2 * linux/arch/arm/mach-omap2/devices.c
4 * OMAP2 platform device setup/initialization
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.
11 #include <linux/gpio.h>
12 #include <linux/kernel.h>
13 #include <linux/init.h>
14 #include <linux/platform_device.h>
16 #include <linux/clk.h>
17 #include <linux/err.h>
18 #include <linux/slab.h>
20 #include <linux/pinctrl/machine.h>
22 #include <asm/mach-types.h>
23 #include <asm/mach/map.h>
25 #include <linux/omap-dma.h>
28 #include "omap_hwmod.h"
29 #include "omap_device.h"
37 #define L3_MODULES_MAX_LEN 12
40 static int __init
omap3_l3_init(void)
42 struct omap_hwmod
*oh
;
43 struct platform_device
*pdev
;
44 char oh_name
[L3_MODULES_MAX_LEN
];
47 * To avoid code running on other OMAPs in
50 if (!(cpu_is_omap34xx()) || of_have_populated_dt())
53 snprintf(oh_name
, L3_MODULES_MAX_LEN
, "l3_main");
55 oh
= omap_hwmod_lookup(oh_name
);
58 pr_err("could not look up %s\n", oh_name
);
60 pdev
= omap_device_build("omap_l3_smx", 0, oh
, NULL
, 0);
62 WARN(IS_ERR(pdev
), "could not build omap_device for %s\n", oh_name
);
64 return PTR_ERR_OR_ZERO(pdev
);
66 omap_postcore_initcall(omap3_l3_init
);
68 static inline void omap_init_sti(void) {}
70 #if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
72 #include <linux/platform_data/spi-omap2-mcspi.h>
74 static int __init
omap_mcspi_init(struct omap_hwmod
*oh
, void *unused
)
76 struct platform_device
*pdev
;
77 char *name
= "omap2_mcspi";
78 struct omap2_mcspi_platform_config
*pdata
;
80 struct omap2_mcspi_dev_attr
*mcspi_attrib
= oh
->dev_attr
;
82 pdata
= kzalloc(sizeof(*pdata
), GFP_KERNEL
);
84 pr_err("Memory allocation for McSPI device failed\n");
88 pdata
->num_cs
= mcspi_attrib
->num_chipselect
;
89 switch (oh
->class->rev
) {
92 pdata
->regs_offset
= 0;
95 pdata
->regs_offset
= OMAP4_MCSPI_REG_OFFSET
;
98 pr_err("Invalid McSPI Revision value\n");
104 pdev
= omap_device_build(name
, spi_num
, oh
, pdata
, sizeof(*pdata
));
105 WARN(IS_ERR(pdev
), "Can't build omap_device for %s:%s\n",
111 static void omap_init_mcspi(void)
113 omap_hwmod_for_each_by_class("mcspi", omap_mcspi_init
, NULL
);
117 static inline void omap_init_mcspi(void) {}
121 * omap_init_rng - bind the RNG hwmod to the RNG omap_device
123 * Bind the RNG hwmod to the RNG omap_device. No return value.
125 static void omap_init_rng(void)
127 struct omap_hwmod
*oh
;
128 struct platform_device
*pdev
;
130 oh
= omap_hwmod_lookup("rng");
134 pdev
= omap_device_build("omap_rng", -1, oh
, NULL
, 0);
135 WARN(IS_ERR(pdev
), "Can't build omap_device for omap_rng\n");
138 static void __init
omap_init_sham(void)
140 struct omap_hwmod
*oh
;
141 struct platform_device
*pdev
;
143 oh
= omap_hwmod_lookup("sham");
147 pdev
= omap_device_build("omap-sham", -1, oh
, NULL
, 0);
148 WARN(IS_ERR(pdev
), "Can't build omap_device for omap-sham\n");
151 static void __init
omap_init_aes(void)
153 struct omap_hwmod
*oh
;
154 struct platform_device
*pdev
;
156 oh
= omap_hwmod_lookup("aes");
160 pdev
= omap_device_build("omap-aes", -1, oh
, NULL
, 0);
161 WARN(IS_ERR(pdev
), "Can't build omap_device for omap-aes\n");
164 /*-------------------------------------------------------------------------*/
166 #if defined(CONFIG_VIDEO_OMAP2_VOUT) || \
167 defined(CONFIG_VIDEO_OMAP2_VOUT_MODULE)
168 #if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
169 static struct resource omap_vout_resource
[3 - CONFIG_FB_OMAP2_NUM_FBS
] = {
172 static struct resource omap_vout_resource
[2] = {
176 static struct platform_device omap_vout_device
= {
178 .num_resources
= ARRAY_SIZE(omap_vout_resource
),
179 .resource
= &omap_vout_resource
[0],
183 int __init
omap_init_vout(void)
185 return platform_device_register(&omap_vout_device
);
188 int __init
omap_init_vout(void) { return 0; }
191 /*-------------------------------------------------------------------------*/
193 static int __init
omap2_init_devices(void)
195 /* Enable dummy states for those platforms without pinctrl support */
196 if (!of_have_populated_dt())
197 pinctrl_provide_dummies();
199 /* If dtb is there, the devices will be created dynamically */
200 if (!of_have_populated_dt()) {
202 * please keep these calls, and their implementations above,
203 * in alphabetical order so they're easier to sort through.
214 omap_arch_initcall(omap2_init_devices
);
216 static int __init
omap_gpmc_init(void)
218 struct omap_hwmod
*oh
;
219 struct platform_device
*pdev
;
220 char *oh_name
= "gpmc";
223 * if the board boots up with a populated DT, do not
224 * manually add the device from this initcall
226 if (of_have_populated_dt())
229 oh
= omap_hwmod_lookup(oh_name
);
231 pr_err("Could not look up %s\n", oh_name
);
235 pdev
= omap_device_build("omap-gpmc", -1, oh
, NULL
, 0);
236 WARN(IS_ERR(pdev
), "could not build omap_device for %s\n", oh_name
);
238 return PTR_ERR_OR_ZERO(pdev
);
240 omap_postcore_initcall(omap_gpmc_init
);