blob: 3c1279f27d1fe4436595e94fb4977707a5f5fadb [file] [log] [blame]
Tony Lindgren1dbae812005-11-10 14:26:51 +00001/*
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 */
Russell King2f8163b2011-07-26 10:53:52 +010011#include <linux/gpio.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000012#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/platform_device.h>
Russell Kingfced80c2008-09-06 12:10:45 +010015#include <linux/io.h>
Kevin Hilman917fa282008-12-10 17:37:17 -080016#include <linux/clk.h>
Varadarajan, Charulathaf2ce6232010-09-23 20:02:42 +053017#include <linux/err.h>
Charulatha V1a5d8192011-02-02 17:52:14 +053018#include <linux/slab.h>
Benoit Coussonad8dfac2011-08-12 13:48:47 +020019#include <linux/of.h>
Matt Porter484202f2012-09-17 16:26:11 -070020#include <linux/pinctrl/machine.h>
Felipe Balbi0f1142a2012-03-16 22:47:48 -070021#include <linux/platform_data/omap4-keypad.h>
Tony Lindgren26f45c22013-05-17 10:45:10 -070022#include <linux/wl12xx.h>
Suman Annab8a7cf82013-01-28 17:21:58 -060023#include <linux/platform_data/mailbox-omap.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000024
Tony Lindgren1dbae812005-11-10 14:26:51 +000025#include <asm/mach-types.h>
26#include <asm/mach/map.h>
27
Tony Lindgren45c3eb72012-11-30 08:41:50 -080028#include <linux/omap-dma.h>
Tony Lindgren2a296c82012-10-02 17:41:35 -070029
Tony Lindgrenee0839c2012-02-24 10:34:35 -080030#include "iomap.h"
Tony Lindgren2a296c82012-10-02 17:41:35 -070031#include "omap_hwmod.h"
Tony Lindgren25c7d492012-10-02 17:25:48 -070032#include "omap_device.h"
Tony Lindgren0e701562012-09-20 11:42:20 -070033#include "omap4-keypad.h"
Tony Lindgren1dbae812005-11-10 14:26:51 +000034
Tony Lindgren7d7e1eb2012-08-27 17:43:01 -070035#include "soc.h"
36#include "common.h"
Tony Lindgren4896e392009-12-11 16:16:32 -080037#include "mux.h"
Paul Walmsley4814ced2010-10-08 11:40:20 -060038#include "control.h"
Laurent Pincharta11f6702009-12-14 08:09:07 -030039#include "devices.h"
Tony Lindgren4896e392009-12-11 16:16:32 -080040
sricharan0abcf612011-02-08 14:10:45 +053041#define L3_MODULES_MAX_LEN 12
sricharana4dc6162011-03-09 16:00:29 +053042#define L3_MODULES 3
sricharan0abcf612011-02-08 14:10:45 +053043
44static int __init omap3_l3_init(void)
45{
sricharan0abcf612011-02-08 14:10:45 +053046 struct omap_hwmod *oh;
Kevin Hilman3528c582011-07-21 13:48:45 -070047 struct platform_device *pdev;
sricharan0abcf612011-02-08 14:10:45 +053048 char oh_name[L3_MODULES_MAX_LEN];
49
50 /*
51 * To avoid code running on other OMAPs in
52 * multi-omap builds
53 */
54 if (!(cpu_is_omap34xx()))
55 return -ENODEV;
56
Paul Walmsleyeeb37112012-04-13 06:34:32 -060057 snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main");
sricharan0abcf612011-02-08 14:10:45 +053058
59 oh = omap_hwmod_lookup(oh_name);
60
61 if (!oh)
62 pr_err("could not look up %s\n", oh_name);
63
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -070064 pdev = omap_device_build("omap_l3_smx", 0, oh, NULL, 0);
sricharan0abcf612011-02-08 14:10:45 +053065
Kevin Hilman3528c582011-07-21 13:48:45 -070066 WARN(IS_ERR(pdev), "could not build omap_device for %s\n", oh_name);
sricharan0abcf612011-02-08 14:10:45 +053067
Thomas Meyer12616742013-06-01 11:44:44 +020068 return PTR_RET(pdev);
sricharan0abcf612011-02-08 14:10:45 +053069}
Tony Lindgrenb76c8b12013-01-11 11:24:18 -080070omap_postcore_initcall(omap3_l3_init);
sricharan0abcf612011-02-08 14:10:45 +053071
sricharana4dc6162011-03-09 16:00:29 +053072static int __init omap4_l3_init(void)
73{
Paul Walmsleyeeb37112012-04-13 06:34:32 -060074 int i;
sricharana4dc6162011-03-09 16:00:29 +053075 struct omap_hwmod *oh[3];
Kevin Hilman3528c582011-07-21 13:48:45 -070076 struct platform_device *pdev;
sricharana4dc6162011-03-09 16:00:29 +053077 char oh_name[L3_MODULES_MAX_LEN];
78
Benoit Coussonad8dfac2011-08-12 13:48:47 +020079 /* If dtb is there, the devices will be created dynamically */
80 if (of_have_populated_dt())
81 return -ENODEV;
82
sricharana4dc6162011-03-09 16:00:29 +053083 /*
84 * To avoid code running on other OMAPs in
85 * multi-omap builds
86 */
R Sricharane17933c2011-11-04 15:52:59 +053087 if (!cpu_is_omap44xx() && !soc_is_omap54xx())
sricharana4dc6162011-03-09 16:00:29 +053088 return -ENODEV;
89
90 for (i = 0; i < L3_MODULES; i++) {
Paul Walmsleyeeb37112012-04-13 06:34:32 -060091 snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main_%d", i+1);
sricharana4dc6162011-03-09 16:00:29 +053092
93 oh[i] = omap_hwmod_lookup(oh_name);
94 if (!(oh[i]))
95 pr_err("could not look up %s\n", oh_name);
96 }
97
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -070098 pdev = omap_device_build_ss("omap_l3_noc", 0, oh, 3, NULL, 0);
sricharana4dc6162011-03-09 16:00:29 +053099
Kevin Hilman3528c582011-07-21 13:48:45 -0700100 WARN(IS_ERR(pdev), "could not build omap_device for %s\n", oh_name);
sricharana4dc6162011-03-09 16:00:29 +0530101
Thomas Meyer12616742013-06-01 11:44:44 +0200102 return PTR_RET(pdev);
sricharana4dc6162011-03-09 16:00:29 +0530103}
Tony Lindgrenb76c8b12013-01-11 11:24:18 -0800104omap_postcore_initcall(omap4_l3_init);
sricharana4dc6162011-03-09 16:00:29 +0530105
Tony Lindgren828c7072009-03-23 18:23:49 -0700106#if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800107
Sergio Aguirrecfe2cde2010-11-15 11:29:54 -0300108static struct resource omap2cam_resources[] = {
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800109 {
Tony Lindgren828c7072009-03-23 18:23:49 -0700110 .start = OMAP24XX_CAMERA_BASE,
111 .end = OMAP24XX_CAMERA_BASE + 0xfff,
112 .flags = IORESOURCE_MEM,
113 },
114 {
Tony Lindgren7d7e1eb2012-08-27 17:43:01 -0700115 .start = 24 + OMAP_INTC_START,
Tony Lindgren828c7072009-03-23 18:23:49 -0700116 .flags = IORESOURCE_IRQ,
117 }
118};
119
Sergio Aguirrecfe2cde2010-11-15 11:29:54 -0300120static struct platform_device omap2cam_device = {
Tony Lindgren828c7072009-03-23 18:23:49 -0700121 .name = "omap24xxcam",
122 .id = -1,
Sergio Aguirrecfe2cde2010-11-15 11:29:54 -0300123 .num_resources = ARRAY_SIZE(omap2cam_resources),
124 .resource = omap2cam_resources,
Tony Lindgren828c7072009-03-23 18:23:49 -0700125};
Laurent Pincharta11f6702009-12-14 08:09:07 -0300126#endif
Tony Lindgren828c7072009-03-23 18:23:49 -0700127
Ohad Ben-Cohen1a51a0c2012-01-11 15:28:11 +0200128#if defined(CONFIG_IOMMU_API)
129
Tony Lindgren2ab7c842012-11-02 12:24:14 -0700130#include <linux/platform_data/iommu-omap.h>
Ohad Ben-Cohen1a51a0c2012-01-11 15:28:11 +0200131
Tony Lindgren828c7072009-03-23 18:23:49 -0700132static struct resource omap3isp_resources[] = {
133 {
134 .start = OMAP3430_ISP_BASE,
135 .end = OMAP3430_ISP_END,
136 .flags = IORESOURCE_MEM,
137 },
138 {
Tony Lindgren828c7072009-03-23 18:23:49 -0700139 .start = OMAP3430_ISP_CCP2_BASE,
140 .end = OMAP3430_ISP_CCP2_END,
141 .flags = IORESOURCE_MEM,
142 },
143 {
144 .start = OMAP3430_ISP_CCDC_BASE,
145 .end = OMAP3430_ISP_CCDC_END,
146 .flags = IORESOURCE_MEM,
147 },
148 {
149 .start = OMAP3430_ISP_HIST_BASE,
150 .end = OMAP3430_ISP_HIST_END,
151 .flags = IORESOURCE_MEM,
152 },
153 {
154 .start = OMAP3430_ISP_H3A_BASE,
155 .end = OMAP3430_ISP_H3A_END,
156 .flags = IORESOURCE_MEM,
157 },
158 {
159 .start = OMAP3430_ISP_PREV_BASE,
160 .end = OMAP3430_ISP_PREV_END,
161 .flags = IORESOURCE_MEM,
162 },
163 {
164 .start = OMAP3430_ISP_RESZ_BASE,
165 .end = OMAP3430_ISP_RESZ_END,
166 .flags = IORESOURCE_MEM,
167 },
168 {
169 .start = OMAP3430_ISP_SBL_BASE,
170 .end = OMAP3430_ISP_SBL_END,
171 .flags = IORESOURCE_MEM,
172 },
173 {
Tuukka Toivonen6817a692010-02-02 11:17:33 -0300174 .start = OMAP3430_ISP_CSI2A_REGS1_BASE,
175 .end = OMAP3430_ISP_CSI2A_REGS1_END,
Tony Lindgren828c7072009-03-23 18:23:49 -0700176 .flags = IORESOURCE_MEM,
177 },
178 {
Tuukka Toivonen6817a692010-02-02 11:17:33 -0300179 .start = OMAP3430_ISP_CSIPHY2_BASE,
180 .end = OMAP3430_ISP_CSIPHY2_END,
181 .flags = IORESOURCE_MEM,
182 },
183 {
184 .start = OMAP3630_ISP_CSI2A_REGS2_BASE,
185 .end = OMAP3630_ISP_CSI2A_REGS2_END,
186 .flags = IORESOURCE_MEM,
187 },
188 {
189 .start = OMAP3630_ISP_CSI2C_REGS1_BASE,
190 .end = OMAP3630_ISP_CSI2C_REGS1_END,
191 .flags = IORESOURCE_MEM,
192 },
193 {
194 .start = OMAP3630_ISP_CSIPHY1_BASE,
195 .end = OMAP3630_ISP_CSIPHY1_END,
196 .flags = IORESOURCE_MEM,
197 },
198 {
199 .start = OMAP3630_ISP_CSI2C_REGS2_BASE,
200 .end = OMAP3630_ISP_CSI2C_REGS2_END,
Tony Lindgren828c7072009-03-23 18:23:49 -0700201 .flags = IORESOURCE_MEM,
202 },
203 {
Sakari Ailusc19d19e2012-10-14 07:31:48 -0300204 .start = OMAP343X_CTRL_BASE + OMAP343X_CONTROL_CSIRXFE,
205 .end = OMAP343X_CTRL_BASE + OMAP343X_CONTROL_CSIRXFE + 3,
206 .flags = IORESOURCE_MEM,
207 },
208 {
209 .start = OMAP343X_CTRL_BASE + OMAP3630_CONTROL_CAMERA_PHY_CTRL,
210 .end = OMAP343X_CTRL_BASE + OMAP3630_CONTROL_CAMERA_PHY_CTRL + 3,
211 .flags = IORESOURCE_MEM,
212 },
213 {
Tony Lindgren7d7e1eb2012-08-27 17:43:01 -0700214 .start = 24 + OMAP_INTC_START,
Tony Lindgren828c7072009-03-23 18:23:49 -0700215 .flags = IORESOURCE_IRQ,
216 }
217};
218
219static struct platform_device omap3isp_device = {
220 .name = "omap3isp",
221 .id = -1,
222 .num_resources = ARRAY_SIZE(omap3isp_resources),
223 .resource = omap3isp_resources,
224};
225
Ohad Ben-Cohenc8eaab32011-09-23 16:44:57 +0300226static struct omap_iommu_arch_data omap3_isp_iommu = {
Omar Ramirez Luna72b15b62012-11-19 19:05:50 -0600227 .name = "mmu_isp",
Ohad Ben-Cohenc8eaab32011-09-23 16:44:57 +0300228};
229
Laurent Pincharta11f6702009-12-14 08:09:07 -0300230int omap3_init_camera(struct isp_platform_data *pdata)
Tony Lindgren828c7072009-03-23 18:23:49 -0700231{
Laurent Pincharta11f6702009-12-14 08:09:07 -0300232 omap3isp_device.dev.platform_data = pdata;
Ohad Ben-Cohenc8eaab32011-09-23 16:44:57 +0300233 omap3isp_device.dev.archdata.iommu = &omap3_isp_iommu;
234
Laurent Pincharta11f6702009-12-14 08:09:07 -0300235 return platform_device_register(&omap3isp_device);
Tony Lindgren828c7072009-03-23 18:23:49 -0700236}
Tony Lindgren828c7072009-03-23 18:23:49 -0700237
Ohad Ben-Cohen1a51a0c2012-01-11 15:28:11 +0200238#else /* !CONFIG_IOMMU_API */
239
240int omap3_init_camera(struct isp_platform_data *pdata)
241{
242 return 0;
243}
244
245#endif
246
Tony Lindgren1dbae812005-11-10 14:26:51 +0000247static inline void omap_init_camera(void)
248{
Sergio Aguirrecfe2cde2010-11-15 11:29:54 -0300249#if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
250 if (cpu_is_omap24xx())
251 platform_device_register(&omap2cam_device);
Tony Lindgren1dbae812005-11-10 14:26:51 +0000252#endif
Sergio Aguirrecfe2cde2010-11-15 11:29:54 -0300253}
Tony Lindgren1dbae812005-11-10 14:26:51 +0000254
Syed Rafiuddin59556762010-12-27 05:51:45 +0000255int __init omap4_keyboard_init(struct omap4_keypad_platform_data
Shubhrajyoti Dattaf67df6c2011-07-05 03:38:24 -0700256 *sdp4430_keypad_data, struct omap_board_data *bdata)
Syed Rafiuddin59556762010-12-27 05:51:45 +0000257{
Kevin Hilman3528c582011-07-21 13:48:45 -0700258 struct platform_device *pdev;
Syed Rafiuddin59556762010-12-27 05:51:45 +0000259 struct omap_hwmod *oh;
260 struct omap4_keypad_platform_data *keypad_data;
261 unsigned int id = -1;
262 char *oh_name = "kbd";
263 char *name = "omap4-keypad";
264
265 oh = omap_hwmod_lookup(oh_name);
266 if (!oh) {
267 pr_err("Could not look up %s\n", oh_name);
268 return -ENODEV;
269 }
270
271 keypad_data = sdp4430_keypad_data;
272
Kevin Hilman3528c582011-07-21 13:48:45 -0700273 pdev = omap_device_build(name, id, oh, keypad_data,
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -0700274 sizeof(struct omap4_keypad_platform_data));
Syed Rafiuddin59556762010-12-27 05:51:45 +0000275
Kevin Hilman3528c582011-07-21 13:48:45 -0700276 if (IS_ERR(pdev)) {
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300277 WARN(1, "Can't build omap_device for %s:%s.\n",
Syed Rafiuddin59556762010-12-27 05:51:45 +0000278 name, oh->name);
Kevin Hilman3528c582011-07-21 13:48:45 -0700279 return PTR_ERR(pdev);
Syed Rafiuddin59556762010-12-27 05:51:45 +0000280 }
Shubhrajyoti Dattaf67df6c2011-07-05 03:38:24 -0700281 oh->mux = omap_hwmod_mux_init(bdata->pads, bdata->pads_cnt);
Syed Rafiuddin59556762010-12-27 05:51:45 +0000282
283 return 0;
284}
285
Suman Annac869c752013-03-12 17:55:29 -0500286#if defined(CONFIG_OMAP2PLUS_MBOX) || defined(CONFIG_OMAP2PLUS_MBOX_MODULE)
Kevin Hilman9cf793f2012-02-20 09:43:30 -0800287static inline void __init omap_init_mbox(void)
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800288{
Felipe Contreras69dbf852011-02-24 12:51:33 -0800289 struct omap_hwmod *oh;
Kevin Hilman3528c582011-07-21 13:48:45 -0700290 struct platform_device *pdev;
Suman Annab8a7cf82013-01-28 17:21:58 -0600291 struct omap_mbox_pdata *pdata;
Felipe Contreras69dbf852011-02-24 12:51:33 -0800292
293 oh = omap_hwmod_lookup("mailbox");
294 if (!oh) {
295 pr_err("%s: unable to find hwmod\n", __func__);
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700296 return;
297 }
Suman Annab8a7cf82013-01-28 17:21:58 -0600298 if (!oh->dev_attr) {
299 pr_err("%s: hwmod doesn't have valid attrs\n", __func__);
300 return;
301 }
Felipe Contreras69dbf852011-02-24 12:51:33 -0800302
Suman Annab8a7cf82013-01-28 17:21:58 -0600303 pdata = (struct omap_mbox_pdata *)oh->dev_attr;
304 pdev = omap_device_build("omap-mailbox", -1, oh, pdata, sizeof(*pdata));
Kevin Hilman3528c582011-07-21 13:48:45 -0700305 WARN(IS_ERR(pdev), "%s: could not build device, err %ld\n",
306 __func__, PTR_ERR(pdev));
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800307}
308#else
309static inline void omap_init_mbox(void) { }
Suman Annac869c752013-03-12 17:55:29 -0500310#endif /* CONFIG_OMAP2PLUS_MBOX */
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800311
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100312static inline void omap_init_sti(void) {}
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100313
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000314#if defined(CONFIG_SND_SOC) || defined(CONFIG_SND_SOC_MODULE)
315
316static struct platform_device omap_pcm = {
317 .name = "omap-pcm-audio",
318 .id = -1,
319};
320
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000321static void omap_init_audio(void)
322{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000323 platform_device_register(&omap_pcm);
324}
325
326#else
327static inline void omap_init_audio(void) {}
328#endif
329
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600330#if defined(CONFIG_SND_OMAP_SOC_MCPDM) || \
331 defined(CONFIG_SND_OMAP_SOC_MCPDM_MODULE)
332
Kevin Hilman9cf793f2012-02-20 09:43:30 -0800333static void __init omap_init_mcpdm(void)
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600334{
335 struct omap_hwmod *oh;
Peter Ujfalusi927dbbb2011-11-03 10:41:22 +0200336 struct platform_device *pdev;
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600337
338 oh = omap_hwmod_lookup("mcpdm");
Peter Ujfalusi5fe0a122013-06-11 10:31:58 +0200339 if (!oh)
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600340 return;
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600341
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -0700342 pdev = omap_device_build("omap-mcpdm", -1, oh, NULL, 0);
Peter Ujfalusi927dbbb2011-11-03 10:41:22 +0200343 WARN(IS_ERR(pdev), "Can't build omap_device for omap-mcpdm.\n");
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600344}
345#else
346static inline void omap_init_mcpdm(void) {}
347#endif
348
Peter Ujfaluside9eb092011-12-13 10:48:54 -0800349#if defined(CONFIG_SND_OMAP_SOC_DMIC) || \
350 defined(CONFIG_SND_OMAP_SOC_DMIC_MODULE)
351
Kevin Hilman9cf793f2012-02-20 09:43:30 -0800352static void __init omap_init_dmic(void)
Peter Ujfaluside9eb092011-12-13 10:48:54 -0800353{
354 struct omap_hwmod *oh;
355 struct platform_device *pdev;
356
357 oh = omap_hwmod_lookup("dmic");
Peter Ujfalusi6d931cf2013-06-11 10:31:59 +0200358 if (!oh)
Peter Ujfaluside9eb092011-12-13 10:48:54 -0800359 return;
Peter Ujfaluside9eb092011-12-13 10:48:54 -0800360
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -0700361 pdev = omap_device_build("omap-dmic", -1, oh, NULL, 0);
Peter Ujfaluside9eb092011-12-13 10:48:54 -0800362 WARN(IS_ERR(pdev), "Can't build omap_device for omap-dmic.\n");
363}
364#else
365static inline void omap_init_dmic(void) {}
366#endif
367
Ricardo Neri5eeec212012-05-09 14:19:14 -0700368#if defined(CONFIG_SND_OMAP_SOC_OMAP_HDMI) || \
369 defined(CONFIG_SND_OMAP_SOC_OMAP_HDMI_MODULE)
370
371static struct platform_device omap_hdmi_audio = {
372 .name = "omap-hdmi-audio",
373 .id = -1,
374};
375
376static void __init omap_init_hdmi_audio(void)
377{
378 struct omap_hwmod *oh;
379 struct platform_device *pdev;
380
381 oh = omap_hwmod_lookup("dss_hdmi");
Peter Ujfalusi7252db52013-06-11 10:32:00 +0200382 if (!oh)
Ricardo Neri5eeec212012-05-09 14:19:14 -0700383 return;
Ricardo Neri5eeec212012-05-09 14:19:14 -0700384
Paul Walmsley6efc3fe2013-02-12 03:58:35 +0000385 pdev = omap_device_build("omap-hdmi-audio-dai", -1, oh, NULL, 0);
Ricardo Neri5eeec212012-05-09 14:19:14 -0700386 WARN(IS_ERR(pdev),
387 "Can't build omap_device for omap-hdmi-audio-dai.\n");
388
389 platform_device_register(&omap_hdmi_audio);
390}
391#else
392static inline void omap_init_hdmi_audio(void) {}
393#endif
394
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300395#if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700396
Arnd Bergmann22037472012-08-24 15:21:06 +0200397#include <linux/platform_data/spi-omap2-mcspi.h>
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700398
Kevin Hilman9cf793f2012-02-20 09:43:30 -0800399static int __init omap_mcspi_init(struct omap_hwmod *oh, void *unused)
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700400{
Kevin Hilman3528c582011-07-21 13:48:45 -0700401 struct platform_device *pdev;
Charulatha V1a5d8192011-02-02 17:52:14 +0530402 char *name = "omap2_mcspi";
403 struct omap2_mcspi_platform_config *pdata;
404 static int spi_num;
405 struct omap2_mcspi_dev_attr *mcspi_attrib = oh->dev_attr;
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700406
Charulatha V1a5d8192011-02-02 17:52:14 +0530407 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
408 if (!pdata) {
409 pr_err("Memory allocation for McSPI device failed\n");
410 return -ENOMEM;
411 }
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700412
Charulatha V1a5d8192011-02-02 17:52:14 +0530413 pdata->num_cs = mcspi_attrib->num_chipselect;
414 switch (oh->class->rev) {
415 case OMAP2_MCSPI_REV:
416 case OMAP3_MCSPI_REV:
417 pdata->regs_offset = 0;
418 break;
419 case OMAP4_MCSPI_REV:
420 pdata->regs_offset = OMAP4_MCSPI_REG_OFFSET;
421 break;
422 default:
423 pr_err("Invalid McSPI Revision value\n");
Julia Lawalle0feca892011-12-23 18:39:31 +0100424 kfree(pdata);
Charulatha V1a5d8192011-02-02 17:52:14 +0530425 return -EINVAL;
426 }
427
428 spi_num++;
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -0700429 pdev = omap_device_build(name, spi_num, oh, pdata, sizeof(*pdata));
Kevin Hilman3528c582011-07-21 13:48:45 -0700430 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s\n",
Charulatha V1a5d8192011-02-02 17:52:14 +0530431 name, oh->name);
432 kfree(pdata);
433 return 0;
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700434}
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700435
436static void omap_init_mcspi(void)
437{
Charulatha V1a5d8192011-02-02 17:52:14 +0530438 omap_hwmod_for_each_by_class("mcspi", omap_mcspi_init, NULL);
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700439}
440
441#else
442static inline void omap_init_mcspi(void) {}
443#endif
444
Paul Walmsley4848d462012-09-23 17:28:27 -0600445/**
446 * omap_init_rng - bind the RNG hwmod to the RNG omap_device
447 *
448 * Bind the RNG hwmod to the RNG omap_device. No return value.
449 */
450static void omap_init_rng(void)
451{
452 struct omap_hwmod *oh;
453 struct platform_device *pdev;
454
455 oh = omap_hwmod_lookup("rng");
456 if (!oh)
457 return;
458
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -0700459 pdev = omap_device_build("omap_rng", -1, oh, NULL, 0);
Paul Walmsley4848d462012-09-23 17:28:27 -0600460 WARN(IS_ERR(pdev), "Can't build omap_device for omap_rng\n");
461}
Will Deacon88341332010-04-09 13:54:43 +0100462
Mark A. Greer26f88e62013-03-18 10:06:32 -0600463static void __init omap_init_sham(void)
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300464{
Mark A. Greer8c7bb572013-03-18 10:06:33 -0600465 struct omap_hwmod *oh;
466 struct platform_device *pdev;
Mark A. Greere569e992013-03-30 15:49:19 -0600467
Mark A. Greer8c7bb572013-03-18 10:06:33 -0600468 oh = omap_hwmod_lookup("sham");
469 if (!oh)
470 return;
Mark A. Greere569e992013-03-30 15:49:19 -0600471
Mark A. Greer8c7bb572013-03-18 10:06:33 -0600472 pdev = omap_device_build("omap-sham", -1, oh, NULL, 0);
473 WARN(IS_ERR(pdev), "Can't build omap_device for omap-sham\n");
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300474}
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300475
Mark A. Greer14ae5562012-12-21 09:28:10 -0700476static void __init omap_init_aes(void)
Dmitry Kasatkinb744c672010-09-03 19:13:55 +0800477{
Mark A. Greer77e2fd82012-12-21 09:28:11 -0700478 struct omap_hwmod *oh;
479 struct platform_device *pdev;
Mark A. Greer660ffd62012-12-21 09:28:09 -0700480
Mark A. Greer77e2fd82012-12-21 09:28:11 -0700481 oh = omap_hwmod_lookup("aes");
482 if (!oh)
483 return;
Mark A. Greer660ffd62012-12-21 09:28:09 -0700484
Mark A. Greer77e2fd82012-12-21 09:28:11 -0700485 pdev = omap_device_build("omap-aes", -1, oh, NULL, 0);
486 WARN(IS_ERR(pdev), "Can't build omap_device for omap-aes\n");
Dmitry Kasatkinb744c672010-09-03 19:13:55 +0800487}
488
Tony Lindgrend8874662008-12-10 17:37:16 -0800489/*-------------------------------------------------------------------------*/
490
Vaibhav Hiremathb2273582010-05-10 14:29:14 -0700491#if defined(CONFIG_VIDEO_OMAP2_VOUT) || \
492 defined(CONFIG_VIDEO_OMAP2_VOUT_MODULE)
493#if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
494static struct resource omap_vout_resource[3 - CONFIG_FB_OMAP2_NUM_FBS] = {
495};
496#else
497static struct resource omap_vout_resource[2] = {
498};
499#endif
500
501static struct platform_device omap_vout_device = {
502 .name = "omap_vout",
503 .num_resources = ARRAY_SIZE(omap_vout_resource),
504 .resource = &omap_vout_resource[0],
505 .id = -1,
506};
507static void omap_init_vout(void)
508{
509 if (platform_device_register(&omap_vout_device) < 0)
510 printk(KERN_ERR "Unable to register OMAP-VOUT device\n");
511}
512#else
513static inline void omap_init_vout(void) {}
514#endif
515
Tony Lindgren26f45c22013-05-17 10:45:10 -0700516#if IS_ENABLED(CONFIG_WL12XX)
517
518static struct wl12xx_platform_data wl12xx __initdata;
519
520void __init omap_init_wl12xx_of(void)
Kishon Vijay Abraham I459bc972012-10-27 19:05:56 +0530521{
Tony Lindgren26f45c22013-05-17 10:45:10 -0700522 int ret;
Kishon Vijay Abraham I459bc972012-10-27 19:05:56 +0530523
Tony Lindgren26f45c22013-05-17 10:45:10 -0700524 if (!of_have_populated_dt())
Kishon Vijay Abraham I459bc972012-10-27 19:05:56 +0530525 return;
526
Tony Lindgren26f45c22013-05-17 10:45:10 -0700527 if (of_machine_is_compatible("ti,omap4-sdp")) {
528 wl12xx.board_ref_clock = WL12XX_REFCLOCK_26;
529 wl12xx.board_tcxo_clock = WL12XX_TCXOCLOCK_26;
530 wl12xx.irq = gpio_to_irq(53);
531 } else if (of_machine_is_compatible("ti,omap4-panda")) {
532 wl12xx.board_ref_clock = WL12XX_REFCLOCK_38;
533 wl12xx.irq = gpio_to_irq(53);
534 } else {
Kishon Vijay Abraham I459bc972012-10-27 19:05:56 +0530535 return;
536 }
537
Tony Lindgren26f45c22013-05-17 10:45:10 -0700538 ret = wl12xx_set_platform_data(&wl12xx);
539 if (ret) {
540 pr_err("error setting wl12xx data: %d\n", ret);
Kishon Vijay Abraham I459bc972012-10-27 19:05:56 +0530541 return;
542 }
543}
544#else
Tony Lindgren26f45c22013-05-17 10:45:10 -0700545static inline void omap_init_wl12xx_of(void)
546{
547}
Kishon Vijay Abraham I459bc972012-10-27 19:05:56 +0530548#endif
549
Tony Lindgren1dbae812005-11-10 14:26:51 +0000550/*-------------------------------------------------------------------------*/
551
552static int __init omap2_init_devices(void)
553{
Matt Porter484202f2012-09-17 16:26:11 -0700554 /* Enable dummy states for those platforms without pinctrl support */
555 if (!of_have_populated_dt())
556 pinctrl_provide_dummies();
557
Paul Walmsley81fbc5ef2010-12-21 19:56:17 -0700558 /*
559 * please keep these calls, and their implementations above,
Tony Lindgren1dbae812005-11-10 14:26:51 +0000560 * in alphabetical order so they're easier to sort through.
561 */
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000562 omap_init_audio();
Tony Lindgren828c7072009-03-23 18:23:49 -0700563 omap_init_camera();
Ricardo Neri5eeec212012-05-09 14:19:14 -0700564 omap_init_hdmi_audio();
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800565 omap_init_mbox();
Benoit Coussonefcf1e52012-01-20 14:15:58 +0100566 /* If dtb is there, the devices will be created dynamically */
Peter Ujfalusi259bd6c2012-05-02 15:23:18 +0300567 if (!of_have_populated_dt()) {
568 omap_init_dmic();
Peter Ujfalusi4b21ffc2012-05-02 15:23:19 +0300569 omap_init_mcpdm();
Benoit Coussonefcf1e52012-01-20 14:15:58 +0100570 omap_init_mcspi();
Mark A. Greer114d7a82013-03-18 10:06:33 -0600571 omap_init_sham();
Mark A. Greer53335ac2012-12-21 09:28:12 -0700572 omap_init_aes();
Tony Lindgren26f45c22013-05-17 10:45:10 -0700573 } else {
574 /* These can be removed when bindings are done */
575 omap_init_wl12xx_of();
Peter Ujfalusi259bd6c2012-05-02 15:23:18 +0300576 }
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100577 omap_init_sti();
Paul Walmsley4848d462012-09-23 17:28:27 -0600578 omap_init_rng();
Vaibhav Hiremathb2273582010-05-10 14:29:14 -0700579 omap_init_vout();
Tony Lindgren1dbae812005-11-10 14:26:51 +0000580
581 return 0;
582}
Tony Lindgrenb76c8b12013-01-11 11:24:18 -0800583omap_arch_initcall(omap2_init_devices);