#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[] = {
{
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
void __init cas7xx_setup(void)
{
cas7xx_flash_setup();
+
+ cellvision_mac_setup();
adm5120_add_device_switch(1, NULL);
}
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/gpio.h>
+#include <linux/etherdevice.h>
#include <asm/bootinfo.h>
#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;
static void __init nfs101_setup(void)
{
cas6xx_flash_setup();
+
+ cellvision_mac_setup();
adm5120_add_device_switch(5, nfs101_vlans);
}
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
*/
*
*/
-#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)
void __init compex_mac_setup(void)
{
- int i, j;
-
- if (!myloader_present())
- return;
-
- for (i = 0; i < 6; i++)
- for (j = 0; j < 6; j++)
- adm5120_eth_macs[i][j] = myloader_info.macs[i][j];
+ if (myloader_present()) {
+ int i;
+
+ 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];
+
+ random_ether_addr(mac);
+ adm5120_setup_eth_macs(mac);
+ }
}
void __init compex_generic_setup(void)
#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>
#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[] = {
{
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)
{
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();
}
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/gpio.h>
+#include <linux/etherdevice.h>
#include <asm/bootinfo.h>
#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[] = {
{
};
#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) {
#endif /* CONFIG_MTD_PARTITIONS */
adm5120_add_device_flash(0);
+
+ easy_setup_mac();
}
static void switch_bank_gpio5(unsigned bank)
#endif /* CONFIG_MTD_PARTITIONS */
adm5120_add_device_flash(0);
+
+ easy_setup_mac();
}
#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>
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);
}
}
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/gpio.h>
+#include <linux/etherdevice.h>
#include <asm/bootinfo.h>
# 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
--- /dev/null
+/*
+ * 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;
+}
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)
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;
#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)
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);
#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;
\ No newline at end of file
+extern void p33x_generic_setup(void) __init;
}
#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;
--- /dev/null
+/*
+ * 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 */