]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-orion5x/dns323-setup.c
ad810aa5fff53615ae7431e5f16c6d2ff9cbeaed
[linux-2.6-omap-h63xx.git] / arch / arm / mach-orion5x / dns323-setup.c
1 /*
2  * arch/arm/mach-orion5x/dns323-setup.c
3  *
4  * Copyright (C) 2007 Herbert Valerio Riedel <hvr@gnu.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as
8  * published by the Free Software Foundation; either version 2 of the
9  * License, or (at your option) any later version.
10  *
11  */
12
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/platform_device.h>
16 #include <linux/pci.h>
17 #include <linux/irq.h>
18 #include <linux/mtd/physmap.h>
19 #include <linux/mv643xx_eth.h>
20 #include <linux/leds.h>
21 #include <linux/gpio_keys.h>
22 #include <linux/input.h>
23 #include <linux/i2c.h>
24 #include <asm/mach-types.h>
25 #include <asm/gpio.h>
26 #include <asm/mach/arch.h>
27 #include <asm/mach/pci.h>
28 #include <asm/arch/orion5x.h>
29 #include "common.h"
30 #include "mpp.h"
31
32 #define DNS323_GPIO_LED_RIGHT_AMBER     1
33 #define DNS323_GPIO_LED_LEFT_AMBER      2
34 #define DNS323_GPIO_LED_POWER           5
35 #define DNS323_GPIO_OVERTEMP            6
36 #define DNS323_GPIO_RTC                 7
37 #define DNS323_GPIO_POWER_OFF           8
38 #define DNS323_GPIO_KEY_POWER           9
39 #define DNS323_GPIO_KEY_RESET           10
40
41 /****************************************************************************
42  * PCI setup
43  */
44
45 static int __init dns323_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
46 {
47         int irq;
48
49         /*
50          * Check for devices with hard-wired IRQs.
51          */
52         irq = orion5x_pci_map_irq(dev, slot, pin);
53         if (irq != -1)
54                 return irq;
55
56         return -1;
57 }
58
59 static struct hw_pci dns323_pci __initdata = {
60         .nr_controllers = 2,
61         .swizzle        = pci_std_swizzle,
62         .setup          = orion5x_pci_sys_setup,
63         .scan           = orion5x_pci_sys_scan_bus,
64         .map_irq        = dns323_pci_map_irq,
65 };
66
67 static int __init dns323_pci_init(void)
68 {
69         if (machine_is_dns323())
70                 pci_common_init(&dns323_pci);
71
72         return 0;
73 }
74
75 subsys_initcall(dns323_pci_init);
76
77 /****************************************************************************
78  * Ethernet
79  */
80
81 static struct mv643xx_eth_platform_data dns323_eth_data = {
82         .phy_addr = 8,
83         .force_phy_addr = 1,
84 };
85
86 /****************************************************************************
87  * 8MiB NOR flash (Spansion S29GL064M90TFIR4)
88  *
89  * Layout as used by D-Link:
90  *  0x00000000-0x00010000 : "MTD1"
91  *  0x00010000-0x00020000 : "MTD2"
92  *  0x00020000-0x001a0000 : "Linux Kernel"
93  *  0x001a0000-0x007d0000 : "File System"
94  *  0x007d0000-0x00800000 : "u-boot"
95  */
96
97 #define DNS323_NOR_BOOT_BASE 0xf4000000
98 #define DNS323_NOR_BOOT_SIZE SZ_8M
99
100 static struct mtd_partition dns323_partitions[] = {
101         {
102                 .name   = "MTD1",
103                 .size   = 0x00010000,
104                 .offset = 0,
105         }, {
106                 .name   = "MTD2",
107                 .size   = 0x00010000,
108                 .offset = 0x00010000,
109         }, {
110                 .name   = "Linux Kernel",
111                 .size   = 0x00180000,
112                 .offset = 0x00020000,
113         }, {
114                 .name   = "File System",
115                 .size   = 0x00630000,
116                 .offset = 0x001A0000,
117         }, {
118                 .name   = "u-boot",
119                 .size   = 0x00030000,
120                 .offset = 0x007d0000,
121         },
122 };
123
124 static struct physmap_flash_data dns323_nor_flash_data = {
125         .width          = 1,
126         .parts          = dns323_partitions,
127         .nr_parts       = ARRAY_SIZE(dns323_partitions)
128 };
129
130 static struct resource dns323_nor_flash_resource = {
131         .flags          = IORESOURCE_MEM,
132         .start          = DNS323_NOR_BOOT_BASE,
133         .end            = DNS323_NOR_BOOT_BASE + DNS323_NOR_BOOT_SIZE - 1,
134 };
135
136 static struct platform_device dns323_nor_flash = {
137         .name           = "physmap-flash",
138         .id             = 0,
139         .dev            = {
140                 .platform_data  = &dns323_nor_flash_data,
141         },
142         .resource       = &dns323_nor_flash_resource,
143         .num_resources  = 1,
144 };
145
146 /****************************************************************************
147  * GPIO LEDs (simple - doesn't use hardware blinking support)
148  */
149
150 static struct gpio_led dns323_leds[] = {
151         {
152                 .name = "power:blue",
153                 .gpio = DNS323_GPIO_LED_POWER,
154                 .active_low = 1,
155         }, {
156                 .name = "right:amber",
157                 .gpio = DNS323_GPIO_LED_RIGHT_AMBER,
158                 .active_low = 1,
159         }, {
160                 .name = "left:amber",
161                 .gpio = DNS323_GPIO_LED_LEFT_AMBER,
162                 .active_low = 1,
163         },
164 };
165
166 static struct gpio_led_platform_data dns323_led_data = {
167         .num_leds       = ARRAY_SIZE(dns323_leds),
168         .leds           = dns323_leds,
169 };
170
171 static struct platform_device dns323_gpio_leds = {
172         .name           = "leds-gpio",
173         .id             = -1,
174         .dev            = {
175                 .platform_data  = &dns323_led_data,
176         },
177 };
178
179 /****************************************************************************
180  * GPIO Attached Keys
181  */
182
183 static struct gpio_keys_button dns323_buttons[] = {
184         {
185                 .code           = KEY_RESTART,
186                 .gpio           = DNS323_GPIO_KEY_RESET,
187                 .desc           = "Reset Button",
188                 .active_low     = 1,
189         }, {
190                 .code           = KEY_POWER,
191                 .gpio           = DNS323_GPIO_KEY_POWER,
192                 .desc           = "Power Button",
193                 .active_low     = 1,
194         },
195 };
196
197 static struct gpio_keys_platform_data dns323_button_data = {
198         .buttons        = dns323_buttons,
199         .nbuttons       = ARRAY_SIZE(dns323_buttons),
200 };
201
202 static struct platform_device dns323_button_device = {
203         .name           = "gpio-keys",
204         .id             = -1,
205         .num_resources  = 0,
206         .dev            = {
207                 .platform_data  = &dns323_button_data,
208         },
209 };
210
211 /****************************************************************************
212  * General Setup
213  */
214 static struct orion5x_mpp_mode dns323_mpp_modes[] __initdata = {
215         {  0, MPP_PCIE_RST_OUTn },
216         {  1, MPP_GPIO },               /* right amber LED (sata ch0) */
217         {  2, MPP_GPIO },               /* left amber LED (sata ch1) */
218         {  3, MPP_UNUSED },
219         {  4, MPP_GPIO },               /* power button LED */
220         {  5, MPP_GPIO },               /* power button LED */
221         {  6, MPP_GPIO },               /* GMT G751-2f overtemp */
222         {  7, MPP_GPIO },               /* M41T80 nIRQ/OUT/SQW */
223         {  8, MPP_GPIO },               /* triggers power off */
224         {  9, MPP_GPIO },               /* power button switch */
225         { 10, MPP_GPIO },               /* reset button switch */
226         { 11, MPP_UNUSED },
227         { 12, MPP_UNUSED },
228         { 13, MPP_UNUSED },
229         { 14, MPP_UNUSED },
230         { 15, MPP_UNUSED },
231         { 16, MPP_UNUSED },
232         { 17, MPP_UNUSED },
233         { 18, MPP_UNUSED },
234         { 19, MPP_UNUSED },
235         { -1 },
236 };
237
238 /*
239  * On the DNS-323 the following devices are attached via I2C:
240  *
241  *  i2c addr | chip        | description
242  *  0x3e     | GMT G760Af  | fan speed PWM controller
243  *  0x48     | GMT G751-2f | temp. sensor and therm. watchdog (LM75 compatible)
244  *  0x68     | ST M41T80   | RTC w/ alarm
245  */
246 static struct i2c_board_info __initdata dns323_i2c_devices[] = {
247         {
248                 I2C_BOARD_INFO("g760a", 0x3e),
249 #if 0
250         /* this entry requires the new-style driver model lm75 driver,
251          * for the meantime "insmod lm75.ko force_lm75=0,0x48" is needed */
252         }, {
253                 I2C_BOARD_INFO("g751", 0x48),
254 #endif
255         }, {
256                 I2C_BOARD_INFO("m41t80", 0x68),
257         },
258 };
259
260 /* DNS-323 specific power off method */
261 static void dns323_power_off(void)
262 {
263         pr_info("%s: triggering power-off...\n", __func__);
264         gpio_set_value(DNS323_GPIO_POWER_OFF, 1);
265 }
266
267 static void __init dns323_init(void)
268 {
269         /* Setup basic Orion functions. Need to be called early. */
270         orion5x_init();
271
272         orion5x_mpp_conf(dns323_mpp_modes);
273         orion5x_write(MPP_DEV_CTRL, 0);         /* DEV_D[31:16] */
274
275         /*
276          * Configure peripherals.
277          */
278         orion5x_ehci0_init();
279         orion5x_eth_init(&dns323_eth_data);
280         orion5x_i2c_init();
281         orion5x_uart0_init();
282
283         /* setup flash mapping
284          * CS3 holds a 8 MB Spansion S29GL064M90TFIR4
285          */
286         orion5x_setup_dev_boot_win(DNS323_NOR_BOOT_BASE, DNS323_NOR_BOOT_SIZE);
287         platform_device_register(&dns323_nor_flash);
288
289         platform_device_register(&dns323_gpio_leds);
290
291         platform_device_register(&dns323_button_device);
292
293         i2c_register_board_info(0, dns323_i2c_devices,
294                                 ARRAY_SIZE(dns323_i2c_devices));
295
296         /* register dns323 specific power-off method */
297         if (gpio_request(DNS323_GPIO_POWER_OFF, "POWEROFF") != 0 ||
298             gpio_direction_output(DNS323_GPIO_POWER_OFF, 0) != 0)
299                 pr_err("DNS323: failed to setup power-off GPIO\n");
300         pm_power_off = dns323_power_off;
301 }
302
303 /* Warning: D-Link uses a wrong mach-type (=526) in their bootloader */
304 MACHINE_START(DNS323, "D-Link DNS-323")
305         /* Maintainer: Herbert Valerio Riedel <hvr@gnu.org> */
306         .phys_io        = ORION5X_REGS_PHYS_BASE,
307         .io_pg_offst    = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
308         .boot_params    = 0x00000100,
309         .init_machine   = dns323_init,
310         .map_io         = orion5x_map_io,
311         .init_irq       = orion5x_init_irq,
312         .timer          = &orion5x_timer,
313         .fixup          = tag_fixup_mem32,
314 MACHINE_END