Blame view

arch/arm/mach-omap2/devices.c 17.1 KB
1dbae815a   Tony Lindgren   [ARM] 3145/1: OMA...
1
2
3
4
5
6
7
8
9
10
  /*
   * linux/arch/arm/mach-omap2/devices.c
   *
   * OMAP2 platform device setup/initialization
   *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
   * the Free Software Foundation; either version 2 of the License, or
   * (at your option) any later version.
   */
2f8163baa   Russell King   ARM: gpio: conver...
11
  #include <linux/gpio.h>
1dbae815a   Tony Lindgren   [ARM] 3145/1: OMA...
12
13
14
  #include <linux/kernel.h>
  #include <linux/init.h>
  #include <linux/platform_device.h>
fced80c73   Russell King   [ARM] Convert asm...
15
  #include <linux/io.h>
917fa280e   Kevin Hilman   omap mmc: force M...
16
  #include <linux/clk.h>
f2ce62312   Varadarajan, Charulatha   OMAP: WDT: Split ...
17
  #include <linux/err.h>
1a5d81905   Charulatha V   OMAP: devices: Mo...
18
  #include <linux/slab.h>
ad8dfac66   Benoit Cousson   arm/dts: OMAP4: A...
19
  #include <linux/of.h>
1dbae815a   Tony Lindgren   [ARM] 3145/1: OMA...
20

a09e64fbc   Russell King   [ARM] Move includ...
21
  #include <mach/hardware.h>
883413341   Will Deacon   ARM: 6046/1: ARM:...
22
  #include <mach/irqs.h>
1dbae815a   Tony Lindgren   [ARM] 3145/1: OMA...
23
24
  #include <asm/mach-types.h>
  #include <asm/mach/map.h>
883413341   Will Deacon   ARM: 6046/1: ARM:...
25
  #include <asm/pmu.h>
1dbae815a   Tony Lindgren   [ARM] 3145/1: OMA...
26

ce491cf85   Tony Lindgren   omap: headers: Mo...
27
28
  #include <plat/tc.h>
  #include <plat/board.h>
a09f73fab   Jarkko Nikula   omap: devices: Av...
29
  #include <plat/mcbsp.h>
ce491cf85   Tony Lindgren   omap: headers: Mo...
30
  #include <plat/mmc.h>
ee5500c45   Dmitry Kasatkin   crypto: omap - Up...
31
  #include <plat/dma.h>
f2ce62312   Varadarajan, Charulatha   OMAP: WDT: Split ...
32
33
  #include <plat/omap_hwmod.h>
  #include <plat/omap_device.h>
59556765c   Syed Rafiuddin   OMAP4: keypad: Ad...
34
  #include <plat/omap4-keypad.h>
1dbae815a   Tony Lindgren   [ARM] 3145/1: OMA...
35

4896e3940   Tony Lindgren   omap: mux: Replac...
36
  #include "mux.h"
4814ced51   Paul Walmsley   OMAP: control: mo...
37
  #include "control.h"
a11f6706c   Laurent Pinchart   [media] omap3: Ad...
38
  #include "devices.h"
4896e3940   Tony Lindgren   omap: mux: Replac...
39

0abcf6185   sricharan   OMAP3: devices: I...
40
  #define L3_MODULES_MAX_LEN 12
a4dc616ae   sricharan   OMAP4: Initialise...
41
  #define L3_MODULES 3
