| 1 | /* |
| 2 | * NETGEAR WNR2000 board support |
| 3 | * |
| 4 | * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org> |
| 5 | * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org> |
| 6 | * Copyright (C) 2008-2009 Andy Boyett <agb@openwrt.org> |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify it |
| 9 | * under the terms of the GNU General Public License version 2 as published |
| 10 | * by the Free Software Foundation. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/mtd/mtd.h> |
| 14 | #include <linux/mtd/partitions.h> |
| 15 | |
| 16 | #include <asm/mach-ar71xx/ar71xx.h> |
| 17 | |
| 18 | #include "machtype.h" |
| 19 | #include "devices.h" |
| 20 | #include "dev-m25p80.h" |
| 21 | #include "dev-ar9xxx-wmac.h" |
| 22 | #include "dev-gpio-buttons.h" |
| 23 | #include "dev-leds-gpio.h" |
| 24 | |
| 25 | #define WNR2000_GPIO_LED_PWR_GREEN 14 |
| 26 | #define WNR2000_GPIO_LED_PWR_AMBER 7 |
| 27 | #define WNR2000_GPIO_LED_WPS 4 |
| 28 | #define WNR2000_GPIO_LED_WLAN 6 |
| 29 | #define WNR2000_GPIO_BTN_RESET 21 |
| 30 | #define WNR2000_GPIO_BTN_WPS 8 |
| 31 | |
| 32 | #define WNR2000_KEYS_POLL_INTERVAL 20 /* msecs */ |
| 33 | #define WNR2000_KEYS_DEBOUNCE_INTERVAL (3 * WNR2000_KEYS_POLL_INTERVAL) |
| 34 | |
| 35 | #ifdef CONFIG_MTD_PARTITIONS |
| 36 | static struct mtd_partition wnr2000_partitions[] = { |
| 37 | { |
| 38 | .name = "u-boot", |
| 39 | .offset = 0, |
| 40 | .size = 0x040000, |
| 41 | .mask_flags = MTD_WRITEABLE, |
| 42 | }, { |
| 43 | .name = "u-boot-env", |
| 44 | .offset = 0x040000, |
| 45 | .size = 0x010000, |
| 46 | }, { |
| 47 | .name = "rootfs", |
| 48 | .offset = 0x050000, |
| 49 | .size = 0x240000, |
| 50 | }, { |
| 51 | .name = "user-config", |
| 52 | .offset = 0x290000, |
| 53 | .size = 0x010000, |
| 54 | }, { |
| 55 | .name = "uImage", |
| 56 | .offset = 0x2a0000, |
| 57 | .size = 0x120000, |
| 58 | }, { |
| 59 | .name = "language_table", |
| 60 | .offset = 0x3c0000, |
| 61 | .size = 0x020000, |
| 62 | }, { |
| 63 | .name = "rootfs_checksum", |
| 64 | .offset = 0x3e0000, |
| 65 | .size = 0x010000, |
| 66 | }, { |
| 67 | .name = "art", |
| 68 | .offset = 0x3f0000, |
| 69 | .size = 0x010000, |
| 70 | .mask_flags = MTD_WRITEABLE, |
| 71 | } |
| 72 | }; |
| 73 | #endif /* CONFIG_MTD_PARTITIONS */ |
| 74 | |
| 75 | static struct flash_platform_data wnr2000_flash_data = { |
| 76 | #ifdef CONFIG_MTD_PARTITIONS |
| 77 | .parts = wnr2000_partitions, |
| 78 | .nr_parts = ARRAY_SIZE(wnr2000_partitions), |
| 79 | #endif |
| 80 | }; |
| 81 | |
| 82 | static struct gpio_led wnr2000_leds_gpio[] __initdata = { |
| 83 | { |
| 84 | .name = "wnr2000:green:power", |
| 85 | .gpio = WNR2000_GPIO_LED_PWR_GREEN, |
| 86 | .active_low = 1, |
| 87 | }, { |
| 88 | .name = "wnr2000:amber:power", |
| 89 | .gpio = WNR2000_GPIO_LED_PWR_AMBER, |
| 90 | .active_low = 1, |
| 91 | }, { |
| 92 | .name = "wnr2000:green:wps", |
| 93 | .gpio = WNR2000_GPIO_LED_WPS, |
| 94 | .active_low = 1, |
| 95 | }, { |
| 96 | .name = "wnr2000:blue:wlan", |
| 97 | .gpio = WNR2000_GPIO_LED_WLAN, |
| 98 | .active_low = 1, |
| 99 | } |
| 100 | }; |
| 101 | |
| 102 | static struct gpio_keys_button wnr2000_gpio_keys[] __initdata = { |
| 103 | { |
| 104 | .desc = "reset", |
| 105 | .type = EV_KEY, |
| 106 | .code = KEY_RESTART, |
| 107 | .debounce_interval = WNR2000_KEYS_DEBOUNCE_INTERVAL, |
| 108 | .gpio = WNR2000_GPIO_BTN_RESET, |
| 109 | }, { |
| 110 | .desc = "wps", |
| 111 | .type = EV_KEY, |
| 112 | .code = KEY_WPS_BUTTON, |
| 113 | .debounce_interval = WNR2000_KEYS_DEBOUNCE_INTERVAL, |
| 114 | .gpio = WNR2000_GPIO_BTN_WPS, |
| 115 | } |
| 116 | }; |
| 117 | |
| 118 | static void __init wnr2000_setup(void) |
| 119 | { |
| 120 | u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000); |
| 121 | |
| 122 | ar71xx_add_device_mdio(0x0); |
| 123 | |
| 124 | ar71xx_init_mac(ar71xx_eth0_data.mac_addr, eeprom, 0); |
| 125 | ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII; |
| 126 | ar71xx_eth0_data.speed = SPEED_100; |
| 127 | ar71xx_eth0_data.duplex = DUPLEX_FULL; |
| 128 | ar71xx_eth0_data.has_ar8216 = 1; |
| 129 | |
| 130 | ar71xx_init_mac(ar71xx_eth1_data.mac_addr, eeprom, 1); |
| 131 | ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII; |
| 132 | ar71xx_eth1_data.phy_mask = 0x10; |
| 133 | |
| 134 | ar71xx_add_device_eth(0); |
| 135 | ar71xx_add_device_eth(1); |
| 136 | |
| 137 | ar71xx_add_device_m25p80(&wnr2000_flash_data); |
| 138 | |
| 139 | ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(wnr2000_leds_gpio), |
| 140 | wnr2000_leds_gpio); |
| 141 | |
| 142 | ar71xx_register_gpio_keys_polled(-1, WNR2000_KEYS_POLL_INTERVAL, |
| 143 | ARRAY_SIZE(wnr2000_gpio_keys), |
| 144 | wnr2000_gpio_keys); |
| 145 | |
| 146 | |
| 147 | ar9xxx_add_device_wmac(eeprom, NULL); |
| 148 | } |
| 149 | |
| 150 | MIPS_MACHINE(AR71XX_MACH_WNR2000, "WNR2000", "NETGEAR WNR2000", wnr2000_setup); |
| 151 | |