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
29#ifdef CONFIG_MTD_PARTITIONS
30static struct mtd_partition pmugw_partitions[] = {
31    {
32        .name = "admboot",
33        .offset = 0,
34        .size = 64*1024,
35        .mask_flags = MTD_WRITEABLE,
36    } , {
37        .name = "boardcfg",
38        .offset = MTDPART_OFS_APPEND,
39        .size = 64*1024,
40    } , {
41        .name = "firmware",
42        .offset = MTDPART_OFS_APPEND,
43        .size = MTDPART_SIZ_FULL,
44    }
45};
46#endif /* CONFIG_MTD_PARTITIONS */
47
48static u8 pmugw_vlans[6] __initdata = {
49    0x41, 0x42, 0x44, 0x48, 0x50, 0x00
50};
51
52static __init void pmugw_setup_mac(void)
53{
54    u8 mac_base[6];
55    int err;
56
57    err = admboot_get_mac_base(PMUGW_CONFIG_OFFSET,
58                   PMUGW_CONFIG_SIZE, mac_base);
59
60    if ((err) || !is_valid_ether_addr(mac_base))
61        random_ether_addr(mac_base);
62
63    adm5120_setup_eth_macs(mac_base);
64}
65
66static void switch_bank_gpio5(unsigned bank)
67{
68    switch (bank) {
69    case 0:
70        gpio_set_value(ADM5120_GPIO_PIN5, 0);
71        break;
72    case 1:
73        gpio_set_value(ADM5120_GPIO_PIN5, 1);
74        break;
75    }
76}
77
78void __init pmugw_setup(void)
79{
80    /* setup flash A20 line */
81    gpio_request(ADM5120_GPIO_PIN5, NULL);
82    gpio_direction_output(ADM5120_GPIO_PIN5, 0);
83    adm5120_flash0_data.switch_bank = switch_bank_gpio5;
84
85#ifdef CONFIG_MTD_PARTITIONS
86    adm5120_flash0_data.nr_parts = ARRAY_SIZE(pmugw_partitions);
87    adm5120_flash0_data.parts = pmugw_partitions;
88#endif /* CONFIG_MTD_PARTITIONS */
89
90    adm5120_add_device_uart(1); /* ttyS0 */
91    adm5120_add_device_uart(0); /* ttyS1 */
92
93    adm5120_add_device_flash(0);
94
95    pmugw_setup_mac();
96    adm5120_add_device_switch(5, pmugw_vlans);
97}
98
99MIPS_MACHINE(MACH_ADM5120_PMUGW, "PMUGW", "Motorola Powerline MU Gateway",
100         pmugw_setup);
101

Archive Download this file



interactive