9044011ed4eba07b3591e6bfdb46bdae4009d6c4
[librecmc/librecmc.git] / target / linux / ar71xx / files / arch / mips / ar71xx / mach-wp543.c
1 /*
2  *  Compex WP543 board support
3  *
4  *  Copyright (C) 2008 Gabor Juhos <juhosg@openwrt.org>
5  *  Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
6  *
7  *  This program is free software; you can redistribute it and/or modify it
8  *  under the terms of the GNU General Public License version 2 as published
9  *  by the Free Software Foundation.
10  */
11
12 #include <linux/platform_device.h>
13 #include <linux/spi/spi.h>
14 #include <linux/spi/flash.h>
15 #include <linux/input.h>
16
17 #include <asm/mips_machine.h>
18 #include <asm/mach-ar71xx/ar71xx.h>
19 #include <asm/mach-ar71xx/pci.h>
20 #include <asm/mach-ar71xx/platform.h>
21
22 #define WP543_GPIO_SW6          2
23 #define WP543_GPIO_LED_1        3
24 #define WP543_GPIO_LED_2        4
25 #define WP543_GPIO_LED_WLAN     5
26 #define WP543_GPIO_LED_CONN     6
27 #define WP543_GPIO_LED_DIAG     7
28 #define WP543_GPIO_SW4          8
29
30 #define WP543_BUTTONS_POLL_INTERVAL     20
31
32 static struct flash_platform_data wp543_flash_data = {
33         /* TODO: add partition map */
34 };
35
36 static struct spi_board_info wp543_spi_info[] = {
37         {
38                 .bus_num        = 0,
39                 .chip_select    = 0,
40                 .max_speed_hz   = 25000000,
41                 .modalias       = "m25p80",
42                 .platform_data  = &wp543_flash_data,
43         }
44 };
45
46 static struct ar71xx_pci_irq wp543_pci_irqs[] __initdata = {
47         {
48                 .slot   = 1,
49                 .pin    = 1,
50                 .irq    = AR71XX_PCI_IRQ_DEV0,
51         }, {
52                 .slot   = 1,
53                 .pin    = 2,
54                 .irq    = AR71XX_PCI_IRQ_DEV1,
55         }
56 };
57
58 static struct gpio_led wp543_leds_gpio[] __initdata = {
59         {
60                 .name           = "wp543:green:led1",
61                 .gpio           = WP543_GPIO_LED_1,
62                 .active_low     = 1,
63         }, {
64                 .name           = "wp543:green:led2",
65                 .gpio           = WP543_GPIO_LED_2,
66                 .active_low     = 1,
67         }, {
68                 .name           = "wp543:green:wlan",
69                 .gpio           = WP543_GPIO_LED_WLAN,
70                 .active_low     = 1,
71         }, {
72                 .name           = "wp543:green:conn",
73                 .gpio           = WP543_GPIO_LED_CONN,
74                 .active_low     = 1,
75         }, {
76                 .name           = "wp543:green:diag",
77                 .gpio           = WP543_GPIO_LED_DIAG,
78                 .active_low     = 1,
79         }
80 };
81
82 static struct gpio_button wp543_gpio_buttons[] __initdata = {
83         {
84                 .desc           = "sw6",
85                 .type           = EV_KEY,
86                 .code           = BTN_0,
87                 .threshold      = 5,
88                 .gpio           = WP543_GPIO_SW6,
89         }, {
90                 .desc           = "sw4",
91                 .type           = EV_KEY,
92                 .code           = BTN_1,
93                 .threshold      = 5,
94                 .gpio           = WP543_GPIO_SW4,
95         }
96 };
97
98 static void __init wp543_setup(void)
99 {
100         ar71xx_add_device_spi(NULL, wp543_spi_info, ARRAY_SIZE(wp543_spi_info));
101
102         ar71xx_add_device_mdio(0xfffffff7);
103         ar71xx_add_device_eth(0, PHY_INTERFACE_MODE_MII, 0x00000008);
104
105         ar71xx_add_device_usb();
106
107         ar71xx_pci_init(ARRAY_SIZE(wp543_pci_irqs), wp543_pci_irqs);
108
109         ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(wp543_leds_gpio),
110                                         wp543_leds_gpio);
111
112         ar71xx_add_device_gpio_buttons(-1, WP543_BUTTONS_POLL_INTERVAL,
113                                         ARRAY_SIZE(wp543_gpio_buttons),
114                                         wp543_gpio_buttons);
115 }
116
117 MIPS_MACHINE(MACH_AR71XX_WP543, "Compex WP543", wp543_setup);