| 1 | /* |
| 2 | * Allnet ALL0258N support |
| 3 | * |
| 4 | * Copyright (C) 2011 Daniel Golle <dgolle@allnet.de> |
| 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 | |
| 16 | #include "dev-eth.h" |
| 17 | #include "dev-ap9x-pci.h" |
| 18 | #include "dev-gpio-buttons.h" |
| 19 | #include "dev-leds-gpio.h" |
| 20 | #include "dev-m25p80.h" |
| 21 | #include "machtypes.h" |
| 22 | |
| 23 | /* found via /sys/gpio/... try and error */ |
| 24 | #define ALL0258N_GPIO_BTN_RESET 1 |
| 25 | #define ALL0258N_GPIO_LED_RSSIHIGH 13 |
| 26 | #define ALL0258N_GPIO_LED_RSSIMEDIUM 15 |
| 27 | #define ALL0258N_GPIO_LED_RSSILOW 14 |
| 28 | |
| 29 | /* defaults taken from others machs */ |
| 30 | #define ALL0258N_KEYS_POLL_INTERVAL 20 /* msecs */ |
| 31 | #define ALL0258N_KEYS_DEBOUNCE_INTERVAL (3 * ALL0258N_KEYS_POLL_INTERVAL) |
| 32 | |
| 33 | /* showed up in the original firmware's bootlog */ |
| 34 | #define ALL0258N_SEC_PHYMASK BIT(3) |
| 35 | |
| 36 | /* |
| 37 | * from U-Boot bootargs of original firmware: |
| 38 | * mtdparts=ar7240-nor0:256k(u-boot),64k(u-boot-env),320k(custom),1024k(kernel),4928k(rootfs),1536k(failsafe),64k(ART) |
| 39 | * we use a more OpenWrt-friendly layout now: |
| 40 | * mtdparts=ar7240-nor0:256k(u-boot),64k(u-boot-env),896k(kernel),5376k(rootfs),1536k(failsafe),64k(ART) |
| 41 | */ |
| 42 | static struct mtd_partition all0258n_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 | }, { |
| 53 | .name = "kernel", |
| 54 | .offset = 0x050000, |
| 55 | .size = 0x0E0000, |
| 56 | }, { |
| 57 | .name = "rootfs", |
| 58 | .offset = 0x130000, |
| 59 | .size = 0x540000, |
| 60 | }, { |
| 61 | .name = "failsafe", |
| 62 | .offset = 0x670000, |
| 63 | .size = 0x180000, |
| 64 | }, { |
| 65 | .name = "firmware", |
| 66 | .offset = 0x050000, |
| 67 | .size = 0x620000, |
| 68 | }, { |
| 69 | .name = "art", |
| 70 | .offset = 0x7F0000, |
| 71 | .size = 0x010000, |
| 72 | .mask_flags = MTD_WRITEABLE, |
| 73 | } |
| 74 | }; |
| 75 | |
| 76 | static struct flash_platform_data all0258n_flash_data = { |
| 77 | .parts = all0258n_partitions, |
| 78 | .nr_parts = ARRAY_SIZE(all0258n_partitions), |
| 79 | }; |
| 80 | |
| 81 | static struct gpio_led all0258n_leds_gpio[] __initdata = { |
| 82 | { |
| 83 | .name = "all0258n:green:rssihigh", |
| 84 | .gpio = ALL0258N_GPIO_LED_RSSIHIGH, |
| 85 | .active_low = 1, |
| 86 | }, { |
| 87 | .name = "all0258n:yellow:rssimedium", |
| 88 | .gpio = ALL0258N_GPIO_LED_RSSIMEDIUM, |
| 89 | .active_low = 1, |
| 90 | }, { |
| 91 | .name = "all0258n:red:rssilow", |
| 92 | .gpio = ALL0258N_GPIO_LED_RSSILOW, |
| 93 | .active_low = 1, |
| 94 | } |
| 95 | }; |
| 96 | |
| 97 | static struct gpio_keys_button all0258n_gpio_keys[] __initdata = { |
| 98 | { |
| 99 | .desc = "reset", |
| 100 | .type = EV_KEY, |
| 101 | .code = KEY_RESTART, |
| 102 | .debounce_interval = ALL0258N_KEYS_DEBOUNCE_INTERVAL, |
| 103 | .gpio = ALL0258N_GPIO_BTN_RESET, |
| 104 | .active_low = 1, |
| 105 | } |
| 106 | }; |
| 107 | |
| 108 | static void __init all0258n_setup(void) |
| 109 | { |
| 110 | u8 *mac = (u8 *) KSEG1ADDR(0x1f7f0000); |
| 111 | u8 *ee = (u8 *) KSEG1ADDR(0x1f7f1000); |
| 112 | |
| 113 | ath79_register_m25p80(&all0258n_flash_data); |
| 114 | |
| 115 | ath79_register_leds_gpio(-1, ARRAY_SIZE(all0258n_leds_gpio), |
| 116 | all0258n_leds_gpio); |
| 117 | |
| 118 | ath79_register_gpio_keys_polled(-1, ALL0258N_KEYS_POLL_INTERVAL, |
| 119 | ARRAY_SIZE(all0258n_gpio_keys), |
| 120 | all0258n_gpio_keys); |
| 121 | |
| 122 | ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0); |
| 123 | ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0); |
| 124 | |
| 125 | ath79_eth1_data.phy_mask = ALL0258N_SEC_PHYMASK; |
| 126 | |
| 127 | ath79_register_mdio(0, 0x0); |
| 128 | |
| 129 | ath79_register_eth(0); |
| 130 | ath79_register_eth(1); |
| 131 | |
| 132 | ap91_pci_init(ee, mac); |
| 133 | } |
| 134 | |
| 135 | MIPS_MACHINE(ATH79_MACH_ALL0258N, "ALL0258N", "Allnet ALL0258N", |
| 136 | all0258n_setup); |
| 137 | |