diff options
author | David S. Miller <davem@davemloft.net> | 2009-06-15 06:02:23 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-06-15 06:02:23 -0400 |
commit | 9cbc1cb8cd46ce1f7645b9de249b2ce8460129bb (patch) | |
tree | 8d104ec2a459346b99413b0b77421ca7b9936c1a /arch/arm/mach-davinci/board-dm646x-evm.c | |
parent | ca44d6e60f9de26281fda203f58b570e1748c015 (diff) | |
parent | 45e3e1935e2857c54783291107d33323b3ef33c8 (diff) |
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6
Conflicts:
Documentation/feature-removal-schedule.txt
drivers/scsi/fcoe/fcoe.c
net/core/drop_monitor.c
net/core/net-traces.c
Diffstat (limited to 'arch/arm/mach-davinci/board-dm646x-evm.c')
-rw-r--r-- | arch/arm/mach-davinci/board-dm646x-evm.c | 262 |
1 files changed, 262 insertions, 0 deletions
diff --git a/arch/arm/mach-davinci/board-dm646x-evm.c b/arch/arm/mach-davinci/board-dm646x-evm.c new file mode 100644 index 000000000000..e17de6352624 --- /dev/null +++ b/arch/arm/mach-davinci/board-dm646x-evm.c | |||
@@ -0,0 +1,262 @@ | |||
1 | /* | ||
2 | * TI DaVinci DM646X EVM board | ||
3 | * | ||
4 | * Derived from: arch/arm/mach-davinci/board-evm.c | ||
5 | * Copyright (C) 2006 Texas Instruments. | ||
6 | * | ||
7 | * (C) 2007-2008, MontaVista Software, Inc. | ||
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public License | ||
10 | * version 2. This program is licensed "as is" without any warranty of any | ||
11 | * kind, whether express or implied. | ||
12 | * | ||
13 | */ | ||
14 | |||
15 | /************************************************************************** | ||
16 | * Included Files | ||
17 | **************************************************************************/ | ||
18 | |||
19 | #include <linux/kernel.h> | ||
20 | #include <linux/module.h> | ||
21 | #include <linux/init.h> | ||
22 | #include <linux/fs.h> | ||
23 | #include <linux/major.h> | ||
24 | #include <linux/root_dev.h> | ||
25 | #include <linux/dma-mapping.h> | ||
26 | #include <linux/serial.h> | ||
27 | #include <linux/serial_8250.h> | ||
28 | #include <linux/leds.h> | ||
29 | #include <linux/gpio.h> | ||
30 | #include <linux/io.h> | ||
31 | #include <linux/platform_device.h> | ||
32 | #include <linux/i2c.h> | ||
33 | #include <linux/i2c/at24.h> | ||
34 | #include <linux/i2c/pcf857x.h> | ||
35 | #include <linux/etherdevice.h> | ||
36 | |||
37 | #include <asm/setup.h> | ||
38 | #include <asm/mach-types.h> | ||
39 | #include <asm/mach/arch.h> | ||
40 | #include <asm/mach/map.h> | ||
41 | #include <asm/mach/flash.h> | ||
42 | |||
43 | #include <mach/dm646x.h> | ||
44 | #include <mach/common.h> | ||
45 | #include <mach/psc.h> | ||
46 | #include <mach/serial.h> | ||
47 | #include <mach/i2c.h> | ||
48 | #include <mach/mmc.h> | ||
49 | #include <mach/emac.h> | ||
50 | #include <mach/common.h> | ||
51 | |||
52 | #define DM646X_EVM_PHY_MASK (0x2) | ||
53 | #define DM646X_EVM_MDIO_FREQUENCY (2200000) /* PHY bus frequency */ | ||
54 | |||
55 | static struct davinci_uart_config uart_config __initdata = { | ||
56 | .enabled_uarts = (1 << 0), | ||
57 | }; | ||
58 | |||
59 | /* LEDS */ | ||
60 | |||
61 | static struct gpio_led evm_leds[] = { | ||
62 | { .name = "DS1", .active_low = 1, }, | ||
63 | { .name = "DS2", .active_low = 1, }, | ||
64 | { .name = "DS3", .active_low = 1, }, | ||
65 | { .name = "DS4", .active_low = 1, }, | ||
66 | }; | ||
67 | |||
68 | static __initconst struct gpio_led_platform_data evm_led_data = { | ||
69 | .num_leds = ARRAY_SIZE(evm_leds), | ||
70 | .leds = evm_leds, | ||
71 | }; | ||
72 | |||
73 | static struct platform_device *evm_led_dev; | ||
74 | |||
75 | static int evm_led_setup(struct i2c_client *client, int gpio, | ||
76 | unsigned int ngpio, void *c) | ||
77 | { | ||
78 | struct gpio_led *leds = evm_leds; | ||
79 | int status; | ||
80 | |||
81 | while (ngpio--) { | ||
82 | leds->gpio = gpio++; | ||
83 | leds++; | ||
84 | }; | ||
85 | |||
86 | evm_led_dev = platform_device_alloc("leds-gpio", 0); | ||
87 | platform_device_add_data(evm_led_dev, &evm_led_data, | ||
88 | sizeof(evm_led_data)); | ||
89 | |||
90 | evm_led_dev->dev.parent = &client->dev; | ||
91 | status = platform_device_add(evm_led_dev); | ||
92 | if (status < 0) { | ||
93 | platform_device_put(evm_led_dev); | ||
94 | evm_led_dev = NULL; | ||
95 | } | ||
96 | return status; | ||
97 | } | ||
98 | |||
99 | static int evm_led_teardown(struct i2c_client *client, int gpio, | ||
100 | unsigned ngpio, void *c) | ||
101 | { | ||
102 | if (evm_led_dev) { | ||
103 | platform_device_unregister(evm_led_dev); | ||
104 | evm_led_dev = NULL; | ||
105 | } | ||
106 | return 0; | ||
107 | } | ||
108 | |||
109 | static int evm_sw_gpio[4] = { -EINVAL, -EINVAL, -EINVAL, -EINVAL }; | ||
110 | |||
111 | static int evm_sw_setup(struct i2c_client *client, int gpio, | ||
112 | unsigned ngpio, void *c) | ||
113 | { | ||
114 | int status; | ||
115 | int i; | ||
116 | char label[10]; | ||
117 | |||
118 | for (i = 0; i < 4; ++i) { | ||
119 | snprintf(label, 10, "user_sw%d", i); | ||
120 | status = gpio_request(gpio, label); | ||
121 | if (status) | ||
122 | goto out_free; | ||
123 | evm_sw_gpio[i] = gpio++; | ||
124 | |||
125 | status = gpio_direction_input(evm_sw_gpio[i]); | ||
126 | if (status) { | ||
127 | gpio_free(evm_sw_gpio[i]); | ||
128 | evm_sw_gpio[i] = -EINVAL; | ||
129 | goto out_free; | ||
130 | } | ||
131 | |||
132 | status = gpio_export(evm_sw_gpio[i], 0); | ||
133 | if (status) { | ||
134 | gpio_free(evm_sw_gpio[i]); | ||
135 | evm_sw_gpio[i] = -EINVAL; | ||
136 | goto out_free; | ||
137 | } | ||
138 | } | ||
139 | return status; | ||
140 | out_free: | ||
141 | for (i = 0; i < 4; ++i) { | ||
142 | if (evm_sw_gpio[i] != -EINVAL) { | ||
143 | gpio_free(evm_sw_gpio[i]); | ||
144 | evm_sw_gpio[i] = -EINVAL; | ||
145 | } | ||
146 | } | ||
147 | return status; | ||
148 | } | ||
149 | |||
150 | static int evm_sw_teardown(struct i2c_client *client, int gpio, | ||
151 | unsigned ngpio, void *c) | ||
152 | { | ||
153 | int i; | ||
154 | |||
155 | for (i = 0; i < 4; ++i) { | ||
156 | if (evm_sw_gpio[i] != -EINVAL) { | ||
157 | gpio_unexport(evm_sw_gpio[i]); | ||
158 | gpio_free(evm_sw_gpio[i]); | ||
159 | evm_sw_gpio[i] = -EINVAL; | ||
160 | } | ||
161 | } | ||
162 | return 0; | ||
163 | } | ||
164 | |||
165 | static int evm_pcf_setup(struct i2c_client *client, int gpio, | ||
166 | unsigned int ngpio, void *c) | ||
167 | { | ||
168 | int status; | ||
169 | |||
170 | if (ngpio < 8) | ||
171 | return -EINVAL; | ||
172 | |||
173 | status = evm_sw_setup(client, gpio, 4, c); | ||
174 | if (status) | ||
175 | return status; | ||
176 | |||
177 | return evm_led_setup(client, gpio+4, 4, c); | ||
178 | } | ||
179 | |||
180 | static int evm_pcf_teardown(struct i2c_client *client, int gpio, | ||
181 | unsigned int ngpio, void *c) | ||
182 | { | ||
183 | BUG_ON(ngpio < 8); | ||
184 | |||
185 | evm_sw_teardown(client, gpio, 4, c); | ||
186 | evm_led_teardown(client, gpio+4, 4, c); | ||
187 | |||
188 | return 0; | ||
189 | } | ||
190 | |||
191 | static struct pcf857x_platform_data pcf_data = { | ||
192 | .gpio_base = DAVINCI_N_GPIO+1, | ||
193 | .setup = evm_pcf_setup, | ||
194 | .teardown = evm_pcf_teardown, | ||
195 | }; | ||
196 | |||
197 | /* Most of this EEPROM is unused, but U-Boot uses some data: | ||
198 | * - 0x7f00, 6 bytes Ethernet Address | ||
199 | * - ... newer boards may have more | ||
200 | */ | ||
201 | |||
202 | static struct at24_platform_data eeprom_info = { | ||
203 | .byte_len = (256*1024) / 8, | ||
204 | .page_size = 64, | ||
205 | .flags = AT24_FLAG_ADDR16, | ||
206 | .setup = davinci_get_mac_addr, | ||
207 | .context = (void *)0x7f00, | ||
208 | }; | ||
209 | |||
210 | static struct i2c_board_info __initdata i2c_info[] = { | ||
211 | { | ||
212 | I2C_BOARD_INFO("24c256", 0x50), | ||
213 | .platform_data = &eeprom_info, | ||
214 | }, | ||
215 | { | ||
216 | I2C_BOARD_INFO("pcf8574a", 0x38), | ||
217 | .platform_data = &pcf_data, | ||
218 | }, | ||
219 | }; | ||
220 | |||
221 | static struct davinci_i2c_platform_data i2c_pdata = { | ||
222 | .bus_freq = 100 /* kHz */, | ||
223 | .bus_delay = 0 /* usec */, | ||
224 | }; | ||
225 | |||
226 | static void __init evm_init_i2c(void) | ||
227 | { | ||
228 | davinci_init_i2c(&i2c_pdata); | ||
229 | i2c_register_board_info(1, i2c_info, ARRAY_SIZE(i2c_info)); | ||
230 | } | ||
231 | |||
232 | static void __init davinci_map_io(void) | ||
233 | { | ||
234 | dm646x_init(); | ||
235 | } | ||
236 | |||
237 | static __init void evm_init(void) | ||
238 | { | ||
239 | struct davinci_soc_info *soc_info = &davinci_soc_info; | ||
240 | |||
241 | evm_init_i2c(); | ||
242 | davinci_serial_init(&uart_config); | ||
243 | |||
244 | soc_info->emac_pdata->phy_mask = DM646X_EVM_PHY_MASK; | ||
245 | soc_info->emac_pdata->mdio_max_freq = DM646X_EVM_MDIO_FREQUENCY; | ||
246 | } | ||
247 | |||
248 | static __init void davinci_dm646x_evm_irq_init(void) | ||
249 | { | ||
250 | davinci_irq_init(); | ||
251 | } | ||
252 | |||
253 | MACHINE_START(DAVINCI_DM6467_EVM, "DaVinci DM646x EVM") | ||
254 | .phys_io = IO_PHYS, | ||
255 | .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc, | ||
256 | .boot_params = (0x80000100), | ||
257 | .map_io = davinci_map_io, | ||
258 | .init_irq = davinci_dm646x_evm_irq_init, | ||
259 | .timer = &davinci_timer, | ||
260 | .init_machine = evm_init, | ||
261 | MACHINE_END | ||
262 | |||