xref: /linux/arch/arm/mach-omap1/devices.c (revision 367b8112fe2ea5c39a7bb4d263dcdd9b612fae18)
1 /*
2  * linux/arch/arm/mach-omap1/devices.c
3  *
4  * OMAP1 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  */
11 
12 #include <linux/module.h>
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/platform_device.h>
16 #include <linux/io.h>
17 
18 #include <mach/hardware.h>
19 #include <asm/mach/map.h>
20 
21 #include <mach/tc.h>
22 #include <mach/board.h>
23 #include <mach/mux.h>
24 #include <mach/gpio.h>
25 
26 /*-------------------------------------------------------------------------*/
27 
28 #if defined(CONFIG_RTC_DRV_OMAP) || defined(CONFIG_RTC_DRV_OMAP_MODULE)
29 
30 #define	OMAP_RTC_BASE		0xfffb4800
31 
32 static struct resource rtc_resources[] = {
33 	{
34 		.start		= OMAP_RTC_BASE,
35 		.end		= OMAP_RTC_BASE + 0x5f,
36 		.flags		= IORESOURCE_MEM,
37 	},
38 	{
39 		.start		= INT_RTC_TIMER,
40 		.flags		= IORESOURCE_IRQ,
41 	},
42 	{
43 		.start		= INT_RTC_ALARM,
44 		.flags		= IORESOURCE_IRQ,
45 	},
46 };
47 
48 static struct platform_device omap_rtc_device = {
49 	.name           = "omap_rtc",
50 	.id             = -1,
51 	.num_resources	= ARRAY_SIZE(rtc_resources),
52 	.resource	= rtc_resources,
53 };
54 
55 static void omap_init_rtc(void)
56 {
57 	(void) platform_device_register(&omap_rtc_device);
58 }
59 #else
60 static inline void omap_init_rtc(void) {}
61 #endif
62 
63 #if defined(CONFIG_OMAP_DSP) || defined(CONFIG_OMAP_DSP_MODULE)
64 
65 #if defined(CONFIG_ARCH_OMAP15XX)
66 #  define OMAP1_MBOX_SIZE	0x23
67 #  define INT_DSP_MAILBOX1	INT_1510_DSP_MAILBOX1
68 #elif defined(CONFIG_ARCH_OMAP16XX)
69 #  define OMAP1_MBOX_SIZE	0x2f
70 #  define INT_DSP_MAILBOX1	INT_1610_DSP_MAILBOX1
71 #endif
72 
73 #define OMAP1_MBOX_BASE		IO_ADDRESS(OMAP16XX_MAILBOX_BASE)
74 
75 static struct resource mbox_resources[] = {
76 	{
77 		.start		= OMAP1_MBOX_BASE,
78 		.end		= OMAP1_MBOX_BASE + OMAP1_MBOX_SIZE,
79 		.flags		= IORESOURCE_MEM,
80 	},
81 	{
82 		.start		= INT_DSP_MAILBOX1,
83 		.flags		= IORESOURCE_IRQ,
84 	},
85 };
86 
87 static struct platform_device mbox_device = {
88 	.name		= "mailbox",
89 	.id		= -1,
90 	.num_resources	= ARRAY_SIZE(mbox_resources),
91 	.resource	= mbox_resources,
92 };
93 
94 static inline void omap_init_mbox(void)
95 {
96 	platform_device_register(&mbox_device);
97 }
98 #else
99 static inline void omap_init_mbox(void) { }
100 #endif
101 
102 #if defined(CONFIG_OMAP_STI)
103 
104 #define OMAP1_STI_BASE		0xfffea000
105 #define OMAP1_STI_CHANNEL_BASE	(OMAP1_STI_BASE + 0x400)
106 
107 static struct resource sti_resources[] = {
108 	{
109 		.start		= OMAP1_STI_BASE,
110 		.end		= OMAP1_STI_BASE + SZ_1K - 1,
111 		.flags		= IORESOURCE_MEM,
112 	},
113 	{
114 		.start		= OMAP1_STI_CHANNEL_BASE,
115 		.end		= OMAP1_STI_CHANNEL_BASE + SZ_1K - 1,
116 		.flags		= IORESOURCE_MEM,
117 	},
118 	{
119 		.start		= INT_1610_STI,
120 		.flags		= IORESOURCE_IRQ,
121 	}
122 };
123 
124 static struct platform_device sti_device = {
125 	.name		= "sti",
126 	.id		= -1,
127 	.num_resources	= ARRAY_SIZE(sti_resources),
128 	.resource	= sti_resources,
129 };
130 
131 static inline void omap_init_sti(void)
132 {
133 	platform_device_register(&sti_device);
134 }
135 #else
136 static inline void omap_init_sti(void) {}
137 #endif
138 
139 /*-------------------------------------------------------------------------*/
140 
141 /*
142  * This gets called after board-specific INIT_MACHINE, and initializes most
143  * on-chip peripherals accessible on this board (except for few like USB):
144  *
145  *  (a) Does any "standard config" pin muxing needed.  Board-specific
146  *	code will have muxed GPIO pins and done "nonstandard" setup;
147  *	that code could live in the boot loader.
148  *  (b) Populating board-specific platform_data with the data drivers
149  *	rely on to handle wiring variations.
150  *  (c) Creating platform devices as meaningful on this board and
151  *	with this kernel configuration.
152  *
153  * Claiming GPIOs, and setting their direction and initial values, is the
154  * responsibility of the device drivers.  So is responding to probe().
155  *
156  * Board-specific knowlege like creating devices or pin setup is to be
157  * kept out of drivers as much as possible.  In particular, pin setup
158  * may be handled by the boot loader, and drivers should expect it will
159  * normally have been done by the time they're probed.
160  */
161 static int __init omap1_init_devices(void)
162 {
163 	/* please keep these calls, and their implementations above,
164 	 * in alphabetical order so they're easier to sort through.
165 	 */
166 
167 	omap_init_mbox();
168 	omap_init_rtc();
169 	omap_init_sti();
170 
171 	return 0;
172 }
173 arch_initcall(omap1_init_devices);
174 
175