Root/target/linux/adm5120/files/arch/mips/adm5120/motorola/pmugw.c

1/*
2 * Motorola Powerline MU Gateway board
3 *
4 * Copyright (C) 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 <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/gpio.h>
15#include <linux/irq.h>
16#include <linux/etherdevice.h>
17
18#include <asm/mips_machine.h>
19
20#include <asm/mach-adm5120/adm5120_defs.h>
21#include <asm/mach-adm5120/adm5120_platform.h>
22#include <asm/mach-adm5120/adm5120_info.h>
23
24#include <prom/admboot.h>
25
26#define PMUGW_CONFIG_OFFSET 0x10000
27#define PMUGW_CONFIG_SIZE 0x1000
28
29static struct mtd_partition pmugw_partitions[] = {
30    {
31        .name = "admboot",
32        .offset = 0,
33        .size = 64*1024,
34        .mask_flags = MTD_WRITEABLE,
35    } , {
36        .name = "boardcfg",
37        .offset = MTDPART_OFS_APPEND,
38        .size = 64*1024,
39    } , {
40        .name = "firmware",
41        .offset = MTDPART_OFS_APPEND,
42        .size = MTDPART_SIZ_FULL,
43    }
44};
45
46static u8 pmugw_vlans[6] __initdata = {
47    0x41, 0x42, 0x44, 0x48, 0x50, 0x00
48};
49
50static __init void pmugw_setup_mac(void)
51{
52    u8 mac_base[6];
53    int err;
54
55    err = admboot_get_mac_base(PMUGW_CONFIG_OFFSET,
56                   PMUGW_CONFIG_SIZE, mac_base);
57
58    if ((err) || !is_valid_ether_addr(mac_base))
59        random_ether_addr(mac_base);
60
61    adm5120_setup_eth_macs(mac_base);
62}
63
64static void switch_bank_gpio5(unsigned bank)
65{
66    switch (bank) {
67    case 0:
68        gpio_set_value(ADM5120_GPIO_PIN5, 0);
69        break;
70    case 1:
71        gpio_set_value(ADM5120_GPIO_PIN5, 1);
72        break;
73    }
74}
75
76void __init pmugw_setup(void)
77{
78    /* setup flash A20 line */
79    gpio_request(ADM5120_GPIO_PIN5, NULL);
80    gpio_direction_output(ADM5120_GPIO_PIN5, 0);
81    adm5120_flash0_data.switch_bank = switch_bank_gpio5;
82
83    adm5120_flash0_data.nr_parts = ARRAY_SIZE(pmugw_partitions);
84    adm5120_flash0_data.parts = pmugw_partitions;
85
86    adm5120_add_device_uart(1); /* ttyAM0 */
87    adm5120_add_device_uart(0); /* ttyAM1 */
88
89    adm5120_add_device_flash(0);
90
91    pmugw_setup_mac();
92    adm5120_add_device_switch(5, pmugw_vlans);
93}
94
95MIPS_MACHINE(MACH_ADM5120_PMUGW, "PMUGW", "Motorola Powerline MU Gateway",
96         pmugw_setup);
97

Archive Download this file



interactive