mirror of
git://projects.qi-hardware.com/openwrt-xburst.git
synced 2025-04-21 12:27:27 +03:00
[adm5120] refactor kernel code (part 1), mark it as broken now
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@7916 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
@@ -5,5 +5,9 @@
|
||||
obj-y := setup.o prom.o irq.o memory.o adm5120_info.o
|
||||
obj-y += gpio.o
|
||||
obj-y += time.o
|
||||
obj-y += reset.o
|
||||
obj-y += board.o
|
||||
obj-y += platform.o
|
||||
obj-y += trxsplit.o
|
||||
|
||||
EXTRA_AFLAGS := $(CFLAGS)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
119
target/linux/adm5120-2.6/files/arch/mips/adm5120/board.c
Normal file
119
target/linux/adm5120-2.6/files/arch/mips/adm5120/board.c
Normal file
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* ADM5120 generic board code
|
||||
*
|
||||
* Copyright (C) 2007 OpenWrt.org
|
||||
* Copyright (C) 2007 Gabor Juhos <juhosg@freemail.hu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/init.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/platform_device.h>
|
||||
|
||||
#include <asm/bootinfo.h>
|
||||
|
||||
#include <asm/mach-adm5120/adm5120_info.h>
|
||||
#include <asm/mach-adm5120/adm5120_defs.h>
|
||||
#include <asm/mach-adm5120/adm5120_board.h>
|
||||
#include <asm/mach-adm5120/adm5120_platform.h>
|
||||
|
||||
static LIST_HEAD(adm5120_boards);
|
||||
static char adm5120_board_name[ADM5120_BOARD_NAMELEN];
|
||||
|
||||
const char *get_system_type(void)
|
||||
{
|
||||
return adm5120_board_name;
|
||||
}
|
||||
|
||||
static struct adm5120_board * __init adm5120_board_find(unsigned long machtype)
|
||||
{
|
||||
struct list_head *this;
|
||||
struct adm5120_board *board;
|
||||
void *ret;
|
||||
|
||||
ret = NULL;
|
||||
list_for_each(this, &adm5120_boards) {
|
||||
board = list_entry(this, struct adm5120_board, list);
|
||||
if (board->mach_type == machtype) {
|
||||
ret = board;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int __init adm5120_board_setup(void)
|
||||
{
|
||||
struct adm5120_board *board;
|
||||
int err;
|
||||
|
||||
board = adm5120_board_find(mips_machtype);
|
||||
if (board == NULL) {
|
||||
printk(KERN_ALERT "adm5120: no board registered for machtype %lu"
|
||||
", trying generic\n", mips_machtype);
|
||||
board = adm5120_board_find(MACH_ADM5120_GENERIC);
|
||||
if (board == NULL)
|
||||
panic("adm5120: unsupported board\n");
|
||||
}
|
||||
|
||||
printk(KERN_INFO "adm5120: setting up board '%s'\n", board->name);
|
||||
|
||||
memcpy(&adm5120_board_name, board->name, ADM5120_BOARD_NAMELEN);
|
||||
|
||||
adm5120_board_reset = board->board_reset;
|
||||
if (board->num_eth_ports > 0)
|
||||
adm5120_eth_num_ports = board->num_eth_ports;
|
||||
|
||||
if (board->board_setup)
|
||||
board->board_setup();
|
||||
|
||||
/* register PCI controller */
|
||||
if (adm5120_package_bga())
|
||||
platform_device_register(&adm5120_pci_device);
|
||||
|
||||
/* register board devices */
|
||||
if (board->num_devices > 0 && board->devices != NULL ) {
|
||||
err = platform_add_devices(board->devices, board->num_devices);
|
||||
if (err)
|
||||
printk(KERN_ALERT "adm5120: adding board devices failed\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void __init adm5120_board_register(struct adm5120_board *board)
|
||||
{
|
||||
list_add(&board->list, &adm5120_boards);
|
||||
printk(KERN_INFO "adm5120: registered board '%s'\n", board->name);
|
||||
}
|
||||
|
||||
void __init adm5120_register_boards(struct adm5120_board **boards,
|
||||
int num)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i<num; i++)
|
||||
adm5120_board_register(boards[i]);
|
||||
}
|
||||
|
||||
arch_initcall(adm5120_board_setup);
|
||||
@@ -0,0 +1,11 @@
|
||||
#
|
||||
# Makefile for platforms based on ADM5120 SoC
|
||||
#
|
||||
|
||||
obj-y += generic.o
|
||||
obj-y += cellvision.o
|
||||
obj-y += compex.o
|
||||
obj-y += edimax.o
|
||||
obj-y += infineon.o
|
||||
obj-y += mikrotik.o
|
||||
obj-y += zyxel.o
|
||||
@@ -0,0 +1,190 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Cellvision/SparkLAN boards
|
||||
*
|
||||
* Copyright (C) 2007 OpenWrt.org
|
||||
* Copyright (C) 2007 Gabor Juhos <juhosg@freemail.hu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
|
||||
#include <asm/bootinfo.h>
|
||||
#include <asm/gpio.h>
|
||||
|
||||
#include <asm/mach-adm5120/adm5120_board.h>
|
||||
#include <asm/mach-adm5120/adm5120_platform.h>
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
static struct mtd_partition cas6xx_partitions[] = {
|
||||
{
|
||||
.name = "admboot",
|
||||
.offset = 0,
|
||||
.size = 32*1024,
|
||||
.mask_flags = MTD_WRITEABLE,
|
||||
} , {
|
||||
.name = "config",
|
||||
.offset = MTDPART_OFS_APPEND,
|
||||
.size = 32*1024,
|
||||
} , {
|
||||
.name = "nvfs1",
|
||||
.offset = MTDPART_OFS_APPEND,
|
||||
.size = 64*1024,
|
||||
} , {
|
||||
.name = "nvfs2",
|
||||
.offset = MTDPART_OFS_APPEND,
|
||||
.size = 64*1024,
|
||||
} , {
|
||||
.name = "firmware",
|
||||
.offset = MTDPART_OFS_APPEND,
|
||||
.size = MTDPART_SIZ_FULL,
|
||||
}
|
||||
};
|
||||
|
||||
static struct mtd_partition cas7xx_partitions[] = {
|
||||
{
|
||||
.name = "admboot",
|
||||
.offset = 0,
|
||||
.size = 32*1024,
|
||||
.mask_flags = MTD_WRITEABLE,
|
||||
} , {
|
||||
.name = "config",
|
||||
.offset = MTDPART_OFS_APPEND,
|
||||
.size = 32*1024,
|
||||
} , {
|
||||
.name = "nvfs",
|
||||
.offset = MTDPART_OFS_APPEND,
|
||||
.size = 128*1024,
|
||||
} , {
|
||||
.name = "firmware",
|
||||
.offset = MTDPART_OFS_APPEND,
|
||||
.size = MTDPART_SIZ_FULL,
|
||||
}
|
||||
};
|
||||
|
||||
static struct platform_device *cas6xx_devices[] __initdata = {
|
||||
&adm5120_flash0_device,
|
||||
};
|
||||
|
||||
static struct platform_device *cas7xx_devices[] __initdata = {
|
||||
&adm5120_flash0_device,
|
||||
};
|
||||
|
||||
static void __init cas6xx_setup(void)
|
||||
{
|
||||
gpio_request(ADM5120_GPIO_PIN5, NULL); /* for flash A20 line */
|
||||
|
||||
/* setup data for flash0 device */
|
||||
adm5120_flash0_data.switch_bank = switch_bank_gpio5;
|
||||
adm5120_flash0_data.nr_parts = ARRAY_SIZE(cas6xx_partitions);
|
||||
adm5120_flash0_data.parts = cas6xx_partitions;
|
||||
|
||||
/* TODO: setup mac address */
|
||||
}
|
||||
|
||||
static void __init cas7xx_setup(void)
|
||||
{
|
||||
gpio_request(ADM5120_GPIO_PIN5, NULL); /* for flash A20 line */
|
||||
|
||||
/* setup data for flash0 device */
|
||||
adm5120_flash0_data.switch_bank = switch_bank_gpio5;
|
||||
adm5120_flash0_data.nr_parts = ARRAY_SIZE(cas7xx_partitions);
|
||||
adm5120_flash0_data.parts = cas7xx_partitions;
|
||||
|
||||
/* TODO: setup mac address */
|
||||
}
|
||||
|
||||
static struct adm5120_board cas630_board __initdata = {
|
||||
.mach_type = MACH_ADM5120_CAS630,
|
||||
.name = "Cellvision CAS-630/630W",
|
||||
.board_setup = cas6xx_setup,
|
||||
.num_eth_ports = 1,
|
||||
.num_devices = ARRAY_SIZE(cas6xx_devices),
|
||||
.devices = cas6xx_devices,
|
||||
};
|
||||
|
||||
static struct adm5120_board cas670_board __initdata = {
|
||||
.mach_type = MACH_ADM5120_CAS670,
|
||||
.name = "Cellvision CAS-670/670W",
|
||||
.board_setup = cas6xx_setup,
|
||||
.num_eth_ports = 1,
|
||||
.num_devices = ARRAY_SIZE(cas6xx_devices),
|
||||
.devices = cas6xx_devices,
|
||||
};
|
||||
|
||||
static struct adm5120_board cas700_board __initdata = {
|
||||
.mach_type = MACH_ADM5120_CAS700,
|
||||
.name = "Cellvision CAS-700/700W",
|
||||
.board_setup = cas7xx_setup,
|
||||
.num_eth_ports = 1,
|
||||
.num_devices = ARRAY_SIZE(cas7xx_devices),
|
||||
.devices = cas7xx_devices,
|
||||
};
|
||||
|
||||
static struct adm5120_board cas771_board __initdata = {
|
||||
.mach_type = MACH_ADM5120_CAS771,
|
||||
.name = "Cellvision CAS-771/771W",
|
||||
.board_setup = cas7xx_setup,
|
||||
.num_eth_ports = 1,
|
||||
.num_devices = ARRAY_SIZE(cas7xx_devices),
|
||||
.devices = cas7xx_devices,
|
||||
};
|
||||
|
||||
static struct adm5120_board cas790_board __initdata = {
|
||||
.mach_type = MACH_ADM5120_CAS790,
|
||||
.name = "Cellvision CAS-790",
|
||||
.board_setup = cas7xx_setup,
|
||||
.num_eth_ports = 1,
|
||||
.num_devices = ARRAY_SIZE(cas7xx_devices),
|
||||
.devices = cas7xx_devices,
|
||||
};
|
||||
|
||||
static struct adm5120_board cas861_board __initdata = {
|
||||
.mach_type = MACH_ADM5120_CAS861,
|
||||
.name = "Cellvision CAS-861/861W",
|
||||
.board_setup = cas7xx_setup,
|
||||
.num_eth_ports = 1,
|
||||
.num_devices = ARRAY_SIZE(cas7xx_devices),
|
||||
.devices = cas7xx_devices,
|
||||
};
|
||||
|
||||
static int __init register_boards(void)
|
||||
{
|
||||
adm5120_board_register(&cas630_board);
|
||||
adm5120_board_register(&cas670_board);
|
||||
adm5120_board_register(&cas700_board);
|
||||
adm5120_board_register(&cas771_board);
|
||||
adm5120_board_register(&cas790_board);
|
||||
adm5120_board_register(&cas861_board);
|
||||
return 0;
|
||||
}
|
||||
|
||||
pure_initcall(register_boards);
|
||||
192
target/linux/adm5120-2.6/files/arch/mips/adm5120/boards/compex.c
Normal file
192
target/linux/adm5120-2.6/files/arch/mips/adm5120/boards/compex.c
Normal file
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Compex boards
|
||||
*
|
||||
* Copyright (C) 2007 OpenWrt.org
|
||||
* Copyright (C) 2007 Gabor Juhos <juhosg@freemail.hu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
|
||||
#include <asm/bootinfo.h>
|
||||
#include <asm/gpio.h>
|
||||
|
||||
#include <asm/mach-adm5120/adm5120_board.h>
|
||||
#include <asm/mach-adm5120/adm5120_platform.h>
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
static void wp54_reset(void)
|
||||
{
|
||||
gpio_direction_output(ADM5120_GPIO_PIN3, 0);
|
||||
}
|
||||
|
||||
static struct mtd_partition wp54g_wrt_partitions[] = {
|
||||
{
|
||||
.name = "cfe",
|
||||
.offset = 0,
|
||||
.size = 0x050000,
|
||||
.mask_flags = MTD_WRITEABLE,
|
||||
} , {
|
||||
.name = "trx",
|
||||
.offset = MTDPART_OFS_APPEND,
|
||||
.size = 0x3A0000,
|
||||
} , {
|
||||
.name = "nvram",
|
||||
.offset = MTDPART_OFS_APPEND,
|
||||
.size = 0x010000,
|
||||
}
|
||||
};
|
||||
|
||||
static struct platform_device *np2xg_devices[] __initdata = {
|
||||
&adm5120_flash0_device,
|
||||
&adm5120_usbc_device,
|
||||
};
|
||||
|
||||
static struct platform_device *wp54_devices[] __initdata = {
|
||||
&adm5120_flash0_device,
|
||||
};
|
||||
|
||||
static void __init np2xg_setup(void)
|
||||
{
|
||||
gpio_request(ADM5120_GPIO_PIN5, NULL); /* for flash A20 line */
|
||||
|
||||
/* setup data for flash0 device */
|
||||
adm5120_flash0_data.switch_bank = switch_bank_gpio5;
|
||||
|
||||
/* TODO: setup mac address */
|
||||
}
|
||||
|
||||
static void __init wp54_setup(void)
|
||||
{
|
||||
gpio_request(ADM5120_GPIO_PIN5, NULL); /* for flash A20 line */
|
||||
gpio_request(ADM5120_GPIO_PIN3, NULL); /* for system reset */
|
||||
|
||||
/* setup data for flash0 device */
|
||||
adm5120_flash0_data.switch_bank = switch_bank_gpio5;
|
||||
|
||||
/* TODO: setup mac address */
|
||||
}
|
||||
|
||||
static void __init wp54_wrt_setup(void)
|
||||
{
|
||||
gpio_request(ADM5120_GPIO_PIN5, NULL); /* for flash A20 line */
|
||||
gpio_request(ADM5120_GPIO_PIN3, NULL); /* for system reset */
|
||||
|
||||
/* setup data for flash0 device */
|
||||
adm5120_flash0_data.switch_bank = switch_bank_gpio5;
|
||||
adm5120_flash0_data.nr_parts = ARRAY_SIZE(wp54g_wrt_partitions);
|
||||
adm5120_flash0_data.parts = wp54g_wrt_partitions;
|
||||
|
||||
/* TODO: setup mac address */
|
||||
}
|
||||
|
||||
static struct adm5120_board np27g_board __initdata = {
|
||||
.mach_type = MACH_ADM5120_NP27G,
|
||||
.name = "Compex NetPassage 27G",
|
||||
.board_setup = np2xg_setup,
|
||||
.num_eth_ports = 4,
|
||||
.num_devices = ARRAY_SIZE(np2xg_devices),
|
||||
.devices = np2xg_devices,
|
||||
};
|
||||
|
||||
static struct adm5120_board np28g_board __initdata = {
|
||||
.mach_type = MACH_ADM5120_NP28G,
|
||||
.name = "Compex NetPassage 28G",
|
||||
.board_setup = np2xg_setup,
|
||||
.num_eth_ports = 3,
|
||||
.num_devices = ARRAY_SIZE(np2xg_devices),
|
||||
.devices = np2xg_devices,
|
||||
};
|
||||
|
||||
static struct adm5120_board wp54ag_board __initdata = {
|
||||
.mach_type = MACH_ADM5120_WP54AG,
|
||||
.name = "Compex WP54AG",
|
||||
.board_setup = wp54_setup,
|
||||
.board_reset = wp54_reset,
|
||||
.num_eth_ports = 2,
|
||||
.num_devices = ARRAY_SIZE(wp54_devices),
|
||||
.devices = wp54_devices,
|
||||
};
|
||||
|
||||
static struct adm5120_board wp54g_board __initdata = {
|
||||
.mach_type = MACH_ADM5120_WP54G,
|
||||
.name = "Compex WP54G",
|
||||
.board_setup = wp54_setup,
|
||||
.board_reset = wp54_reset,
|
||||
.num_eth_ports = 2,
|
||||
.num_devices = ARRAY_SIZE(wp54_devices),
|
||||
.devices = wp54_devices,
|
||||
};
|
||||
|
||||
static struct adm5120_board wp54g_wrt_board __initdata = {
|
||||
.mach_type = MACH_ADM5120_WP54G,
|
||||
.name = "Compex WP54G-WRT",
|
||||
.board_setup = wp54_wrt_setup,
|
||||
.board_reset = wp54_reset,
|
||||
.num_eth_ports = 2,
|
||||
.num_devices = ARRAY_SIZE(wp54_devices),
|
||||
.devices = wp54_devices,
|
||||
};
|
||||
|
||||
static struct adm5120_board wpp54ag_board __initdata = {
|
||||
.mach_type = MACH_ADM5120_WPP54AG,
|
||||
.name = "Compex WPP54AG",
|
||||
.board_setup = wp54_setup,
|
||||
.board_reset = wp54_reset,
|
||||
.num_eth_ports = 2,
|
||||
.num_devices = ARRAY_SIZE(wp54_devices),
|
||||
.devices = wp54_devices,
|
||||
};
|
||||
|
||||
static struct adm5120_board wpp54g_board __initdata = {
|
||||
.mach_type = MACH_ADM5120_WPP54G,
|
||||
.name = "Compex WPP54G",
|
||||
.board_setup = wp54_setup,
|
||||
.board_reset = wp54_reset,
|
||||
.num_eth_ports = 2,
|
||||
.num_devices = ARRAY_SIZE(wp54_devices),
|
||||
.devices = wp54_devices,
|
||||
};
|
||||
|
||||
static int __init register_boards(void)
|
||||
{
|
||||
adm5120_board_register(&np27g_board);
|
||||
adm5120_board_register(&np28g_board);
|
||||
adm5120_board_register(&wp54ag_board);
|
||||
adm5120_board_register(&wp54g_board);
|
||||
adm5120_board_register(&wp54g_wrt_board);
|
||||
adm5120_board_register(&wpp54ag_board);
|
||||
adm5120_board_register(&wpp54g_board);
|
||||
return 0;
|
||||
}
|
||||
|
||||
pure_initcall(register_boards);
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Edimax boards
|
||||
*
|
||||
* Copyright (C) 2007 OpenWrt.org
|
||||
* Copyright (C) 2007 Gabor Juhos <juhosg@freemail.hu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
|
||||
#include <asm/bootinfo.h>
|
||||
#include <asm/gpio.h>
|
||||
|
||||
#include <asm/mach-adm5120/adm5120_board.h>
|
||||
#include <asm/mach-adm5120/adm5120_platform.h>
|
||||
|
||||
static struct mtd_partition br6104k_partitions[] = {
|
||||
{
|
||||
.name = "admboot",
|
||||
.offset = 0,
|
||||
.size = 32*1024,
|
||||
.mask_flags = MTD_WRITEABLE,
|
||||
} , {
|
||||
.name = "config",
|
||||
.offset = MTDPART_OFS_APPEND,
|
||||
.size = 32*1024,
|
||||
} , {
|
||||
.name = "firmware",
|
||||
.offset = MTDPART_OFS_APPEND,
|
||||
.size = MTDPART_SIZ_FULL,
|
||||
}
|
||||
};
|
||||
|
||||
static struct platform_device *br6104k_devices[] __initdata = {
|
||||
&adm5120_flash0_device,
|
||||
};
|
||||
|
||||
static void __init br6104k_setup(void) {
|
||||
/* setup data for flash0 device */
|
||||
adm5120_flash0_data.nr_parts = ARRAY_SIZE(br6104k_partitions);
|
||||
adm5120_flash0_data.parts = br6104k_partitions;
|
||||
|
||||
/* TODO: setup mac addresses, if possible */
|
||||
}
|
||||
|
||||
static struct adm5120_board br6104k_board __initdata = {
|
||||
.mach_type = MACH_ADM5120_BR6104K,
|
||||
.name = "Edimax BR-6104K",
|
||||
.board_setup = br6104k_setup,
|
||||
.num_eth_ports = 5,
|
||||
.num_devices = ARRAY_SIZE(br6104k_devices),
|
||||
.devices = br6104k_devices,
|
||||
};
|
||||
|
||||
static int __init register_boards(void)
|
||||
{
|
||||
adm5120_board_register(&br6104k_board);
|
||||
return 0;
|
||||
}
|
||||
|
||||
pure_initcall(register_boards);
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Generic ADM5120 based board
|
||||
*
|
||||
* Copyright (C) 2007 OpenWrt.org
|
||||
* Copyright (C) 2007 Gabor Juhos <juhosg@freemail.hu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
|
||||
#include <asm/bootinfo.h>
|
||||
#include <asm/gpio.h>
|
||||
|
||||
#include <asm/mach-adm5120/adm5120_board.h>
|
||||
#include <asm/mach-adm5120/adm5120_platform.h>
|
||||
|
||||
static struct platform_device *generic_devices[] __initdata = {
|
||||
&adm5120_flash0_device,
|
||||
};
|
||||
|
||||
static struct adm5120_board generic_board __initdata = {
|
||||
.mach_type = MACH_ADM5120_GENERIC,
|
||||
.name = "Generic ADM5120 board",
|
||||
.num_eth_ports = 6,
|
||||
.num_devices = ARRAY_SIZE(generic_devices),
|
||||
.devices = generic_devices,
|
||||
};
|
||||
|
||||
static int __init register_boards(void)
|
||||
{
|
||||
adm5120_board_register(&generic_board);
|
||||
return 0;
|
||||
}
|
||||
|
||||
pure_initcall(register_boards);
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Infineon boards
|
||||
*
|
||||
* Copyright (C) 2007 OpenWrt.org
|
||||
* Copyright (C) 2007 Gabor Juhos <juhosg@freemail.hu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
|
||||
#include <asm/bootinfo.h>
|
||||
#include <asm/gpio.h>
|
||||
|
||||
#include <asm/mach-adm5120/adm5120_board.h>
|
||||
#include <asm/mach-adm5120/adm5120_platform.h>
|
||||
|
||||
static void switch_bank_gpio3(unsigned bank)
|
||||
{
|
||||
switch (bank) {
|
||||
case 0:
|
||||
gpio_set_value(ADM5120_GPIO_PIN3, 0);
|
||||
break;
|
||||
case 1:
|
||||
gpio_set_value(ADM5120_GPIO_PIN3, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static struct mtd_partition easy83000_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,
|
||||
}
|
||||
};
|
||||
|
||||
static struct platform_device *easy83000_devices[] __initdata = {
|
||||
&adm5120_flash0_device,
|
||||
};
|
||||
|
||||
static void __init easy83000_setup(void)
|
||||
{
|
||||
gpio_request(ADM5120_GPIO_PIN3, NULL); /* for flash A20 line */
|
||||
|
||||
/* setup data for flash0 device */
|
||||
adm5120_flash0_data.switch_bank = switch_bank_gpio3;
|
||||
adm5120_flash0_data.nr_parts = ARRAY_SIZE(easy83000_partitions);
|
||||
adm5120_flash0_data.parts = easy83000_partitions;
|
||||
|
||||
/* TODO: setup mac addresses */
|
||||
}
|
||||
|
||||
static struct adm5120_board easy83000_board __initdata = {
|
||||
.mach_type = MACH_ADM5120_EASY83000,
|
||||
.name = "Infineon EASY-83000",
|
||||
.board_setup = easy83000_setup,
|
||||
.num_eth_ports = 6,
|
||||
.num_devices = ARRAY_SIZE(easy83000_devices),
|
||||
.devices = easy83000_devices,
|
||||
};
|
||||
|
||||
static int __init register_boards(void)
|
||||
{
|
||||
adm5120_board_register(&easy83000_board);
|
||||
return 0;
|
||||
}
|
||||
|
||||
pure_initcall(register_boards);
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Mikrotik RouterBOARDs 111/112/133/133C/153
|
||||
*
|
||||
* Copyright (C) 2007 OpenWrt.org
|
||||
* Copyright (C) 2007 Gabor Juhos <juhosg@freemail.hu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
|
||||
#include <asm/bootinfo.h>
|
||||
#include <asm/gpio.h>
|
||||
|
||||
#include <asm/mach-adm5120/adm5120_board.h>
|
||||
#include <asm/mach-adm5120/adm5120_platform.h>
|
||||
|
||||
static struct mtd_partition rb1xx_partitions[] = {
|
||||
{
|
||||
.name = "booter",
|
||||
.offset = 0,
|
||||
.size = 64*1024,
|
||||
.mask_flags = MTD_WRITEABLE,
|
||||
} , {
|
||||
.name = "firmware",
|
||||
.offset = MTDPART_OFS_APPEND,
|
||||
.size = MTDPART_SIZ_FULL,
|
||||
}
|
||||
};
|
||||
|
||||
static struct platform_device *rb1xx_devices[] __initdata = {
|
||||
&adm5120_flash0_device,
|
||||
};
|
||||
|
||||
static void __init rb1xx_setup(void)
|
||||
{
|
||||
/* setup data for flash0 device */
|
||||
adm5120_flash0_data.nr_parts = ARRAY_SIZE(rb1xx_partitions);
|
||||
adm5120_flash0_data.parts = rb1xx_partitions;
|
||||
|
||||
/* TODO: setup mac address */
|
||||
}
|
||||
|
||||
static struct adm5120_board rb111_board __initdata = {
|
||||
.mach_type = MACH_ADM5120_RB_111,
|
||||
.name = "Mikrotik RouterBOARD 111",
|
||||
.board_setup = rb1xx_setup,
|
||||
.num_eth_ports = 1,
|
||||
.num_devices = ARRAY_SIZE(rb1xx_devices),
|
||||
.devices = rb1xx_devices,
|
||||
};
|
||||
|
||||
static struct adm5120_board rb112_board __initdata = {
|
||||
.mach_type = MACH_ADM5120_RB_112,
|
||||
.name = "Mikrotik RouterBOARD 112",
|
||||
.board_setup = rb1xx_setup,
|
||||
.num_eth_ports = 1,
|
||||
.num_devices = ARRAY_SIZE(rb1xx_devices),
|
||||
.devices = rb1xx_devices,
|
||||
};
|
||||
|
||||
static struct adm5120_board rb133_board __initdata = {
|
||||
.mach_type = MACH_ADM5120_RB_133,
|
||||
.name = "Mikrotik RouterBOARD 133",
|
||||
.board_setup = rb1xx_setup,
|
||||
.num_eth_ports = 3,
|
||||
.num_devices = ARRAY_SIZE(rb1xx_devices),
|
||||
.devices = rb1xx_devices,
|
||||
};
|
||||
|
||||
static struct adm5120_board rb133c_board __initdata = {
|
||||
.mach_type = MACH_ADM5120_RB_133C,
|
||||
.name = "Mikrotik RouterBOARD 133C",
|
||||
.board_setup = rb1xx_setup,
|
||||
.num_eth_ports = 1,
|
||||
.num_devices = ARRAY_SIZE(rb1xx_devices),
|
||||
.devices = rb1xx_devices,
|
||||
};
|
||||
|
||||
static struct adm5120_board rb153_board __initdata = {
|
||||
.mach_type = MACH_ADM5120_RB_153,
|
||||
.name = "Mikrotik RouterBOARD 153",
|
||||
.board_setup = rb1xx_setup,
|
||||
.num_eth_ports = 5,
|
||||
.num_devices = ARRAY_SIZE(rb1xx_devices),
|
||||
.devices = rb1xx_devices,
|
||||
};
|
||||
|
||||
static int __init register_boards(void)
|
||||
{
|
||||
adm5120_board_register(&rb111_board);
|
||||
adm5120_board_register(&rb112_board);
|
||||
adm5120_board_register(&rb133_board);
|
||||
adm5120_board_register(&rb133c_board);
|
||||
adm5120_board_register(&rb153_board);
|
||||
return 0;
|
||||
}
|
||||
|
||||
pure_initcall(register_boards);
|
||||
108
target/linux/adm5120-2.6/files/arch/mips/adm5120/boards/zyxel.c
Normal file
108
target/linux/adm5120-2.6/files/arch/mips/adm5120/boards/zyxel.c
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* ZyXEL Prestige P-334/P-335 boards
|
||||
*
|
||||
* Copyright (C) 2007 OpenWrt.org
|
||||
* Copyright (C) 2007 Gabor Juhos <juhosg@freemail.hu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
|
||||
#include <asm/bootinfo.h>
|
||||
#include <asm/gpio.h>
|
||||
|
||||
#include <asm/mach-adm5120/adm5120_board.h>
|
||||
#include <asm/mach-adm5120/adm5120_platform.h>
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
static struct mtd_partition p33x_partitions[] = {
|
||||
{
|
||||
.name = "bootbase",
|
||||
.offset = 0,
|
||||
.size = 16*1024,
|
||||
.mask_flags = MTD_WRITEABLE,
|
||||
} , {
|
||||
.name = "rom",
|
||||
.offset = MTDPART_OFS_APPEND,
|
||||
.size = 16*1024,
|
||||
} , {
|
||||
.name = "firmware",
|
||||
.offset = MTDPART_OFS_APPEND,
|
||||
.size = MTDPART_SIZ_FULL,
|
||||
}
|
||||
};
|
||||
|
||||
static struct platform_device *p334_devices[] __initdata = {
|
||||
&adm5120_flash0_device,
|
||||
};
|
||||
|
||||
static struct platform_device *p335_devices[] __initdata = {
|
||||
&adm5120_flash0_device,
|
||||
&adm5120_usbc_device,
|
||||
};
|
||||
|
||||
static void __init p33x_setup(void)
|
||||
{
|
||||
gpio_request(ADM5120_GPIO_PIN5, NULL); /* for flash A20 line */
|
||||
|
||||
/* setup data for flash0 device */
|
||||
adm5120_flash0_data.switch_bank = switch_bank_gpio5;
|
||||
adm5120_flash0_data.nr_parts = ARRAY_SIZE(p33x_partitions);
|
||||
adm5120_flash0_data.parts = p33x_partitions;
|
||||
|
||||
/* TODO: setup mac address */
|
||||
}
|
||||
|
||||
static struct adm5120_board p334wt_board __initdata = {
|
||||
.mach_type = MACH_ADM5120_P334WT,
|
||||
.name = "ZyXEL Prestige 334WT",
|
||||
.board_setup = p33x_setup,
|
||||
.num_devices = ARRAY_SIZE(p334_devices),
|
||||
.devices = p334_devices,
|
||||
};
|
||||
|
||||
static struct adm5120_board p335_board __initdata = {
|
||||
.mach_type = MACH_ADM5120_P335,
|
||||
.name = "ZyXEL Prestige 335/335WT",
|
||||
.board_setup = p33x_setup,
|
||||
.num_devices = ARRAY_SIZE(p335_devices),
|
||||
.devices = p335_devices,
|
||||
};
|
||||
|
||||
static int __init register_boards(void)
|
||||
{
|
||||
adm5120_board_register(&p334wt_board);
|
||||
adm5120_board_register(&p335_board);
|
||||
return 0;
|
||||
}
|
||||
|
||||
pure_initcall(register_boards);
|
||||
@@ -345,7 +345,7 @@ static int __init adm5120_gpio_init(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
subsys_initcall(adm5120_gpio_init);
|
||||
pure_initcall(adm5120_gpio_init);
|
||||
|
||||
EXPORT_SYMBOL(adm5120_gpio_direction_output);
|
||||
EXPORT_SYMBOL(adm5120_gpio_direction_input);
|
||||
|
||||
@@ -1,90 +1,179 @@
|
||||
/*****************************************************************************
|
||||
* Carsten Langgaard, carstenl@mips.com
|
||||
* Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.
|
||||
* Copyright (C) 2003 ADMtek Incorporated.
|
||||
* daniell@admtek.com.tw
|
||||
* Copyright (C) 2005 Jeroen Vreeken (pe1rxq@amsat.org)
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* ########################################################################
|
||||
* Copyright (C) 2007 OpenWrt.org
|
||||
* Copyright (C) 2007 Gabor Juhos <juhosg@freemail.hu>
|
||||
*
|
||||
* This program is free software; you can distribute it and/or modify it
|
||||
* under the terms of the GNU General Public License (Version 2) as
|
||||
* published by the Free Software Foundation.
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* ########################################################################
|
||||
*
|
||||
*****************************************************************************/
|
||||
*/
|
||||
|
||||
#include <linux/autoconf.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/mm.h>
|
||||
#include <linux/bootmem.h>
|
||||
#include <linux/pfn.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/kernel.h>
|
||||
|
||||
#include <asm/bootinfo.h>
|
||||
#include <asm/page.h>
|
||||
#include <asm/sections.h>
|
||||
#include <asm/addrspace.h>
|
||||
|
||||
#include <asm/mach-adm5120/adm5120_info.h>
|
||||
#include <asm-mips/mips-boards/prom.h>
|
||||
#include <asm/mach-adm5120/adm5120_defs.h>
|
||||
#include <asm/mach-adm5120/adm5120_switch.h>
|
||||
#include <asm/mach-adm5120/adm5120_mpmc.h>
|
||||
|
||||
#define PFN_ALIGN(x) (((unsigned long)(x) + (PAGE_SIZE - 1)) & PAGE_MASK)
|
||||
#define SWITCH_READ(r) *(u32 *)(KSEG1ADDR(ADM5120_SWITCH_BASE)+(r))
|
||||
#define SWITCH_WRITE(r,v) *(u32 *)(KSEG1ADDR(ADM5120_SWITCH_BASE)+(r))=(v)
|
||||
|
||||
struct prom_pmemblock mdesc[PROM_MAX_PMEMBLOCKS];
|
||||
#define MPMC_READ(r) *(u32 *)(KSEG1ADDR(ADM5120_SWITCH_BASE)+(r))
|
||||
#define MPMC_WRITE(r,v) *(u32 *)(KSEG1ADDR(ADM5120_SWITCH_BASE)+(r))=(v)
|
||||
|
||||
struct prom_pmemblock * __init prom_getmdesc(void)
|
||||
#if 1
|
||||
# define mem_dbg(f, a...) printk("mem_detect: " f, ## a)
|
||||
#else
|
||||
# define mem_dbg(f, a...)
|
||||
#endif
|
||||
|
||||
#define MEM_WR_DELAY 10000 /* 0.01 usec */
|
||||
|
||||
unsigned long adm5120_memsize;
|
||||
|
||||
static int __init mem_check_pattern(u8 *addr, unsigned long offs)
|
||||
{
|
||||
unsigned int memsize;
|
||||
char cmdline[CL_SIZE], *ptr;
|
||||
volatile u32 *p1 = (volatile u32 *)addr;
|
||||
volatile u32 *p2 = (volatile u32 *)(addr+offs);
|
||||
u32 t,u,v;
|
||||
|
||||
memsize = adm5120_memsize;
|
||||
/* Check the command line for a memsize directive that overrides
|
||||
* the physical/default amount */
|
||||
strcpy(cmdline, arcs_cmdline);
|
||||
ptr = strstr(cmdline, "memsize=");
|
||||
if (ptr && (ptr != cmdline) && (*(ptr - 1) != ' '))
|
||||
ptr = strstr(ptr, " memsize=");
|
||||
/* save original value */
|
||||
t = *p1;
|
||||
u = *p2;
|
||||
|
||||
if (ptr)
|
||||
memsize = memparse(ptr + 8, &ptr);
|
||||
|
||||
memset(mdesc, 0, sizeof(mdesc));
|
||||
mdesc[0].type = BOOT_MEM_RAM;
|
||||
mdesc[0].base = CPHYSADDR(PFN_ALIGN(&_end));
|
||||
mdesc[0].size = memsize - mdesc[0].base;
|
||||
if (t != u)
|
||||
return 0;
|
||||
|
||||
return &mdesc[0];
|
||||
v = 0x55555555;
|
||||
if (u == v)
|
||||
v = 0xAAAAAAAA;
|
||||
|
||||
mem_dbg("write 0x%08lX to 0x%08lX\n", v, (unsigned long)p1);
|
||||
|
||||
*p1 = v;
|
||||
mem_dbg("delay %d ns\n", MEM_WR_DELAY);
|
||||
adm5120_ndelay(MEM_WR_DELAY);
|
||||
u = *p2;
|
||||
|
||||
mem_dbg("pattern at 0x%08lX is 0x%08lX\n", (unsigned long)p2, u);
|
||||
|
||||
/* restore original value */
|
||||
*p1 = t;
|
||||
|
||||
return (v == u);
|
||||
}
|
||||
|
||||
void __init prom_meminit(void)
|
||||
static void __init adm5120_detect_memsize(void)
|
||||
{
|
||||
struct prom_pmemblock *p;
|
||||
u32 memctrl;
|
||||
u32 size, maxsize;
|
||||
u8 *p;
|
||||
|
||||
p = prom_getmdesc();
|
||||
|
||||
while (p->size)
|
||||
{
|
||||
long type;
|
||||
unsigned long base, size;
|
||||
base = p->base;
|
||||
type = p->type,
|
||||
size = p->size;
|
||||
add_memory_region(base, size, type);
|
||||
p++;
|
||||
memctrl = SWITCH_READ(SWITCH_REG_MEMCTRL);
|
||||
switch (memctrl & MEMCTRL_SDRS_MASK) {
|
||||
case MEMCTRL_SDRS_4M:
|
||||
maxsize = 4 << 20;
|
||||
break;
|
||||
case MEMCTRL_SDRS_8M:
|
||||
maxsize = 8 << 20;
|
||||
break;
|
||||
case MEMCTRL_SDRS_16M:
|
||||
maxsize = 16 << 20;
|
||||
break;
|
||||
default:
|
||||
maxsize = 64 << 20;
|
||||
break;
|
||||
}
|
||||
|
||||
/* disable buffers for both SDRAM banks */
|
||||
mem_dbg("disable buffers for both banks\n");
|
||||
MPMC_WRITE(MPMC_REG_DC0, MPMC_READ(MPMC_REG_DC0) & ~DC_BE);
|
||||
MPMC_WRITE(MPMC_REG_DC1, MPMC_READ(MPMC_REG_DC1) & ~DC_BE);
|
||||
|
||||
mem_dbg("checking for %ldMB chip in 1st bank\n", maxsize >> 20);
|
||||
|
||||
/* detect size of the 1st SDRAM bank */
|
||||
p = (u8 *)KSEG1ADDR(0);
|
||||
for (size = 2<<20; size <= (maxsize >> 1); size <<= 1) {
|
||||
if (mem_check_pattern(p, size)) {
|
||||
/* mirrored address */
|
||||
mem_dbg("mirrored data found at offset 0x%lX\n", size);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mem_dbg("chip size in 1st bank is %ldMB\n", size >> 20);
|
||||
adm5120_memsize = size;
|
||||
|
||||
if (size != maxsize)
|
||||
/* 2nd bank is not supported */
|
||||
goto out;
|
||||
|
||||
if ((memctrl & MEMCTRL_SDR1_ENABLE) == 0)
|
||||
/* 2nd bank is disabled */
|
||||
goto out;
|
||||
|
||||
/*
|
||||
* some bootloaders enable 2nd bank, even if the 2nd SDRAM chip
|
||||
* are missing.
|
||||
*/
|
||||
mem_dbg("check presence of 2nd bank\n");
|
||||
|
||||
p = (u8 *)KSEG1ADDR(maxsize+size-4);
|
||||
if (mem_check_pattern(p, 0)) {
|
||||
adm5120_memsize += size;
|
||||
}
|
||||
|
||||
if (maxsize != size) {
|
||||
/* adjusting MECTRL register */
|
||||
memctrl &= ~(MEMCTRL_SDRS_MASK);
|
||||
switch (size>>20) {
|
||||
case 4:
|
||||
memctrl |= MEMCTRL_SDRS_4M;
|
||||
break;
|
||||
case 8:
|
||||
memctrl |= MEMCTRL_SDRS_8M;
|
||||
break;
|
||||
case 16:
|
||||
memctrl |= MEMCTRL_SDRS_16M;
|
||||
break;
|
||||
default:
|
||||
memctrl |= MEMCTRL_SDRS_64M;
|
||||
break;
|
||||
}
|
||||
SWITCH_WRITE(SWITCH_REG_MEMCTRL, memctrl);
|
||||
}
|
||||
|
||||
out:
|
||||
/* reenable buffer for both SDRAM banks */
|
||||
mem_dbg("enable buffers for both banks\n");
|
||||
MPMC_WRITE(MPMC_REG_DC0, MPMC_READ(MPMC_REG_DC0) | DC_BE);
|
||||
MPMC_WRITE(MPMC_REG_DC1, MPMC_READ(MPMC_REG_DC1) | DC_BE);
|
||||
|
||||
mem_dbg("%dx%ldMB memory found\n", (adm5120_memsize == size) ? 1 : 2 ,
|
||||
size >>20);
|
||||
}
|
||||
|
||||
void __init prom_free_prom_memory(void)
|
||||
void __init adm5120_mem_init(void)
|
||||
{
|
||||
/* We do not have to prom memory to free */
|
||||
adm5120_detect_memsize();
|
||||
add_memory_region(0, adm5120_memsize, BOOT_MEM_RAM);
|
||||
}
|
||||
|
||||
111
target/linux/adm5120-2.6/files/arch/mips/adm5120/platform.c
Normal file
111
target/linux/adm5120-2.6/files/arch/mips/adm5120/platform.c
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Generic ADM5120 platform devices
|
||||
*
|
||||
* Copyright (C) 2007 OpenWrt.org
|
||||
* Copyright (C) 2007 Gabor Juhos <juhosg@freemail.hu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/init.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/platform_device.h>
|
||||
|
||||
#include <asm/bootinfo.h>
|
||||
#include <asm/gpio.h>
|
||||
|
||||
#include <asm/mach-adm5120/adm5120_defs.h>
|
||||
#include <asm/mach-adm5120/adm5120_info.h>
|
||||
#include <asm/mach-adm5120/adm5120_irq.h>
|
||||
#include <asm/mach-adm5120/adm5120_switch.h>
|
||||
#include <asm/mach-adm5120/adm5120_platform.h>
|
||||
|
||||
#if 1
|
||||
/*
|
||||
* TODO:remove global adm5120_eth* variables when the switch driver will be
|
||||
* converted into a real platform driver
|
||||
*/
|
||||
unsigned int adm5120_eth_num_ports = 6;
|
||||
unsigned char adm5120_eth_macs[6][6] = {
|
||||
{'\00', 'A', 'D', 'M', '\x51', '\x20' },
|
||||
{'\00', 'A', 'D', 'M', '\x51', '\x21' },
|
||||
{'\00', 'A', 'D', 'M', '\x51', '\x22' },
|
||||
{'\00', 'A', 'D', 'M', '\x51', '\x23' },
|
||||
{'\00', 'A', 'D', 'M', '\x51', '\x24' },
|
||||
{'\00', 'A', 'D', 'M', '\x51', '\x25' }
|
||||
};
|
||||
|
||||
EXPORT_SYMBOL_GPL(adm5120_eth_num_ports);
|
||||
EXPORT_SYMBOL_GPL(adm5120_eth_macs);
|
||||
#else
|
||||
/* Built-in ethernet switch */
|
||||
struct adm5120_switch_platform_data adm5120_switch_data;
|
||||
struct platform_device adm5120_switch_device = {
|
||||
.name = "adm5120-switch",
|
||||
.id = -1,
|
||||
.dev.platform_data = &adm5120_switch_data,
|
||||
};
|
||||
#endif
|
||||
|
||||
/* PCI Host Controller */
|
||||
struct adm5120_pci_platform_data adm5120_pci_data;
|
||||
struct platform_device adm5120_pci_device = {
|
||||
.name = "adm5120-pci",
|
||||
.id = -1,
|
||||
.dev.platform_data = &adm5120_pci_data,
|
||||
};
|
||||
|
||||
/* USB Host Controller */
|
||||
struct resource adm5120_usbc_resources[] = {
|
||||
[0] = {
|
||||
.start = ADM5120_USBC_BASE,
|
||||
.end = ADM5120_USBC_BASE+ADM5120_USBC_SIZE-1,
|
||||
.flags = IORESOURCE_MEM,
|
||||
},
|
||||
[1] = {
|
||||
.start = ADM5120_IRQ_USBC,
|
||||
.end = ADM5120_IRQ_USBC,
|
||||
.flags = IORESOURCE_IRQ,
|
||||
},
|
||||
};
|
||||
|
||||
struct platform_device adm5120_usbc_device = {
|
||||
.name = "adm5120-usbc",
|
||||
.id = -1,
|
||||
.num_resources = ARRAY_SIZE(adm5120_usbc_resources),
|
||||
.resource = adm5120_usbc_resources,
|
||||
};
|
||||
|
||||
/* NOR flash 0 */
|
||||
struct adm5120_flash_platform_data adm5120_flash0_data;
|
||||
struct platform_device adm5120_flash0_device = {
|
||||
.name = "adm5120-flash",
|
||||
.id = 0,
|
||||
.dev.platform_data = &adm5120_flash0_data,
|
||||
};
|
||||
|
||||
/* NOR flash 1 */
|
||||
struct adm5120_flash_platform_data adm5120_flash1_data;
|
||||
struct platform_device adm5120_flash1_device = {
|
||||
.name = "adm5120-flash",
|
||||
.id = 1,
|
||||
.dev.platform_data = &adm5120_flash1_data,
|
||||
};
|
||||
@@ -1,96 +1,160 @@
|
||||
/*****************************************************************************
|
||||
* Carsten Langgaard, carstenl@mips.com
|
||||
* Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.
|
||||
* Copyright (C) 2003 ADMtek Incorporated.
|
||||
* daniell@admtek.com.tw
|
||||
* Copyright (C) 2007 OpenWrt.org
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* This program is free software; you can distribute it and/or modify it
|
||||
* under the terms of the GNU General Public License (Version 2) as
|
||||
* published by the Free Software Foundation.
|
||||
* ADM5120 specific prom routines
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
* Copyright (C) 2007 OpenWrt.org
|
||||
* Copyright (C) 2007 Gabor Juhos <juhosg@freemail.hu>
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
*****************************************************************************/
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/init.h>
|
||||
#include <linux/autoconf.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/mm.h>
|
||||
#include <linux/bootmem.h>
|
||||
|
||||
#include <asm/bootinfo.h>
|
||||
#include <asm/addrspace.h>
|
||||
|
||||
#include <asm/mach-adm5120/adm5120_info.h>
|
||||
#include <asm/mach-adm5120/adm5120_defs.h>
|
||||
#include <asm/mach-adm5120/adm5120_uart.h>
|
||||
|
||||
static char **prom_envp = NULL;
|
||||
#include <prom/cfe.h>
|
||||
#include <prom/generic.h>
|
||||
#include <prom/routerboot.h>
|
||||
#include <prom/myloader.h>
|
||||
#include <prom/zynos.h>
|
||||
|
||||
void setup_prom_printf(int);
|
||||
void prom_printf(char *, ...);
|
||||
void prom_meminit(void);
|
||||
unsigned int adm5120_prom_type = ADM5120_PROM_GENERIC;
|
||||
|
||||
struct board_desc {
|
||||
unsigned long mach_type;
|
||||
char *name;
|
||||
};
|
||||
|
||||
#define READCSR(r) *(volatile unsigned long *)(0xB2600000+(r))
|
||||
#define WRITECSR(r,v) *(volatile unsigned long *)(0xB2600000+(r)) = v
|
||||
#define DEFBOARD(n, mt) { .mach_type = (mt), .name = (n)}
|
||||
static struct board_desc common_boards[] __initdata = {
|
||||
/* Cellvision/SparkLAN boards */
|
||||
DEFBOARD("CAS-630", MACH_ADM5120_CAS630),
|
||||
DEFBOARD("CAS-670", MACH_ADM5120_CAS670),
|
||||
DEFBOARD("CAS-771", MACH_ADM5120_CAS771),
|
||||
DEFBOARD("CAS-790", MACH_ADM5120_CAS790),
|
||||
DEFBOARD("CAS-861", MACH_ADM5120_CAS861),
|
||||
/* Compex boards */
|
||||
DEFBOARD("WP54G-WRT", MACH_ADM5120_WP54G_WRT),
|
||||
/* Edimax boards */
|
||||
DEFBOARD("BR-6104K", MACH_ADM5120_BR6104K),
|
||||
DEFBOARD("BR-6104KP", MACH_ADM5120_BR6104K),
|
||||
/* Infineon boards */
|
||||
DEFBOARD("EASY 5120", MACH_ADM5120_EASY5120),
|
||||
DEFBOARD("EASY 5120-RT", MACH_ADM5120_EASY5120RT),
|
||||
DEFBOARD("EASY 5120P-ATA", MACH_ADM5120_EASY5120PATA),
|
||||
DEFBOARD("EASY 83000", MACH_ADM5120_EASY83000),
|
||||
/* Mikrotik RouterBOARDs */
|
||||
DEFBOARD("111", MACH_ADM5120_RB_111),
|
||||
DEFBOARD("112", MACH_ADM5120_RB_112),
|
||||
DEFBOARD("133", MACH_ADM5120_RB_133),
|
||||
DEFBOARD("133C", MACH_ADM5120_RB_133C),
|
||||
DEFBOARD("miniROUTER", MACH_ADM5120_RB_150),
|
||||
DEFBOARD("153", MACH_ADM5120_RB_153),
|
||||
};
|
||||
|
||||
#define UART_DR_REG 0x00
|
||||
#define UART_FR_REG 0x18
|
||||
#define UART_TX_FIFO_FULL 0x20
|
||||
|
||||
int putPromChar(char c)
|
||||
static unsigned long __init find_machtype_byname(char *name)
|
||||
{
|
||||
WRITECSR(UART_DR_REG, c);
|
||||
while ( (READCSR(UART_FR_REG) & UART_TX_FIFO_FULL) );
|
||||
return 0;
|
||||
unsigned long ret;
|
||||
int i;
|
||||
|
||||
ret = MACH_ADM5120_GENERIC;
|
||||
if (name == NULL)
|
||||
goto out;
|
||||
|
||||
if (*name == '\0')
|
||||
goto out;
|
||||
|
||||
for (i=0; i<ARRAY_SIZE(common_boards); i++) {
|
||||
if (strcmp(common_boards[i].name, name) == 0) {
|
||||
ret = common_boards[i].mach_type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ugly prom_printf used for debugging
|
||||
*/
|
||||
|
||||
void prom_printf(char *fmt, ...)
|
||||
static unsigned long __init detect_machtype_routerboot(void)
|
||||
{
|
||||
va_list args;
|
||||
int l;
|
||||
char *p, *buf_end;
|
||||
char buf[1024];
|
||||
char *name;
|
||||
|
||||
va_start(args, fmt);
|
||||
l = vsprintf(buf, fmt, args); /* hopefully i < sizeof(buf) */
|
||||
va_end(args);
|
||||
|
||||
buf_end = buf + l;
|
||||
|
||||
for (p = buf; p < buf_end; p++) {
|
||||
/* Crude cr/nl handling is better than none */
|
||||
if (*p == '\n')
|
||||
putPromChar('\r');
|
||||
putPromChar(*p);
|
||||
}
|
||||
name = routerboot_get_boardname();
|
||||
return find_machtype_byname(name);
|
||||
}
|
||||
|
||||
char *prom_getenv(char *envname)
|
||||
static unsigned long __init detect_machtype_generic(void)
|
||||
{
|
||||
char **env;
|
||||
char *ret;
|
||||
char *name;
|
||||
|
||||
ret = NULL;
|
||||
name = generic_prom_getenv("board");
|
||||
return find_machtype_byname(name);
|
||||
}
|
||||
|
||||
if (prom_envp== NULL)
|
||||
return NULL;
|
||||
unsigned long __init detect_machtype_cfe(void)
|
||||
{
|
||||
char *name;
|
||||
|
||||
for (env = prom_envp; *env != NULL; env++) {
|
||||
if (strcmp(envname, *env++) == 0) {
|
||||
ret = *env;
|
||||
name = cfe_getenv("BOARD_NAME");
|
||||
return find_machtype_byname(name);
|
||||
}
|
||||
|
||||
static struct {
|
||||
unsigned long mach_type;
|
||||
u16 vendor_id;
|
||||
u16 board_id;
|
||||
} zynos_boards[] __initdata = {
|
||||
#define ZYNOS_BOARD(vi, bi, mt) { .vendor_id = (vi), .board_id = (bi), \
|
||||
.mach_type = (mt) }
|
||||
|
||||
#define ZYXEL_BOARD(bi, mt) ZYNOS_BOARD(ZYNOS_VENDOR_ID_ZYXEL, bi, mt)
|
||||
#define DLINK_BOARD(bi, mt) ZYNOS_BOARD(ZYNOS_VENDOR_ID_DLINK, bi, mt)
|
||||
#define LUCENT_BOARD(bi, mt) ZYNOS_BOARD(ZYNOS_VENDOR_ID_LUCENT, bi, mt)
|
||||
ZYXEL_BOARD(ZYNOS_BOARD_HS100, MACH_ADM5120_HS100),
|
||||
ZYXEL_BOARD(ZYNOS_BOARD_P334, MACH_ADM5120_P334),
|
||||
ZYXEL_BOARD(ZYNOS_BOARD_P334U, MACH_ADM5120_P334U),
|
||||
ZYXEL_BOARD(ZYNOS_BOARD_P334W, MACH_ADM5120_P334W),
|
||||
ZYXEL_BOARD(ZYNOS_BOARD_P334WH, MACH_ADM5120_P334WH),
|
||||
ZYXEL_BOARD(ZYNOS_BOARD_P334WHD, MACH_ADM5120_P334WHD),
|
||||
ZYXEL_BOARD(ZYNOS_BOARD_P334WT, MACH_ADM5120_P334WT),
|
||||
ZYXEL_BOARD(ZYNOS_BOARD_P335, MACH_ADM5120_P335),
|
||||
ZYXEL_BOARD(ZYNOS_BOARD_P335PLUS, MACH_ADM5120_P335PLUS),
|
||||
ZYXEL_BOARD(ZYNOS_BOARD_P335U, MACH_ADM5120_P335U)
|
||||
};
|
||||
|
||||
static unsigned long __init detect_machtype_bootbase(void)
|
||||
{
|
||||
unsigned long ret;
|
||||
int i;
|
||||
|
||||
ret = MACH_ADM5120_GENERIC;
|
||||
for (i=0; i<ARRAY_SIZE(zynos_boards); i++) {
|
||||
if (zynos_boards[i].vendor_id == bootbase_info.vendor_id &&
|
||||
zynos_boards[i].board_id == bootbase_info.board_id) {
|
||||
ret = zynos_boards[i].mach_type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -98,29 +162,108 @@ char *prom_getenv(char *envname)
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern char _image_cmdline;
|
||||
/*
|
||||
* initialize the prom module.
|
||||
*/
|
||||
void __init prom_init(void)
|
||||
{
|
||||
char *cmd;
|
||||
static struct {
|
||||
unsigned long mach_type;
|
||||
u16 vid;
|
||||
u16 did;
|
||||
u16 svid;
|
||||
u16 sdid;
|
||||
} mylo_boards[] __initdata = {
|
||||
#define MYLO_BOARD(v,d,sv,sd,mt) { .vid = (v), .did = (d), .svid = (sv), \
|
||||
.sdid = (sd), .mach_type = (mt) }
|
||||
#define COMPEX_BOARD(d,mt) MYLO_BOARD(VENID_COMPEX,(d),VENID_COMPEX,(d),(mt))
|
||||
|
||||
if ((fw_arg2 & 3) == 0) {
|
||||
prom_envp = (char **)fw_arg2;
|
||||
COMPEX_BOARD(DEVID_COMPEX_NP27G, MACH_ADM5120_NP27G),
|
||||
COMPEX_BOARD(DEVID_COMPEX_NP28G, MACH_ADM5120_NP28G),
|
||||
COMPEX_BOARD(DEVID_COMPEX_NP28GHS, MACH_ADM5120_NP28GHS),
|
||||
COMPEX_BOARD(DEVID_COMPEX_WP54G, MACH_ADM5120_WP54G),
|
||||
COMPEX_BOARD(DEVID_COMPEX_WP54Gv1C, MACH_ADM5120_WP54Gv1C),
|
||||
COMPEX_BOARD(DEVID_COMPEX_WP54AG, MACH_ADM5120_WP54AG),
|
||||
COMPEX_BOARD(DEVID_COMPEX_WPP54G, MACH_ADM5120_WPP54G),
|
||||
COMPEX_BOARD(DEVID_COMPEX_WPP54AG, MACH_ADM5120_WPP54AG),
|
||||
};
|
||||
|
||||
static unsigned long __init detect_machtype_myloader(void)
|
||||
{
|
||||
unsigned long ret;
|
||||
int i;
|
||||
|
||||
ret = MACH_ADM5120_GENERIC;
|
||||
for (i=0; i<ARRAY_SIZE(mylo_boards); i++) {
|
||||
if (mylo_boards[i].vid == myloader_info.vid &&
|
||||
mylo_boards[i].did == myloader_info.did &&
|
||||
mylo_boards[i].svid == myloader_info.svid &&
|
||||
mylo_boards[i].sdid == myloader_info.sdid) {
|
||||
ret = mylo_boards[i].mach_type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
adm5120_info_init();
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* you should these macros defined in include/asm/bootinfo.h */
|
||||
mips_machgroup = MACH_GROUP_ADM5120;
|
||||
mips_machtype = adm5120_board.mach_type;
|
||||
static void __init prom_detect_machtype(void)
|
||||
{
|
||||
if (bootbase_present()) {
|
||||
adm5120_prom_type = ADM5120_PROM_BOOTBASE;
|
||||
mips_machtype = detect_machtype_bootbase();
|
||||
return;
|
||||
}
|
||||
|
||||
if (cfe_present()) {
|
||||
adm5120_prom_type = ADM5120_PROM_CFE;
|
||||
mips_machtype = detect_machtype_cfe();
|
||||
return;
|
||||
}
|
||||
|
||||
if (myloader_present()) {
|
||||
adm5120_prom_type = ADM5120_PROM_MYLOADER;
|
||||
mips_machtype = detect_machtype_myloader();
|
||||
return;
|
||||
}
|
||||
|
||||
if (routerboot_present()) {
|
||||
adm5120_prom_type = ADM5120_PROM_ROUTERBOOT;
|
||||
mips_machtype = detect_machtype_routerboot();
|
||||
return;
|
||||
}
|
||||
|
||||
adm5120_prom_type = ADM5120_PROM_GENERIC;
|
||||
mips_machtype = detect_machtype_generic();
|
||||
}
|
||||
|
||||
/* TODO: this is an ugly hack for RouterBOARDS */
|
||||
extern char _image_cmdline;
|
||||
static void __init prom_init_cmdline(void)
|
||||
{
|
||||
char *cmd;
|
||||
|
||||
/* init command line, register a default kernel command line */
|
||||
cmd = &_image_cmdline + 8;
|
||||
if( strlen(cmd) > 0) strcpy( &(arcs_cmdline[0]), cmd);
|
||||
else strcpy(&(arcs_cmdline[0]), CONFIG_CMDLINE);
|
||||
|
||||
/* init memory map */
|
||||
prom_meminit();
|
||||
}
|
||||
|
||||
#define UART_READ(r) *(volatile u32 *)(KSEG1ADDR(ADM5120_UART0_BASE)+(r))
|
||||
#define UART_WRITE(r,v) *(volatile u32 *)(KSEG1ADDR(ADM5120_UART0_BASE)+(r))=(v)
|
||||
|
||||
void __init prom_putchar(char ch)
|
||||
{
|
||||
while ((UART_READ(UART_REG_FLAG) & UART_FLAG_TXFE) == 0);
|
||||
UART_WRITE(UART_REG_DATA, ch);
|
||||
while ((UART_READ(UART_REG_FLAG) & UART_FLAG_TXFE) == 0);
|
||||
}
|
||||
|
||||
void __init prom_init(void)
|
||||
{
|
||||
mips_machgroup = MACH_GROUP_ADM5120;
|
||||
prom_detect_machtype();
|
||||
|
||||
prom_init_cmdline();
|
||||
}
|
||||
|
||||
void __init prom_free_prom_memory(void)
|
||||
{
|
||||
/* We do not have to prom memory to free */
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
#
|
||||
# Makefile for the ADMtek ADM5120 SoC specific parts of the kernel
|
||||
#
|
||||
|
||||
lib-y += bootbase.o
|
||||
lib-y += cfe.o
|
||||
lib-y += generic.o
|
||||
lib-y += myloader.o
|
||||
lib-y += routerboot.o
|
||||
124
target/linux/adm5120-2.6/files/arch/mips/adm5120/prom/bootbase.c
Normal file
124
target/linux/adm5120-2.6/files/arch/mips/adm5120/prom/bootbase.c
Normal file
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* ZyXEL's Bootbase specific prom routines
|
||||
*
|
||||
* Copyright (C) 2007 OpenWrt.org
|
||||
* Copyright (C) 2007 Gabor Juhos <juhosg@freemail.hu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/autoconf.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/string.h>
|
||||
|
||||
#include <asm/bootinfo.h>
|
||||
#include <asm/addrspace.h>
|
||||
#include <asm/byteorder.h>
|
||||
|
||||
#include <adm5120_defs.h>
|
||||
#include <prom/zynos.h>
|
||||
#include "prom_read.h"
|
||||
|
||||
#define ZYNOS_INFO_ADDR KSEG1ADDR(ADM5120_SRAM0_BASE+0x3F90)
|
||||
#define ZYNOS_HDBG_ADDR KSEG1ADDR(ADM5120_SRAM0_BASE+0x4000)
|
||||
#define BOOTEXT_ADDR_MIN KSEG1ADDR(ADM5120_SRAM0_BASE)
|
||||
#define BOOTEXT_ADDR_MAX (BOOTEXT_ADDR_MIN + (2*1024*1024))
|
||||
|
||||
static int bootbase_found = 0;
|
||||
static struct zynos_board_info *board_info;
|
||||
|
||||
struct bootbase_info bootbase_info;
|
||||
|
||||
static inline int bootbase_dbgarea_present(u8 *data)
|
||||
{
|
||||
u32 t;
|
||||
|
||||
t = prom_read_be32(data+5);
|
||||
if (t != ZYNOS_MAGIC_DBGAREA1)
|
||||
return 0;
|
||||
|
||||
t = prom_read_be32(data+9);
|
||||
if (t != ZYNOS_MAGIC_DBGAREA2)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static inline u32 bootbase_get_bootext_addr(void)
|
||||
{
|
||||
return prom_read_be32(&board_info->bootext_addr);
|
||||
}
|
||||
|
||||
static inline u16 bootbase_get_vendor_id(void)
|
||||
{
|
||||
#define CHECK_VENDOR(n) (strnicmp(board_info->vendor,(n),strlen(n)) == 0)
|
||||
unsigned char vendor[ZYNOS_NAME_LEN];
|
||||
int i;
|
||||
|
||||
for (i=0; i<ZYNOS_NAME_LEN; i++)
|
||||
vendor[i]=board_info->vendor[i];
|
||||
|
||||
if CHECK_VENDOR(ZYNOS_VENDOR_ZYXEL)
|
||||
return ZYNOS_VENDOR_ID_ZYXEL;
|
||||
|
||||
if CHECK_VENDOR(ZYNOS_VENDOR_DLINK)
|
||||
return ZYNOS_VENDOR_ID_DLINK;
|
||||
|
||||
if CHECK_VENDOR(ZYNOS_VENDOR_LUCENT)
|
||||
return ZYNOS_VENDOR_ID_LUCENT;
|
||||
|
||||
if CHECK_VENDOR(ZYNOS_VENDOR_NETGEAR)
|
||||
return ZYNOS_VENDOR_ID_NETGEAR;
|
||||
|
||||
return ZYNOS_VENDOR_ID_OTHER;
|
||||
}
|
||||
|
||||
static inline u16 bootbase_get_board_id(void)
|
||||
{
|
||||
return prom_read_be16(&board_info->board_id);
|
||||
}
|
||||
|
||||
int __init bootbase_present(void)
|
||||
{
|
||||
u32 t;
|
||||
|
||||
if (bootbase_found)
|
||||
goto out;
|
||||
|
||||
/* check presence of the dbgarea */
|
||||
if (bootbase_dbgarea_present((u8 *)ZYNOS_HDBG_ADDR) == 0)
|
||||
goto out;
|
||||
|
||||
board_info = (struct zynos_board_info *)(ZYNOS_INFO_ADDR);
|
||||
|
||||
/* check for a valid BootExt address */
|
||||
t = bootbase_get_bootext_addr();
|
||||
if ((t < BOOTEXT_ADDR_MIN) || (t > BOOTEXT_ADDR_MAX))
|
||||
goto out;
|
||||
|
||||
bootbase_info.vendor_id = bootbase_get_vendor_id();
|
||||
bootbase_info.board_id = bootbase_get_board_id();
|
||||
|
||||
bootbase_found = 1;
|
||||
|
||||
out:
|
||||
return bootbase_found;
|
||||
}
|
||||
|
||||
86
target/linux/adm5120-2.6/files/arch/mips/adm5120/prom/cfe.c
Normal file
86
target/linux/adm5120-2.6/files/arch/mips/adm5120/prom/cfe.c
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Broadcom's CFE specific prom routines
|
||||
*
|
||||
* Copyright (C) 2007 OpenWrt.org
|
||||
* Copyright (C) 2007 Gabor Juhos <juhosg@freemail.hu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/init.h>
|
||||
|
||||
#include <asm/bootinfo.h>
|
||||
#include <asm/addrspace.h>
|
||||
|
||||
#include <prom/cfe.h>
|
||||
#include "prom_read.h"
|
||||
|
||||
/*
|
||||
* CFE based boards
|
||||
*/
|
||||
#define CFE_EPTSEAL 0x43464531 /* CFE1 is the magic number to recognize CFE
|
||||
from other bootloaders */
|
||||
|
||||
static int cfe_found = 0;
|
||||
|
||||
static u32 cfe_handle;
|
||||
static u32 cfe_entry;
|
||||
static u32 cfe_seal;
|
||||
|
||||
int __init cfe_present(void)
|
||||
{
|
||||
/*
|
||||
* This method only works, when we are booted directly from the CFE.
|
||||
*/
|
||||
u32 a1 = (u32) fw_arg1;
|
||||
|
||||
if (cfe_found)
|
||||
return 1;
|
||||
|
||||
cfe_handle = (u32) fw_arg0;
|
||||
cfe_entry = (u32) fw_arg2;
|
||||
cfe_seal = (u32) fw_arg3;
|
||||
|
||||
/* Check for CFE by finding the CFE magic number */
|
||||
if (cfe_seal != CFE_EPTSEAL) {
|
||||
/* We are not booted from CFE */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* cfe_a1_val must be 0, because only one CPU present in the ADM5120 */
|
||||
if (a1 != 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* The cfe_handle, and the cfe_entry must be kernel mode addresses */
|
||||
if ((cfe_handle < KSEG0) || (cfe_entry < KSEG0)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
cfe_found = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
char *cfe_getenv(char *envname)
|
||||
{
|
||||
if (cfe_found == 0)
|
||||
return NULL;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Generic PROM routines
|
||||
*
|
||||
* Copyright (C) 2007 OpenWrt.org
|
||||
* Copyright (C) 2007 Gabor Juhos <juhosg@freemail.hu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/string.h>
|
||||
|
||||
#include <asm/bootinfo.h>
|
||||
|
||||
#include <prom/generic.h>
|
||||
|
||||
static int *_prom_argc;
|
||||
static char **_prom_argv;
|
||||
static char **_prom_envp;
|
||||
|
||||
char *generic_prom_getenv(char *envname)
|
||||
{
|
||||
char **env;
|
||||
char *ret;
|
||||
|
||||
ret = NULL;
|
||||
for (env = _prom_envp; *env != NULL; env++) {
|
||||
if (strcmp(envname, *env++) == 0) {
|
||||
ret = *env;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int generic_prom_present(void)
|
||||
{
|
||||
_prom_argc = (int *)fw_arg0;
|
||||
_prom_argv = (char **)fw_arg1;
|
||||
_prom_envp = (char **)fw_arg2;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Compex's MyLoader specific prom routines
|
||||
*
|
||||
* Copyright (C) 2007 OpenWrt.org
|
||||
* Copyright (C) 2007 Gabor Juhos <juhosg@freemail.hu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/autoconf.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/string.h>
|
||||
|
||||
#include <asm/bootinfo.h>
|
||||
#include <asm/addrspace.h>
|
||||
#include <asm/byteorder.h>
|
||||
|
||||
#include <adm5120_defs.h>
|
||||
#include <prom/myloader.h>
|
||||
#include "prom_read.h"
|
||||
|
||||
#define SYS_PARAMS_ADDR KSEG1ADDR(ADM5120_SRAM0_BASE+0x0F000)
|
||||
#define BOARD_PARAMS_ADDR KSEG1ADDR(ADM5120_SRAM0_BASE+0x0F800)
|
||||
#define PART_TABLE_ADDR KSEG1ADDR(ADM5120_SRAM0_BASE+0x10000)
|
||||
|
||||
static int myloader_found = 0;
|
||||
|
||||
struct myloader_info myloader_info;
|
||||
|
||||
int __init myloader_present(void)
|
||||
{
|
||||
struct mylo_system_params *sysp;
|
||||
struct mylo_board_params *boardp;
|
||||
struct mylo_partition_table *parts;
|
||||
|
||||
if (myloader_found)
|
||||
goto out;
|
||||
|
||||
sysp = (struct mylo_system_params *)(SYS_PARAMS_ADDR);
|
||||
boardp = (struct mylo_board_params *)(BOARD_PARAMS_ADDR);
|
||||
parts = (struct mylo_partition_table *)(PART_TABLE_ADDR);
|
||||
|
||||
/* Check for some magic numbers */
|
||||
if ((le32_to_cpu(sysp->magic) != MYLO_MAGIC_SYS_PARAMS) ||
|
||||
(le32_to_cpu(boardp->magic) != MYLO_MAGIC_BOARD_PARAMS) ||
|
||||
(le32_to_cpu(parts->magic) != MYLO_MAGIC_PARTITIONS))
|
||||
goto out;
|
||||
|
||||
myloader_info.vid = le32_to_cpu(sysp->vid);
|
||||
myloader_info.did = le32_to_cpu(sysp->did);
|
||||
myloader_info.svid = le32_to_cpu(sysp->svid);
|
||||
myloader_info.sdid = le32_to_cpu(sysp->sdid);
|
||||
|
||||
myloader_found = 1;
|
||||
|
||||
out:
|
||||
return myloader_found;
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Generic prom definitions
|
||||
*
|
||||
* Copyright (C) 2007 OpenWrt.org
|
||||
* Copyright (C) 2007 Gabor Juhos <juhosg@freemail.hu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef _ADM5120_PROM_H_
|
||||
#define _ADM5120_PROM_H_
|
||||
|
||||
/*
|
||||
* Helper routines
|
||||
*/
|
||||
static inline u16 prom_read_le16(void *buf)
|
||||
{
|
||||
u8 *p = buf;
|
||||
|
||||
return ((u16)p[0] + ((u16)p[1] << 8));
|
||||
}
|
||||
|
||||
static inline u32 prom_read_le32(void *buf)
|
||||
{
|
||||
u8 *p = buf;
|
||||
|
||||
return ((u32)p[0] + ((u32)p[1] << 8) + ((u32)p[2] << 16) +
|
||||
((u32)p[3] << 24));
|
||||
}
|
||||
|
||||
static inline u16 prom_read_be16(void *buf)
|
||||
{
|
||||
u8 *p = buf;
|
||||
|
||||
return (((u16)p[0] << 8) + (u16)p[1]);
|
||||
}
|
||||
|
||||
static inline u32 prom_read_be32(void *buf)
|
||||
{
|
||||
u8 *p = buf;
|
||||
|
||||
return (((u32)p[0] << 24) + ((u32)p[1] << 16) + ((u32)p[2] << 8) +
|
||||
((u32)p[3]));
|
||||
}
|
||||
|
||||
#endif /* _ADM5120_PROM_H_ */
|
||||
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Mikrotik's RouterBOOT specific prom routines
|
||||
*
|
||||
* Copyright (C) 2007 OpenWrt.org
|
||||
* Copyright (C) 2007 Gabor Juhos <juhosg@freemail.hu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/autoconf.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/string.h>
|
||||
|
||||
#include <asm/bootinfo.h>
|
||||
#include <asm/addrspace.h>
|
||||
|
||||
#include <adm5120_defs.h>
|
||||
#include <prom/routerboot.h>
|
||||
#include "prom_read.h"
|
||||
|
||||
static struct rb_hard_settings rb_hs;
|
||||
static int rb_found = 0;
|
||||
|
||||
static int __init routerboot_load_hs(u8 *buf, u16 buflen)
|
||||
{
|
||||
u16 id,len;
|
||||
u8 *mac;
|
||||
int i,j;
|
||||
|
||||
memset(&rb_hs, 0, sizeof(rb_hs));
|
||||
|
||||
if (buflen < 4)
|
||||
return -1;
|
||||
|
||||
if (prom_read_le32(buf) != RB_MAGIC_HARD)
|
||||
return -1;
|
||||
|
||||
/* skip magic value */
|
||||
buf += 4;
|
||||
buflen -= 4;
|
||||
|
||||
while (buflen > 2) {
|
||||
id = prom_read_le16(buf);
|
||||
buf += 2;
|
||||
buflen -= 2;
|
||||
if (id == RB_ID_TERMINATOR || buflen < 2)
|
||||
break;
|
||||
|
||||
len = prom_read_le16(buf);
|
||||
buf += 2;
|
||||
buflen -= 2;
|
||||
|
||||
if (buflen < len)
|
||||
break;
|
||||
|
||||
switch (id) {
|
||||
case RB_ID_BIOS_VERSION:
|
||||
rb_hs.bios_ver = (char *)buf;
|
||||
break;
|
||||
case RB_ID_BOARD_NAME:
|
||||
rb_hs.name = (char *)buf;
|
||||
break;
|
||||
case RB_ID_MEMORY_SIZE:
|
||||
rb_hs.mem_size = prom_read_le32(buf);
|
||||
break;
|
||||
case RB_ID_MAC_ADDRESS_COUNT:
|
||||
rb_hs.mac_count = prom_read_le32(buf);
|
||||
break;
|
||||
case RB_ID_MAC_ADDRESS_PACK:
|
||||
rb_hs.mac_count = len/RB_MAC_SIZE;
|
||||
if (rb_hs.mac_count > RB_MAX_MAC_COUNT)
|
||||
rb_hs.mac_count = RB_MAX_MAC_COUNT;
|
||||
mac = buf;
|
||||
for (i=0; i < rb_hs.mac_count; i++) {
|
||||
for (j=0; j < RB_MAC_SIZE; j++)
|
||||
rb_hs.macs[i][j] = mac[j];
|
||||
mac += RB_MAC_SIZE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
buf += len;
|
||||
buflen -= len;
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define RB_BS_OFFS 0x14
|
||||
#define RB_OFFS_MAX (128*1024)
|
||||
|
||||
int __init routerboot_present(void)
|
||||
{
|
||||
struct rb_bios_settings *bs;
|
||||
u8 *base;
|
||||
u32 off,len;
|
||||
|
||||
if (rb_found)
|
||||
goto out;
|
||||
|
||||
base = (u8 *)KSEG1ADDR(ADM5120_SRAM0_BASE);
|
||||
bs = (struct rb_bios_settings *)(base + RB_BS_OFFS);
|
||||
|
||||
off = prom_read_le32(&bs->hs_offs);
|
||||
len = prom_read_le32(&bs->hs_size);
|
||||
if (off > RB_OFFS_MAX)
|
||||
goto out;
|
||||
|
||||
if (routerboot_load_hs(base+off, len) != 0)
|
||||
goto out;
|
||||
|
||||
rb_found = 1;
|
||||
|
||||
out:
|
||||
return rb_found;
|
||||
}
|
||||
|
||||
char *routerboot_get_boardname(void)
|
||||
{
|
||||
if (rb_found == 0)
|
||||
return NULL;
|
||||
|
||||
return rb_hs.name;
|
||||
}
|
||||
62
target/linux/adm5120-2.6/files/arch/mips/adm5120/reset.c
Normal file
62
target/linux/adm5120-2.6/files/arch/mips/adm5120/reset.c
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* ADM5120 specific reset routines
|
||||
*
|
||||
* Copyright (C) ADMtek Incorporated.
|
||||
* Copyright (C) 2005 Jeroen Vreeken (pe1rxq@amsat.org)
|
||||
* Copyright (C) 2007 Gabor Juhos <juhosg@freemail.hu>
|
||||
* Copyright (C) 2007 OpenWrt.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
|
||||
#include <asm/bootinfo.h>
|
||||
#include <asm/addrspace.h>
|
||||
|
||||
#include <asm/mach-adm5120/adm5120_info.h>
|
||||
#include <asm/mach-adm5120/adm5120_defs.h>
|
||||
#include <asm/mach-adm5120/adm5120_switch.h>
|
||||
|
||||
#define ADM5120_SOFTRESET 0x12000004
|
||||
|
||||
void (*adm5120_board_reset)(void);
|
||||
|
||||
void adm5120_restart(char *command)
|
||||
{
|
||||
/* TODO: stop switch before reset */
|
||||
|
||||
if (adm5120_board_reset)
|
||||
adm5120_board_reset();
|
||||
|
||||
*(u32*)KSEG1ADDR(ADM5120_SOFTRESET)=1;
|
||||
}
|
||||
|
||||
void adm5120_halt(void)
|
||||
{
|
||||
printk(KERN_NOTICE "\n** You can safely turn off the power\n");
|
||||
while (1);
|
||||
}
|
||||
|
||||
void adm5120_power_off(void)
|
||||
{
|
||||
adm5120_halt();
|
||||
}
|
||||
@@ -1,15 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) ADMtek Incorporated.
|
||||
* Creator : daniell@admtek.com.tw
|
||||
* Copyright 1999, 2000 MIPS Technologies, Inc.
|
||||
* Copyright Jeroen Vreeken (pe1rxq@amsat.org), 2005
|
||||
* Copyright (C) 2007 OpenWrt.org
|
||||
* $Id$
|
||||
*
|
||||
* ADM5120 specific setup
|
||||
*
|
||||
* Copyright (C) ADMtek Incorporated.
|
||||
* Copyright (C) 2005 Jeroen Vreeken (pe1rxq@amsat.org)
|
||||
* Copyright (C) 2007 Gabor Juhos <juhosg@freemail.hu>
|
||||
* Copyright (C) 2007 OpenWrt.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/autoconf.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/kernel.h>
|
||||
|
||||
#include <asm/reboot.h>
|
||||
#include <asm/io.h>
|
||||
@@ -17,33 +34,34 @@
|
||||
|
||||
#include <asm/mach-adm5120/adm5120_info.h>
|
||||
#include <asm/mach-adm5120/adm5120_defs.h>
|
||||
#include <asm/mach-adm5120/adm5120_irq.h>
|
||||
#include <asm/mach-adm5120/adm5120_switch.h>
|
||||
#include <asm/mach-adm5120/adm5120_board.h>
|
||||
|
||||
extern void adm5120_time_init(void) __init;
|
||||
static char *prom_names[ADM5120_PROM_LAST+1] __initdata = {
|
||||
[ADM5120_PROM_GENERIC] = "Generic",
|
||||
[ADM5120_PROM_CFE] = "CFE",
|
||||
[ADM5120_PROM_UBOOT] = "U-Boot",
|
||||
[ADM5120_PROM_MYLOADER] = "MyLoader",
|
||||
[ADM5120_PROM_ROUTERBOOT] = "RouterBOOT",
|
||||
[ADM5120_PROM_BOOTBASE] = "Bootbase"
|
||||
};
|
||||
|
||||
#define ADM5120_SOFTRESET 0x12000004
|
||||
|
||||
void adm5120_restart(char *command)
|
||||
static void __init adm5120_report(void)
|
||||
{
|
||||
*(u32*)KSEG1ADDR(ADM5120_SOFTRESET)=1;
|
||||
}
|
||||
|
||||
|
||||
void adm5120_halt(void)
|
||||
{
|
||||
printk(KERN_NOTICE "\n** You can safely turn off the power\n");
|
||||
while (1);
|
||||
}
|
||||
|
||||
|
||||
void adm5120_power_off(void)
|
||||
{
|
||||
adm5120_halt();
|
||||
printk(KERN_INFO "SoC : ADM%04X%s revision %d, running at %ldMHz\n",
|
||||
adm5120_product_code,
|
||||
(adm5120_package == ADM5120_PACKAGE_BGA) ? "" : "P",
|
||||
adm5120_revision, (adm5120_speed / 1000000)
|
||||
);
|
||||
printk(KERN_INFO "Bootdev : %s flash\n", adm5120_nand_boot ? "NAND":"NOR");
|
||||
printk(KERN_INFO "Prom : %s\n", prom_names[adm5120_prom_type]);
|
||||
}
|
||||
|
||||
void __init plat_mem_setup(void)
|
||||
{
|
||||
printk(KERN_INFO "ADM5120 board setup\n");
|
||||
adm5120_soc_init();
|
||||
adm5120_mem_init();
|
||||
adm5120_report();
|
||||
|
||||
board_time_init = adm5120_time_init;
|
||||
|
||||
@@ -53,39 +71,3 @@ void __init plat_mem_setup(void)
|
||||
|
||||
set_io_port_base(KSEG1);
|
||||
}
|
||||
|
||||
const char *get_system_type(void)
|
||||
{
|
||||
return adm5120_board_name();
|
||||
}
|
||||
|
||||
static struct resource adm5120_hcd_resources[] = {
|
||||
[0] = {
|
||||
.start = ADM5120_USBC_BASE,
|
||||
.end = ADM5120_USBC_BASE+ADM5120_USBC_SIZE-1,
|
||||
.flags = IORESOURCE_MEM,
|
||||
},
|
||||
[1] = {
|
||||
.start = ADM5120_IRQ_USBC,
|
||||
.end = ADM5120_IRQ_USBC,
|
||||
.flags = IORESOURCE_IRQ,
|
||||
},
|
||||
};
|
||||
|
||||
static struct platform_device adm5120hcd_device = {
|
||||
.name = "adm5120-hcd",
|
||||
.id = -1,
|
||||
.num_resources = ARRAY_SIZE(adm5120_hcd_resources),
|
||||
.resource = adm5120_hcd_resources,
|
||||
};
|
||||
|
||||
static struct platform_device *devices[] __initdata = {
|
||||
&adm5120hcd_device,
|
||||
};
|
||||
|
||||
static int __init adm5120_init(void)
|
||||
{
|
||||
return platform_add_devices(devices, ARRAY_SIZE(devices));
|
||||
}
|
||||
|
||||
subsys_initcall(adm5120_init);
|
||||
|
||||
219
target/linux/adm5120-2.6/files/arch/mips/adm5120/trxsplit.c
Normal file
219
target/linux/adm5120-2.6/files/arch/mips/adm5120/trxsplit.c
Normal file
@@ -0,0 +1,219 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2007 OpenWrt.org
|
||||
* Copyright (C) Gabor Juhos <juhosg@freemail.hu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/kmod.h>
|
||||
#include <linux/root_dev.h>
|
||||
|
||||
#include <linux/mtd/mtd.h>
|
||||
#include <linux/mtd/partitions.h>
|
||||
|
||||
#include <linux/byteorder/generic.h>
|
||||
|
||||
#define PFX "trxsplit: "
|
||||
|
||||
#define TRX_MAGIC 0x30524448 /* "HDR0" */
|
||||
#define TRX_VERSION 1
|
||||
#define TRX_MAX_LEN 0x3A0000
|
||||
#define TRX_NO_HEADER 1 /* Do not write TRX header */
|
||||
#define TRX_GZ_FILES 0x2 /* Contains up to TRX_MAX_OFFSET individual gzip files */
|
||||
#define TRX_MAX_OFFSET 3
|
||||
#define TRX_MIN_KERNEL_SIZE 256*1024
|
||||
|
||||
struct trx_header {
|
||||
u32 magic; /* "HDR0" */
|
||||
u32 len; /* Length of file including header */
|
||||
u32 crc32; /* 32-bit CRC from flag_version to end of file */
|
||||
u32 flag_version; /* 0:15 flags, 16:31 version */
|
||||
u32 offsets[TRX_MAX_OFFSET]; /* Offsets of partitions from start of header */
|
||||
};
|
||||
|
||||
#define BLOCK_LEN_MIN 0x10000
|
||||
|
||||
static struct mtd_info *trx_mtd_master = NULL;
|
||||
static struct mtd_info *trx_mtds[TRX_MAX_OFFSET];
|
||||
static struct mtd_partition trx_parts[TRX_MAX_OFFSET];
|
||||
static struct trx_header trx_hdr;
|
||||
static int trx_nr_parts = 0;
|
||||
static int trx_rootfs_part = -1;
|
||||
|
||||
static int __init trxsplit_checktrx(struct mtd_info *mtd, unsigned long offset)
|
||||
{
|
||||
size_t retlen;
|
||||
int err;
|
||||
|
||||
err = mtd->read(mtd, offset, sizeof(trx_hdr), &retlen, (void *)&trx_hdr);
|
||||
if (err)
|
||||
goto err_out;
|
||||
|
||||
if (retlen != sizeof(trx_hdr))
|
||||
goto err_out;
|
||||
|
||||
trx_hdr.magic = le32_to_cpu(trx_hdr.magic);
|
||||
trx_hdr.len = le32_to_cpu(trx_hdr.len);
|
||||
trx_hdr.crc32 = le32_to_cpu(trx_hdr.crc32);
|
||||
trx_hdr.flag_version = le32_to_cpu(trx_hdr.flag_version);
|
||||
trx_hdr.offsets[0] = le32_to_cpu(trx_hdr.offsets[0]);
|
||||
trx_hdr.offsets[1] = le32_to_cpu(trx_hdr.offsets[1]);
|
||||
trx_hdr.offsets[2] = le32_to_cpu(trx_hdr.offsets[2]);
|
||||
|
||||
/* sanity checks */
|
||||
if (trx_hdr.magic != TRX_MAGIC)
|
||||
goto err_out;
|
||||
|
||||
if (trx_hdr.len > mtd->size - offset)
|
||||
goto err_out;
|
||||
|
||||
/* TODO: add crc32 checking too? */
|
||||
|
||||
return 1;
|
||||
|
||||
err_out:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __init trxsplit_create_partitions(struct mtd_info *mtd,
|
||||
unsigned long offset)
|
||||
{
|
||||
struct mtd_partition *part = trx_parts;
|
||||
int i;
|
||||
|
||||
for (i=0;i<TRX_MAX_OFFSET;i++) {
|
||||
part = &trx_parts[i];
|
||||
if (trx_hdr.offsets[i] == 0)
|
||||
continue;
|
||||
part->offset = offset + trx_hdr.offsets[i];
|
||||
part->mtdp = &trx_mtds[trx_nr_parts];
|
||||
trx_nr_parts++;
|
||||
}
|
||||
|
||||
for (i=0; i<trx_nr_parts-1; i++) {
|
||||
trx_parts[i].size = trx_parts[i+1].offset - trx_parts[i].offset;
|
||||
}
|
||||
trx_parts[i].size = mtd->size - trx_parts[i].offset;
|
||||
|
||||
i=0;
|
||||
part = &trx_parts[i];
|
||||
if (part->size < TRX_MIN_KERNEL_SIZE) {
|
||||
part->name = "trx_loader";
|
||||
i++;
|
||||
}
|
||||
|
||||
part = &trx_parts[i];
|
||||
part->name = "trx_kernel";
|
||||
i++;
|
||||
|
||||
part = &trx_parts[i];
|
||||
part->name = "trx_rootfs";
|
||||
trx_rootfs_part = i;
|
||||
}
|
||||
|
||||
static void __init trxsplit_add_mtd(struct mtd_info *mtd)
|
||||
{
|
||||
unsigned long offset;
|
||||
unsigned long blocklen;
|
||||
int found;
|
||||
|
||||
if (trx_mtd_master)
|
||||
return;
|
||||
|
||||
blocklen = mtd->erasesize;
|
||||
if (blocklen < BLOCK_LEN_MIN)
|
||||
blocklen = BLOCK_LEN_MIN;
|
||||
|
||||
printk(KERN_INFO PFX "searching TRX header in '%s'\n", mtd->name);
|
||||
|
||||
found = 0;
|
||||
for (offset=0; offset < mtd->size; offset+=blocklen) {
|
||||
found = trxsplit_checktrx(mtd, offset);
|
||||
if (found)
|
||||
break;
|
||||
}
|
||||
|
||||
if (found == 0) {
|
||||
printk(KERN_ALERT PFX "no TRX header found\n");
|
||||
return;
|
||||
}
|
||||
|
||||
printk(KERN_INFO PFX "TRX header found at 0x%lX\n", offset);
|
||||
|
||||
trxsplit_create_partitions(mtd, offset);
|
||||
|
||||
trx_mtd_master = mtd;
|
||||
}
|
||||
|
||||
static void trxsplit_remove_mtd(struct mtd_info *mtd)
|
||||
{
|
||||
}
|
||||
|
||||
static struct mtd_notifier trxsplit_notifier __initdata = {
|
||||
.add = trxsplit_add_mtd,
|
||||
.remove = trxsplit_remove_mtd,
|
||||
};
|
||||
|
||||
static void __init trxsplit_find_trx(void)
|
||||
{
|
||||
register_mtd_user(&trxsplit_notifier);
|
||||
unregister_mtd_user(&trxsplit_notifier);
|
||||
}
|
||||
|
||||
static int __init trxsplit_init(void)
|
||||
{
|
||||
int err;
|
||||
int i;
|
||||
|
||||
trxsplit_find_trx();
|
||||
|
||||
if (trx_mtd_master == NULL)
|
||||
goto err;
|
||||
|
||||
printk(KERN_INFO PFX "creating TRX partitions in '%s'\n",
|
||||
trx_mtd_master->name);
|
||||
|
||||
err = add_mtd_partitions(trx_mtd_master, trx_parts, trx_nr_parts);
|
||||
if (err) {
|
||||
printk(KERN_ALERT PFX "creating TRX partitions failed\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
for (i=0; i<trx_nr_parts; i++) {
|
||||
/* TODO: add error checking */
|
||||
add_mtd_device(trx_mtds[i]);
|
||||
}
|
||||
|
||||
if (ROOT_DEV == 0 && trx_rootfs_part >= 0) {
|
||||
printk(KERN_INFO PFX "set '%s' to be root filesystem\n",
|
||||
trx_mtds[trx_rootfs_part]->name);
|
||||
ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, trx_mtds[trx_rootfs_part]->index);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err:
|
||||
return -1;
|
||||
}
|
||||
|
||||
late_initcall(trxsplit_init);
|
||||
Reference in New Issue
Block a user