1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
/*
* Motorola Powerline MU Gateway board
*
* Copyright (C) 2008 Gabor Juhos <juhosg@openwrt.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
*/
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/gpio.h>
#include <linux/irq.h>
#include <linux/etherdevice.h>
#include <asm/mips_machine.h>
#include <asm/mach-adm5120/adm5120_defs.h>
#include <asm/mach-adm5120/adm5120_platform.h>
#include <asm/mach-adm5120/adm5120_info.h>
#include <prom/admboot.h>
#define PMUGW_CONFIG_OFFSET 0x10000
#define PMUGW_CONFIG_SIZE 0x1000
#ifdef CONFIG_MTD_PARTITIONS
static struct mtd_partition pmugw_partitions[] = {
{
.name = "admboot",
.offset = 0,
.size = 64*1024,
.mask_flags = MTD_WRITEABLE,
} , {
.name = "boardcfg",
.offset = MTDPART_OFS_APPEND,
.size = 64*1024,
} , {
.name = "firmware",
.offset = MTDPART_OFS_APPEND,
.size = MTDPART_SIZ_FULL,
}
};
#endif /* CONFIG_MTD_PARTITIONS */
static u8 pmugw_vlans[6] __initdata = {
0x41, 0x42, 0x44, 0x48, 0x50, 0x00
};
static __init void pmugw_setup_mac(void)
{
u8 mac_base[6];
int err;
err = admboot_get_mac_base(PMUGW_CONFIG_OFFSET,
PMUGW_CONFIG_SIZE, mac_base);
if ((err) || !is_valid_ether_addr(mac_base))
random_ether_addr(mac_base);
adm5120_setup_eth_macs(mac_base);
}
static void switch_bank_gpio5(unsigned bank)
{
switch (bank) {
case 0:
gpio_set_value(ADM5120_GPIO_PIN5, 0);
break;
case 1:
gpio_set_value(ADM5120_GPIO_PIN5, 1);
break;
}
}
void __init pmugw_setup(void)
{
/* setup flash A20 line */
gpio_request(ADM5120_GPIO_PIN5, NULL);
gpio_direction_output(ADM5120_GPIO_PIN5, 0);
adm5120_flash0_data.switch_bank = switch_bank_gpio5;
#ifdef CONFIG_MTD_PARTITIONS
adm5120_flash0_data.nr_parts = ARRAY_SIZE(pmugw_partitions);
adm5120_flash0_data.parts = pmugw_partitions;
#endif /* CONFIG_MTD_PARTITIONS */
adm5120_add_device_uart(1); /* ttyS0 */
adm5120_add_device_uart(0); /* ttyS1 */
adm5120_add_device_flash(0);
pmugw_setup_mac();
adm5120_add_device_switch(5, pmugw_vlans);
}
MIPS_MACHINE(MACH_ADM5120_PMUGW, "PMUGW", "Motorola Powerline MU Gateway",
pmugw_setup);
|