| 1 | /* |
| 2 | * D-Link DIR-600 rev. A1 board support |
| 3 | * |
| 4 | * Copyright (C) 2010 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-ar71xx/ar71xx.h> |
| 15 | |
| 16 | #include "machtype.h" |
| 17 | #include "devices.h" |
| 18 | #include "dev-m25p80.h" |
| 19 | #include "dev-ap91-eth.h" |
| 20 | #include "dev-ap91-pci.h" |
| 21 | #include "dev-gpio-buttons.h" |
| 22 | #include "dev-leds-gpio.h" |
| 23 | #include "nvram.h" |
| 24 | |
| 25 | #define DIR_600_A1_GPIO_LED_WPS 0 |
| 26 | #define DIR_600_A1_GPIO_LED_POWER_AMBER 1 |
| 27 | #define DIR_600_A1_GPIO_LED_POWER_GREEN 6 |
| 28 | |
| 29 | #define DIR_600_A1_GPIO_BTN_RESET 8 |
| 30 | #define DIR_600_A1_GPIO_BTN_WPS 12 |
| 31 | |
| 32 | #define DIR_600_A1_BUTTONS_POLL_INTERVAL 20 |
| 33 | |
| 34 | #define DIR_600_A1_NVRAM_ADDR 0x1f030000 |
| 35 | #define DIR_600_A1_NVRAM_SIZE 0x10000 |
| 36 | |
| 37 | #ifdef CONFIG_MTD_PARTITIONS |
| 38 | static struct mtd_partition dir_600_a1_partitions[] = { |
| 39 | { |
| 40 | .name = "u-boot", |
| 41 | .offset = 0, |
| 42 | .size = 0x030000, |
| 43 | .mask_flags = MTD_WRITEABLE, |
| 44 | }, { |
| 45 | .name = "nvram", |
| 46 | .offset = 0x030000, |
| 47 | .size = 0x010000, |
| 48 | }, { |
| 49 | .name = "kernel", |
| 50 | .offset = 0x040000, |
| 51 | .size = 0x0e0000, |
| 52 | }, { |
| 53 | .name = "rootfs", |
| 54 | .offset = 0x120000, |
| 55 | .size = 0x2c0000, |
| 56 | }, { |
| 57 | .name = "mac", |
| 58 | .offset = 0x3e0000, |
| 59 | .size = 0x010000, |
| 60 | .mask_flags = MTD_WRITEABLE, |
| 61 | }, { |
| 62 | .name = "art", |
| 63 | .offset = 0x3f0000, |
| 64 | .size = 0x010000, |
| 65 | .mask_flags = MTD_WRITEABLE, |
| 66 | }, { |
| 67 | .name = "firmware", |
| 68 | .offset = 0x040000, |
| 69 | .size = 0x3a0000, |
| 70 | } |
| 71 | }; |
| 72 | #endif /* CONFIG_MTD_PARTITIONS */ |
| 73 | |
| 74 | static struct flash_platform_data dir_600_a1_flash_data = { |
| 75 | #ifdef CONFIG_MTD_PARTITIONS |
| 76 | .parts = dir_600_a1_partitions, |
| 77 | .nr_parts = ARRAY_SIZE(dir_600_a1_partitions), |
| 78 | #endif |
| 79 | }; |
| 80 | |
| 81 | static struct gpio_led dir_600_a1_leds_gpio[] __initdata = { |
| 82 | { |
| 83 | .name = "dir-600-a1:green:power", |
| 84 | .gpio = DIR_600_A1_GPIO_LED_POWER_GREEN, |
| 85 | }, { |
| 86 | .name = "dir-600-a1:amber:power", |
| 87 | .gpio = DIR_600_A1_GPIO_LED_POWER_AMBER, |
| 88 | }, { |
| 89 | .name = "dir-600-a1:blue:wps", |
| 90 | .gpio = DIR_600_A1_GPIO_LED_WPS, |
| 91 | .active_low = 1, |
| 92 | } |
| 93 | }; |
| 94 | |
| 95 | static struct gpio_button dir_600_a1_gpio_buttons[] __initdata = { |
| 96 | { |
| 97 | .desc = "reset", |
| 98 | .type = EV_KEY, |
| 99 | .code = BTN_0, |
| 100 | .threshold = 3, |
| 101 | .gpio = DIR_600_A1_GPIO_BTN_RESET, |
| 102 | .active_low = 1, |
| 103 | }, { |
| 104 | .desc = "wps", |
| 105 | .type = EV_KEY, |
| 106 | .code = BTN_1, |
| 107 | .threshold = 3, |
| 108 | .gpio = DIR_600_A1_GPIO_BTN_WPS, |
| 109 | .active_low = 1, |
| 110 | } |
| 111 | }; |
| 112 | |
| 113 | static void __init dir_600_a1_setup(void) |
| 114 | { |
| 115 | const char *nvram = (char *) KSEG1ADDR(DIR_600_A1_NVRAM_ADDR); |
| 116 | u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000); |
| 117 | u8 mac_buff[6]; |
| 118 | u8 *mac = NULL; |
| 119 | |
| 120 | if (nvram_parse_mac_addr(nvram, DIR_600_A1_NVRAM_SIZE, |
| 121 | "lan_mac=", mac_buff) == 0) |
| 122 | mac = mac_buff; |
| 123 | |
| 124 | ar71xx_add_device_m25p80(&dir_600_a1_flash_data); |
| 125 | |
| 126 | ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(dir_600_a1_leds_gpio), |
| 127 | dir_600_a1_leds_gpio); |
| 128 | |
| 129 | ar71xx_add_device_gpio_buttons(-1, DIR_600_A1_BUTTONS_POLL_INTERVAL, |
| 130 | ARRAY_SIZE(dir_600_a1_gpio_buttons), |
| 131 | dir_600_a1_gpio_buttons); |
| 132 | |
| 133 | ap91_eth_init(mac, NULL); |
| 134 | ap91_pci_init(ee, mac); |
| 135 | } |
| 136 | |
| 137 | MIPS_MACHINE(AR71XX_MACH_DIR_600_A1, "DIR-600-A1", "D-Link DIR-600 rev. A1", |
| 138 | dir_600_a1_setup); |
| 139 | |