blob: aef96e45cb2049c2cebba2ad50e1e8a0a8036225 [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>
Tony Lindgren26f45c22013-05-17 10:45:10 -070018#include <linux/gpio.h>
Charulatha V1a5d8192011-02-02 17:52:14 +053019#include <linux/slab.h>
Benoit Coussonad8dfac2011-08-12 13:48:47 +020020#include <linux/of.h>
Matt Porter484202f2012-09-17 16:26:11 -070021#include <linux/pinctrl/machine.h>
Felipe Balbi0f1142a2012-03-16 22:47:48 -070022#include <linux/platform_data/omap4-keypad.h>
Tony Lindgren26f45c22013-05-17 10:45:10 -070023#include <linux/wl12xx.h>
Suman Annab8a7cf82013-01-28 17:21:58 -060024#include <linux/platform_data/mailbox-omap.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000025
Tony Lindgren1dbae812005-11-10 14:26:51 +000026#include <asm/mach-types.h>
27#include <asm/mach/map.h>
28
Tony Lindgren45c3eb72012-11-30 08:41:50 -080029#include <linux/omap-dma.h>
Tony Lindgren2a296c82012-10-02 17:41:35 -070030
Tony Lindgrenee0839c2012-02-24 10:34:35 -080031#include "iomap.h"
Tony Lindgren2a296c82012-10-02 17:41:35 -070032#include "omap_hwmod.h"
Tony Lindgren25c7d492012-10-02 17:25:48 -070033#include "omap_device.h"
Tony Lindgren0e701562012-09-20 11:42:20 -070034#include "omap4-keypad.h"
Tony Lindgren1dbae812005-11-10 14:26:51 +000035
Tony Lindgren7d7e1eb2012-08-27 17:43:01 -070036#include "soc.h"
37#include "common.h"
Tony Lindgren4896e392009-12-11 16:16:32 -080038#include "mux.h"
Paul Walmsley4814ced2010-10-08 11:40:20 -060039#include "control.h"
Laurent Pincharta11f6702009-12-14 08:09:07 -030040#include "devices.h"
Tony Lindgren4896e392009-12-11 16:16:32 -080041
sricharan0abcf612011-02-08 14:10:45 +053042#define L3_MODULES_MAX_LEN 12
sricharana4dc6162011-03-09 16:00:29 +053043#define L3_MODULES 3
sricharan0abcf612011-02-08 14:10:45 +053044
45static int __init omap3_l3_init(void)
46{
sricharan0abcf612011-02-08 14:10:45 +053047 struct omap_hwmod *oh;
Kevin Hilman3528c582011-07-21 13:48:45 -070048 struct platform_device *pdev;
sricharan0abcf612011-02-08 14:10:45 +053049 char oh_name[L3_MODULES_MAX_LEN];
50
51 /*
52 * To avoid code running on other OMAPs in
53 * multi-omap builds
54 */
55 if (!(cpu_is_omap34xx()))
56 return -ENODEV;
57
Paul Walmsleyeeb37112012-04-13 06:34:32 -060058 snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main");
sricharan0abcf612011-02-08 14:10:45 +053059
60 oh = omap_hwmod_lookup(oh_name);
61
62 if (!oh)
63 pr_err("could not look up %s\n", oh_name);
64
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -070065 pdev = omap_device_build("omap_l3_smx", 0, oh, NULL, 0);
sricharan0abcf612011-02-08 14:10:45 +053066
Kevin Hilman3528c582011-07-21 13:48:45 -070067 WARN(IS_ERR(pdev), "could not build omap_device for %s\n", oh_name);
sricharan0abcf612011-02-08 14:10:45 +053068
Kevin Hilman3528c582011-07-21 13:48:45 -070069 return IS_ERR(pdev) ? PTR_ERR(pdev) : 0;
sricharan0abcf612011-02-08 14:10:45 +053070}
Tony Lindgrenb76c8b192013-01-11 11:24:18 -080071omap_postcore_initcall(omap3_l3_init);
sricharan0abcf612011-02-08 14:10:45 +053072
sricharana4dc6162011-03-09 16:00:29 +053073static int __init omap4_l3_init(void)
74{
Paul Walmsleyeeb37112012-04-13 06:34:32 -060075 int i;
sricharana4dc6162011-03-09 16:00:29 +053076 struct omap_hwmod *oh[3];
Kevin Hilman3528c582011-07-21 13:48:45 -070077 struct platform_device *pdev;
sricharana4dc6162011-03-09 16:00:29 +053078 char oh_name[L3_MODULES_MAX_LEN];
79
Benoit Coussonad8dfac2011-08-12 13:48:47 +020080 /* If dtb is there, the devices will be created dynamically */
81 if (of_have_populated_dt())
82 return -ENODEV;
83
sricharana4dc6162011-03-09 16:00:29 +053084 /*
85 * To avoid code running on other OMAPs in
86 * multi-omap builds
87 */
R Sricharane17933c2011-11-04 15:52:59 +053088 if (!cpu_is_omap44xx() && !soc_is_omap54xx())
sricharana4dc6162011-03-09 16:00:29 +053089 return -ENODEV;
90
91 for (i = 0; i < L3_MODULES; i++) {
Paul Walmsleyeeb37112012-04-13 06:34:32 -060092 snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main_%d", i+1);
sricharana4dc6162011-03-09 16:00:29 +053093
94 oh[i] = omap_hwmod_lookup(oh_name);
95 if (!(oh[i]))
96 pr_err("could not look up %s\n", oh_name);
97 }
98
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -070099 pdev = omap_device_build_ss("omap_l3_noc", 0, oh, 3, NULL, 0);
sricharana4dc6162011-03-09 16:00:29 +0530100
Kevin Hilman3528c582011-07-21 13:48:45 -0700101 WARN(IS_ERR(pdev), "could not build omap_device for %s\n", oh_name);
sricharana4dc6162011-03-09 16:00:29 +0530102
Kevin Hilman3528c582011-07-21 13:48:45 -0700103 return IS_ERR(pdev) ? PTR_ERR(pdev) : 0;
sricharana4dc6162011-03-09 16:00:29 +0530104}
Tony Lindgrenb76c8b192013-01-11 11:24:18 -0800105omap_postcore_initcall(omap4_l3_init);
sricharana4dc6162011-03-09 16:00:29 +0530106
Tony Lindgren828c7072009-03-23 18:23:49 -0700107#if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800108
Sergio Aguirrecfe2cde2010-11-15 11:29:54 -0300109static struct resource omap2cam_resources[] = {
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800110 {
Tony Lindgren828c7072009-03-23 18:23:49 -0700111 .start = OMAP24XX_CAMERA_BASE,
112 .end = OMAP24XX_CAMERA_BASE + 0xfff,
113 .flags = IORESOURCE_MEM,
114 },
115 {
Tony Lindgren7d7e1eb2012-08-27 17:43:01 -0700116 .start = 24 + OMAP_INTC_START,
Tony Lindgren828c7072009-03-23 18:23:49 -0700117 .flags = IORESOURCE_IRQ,
118 }
119};
120
Sergio Aguirrecfe2cde2010-11-15 11:29:54 -0300121static struct platform_device omap2cam_device = {
Tony Lindgren828c7072009-03-23 18:23:49 -0700122 .name = "omap24xxcam",
123 .id = -1,
Sergio Aguirrecfe2cde2010-11-15 11:29:54 -0300124 .num_resources = ARRAY_SIZE(omap2cam_resources),
125 .resource = omap2cam_resources,
Tony Lindgren828c7072009-03-23 18:23:49 -0700126};
Laurent Pincharta11f6702009-12-14 08:09:07 -0300127#endif
Tony Lindgren828c7072009-03-23 18:23:49 -0700128
Ohad Ben-Cohen1a51a0c2012-01-11 15:28:11 +0200129#if defined(CONFIG_IOMMU_API)
130
Tony Lindgren2ab7c842012-11-02 12:24:14 -0700131#include <linux/platform_data/iommu-omap.h>
Ohad Ben-Cohen1a51a0c2012-01-11 15:28:11 +0200132
Tony Lindgren828c7072009-03-23 18:23:49 -0700133static struct resource omap3isp_resources[] = {
134 {
135 .start = OMAP3430_ISP_BASE,
136 .end = OMAP3430_ISP_END,
137 .flags = IORESOURCE_MEM,
138 },
139 {
Tony Lindgren828c7072009-03-23 18:23:49 -0700140 .start = OMAP3430_ISP_CCP2_BASE,
141 .end = OMAP3430_ISP_CCP2_END,
142 .flags = IORESOURCE_MEM,
143 },
144 {
145 .start = OMAP3430_ISP_CCDC_BASE,
146 .end = OMAP3430_ISP_CCDC_END,
147 .flags = IORESOURCE_MEM,
148 },
149 {
150 .start = OMAP3430_ISP_HIST_BASE,
151 .end = OMAP3430_ISP_HIST_END,
152 .flags = IORESOURCE_MEM,
153 },
154 {
155 .start = OMAP3430_ISP_H3A_BASE,
156 .end = OMAP3430_ISP_H3A_END,
157 .flags = IORESOURCE_MEM,
158 },
159 {
160 .start = OMAP3430_ISP_PREV_BASE,
161 .end = OMAP3430_ISP_PREV_END,
162 .flags = IORESOURCE_MEM,
163 },
164 {
165 .start = OMAP3430_ISP_RESZ_BASE,
166 .end = OMAP3430_ISP_RESZ_END,
167 .flags = IORESOURCE_MEM,
168 },
169 {
170 .start = OMAP3430_ISP_SBL_BASE,
171 .end = OMAP3430_ISP_SBL_END,
172 .flags = IORESOURCE_MEM,
173 },
174 {
Tuukka Toivonen6817a692010-02-02 11:17:33 -0300175 .start = OMAP3430_ISP_CSI2A_REGS1_BASE,
176 .end = OMAP3430_ISP_CSI2A_REGS1_END,
Tony Lindgren828c7072009-03-23 18:23:49 -0700177 .flags = IORESOURCE_MEM,
178 },
179 {
Tuukka Toivonen6817a692010-02-02 11:17:33 -0300180 .start = OMAP3430_ISP_CSIPHY2_BASE,
181 .end = OMAP3430_ISP_CSIPHY2_END,
182 .flags = IORESOURCE_MEM,
183 },
184 {
185 .start = OMAP3630_ISP_CSI2A_REGS2_BASE,
186 .end = OMAP3630_ISP_CSI2A_REGS2_END,
187 .flags = IORESOURCE_MEM,
188 },
189 {
190 .start = OMAP3630_ISP_CSI2C_REGS1_BASE,
191 .end = OMAP3630_ISP_CSI2C_REGS1_END,
192 .flags = IORESOURCE_MEM,
193 },
194 {
195 .start = OMAP3630_ISP_CSIPHY1_BASE,
196 .end = OMAP3630_ISP_CSIPHY1_END,
197 .flags = IORESOURCE_MEM,
198 },
199 {
200 .start = OMAP3630_ISP_CSI2C_REGS2_BASE,
201 .end = OMAP3630_ISP_CSI2C_REGS2_END,
Tony Lindgren828c7072009-03-23 18:23:49 -0700202 .flags = IORESOURCE_MEM,
203 },
204 {
Sakari Ailusc19d19e2012-10-14 07:31:48 -0300205 .start = OMAP343X_CTRL_BASE + OMAP343X_CONTROL_CSIRXFE,
206 .end = OMAP343X_CTRL_BASE + OMAP343X_CONTROL_CSIRXFE + 3,
207 .flags = IORESOURCE_MEM,
208 },
209 {
210 .start = OMAP343X_CTRL_BASE + OMAP3630_CONTROL_CAMERA_PHY_CTRL,
211 .end = OMAP343X_CTRL_BASE + OMAP3630_CONTROL_CAMERA_PHY_CTRL + 3,
212 .flags = IORESOURCE_MEM,
213 },
214 {
Tony Lindgren7d7e1eb2012-08-27 17:43:01 -0700215 .start = 24 + OMAP_INTC_START,
Tony Lindgren828c7072009-03-23 18:23:49 -0700216 .flags = IORESOURCE_IRQ,
217 }
218};
219
220static struct platform_device omap3isp_device = {
221 .name = "omap3isp",
222 .id = -1,
223 .num_resources = ARRAY_SIZE(omap3isp_resources),
224 .resource = omap3isp_resources,
225};
226
Ohad Ben-Cohenc8eaab32011-09-23 16:44:57 +0300227static struct omap_iommu_arch_data omap3_isp_iommu = {
Omar Ramirez Luna72b15b62012-11-19 19:05:50 -0600228 .name = "mmu_isp",
Ohad Ben-Cohenc8eaab32011-09-23 16:44:57 +0300229};
230
Laurent Pincharta11f6702009-12-14 08:09:07 -0300231int omap3_init_camera(struct isp_platform_data *pdata)
Tony Lindgren828c7072009-03-23 18:23:49 -0700232{
Laurent Pincharta11f6702009-12-14 08:09:07 -0300233 omap3isp_device.dev.platform_data = pdata;
Ohad Ben-Cohenc8eaab32011-09-23 16:44:57 +0300234 omap3isp_device.dev.archdata.iommu = &omap3_isp_iommu;
235
Laurent Pincharta11f6702009-12-14 08:09:07 -0300236 return platform_device_register(&omap3isp_device);
Tony Lindgren828c7072009-03-23 18:23:49 -0700237}
Tony Lindgren828c7072009-03-23 18:23:49 -0700238
Ohad Ben-Cohen1a51a0c2012-01-11 15:28:11 +0200239#else /* !CONFIG_IOMMU_API */
240
241int omap3_init_camera(struct isp_platform_data *pdata)
242{
243 return 0;
244}
245
246#endif
247
Tony Lindgren1dbae812005-11-10 14:26:51 +0000248static inline void omap_init_camera(void)
249{
Sergio Aguirrecfe2cde2010-11-15 11:29:54 -0300250#if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
251 if (cpu_is_omap24xx())
252 platform_device_register(&omap2cam_device);
Tony Lindgren1dbae812005-11-10 14:26:51 +0000253#endif
Sergio Aguirrecfe2cde2010-11-15 11:29:54 -0300254}
Tony Lindgren1dbae812005-11-10 14:26:51 +0000255
Syed Rafiuddin59556762010-12-27 05:51:45 +0000256int __init omap4_keyboard_init(struct omap4_keypad_platform_data
Shubhrajyoti Dattaf67df6c2011-07-05 03:38:24 -0700257 *sdp4430_keypad_data, struct omap_board_data *bdata)
Syed Rafiuddin59556762010-12-27 05:51:45 +0000258{
Kevin Hilman3528c582011-07-21 13:48:45 -0700259 struct platform_device *pdev;
Syed Rafiuddin59556762010-12-27 05:51:45 +0000260 struct omap_hwmod *oh;
261 struct omap4_keypad_platform_data *keypad_data;
262 unsigned int id = -1;
263 char *oh_name = "kbd";
264 char *name = "omap4-keypad";
265
266 oh = omap_hwmod_lookup(oh_name);
267 if (!oh) {
268 pr_err("Could not look up %s\n", oh_name);
269 return -ENODEV;
270 }
271
272 keypad_data = sdp4430_keypad_data;
273
Kevin Hilman3528c582011-07-21 13:48:45 -0700274 pdev = omap_device_build(name, id, oh, keypad_data,
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -0700275 sizeof(struct omap4_keypad_platform_data));
Syed Rafiuddin59556762010-12-27 05:51:45 +0000276
Kevin Hilman3528c582011-07-21 13:48:45 -0700277 if (IS_ERR(pdev)) {
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300278 WARN(1, "Can't build omap_device for %s:%s.\n",
Syed Rafiuddin59556762010-12-27 05:51:45 +0000279 name, oh->name);
Kevin Hilman3528c582011-07-21 13:48:45 -0700280 return PTR_ERR(pdev);
Syed Rafiuddin59556762010-12-27 05:51:45 +0000281 }
Shubhrajyoti Dattaf67df6c2011-07-05 03:38:24 -0700282 oh->mux = omap_hwmod_mux_init(bdata->pads, bdata->pads_cnt);
Syed Rafiuddin59556762010-12-27 05:51:45 +0000283
284 return 0;
285}
286
Suman Annac869c752013-03-12 17:55:29 -0500287#if defined(CONFIG_OMAP2PLUS_MBOX) || defined(CONFIG_OMAP2PLUS_MBOX_MODULE)
Kevin Hilman9cf793f2012-02-20 09:43:30 -0800288static inline void __init omap_init_mbox(void)
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800289{
Felipe Contreras69dbf852011-02-24 12:51:33 -0800290 struct omap_hwmod *oh;
Kevin Hilman3528c582011-07-21 13:48:45 -0700291 struct platform_device *pdev;
Suman Annab8a7cf82013-01-28 17:21:58 -0600292 struct omap_mbox_pdata *pdata;
Felipe Contreras69dbf852011-02-24 12:51:33 -0800293
294 oh = omap_hwmod_lookup("mailbox");
295 if (!oh) {
296 pr_err("%s: unable to find hwmod\n", __func__);
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700297 return;
298 }
Suman Annab8a7cf82013-01-28 17:21:58 -0600299 if (!oh->dev_attr) {
300 pr_err("%s: hwmod doesn't have valid attrs\n", __func__);
301 return;
302 }
Felipe Contreras69dbf852011-02-24 12:51:33 -0800303
Suman Annab8a7cf82013-01-28 17:21:58 -0600304 pdata = (struct omap_mbox_pdata *)oh->dev_attr;
305 pdev = omap_device_build("omap-mailbox", -1, oh, pdata, sizeof(*pdata));
Kevin Hilman3528c582011-07-21 13:48:45 -0700306 WARN(IS_ERR(pdev), "%s: could not build device, err %ld\n",
307 __func__, PTR_ERR(pdev));
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800308}
309#else
310static inline void omap_init_mbox(void) { }
Suman Annac869c752013-03-12 17:55:29 -0500311#endif /* CONFIG_OMAP2PLUS_MBOX */
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800312
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100313static inline void omap_init_sti(void) {}
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100314
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000315#if defined(CONFIG_SND_SOC) || defined(CONFIG_SND_SOC_MODULE)
316
317static struct platform_device omap_pcm = {
318 .name = "omap-pcm-audio",
319 .id = -1,
320};
321
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000322static void omap_init_audio(void)
323{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000324 platform_device_register(&omap_pcm);
325}
326
327#else
328static inline void omap_init_audio(void) {}
329#endif
330
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600331#if defined(CONFIG_SND_OMAP_SOC_MCPDM) || \
332 defined(CONFIG_SND_OMAP_SOC_MCPDM_MODULE)
333
Kevin Hilman9cf793f2012-02-20 09:43:30 -0800334static void __init omap_init_mcpdm(void)
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600335{
336 struct omap_hwmod *oh;
Peter Ujfalusi927dbbb2011-11-03 10:41:22 +0200337 struct platform_device *pdev;
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600338
339 oh = omap_hwmod_lookup("mcpdm");
Peter Ujfalusi5fe0a122013-06-11 10:31:58 +0200340 if (!oh)
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600341 return;
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600342
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -0700343 pdev = omap_device_build("omap-mcpdm", -1, oh, NULL, 0);
Peter Ujfalusi927dbbb2011-11-03 10:41:22 +0200344 WARN(IS_ERR(pdev), "Can't build omap_device for omap-mcpdm.\n");
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600345}
346#else
347static inline void omap_init_mcpdm(void) {}
348#endif
349
Peter Ujfaluside9eb092011-12-13 10:48:54 -0800350#if defined(CONFIG_SND_OMAP_SOC_DMIC) || \
351 defined(CONFIG_SND_OMAP_SOC_DMIC_MODULE)
352
Kevin Hilman9cf793f2012-02-20 09:43:30 -0800353static void __init omap_init_dmic(void)
Peter Ujfaluside9eb092011-12-13 10:48:54 -0800354{
355 struct omap_hwmod *oh;
356 struct platform_device *pdev;
357
358 oh = omap_hwmod_lookup("dmic");
Peter Ujfalusi6d931cf2013-06-11 10:31:59 +0200359 if (!oh)
Peter Ujfaluside9eb092011-12-13 10:48:54 -0800360 return;
Peter Ujfaluside9eb092011-12-13 10:48:54 -0800361
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -0700362 pdev = omap_device_build("omap-dmic", -1, oh, NULL, 0);
Peter Ujfaluside9eb092011-12-13 10:48:54 -0800363 WARN(IS_ERR(pdev), "Can't build omap_device for omap-dmic.\n");
364}
365#else
366static inline void omap_init_dmic(void) {}
367#endif
368
Ricardo Neri5eeec212012-05-09 14:19:14 -0700369#if defined(CONFIG_SND_OMAP_SOC_OMAP_HDMI) || \
370 defined(CONFIG_SND_OMAP_SOC_OMAP_HDMI_MODULE)
371
372static struct platform_device omap_hdmi_audio = {
373 .name = "omap-hdmi-audio",
374 .id = -1,
375};
376
377static void __init omap_init_hdmi_audio(void)
378{
379 struct omap_hwmod *oh;
380 struct platform_device *pdev;
381
382 oh = omap_hwmod_lookup("dss_hdmi");
Peter Ujfalusi7252db52013-06-11 10:32:00 +0200383 if (!oh)
Ricardo Neri5eeec212012-05-09 14:19:14 -0700384 return;
Ricardo Neri5eeec212012-05-09 14:19:14 -0700385
Paul Walmsley6efc3fe2013-02-12 03:58:35 +0000386 pdev = omap_device_build("omap-hdmi-audio-dai", -1, oh, NULL, 0);
Ricardo Neri5eeec212012-05-09 14:19:14 -0700387 WARN(IS_ERR(pdev),
388 "Can't build omap_device for omap-hdmi-audio-dai.\n");
389
390 platform_device_register(&omap_hdmi_audio);
391}
392#else
393static inline void omap_init_hdmi_audio(void) {}
394#endif
395
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300396#if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700397
Arnd Bergmann22037472012-08-24 15:21:06 +0200398#include <linux/platform_data/spi-omap2-mcspi.h>
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700399
Kevin Hilman9cf793f2012-02-20 09:43:30 -0800400static int __init omap_mcspi_init(struct omap_hwmod *oh, void *unused)
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700401{
Kevin Hilman3528c582011-07-21 13:48:45 -0700402 struct platform_device *pdev;
Charulatha V1a5d8192011-02-02 17:52:14 +0530403 char *name = "omap2_mcspi";
404 struct omap2_mcspi_platform_config *pdata;
405 static int spi_num;
406 struct omap2_mcspi_dev_attr *mcspi_attrib = oh->dev_attr;
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700407
Charulatha V1a5d8192011-02-02 17:52:14 +0530408 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
409 if (!pdata) {
410 pr_err("Memory allocation for McSPI device failed\n");
411 return -ENOMEM;
412 }
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700413
Charulatha V1a5d8192011-02-02 17:52:14 +0530414 pdata->num_cs = mcspi_attrib->num_chipselect;
415 switch (oh->class->rev) {
416 case OMAP2_MCSPI_REV:
417 case OMAP3_MCSPI_REV:
418 pdata->regs_offset = 0;
419 break;
420 case OMAP4_MCSPI_REV:
421 pdata->regs_offset = OMAP4_MCSPI_REG_OFFSET;
422 break;
423 default:
424 pr_err("Invalid McSPI Revision value\n");
Julia Lawalle0feca892011-12-23 18:39:31 +0100425 kfree(pdata);
Charulatha V1a5d8192011-02-02 17:52:14 +0530426 return -EINVAL;
427 }
428
429 spi_num++;
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -0700430 pdev = omap_device_build(name, spi_num, oh, pdata, sizeof(*pdata));
Kevin Hilman3528c582011-07-21 13:48:45 -0700431 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s\n",
Charulatha V1a5d8192011-02-02 17:52:14 +0530432 name, oh->name);
433 kfree(pdata);
434 return 0;
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700435}
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700436
437static void omap_init_mcspi(void)
438{
Charulatha V1a5d8192011-02-02 17:52:14 +0530439 omap_hwmod_for_each_by_class("mcspi", omap_mcspi_init, NULL);
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700440}
441
442#else
443static inline void omap_init_mcspi(void) {}
444#endif
445
Paul Walmsley4848d462012-09-23 17:28:27 -0600446/**
447 * omap_init_rng - bind the RNG hwmod to the RNG omap_device
448 *
449 * Bind the RNG hwmod to the RNG omap_device. No return value.
450 */
451static void omap_init_rng(void)
452{
453 struct omap_hwmod *oh;
454 struct platform_device *pdev;
455
456 oh = omap_hwmod_lookup("rng");
457 if (!oh)
458 return;
459
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -0700460 pdev = omap_device_build("omap_rng", -1, oh, NULL, 0);
Paul Walmsley4848d462012-09-23 17:28:27 -0600461 WARN(IS_ERR(pdev), "Can't build omap_device for omap_rng\n");
462}
Will Deacon88341332010-04-09 13:54:43 +0100463
Mark A. Greer26f88e62013-03-18 10:06:32 -0600464static void __init omap_init_sham(void)
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300465{
Mark A. Greer8c7bb572013-03-18 10:06:33 -0600466 struct omap_hwmod *oh;
467 struct platform_device *pdev;
Mark A. Greere569e992013-03-30 15:49:19 -0600468
Mark A. Greer8c7bb572013-03-18 10:06:33 -0600469 oh = omap_hwmod_lookup("sham");
470 if (!oh)
471 return;
Mark A. Greere569e992013-03-30 15:49:19 -0600472
Mark A. Greer8c7bb572013-03-18 10:06:33 -0600473 pdev = omap_device_build("omap-sham", -1, oh, NULL, 0);
474 WARN(IS_ERR(pdev), "Can't build omap_device for omap-sham\n");
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300475}
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300476
Mark A. Greer14ae5562012-12-21 09:28:10 -0700477static void __init omap_init_aes(void)
Dmitry Kasatkinb744c672010-09-03 19:13:55 +0800478{
Mark A. Greer77e2fd82012-12-21 09:28:11 -0700479 struct omap_hwmod *oh;
480 struct platform_device *pdev;
Mark A. Greer660ffd62012-12-21 09:28:09 -0700481
Mark A. Greer77e2fd82012-12-21 09:28:11 -0700482 oh = omap_hwmod_lookup("aes");
483 if (!oh)
484 return;
Mark A. Greer660ffd62012-12-21 09:28:09 -0700485
Mark A. Greer77e2fd82012-12-21 09:28:11 -0700486 pdev = omap_device_build("omap-aes", -1, oh, NULL, 0);
487 WARN(IS_ERR(pdev), "Can't build omap_device for omap-aes\n");
Dmitry Kasatkinb744c672010-09-03 19:13:55 +0800488}
489
Tony Lindgrend8874662008-12-10 17:37:16 -0800490/*-------------------------------------------------------------------------*/
491
Vaibhav Hiremathb2273582010-05-10 14:29:14 -0700492#if defined(CONFIG_VIDEO_OMAP2_VOUT) || \
493 defined(CONFIG_VIDEO_OMAP2_VOUT_MODULE)
494#if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
495static struct resource omap_vout_resource[3 - CONFIG_FB_OMAP2_NUM_FBS] = {
496};
497#else
498static struct resource omap_vout_resource[2] = {
499};
500#endif
501
502static struct platform_device omap_vout_device = {
503 .name = "omap_vout",
504 .num_resources = ARRAY_SIZE(omap_vout_resource),
505 .resource = &omap_vout_resource[0],
506 .id = -1,
507};
508static void omap_init_vout(void)
509{
510 if (platform_device_register(&omap_vout_device) < 0)
511 printk(KERN_ERR "Unable to register OMAP-VOUT device\n");
512}
513#else
514static inline void omap_init_vout(void) {}
515#endif
516
Tony Lindgren26f45c22013-05-17 10:45:10 -0700517#if IS_ENABLED(CONFIG_WL12XX)
518
519static struct wl12xx_platform_data wl12xx __initdata;
520
521void __init omap_init_wl12xx_of(void)
Kishon Vijay Abraham I459bc972012-10-27 19:05:56 +0530522{
Tony Lindgren26f45c22013-05-17 10:45:10 -0700523 int ret;
Kishon Vijay Abraham I459bc972012-10-27 19:05:56 +0530524
Tony Lindgren26f45c22013-05-17 10:45:10 -0700525 if (!of_have_populated_dt())
Kishon Vijay Abraham I459bc972012-10-27 19:05:56 +0530526 return;
527
Tony Lindgren26f45c22013-05-17 10:45:10 -0700528 if (of_machine_is_compatible("ti,omap4-sdp")) {
529 wl12xx.board_ref_clock = WL12XX_REFCLOCK_26;
530 wl12xx.board_tcxo_clock = WL12XX_TCXOCLOCK_26;
531 wl12xx.irq = gpio_to_irq(53);
532 } else if (of_machine_is_compatible("ti,omap4-panda")) {
533 wl12xx.board_ref_clock = WL12XX_REFCLOCK_38;
534 wl12xx.irq = gpio_to_irq(53);
535 } else {
Kishon Vijay Abraham I459bc972012-10-27 19:05:56 +0530536 return;
537 }
538
Tony Lindgren26f45c22013-05-17 10:45:10 -0700539 ret = wl12xx_set_platform_data(&wl12xx);
540 if (ret) {
541 pr_err("error setting wl12xx data: %d\n", ret);
Kishon Vijay Abraham I459bc972012-10-27 19:05:56 +0530542 return;
543 }
544}
545#else
Tony Lindgren26f45c22013-05-17 10:45:10 -0700546static inline void omap_init_wl12xx_of(void)
547{
548}
Kishon Vijay Abraham I459bc972012-10-27 19:05:56 +0530549#endif
550
Tony Lindgren1dbae812005-11-10 14:26:51 +0000551/*-------------------------------------------------------------------------*/
552
553static int __init omap2_init_devices(void)
554{
Matt Porter484202f2012-09-17 16:26:11 -0700555 /* Enable dummy states for those platforms without pinctrl support */
556 if (!of_have_populated_dt())
557 pinctrl_provide_dummies();
558
Paul Walmsley81fbc5ef2010-12-21 19:56:17 -0700559 /*
560 * please keep these calls, and their implementations above,
Tony Lindgren1dbae812005-11-10 14:26:51 +0000561 * in alphabetical order so they're easier to sort through.
562 */
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000563 omap_init_audio();
Tony Lindgren828c7072009-03-23 18:23:49 -0700564 omap_init_camera();
Ricardo Neri5eeec212012-05-09 14:19:14 -0700565 omap_init_hdmi_audio();
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800566 omap_init_mbox();
Benoit Coussonefcf1e52012-01-20 14:15:58 +0100567 /* If dtb is there, the devices will be created dynamically */
Peter Ujfalusi259bd6c2012-05-02 15:23:18 +0300568 if (!of_have_populated_dt()) {
569 omap_init_dmic();
Peter Ujfalusi4b21ffc2012-05-02 15:23:19 +0300570 omap_init_mcpdm();
Benoit Coussonefcf1e52012-01-20 14:15:58 +0100571 omap_init_mcspi();
Mark A. Greer114d7a82013-03-18 10:06:33 -0600572 omap_init_sham();
Mark A. Greer53335ac2012-12-21 09:28:12 -0700573 omap_init_aes();
Tony Lindgren26f45c22013-05-17 10:45:10 -0700574 } else {
575 /* These can be removed when bindings are done */
576 omap_init_wl12xx_of();
Peter Ujfalusi259bd6c2012-05-02 15:23:18 +0300577 }
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100578 omap_init_sti();
Paul Walmsley4848d462012-09-23 17:28:27 -0600579 omap_init_rng();
Vaibhav Hiremathb2273582010-05-10 14:29:14 -0700580 omap_init_vout();
Tony Lindgren1dbae812005-11-10 14:26:51 +0000581
582 return 0;
583}
Tony Lindgrenb76c8b192013-01-11 11:24:18 -0800584omap_arch_initcall(omap2_init_devices);