ARM: wire up copy_file_range() syscall
[deliverable/linux.git] / arch / arm / mach-omap2 / devices.c
CommitLineData
1dbae815
TL
1/*
2 * linux/arch/arm/mach-omap2/devices.c
3 *
4 * OMAP2 platform device setup/initialization
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
2f8163ba 11#include <linux/gpio.h>
1dbae815
TL
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/platform_device.h>
fced80c7 15#include <linux/io.h>
917fa280 16#include <linux/clk.h>
f2ce6231 17#include <linux/err.h>
1a5d8190 18#include <linux/slab.h>
ad8dfac6 19#include <linux/of.h>
484202f4 20#include <linux/pinctrl/machine.h>
b8a7cf8e 21#include <linux/platform_data/mailbox-omap.h>
1dbae815 22
1dbae815
TL
23#include <asm/mach-types.h>
24#include <asm/mach/map.h>
25
45c3eb7d 26#include <linux/omap-dma.h>
2a296c8f 27
ee0839c2 28#include "iomap.h"
2a296c8f 29#include "omap_hwmod.h"
25c7d49e 30#include "omap_device.h"
1dbae815 31
7d7e1eba
TL
32#include "soc.h"
33#include "common.h"
4896e394 34#include "mux.h"
4814ced5 35#include "control.h"
576e5bda 36#include "display.h"
4896e394 37
0abcf618 38#define L3_MODULES_MAX_LEN 12
a4dc616a 39#define L3_MODULES 3
0abcf618 40
41static int __init omap3_l3_init(void)
42{
0abcf618 43 struct omap_hwmod *oh;
3528c58e 44 struct platform_device *pdev;
0abcf618 45 char oh_name[L3_MODULES_MAX_LEN];
46
47 /*
48 * To avoid code running on other OMAPs in
49 * multi-omap builds
50 */
aa25729c 51 if (!(cpu_is_omap34xx()) || of_have_populated_dt())
0abcf618 52 return -ENODEV;
53
eeb3711b 54 snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main");
0abcf618 55
56 oh = omap_hwmod_lookup(oh_name);
57
58 if (!oh)
59 pr_err("could not look up %s\n", oh_name);
60
c1d1cd59 61 pdev = omap_device_build("omap_l3_smx", 0, oh, NULL, 0);
0abcf618 62
3528c58e 63 WARN(IS_ERR(pdev), "could not build omap_device for %s\n", oh_name);
0abcf618 64
e44be50c 65 return PTR_ERR_OR_ZERO(pdev);
0abcf618 66}
b76c8b19 67omap_postcore_initcall(omap3_l3_init);
0abcf618 68
c869c75c 69#if defined(CONFIG_OMAP2PLUS_MBOX) || defined(CONFIG_OMAP2PLUS_MBOX_MODULE)
9cf793f9 70static inline void __init omap_init_mbox(void)
c40fae95 71{
69dbf857 72 struct omap_hwmod *oh;
3528c58e 73 struct platform_device *pdev;
b8a7cf8e 74 struct omap_mbox_pdata *pdata;
69dbf857
FC
75
76 oh = omap_hwmod_lookup("mailbox");
77 if (!oh) {
78 pr_err("%s: unable to find hwmod\n", __func__);
6c20a683
HD
79 return;
80 }
b8a7cf8e
SA
81 if (!oh->dev_attr) {
82 pr_err("%s: hwmod doesn't have valid attrs\n", __func__);
83 return;
84 }
69dbf857 85
b8a7cf8e
SA
86 pdata = (struct omap_mbox_pdata *)oh->dev_attr;
87 pdev = omap_device_build("omap-mailbox", -1, oh, pdata, sizeof(*pdata));
3528c58e
KH
88 WARN(IS_ERR(pdev), "%s: could not build device, err %ld\n",
89 __func__, PTR_ERR(pdev));
c40fae95
TL
90}
91#else
92static inline void omap_init_mbox(void) { }
c869c75c 93#endif /* CONFIG_OMAP2PLUS_MBOX */
c40fae95 94
9b6553cd 95static inline void omap_init_sti(void) {}
9b6553cd 96
646e3ed1 97#if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
ed7eb9d9 98
2203747c 99#include <linux/platform_data/spi-omap2-mcspi.h>
ed7eb9d9 100
9cf793f9 101static int __init omap_mcspi_init(struct omap_hwmod *oh, void *unused)
af41a12f 102{
3528c58e 103 struct platform_device *pdev;
1a5d8190
C
104 char *name = "omap2_mcspi";
105 struct omap2_mcspi_platform_config *pdata;
106 static int spi_num;
107 struct omap2_mcspi_dev_attr *mcspi_attrib = oh->dev_attr;
108
109 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
110 if (!pdata) {
111 pr_err("Memory allocation for McSPI device failed\n");
112 return -ENOMEM;
113 }
af41a12f 114
1a5d8190
C
115 pdata->num_cs = mcspi_attrib->num_chipselect;
116 switch (oh->class->rev) {
117 case OMAP2_MCSPI_REV:
118 case OMAP3_MCSPI_REV:
119 pdata->regs_offset = 0;
120 break;
121 case OMAP4_MCSPI_REV:
122 pdata->regs_offset = OMAP4_MCSPI_REG_OFFSET;
123 break;
124 default:
125 pr_err("Invalid McSPI Revision value\n");
e0feca89 126 kfree(pdata);
1a5d8190
C
127 return -EINVAL;
128 }
af41a12f 129
1a5d8190 130 spi_num++;
c1d1cd59 131 pdev = omap_device_build(name, spi_num, oh, pdata, sizeof(*pdata));
3528c58e 132 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s\n",
1a5d8190
C
133 name, oh->name);
134 kfree(pdata);
135 return 0;
af41a12f 136}
af41a12f
TL
137
138static void omap_init_mcspi(void)
139{
1a5d8190 140 omap_hwmod_for_each_by_class("mcspi", omap_mcspi_init, NULL);
ed7eb9d9
JY
141}
142
143#else
144static inline void omap_init_mcspi(void) {}
145#endif
146
4848d460
PW
147/**
148 * omap_init_rng - bind the RNG hwmod to the RNG omap_device
149 *
150 * Bind the RNG hwmod to the RNG omap_device. No return value.
151 */
152static void omap_init_rng(void)
153{
154 struct omap_hwmod *oh;
155 struct platform_device *pdev;
156
157 oh = omap_hwmod_lookup("rng");
158 if (!oh)
159 return;
160
c1d1cd59 161 pdev = omap_device_build("omap_rng", -1, oh, NULL, 0);
4848d460
PW
162 WARN(IS_ERR(pdev), "Can't build omap_device for omap_rng\n");
163}
88341334 164
26f88e6e 165static void __init omap_init_sham(void)
646e3ed1 166{
8c7bb573
MG
167 struct omap_hwmod *oh;
168 struct platform_device *pdev;
169
170 oh = omap_hwmod_lookup("sham");
171 if (!oh)
172 return;
173
174 pdev = omap_device_build("omap-sham", -1, oh, NULL, 0);
175 WARN(IS_ERR(pdev), "Can't build omap_device for omap-sham\n");
646e3ed1 176}
646e3ed1 177
14ae5564 178static void __init omap_init_aes(void)
b744c679 179{
77e2fd84
MG
180 struct omap_hwmod *oh;
181 struct platform_device *pdev;
182
183 oh = omap_hwmod_lookup("aes");
184 if (!oh)
185 return;
186
187 pdev = omap_device_build("omap-aes", -1, oh, NULL, 0);
188 WARN(IS_ERR(pdev), "Can't build omap_device for omap-aes\n");
b744c679
DK
189}
190
d8874665
TL
191/*-------------------------------------------------------------------------*/
192
b227358d
VH
193#if defined(CONFIG_VIDEO_OMAP2_VOUT) || \
194 defined(CONFIG_VIDEO_OMAP2_VOUT_MODULE)
195#if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
196static struct resource omap_vout_resource[3 - CONFIG_FB_OMAP2_NUM_FBS] = {
197};
198#else
199static struct resource omap_vout_resource[2] = {
200};
201#endif
202
203static struct platform_device omap_vout_device = {
204 .name = "omap_vout",
205 .num_resources = ARRAY_SIZE(omap_vout_resource),
206 .resource = &omap_vout_resource[0],
207 .id = -1,
208};
576e5bda
AT
209
210int __init omap_init_vout(void)
b227358d 211{
576e5bda 212 return platform_device_register(&omap_vout_device);
b227358d
VH
213}
214#else
576e5bda 215int __init omap_init_vout(void) { return 0; }
b227358d
VH
216#endif
217
1dbae815
TL
218/*-------------------------------------------------------------------------*/
219
220static int __init omap2_init_devices(void)
221{
484202f4
MP
222 /* Enable dummy states for those platforms without pinctrl support */
223 if (!of_have_populated_dt())
224 pinctrl_provide_dummies();
225
efcf1e50 226 /* If dtb is there, the devices will be created dynamically */
259bd6ce 227 if (!of_have_populated_dt()) {
f2e6a0a9
PU
228 /*
229 * please keep these calls, and their implementations above,
230 * in alphabetical order so they're easier to sort through.
231 */
dbd5f460 232 omap_init_mbox();
efcf1e50 233 omap_init_mcspi();
114d7a8b 234 omap_init_sham();
53335acc 235 omap_init_aes();
674ee08f 236 omap_init_rng();
259bd6ce 237 }
9b6553cd 238 omap_init_sti();
1dbae815
TL
239
240 return 0;
241}
b76c8b19 242omap_arch_initcall(omap2_init_devices);
a8612809
TL
243
244static int __init omap_gpmc_init(void)
245{
246 struct omap_hwmod *oh;
247 struct platform_device *pdev;
248 char *oh_name = "gpmc";
249
250 /*
251 * if the board boots up with a populated DT, do not
252 * manually add the device from this initcall
253 */
254 if (of_have_populated_dt())
255 return -ENODEV;
256
257 oh = omap_hwmod_lookup(oh_name);
258 if (!oh) {
259 pr_err("Could not look up %s\n", oh_name);
260 return -ENODEV;
261 }
262
263 pdev = omap_device_build("omap-gpmc", -1, oh, NULL, 0);
264 WARN(IS_ERR(pdev), "could not build omap_device for %s\n", oh_name);
265
e44be50c 266 return PTR_ERR_OR_ZERO(pdev);
a8612809
TL
267}
268omap_postcore_initcall(omap_gpmc_init);
This page took 1.112598 seconds and 5 git commands to generate.