load the mac address from flash where it is possible
SVN-Revision: 12357
This commit is contained in:
parent
6922a3692d
commit
d9b755b3dc
@ -11,9 +11,14 @@
|
||||
|
||||
#include "cellvision.h"
|
||||
|
||||
#include <prom/admboot.h>
|
||||
|
||||
#define CELLVISION_GPIO_FLASH_A20 ADM5120_GPIO_PIN5
|
||||
#define CELLVISION_GPIO_DEV_MASK (1 << CELLVISION_GPIO_FLASH_A20)
|
||||
|
||||
#define CELLVISION_CONFIG_OFFSET 0x8000
|
||||
#define CELLVISION_CONFIG_SIZE 0x1000
|
||||
|
||||
#ifdef CONFIG_MTD_PARTITIONS
|
||||
static struct mtd_partition cas6xx_partitions[] = {
|
||||
{
|
||||
@ -84,6 +89,20 @@ static void __init cellvision_flash_setup(void)
|
||||
adm5120_add_device_flash(0);
|
||||
}
|
||||
|
||||
void __init cellvision_mac_setup(void)
|
||||
{
|
||||
u8 mac_base[6];
|
||||
int err;
|
||||
|
||||
err = admboot_get_mac_base(CELLVISION_CONFIG_OFFSET,
|
||||
CELLVISION_CONFIG_SIZE, mac_base);
|
||||
|
||||
if ((err) || !is_valid_ether_addr(mac_base))
|
||||
random_ether_addr(mac_base);
|
||||
|
||||
adm5120_setup_eth_macs(mac_base);
|
||||
}
|
||||
|
||||
void __init cas6xx_flash_setup(void)
|
||||
{
|
||||
#ifdef CONFIG_MTD_PARTITIONS
|
||||
@ -118,6 +137,8 @@ ADM5120_BOARD(MACH_ADM5120_CAS670, "Cellvision CAS-670/670W", cas6xx_setup);
|
||||
void __init cas7xx_setup(void)
|
||||
{
|
||||
cas7xx_flash_setup();
|
||||
|
||||
cellvision_mac_setup();
|
||||
adm5120_add_device_switch(1, NULL);
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/etherdevice.h>
|
||||
|
||||
#include <asm/bootinfo.h>
|
||||
|
||||
@ -20,6 +21,8 @@
|
||||
#include <asm/mach-adm5120/adm5120_platform.h>
|
||||
#include <asm/mach-adm5120/adm5120_irq.h>
|
||||
|
||||
extern void cellvision_mac_setup(void) __init;
|
||||
|
||||
extern void cas6xx_flash_setup(void) __init;
|
||||
extern void cas7xx_flash_setup(void) __init;
|
||||
extern void cas6xx_setup(void) __init;
|
||||
|
@ -18,6 +18,8 @@ static u8 nfs101_vlans[6] __initdata = { /* TODO: not tested */
|
||||
static void __init nfs101_setup(void)
|
||||
{
|
||||
cas6xx_flash_setup();
|
||||
|
||||
cellvision_mac_setup();
|
||||
adm5120_add_device_switch(5, nfs101_vlans);
|
||||
}
|
||||
|
||||
|
@ -50,6 +50,26 @@ unsigned char adm5120_eth_vlans[6] = {
|
||||
EXPORT_SYMBOL_GPL(adm5120_eth_vlans);
|
||||
#endif
|
||||
|
||||
void __init adm5120_setup_eth_macs(u8 *mac_base)
|
||||
{
|
||||
u32 t;
|
||||
int i, j;
|
||||
|
||||
t = ((u32) mac_base[3] << 16) | ((u32) mac_base[4] << 8)
|
||||
| ((u32) mac_base[5]);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(adm5120_eth_macs); i++) {
|
||||
for (j = 0; j < 3; j++)
|
||||
adm5120_eth_macs[i][j] = mac_base[j];
|
||||
|
||||
adm5120_eth_macs[i][3] = (t >> 16) & 0xff;
|
||||
adm5120_eth_macs[i][4] = (t >> 8) & 0xff;
|
||||
adm5120_eth_macs[i][5] = t & 0xff;
|
||||
|
||||
t++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Built-in ethernet switch
|
||||
*/
|
||||
|
@ -9,21 +9,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/gpio.h>
|
||||
|
||||
#include <asm/bootinfo.h>
|
||||
|
||||
#include <asm/mach-adm5120/adm5120_info.h>
|
||||
#include <asm/mach-adm5120/adm5120_board.h>
|
||||
#include <asm/mach-adm5120/adm5120_platform.h>
|
||||
#include <asm/mach-adm5120/adm5120_irq.h>
|
||||
#include "compex.h"
|
||||
|
||||
#include <asm/mach-adm5120/prom/myloader.h>
|
||||
|
||||
#include "compex.h"
|
||||
|
||||
#define COMPEX_GPIO_DEV_MASK (1 << ADM5120_GPIO_PIN5)
|
||||
|
||||
static void switch_bank_gpio5(unsigned bank)
|
||||
@ -40,14 +29,22 @@ static void switch_bank_gpio5(unsigned bank)
|
||||
|
||||
void __init compex_mac_setup(void)
|
||||
{
|
||||
int i, j;
|
||||
if (myloader_present()) {
|
||||
int i;
|
||||
|
||||
if (!myloader_present())
|
||||
return;
|
||||
for (i = 0; i < 6; i++) {
|
||||
if (is_valid_ether_addr(myloader_info.macs[i]))
|
||||
memcpy(myloader_info.macs[i],
|
||||
adm5120_eth_macs[i], ETH_ALEN);
|
||||
else
|
||||
random_ether_addr(adm5120_eth_macs[i]);
|
||||
}
|
||||
} else {
|
||||
u8 mac[ETH_ALEN];
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
for (j = 0; j < 6; j++)
|
||||
adm5120_eth_macs[i][j] = myloader_info.macs[i][j];
|
||||
random_ether_addr(mac);
|
||||
adm5120_setup_eth_macs(mac);
|
||||
}
|
||||
}
|
||||
|
||||
void __init compex_generic_setup(void)
|
||||
|
@ -11,9 +11,10 @@
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/etherdevice.h>
|
||||
|
||||
#include <asm/bootinfo.h>
|
||||
#include <linux/gpio.h>
|
||||
|
||||
#include <asm/mach-adm5120/adm5120_info.h>
|
||||
#include <asm/mach-adm5120/adm5120_board.h>
|
||||
|
@ -11,8 +11,13 @@
|
||||
|
||||
#include "br-61xx.h"
|
||||
|
||||
#include <prom/admboot.h>
|
||||
|
||||
#define BR61XX_GPIO_DEV_MASK 0
|
||||
|
||||
#define BR61XX_CONFIG_OFFSET 0x8000
|
||||
#define BR61XX_CONFIG_SIZE 0x1000
|
||||
|
||||
#ifdef CONFIG_MTD_PARTITIONS
|
||||
static struct mtd_partition br61xx_partitions[] = {
|
||||
{
|
||||
@ -46,6 +51,20 @@ static u8 br61xx_vlans[6] __initdata = {
|
||||
0x41, 0x42, 0x44, 0x48, 0x50, 0x00
|
||||
};
|
||||
|
||||
static void __init br61xx_mac_setup(void)
|
||||
{
|
||||
u8 mac_base[6];
|
||||
int err;
|
||||
|
||||
err = admboot_get_mac_base(BR61XX_CONFIG_OFFSET,
|
||||
BR61XX_CONFIG_SIZE, mac_base);
|
||||
|
||||
if ((err) || !is_valid_ether_addr(mac_base))
|
||||
random_ether_addr(mac_base);
|
||||
|
||||
adm5120_setup_eth_macs(mac_base);
|
||||
}
|
||||
|
||||
void __init br61xx_generic_setup(void)
|
||||
{
|
||||
|
||||
@ -56,9 +75,10 @@ void __init br61xx_generic_setup(void)
|
||||
adm5120_add_device_flash(0);
|
||||
|
||||
adm5120_add_device_gpio(BR61XX_GPIO_DEV_MASK);
|
||||
|
||||
adm5120_add_device_switch(5, br61xx_vlans);
|
||||
adm5120_add_device_gpio_buttons(ARRAY_SIZE(br61xx_gpio_buttons),
|
||||
br61xx_gpio_buttons);
|
||||
|
||||
/* TODO: setup mac addresses */
|
||||
br61xx_mac_setup();
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/etherdevice.h>
|
||||
|
||||
#include <asm/bootinfo.h>
|
||||
|
||||
|
@ -11,6 +11,11 @@
|
||||
|
||||
#include "infineon.h"
|
||||
|
||||
#include <prom/admboot.h>
|
||||
|
||||
#define EASY_CONFIG_OFFSET 0x10000
|
||||
#define EASY_CONFIG_SIZE 0x1000
|
||||
|
||||
#ifdef CONFIG_MTD_PARTITIONS
|
||||
static struct mtd_partition easy_partitions[] = {
|
||||
{
|
||||
@ -30,6 +35,20 @@ static struct mtd_partition easy_partitions[] = {
|
||||
};
|
||||
#endif /* CONFIG_MTD_PARTITIONS */
|
||||
|
||||
static __init void easy_setup_mac(void)
|
||||
{
|
||||
u8 mac_base[6];
|
||||
int err;
|
||||
|
||||
err = admboot_get_mac_base(EASY_CONFIG_OFFSET,
|
||||
EASY_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_gpio3(unsigned bank)
|
||||
{
|
||||
switch (bank) {
|
||||
@ -55,6 +74,8 @@ void __init easy_setup_pqfp(void)
|
||||
#endif /* CONFIG_MTD_PARTITIONS */
|
||||
|
||||
adm5120_add_device_flash(0);
|
||||
|
||||
easy_setup_mac();
|
||||
}
|
||||
|
||||
static void switch_bank_gpio5(unsigned bank)
|
||||
@ -82,4 +103,6 @@ void __init easy_setup_bga(void)
|
||||
#endif /* CONFIG_MTD_PARTITIONS */
|
||||
|
||||
adm5120_add_device_flash(0);
|
||||
|
||||
easy_setup_mac();
|
||||
}
|
||||
|
@ -11,9 +11,10 @@
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/etherdevice.h>
|
||||
|
||||
#include <asm/bootinfo.h>
|
||||
#include <linux/gpio.h>
|
||||
|
||||
#include <asm/mach-adm5120/adm5120_defs.h>
|
||||
#include <asm/mach-adm5120/adm5120_irq.h>
|
||||
|
@ -101,15 +101,13 @@ struct gpio_button rb1xx_gpio_buttons[] __initdata = {
|
||||
|
||||
static void __init rb1xx_mac_setup(void)
|
||||
{
|
||||
int i, j;
|
||||
if (rb_hs.mac_base != NULL && is_valid_ether_addr(rb_hs.mac_base)) {
|
||||
adm5120_setup_eth_macs(rb_hs.mac_base);
|
||||
} else {
|
||||
u8 mac[ETH_ALEN];
|
||||
|
||||
if (!rb_hs.mac_base)
|
||||
return;
|
||||
|
||||
for (i = 0; i < 6; i++) {
|
||||
for (j = 0; j < 5; j++)
|
||||
adm5120_eth_macs[i][j] = rb_hs.mac_base[j];
|
||||
adm5120_eth_macs[i][5] = rb_hs.mac_base[5]+i;
|
||||
random_ether_addr(mac);
|
||||
adm5120_setup_eth_macs(mac);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <linux/init.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/etherdevice.h>
|
||||
|
||||
#include <asm/bootinfo.h>
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Makefile for the ADMtek ADM5120 SoC specific parts of the kernel
|
||||
#
|
||||
|
||||
lib-y += admboot.o
|
||||
lib-y += bootbase.o
|
||||
lib-y += cfe.o
|
||||
lib-y += generic.o
|
||||
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* ADMBoot specific prom routines
|
||||
*
|
||||
* 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/types.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/errno.h>
|
||||
|
||||
#include <asm/addrspace.h>
|
||||
#include <asm/byteorder.h>
|
||||
|
||||
#include <asm/mach-adm5120/adm5120_defs.h>
|
||||
#include <prom/admboot.h>
|
||||
#include "prom_read.h"
|
||||
|
||||
#define ADMBOOT_MAGIC_MAC_BASE 0x636D676D /* 'mgmc' */
|
||||
|
||||
int __init admboot_get_mac_base(u32 offset, u32 len, u8 *mac)
|
||||
{
|
||||
u8 *cfg;
|
||||
int i;
|
||||
|
||||
cfg = (u8 *) KSEG1ADDR(ADM5120_SRAM0_BASE + offset);
|
||||
for (i = 0; i < len; i += 4) {
|
||||
u32 magic;
|
||||
|
||||
magic = prom_read_le32(cfg + i);
|
||||
if (magic == ADMBOOT_MAGIC_MAC_BASE) {
|
||||
int j;
|
||||
|
||||
for (j = 0; j < 6; j++)
|
||||
mac[j] = cfg[i + 4 + j];
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -ENXIO;
|
||||
}
|
@ -53,6 +53,14 @@ static inline u32 bootbase_get_bootext_addr(void)
|
||||
return prom_read_be32(&board_info->bootext_addr);
|
||||
}
|
||||
|
||||
static inline void bootbase_get_mac(u8 *mac)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
mac[i] = board_info->mac[i];
|
||||
}
|
||||
|
||||
static inline u16 bootbase_get_vendor_id(void)
|
||||
{
|
||||
#define CHECK_VENDOR(n) (strnicmp(board_info->vendor, (n), strlen(n)) == 0)
|
||||
@ -102,6 +110,7 @@ int __init bootbase_present(void)
|
||||
|
||||
bootbase_info.vendor_id = bootbase_get_vendor_id();
|
||||
bootbase_info.board_id = bootbase_get_board_id();
|
||||
bootbase_get_mac(bootbase_info.mac);
|
||||
|
||||
bootbase_found = 1;
|
||||
|
||||
|
@ -11,6 +11,8 @@
|
||||
|
||||
#include "p-33x.h"
|
||||
|
||||
#include <prom/zynos.h>
|
||||
|
||||
#define P33X_GPIO_FLASH_A20 ADM5120_GPIO_PIN5
|
||||
#define P33X_GPIO_DEV_MASK (1 << P33X_GPIO_FLASH_A20)
|
||||
|
||||
@ -76,6 +78,8 @@ void __init p33x_generic_setup(void)
|
||||
adm5120_add_device_flash(0);
|
||||
|
||||
adm5120_add_device_gpio(P33X_GPIO_DEV_MASK);
|
||||
|
||||
adm5120_setup_eth_macs(bootbase_info.mac);
|
||||
adm5120_add_device_switch(5, p33x_vlans);
|
||||
|
||||
adm5120_pci_set_irq_map(ARRAY_SIZE(p33x_pci_irqs), p33x_pci_irqs);
|
||||
|
@ -11,12 +11,12 @@
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/gpio.h>
|
||||
|
||||
#include <asm/bootinfo.h>
|
||||
#include <linux/gpio.h>
|
||||
|
||||
#include <asm/mach-adm5120/adm5120_board.h>
|
||||
#include <asm/mach-adm5120/adm5120_platform.h>
|
||||
#include <asm/mach-adm5120/adm5120_irq.h>
|
||||
|
||||
extern void p33x_generic_setup(void) __init;
|
||||
extern void p33x_generic_setup(void) __init;
|
||||
|
@ -57,6 +57,8 @@ static inline void adm5120_pci_set_irq_map(unsigned int nr_irqs,
|
||||
}
|
||||
#endif
|
||||
|
||||
extern void adm5120_setup_eth_macs(u8 *mac_base) __init;
|
||||
|
||||
extern struct adm5120_flash_platform_data adm5120_flash0_data;
|
||||
extern struct adm5120_flash_platform_data adm5120_flash1_data;
|
||||
|
||||
|
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* ADMBoot specific definitions
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _ADMBOOT_H
|
||||
#define _ADMBOOT_H
|
||||
|
||||
extern int admboot_get_mac_base(u32 offset, u32 len, u8 *mac) __init;
|
||||
|
||||
#endif /* _ADMBOOT_H */
|
Loading…
Reference in New Issue
Block a user