Root/target/linux/adm5120/files/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#define BR61XX_KEYS_POLL_INTERVAL 20
22#define BR61XX_KEYS_DEBOUNCE_INTERVAL (3 * BR61XX_KEYS_POLL_INTERVAL)
23
24static struct mtd_partition br61xx_partitions[] = {
25    {
26        .name = "admboot",
27        .offset = 0,
28        .size = 32*1024,
29        .mask_flags = MTD_WRITEABLE,
30    } , {
31        .name = "config",
32        .offset = MTDPART_OFS_APPEND,
33        .size = 32*1024,
34    } , {
35        .name = "firmware",
36        .offset = MTDPART_OFS_APPEND,
37        .size = MTDPART_SIZ_FULL,
38    }
39};
40
41static struct gpio_keys_button br61xx_gpio_buttons[] __initdata = {
42    {
43        .desc = "reset_button",
44        .type = EV_KEY,
45        .code = KEY_RESTART,
46        .debounce_interval = BR61XX_KEYS_DEBOUNCE_INTERVAL,
47        .gpio = ADM5120_GPIO_PIN2,
48    }
49};
50
51static u8 br61xx_vlans[6] __initdata = {
52    0x41, 0x42, 0x44, 0x48, 0x50, 0x00
53};
54
55static void __init br61xx_mac_setup(void)
56{
57    u8 mac_base[6];
58    int err;
59
60    err = admboot_get_mac_base(BR61XX_CONFIG_OFFSET,
61                   BR61XX_CONFIG_SIZE, mac_base);
62
63    if ((err) || !is_valid_ether_addr(mac_base))
64        random_ether_addr(mac_base);
65
66    adm5120_setup_eth_macs(mac_base);
67}
68
69void __init br61xx_generic_setup(void)
70{
71
72    adm5120_flash0_data.nr_parts = ARRAY_SIZE(br61xx_partitions);
73    adm5120_flash0_data.parts = br61xx_partitions;
74    adm5120_add_device_flash(0);
75
76    adm5120_add_device_gpio(BR61XX_GPIO_DEV_MASK);
77
78    adm5120_add_device_uart(0);
79    adm5120_add_device_uart(1);
80
81    adm5120_add_device_switch(5, br61xx_vlans);
82
83    adm5120_register_gpio_buttons(-1, BR61XX_KEYS_POLL_INTERVAL,
84                      ARRAY_SIZE(br61xx_gpio_buttons),
85                      br61xx_gpio_buttons);
86
87    br61xx_mac_setup();
88}
89

Archive Download this file



interactive