blob: 847329cafc5c060dc94f208a177652e8e9f047e2 [file] [log] [blame]
Tony Lindgren7c38cf02005-09-08 23:07:38 +01001/*
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>
Russell Kingd052d1b2005-10-29 19:07:23 +010016#include <linux/platform_device.h>
Tony Lindgren7c38cf02005-09-08 23:07:38 +010017
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
Tony Lindgren7c38cf02005-09-08 23:07:38 +010028#if defined(CONFIG_OMAP1610_IR) || defined(CONFIG_OMAP161O_IR_MODULE)
29
30static u64 irda_dmamask = 0xffffffff;
31
32static struct platform_device omap1610ir_device = {
33 .name = "omap1610-ir",
34 .id = -1,
35 .dev = {
Tony Lindgren7c38cf02005-09-08 23:07:38 +010036 .dma_mask = &irda_dmamask,
37 },
38};
39
40static void omap_init_irda(void)
41{
42 /* FIXME define and use a boot tag, members something like:
43 * u8 uart; // uart1, or uart3
44 * ... but driver only handles uart3 for now
45 * s16 fir_sel; // gpio for SIR vs FIR
46 * ... may prefer a callback for SIR/MIR/FIR mode select;
47 * while h2 uses a GPIO, H3 uses a gpio expander
48 */
49 if (machine_is_omap_h2()
50 || machine_is_omap_h3())
51 (void) platform_device_register(&omap1610ir_device);
52}
53#else
54static inline void omap_init_irda(void) {}
55#endif
56
57/*-------------------------------------------------------------------------*/
58
Tony Lindgren7c38cf02005-09-08 23:07:38 +010059#if defined(CONFIG_OMAP_RTC) || defined(CONFIG_OMAP_RTC)
60
61#define OMAP_RTC_BASE 0xfffb4800
62
63static struct resource rtc_resources[] = {
64 {
65 .start = OMAP_RTC_BASE,
66 .end = OMAP_RTC_BASE + 0x5f,
67 .flags = IORESOURCE_MEM,
68 },
69 {
70 .start = INT_RTC_TIMER,
71 .flags = IORESOURCE_IRQ,
72 },
73 {
74 .start = INT_RTC_ALARM,
75 .flags = IORESOURCE_IRQ,
76 },
77};
78
79static struct platform_device omap_rtc_device = {
80 .name = "omap_rtc",
81 .id = -1,
Tony Lindgren7c38cf02005-09-08 23:07:38 +010082 .num_resources = ARRAY_SIZE(rtc_resources),
83 .resource = rtc_resources,
84};
85
86static void omap_init_rtc(void)
87{
88 (void) platform_device_register(&omap_rtc_device);
89}
90#else
91static inline void omap_init_rtc(void) {}
92#endif
93
Tony Lindgren9b6553c2006-04-02 17:46:30 +010094#if defined(CONFIG_OMAP_STI)
95
96#define OMAP1_STI_BASE IO_ADDRESS(0xfffea000)
97#define OMAP1_STI_CHANNEL_BASE (OMAP1_STI_BASE + 0x400)
98
99static struct resource sti_resources[] = {
100 {
101 .start = OMAP1_STI_BASE,
102 .end = OMAP1_STI_BASE + SZ_1K - 1,
103 .flags = IORESOURCE_MEM,
104 },
105 {
106 .start = OMAP1_STI_CHANNEL_BASE,
107 .end = OMAP1_STI_CHANNEL_BASE + SZ_1K - 1,
108 .flags = IORESOURCE_MEM,
109 },
110 {
111 .start = INT_1610_STI,
112 .flags = IORESOURCE_IRQ,
113 }
114};
115
116static struct platform_device sti_device = {
117 .name = "sti",
118 .id = -1,
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100119 .num_resources = ARRAY_SIZE(sti_resources),
120 .resource = sti_resources,
121};
122
123static inline void omap_init_sti(void)
124{
125 platform_device_register(&sti_device);
126}
127#else
128static inline void omap_init_sti(void) {}
129#endif
Tony Lindgren7c38cf02005-09-08 23:07:38 +0100130
131/*-------------------------------------------------------------------------*/
132
133/*
134 * This gets called after board-specific INIT_MACHINE, and initializes most
135 * on-chip peripherals accessible on this board (except for few like USB):
136 *
137 * (a) Does any "standard config" pin muxing needed. Board-specific
138 * code will have muxed GPIO pins and done "nonstandard" setup;
139 * that code could live in the boot loader.
140 * (b) Populating board-specific platform_data with the data drivers
141 * rely on to handle wiring variations.
142 * (c) Creating platform devices as meaningful on this board and
143 * with this kernel configuration.
144 *
145 * Claiming GPIOs, and setting their direction and initial values, is the
146 * responsibility of the device drivers. So is responding to probe().
147 *
148 * Board-specific knowlege like creating devices or pin setup is to be
149 * kept out of drivers as much as possible. In particular, pin setup
150 * may be handled by the boot loader, and drivers should expect it will
151 * normally have been done by the time they're probed.
152 */
Tony Lindgren3179a012005-11-10 14:26:48 +0000153static int __init omap1_init_devices(void)
Tony Lindgren7c38cf02005-09-08 23:07:38 +0100154{
155 /* please keep these calls, and their implementations above,
156 * in alphabetical order so they're easier to sort through.
157 */
Tony Lindgren7c38cf02005-09-08 23:07:38 +0100158 omap_init_irda();
Tony Lindgren7c38cf02005-09-08 23:07:38 +0100159 omap_init_rtc();
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100160 omap_init_sti();
Tony Lindgren7c38cf02005-09-08 23:07:38 +0100161
162 return 0;
163}
Tony Lindgren3179a012005-11-10 14:26:48 +0000164arch_initcall(omap1_init_devices);
Tony Lindgren7c38cf02005-09-08 23:07:38 +0100165