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/leds.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
27 static struct gpio_led rb4xx_leds_gpio[] = {
29 .name = "rb4xx:yellow:user",
30 .gpio = RB4XX_GPIO_USER_LED,
35 static struct gpio_led_platform_data rb4xx_leds_gpio_data = {
36 .leds = rb4xx_leds_gpio,
37 .num_leds = ARRAY_SIZE(rb4xx_leds_gpio),
40 static struct platform_device rb4xx_leds_gpio_device = {
44 .platform_data = &rb4xx_leds_gpio_data,
48 static struct platform_device rb4xx_nand_device = {
53 static struct ar71xx_pci_irq rb4xx_pci_irqs[] __initdata = {
57 .irq = AR71XX_PCI_IRQ_DEV0,
61 .irq = AR71XX_PCI_IRQ_DEV1,
65 .irq = AR71XX_PCI_IRQ_DEV1,
69 .irq = AR71XX_PCI_IRQ_DEV2,
75 * SPI device support is experimental
77 static struct flash_platform_data rb4xx_flash_data = {
81 static struct spi_board_info rb4xx_spi_info[] = {
85 .max_speed_hz = 25000000,
87 .platform_data = &rb4xx_flash_data,
91 static struct mmc_spi_platform_data rb433_mmc_data = {
92 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
95 static struct spi_board_info rb433_spi_info[] = {
99 .max_speed_hz = 25000000,
100 .modalias = "m25p80",
101 .platform_data = &rb433_flash_data,
105 .max_speed_hz = 25000000,
106 .modalias = "mmc_spi",
107 .platform_data = &rb433_mmc_data,
111 static u32 rb433_spi_get_ioc_base(u8 chip_select, int cs_high, int is_on)
115 if (is_on == AR71XX_SPI_CS_INACTIVE) {
116 ret = SPI_IOC_CS0 | SPI_IOC_CS1;
119 ret = SPI_IOC_CS0 | SPI_IOC_CS1;
121 if ((chip_select ^ 2) == 0)
122 ret = SPI_IOC_CS1 ^ (SPI_IOC_CS0 | SPI_IOC_CS1);
124 ret = SPI_IOC_CS0 ^ (SPI_IOC_CS0 | SPI_IOC_CS1);
131 struct ar71xx_spi_platform_data rb433_spi_data = {
134 .get_ioc_base = rb433_spi_get_ioc_base,
137 static void rb4xx_add_device_spi(void)
139 ar71xx_add_device_spi(NULL, rb4xx_spi_info, ARRAY_SIZE(rb4xx_spi_info));
142 static void rb433_add_device_spi(void)
144 ar71xx_add_device_spi(&rb433_spi_data, rb433_spi_info,
145 ARRAY_SIZE(rb433_spi_info));
148 static inline void rb4xx_add_device_spi(void) {}
149 static inline void rb433_add_device_spi(void) {}
152 static void __init rb411_setup(void)
154 rb4xx_add_device_spi();
156 ar71xx_add_device_eth(0, PHY_INTERFACE_MODE_MII, 0x00000001);
158 platform_device_register(&rb4xx_leds_gpio_device);
159 platform_device_register(&rb4xx_nand_device);
161 ar71xx_pci_init(ARRAY_SIZE(rb4xx_pci_irqs), rb4xx_pci_irqs);
164 MIPS_MACHINE(MACH_AR71XX_RB_411, "MikroTik RouterBOARD 411/A/AH", rb411_setup);
166 static void __init rb433_setup(void)
168 rb433_add_device_spi();
170 ar71xx_add_device_eth(0, PHY_INTERFACE_MODE_MII, 0x00000001);
171 ar71xx_add_device_eth(1, PHY_INTERFACE_MODE_RMII, 0xffffffff);
173 platform_device_register(&rb4xx_leds_gpio_device);
174 platform_device_register(&rb4xx_nand_device);
176 ar71xx_pci_init(ARRAY_SIZE(rb4xx_pci_irqs), rb4xx_pci_irqs);
179 MIPS_MACHINE(MACH_AR71XX_RB_433, "MikroTik RouterBOARD 433/AH", rb433_setup);
181 static void __init rb450_setup(void)
183 rb4xx_add_device_spi();
185 ar71xx_add_device_eth(0, PHY_INTERFACE_MODE_MII, 0x00000001);
186 ar71xx_add_device_eth(1, PHY_INTERFACE_MODE_RMII, 0xffffffff);
188 platform_device_register(&rb4xx_leds_gpio_device);
189 platform_device_register(&rb4xx_nand_device);
192 MIPS_MACHINE(MACH_AR71XX_RB_450, "MikroTik RouterBOARD 450", rb450_setup);