| 1 | /* |
| 2 | * Zcomax ZCN-1523H-2-8/5-16 board support |
| 3 | * |
| 4 | * Copyright (C) 2010-2012 Gabor Juhos <juhosg@openwrt.org> |
| 5 | * |
| 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. |
| 9 | */ |
| 10 | |
| 11 | #include <linux/mtd/mtd.h> |
| 12 | #include <linux/mtd/partitions.h> |
| 13 | |
| 14 | #include <asm/mach-ath79/ath79.h> |
| 15 | #include <asm/mach-ath79/ar71xx_regs.h> |
| 16 | |
| 17 | #include "common.h" |
| 18 | #include "dev-eth.h" |
| 19 | #include "dev-m25p80.h" |
| 20 | #include "dev-ap9x-pci.h" |
| 21 | #include "dev-gpio-buttons.h" |
| 22 | #include "dev-leds-gpio.h" |
| 23 | #include "machtypes.h" |
| 24 | |
| 25 | #define ZCN_1523H_GPIO_BTN_RESET 0 |
| 26 | #define ZCN_1523H_GPIO_LED_INIT 11 |
| 27 | #define ZCN_1523H_GPIO_LED_LAN1 17 |
| 28 | |
| 29 | #define ZCN_1523H_2_GPIO_LED_WEAK 13 |
| 30 | #define ZCN_1523H_2_GPIO_LED_MEDIUM 14 |
| 31 | #define ZCN_1523H_2_GPIO_LED_STRONG 15 |
| 32 | |
| 33 | #define ZCN_1523H_5_GPIO_LED_UNKNOWN 1 |
| 34 | #define ZCN_1523H_5_GPIO_LED_LAN2 13 |
| 35 | #define ZCN_1523H_5_GPIO_LED_WEAK 14 |
| 36 | #define ZCN_1523H_5_GPIO_LED_MEDIUM 15 |
| 37 | #define ZCN_1523H_5_GPIO_LED_STRONG 16 |
| 38 | |
| 39 | #define ZCN_1523H_KEYS_POLL_INTERVAL 20 /* msecs */ |
| 40 | #define ZCN_1523H_KEYS_DEBOUNCE_INTERVAL (3 * ZCN_1523H_KEYS_POLL_INTERVAL) |
| 41 | |
| 42 | static struct mtd_partition zcn_1523h_partitions[] = { |
| 43 | { |
| 44 | .name = "u-boot", |
| 45 | .offset = 0, |
| 46 | .size = 0x040000, |
| 47 | .mask_flags = MTD_WRITEABLE, |
| 48 | }, { |
| 49 | .name = "u-boot-env", |
| 50 | .offset = 0x040000, |
| 51 | .size = 0x010000, |
| 52 | .mask_flags = MTD_WRITEABLE, |
| 53 | }, { |
| 54 | .name = "rootfs", |
| 55 | .offset = 0x050000, |
| 56 | .size = 0x610000, |
| 57 | }, { |
| 58 | .name = "kernel", |
| 59 | .offset = 0x660000, |
| 60 | .size = 0x170000, |
| 61 | }, { |
| 62 | .name = "configure", |
| 63 | .offset = 0x7d0000, |
| 64 | .size = 0x010000, |
| 65 | .mask_flags = MTD_WRITEABLE, |
| 66 | }, { |
| 67 | .name = "mfg", |
| 68 | .offset = 0x7e0000, |
| 69 | .size = 0x010000, |
| 70 | .mask_flags = MTD_WRITEABLE, |
| 71 | }, { |
| 72 | .name = "eeprom", |
| 73 | .offset = 0x7f0000, |
| 74 | .size = 0x010000, |
| 75 | .mask_flags = MTD_WRITEABLE, |
| 76 | }, { |
| 77 | .name = "firmware", |
| 78 | .offset = 0x050000, |
| 79 | .size = 0x780000, |
| 80 | } |
| 81 | }; |
| 82 | |
| 83 | static struct flash_platform_data zcn_1523h_flash_data = { |
| 84 | .parts = zcn_1523h_partitions, |
| 85 | .nr_parts = ARRAY_SIZE(zcn_1523h_partitions), |
| 86 | }; |
| 87 | |
| 88 | static struct gpio_keys_button zcn_1523h_gpio_keys[] __initdata = { |
| 89 | { |
| 90 | .desc = "reset", |
| 91 | .type = EV_KEY, |
| 92 | .code = KEY_RESTART, |
| 93 | .debounce_interval = ZCN_1523H_KEYS_DEBOUNCE_INTERVAL, |
| 94 | .gpio = ZCN_1523H_GPIO_BTN_RESET, |
| 95 | .active_low = 1, |
| 96 | } |
| 97 | }; |
| 98 | |
| 99 | static struct gpio_led zcn_1523h_leds_gpio[] __initdata = { |
| 100 | { |
| 101 | .name = "zcn-1523h:amber:init", |
| 102 | .gpio = ZCN_1523H_GPIO_LED_INIT, |
| 103 | .active_low = 1, |
| 104 | }, { |
| 105 | .name = "zcn-1523h:green:lan1", |
| 106 | .gpio = ZCN_1523H_GPIO_LED_LAN1, |
| 107 | .active_low = 1, |
| 108 | } |
| 109 | }; |
| 110 | |
| 111 | static struct gpio_led zcn_1523h_2_leds_gpio[] __initdata = { |
| 112 | { |
| 113 | .name = "zcn-1523h:red:weak", |
| 114 | .gpio = ZCN_1523H_2_GPIO_LED_WEAK, |
| 115 | .active_low = 1, |
| 116 | }, { |
| 117 | .name = "zcn-1523h:amber:medium", |
| 118 | .gpio = ZCN_1523H_2_GPIO_LED_MEDIUM, |
| 119 | .active_low = 1, |
| 120 | }, { |
| 121 | .name = "zcn-1523h:green:strong", |
| 122 | .gpio = ZCN_1523H_2_GPIO_LED_STRONG, |
| 123 | .active_low = 1, |
| 124 | } |
| 125 | }; |
| 126 | |
| 127 | static struct gpio_led zcn_1523h_5_leds_gpio[] __initdata = { |
| 128 | { |
| 129 | .name = "zcn-1523h:red:weak", |
| 130 | .gpio = ZCN_1523H_5_GPIO_LED_WEAK, |
| 131 | .active_low = 1, |
| 132 | }, { |
| 133 | .name = "zcn-1523h:amber:medium", |
| 134 | .gpio = ZCN_1523H_5_GPIO_LED_MEDIUM, |
| 135 | .active_low = 1, |
| 136 | }, { |
| 137 | .name = "zcn-1523h:green:strong", |
| 138 | .gpio = ZCN_1523H_5_GPIO_LED_STRONG, |
| 139 | .active_low = 1, |
| 140 | }, { |
| 141 | .name = "zcn-1523h:green:lan2", |
| 142 | .gpio = ZCN_1523H_5_GPIO_LED_LAN2, |
| 143 | .active_low = 1, |
| 144 | }, { |
| 145 | .name = "zcn-1523h:amber:unknown", |
| 146 | .gpio = ZCN_1523H_5_GPIO_LED_UNKNOWN, |
| 147 | } |
| 148 | }; |
| 149 | |
| 150 | static void __init zcn_1523h_generic_setup(void) |
| 151 | { |
| 152 | u8 *mac = (u8 *) KSEG1ADDR(0x1f7e0004); |
| 153 | u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000); |
| 154 | |
| 155 | ath79_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN | |
| 156 | AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN | |
| 157 | AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN | |
| 158 | AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN | |
| 159 | AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN); |
| 160 | |
| 161 | ath79_register_m25p80(&zcn_1523h_flash_data); |
| 162 | |
| 163 | ath79_register_leds_gpio(0, ARRAY_SIZE(zcn_1523h_leds_gpio), |
| 164 | zcn_1523h_leds_gpio); |
| 165 | |
| 166 | ath79_register_gpio_keys_polled(-1, ZCN_1523H_KEYS_POLL_INTERVAL, |
| 167 | ARRAY_SIZE(zcn_1523h_gpio_keys), |
| 168 | zcn_1523h_gpio_keys); |
| 169 | |
| 170 | ap91_pci_init(ee, mac); |
| 171 | |
| 172 | ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0); |
| 173 | ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1); |
| 174 | |
| 175 | ath79_register_mdio(0, 0x0); |
| 176 | |
| 177 | /* LAN1 port */ |
| 178 | ath79_register_eth(0); |
| 179 | } |
| 180 | |
| 181 | static void __init zcn_1523h_2_setup(void) |
| 182 | { |
| 183 | zcn_1523h_generic_setup(); |
| 184 | ap9x_pci_setup_wmac_gpio(0, BIT(9), 0); |
| 185 | |
| 186 | ath79_register_leds_gpio(1, ARRAY_SIZE(zcn_1523h_2_leds_gpio), |
| 187 | zcn_1523h_2_leds_gpio); |
| 188 | } |
| 189 | |
| 190 | MIPS_MACHINE(ATH79_MACH_ZCN_1523H_2, "ZCN-1523H-2", "Zcomax ZCN-1523H-2", |
| 191 | zcn_1523h_2_setup); |
| 192 | |
| 193 | static void __init zcn_1523h_5_setup(void) |
| 194 | { |
| 195 | zcn_1523h_generic_setup(); |
| 196 | ap9x_pci_setup_wmac_gpio(0, BIT(8), 0); |
| 197 | |
| 198 | ath79_register_leds_gpio(1, ARRAY_SIZE(zcn_1523h_5_leds_gpio), |
| 199 | zcn_1523h_5_leds_gpio); |
| 200 | |
| 201 | /* LAN2 port */ |
| 202 | ath79_register_eth(1); |
| 203 | } |
| 204 | |
| 205 | MIPS_MACHINE(ATH79_MACH_ZCN_1523H_5, "ZCN-1523H-5", "Zcomax ZCN-1523H-5", |
| 206 | zcn_1523h_5_setup); |
| 207 | |