]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap1/devices.c
876c38da14f75c2d9e6023b9d5bbd05c5357d066
[linux-2.6-omap-h63xx.git] / arch / arm / mach-omap1 / devices.c
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/config.h>
13 #include <linux/module.h>
14 #include <linux/kernel.h>
15 #include <linux/init.h>
16 #include <linux/platform_device.h>
17
18 #include <asm/hardware.h>
19 #include <asm/io.h>
20 #include <asm/mach-types.h>
21 #include <asm/mach/map.h>
22
23 #include <asm/arch/tc.h>
24 #include <asm/arch/board.h>
25 #include <asm/arch/mux.h>
26 #include <asm/arch/gpio.h>
27
28 extern void omap_nop_release(struct device *dev);
29
30 /*-------------------------------------------------------------------------*/
31
32 #if     defined(CONFIG_OMAP1610_IR) || defined(CONFIG_OMAP161O_IR_MODULE)
33
34 static u64 irda_dmamask = 0xffffffff;
35
36 static struct platform_device omap1610ir_device = {
37         .name = "omap1610-ir",
38         .id = -1,
39         .dev = {
40                 .release        = omap_nop_release,
41                 .dma_mask       = &irda_dmamask,
42         },
43 };
44
45 static void omap_init_irda(void)
46 {
47         /* FIXME define and use a boot tag, members something like:
48          *  u8          uart;           // uart1, or uart3
49          * ... but driver only handles uart3 for now
50          *  s16         fir_sel;        // gpio for SIR vs FIR
51          * ... may prefer a callback for SIR/MIR/FIR mode select;
52          * while h2 uses a GPIO, H3 uses a gpio expander
53          */
54         if (machine_is_omap_h2()
55                         || machine_is_omap_h3())
56                 (void) platform_device_register(&omap1610ir_device);
57 }
58 #else
59 static inline void omap_init_irda(void) {}
60 #endif
61
62 /*-------------------------------------------------------------------------*/
63
64 #if     defined(CONFIG_OMAP_RTC) || defined(CONFIG_OMAP_RTC)
65
66 #define OMAP_RTC_BASE           0xfffb4800
67
68 static struct resource rtc_resources[] = {
69         {
70                 .start          = OMAP_RTC_BASE,
71                 .end            = OMAP_RTC_BASE + 0x5f,
72                 .flags          = IORESOURCE_MEM,
73         },
74         {
75                 .start          = INT_RTC_TIMER,
76                 .flags          = IORESOURCE_IRQ,
77         },
78         {
79                 .start          = INT_RTC_ALARM,
80                 .flags          = IORESOURCE_IRQ,
81         },
82 };
83
84 static struct platform_device omap_rtc_device = {
85         .name           = "omap_rtc",
86         .id             = -1,
87         .dev = {
88                 .release        = omap_nop_release,
89         },
90         .num_resources  = ARRAY_SIZE(rtc_resources),
91         .resource       = rtc_resources,
92 };
93
94 static void omap_init_rtc(void)
95 {
96         (void) platform_device_register(&omap_rtc_device);
97 }
98 #else
99 static inline void omap_init_rtc(void) {}
100 #endif
101
102 #if defined(CONFIG_OMAP_STI)
103
104 #define OMAP1_STI_BASE          IO_ADDRESS(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         .dev = {
128                 .release        = omap_nop_release,
129         },
130         .num_resources  = ARRAY_SIZE(sti_resources),
131         .resource       = sti_resources,
132 };
133
134 static inline void omap_init_sti(void)
135 {
136         platform_device_register(&sti_device);
137 }
138 #else
139 static inline void omap_init_sti(void) {}
140 #endif
141
142 /*-------------------------------------------------------------------------*/
143
144 /*
145  * This gets called after board-specific INIT_MACHINE, and initializes most
146  * on-chip peripherals accessible on this board (except for few like USB):
147  *
148  *  (a) Does any "standard config" pin muxing needed.  Board-specific
149  *      code will have muxed GPIO pins and done "nonstandard" setup;
150  *      that code could live in the boot loader.
151  *  (b) Populating board-specific platform_data with the data drivers
152  *      rely on to handle wiring variations.
153  *  (c) Creating platform devices as meaningful on this board and
154  *      with this kernel configuration.
155  *
156  * Claiming GPIOs, and setting their direction and initial values, is the
157  * responsibility of the device drivers.  So is responding to probe().
158  *
159  * Board-specific knowlege like creating devices or pin setup is to be
160  * kept out of drivers as much as possible.  In particular, pin setup
161  * may be handled by the boot loader, and drivers should expect it will
162  * normally have been done by the time they're probed.
163  */
164 static int __init omap1_init_devices(void)
165 {
166         /* please keep these calls, and their implementations above,
167          * in alphabetical order so they're easier to sort through.
168          */
169         omap_init_irda();
170         omap_init_rtc();
171         omap_init_sti();
172
173         return 0;
174 }
175 arch_initcall(omap1_init_devices);
176