2 * MikroTik RouterBOARD 4xx series support
4 * Copyright (C) 2008 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
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.
12 #include <linux/platform_device.h>
13 #include <linux/irq.h>
14 #include <linux/mmc/host.h>
15 #include <linux/spi/spi.h>
16 #include <linux/spi/flash.h>
17 #include <linux/spi/mmc_spi.h>
18 #include <linux/input.h>
20 #include <asm/mips_machine.h>
21 #include <asm/mach-ar71xx/ar71xx.h>
22 #include <asm/mach-ar71xx/pci.h>
23 #include <asm/mach-ar71xx/platform.h>
25 #define RB4XX_GPIO_USER_LED 4
26 #define RB4XX_GPIO_RESET_SWITCH 7
28 #define RB4XX_BUTTONS_POLL_INTERVAL 20
30 static struct gpio_led rb4xx_leds_gpio
[] __initdata
= {
32 .name
= "rb4xx:yellow:user",
33 .gpio
= RB4XX_GPIO_USER_LED
,
38 static struct gpio_button rb4xx_gpio_buttons
[] __initdata
= {
40 .desc
= "reset_switch",
44 .gpio
= RB4XX_GPIO_RESET_SWITCH
,
49 static struct platform_device rb4xx_nand_device
= {
54 static struct ar71xx_pci_irq rb4xx_pci_irqs
[] __initdata
= {
58 .irq
= AR71XX_PCI_IRQ_DEV0
,
62 .irq
= AR71XX_PCI_IRQ_DEV1
,
66 .irq
= AR71XX_PCI_IRQ_DEV1
,
70 .irq
= AR71XX_PCI_IRQ_DEV2
,
76 * SPI device support is experimental
78 static struct flash_platform_data rb4xx_flash_data
= {
82 static struct spi_board_info rb4xx_spi_info
[] = {
86 .max_speed_hz
= 25000000,
88 .platform_data
= &rb4xx_flash_data
,
92 static struct mmc_spi_platform_data rb433_mmc_data
= {
93 .ocr_mask
= MMC_VDD_32_33
| MMC_VDD_33_34
,
96 static struct spi_board_info rb433_spi_info
[] = {
100 .max_speed_hz
= 25000000,
101 .modalias
= "m25p80",
102 .platform_data
= &rb433_flash_data
,
106 .max_speed_hz
= 25000000,
107 .modalias
= "mmc_spi",
108 .platform_data
= &rb433_mmc_data
,
112 static u32
rb433_spi_get_ioc_base(u8 chip_select
, int cs_high
, int is_on
)
116 if (is_on
== AR71XX_SPI_CS_INACTIVE
) {
117 ret
= SPI_IOC_CS0
| SPI_IOC_CS1
;
120 ret
= SPI_IOC_CS0
| SPI_IOC_CS1
;
122 if ((chip_select
^ 2) == 0)
123 ret
= SPI_IOC_CS1
^ (SPI_IOC_CS0
| SPI_IOC_CS1
);
125 ret
= SPI_IOC_CS0
^ (SPI_IOC_CS0
| SPI_IOC_CS1
);
132 struct ar71xx_spi_platform_data rb433_spi_data
= {
135 .get_ioc_base
= rb433_spi_get_ioc_base
,
138 static void rb4xx_add_device_spi(void)
140 ar71xx_add_device_spi(NULL
, rb4xx_spi_info
, ARRAY_SIZE(rb4xx_spi_info
));
143 static void rb433_add_device_spi(void)
145 ar71xx_add_device_spi(&rb433_spi_data
, rb433_spi_info
,
146 ARRAY_SIZE(rb433_spi_info
));
149 static inline void rb4xx_add_device_spi(void) {}
150 static inline void rb433_add_device_spi(void) {}
153 static void __init
rb411_setup(void)
155 rb4xx_add_device_spi();
157 ar71xx_add_device_mdio(0xfffffffe);
158 ar71xx_add_device_eth(0, PHY_INTERFACE_MODE_MII
, 0x00000001);
160 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(rb4xx_leds_gpio
),
163 ar71xx_add_device_gpio_buttons(-1, RB4XX_BUTTONS_POLL_INTERVAL
,
164 ARRAY_SIZE(rb4xx_gpio_buttons
),
167 platform_device_register(&rb4xx_nand_device
);
169 ar71xx_pci_init(ARRAY_SIZE(rb4xx_pci_irqs
), rb4xx_pci_irqs
);
172 MIPS_MACHINE(MACH_AR71XX_RB_411
, "MikroTik RouterBOARD 411/A/AH", rb411_setup
);
174 static void __init
rb433_setup(void)
176 rb433_add_device_spi();
178 ar71xx_add_device_mdio(0xffffffec);
179 ar71xx_add_device_eth(1, PHY_INTERFACE_MODE_RMII
, 0x00000010);
180 ar71xx_add_device_eth(0, PHY_INTERFACE_MODE_MII
, 0x00000003);
182 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(rb4xx_leds_gpio
),
185 ar71xx_add_device_gpio_buttons(-1, RB4XX_BUTTONS_POLL_INTERVAL
,
186 ARRAY_SIZE(rb4xx_gpio_buttons
),
189 platform_device_register(&rb4xx_nand_device
);
191 ar71xx_pci_init(ARRAY_SIZE(rb4xx_pci_irqs
), rb4xx_pci_irqs
);
194 MIPS_MACHINE(MACH_AR71XX_RB_433
, "MikroTik RouterBOARD 433/AH", rb433_setup
);
196 static void __init
rb450_setup(void)
198 rb4xx_add_device_spi();
200 ar71xx_add_device_mdio(0xffffffe0);
201 ar71xx_add_device_eth(1, PHY_INTERFACE_MODE_RMII
, 0x00000010);
202 ar71xx_add_device_eth(0, PHY_INTERFACE_MODE_MII
, 0x0000000f);
204 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(rb4xx_leds_gpio
),
207 ar71xx_add_device_gpio_buttons(-1, RB4XX_BUTTONS_POLL_INTERVAL
,
208 ARRAY_SIZE(rb4xx_gpio_buttons
),
211 platform_device_register(&rb4xx_nand_device
);
214 MIPS_MACHINE(MACH_AR71XX_RB_450
, "MikroTik RouterBOARD 450", rb450_setup
);
216 static void __init
rb493_setup(void)
218 rb4xx_add_device_spi();
221 ar71xx_add_device_mdio(0x3fffff00);
222 ar71xx_add_device_eth(0, PHY_INTERFACE_MODE_MII
, 0x00000000);
223 ar71xx_add_device_eth(1, PHY_INTERFACE_MODE_RMII
, 0x00000001);
226 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(rb4xx_leds_gpio
),
229 ar71xx_add_device_gpio_buttons(-1, RB4XX_BUTTONS_POLL_INTERVAL
,
230 ARRAY_SIZE(rb4xx_gpio_buttons
),
233 platform_device_register(&rb4xx_nand_device
);
236 MIPS_MACHINE(MACH_AR71XX_RB_493
, "MikroTik RouterBOARD 493/AH", rb493_setup
);