0abcf6185   sricharan   OMAP3: devices: I...
42
43
44
45
46
  
  static int __init omap3_l3_init(void)
  {
  	int l;
  	struct omap_hwmod *oh;
3528c58eb   Kevin Hilman   OMAP: omap_device...
47
  	struct platform_device *pdev;
0abcf6185   sricharan   OMAP3: devices: I...
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
  	char oh_name[L3_MODULES_MAX_LEN];
  
  	/*
  	 * To avoid code running on other OMAPs in
  	 * multi-omap builds
  	 */
  	if (!(cpu_is_omap34xx()))
  		return -ENODEV;
  
  	l = snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main");
  
  	oh = omap_hwmod_lookup(oh_name);
  
  	if (!oh)
  		pr_err("could not look up %s
  ", oh_name);
3528c58eb   Kevin Hilman   OMAP: omap_device...
64
  	pdev = omap_device_build("omap_l3_smx", 0, oh, NULL, 0,
0abcf6185   sricharan   OMAP3: devices: I...
65
  							   NULL, 0, 0);
3528c58eb   Kevin Hilman   OMAP: omap_device...
66
67
  	WARN(IS_ERR(pdev), "could not build omap_device for %s
  ", oh_name);
0abcf6185   sricharan   OMAP3: devices: I...
68

3528c58eb   Kevin Hilman   OMAP: omap_device...
69
  	return IS_ERR(pdev) ? PTR_ERR(pdev) : 0;
0abcf6185   sricharan   OMAP3: devices: I...
70
71
  }
  postcore_initcall(omap3_l3_init);
a4dc616ae   sricharan   OMAP4: Initialise...
72
73
74
75
  static int __init omap4_l3_init(void)
  {
  	int l, i;
  	struct omap_hwmod *oh[3];
3528c58eb   Kevin Hilman   OMAP: omap_device...
76
  	struct platform_device *pdev;
a4dc616ae   sricharan   OMAP4: Initialise...
77
  	char oh_name[L3_MODULES_MAX_LEN];
ad8dfac66   Benoit Cousson   arm/dts: OMAP4: A...
78
79
80
  	/* If dtb is there, the devices will be created dynamically */
  	if (of_have_populated_dt())
  		return -ENODEV;
a4dc616ae   sricharan   OMAP4: Initialise...
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
  	/*
  	 * To avoid code running on other OMAPs in
  	 * multi-omap builds
  	 */
  	if (!(cpu_is_omap44xx()))
  		return -ENODEV;
  
  	for (i = 0; i < L3_MODULES; i++) {
  		l = snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main_%d", i+1);
  
  		oh[i] = omap_hwmod_lookup(oh_name);
  		if (!(oh[i]))
  			pr_err("could not look up %s
  ", oh_name);
  	}
3528c58eb   Kevin Hilman   OMAP: omap_device...
96
  	pdev = omap_device_build_ss("omap_l3_noc", 0, oh, 3, NULL,
a4dc616ae   sricharan   OMAP4: Initialise...
97
  						     0, NULL, 0, 0);
3528c58eb   Kevin Hilman   OMAP: omap_device...
98
99
  	WARN(IS_ERR(pdev), "could not build omap_device for %s
  ", oh_name);
a4dc616ae   sricharan   OMAP4: Initialise...
100

3528c58eb   Kevin Hilman   OMAP: omap_device...
101
  	return IS_ERR(pdev) ? PTR_ERR(pdev) : 0;
a4dc616ae   sricharan   OMAP4: Initialise...
102
103
  }
  postcore_initcall(omap4_l3_init);
828c707e6   Tony Lindgren   ARM: OMAP3: Add b...
104
  #if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
c40fae952   Tony Lindgren   ARM: OMAP: Sync c...
105

cfe2cde6d   Sergio Aguirre   [media] omap2: Fi...
106
  static struct resource omap2cam_resources[] = {
c40fae952   Tony Lindgren   ARM: OMAP: Sync c...
107
  	{
828c707e6   Tony Lindgren   ARM: OMAP3: Add b...
108
109
110
111
112
113
114
115
116
  		.start		= OMAP24XX_CAMERA_BASE,
  		.end		= OMAP24XX_CAMERA_BASE + 0xfff,
  		.flags		= IORESOURCE_MEM,
  	},
  	{
  		.start		= INT_24XX_CAM_IRQ,
  		.flags		= IORESOURCE_IRQ,
  	}
  };
cfe2cde6d   Sergio Aguirre   [media] omap2: Fi...
117
  static struct platform_device omap2cam_device = {
828c707e6   Tony Lindgren   ARM: OMAP3: Add b...
118
119
  	.name		= "omap24xxcam",
  	.id		= -1,
cfe2cde6d   Sergio Aguirre   [media] omap2: Fi...
120
121
  	.num_resources	= ARRAY_SIZE(omap2cam_resources),
  	.resource	= omap2cam_resources,
828c707e6   Tony Lindgren   ARM: OMAP3: Add b...
122
  };
a11f6706c   Laurent Pinchart   [media] omap3: Ad...
123
  #endif
828c707e6   Tony Lindgren   ARM: OMAP3: Add b...
124

1a51a0ce1   Ohad Ben-Cohen   ARM: OMAP3: fix b...
125
126
127
  #if defined(CONFIG_IOMMU_API)
  
  #include <plat/iommu.h>
828c707e6   Tony Lindgren   ARM: OMAP3: Add b...
128
129
130
131
132
133
134
  static struct resource omap3isp_resources[] = {
  	{
  		.start		= OMAP3430_ISP_BASE,
  		.end		= OMAP3430_ISP_END,
  		.flags		= IORESOURCE_MEM,
  	},
  	{
828c707e6   Tony Lindgren   ARM: OMAP3: Add b...
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
  		.start		= OMAP3430_ISP_CCP2_BASE,
  		.end		= OMAP3430_ISP_CCP2_END,
  		.flags		= IORESOURCE_MEM,
  	},
  	{
  		.start		= OMAP3430_ISP_CCDC_BASE,
  		.end		= OMAP3430_ISP_CCDC_END,
  		.flags		= IORESOURCE_MEM,
  	},
  	{
  		.start		= OMAP3430_ISP_HIST_BASE,
  		.end		= OMAP3430_ISP_HIST_END,
  		.flags		= IORESOURCE_MEM,
  	},
  	{
  		.start		= OMAP3430_ISP_H3A_BASE,
  		.end		= OMAP3430_ISP_H3A_END,
  		.flags		= IORESOURCE_MEM,
  	},
  	{
  		.start		= OMAP3430_ISP_PREV_BASE,
  		.end		= OMAP3430_ISP_PREV_END,
  		.flags		= IORESOURCE_MEM,
  	},
  	{
  		.start		= OMAP3430_ISP_RESZ_BASE,
  		.end		= OMAP3430_ISP_RESZ_END,
  		.flags		= IORESOURCE_MEM,
  	},
  	{
  		.start		= OMAP3430_ISP_SBL_BASE,
  		.end		= OMAP3430_ISP_SBL_END,
  		.flags		= IORESOURCE_MEM,
  	},
  	{
6817a69a0   Tuukka Toivonen   [media] ARM: OMAP...
170
171
  		.start		= OMAP3430_ISP_CSI2A_REGS1_BASE,
  		.end		= OMAP3430_ISP_CSI2A_REGS1_END,
828c707e6   Tony Lindgren   ARM: OMAP3: Add b...
172
173
174
  		.flags		= IORESOURCE_MEM,
  	},
  	{
6817a69a0   Tuukka Toivonen   [media] ARM: OMAP...
175
176
177
178
179
180
181
  		.start		= OMAP3430_ISP_CSIPHY2_BASE,
  		.end		= OMAP3430_ISP_CSIPHY2_END,
  		.flags		= IORESOURCE_MEM,
  	},
  	{
  		.start		= OMAP3630_ISP_CSI2A_REGS2_BASE,
  		.end		= OMAP3630_ISP_CSI2A_REGS2_END,
828c707e6   Tony Lindgren   ARM: OMAP3: Add b...
182
183
184
  		.flags		= IORESOURCE_MEM,
  	},
  	{
6817a69a0   Tuukka Toivonen   [media] ARM: OMAP...
185
186
187
188
189
190
191
192
193
194
195
196
  		.start		= OMAP3630_ISP_CSI2C_REGS1_BASE,
  		.end		= OMAP3630_ISP_CSI2C_REGS1_END,
  		.flags		= IORESOURCE_MEM,
  	},
  	{
  		.start		= OMAP3630_ISP_CSIPHY1_BASE,
  		.end		= OMAP3630_ISP_CSIPHY1_END,
  		.flags		= IORESOURCE_MEM,
  	},
  	{
  		.start		= OMAP3630_ISP_CSI2C_REGS2_BASE,
  		.end		= OMAP3630_ISP_CSI2C_REGS2_END,
828c707e6   Tony Lindgren   ARM: OMAP3: Add b...
197
198
199
200
201
202
203
204
205
206
207
208
209
210
  		.flags		= IORESOURCE_MEM,
  	},
  	{
  		.start		= INT_34XX_CAM_IRQ,
  		.flags		= IORESOURCE_IRQ,
  	}
  };
  
  static struct platform_device omap3isp_device = {
  	.name		= "omap3isp",
  	.id		= -1,
  	.num_resources	= ARRAY_SIZE(omap3isp_resources),
  	.resource	= omap3isp_resources,
  };
c8eaab3b7   Ohad Ben-Cohen   ARM: OMAP3: bind ...
211
212
213
  static struct omap_iommu_arch_data omap3_isp_iommu = {
  	.name = "isp",
  };
a11f6706c   Laurent Pinchart   [media] omap3: Ad...
214
  int omap3_init_camera(struct isp_platform_data *pdata)
828c707e6   Tony Lindgren   ARM: OMAP3: Add b...
215
  {
a11f6706c   Laurent Pinchart   [media] omap3: Ad...
216
  	omap3isp_device.dev.platform_data = pdata;
c8eaab3b7   Ohad Ben-Cohen   ARM: OMAP3: bind ...
217
  	omap3isp_device.dev.archdata.iommu = &omap3_isp_iommu;
a11f6706c   Laurent Pinchart   [media] omap3: Ad...
218
  	return platform_device_register(&omap3isp_device);
828c707e6   Tony Lindgren   ARM: OMAP3: Add b...
219
  }
828c707e6   Tony Lindgren   ARM: OMAP3: Add b...
220

1a51a0ce1   Ohad Ben-Cohen   ARM: OMAP3: fix b...
221
222
223
224
225
226
227
228
  #else /* !CONFIG_IOMMU_API */
  
  int omap3_init_camera(struct isp_platform_data *pdata)
  {
  	return 0;
  }
  
  #endif
828c707e6   Tony Lindgren   ARM: OMAP3: Add b...
229
230
  static inline void omap_init_camera(void)
  {
cfe2cde6d   Sergio Aguirre   [media] omap2: Fi...
231
232
233
  #if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
  	if (cpu_is_omap24xx())
  		platform_device_register(&omap2cam_device);
828c707e6   Tony Lindgren   ARM: OMAP3: Add b...
234
  #endif
cfe2cde6d   Sergio Aguirre   [media] omap2: Fi...
235
  }
828c707e6   Tony Lindgren   ARM: OMAP3: Add b...
236

59556765c   Syed Rafiuddin   OMAP4: keypad: Ad...
237
  int __init omap4_keyboard_init(struct omap4_keypad_platform_data
f67df6c67   Shubhrajyoti Datta   OMAP4: Keyboard: ...
238
  			*sdp4430_keypad_data, struct omap_board_data *bdata)
59556765c   Syed Rafiuddin   OMAP4: keypad: Ad...
239
  {
3528c58eb   Kevin Hilman   OMAP: omap_device...
240
  	struct platform_device *pdev;
59556765c   Syed Rafiuddin   OMAP4: keypad: Ad...
241
242
243
244
245
246
247
248
249
250
251
252
253
254
  	struct omap_hwmod *oh;
  	struct omap4_keypad_platform_data *keypad_data;
  	unsigned int id = -1;
  	char *oh_name = "kbd";
  	char *name = "omap4-keypad";
  
  	oh = omap_hwmod_lookup(oh_name);
  	if (!oh) {
  		pr_err("Could not look up %s
  ", oh_name);
  		return -ENODEV;
  	}
  
  	keypad_data = sdp4430_keypad_data;
3528c58eb   Kevin Hilman   OMAP: omap_device...
255
  	pdev = omap_device_build(name, id, oh, keypad_data,
f718e2c03   Benoit Cousson   ARM: OMAP2+: devi...
256
  			sizeof(struct omap4_keypad_platform_data), NULL, 0, 0);
59556765c   Syed Rafiuddin   OMAP4: keypad: Ad...
257

3528c58eb   Kevin Hilman   OMAP: omap_device...
258
  	if (IS_ERR(pdev)) {
25985edce   Lucas De Marchi   Fix common misspe...
259
260
  		WARN(1, "Can't build omap_device for %s:%s.
  ",
59556765c   Syed Rafiuddin   OMAP4: keypad: Ad...
261
  						name, oh->name);
3528c58eb   Kevin Hilman   OMAP: omap_device...
262
  		return PTR_ERR(pdev);
59556765c   Syed Rafiuddin   OMAP4: keypad: Ad...
263
  	}
f67df6c67   Shubhrajyoti Datta   OMAP4: Keyboard: ...
264
  	oh->mux = omap_hwmod_mux_init(bdata->pads, bdata->pads_cnt);
59556765c   Syed Rafiuddin   OMAP4: keypad: Ad...
265
266
267
  
  	return 0;
  }
6c20a6837   Hiroshi DOYU   omap mailbox: add...
268
  #if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)
c40fae952   Tony Lindgren   ARM: OMAP: Sync c...
269
270
  static inline void omap_init_mbox(void)
  {
69dbf857c   Felipe Contreras   OMAP: mailbox: bu...
271
  	struct omap_hwmod *oh;
3528c58eb   Kevin Hilman   OMAP: omap_device...
272
  	struct platform_device *pdev;
69dbf857c   Felipe Contreras   OMAP: mailbox: bu...
273
274
275
276
277
  
  	oh = omap_hwmod_lookup("mailbox");
  	if (!oh) {
  		pr_err("%s: unable to find hwmod
  ", __func__);
6c20a6837   Hiroshi DOYU   omap mailbox: add...
278
279
  		return;
  	}
69dbf857c   Felipe Contreras   OMAP: mailbox: bu...
280

f718e2c03   Benoit Cousson   ARM: OMAP2+: devi...
281
  	pdev = omap_device_build("omap-mailbox", -1, oh, NULL, 0, NULL, 0, 0);
3528c58eb   Kevin Hilman   OMAP: omap_device...
282
283
284
  	WARN(IS_ERR(pdev), "%s: could not build device, err %ld
  ",
  						__func__, PTR_ERR(pdev));
c40fae952   Tony Lindgren   ARM: OMAP: Sync c...
285
286
287
  }
  #else
  static inline void omap_init_mbox(void) { }
6c20a6837   Hiroshi DOYU   omap mailbox: add...
288
  #endif /* CONFIG_OMAP_MBOX_FWK */
c40fae952   Tony Lindgren   ARM: OMAP: Sync c...
289

9b6553cd0   Tony Lindgren   [ARM] 3433/1: ARM...
290
  static inline void omap_init_sti(void) {}
9b6553cd0   Tony Lindgren   [ARM] 3433/1: ARM...
291

f0fba2ad1   Liam Girdwood   ASoC: multi-compo...
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
  #if defined(CONFIG_SND_SOC) || defined(CONFIG_SND_SOC_MODULE)
  
  static struct platform_device omap_pcm = {
  	.name	= "omap-pcm-audio",
  	.id	= -1,
  };
  
  /*
   * OMAP2420 has 2 McBSP ports
   * OMAP2430 has 5 McBSP ports
   * OMAP3 has 5 McBSP ports
   * OMAP4 has 4 McBSP ports
   */
  OMAP_MCBSP_PLATFORM_DEVICE(1);
  OMAP_MCBSP_PLATFORM_DEVICE(2);
  OMAP_MCBSP_PLATFORM_DEVICE(3);
  OMAP_MCBSP_PLATFORM_DEVICE(4);
  OMAP_MCBSP_PLATFORM_DEVICE(5);
  
  static void omap_init_audio(void)
  {
  	platform_device_register(&omap_mcbsp1);
  	platform_device_register(&omap_mcbsp2);
  	if (cpu_is_omap243x() || cpu_is_omap34xx() || cpu_is_omap44xx()) {
  		platform_device_register(&omap_mcbsp3);
  		platform_device_register(&omap_mcbsp4);
  	}
  	if (cpu_is_omap243x() || cpu_is_omap34xx())
  		platform_device_register(&omap_mcbsp5);
  
  	platform_device_register(&omap_pcm);
  }
  
  #else
  static inline void omap_init_audio(void) {}
  #endif
d231f5cba   Peter Ujfalusi   OMAP: McPDM: Conv...
328
329
  #if defined(CONFIG_SND_OMAP_SOC_MCPDM) || \
  		defined(CONFIG_SND_OMAP_SOC_MCPDM_MODULE)
d231f5cba   Peter Ujfalusi   OMAP: McPDM: Conv...
330
331
332
  static void omap_init_mcpdm(void)
  {
  	struct omap_hwmod *oh;
927dbbb22   Peter Ujfalusi   ARM: OMAP2+: devi...
333
  	struct platform_device *pdev;
d231f5cba   Peter Ujfalusi   OMAP: McPDM: Conv...
334
335
336
337
338
339
340
  
  	oh = omap_hwmod_lookup("mcpdm");
  	if (!oh) {
  		printk(KERN_ERR "Could not look up mcpdm hw_mod
  ");
  		return;
  	}
927dbbb22   Peter Ujfalusi   ARM: OMAP2+: devi...
341
342
343
  	pdev = omap_device_build("omap-mcpdm", -1, oh, NULL, 0, NULL, 0, 0);
  	WARN(IS_ERR(pdev), "Can't build omap_device for omap-mcpdm.
  ");
d231f5cba   Peter Ujfalusi   OMAP: McPDM: Conv...
344
345
346
347
  }
  #else
  static inline void omap_init_mcpdm(void) {}
  #endif
646e3ed1a   Tony Lindgren   ARM: OMAP2: Misc ...
348
  #if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
ed7eb9d90   Juha Yrjola   ARM: OMAP: Regist...
349

ce491cf85   Tony Lindgren   omap: headers: Mo...
350
  #include <plat/mcspi.h>
ed7eb9d90   Juha Yrjola   ARM: OMAP: Regist...
351

1a5d81905   Charulatha V   OMAP: devices: Mo...
352
  static int omap_mcspi_init(struct omap_hwmod *oh, void *unused)
af41a12f0   Tony Lindgren   omap: Fix mcspi c...
353
  {
3528c58eb   Kevin Hilman   OMAP: omap_device...
354
  	struct platform_device *pdev;
1a5d81905   Charulatha V   OMAP: devices: Mo...
355
356
357
358
359
360
361
362
363
364
365
  	char *name = "omap2_mcspi";
  	struct omap2_mcspi_platform_config *pdata;
  	static int spi_num;
  	struct omap2_mcspi_dev_attr *mcspi_attrib = oh->dev_attr;
  
  	pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
  	if (!pdata) {
  		pr_err("Memory allocation for McSPI device failed
  ");
  		return -ENOMEM;
  	}
af41a12f0   Tony Lindgren   omap: Fix mcspi c...
366

1a5d81905   Charulatha V   OMAP: devices: Mo...
367
368
369
370
371
372
373
374
375
376
377
378
379
380
  	pdata->num_cs = mcspi_attrib->num_chipselect;
  	switch (oh->class->rev) {
  	case OMAP2_MCSPI_REV:
  	case OMAP3_MCSPI_REV:
  			pdata->regs_offset = 0;
  			break;
  	case OMAP4_MCSPI_REV:
  			pdata->regs_offset = OMAP4_MCSPI_REG_OFFSET;
  			break;
  	default:
  			pr_err("Invalid McSPI Revision value
  ");
  			return -EINVAL;
  	}
af41a12f0   Tony Lindgren   omap: Fix mcspi c...
381

1a5d81905   Charulatha V   OMAP: devices: Mo...
382
  	spi_num++;
3528c58eb   Kevin Hilman   OMAP: omap_device...
383
  	pdev = omap_device_build(name, spi_num, oh, pdata,
f718e2c03   Benoit Cousson   ARM: OMAP2+: devi...
384
  				sizeof(*pdata),	NULL, 0, 0);
3528c58eb   Kevin Hilman   OMAP: omap_device...
385
386
  	WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s
  ",
1a5d81905   Charulatha V   OMAP: devices: Mo...
387
388
389
  				name, oh->name);
  	kfree(pdata);
  	return 0;
af41a12f0   Tony Lindgren   omap: Fix mcspi c...
390
  }
af41a12f0   Tony Lindgren   omap: Fix mcspi c...
391
392
393
  
  static void omap_init_mcspi(void)
  {
1a5d81905   Charulatha V   OMAP: devices: Mo...
394
  	omap_hwmod_for_each_by_class("mcspi", omap_mcspi_init, NULL);
ed7eb9d90   Juha Yrjola   ARM: OMAP: Regist...
395
396
397
398
399
  }
  
  #else
  static inline void omap_init_mcspi(void) {}
  #endif
883413341   Will Deacon   ARM: 6046/1: ARM:...
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
  static struct resource omap2_pmu_resource = {
  	.start	= 3,
  	.end	= 3,
  	.flags	= IORESOURCE_IRQ,
  };
  
  static struct resource omap3_pmu_resource = {
  	.start	= INT_34XX_BENCH_MPU_EMUL,
  	.end	= INT_34XX_BENCH_MPU_EMUL,
  	.flags	= IORESOURCE_IRQ,
  };
  
  static struct platform_device omap_pmu_device = {
  	.name		= "arm-pmu",
  	.id		= ARM_PMU_DEVICE_CPU,
  	.num_resources	= 1,
  };
  
  static void omap_init_pmu(void)
  {
  	if (cpu_is_omap24xx())
  		omap_pmu_device.resource = &omap2_pmu_resource;
  	else if (cpu_is_omap34xx())
  		omap_pmu_device.resource = &omap3_pmu_resource;
  	else
  		return;
  
  	platform_device_register(&omap_pmu_device);
  }
ee5500c45   Dmitry Kasatkin   crypto: omap - Up...
429
  #if defined(CONFIG_CRYPTO_DEV_OMAP_SHAM) || defined(CONFIG_CRYPTO_DEV_OMAP_SHAM_MODULE)
edc774ed0   Dmitry Kasatkin   crypto: omap - OM...
430
  #ifdef CONFIG_ARCH_OMAP2
ee5500c45   Dmitry Kasatkin   crypto: omap - Up...
431
  static struct resource omap2_sham_resources[] = {
646e3ed1a   Tony Lindgren   ARM: OMAP2: Misc ...
432
433
434
435
436
437
438
439
440
441
  	{
  		.start	= OMAP24XX_SEC_SHA1MD5_BASE,
  		.end	= OMAP24XX_SEC_SHA1MD5_BASE + 0x64,
  		.flags	= IORESOURCE_MEM,
  	},
  	{
  		.start	= INT_24XX_SHA1MD5,
  		.flags	= IORESOURCE_IRQ,
  	}
  };
ee5500c45   Dmitry Kasatkin   crypto: omap - Up...
442
443
444
445
446
  static int omap2_sham_resources_sz = ARRAY_SIZE(omap2_sham_resources);
  #else
  #define omap2_sham_resources		NULL
  #define omap2_sham_resources_sz		0
  #endif
646e3ed1a   Tony Lindgren   ARM: OMAP2: Misc ...
447

edc774ed0   Dmitry Kasatkin   crypto: omap - OM...
448
  #ifdef CONFIG_ARCH_OMAP3
ee5500c45   Dmitry Kasatkin   crypto: omap - Up...
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
  static struct resource omap3_sham_resources[] = {
  	{
  		.start	= OMAP34XX_SEC_SHA1MD5_BASE,
  		.end	= OMAP34XX_SEC_SHA1MD5_BASE + 0x64,
  		.flags	= IORESOURCE_MEM,
  	},
  	{
  		.start	= INT_34XX_SHA1MD52_IRQ,
  		.flags	= IORESOURCE_IRQ,
  	},
  	{
  		.start	= OMAP34XX_DMA_SHA1MD5_RX,
  		.flags	= IORESOURCE_DMA,
  	}
  };
  static int omap3_sham_resources_sz = ARRAY_SIZE(omap3_sham_resources);
  #else
  #define omap3_sham_resources		NULL
  #define omap3_sham_resources_sz		0
  #endif
  
  static struct platform_device sham_device = {
  	.name		= "omap-sham",
646e3ed1a   Tony Lindgren   ARM: OMAP2: Misc ...
472
  	.id		= -1,
646e3ed1a   Tony Lindgren   ARM: OMAP2: Misc ...
473
  };
ee5500c45   Dmitry Kasatkin   crypto: omap - Up...
474
  static void omap_init_sham(void)
646e3ed1a   Tony Lindgren   ARM: OMAP2: Misc ...
475
  {
ee5500c45   Dmitry Kasatkin   crypto: omap - Up...
476
477
478
479
480
481
482
483
484
485
486
487
  	if (cpu_is_omap24xx()) {
  		sham_device.resource = omap2_sham_resources;
  		sham_device.num_resources = omap2_sham_resources_sz;
  	} else if (cpu_is_omap34xx()) {
  		sham_device.resource = omap3_sham_resources;
  		sham_device.num_resources = omap3_sham_resources_sz;
  	} else {
  		pr_err("%s: platform not supported
  ", __func__);
  		return;
  	}
  	platform_device_register(&sham_device);
646e3ed1a   Tony Lindgren   ARM: OMAP2: Misc ...
488
489
  }
  #else
ee5500c45   Dmitry Kasatkin   crypto: omap - Up...
490
  static inline void omap_init_sham(void) { }
646e3ed1a   Tony Lindgren   ARM: OMAP2: Misc ...
491
  #endif
b744c679f   Dmitry Kasatkin   crypto: updates t...
492
  #if defined(CONFIG_CRYPTO_DEV_OMAP_AES) || defined(CONFIG_CRYPTO_DEV_OMAP_AES_MODULE)
82a0c149b   Dmitry Kasatkin   omap: crypto: upd...
493
  #ifdef CONFIG_ARCH_OMAP2
b744c679f   Dmitry Kasatkin   crypto: updates t...
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
  static struct resource omap2_aes_resources[] = {
  	{
  		.start	= OMAP24XX_SEC_AES_BASE,
  		.end	= OMAP24XX_SEC_AES_BASE + 0x4C,
  		.flags	= IORESOURCE_MEM,
  	},
  	{
  		.start	= OMAP24XX_DMA_AES_TX,
  		.flags	= IORESOURCE_DMA,
  	},
  	{
  		.start	= OMAP24XX_DMA_AES_RX,
  		.flags	= IORESOURCE_DMA,
  	}
  };
  static int omap2_aes_resources_sz = ARRAY_SIZE(omap2_aes_resources);
  #else
  #define omap2_aes_resources		NULL
  #define omap2_aes_resources_sz		0
  #endif
82a0c149b   Dmitry Kasatkin   omap: crypto: upd...
514
  #ifdef CONFIG_ARCH_OMAP3
b744c679f   Dmitry Kasatkin   crypto: updates t...
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
  static struct resource omap3_aes_resources[] = {
  	{
  		.start	= OMAP34XX_SEC_AES_BASE,
  		.end	= OMAP34XX_SEC_AES_BASE + 0x4C,
  		.flags	= IORESOURCE_MEM,
  	},
  	{
  		.start	= OMAP34XX_DMA_AES2_TX,
  		.flags	= IORESOURCE_DMA,
  	},
  	{
  		.start	= OMAP34XX_DMA_AES2_RX,
  		.flags	= IORESOURCE_DMA,
  	}
  };
  static int omap3_aes_resources_sz = ARRAY_SIZE(omap3_aes_resources);
  #else
  #define omap3_aes_resources		NULL
  #define omap3_aes_resources_sz		0
  #endif
  
  static struct platform_device aes_device = {
  	.name		= "omap-aes",
  	.id		= -1,
  };
  
  static void omap_init_aes(void)
  {
  	if (cpu_is_omap24xx()) {
  		aes_device.resource = omap2_aes_resources;
  		aes_device.num_resources = omap2_aes_resources_sz;
  	} else if (cpu_is_omap34xx()) {
  		aes_device.resource = omap3_aes_resources;
  		aes_device.num_resources = omap3_aes_resources_sz;
  	} else {
  		pr_err("%s: platform not supported
  ", __func__);
  		return;
  	}
  	platform_device_register(&aes_device);
  }
  
  #else
  static inline void omap_init_aes(void) { }
  #endif
d88746652   Tony Lindgren   omap mmc: Add bet...
560
  /*-------------------------------------------------------------------------*/
e08016d0f   Anand Gadiyar   omap: mmc: split ...
561
  #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)
917fa280e   Kevin Hilman   omap mmc: force M...
562

e08016d0f   Anand Gadiyar   omap: mmc: split ...
563
564
  static inline void omap242x_mmc_mux(struct omap_mmc_platform_data
  							*mmc_controller)
d88746652   Tony Lindgren   omap mmc: Add bet...
565
  {
ed8303fc1   stanley.miao   omap: init the gp...
566
567
568
569
570
571
572
573
  	if ((mmc_controller->slots[0].switch_pin > 0) && \
  		(mmc_controller->slots[0].switch_pin < OMAP_MAX_GPIO_LINES))
  		omap_mux_init_gpio(mmc_controller->slots[0].switch_pin,
  					OMAP_PIN_INPUT_PULLUP);
  	if ((mmc_controller->slots[0].gpio_wp > 0) && \
  		(mmc_controller->slots[0].gpio_wp < OMAP_MAX_GPIO_LINES))
  		omap_mux_init_gpio(mmc_controller->slots[0].gpio_wp,
  					OMAP_PIN_INPUT_PULLUP);
e08016d0f   Anand Gadiyar   omap: mmc: split ...
574
575
576
577
578
579
580
581
582
583
584
585
586
  	omap_mux_init_signal("sdmmc_cmd", 0);
  	omap_mux_init_signal("sdmmc_clki", 0);
  	omap_mux_init_signal("sdmmc_clko", 0);
  	omap_mux_init_signal("sdmmc_dat0", 0);
  	omap_mux_init_signal("sdmmc_dat_dir0", 0);
  	omap_mux_init_signal("sdmmc_cmd_dir", 0);
  	if (mmc_controller->slots[0].caps & MMC_CAP_4_BIT_DATA) {
  		omap_mux_init_signal("sdmmc_dat1", 0);
  		omap_mux_init_signal("sdmmc_dat2", 0);
  		omap_mux_init_signal("sdmmc_dat3", 0);
  		omap_mux_init_signal("sdmmc_dat_dir1", 0);
  		omap_mux_init_signal("sdmmc_dat_dir2", 0);
  		omap_mux_init_signal("sdmmc_dat_dir3", 0);
d88746652   Tony Lindgren   omap mmc: Add bet...
587
  	}
57b9daa0e   Vikram Pandita   OMAP3: MMC: Add m...
588

e08016d0f   Anand Gadiyar   omap: mmc: split ...
589
590
591
592
593
594
595
596
  	/*
  	 * Use internal loop-back in MMC/SDIO Module Input Clock
  	 * selection
  	 */
  	if (mmc_controller->slots[0].internal_clock) {
  		u32 v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
  		v |= (1 << 24);
  		omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0);
57b9daa0e   Vikram Pandita   OMAP3: MMC: Add m...
597
  	}
d88746652   Tony Lindgren   omap mmc: Add bet...
598
  }
e08016d0f   Anand Gadiyar   omap: mmc: split ...
599
  void __init omap242x_init_mmc(struct omap_mmc_platform_data **mmc_data)
d88746652   Tony Lindgren   omap mmc: Add bet...
600
  {
e08016d0f   Anand Gadiyar   omap: mmc: split ...
601
  	char *name = "mmci-omap";
d88746652   Tony Lindgren   omap mmc: Add bet...
602

e08016d0f   Anand Gadiyar   omap: mmc: split ...
603
604
605
606
607
  	if (!mmc_data[0]) {
  		pr_err("%s fails: Incomplete platform data
  ", __func__);
  		return;
  	}
d88746652   Tony Lindgren   omap mmc: Add bet...
608

e08016d0f   Anand Gadiyar   omap: mmc: split ...
609
610
611
  	omap242x_mmc_mux(mmc_data[0]);
  	omap_mmc_add(name, 0, OMAP2_MMC1_BASE, OMAP2420_MMC_SIZE,
  					INT_24XX_MMC_IRQ, mmc_data[0]);
d88746652   Tony Lindgren   omap mmc: Add bet...
612
613
614
615
616
  }
  
  #endif
  
  /*-------------------------------------------------------------------------*/
646e3ed1a   Tony Lindgren   ARM: OMAP2: Misc ...
617
  #if defined(CONFIG_HDQ_MASTER_OMAP) || defined(CONFIG_HDQ_MASTER_OMAP_MODULE)
59b479e09   Tony Lindgren   omap: Start using...
618
  #if defined(CONFIG_SOC_OMAP2430) || defined(CONFIG_SOC_OMAP3430)
646e3ed1a   Tony Lindgren   ARM: OMAP2: Misc ...
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
  #define OMAP_HDQ_BASE	0x480B2000
  #endif
  static struct resource omap_hdq_resources[] = {
  	{
  		.start		= OMAP_HDQ_BASE,
  		.end		= OMAP_HDQ_BASE + 0x1C,
  		.flags		= IORESOURCE_MEM,
  	},
  	{
  		.start		= INT_24XX_HDQ_IRQ,
  		.flags		= IORESOURCE_IRQ,
  	},
  };
  static struct platform_device omap_hdq_dev = {
  	.name = "omap_hdq",
  	.id = 0,
  	.dev = {
  		.platform_data = NULL,
  	},
  	.num_resources	= ARRAY_SIZE(omap_hdq_resources),
  	.resource	= omap_hdq_resources,
  };
  static inline void omap_hdq_init(void)
  {
  	(void) platform_device_register(&omap_hdq_dev);
  }
  #else
  static inline void omap_hdq_init(void) {}
  #endif
b227358d3   Vaibhav Hiremath   OMAP2/3: Add V4L2...
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
  /*---------------------------------------------------------------------------*/
  
  #if defined(CONFIG_VIDEO_OMAP2_VOUT) || \
  	defined(CONFIG_VIDEO_OMAP2_VOUT_MODULE)
  #if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
  static struct resource omap_vout_resource[3 - CONFIG_FB_OMAP2_NUM_FBS] = {
  };
  #else
  static struct resource omap_vout_resource[2] = {
  };
  #endif
  
  static struct platform_device omap_vout_device = {
  	.name		= "omap_vout",
  	.num_resources	= ARRAY_SIZE(omap_vout_resource),
  	.resource 	= &omap_vout_resource[0],
  	.id		= -1,
  };
  static void omap_init_vout(void)
  {
  	if (platform_device_register(&omap_vout_device) < 0)
  		printk(KERN_ERR "Unable to register OMAP-VOUT device
  ");
  }
  #else
  static inline void omap_init_vout(void) {}
  #endif
1dbae815a   Tony Lindgren   [ARM] 3145/1: OMA...
675
676
677
678
  /*-------------------------------------------------------------------------*/
  
  static int __init omap2_init_devices(void)
  {
81fbc5ef9   Paul Walmsley   OMAP2+: wd_timer:...
679
680
  	/*
  	 * please keep these calls, and their implementations above,
1dbae815a   Tony Lindgren   [ARM] 3145/1: OMA...
681
682
  	 * in alphabetical order so they're easier to sort through.
  	 */
f0fba2ad1   Liam Girdwood   ASoC: multi-compo...
683
  	omap_init_audio();
d231f5cba   Peter Ujfalusi   OMAP: McPDM: Conv...
684
  	omap_init_mcpdm();
828c707e6   Tony Lindgren   ARM: OMAP3: Add b...
685
  	omap_init_camera();
c40fae952   Tony Lindgren   ARM: OMAP: Sync c...
686
  	omap_init_mbox();
ed7eb9d90   Juha Yrjola   ARM: OMAP: Regist...
687
  	omap_init_mcspi();
883413341   Will Deacon   ARM: 6046/1: ARM:...
688
  	omap_init_pmu();
646e3ed1a   Tony Lindgren   ARM: OMAP2: Misc ...
689
  	omap_hdq_init();
9b6553cd0   Tony Lindgren   [ARM] 3433/1: ARM...
690
  	omap_init_sti();
ee5500c45   Dmitry Kasatkin   crypto: omap - Up...
691
  	omap_init_sham();
b744c679f   Dmitry Kasatkin   crypto: updates t...
692
  	omap_init_aes();
b227358d3   Vaibhav Hiremath   OMAP2/3: Add V4L2...
693
  	omap_init_vout();
1dbae815a   Tony Lindgren   [ARM] 3145/1: OMA...
694
695
696
697
  
  	return 0;
  }
  arch_initcall(omap2_init_devices);
f2ce62312   Varadarajan, Charulatha   OMAP: WDT: Split ...
698
699
  
  #if defined(CONFIG_OMAP_WATCHDOG) || defined(CONFIG_OMAP_WATCHDOG_MODULE)
f2ce62312   Varadarajan, Charulatha   OMAP: WDT: Split ...
700
701
702
  static int __init omap_init_wdt(void)
  {
  	int id = -1;
3528c58eb   Kevin Hilman   OMAP: omap_device...
703
  	struct platform_device *pdev;
f2ce62312   Varadarajan, Charulatha   OMAP: WDT: Split ...
704
705
706
707
708
709
710
711
712
713
714
715
716
  	struct omap_hwmod *oh;
  	char *oh_name = "wd_timer2";
  	char *dev_name = "omap_wdt";
  
  	if (!cpu_class_is_omap2())
  		return 0;
  
  	oh = omap_hwmod_lookup(oh_name);
  	if (!oh) {
  		pr_err("Could not look up wd_timer%d hwmod
  ", id);
  		return -EINVAL;
  	}
f718e2c03   Benoit Cousson   ARM: OMAP2+: devi...
717
  	pdev = omap_device_build(dev_name, id, oh, NULL, 0, NULL, 0, 0);
3528c58eb   Kevin Hilman   OMAP: omap_device...
718
719
  	WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.
  ",
f2ce62312   Varadarajan, Charulatha   OMAP: WDT: Split ...
720
721
722
723
724
  				dev_name, oh->name);
  	return 0;
  }
  subsys_initcall(omap_init_wdt);
  #endif