diff options
author | Gabor Juhos <juhosg@openwrt.org> | 2007-07-11 13:00:27 +0000 |
---|---|---|
committer | Gabor Juhos <juhosg@openwrt.org> | 2007-07-11 13:00:27 +0000 |
commit | e755238ccf164b571a8fec6abb0ef427e66f2c0c (patch) | |
tree | a898a3d4793d5b1ece23dce2f4d5ded01d0e5697 /target/linux/adm5120-2.6/files/arch/mips | |
parent | 5e109d6e8cb9e11c4d075f8a98f832dddb7ab8f1 (diff) | |
download | master-187ad058-e755238ccf164b571a8fec6abb0ef427e66f2c0c.tar.gz master-187ad058-e755238ccf164b571a8fec6abb0ef427e66f2c0c.tar.bz2 master-187ad058-e755238ccf164b571a8fec6abb0ef427e66f2c0c.zip |
[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
Diffstat (limited to 'target/linux/adm5120-2.6/files/arch/mips')
26 files changed, 2377 insertions, 1273 deletions
diff --git a/target/linux/adm5120-2.6/files/arch/mips/adm5120/Makefile b/target/linux/adm5120-2.6/files/arch/mips/adm5120/Makefile index deb1adf7e1..fd588a4e3c 100644 --- a/target/linux/adm5120-2.6/files/arch/mips/adm5120/Makefile +++ b/target/linux/adm5120-2.6/files/arch/mips/adm5120/Makefile @@ -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) diff --git a/target/linux/adm5120-2.6/files/arch/mips/adm5120/adm5120_info.c b/target/linux/adm5120-2.6/files/arch/mips/adm5120/adm5120_info.c index c34dbd0095..17d82faaf9 100644 --- a/target/linux/adm5120-2.6/files/arch/mips/adm5120/adm5120_info.c +++ b/target/linux/adm5120-2.6/files/arch/mips/adm5120/adm5120_info.c @@ -1,904 +1,42 @@ /* - * $Id$ + * $Id$ * - * Copyright (C) 2007 OpenWrt.org - * Copyright (C) 2007 Gabor Juhos <juhosg@freemail.hu> + * 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. * - * 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. */ #include <linux/types.h> -#include <linux/autoconf.h> #include <linux/kernel.h> #include <linux/init.h> -#include <linux/string.h> -#include <linux/module.h> #include <asm/bootinfo.h> #include <asm/addrspace.h> -#include <asm/byteorder.h> +#include <asm/mach-adm5120/adm5120_info.h> #include <asm/mach-adm5120/adm5120_defs.h> #include <asm/mach-adm5120/adm5120_switch.h> -#include <asm/mach-adm5120/adm5120_mpmc.h> -#include <asm/mach-adm5120/adm5120_info.h> -#include <asm/mach-adm5120/myloader.h> -#include <asm/mach-adm5120/routerboot.h> -#include <asm/mach-adm5120/zynos.h> - -extern char *prom_getenv(char *envname); -/* - * Globals - */ -struct adm5120_board adm5120_board; -EXPORT_SYMBOL_GPL(adm5120_board); - -unsigned int adm5120_boot_loader; unsigned int adm5120_product_code; unsigned int adm5120_revision; unsigned int adm5120_package; unsigned int adm5120_nand_boot; unsigned long adm5120_speed; -unsigned long adm5120_memsize; - -/* - * Locals - */ -static char *boot_loader_names[BOOT_LOADER_LAST+1] = { - [BOOT_LOADER_UNKNOWN] = "Unknown", - [BOOT_LOADER_CFE] = "CFE", - [BOOT_LOADER_UBOOT] = "U-Boot", - [BOOT_LOADER_MYLOADER] = "MyLoader", - [BOOT_LOADER_ROUTERBOOT]= "RouterBOOT", - [BOOT_LOADER_BOOTBASE] = "Bootbase" -}; - -static struct adm5120_board __initdata adm5120_boards[] = { - /* FIXME: some boards have invalid fields */ - { - .name = "Cellvision CAS-630/630W", - .mach_type = MACH_ADM5120_CAS630, - .has_usb = 0, - .iface_num = 1, - .flash0_size = 4*1024*1024, - }, - { - .name = "Cellvision CAS-670/670W", - .mach_type = MACH_ADM5120_CAS670, - .has_usb = 0, - .iface_num = 1, - .flash0_size = 4*1024*1024, - }, - { - .name = "Cellvision CAS-700/700W", - .mach_type = MACH_ADM5120_CAS700, - .has_usb = 0, - .iface_num = 1, - .flash0_size = 4*1024*1024, - }, - { - .name = "Cellvision CAS-771/771W", - .mach_type = MACH_ADM5120_CAS771, - .has_usb = 0, - .iface_num = 5, - .mem_size = (32 << 20), - .flash0_size = 4*1024*1024, - }, - { - .name = "Cellvision CAS-790", - .mach_type = MACH_ADM5120_CAS790, - .has_usb = 0, - .iface_num = 1, - .flash0_size = 4*1024*1024, - }, - { - .name = "Cellvision CAS-861/861W", - .mach_type = MACH_ADM5120_CAS861, - .has_usb = 0, - .iface_num = 1, - .flash0_size = 4*1024*1024, - }, - { - .name = "Cellvision NFS-101U/101WU", - .mach_type = MACH_ADM5120_NFS101U, - .has_usb = 0, - .iface_num = 1, - .flash0_size = 4*1024*1024, - }, - { - .name = "Cellvision NFS-202U/202WU", - .mach_type = MACH_ADM5120_NFS202U, - .has_usb = 0, - .iface_num = 1, - .flash0_size = 4*1024*1024, - }, - { - .name = "Compex NetPassage 27G", - .mach_type = MACH_ADM5120_NP27G, - .has_usb = 1, - .iface_num = 5, - .flash0_size = 4*1024*1024, - }, - { - .name = "Compex NetPassage 28G", - .mach_type = MACH_ADM5120_NP28G, - .has_usb = 0, - .iface_num = 4, - .flash0_size = 4*1024*1024, - }, - { - .name = "Compex NP28G (HotSpot)", - .mach_type = MACH_ADM5120_NP28GHS, - .has_usb = 0, - .iface_num = 4, - .flash0_size = 4*1024*1024, - }, - { - .name = "Compex WP54AG", - .mach_type = MACH_ADM5120_WP54AG, - .has_usb = 0, - .iface_num = 2, - .mem_size = (16 << 20), - .flash0_size = 4*1024*1024, - }, - { - .name = "Compex WP54G", - .mach_type = MACH_ADM5120_WP54G, - .has_usb = 0, - .iface_num = 2, - .flash0_size = 4*1024*1024, - }, - { - .name = "Compex WP54G-WRT", - .mach_type = MACH_ADM5120_WP54G_WRT, - .has_usb = 0, - .iface_num = 2, - .flash0_size = 4*1024*1024, - }, - { - .name = "Compex WP54G v1C", - .mach_type = MACH_ADM5120_WP54Gv1C, - .has_usb = 0, - .iface_num = 2, - .flash0_size = 2*1024*1024, - }, - { - .name = "Compex WPP54AG", - .mach_type = MACH_ADM5120_WPP54AG, - .has_usb = 0, - .iface_num = 2, - .flash0_size = 4*1024*1024, - }, - { - .name = "Compex WPP54G", - .mach_type = MACH_ADM5120_WPP54G, - .has_usb = 0, - .iface_num = 2, - .flash0_size = 4*1024*1024, - }, - { - .name = "Edimax BR-6104K", - .mach_type = MACH_ADM5120_BR6104K, - .has_usb = 0, - .iface_num = 5, - .mem_size = (16 << 20), - .flash0_size = 2*1024*1024, - }, - { - .name = "Infineon EASY 5120", - .mach_type = MACH_ADM5120_EASY5120, - .has_usb = 0, - .iface_num = 0, - .flash0_size = 2*1024*1024, - }, - { - .name = "Infineon EASY 5120-RT", - .mach_type = MACH_ADM5120_EASY5120RT, - .has_usb = 0, - .iface_num = 0, - .flash0_size = 2*1024*1024, - }, - { - .name = "Infineon EASY 5120P-ATA", - .mach_type = MACH_ADM5120_EASY5120PATA, - .has_usb = 0, - .iface_num = 0, - .flash0_size = 2*1024*1024, - }, - { - .name = "Infineon EASY 83000", - .mach_type = MACH_ADM5120_EASY83000, - .has_usb = 0, - .iface_num = 6, - .flash0_size = 4*1024*1024, - }, - { - .name = "RouterBOARD 111", - .mach_type = MACH_ADM5120_RB_111, - .has_usb = 0, - .iface_num = 1, - .flash0_size = 128*1024, - }, - { - .name = "RouterBOARD 112", - .mach_type = MACH_ADM5120_RB_112, - .has_usb = 0, - .iface_num = 1, - .flash0_size = 128*1024, - }, - { - .name = "RouterBOARD 133", - .mach_type = MACH_ADM5120_RB_133, - .has_usb = 0, - .iface_num = 3, - .flash0_size = 128*1024, - }, - { - .name = "RouterBOARD 133C", - .mach_type = MACH_ADM5120_RB_133C, - .has_usb = 0, - .iface_num = 1, - .flash0_size = 128*1024, - }, - { - .name = "RouterBOARD 150", - .mach_type = MACH_ADM5120_RB_150, - .has_usb = 0, - .iface_num = 5, - .flash0_size = 128*1024, - }, - { - .name = "RouterBOARD 153", - .mach_type = MACH_ADM5120_RB_153, - .has_usb = 0, - .iface_num = 5, - .flash0_size = 128*1024, - }, - { - .name = "ZyXEL ES-2024A", - .mach_type = MACH_ADM5120_ES2024A, - .has_usb = 0, - .iface_num = 0, - .flash0_size = 4*1024*1024, - }, - { - .name = "ZyXEL ES-2024PWR", - .mach_type = MACH_ADM5120_ES2024PWR, - .has_usb = 0, - .iface_num = 0, - .flash0_size = 4*1024*1024, - }, - { - .name = "ZyXEL ES-2108", - .mach_type = MACH_ADM5120_ES2108, - .has_usb = 0, - .iface_num = 0, - .flash0_size = 4*1024*1024, - }, - { - .name = "ZyXEL ES-2108-F", - .mach_type = MACH_ADM5120_ES2108F, - .has_usb = 0, - .iface_num = 0, - .flash0_size = 4*1024*1024, - }, - { - .name = "ZyXEL ES-2108-G", - .mach_type = MACH_ADM5120_ES2108G, - .has_usb = 0, - .iface_num = 0, - .flash0_size = 4*1024*1024, - }, - { - .name = "ZyXEL ES-2108-LC", - .mach_type = MACH_ADM5120_ES2108LC, - .has_usb = 0, - .iface_num = 0, - .flash0_size = 4*1024*1024, - }, - { - .name = "ZyXEL ES-2108-PWR", - .mach_type = MACH_ADM5120_ES2108PWR, - .has_usb = 0, - .iface_num = 0, - .flash0_size = 4*1024*1024, - }, - { - .name = "ZyXEL HomeSafe 100/100W", - .mach_type = MACH_ADM5120_HS100, - .has_usb = 0, - .iface_num = 5, - .flash0_size = 4*1024*1024, - }, - { - .name = "ZyXEL Prestige 334", - .mach_type = MACH_ADM5120_P334, - .has_usb = 0, - .iface_num = 5, - .flash0_size = 2*1024*1024, - }, - { - .name = "ZyXEL Prestige 334U", - .mach_type = MACH_ADM5120_P334U, - .has_usb = 0, - .iface_num = 5, - .flash0_size = 4*1024*1024, - }, - { - .name = "ZyXEL Prestige 334W", - .mach_type = MACH_ADM5120_P334W, - .has_usb = 0, - .iface_num = 5, - .flash0_size = 2*1024*1024, - }, - { - .name = "ZyXEL Prestige 334WH", - .mach_type = MACH_ADM5120_P334WH, - .has_usb = 0, - .iface_num = 5, - .flash0_size = 4*1024*1024, - }, - { - .name = "ZyXEL Prestige 334WHD", - .mach_type = MACH_ADM5120_P334WHD, - .has_usb = 0, - .iface_num = 5, - .flash0_size = 4*1024*1024, - }, - { - .name = "ZyXEL Prestige 334WT", - .mach_type = MACH_ADM5120_P334WT, - .has_usb = 1, - .iface_num = 5, - .flash0_size = 4*1024*1024, - }, - { - .name = "ZyXEL Prestige 335/335WT", - .mach_type = MACH_ADM5120_P335, - .has_usb = 1, - .iface_num = 5, - .flash0_size = 4*1024*1024, - }, - { - .name = "ZyXEL Prestige 335Plus", - .mach_type = MACH_ADM5120_P335PLUS, - .has_usb = 1, - .iface_num = 5, - .flash0_size = 4*1024*1024, - }, - { - .name = "ZyXEL Prestige 335U", - .mach_type = MACH_ADM5120_P335U, - .has_usb = 1, - .iface_num = 5, - .flash0_size = 4*1024*1024, - }, - { - .name = "Unknown ADM5120 board", - .mach_type = MACH_ADM5120_UNKNOWN, - .has_usb = 1, - .iface_num = 5, - .flash0_size = 4*1024*1024, - } -}; - -#define DUMMY_BOARD() {.mach_type = MACH_ADM5120_UNKNOWN} - -struct mylo_board { - u16 vid; - u16 did; - u16 svid; - u16 sdid; - unsigned long mach_type; -}; - - -#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)) - -static struct mylo_board mylo_boards[] __initdata = { - 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), - DUMMY_BOARD() -}; - -#define ROUTERBOARD_NAME_LEN 16 - -struct routerboard { - unsigned long mach_type; - char name[ROUTERBOARD_NAME_LEN]; -}; - -#define ROUTERBOARD(n, mt) { .name = (n), .mach_type = (mt) } -static struct routerboard routerboards[] __initdata = { - ROUTERBOARD("111", MACH_ADM5120_RB_111), - ROUTERBOARD("112", MACH_ADM5120_RB_112), - ROUTERBOARD("133", MACH_ADM5120_RB_133), - ROUTERBOARD("133C", MACH_ADM5120_RB_133C), - ROUTERBOARD("miniROUTER", MACH_ADM5120_RB_150), - ROUTERBOARD("153", MACH_ADM5120_RB_150), - DUMMY_BOARD() -}; - -struct zynos_board { - unsigned long mach_type; - unsigned int vendor_id; - u16 board_id; -}; - -#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) - -static struct zynos_board zynos_boards[] __initdata = { - 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), - DUMMY_BOARD() -}; - -struct common_board { - char *name; - unsigned long mach_type; -}; - -#define DEFBOARD(n, mt) { .name = (n), .mach_type = (mt) } -static struct common_board common_boards[] __initdata = { - DEFBOARD("CAS-630", MACH_ADM5120_CAS630), - DEFBOARD("CAS-670", MACH_ADM5120_CAS670), - DEFBOARD("CAS-700", MACH_ADM5120_CAS700), - DEFBOARD("CAS-771", MACH_ADM5120_CAS771), - DEFBOARD("CAS-790", MACH_ADM5120_CAS790), - DEFBOARD("CAS-861", MACH_ADM5120_CAS861), - DEFBOARD("NFS-101U", MACH_ADM5120_NFS101U), - DEFBOARD("NFS-202U", MACH_ADM5120_NFS202U), - 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), - DEFBOARD("BR-6104K", MACH_ADM5120_BR6104K), - DEFBOARD("WP54G-WRT", MACH_ADM5120_WP54G_WRT), - DEFBOARD("P-334WT", MACH_ADM5120_P334WT), - DEFBOARD("P-335", MACH_ADM5120_P335), -}; - -/* - * Helper routines - */ -static inline u16 read_le16(void *buf) -{ - u8 *p; - - p = buf; - return ((u16)p[0] + ((u16)p[1] << 8)); -} - -static inline u32 read_le32(void *buf) -{ - u8 *p; - - p = buf; - return ((u32)p[0] + ((u32)p[1] << 8) + ((u32)p[2] << 16) + - ((u32)p[3] << 24)); -} - -static inline u16 read_be16(void *buf) -{ - u8 *p; - - p = buf; - return (((u16)p[0] << 8) + (u16)p[1]); -} - -static inline u32 read_be32(void *buf) -{ - u8 *p; - - p = buf; - return (((u32)p[0] << 24) + ((u32)p[1] << 16) + ((u32)p[2] << 8) + - ((u32)p[3])); -} - -/* - * CFE based boards - */ -#define CFE_EPTSEAL 0x43464531 /* CFE1 is the magic number to recognize CFE -from other bootloaders */ - -static int __init cfe_present(void) -{ - /* - * This method only works, when we are booted directly from the CFE. - */ - u32 cfe_handle = (u32) fw_arg0; - u32 cfe_a1_val = (u32) fw_arg1; - u32 cfe_entry = (u32) fw_arg2; - u32 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 (cfe_a1_val != 0) { - return 0; - } - - /* The cfe_handle, and the cfe_entry must be kernel mode addresses */ - if ((cfe_handle < KSEG0) || (cfe_entry < KSEG0)) { - return 0; - } - - return 1; -} - -static unsigned long __init cfe_detect_board(void) -{ - return MACH_ADM5120_WP54G_WRT; -} - -/* - * MyLoader based boards - */ -#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 unsigned long __init myloader_detect_board(void) -{ - struct mylo_system_params *sysp; - struct mylo_board_params *boardp; - struct mylo_partition_table *parts; - struct mylo_board *board; - unsigned long ret; - - ret = MACH_ADM5120_UNKNOWN; - - 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; - - for (board = mylo_boards; board->mach_type != MACH_ADM5120_UNKNOWN; - board++) { - if ((le16_to_cpu(sysp->vid) == board->vid) && - (le16_to_cpu(sysp->did) == board->did) && - (le16_to_cpu(sysp->svid) == board->svid) && - (le16_to_cpu(sysp->sdid) == board->sdid)) { - ret = board->mach_type; - break; - } - } - - /* assume MyLoader as the boot-loader */ - adm5120_boot_loader = BOOT_LOADER_MYLOADER; - -out: - return ret; -} - -/* - * RouterBOOT based boards - */ -static int __init routerboot_load_hs(u8 *buf, u16 buflen, - struct rb_hard_settings *hs) -{ - u16 id,len; - u8 *mac; - int i,j; - - if (buflen < 4) - return -1; - - if (read_le32(buf) != RB_MAGIC_HARD) - return -1; - - /* skip magic value */ - buf += 4; - buflen -= 4; - - while (buflen > 2) { - id = read_le16(buf); - buf += 2; - buflen -= 2; - if (id == RB_ID_TERMINATOR || buflen < 2) - break; - - len = read_le16(buf); - buf += 2; - buflen -= 2; - - if (buflen < len) - break; - - switch (id) { - case RB_ID_BIOS_VERSION: - hs->bios_ver = (char *)buf; - break; - case RB_ID_BOARD_NAME: - hs->name = (char *)buf; - break; - case RB_ID_MEMORY_SIZE: - hs->mem_size = read_le32(buf); - break; - case RB_ID_MAC_ADDRESS_COUNT: - hs->mac_count = read_le32(buf); - break; - case RB_ID_MAC_ADDRESS_PACK: - hs->mac_count = len/RB_MAC_SIZE; - if (hs->mac_count > RB_MAX_MAC_COUNT) - hs->mac_count = RB_MAX_MAC_COUNT; - mac = buf; - for (i=0; i < hs->mac_count; i++) { - for (j=0; j < RB_MAC_SIZE; j++) - 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) - -static unsigned long __init routerboot_detect_board(void) -{ - struct routerboard *board; - struct rb_hard_settings hs; - struct rb_bios_settings *bs; - u8 *base; - u32 off,len; - unsigned long ret; - - ret = MACH_ADM5120_UNKNOWN; - - base = (u8 *)KSEG1ADDR(ADM5120_SRAM0_BASE); - bs = (struct rb_bios_settings *)(base + RB_BS_OFFS); - - off = read_le32(&bs->hs_offs); - len = read_le32(&bs->hs_size); - if (off > RB_OFFS_MAX) - return ret; - - memset(&hs, 0, sizeof(hs)); - if (routerboot_load_hs(base+off, len, &hs) != 0) - return ret; - - /* assume RouterBOOT as the boot-loader */ - adm5120_boot_loader = BOOT_LOADER_ROUTERBOOT; - - if (hs.name == NULL) - return ret; - - for (board = routerboards; board->mach_type != MACH_ADM5120_UNKNOWN; - board++) { - if (strncmp(board->name, hs.name, strlen(board->name)) == 0) { - ret = board->mach_type; - break; - } - } - - return ret; -} - -/* - * ZyNOS based boards - */ -static inline u32 zynos_dbgarea_present(u8 *data) -{ - u32 t; - - t = read_be32(data+5); - if (t != ZYNOS_MAGIC_DBGAREA1) - return 0; - - t = read_be32(data+9); - if (t != ZYNOS_MAGIC_DBGAREA2) - return 0; - - return 1; -} - -#define CHECK_VENDOR(n) (strnicmp(vendor,(n),strlen(n)) == 0) - -static inline unsigned int zynos_get_vendor_id(struct zynos_board_info *info) -{ - unsigned char vendor[ZYNOS_NAME_LEN]; - int i; - - for (i=0; i<ZYNOS_NAME_LEN; i++) - vendor[i]=info->vendor[i]; - - if CHECK_VENDOR(ZYNOS_VENDOR_ZYXEL) - return ZYNOS_VENDOR_ID_ZYXEL; -#if 0 - /* TODO: there are no known ADM5120 based boards from other vendors */ - 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; -#endif - - return ZYNOS_VENDOR_ID_OTHER; -} - -static inline u16 zynos_get_board_id(struct zynos_board_info *info) -{ - return read_be16(&info->board_id); -} - -static inline u32 zynos_get_bootext_addr(struct zynos_board_info *info) -{ - return read_be32(&info->bootext_addr); -} - - -#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 unsigned long __init zynos_detect_board(void) -{ - struct zynos_board_info *info; - struct zynos_board *board; - unsigned int vendor_id; - u16 board_id; - u32 t; - unsigned long ret; - - ret = MACH_ADM5120_UNKNOWN; - /* check presence of the dbgarea */ - if (zynos_dbgarea_present((u8 *)ZYNOS_HDBG_ADDR) == 0) - goto out; - - info = (struct zynos_board_info *)(ZYNOS_INFO_ADDR); - - /* check for a valid BootExt address */ - t = zynos_get_bootext_addr(info); - if ((t < BOOTEXT_ADDR_MIN) || (t > BOOTEXT_ADDR_MAX)) - goto out; - - vendor_id = zynos_get_vendor_id(info); - board_id = zynos_get_board_id(info); - - for (board = zynos_boards; board->mach_type != MACH_ADM5120_UNKNOWN; - board++) { - if ((board->vendor_id == vendor_id) && - (board->board_id == board_id)) { - ret = board->mach_type; - break; - } - } - - /* assume Bootbase as the boot-loader */ - adm5120_boot_loader = BOOT_LOADER_BOOTBASE; - -out: - return ret; -} - -/* - * U-Boot based boards - */ -static int __init uboot_present(void) -{ - /* FIXME: not yet implemented */ - return 0; -} - -static unsigned long __init uboot_detect_board(void) -{ - /* FIXME: not yet implemented */ - return MACH_ADM5120_UNKNOWN; -} - -/* - * Misc boards - */ -static unsigned long __init prom_detect_board(void) -{ - char *name; - unsigned long ret; - int i; - - ret = MACH_ADM5120_UNKNOWN; - name = prom_getenv("board_name"); - 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; -} - -static void __init adm5120_detect_board(void) -{ - struct adm5120_board *board; - unsigned long t; - - adm5120_boot_loader = BOOT_LOADER_UNKNOWN; - - /* Try to detect board type without bootloader */ - t = routerboot_detect_board(); - - if (t == MACH_ADM5120_UNKNOWN) - t = zynos_detect_board(); - - if (t == MACH_ADM5120_UNKNOWN) - t = myloader_detect_board(); - - /* Try to detect bootloader type */ - if (cfe_present()) { - adm5120_boot_loader = BOOT_LOADER_CFE; - if (t == MACH_ADM5120_UNKNOWN) - t = cfe_detect_board(); - } else if (uboot_present()) { - adm5120_boot_loader = BOOT_LOADER_UBOOT; - if (t == MACH_ADM5120_UNKNOWN) - t = uboot_detect_board(); - } else { - if (t == MACH_ADM5120_UNKNOWN) - t = prom_detect_board(); - } - - for (board = adm5120_boards; board->mach_type != MACH_ADM5120_UNKNOWN; - board++) { - if (board->mach_type == t) - break; - } - - memcpy(&adm5120_board, board, sizeof(adm5120_board)); -} #define SWITCH_READ(r) *(u32 *)(KSEG1ADDR(ADM5120_SWITCH_BASE)+(r)) #define SWITCH_WRITE(r,v) *(u32 *)(KSEG1ADDR(ADM5120_SWITCH_BASE)+(r))=(v) @@ -912,28 +50,7 @@ static void __init adm5120_detect_board(void) #define CODE_GET_CLKS(c) (((c) >> CODE_CLKS_SHIFT) & CODE_CLKS_MASK) #define CODE_GET_NAB(c) (((c) & CODE_NAB) != 0) -static void __init adm5120_detect_cpuinfo(void) -{ - u32 code; - u32 clks; - - code = SWITCH_READ(SWITCH_REG_CODE); - - adm5120_product_code = CODE_GET_PC(code); - adm5120_revision = CODE_GET_REV(code); - adm5120_package = (CODE_GET_PK(code) == CODE_PK_BGA) ? - ADM5120_PACKAGE_BGA : ADM5120_PACKAGE_PQFP; - adm5120_nand_boot = CODE_GET_NAB(code); - - clks = CODE_GET_CLKS(code); - adm5120_speed = ADM5120_SPEED_175; - if (clks & 1) - adm5120_speed += 25000000; - if (clks & 2) - adm5120_speed += 50000000; -} - -static void adm5120_ndelay(u32 ns) +void adm5120_ndelay(u32 ns) { u32 t; @@ -954,166 +71,23 @@ static void adm5120_ndelay(u32 ns) SWITCH_WRITE(SWITCH_REG_TIMER_INT, (TIMER_INT_TOS | TIMER_INT_TOM)); } -#define MPMC_READ(r) *(u32 *)(KSEG1ADDR(ADM5120_SWITCH_BASE)+(r)) -#define MPMC_WRITE(r,v) *(u32 *)(KSEG1ADDR(ADM5120_SWITCH_BASE)+(r))=(v) - -extern void prom_printf(char *, ...); -#if 1 -# define mem_dbg(f, a...) prom_printf("mem_detect: " f, ## a) -#else -# define mem_dbg(f, a...) -#endif - -#define MEM_WR_DELAY 10000 /* 0.01 usec */ - -static int mem_check_pattern(u8 *addr, unsigned long offs) -{ - volatile u32 *p1 = (volatile u32 *)addr; - volatile u32 *p2 = (volatile u32 *)(addr+offs); - u32 t,u,v; - - /* save original value */ - t = *p1; - u = *p2; - - if (t != u) - return 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); -} - -static void __init adm5120_detect_memsize(void) +void __init adm5120_soc_init(void) { - u32 memctrl; - u32 size, maxsize; - u8 *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); - - size = adm5120_board_memsize(); - if (size > 0 && size != adm5120_memsize) { - mem_dbg("wrong memory size detected, board settings will be used\n"); - adm5120_memsize = size; - } -} + u32 code; + u32 clks; -void __init adm5120_info_show(void) -{ - /* FIXME: move this somewhere else */ - printk(KERN_INFO "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 "Boot loader is: %s\n", boot_loader_names[adm5120_boot_loader]); - printk(KERN_INFO "Booted from : %s flash\n", adm5120_nand_boot ? "NAND":"NOR"); - printk(KERN_INFO "Board is : %s\n", adm5120_board_name()); - printk(KERN_INFO "Memory size : %ldMB\n", adm5120_memsize >> 20); -} + code = SWITCH_READ(SWITCH_REG_CODE); -void __init adm5120_info_init(void) -{ - adm5120_detect_cpuinfo(); - adm5120_detect_board(); - adm5120_detect_memsize(); + adm5120_product_code = CODE_GET_PC(code); + adm5120_revision = CODE_GET_REV(code); + adm5120_package = (CODE_GET_PK(code) == CODE_PK_BGA) ? + ADM5120_PACKAGE_BGA : ADM5120_PACKAGE_PQFP; + adm5120_nand_boot = CODE_GET_NAB(code); - adm5120_info_show(); + clks = CODE_GET_CLKS(code); + adm5120_speed = ADM5120_SPEED_175; + if (clks & 1) + adm5120_speed += 25000000; + if (clks & 2) + adm5120_speed += 50000000; } diff --git a/target/linux/adm5120-2.6/files/arch/mips/adm5120/board.c b/target/linux/adm5120-2.6/files/arch/mips/adm5120/board.c new file mode 100644 index 0000000000..a4643837c3 --- /dev/null +++ b/target/linux/adm5120-2.6/files/arch/mips/adm5120/board.c @@ -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); diff --git a/target/linux/adm5120-2.6/files/arch/mips/adm5120/boards/Makefile b/target/linux/adm5120-2.6/files/arch/mips/adm5120/boards/Makefile new file mode 100644 index 0000000000..a05c891565 --- /dev/null +++ b/target/linux/adm5120-2.6/files/arch/mips/adm5120/boards/Makefile @@ -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 diff --git a/target/linux/adm5120-2.6/files/arch/mips/adm5120/boards/cellvision.c b/target/linux/adm5120-2.6/files/arch/mips/adm5120/boards/cellvision.c new file mode 100644 index 0000000000..fb844b7bbd --- /dev/null +++ b/target/linux/adm5120-2.6/files/arch/mips/adm5120/boards/cellvision.c @@ -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); diff --git a/target/linux/adm5120-2.6/files/arch/mips/adm5120/boards/compex.c b/target/linux/adm5120-2.6/files/arch/mips/adm5120/boards/compex.c new file mode 100644 index 0000000000..bbc5106e20 --- /dev/null +++ b/target/linux/adm5120-2.6/files/arch/mips/adm5120/boards/compex.c @@ -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); diff --git a/target/linux/adm5120-2.6/files/arch/mips/adm5120/boards/edimax.c b/target/linux/adm5120-2.6/files/arch/mips/adm5120/boards/edimax.c new file mode 100644 index 0000000000..f39d5c763d --- /dev/null +++ b/target/linux/adm5120-2.6/files/arch/mips/adm5120/boards/edimax.c @@ -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); diff --git a/target/linux/adm5120-2.6/files/arch/mips/adm5120/boards/generic.c b/target/linux/adm5120-2.6/files/arch/mips/adm5120/boards/generic.c new file mode 100644 index 0000000000..8d795a8816 --- /dev/null +++ b/target/linux/adm5120-2.6/files/arch/mips/adm5120/boards/generic.c @@ -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); diff --git a/target/linux/adm5120-2.6/files/arch/mips/adm5120/boards/infineon.c b/target/linux/adm5120-2.6/files/arch/mips/adm5120/boards/infineon.c new file mode 100644 index 0000000000..30501d95b1 --- /dev/null +++ b/target/linux/adm5120-2.6/files/arch/mips/adm5120/boards/infineon.c @@ -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); diff --git a/target/linux/adm5120-2.6/files/arch/mips/adm5120/boards/mikrotik.c b/target/linux/adm5120-2.6/files/arch/mips/adm5120/boards/mikrotik.c new file mode 100644 index 0000000000..7ced1f196c --- /dev/null +++ b/target/linux/adm5120-2.6/files/arch/mips/adm5120/boards/mikrotik.c @@ -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); diff --git a/target/linux/adm5120-2.6/files/arch/mips/adm5120/boards/zyxel.c b/target/linux/adm5120-2.6/files/arch/mips/adm5120/boards/zyxel.c new file mode 100644 index 0000000000..8b57876607 --- /dev/null +++ b/target/linux/adm5120-2.6/files/arch/mips/adm5120/boards/zyxel.c @@ -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); diff --git a/target/linux/adm5120-2.6/files/arch/mips/adm5120/gpio.c b/target/linux/adm5120-2.6/files/arch/mips/adm5120/gpio.c index 5ae5d74940..1fac84bb53 100644 --- a/target/linux/adm5120-2.6/files/arch/mips/adm5120/gpio.c +++ b/target/linux/adm5120-2.6/files/arch/mips/adm5120/gpio.c @@ -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); diff --git a/target/linux/adm5120-2.6/files/arch/mips/adm5120/memory.c b/target/linux/adm5120-2.6/files/arch/mips/adm5120/memory.c index 190a0788fc..b602572459 100644 --- a/target/linux/adm5120-2.6/files/arch/mips/adm5120/memory.c +++ b/target/linux/adm5120-2.6/files/arch/mips/adm5120/memory.c @@ -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 SWITCH_READ(r) *(u32 *)(KSEG1ADDR(ADM5120_SWITCH_BASE)+(r)) +#define SWITCH_WRITE(r,v) *(u32 *)(KSEG1ADDR(ADM5120_SWITCH_BASE)+(r))=(v) + +#define MPMC_READ(r) *(u32 *)(KSEG1ADDR(ADM5120_SWITCH_BASE)+(r)) +#define MPMC_WRITE(r,v) *(u32 *)(KSEG1ADDR(ADM5120_SWITCH_BASE)+(r))=(v) + +#if 1 +# define mem_dbg(f, a...) printk("mem_detect: " f, ## a) +#else +# define mem_dbg(f, a...) +#endif -#define PFN_ALIGN(x) (((unsigned long)(x) + (PAGE_SIZE - 1)) & PAGE_MASK) +#define MEM_WR_DELAY 10000 /* 0.01 usec */ -struct prom_pmemblock mdesc[PROM_MAX_PMEMBLOCKS]; +unsigned long adm5120_memsize; -struct prom_pmemblock * __init prom_getmdesc(void) +static int __init mem_check_pattern(u8 *addr, unsigned long offs) { - unsigned int memsize; - char cmdline[CL_SIZE], *ptr; - - 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="); - - 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; - - return &mdesc[0]; + volatile u32 *p1 = (volatile u32 *)addr; + volatile u32 *p2 = (volatile u32 *)(addr+offs); + u32 t,u,v; + + /* save original value */ + t = *p1; + u = *p2; + + if (t != u) + return 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; - - 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++; + u32 memctrl; + u32 size, maxsize; + u8 *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); } diff --git a/target/linux/adm5120-2.6/files/arch/mips/adm5120/platform.c b/target/linux/adm5120-2.6/files/arch/mips/adm5120/platform.c new file mode 100644 index 0000000000..8fd89ae7c7 --- /dev/null +++ b/target/linux/adm5120-2.6/files/arch/mips/adm5120/platform.c @@ -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, +}; diff --git a/target/linux/adm5120-2.6/files/arch/mips/adm5120/prom.c b/target/linux/adm5120-2.6/files/arch/mips/adm5120/prom.c index c2e1dcbae1..97ecc99bc9 100644 --- a/target/linux/adm5120-2.6/files/arch/mips/adm5120/prom.c +++ b/target/linux/adm5120-2.6/files/arch/mips/adm5120/prom.c @@ -1,96 +1,200 @@ -/***************************************************************************** - * 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$ + * + * ADM5120 specific prom routines * - * 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. + * Copyright (C) 2007 OpenWrt.org + * Copyright (C) 2007 Gabor Juhos <juhosg@freemail.hu> * - * 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 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. * - * 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 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 +static unsigned long __init find_machtype_byname(char *name) +{ + unsigned long ret; + int i; + + ret = MACH_ADM5120_GENERIC; + if (name == NULL) + goto out; -int putPromChar(char c) + 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; +} + +static unsigned long __init detect_machtype_routerboot(void) { - WRITECSR(UART_DR_REG, c); - while ( (READCSR(UART_FR_REG) & UART_TX_FIFO_FULL) ); - return 0; + char *name; + + name = routerboot_get_boardname(); + return find_machtype_byname(name); } -/* - * Ugly prom_printf used for debugging - */ +static unsigned long __init detect_machtype_generic(void) +{ + char *name; + + name = generic_prom_getenv("board"); + return find_machtype_byname(name); +} -void prom_printf(char *fmt, ...) +unsigned long __init detect_machtype_cfe(void) { - va_list args; - int l; - char *p, *buf_end; - char buf[1024]; - - 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); - } + char *name; + + name = cfe_getenv("BOARD_NAME"); + return find_machtype_byname(name); } -char *prom_getenv(char *envname) +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) { - char **env; - char *ret; + 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; + } + } + + return ret; +} - ret = NULL; +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 (prom_envp== NULL) - return NULL; + 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), +}; - for (env = prom_envp; *env != NULL; env++) { - if (strcmp(envname, *env++) == 0) { - ret = *env; +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; } } @@ -98,29 +202,68 @@ char *prom_getenv(char *envname) return ret; } -extern char _image_cmdline; -/* - * initialize the prom module. - */ -void __init prom_init(void) +static void __init prom_detect_machtype(void) { - char *cmd; + if (bootbase_present()) { + adm5120_prom_type = ADM5120_PROM_BOOTBASE; + mips_machtype = detect_machtype_bootbase(); + return; + } - if ((fw_arg2 & 3) == 0) { - prom_envp = (char **)fw_arg2; + if (cfe_present()) { + adm5120_prom_type = ADM5120_PROM_CFE; + mips_machtype = detect_machtype_cfe(); + return; } - adm5120_info_init(); + if (myloader_present()) { + adm5120_prom_type = ADM5120_PROM_MYLOADER; + mips_machtype = detect_machtype_myloader(); + return; + } - /* you should these macros defined in include/asm/bootinfo.h */ - mips_machgroup = MACH_GROUP_ADM5120; - mips_machtype = adm5120_board.mach_type; + 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 */ } diff --git a/target/linux/adm5120-2.6/files/arch/mips/adm5120/prom/Makefile b/target/linux/adm5120-2.6/files/arch/mips/adm5120/prom/Makefile new file mode 100644 index 0000000000..d844b600f3 --- /dev/null +++ b/target/linux/adm5120-2.6/files/arch/mips/adm5120/prom/Makefile @@ -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 diff --git a/target/linux/adm5120-2.6/files/arch/mips/adm5120/prom/bootbase.c b/target/linux/adm5120-2.6/files/arch/mips/adm5120/prom/bootbase.c new file mode 100644 index 0000000000..c54c4ce671 --- /dev/null +++ b/target/linux/adm5120-2.6/files/arch/mips/adm5120/prom/bootbase.c @@ -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; +} + diff --git a/target/linux/adm5120-2.6/files/arch/mips/adm5120/prom/cfe.c b/target/linux/adm5120-2.6/files/arch/mips/adm5120/prom/cfe.c new file mode 100644 index 0000000000..cce69449cb --- /dev/null +++ b/target/linux/adm5120-2.6/files/arch/mips/adm5120/prom/cfe.c @@ -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; +} diff --git a/target/linux/adm5120-2.6/files/arch/mips/adm5120/prom/generic.c b/target/linux/adm5120-2.6/files/arch/mips/adm5120/prom/generic.c new file mode 100644 index 0000000000..412e9a7bdc --- /dev/null +++ b/target/linux/adm5120-2.6/files/arch/mips/adm5120/prom/generic.c @@ -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; +} diff --git a/target/linux/adm5120-2.6/files/arch/mips/adm5120/prom/myloader.c b/target/linux/adm5120-2.6/files/arch/mips/adm5120/prom/myloader.c new file mode 100644 index 0000000000..972de4e53d --- /dev/null +++ b/target/linux/adm5120-2.6/files/arch/mips/adm5120/prom/myloader.c @@ -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; +} diff --git a/target/linux/adm5120-2.6/files/arch/mips/adm5120/prom/prom_read.h b/target/linux/adm5120-2.6/files/arch/mips/adm5120/prom/prom_read.h new file mode 100644 index 0000000000..8cef4a485a --- /dev/null +++ b/target/linux/adm5120-2.6/files/arch/mips/adm5120/prom/prom_read.h @@ -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_ */ + + diff --git a/target/linux/adm5120-2.6/files/arch/mips/adm5120/prom/routerboot.c b/target/linux/adm5120-2.6/files/arch/mips/adm5120/prom/routerboot.c new file mode 100644 index 0000000000..ad28353560 --- /dev/null +++ b/target/linux/adm5120-2.6/files/arch/mips/adm5120/prom/routerboot.c @@ -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; +} diff --git a/target/linux/adm5120-2.6/files/arch/mips/adm5120/reset.c b/target/linux/adm5120-2.6/files/arch/mips/adm5120/reset.c new file mode 100644 index 0000000000..25184846a7 --- /dev/null +++ b/target/linux/adm5120-2.6/files/arch/mips/adm5120/reset.c @@ -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(); +} diff --git a/target/linux/adm5120-2.6/files/arch/mips/adm5120/setup.c b/target/linux/adm5120-2.6/files/arch/mips/adm5120/setup.c index aa30dc5c83..83cf74cb77 100644 --- a/target/linux/adm5120-2.6/files/arch/mips/adm5120/setup.c +++ b/target/linux/adm5120-2.6/files/arch/mips/adm5120/setup.c @@ -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> - -extern void adm5120_time_init(void) __init; - -#define ADM5120_SOFTRESET 0x12000004 - -void adm5120_restart(char *command) -{ - *(u32*)KSEG1ADDR(ADM5120_SOFTRESET)=1; -} - - -void adm5120_halt(void) -{ - printk(KERN_NOTICE "\n** You can safely turn off the power\n"); - while (1); -} - +#include <asm/mach-adm5120/adm5120_switch.h> +#include <asm/mach-adm5120/adm5120_board.h> + +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" +}; -void adm5120_power_off(void) +static void __init adm5120_report(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); diff --git a/target/linux/adm5120-2.6/files/arch/mips/adm5120/trxsplit.c b/target/linux/adm5120-2.6/files/arch/mips/adm5120/trxsplit.c new file mode 100644 index 0000000000..0377892d3f --- /dev/null +++ b/target/linux/adm5120-2.6/files/arch/mips/adm5120/trxsplit.c @@ -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); diff --git a/target/linux/adm5120-2.6/files/arch/mips/pci/fixup-adm5120.c b/target/linux/adm5120-2.6/files/arch/mips/pci/fixup-adm5120.c index e67064d645..cf450f0668 100644 --- a/target/linux/adm5120-2.6/files/arch/mips/pci/fixup-adm5120.c +++ b/target/linux/adm5120-2.6/files/arch/mips/pci/fixup-adm5120.c @@ -25,7 +25,6 @@ * */ -#include <linux/autoconf.h> #include <linux/types.h> #include <linux/kernel.h> #include <linux/init.h> @@ -125,8 +124,7 @@ int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin) case MACH_ADM5120_WPP54AG: case MACH_ADM5120_WPP54G: default: - printk(KERN_ALERT "PCI: irq map is unknown for %s, using " - "defaults.\n", adm5120_board_name()); + printk(KERN_ALERT "PCI: irq map is unknown, using defaults.\n"); break; } |