2 * Mikrotik RouterBOARD 150 support
4 * Copyright (C) 2007-2008 Gabor Juhos <juhosg@openwrt.org>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
14 #define RB150_NAND_BASE 0x1FC80000
15 #define RB150_NAND_SIZE 1
17 #define RB150_GPIO_NAND_READY ADM5120_GPIO_PIN0
18 #define RB150_GPIO_NAND_NCE ADM5120_GPIO_PIN1
19 #define RB150_GPIO_NAND_CLE ADM5120_GPIO_P2L2
20 #define RB150_GPIO_NAND_ALE ADM5120_GPIO_P3L2
21 #define RB150_GPIO_RESET_BUTTON ADM5120_GPIO_PIN1 /* FIXME */
23 #define RB150_NAND_DELAY 100
25 #define RB150_NAND_WRITE(v) \
26 writeb((v), (void __iomem *)KSEG1ADDR(RB150_NAND_BASE))
28 static struct resource rb150_nand_resources[] __initdata = {
30 .start = RB150_NAND_BASE,
31 .end = RB150_NAND_BASE + RB150_NAND_SIZE-1,
32 .flags = IORESOURCE_MEM,
36 static struct gpio_led rb150_gpio_leds[] __initdata = {
37 GPIO_LED_STD(ADM5120_GPIO_P0L2, "user", NULL),
38 GPIO_LED_INV(ADM5120_GPIO_P0L1, "lan1_led1", NULL),
39 GPIO_LED_INV(ADM5120_GPIO_P0L0, "lan1_led2", NULL),
40 GPIO_LED_INV(ADM5120_GPIO_P1L1, "lan5_led1", NULL),
41 GPIO_LED_INV(ADM5120_GPIO_P1L0, "lan5_led2", NULL),
42 GPIO_LED_INV(ADM5120_GPIO_P2L1, "lan4_led1", NULL),
43 GPIO_LED_INV(ADM5120_GPIO_P2L0, "lan4_led2", NULL),
44 GPIO_LED_INV(ADM5120_GPIO_P3L1, "lan3_led1", NULL),
45 GPIO_LED_INV(ADM5120_GPIO_P3L0, "lan3_led2", NULL),
46 GPIO_LED_INV(ADM5120_GPIO_P4L1, "lan2_led1", NULL),
47 GPIO_LED_INV(ADM5120_GPIO_P4L0, "lan2_led2", NULL),
50 static u8 rb150_vlans[6] __initdata = {
51 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00
54 static int rb150_nand_dev_ready(struct mtd_info *mtd)
56 return gpio_get_value(RB150_GPIO_NAND_READY);
59 static void rb150_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
62 if (ctrl & NAND_CTRL_CHANGE) {
63 gpio_set_value(RB150_GPIO_NAND_CLE, (ctrl & NAND_CLE) ? 1 : 0);
64 gpio_set_value(RB150_GPIO_NAND_ALE, (ctrl & NAND_ALE) ? 1 : 0);
65 gpio_set_value(RB150_GPIO_NAND_NCE, (ctrl & NAND_NCE) ? 0 : 1);
68 udelay(RB150_NAND_DELAY);
70 if (cmd != NAND_CMD_NONE)
71 RB150_NAND_WRITE(cmd);
74 static void __init rb150_add_device_nand(void)
76 struct platform_device *pdev;
79 /* setup GPIO pins for NAND flash chip */
80 gpio_request(RB150_GPIO_NAND_READY, "nand-ready");
81 gpio_direction_input(RB150_GPIO_NAND_READY);
82 gpio_request(RB150_GPIO_NAND_NCE, "nand-nce");
83 gpio_direction_output(RB150_GPIO_NAND_NCE, 1);
84 gpio_request(RB150_GPIO_NAND_CLE, "nand-cle");
85 gpio_direction_output(RB150_GPIO_NAND_CLE, 0);
86 gpio_request(RB150_GPIO_NAND_ALE, "nand-ale");
87 gpio_direction_output(RB150_GPIO_NAND_ALE, 0);
89 pdev = platform_device_alloc("gen_nand", -1);
93 err = platform_device_add_resources(pdev, rb150_nand_resources,
94 ARRAY_SIZE(rb150_nand_resources));
99 rb1xx_nand_data.ctrl.cmd_ctrl = rb150_nand_cmd_ctrl;
100 rb1xx_nand_data.ctrl.dev_ready = rb150_nand_dev_ready;
102 err = platform_device_add_data(pdev, &rb1xx_nand_data,
103 sizeof(rb1xx_nand_data));
107 err = platform_device_add(pdev);
114 platform_device_put(pdev);
119 static void __init rb150_setup(void)
121 rb1xx_gpio_buttons[0].gpio = RB150_GPIO_RESET_BUTTON;
122 rb1xx_generic_setup();
123 rb150_add_device_nand();
125 adm5120_add_device_gpio_leds(ARRAY_SIZE(rb150_gpio_leds),
127 adm5120_add_device_switch(5, rb150_vlans);
130 MIPS_MACHINE(MACH_ADM5120_RB_150, "miniROUTER", "Mikrotik RouterBOARD 150",