6ecdb4e425bbb2e70b4996286efeff1b7ac00d9f
[openwrt/svn-archive/archive.git] / target / linux / adm5120 / files-2.6.26 / arch / mips / adm5120 / edimax / br-61xx.c
1 /*
2 * Edimax BR-61xx support
3 *
4 * Copyright (C) 2007-2008 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
12 #include "br-61xx.h"
13
14 #include <prom/admboot.h>
15
16 #define BR61XX_GPIO_DEV_MASK 0
17
18 #define BR61XX_CONFIG_OFFSET 0x8000
19 #define BR61XX_CONFIG_SIZE 0x1000
20
21 #ifdef CONFIG_MTD_PARTITIONS
22 static struct mtd_partition br61xx_partitions[] = {
23 {
24 .name = "admboot",
25 .offset = 0,
26 .size = 32*1024,
27 .mask_flags = MTD_WRITEABLE,
28 } , {
29 .name = "config",
30 .offset = MTDPART_OFS_APPEND,
31 .size = 32*1024,
32 } , {
33 .name = "firmware",
34 .offset = MTDPART_OFS_APPEND,
35 .size = MTDPART_SIZ_FULL,
36 }
37 };
38 #endif /* CONFIG_MTD_PARTITIONS */
39
40 static struct gpio_button br61xx_gpio_buttons[] __initdata = {
41 {
42 .desc = "reset_button",
43 .type = EV_KEY,
44 .code = BTN_0,
45 .threshold = 5,
46 .gpio = ADM5120_GPIO_PIN2,
47 }
48 };
49
50 static u8 br61xx_vlans[6] __initdata = {
51 0x41, 0x42, 0x44, 0x48, 0x50, 0x00
52 };
53
54 static void __init br61xx_mac_setup(void)
55 {
56 u8 mac_base[6];
57 int err;
58
59 err = admboot_get_mac_base(BR61XX_CONFIG_OFFSET,
60 BR61XX_CONFIG_SIZE, mac_base);
61
62 if ((err) || !is_valid_ether_addr(mac_base))
63 random_ether_addr(mac_base);
64
65 adm5120_setup_eth_macs(mac_base);
66 }
67
68 void __init br61xx_generic_setup(void)
69 {
70
71 #ifdef CONFIG_MTD_PARTITIONS
72 adm5120_flash0_data.nr_parts = ARRAY_SIZE(br61xx_partitions);
73 adm5120_flash0_data.parts = br61xx_partitions;
74 #endif /* CONFIG_MTD_PARTITIONS */
75 adm5120_add_device_flash(0);
76
77 adm5120_add_device_gpio(BR61XX_GPIO_DEV_MASK);
78
79 adm5120_add_device_uart(0);
80 adm5120_add_device_uart(1);
81
82 adm5120_add_device_switch(5, br61xx_vlans);
83 adm5120_add_device_gpio_buttons(ARRAY_SIZE(br61xx_gpio_buttons),
84 br61xx_gpio_buttons);
85
86 br61xx_mac_setup();
87 }