diff options
Diffstat (limited to 'target/linux')
57 files changed, 3529 insertions, 1494 deletions
diff --git a/target/linux/adm5120-2.6/Makefile b/target/linux/adm5120-2.6/Makefile index 4f08a3b2c..fb46f2831 100644 --- a/target/linux/adm5120-2.6/Makefile +++ b/target/linux/adm5120-2.6/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk ARCH:=mipsel BOARD:=adm5120 BOARDNAME:=ADM5120 (Little Endian) -FEATURES:=squashfs jffs2 pci usb +FEATURES:=squashfs jffs2 pci usb broken LINUX_VERSION:=2.6.22.1 diff --git a/target/linux/adm5120-2.6/config/default b/target/linux/adm5120-2.6/config/default index f22330490..70d218d23 100644 --- a/target/linux/adm5120-2.6/config/default +++ b/target/linux/adm5120-2.6/config/default @@ -1,7 +1,7 @@ CONFIG_32BIT=y # CONFIG_64BIT is not set # CONFIG_64BIT_PHYS_ADDR is not set -CONFIG_ADM5120_HARDWARE_SWAB=y +# CONFIG_ADM5120_HARDWARE_SWAB is not set CONFIG_ADM5120_NR_UARTS=2 # CONFIG_ARCH_HAS_ILOG2_U32 is not set # CONFIG_ARCH_HAS_ILOG2_U64 is not set @@ -52,6 +52,7 @@ CONFIG_DEVPORT=y # CONFIG_DM9000 is not set CONFIG_DMA_NEED_PCI_MAP_STATE=y CONFIG_DMA_NONCOHERENT=y +CONFIG_EARLY_PRINTK=y CONFIG_ELF_CORE=y # CONFIG_EXT3_FS_POSIX_ACL is not set # CONFIG_EXT3_FS_SECURITY is not set @@ -154,7 +155,7 @@ CONFIG_MTD_COMPLEX_MAPPINGS=y # CONFIG_MTD_DOC2001 is not set # CONFIG_MTD_DOC2001PLUS is not set CONFIG_MTD_GEN_PROBE=y -# CONFIG_MTD_JEDECPROBE is not set +CONFIG_MTD_JEDECPROBE=y CONFIG_MTD_MAP_BANK_WIDTH_1=y # CONFIG_MTD_MAP_BANK_WIDTH_16 is not set CONFIG_MTD_MAP_BANK_WIDTH_2=y @@ -184,6 +185,7 @@ CONFIG_MTD_PARTITIONS=y # CONFIG_MTD_REDBOOT_PARTS is not set # CONFIG_MTD_ROM is not set # CONFIG_MTD_SLRAM is not set +# CONFIG_MTD_SPLIT_ROOTFS is not set # CONFIG_NETDEV_1000 is not set CONFIG_NET_KEY=y # CONFIG_NET_PCI is not set @@ -230,6 +232,7 @@ CONFIG_SOFT_WATCHDOG=m # CONFIG_SPARSEMEM_STATIC is not set CONFIG_SYSVIPC_SYSCTL=y CONFIG_SYS_HAS_CPU_MIPS32_R1=y +CONFIG_SYS_HAS_EARLY_PRINTK=y CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y CONFIG_SYS_SUPPORTS_ARBIT_HZ=y CONFIG_SYS_SUPPORTS_BIG_ENDIAN=y @@ -243,7 +246,7 @@ CONFIG_TRAD_SIGNALS=y CONFIG_USB=y # CONFIG_USBPCWATCHDOG is not set # CONFIG_USB_ACM is not set -CONFIG_USB_ADM5120_HCD=y +CONFIG_USB_ADM5120_HCD=m # CONFIG_USB_ALI_M5632 is not set # CONFIG_USB_AN2720 is not set # CONFIG_USB_CATC is not set 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 deb1adf7e..fd588a4e3 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 c34dbd009..17d82faaf 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 000000000..a4643837c --- /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 000000000..a05c89156 --- /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 000000000..fb844b7bb --- /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 000000000..bbc5106e2 --- /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 000000000..f39d5c763 --- /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 000000000..8d795a881 --- /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 000000000..30501d95b --- /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 000000000..7ced1f196 --- /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 000000000..8b5787660 --- /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 5ae5d7494..1fac84bb5 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 190a0788f..b60257245 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 000000000..8fd89ae7c --- /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 c2e1dcbae..97ecc99bc 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 000000000..d844b600f --- /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 000000000..c54c4ce67 --- /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 000000000..cce69449c --- /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 000000000..412e9a7bd --- /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 000000000..972de4e53 --- /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 000000000..8cef4a485 --- /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 000000000..ad2835356 --- /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 000000000..25184846a --- /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 aa30dc5c8..83cf74cb7 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 000000000..0377892d3 --- /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 e67064d64..cf450f066 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; } diff --git a/target/linux/adm5120-2.6/files/drivers/leds/leds-adm5120.c b/target/linux/adm5120-2.6/files/drivers/leds/leds-adm5120.c index ba0269d12..e8609d374 100644 --- a/target/linux/adm5120-2.6/files/drivers/leds/leds-adm5120.c +++ b/target/linux/adm5120-2.6/files/drivers/leds/leds-adm5120.c @@ -163,7 +163,7 @@ LED_ARRAY(wp54g) { LED_INV(ADM5120_GPIO_P1L0, "lan2", NULL ), }; -LED_ARRAY(unknown) { +LED_ARRAY(generic) { #if defined(CONFIG_LEDS_ADM5120_DIAG) LED_STD(ADM5120_GPIO_PIN0, "gpio0", NULL ), LED_STD(ADM5120_GPIO_PIN1, "gpio1", NULL ), @@ -198,7 +198,7 @@ LED_ARRAY(unknown) { } static struct mach_data machines[] __initdata = { - MACH_DATA(MACH_ADM5120_UNKNOWN, unknown), + MACH_DATA(MACH_ADM5120_GENERIC, generic), MACH_DATA(MACH_ADM5120_P334WT, p334wt), MACH_DATA(MACH_ADM5120_WP54AG, wp54g), MACH_DATA(MACH_ADM5120_WP54G, wp54g), diff --git a/target/linux/adm5120-2.6/files/drivers/mtd/maps/adm5120-flash.c b/target/linux/adm5120-2.6/files/drivers/mtd/maps/adm5120-flash.c new file mode 100644 index 000000000..a60e6e54b --- /dev/null +++ b/target/linux/adm5120-2.6/files/drivers/mtd/maps/adm5120-flash.c @@ -0,0 +1,572 @@ +/* + * $Id$ + * + * Platform driver for NOR flash devices on ADM5120 based boards + * + * Copyright (C) 2007 OpenWrt.org + * Copyright (C) 2007 Gabor Juhos <juhosg@freemail.hu> + * + * This file was derived from: drivers/mtd/map/physmap.c + * Copyright (C) 2003 MontaVista Software Inc. + * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net + * + * 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/init.h> +#include <linux/slab.h> +#include <linux/device.h> + +#include <linux/platform_device.h> +#include <linux/mtd/mtd.h> +#include <linux/mtd/map.h> +#include <linux/mtd/partitions.h> + +#include <asm/io.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_platform.h> + +#define DRV_NAME "adm5120-flash" +#define DRV_DESC "ADM5120 flash MAP driver" +#define MAX_PARSED_PARTS 8 + +#define MAP_DBG(m, f, a...) printk(KERN_DEBUG "%s: " f, (m->name) , ## a) +#define MAP_ERR(m, f, a...) printk(KERN_ERR "%s: " f, (m->name) , ## a) +#define MAP_INFO(m, f, a...) printk(KERN_INFO "%s: " f, (m->name) , ## a) + +struct adm5120_map_info { + struct map_info map; + void (*switch_bank)(unsigned); + unsigned long chip_size; +}; + +struct adm5120_flash_info { + struct mtd_info *mtd; + struct resource *res; + struct platform_device *dev; + struct adm5120_map_info amap; +#ifdef CONFIG_MTD_PARTITIONS + int nr_parts; + struct mtd_partition *parts[MAX_PARSED_PARTS]; +#endif +}; + +struct flash_desc { + u32 phys; + u32 srs_shift; + u32 mpmc_reg; +}; + +/* + * Globals + */ +static DEFINE_SPINLOCK(adm5120_flash_spin); +#define FLASH_LOCK() spin_lock(&adm5120_flash_spin) +#define FLASH_UNLOCK() spin_unlock(&adm5120_flash_spin) + +static u32 flash_bankwidths[4] = { 1, 2, 4, 0 }; + +static u32 flash_sizes[8] = { + 0, 512*1024, 1024*1024, 2*1024*1024, + 4*1024*1024, 0, 0, 0 +}; + +static struct flash_desc flash_descs[2] = { + { + .phys = ADM5120_SRAM0_BASE, + .mpmc_reg = MPMC_REG_SC1, + .srs_shift = MEMCTRL_SRS0_SHIFT, + }, { + .phys = ADM5120_SRAM1_BASE, + .mpmc_reg = MPMC_REG_SC0, + .srs_shift = MEMCTRL_SRS1_SHIFT, + } +}; + +static const char *probe_types[] = { + "cfi_probe", + "jedec_probe", + "map_rom", + NULL +}; + +#ifdef CONFIG_MTD_PARTITIONS +static const char *parse_types[] = { + "cmdlinepart", +#ifdef CONFIG_MTD_REDBOOT_PARTS + "RedBoot", +#endif +#ifdef CONFIG_MTD_MYLOADER_PARTS + "MyLoader", +#endif +}; +#endif + +#define BANK_SIZE (2<<20) +#define BANK_SIZE_MAX (4<<20) +#define BANK_OFFS_MASK (BANK_SIZE-1) +#define BANK_START_MASK (~BANK_OFFS_MASK) + +static inline struct adm5120_map_info *map_to_amap(struct map_info *map) +{ + return (struct adm5120_map_info *)map; +} + +static void adm5120_flash_switchbank(struct map_info *map, + unsigned long ofs) +{ + struct adm5120_map_info *amap = map_to_amap(map); + unsigned bank; + + if (amap->switch_bank == NULL) + return; + + bank = (ofs & BANK_START_MASK) >> 21; + if (bank > 1) + BUG(); + + MAP_DBG(map, "ofs=%lu, switching to bank %u\n", ofs, bank); + amap->switch_bank(bank); +} + +static map_word adm5120_flash_read(struct map_info *map, unsigned long ofs) +{ + struct adm5120_map_info *amap = map_to_amap(map); + map_word ret; + + MAP_DBG(map, "reading from ofs %lu\n", ofs); + + if (ofs >= amap->chip_size) + return map_word_ff(map); + + FLASH_LOCK(); + adm5120_flash_switchbank(map, ofs); + ret = inline_map_read(map, (ofs & BANK_OFFS_MASK)); + FLASH_UNLOCK(); + + return ret; +} + +static void adm5120_flash_write(struct map_info *map, const map_word datum, + unsigned long ofs) +{ + struct adm5120_map_info *amap = map_to_amap(map); + + MAP_DBG(map,"writing to ofs %lu\n", ofs); + + if (ofs > amap->chip_size) + return; + + FLASH_LOCK(); + adm5120_flash_switchbank(map, ofs); + inline_map_write(map, datum, (ofs & BANK_OFFS_MASK)); + FLASH_UNLOCK(); +} + +static void adm5120_flash_copy_from(struct map_info *map, void *to, + unsigned long from, ssize_t len) +{ + struct adm5120_map_info *amap = map_to_amap(map); + char *p; + ssize_t t; + + MAP_DBG(map, "copying %lu byte(s) from %lu to %lX\n", + (unsigned long)len, from, (unsigned long)to); + + if (from > amap->chip_size) + return; + + p = (char *)to; + while (len > 0) { + if (len > BANK_SIZE - (from & BANK_OFFS_MASK)) + t = BANK_SIZE - (from & BANK_OFFS_MASK); + else + t = len; + + MAP_DBG(map, "copying %lu byte(s) from %lu to %lX\n", + (unsigned long)t, (from & BANK_OFFS_MASK), + (unsigned long)p); + + FLASH_LOCK(); + adm5120_flash_switchbank(map, from); + inline_map_copy_from(map, to, (from & BANK_OFFS_MASK), t); + FLASH_UNLOCK(); + p += t; + from += t; + len -= t; + } +} + +static int adm5120_flash_initres(struct adm5120_flash_info *info) +{ + struct map_info *map = &info->amap.map; + int err = 0; + + info->res = request_mem_region(map->phys, map->size, map->name); + if (info->res == NULL) { + MAP_ERR(map, "could not reserve memory region\n"); + err = -ENOMEM; + goto out; + } + + map->virt = ioremap_nocache(map->phys, map->size); + if (map->virt == NULL) { + MAP_ERR(map, "failed to ioremap flash region\n"); + err = -ENOMEM; + goto out; + } + +out: + return err; +} + +#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_MPMC_BASE)+(r)) +#define MPMC_WRITE(r,v) *(u32 *)(KSEG1ADDR(ADM5120_MPMC_BASE)+(r))=(v) + +static int adm5120_flash_initinfo(struct adm5120_flash_info *info, + struct platform_device *dev) +{ + struct map_info *map = &info->amap.map; + struct adm5120_flash_platform_data *pdata = dev->dev.platform_data; + struct flash_desc *fdesc; + u32 t; + + map->name = dev->dev.bus_id; + + if (dev->id > 1) { + MAP_ERR(map, "invalid flash id\n"); + goto err_out; + } + + fdesc = &flash_descs[dev->id]; + + /* get memory window size */ + t = SWITCH_READ(SWITCH_REG_MEMCTRL) >> fdesc->srs_shift; + t &= MEMCTRL_SRS_MASK; + info->amap.chip_size = flash_sizes[t]; + if (info->amap.chip_size == 0) { + MAP_ERR(map, "invalid flash size detected\n"); + goto err_out; + } + + /* get flash bus width */ + t = MPMC_READ(fdesc->mpmc_reg) & SC_MW_MASK; + map->bankwidth = flash_bankwidths[t]; + if (map->bankwidth == 0) { + MAP_ERR(map, "invalid bus width detected\n"); + goto err_out; + } + + map->phys = fdesc->phys; + map->size = BANK_SIZE_MAX; + + simple_map_init(map); + map->read = adm5120_flash_read; + map->write = adm5120_flash_write; + map->copy_from = adm5120_flash_copy_from; + + if (pdata) { + map->set_vpp = pdata->set_vpp; + info->amap.switch_bank = pdata->switch_bank; + } + + info->dev = dev; + + MAP_INFO(map, "probing at 0x%lX, size:%ldKiB, width:%d bits\n", + (unsigned long)map->phys, + (unsigned long)info->amap.chip_size >> 10, + map->bankwidth*8); + + return 0; + +err_out: + return -ENODEV; +} + +static void adm5120_flash_initbanks(struct adm5120_flash_info *info) +{ + struct map_info *map = &info->amap.map; + + if (info->mtd->size <= BANK_SIZE) + /* no bank switching needed */ + return; + + if (info->amap.switch_bank) { + info->amap.chip_size = info->mtd->size; + return; + } + + MAP_ERR(map, "reduce visibility from %ldKiB to %ldKiB\n", + (unsigned long)map->size >> 10, + (unsigned long)info->mtd->size >> 10); + + info->mtd->size = info->amap.chip_size; +} + +#ifdef CONFIG_MTD_PARTITIONS +static int adm5120_flash_initparts(struct adm5120_flash_info *info) +{ + struct adm5120_flash_platform_data *pdata = info->dev->dev.platform_data; + struct map_info *map = &info->amap.map; + int num_parsers; + const char *parser[2]; + int err = 0; + int nr_parts; + int i; + + info->nr_parts = 0; + + if (pdata == NULL) + goto out; + + if (pdata->nr_parts) { + MAP_INFO(map, "adding static partitions\n"); + err = add_mtd_partitions(info->mtd, pdata->parts, + pdata->nr_parts); + if (err == 0) { + info->nr_parts += pdata->nr_parts; + goto out; + } + } + + num_parsers = ARRAY_SIZE(parse_types); + if (num_parsers > MAX_PARSED_PARTS) + num_parsers = MAX_PARSED_PARTS; + + parser[1] = NULL; + for (i=0; i<num_parsers; i++) { + parser[0] = parse_types[i]; + + MAP_INFO(map, "parsing \"%s\" partitions\n", + parser[0]); + nr_parts = parse_mtd_partitions(info->mtd, parser, + &info->parts[i], 0); + + if (nr_parts <= 0) + continue; + + MAP_INFO(map, "adding \"%s\" partitions\n", + parser[0]); + + err = add_mtd_partitions(info->mtd, info->parts[i], nr_parts); + if (err) + break; + + info->nr_parts += nr_parts; + } +out: + return err; +} +#else +static int adm5120_flash_initparts(struct adm5120_flash_info *info) +{ + return 0; +} +#endif /* CONFIG_MTD_PARTITIONS */ + +#ifdef CONFIG_MTD_PARTITIONS +static void adm5120_flash_remove_mtd(struct adm5120_flash_info *info) +{ + int i; + + if (info->nr_parts) { + del_mtd_partitions(info->mtd); + for (i=0; i<MAX_PARSED_PARTS; i++) + if (info->parts[i] != NULL) + kfree(info->parts[i]); + } else { + del_mtd_device(info->mtd); + } +} +#else +static void adm5120_flash_remove_mtd(struct adm5120_flash_info *info) +{ + del_mtd_device(info->mtd); +} +#endif + +static int adm5120_flash_remove(struct platform_device *dev) +{ + struct adm5120_flash_info *info; + + info = platform_get_drvdata(dev); + if (info == NULL) + return 0; + + platform_set_drvdata(dev, NULL); + + if (info->mtd != NULL) { + adm5120_flash_remove_mtd(info); + map_destroy(info->mtd); + } + + if (info->amap.map.virt != NULL) + iounmap(info->amap.map.virt); + + if (info->res != NULL) { + release_resource(info->res); + kfree(info->res); + } + + return 0; +} + +static int adm5120_flash_probe(struct platform_device *dev) +{ + struct adm5120_flash_info *info; + struct map_info *map; + const char **probe_type; + int err; + + info = kzalloc(sizeof(*info), GFP_KERNEL); + if (info == NULL) { + err = -ENOMEM; + goto err_out; + } + + platform_set_drvdata(dev, info); + + err = adm5120_flash_initinfo(info, dev); + if (err) + goto err_out; + + err = adm5120_flash_initres(info); + if (err) + goto err_out; + + map = &info->amap.map; + for (probe_type = probe_types; info->mtd == NULL && *probe_type != NULL; + probe_type++) + info->mtd = do_map_probe(*probe_type, map); + + if (info->mtd == NULL) { + MAP_ERR(map, "map_probe failed\n"); + err = -ENXIO; + goto err_out; + } + + adm5120_flash_initbanks(info); + + if (info->mtd->size < info->amap.chip_size) { + /* readjust resources */ + iounmap(map->virt); + release_resource(info->res); + kfree(info->res); + + info->amap.chip_size = info->mtd->size; + map->size = info->mtd->size; + MAP_INFO(map, "reducing map size to %ldKiB\n", + (unsigned long)map->size >> 10); + err = adm5120_flash_initres(info); + if (err) + goto err_out; + } + + MAP_INFO(map, "found at 0x%lX, size:%ldKiB, width:%d bits\n", + (unsigned long)map->phys, (unsigned long)map->size >> 10, + map->bankwidth*8); + + info->mtd->owner = THIS_MODULE; + + err = adm5120_flash_initparts(info); + if (err) + goto err_out; + + if (info->nr_parts == 0) { + MAP_INFO(map, "no partitions available, registering whole flash\n"); + add_mtd_device(info->mtd); + } + + return 0; + +err_out: + adm5120_flash_remove(dev); + return err; +} + +#ifdef CONFIG_PM +static int adm5120_flash_suspend(struct platform_device *dev, pm_message_t state) +{ + struct adm5120_flash_info *info = platform_get_drvdata(dev); + int ret = 0; + + if (info) + ret = info->mtd->suspend(info->mtd); + + return ret; +} + +static int adm5120_flash_resume(struct platform_device *dev) +{ + struct adm5120_flash_info *info = platform_get_drvdata(dev); + + if (info) + info->mtd->resume(info->mtd); + + return 0; +} + +static void adm5120_flash_shutdown(struct platform_device *dev) +{ + struct adm5120_flash_info *info = platform_get_drvdata(dev); + + if (info && info->mtd->suspend(info->mtd) == 0) + info->mtd->resume(info->mtd); +} +#endif + +static struct platform_driver adm5120_flash_driver = { + .probe = adm5120_flash_probe, + .remove = adm5120_flash_remove, +#ifdef CONFIG_PM + .suspend = adm5120_flash_suspend, + .resume = adm5120_flash_resume, + .shutdown = adm5120_flash_shutdown, +#endif + .driver = { + .name = DRV_NAME, + }, +}; + +static int __init adm5120_flash_init(void) +{ + int err; + + err = platform_driver_register(&adm5120_flash_driver); + + return err; +} + +static void __exit adm5120_flash_exit(void) +{ + platform_driver_unregister(&adm5120_flash_driver); +} + +module_init(adm5120_flash_init); +module_exit(adm5120_flash_exit); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Gabor Juhos <juhosg@freemail.hu>"); +MODULE_DESCRIPTION(DRV_DESC); diff --git a/target/linux/adm5120-2.6/files/drivers/mtd/myloader.c b/target/linux/adm5120-2.6/files/drivers/mtd/myloader.c index ee916d780..222245cc9 100644 --- a/target/linux/adm5120-2.6/files/drivers/mtd/myloader.c +++ b/target/linux/adm5120-2.6/files/drivers/mtd/myloader.c @@ -1,4 +1,6 @@ /* + * $Id$ + * * Parse MyLoader-style flash partition tables and produce a Linux partition * array to match. * @@ -33,7 +35,8 @@ #include <linux/mtd/partitions.h> #include <linux/byteorder/generic.h> -#include <asm/mach-adm5120/myloader.h> + +#include <prom/myloader.h> #define NAME_LEN_MAX 20 #define NAME_MYLOADER "MyLoader" @@ -68,12 +71,10 @@ int parse_myloader_partitions(struct mtd_info *master, /* Partition Table is always located on the second erase block */ offset = blocklen; - printk(KERN_NOTICE "Searching for MyLoader partition table " - "in %s at offset 0x%lx\n", master->name, offset); - - ret = master->read(master, offset, sizeof(*tab), &retlen, - (void *)tab); + printk(KERN_NOTICE "%s: searching for MyLoader partition table at " + "offset 0x%lx\n", master->name, offset); + ret = master->read(master, offset, sizeof(*tab), &retlen, (void *)tab); if (ret) goto out; @@ -84,8 +85,8 @@ int parse_myloader_partitions(struct mtd_info *master, /* Check for Partition Table magic number */ if (tab->magic != le32_to_cpu(MYLO_MAGIC_PARTITIONS)) { - printk(KERN_NOTICE "No MyLoader partition table detected " - "in %s\n", master->name); + printk(KERN_NOTICE "%s: no MyLoader partition table found\n", + master->name); ret = 0; goto out_free_buf; } @@ -103,7 +104,6 @@ int parse_myloader_partitions(struct mtd_info *master, num_parts++; } - mtd_parts = kzalloc((num_parts*sizeof(*mtd_part) + num_parts*NAME_LEN_MAX), GFP_KERNEL); @@ -119,6 +119,7 @@ int parse_myloader_partitions(struct mtd_info *master, mtd_part->name = names; mtd_part->offset = 0; mtd_part->size = blocklen; + mtd_part->mask_flags = MTD_WRITEABLE; mtd_part++; names += NAME_LEN_MAX; @@ -126,6 +127,7 @@ int parse_myloader_partitions(struct mtd_info *master, mtd_part->name = names; mtd_part->offset = blocklen; mtd_part->size = blocklen; + mtd_part->mask_flags = MTD_WRITEABLE; mtd_part++; names += NAME_LEN_MAX; @@ -136,9 +138,9 @@ int parse_myloader_partitions(struct mtd_info *master, continue; sprintf(names, "partition%d", i); - mtd_part->name = names; mtd_part->offset = le32_to_cpu(part->addr); mtd_part->size = le32_to_cpu(part->size); + mtd_part->name = names; mtd_part++; names += NAME_LEN_MAX; } diff --git a/target/linux/adm5120-2.6/files/drivers/net/adm5120sw.c b/target/linux/adm5120-2.6/files/drivers/net/adm5120sw.c index dfc030ea1..6c311bfde 100644 --- a/target/linux/adm5120-2.6/files/drivers/net/adm5120sw.c +++ b/target/linux/adm5120-2.6/files/drivers/net/adm5120sw.c @@ -40,9 +40,9 @@ static unsigned char vlan_matrix[SW_DEVS] = { 0x41, 0x42, 0x44, 0x48, 0x50, 0x60 }; -/* default settings - unlimited TX and RX on all ports, default shaper mode */ +/* default settings - unlimited TX and RX on all ports, default shaper mode */ static unsigned char bw_matrix[SW_DEVS] = { - 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0 }; static int adm5120_nrdevs; @@ -373,17 +373,17 @@ static int adm5120_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) break; case SIOCGETBW: err = copy_to_user(rq->ifr_data, bw_matrix, sizeof(bw_matrix)); - if (err) - return -EFAULT; - break; + if (err) + return -EFAULT; + break; case SIOCSETBW: - if (!capable(CAP_NET_ADMIN)) + if (!capable(CAP_NET_ADMIN)) return -EPERM; err = copy_from_user(bw_matrix, rq->ifr_data, sizeof(bw_matrix)); - if (err) + if (err) return -EFAULT; adm5120_set_bw(bw_matrix); - break; + break; default: return -EOPNOTSUPP; } @@ -428,9 +428,7 @@ static int __init adm5120_sw_init(void) if (err) goto out; - adm5120_nrdevs = adm5120_board.iface_num; - if (adm5120_nrdevs > 5 && !adm5120_has_gmii()) - adm5120_nrdevs = 5; + adm5120_nrdevs = adm5120_eth_num_ports; adm5120_set_reg(ADM5120_CPUP_CONF, ADM5120_DISCCPUPORT | ADM5120_CRC_PADDING | @@ -483,12 +481,8 @@ static int __init adm5120_sw_init(void) dev->tx_timeout = adm5120_tx_timeout; dev->watchdog_timeo = ETH_TX_TIMEOUT; dev->set_mac_address = adm5120_sw_set_mac_address; - /* HACK alert!!! In the original admtek driver it is asumed - that you can read the MAC addressess from flash, but edimax - decided to leave that space intentionally blank... - */ - memcpy(dev->dev_addr, "\x00\x50\xfc\x11\x22\x01", 6); - dev->dev_addr[5] += i; + + memcpy(dev->dev_addr, adm5120_eth_macs[i], 6); adm5120_write_mac(dev); if ((err = register_netdev(dev))) { diff --git a/target/linux/adm5120-2.6/files/drivers/usb/host/adm5120-hcd.c b/target/linux/adm5120-2.6/files/drivers/usb/host/adm5120-hcd.c index 87bfcc6c7..c8be7393f 100644 --- a/target/linux/adm5120-2.6/files/drivers/usb/host/adm5120-hcd.c +++ b/target/linux/adm5120-2.6/files/drivers/usb/host/adm5120-hcd.c @@ -18,6 +18,7 @@ #include <linux/usb.h> #include <linux/platform_device.h> +#include <asm/bootinfo.h> #include <asm/io.h> #include <asm/irq.h> #include <asm/system.h> @@ -751,7 +752,7 @@ static int __init adm5120hcd_probe(struct platform_device *pdev) err = -ENOMEM; goto out_mem; } - + hcd = usb_create_hcd(&adm5120_hc_driver, &pdev->dev, pdev->dev.bus_id); if (!hcd) goto out_mem; @@ -821,22 +822,30 @@ static struct platform_driver adm5120hcd_driver = { .probe = adm5120hcd_probe, .remove = adm5120hcd_remove, .driver = { - .name = "adm5120-hcd", + .name = "adm5120-usbc", .owner = THIS_MODULE, }, }; static int __init adm5120hcd_init(void) { - if (usb_disabled()) + int ret; + + if (usb_disabled()) { + printk(KERN_DEBUG PFX "USB support is disabled\n"); return -ENODEV; - if (!adm5120_board.has_usb) { - printk(KERN_DEBUG PFX "this board does not have USB\n"); + } + + if (mips_machgroup != MACH_GROUP_ADM5120) { + printk(KERN_DEBUG PFX "unsupported machine group\n"); return -ENODEV; } - printk(KERN_INFO PFX "registered\n"); - return platform_driver_register(&adm5120hcd_driver); + ret = platform_driver_register(&adm5120hcd_driver); + if (ret == 0) + printk(KERN_INFO PFX "registered\n"); + + return ret; } static void __exit adm5120hcd_exit(void) diff --git a/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/adm5120_board.h b/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/adm5120_board.h new file mode 100644 index 000000000..80ace7865 --- /dev/null +++ b/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/adm5120_board.h @@ -0,0 +1,49 @@ +/* + * $Id$ + * + * ADM5120 board 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_BOARD_H_ +#define _ADM5120_BOARD_H_ + +#include <linux/init.h> +#include <linux/list.h> + +#define ADM5120_BOARD_NAMELEN 64 + +struct adm5120_board { + unsigned long mach_type; + char name[ADM5120_BOARD_NAMELEN]; + + void (*board_setup)(void); + void (*board_reset)(void); + + unsigned int num_eth_ports; + unsigned int num_devices; + struct platform_device **devices; + + struct list_head list; +}; + +extern void adm5120_board_register(struct adm5120_board *) __init; + +#endif /* _ADM5120_BOARD_H_ */ diff --git a/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/adm5120_info.h b/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/adm5120_info.h index 5c6424418..009bf4a71 100644 --- a/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/adm5120_info.h +++ b/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/adm5120_info.h @@ -1,13 +1,23 @@ /* - * $Id$ + * $Id$ * - * Copyright (C) 2007 OpenWrt.org - * Copyright (C) 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 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_INFO_H @@ -15,27 +25,14 @@ #include <linux/types.h> -#define ADM5120_BOARD_NAMELEN 64 - -struct adm5120_board { - char name[ADM5120_BOARD_NAMELEN]; - unsigned long mach_type; - unsigned int iface_num; /* Number of Ethernet interfaces */ - unsigned int has_usb; /* USB controller presence flag */ - u32 mem_size; /* onboard memory size */ - u32 flash0_size; /* Flash 0 size */ -}; - -extern struct adm5120_board adm5120_board; - -extern unsigned int adm5120_boot_loader; -#define BOOT_LOADER_UNKNOWN 0 -#define BOOT_LOADER_CFE 1 -#define BOOT_LOADER_UBOOT 2 -#define BOOT_LOADER_MYLOADER 3 -#define BOOT_LOADER_ROUTERBOOT 4 -#define BOOT_LOADER_BOOTBASE 5 -#define BOOT_LOADER_LAST 5 +extern unsigned int adm5120_prom_type; +#define ADM5120_PROM_GENERIC 0 +#define ADM5120_PROM_CFE 1 +#define ADM5120_PROM_MYLOADER 2 +#define ADM5120_PROM_ROUTERBOOT 3 +#define ADM5120_PROM_BOOTBASE 4 +#define ADM5120_PROM_UBOOT 5 +#define ADM5120_PROM_LAST 5 extern unsigned int adm5120_product_code; extern unsigned int adm5120_revision; @@ -53,7 +50,22 @@ extern unsigned int adm5120_package; extern unsigned long adm5120_memsize; -extern void adm5120_info_init(void); +/* + * TODO:remove adm5120_eth* variables when the switch driver will be + * converted into a real platform driver + */ +extern unsigned int adm5120_eth_num_ports; +extern unsigned char adm5120_eth_macs[6][6]; + +extern void adm5120_mem_init(void) __init; +extern void adm5120_time_init(void) __init; +extern void adm5120_ndelay(u32 ns); + +extern void adm5120_restart(char *command); +extern void adm5120_halt(void); +extern void adm5120_power_off(void); + +extern void (*adm5120_board_reset)(void); static inline int adm5120_package_pqfp(void) { @@ -75,14 +87,4 @@ static inline int adm5120_has_gmii(void) return (adm5120_package == ADM5120_PACKAGE_BGA); } -static inline char *adm5120_board_name(void) -{ - return adm5120_board.name; -} - -static inline u32 adm5120_board_memsize(void) -{ - return adm5120_board.mem_size; -} - #endif /* _ADM5120_INFO_H */ diff --git a/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/adm5120_intc.h b/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/adm5120_intc.h index 1d16fdcda..58995fe55 100644 --- a/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/adm5120_intc.h +++ b/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/adm5120_intc.h @@ -1,4 +1,6 @@ /* + * $Id$ + * * ADM5120 interrupt controller definitions * * This header file defines the hardware registers of the ADM5120 SoC @@ -22,6 +24,7 @@ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ + #ifndef _ADM5120_INTC_H_ #define _ADM5120_INTC_H_ diff --git a/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/adm5120_platform.h b/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/adm5120_platform.h new file mode 100644 index 000000000..b9822983c --- /dev/null +++ b/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/adm5120_platform.h @@ -0,0 +1,66 @@ +/* + * $Id$ + * + * ADM5120 specific platform 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_PLATFORM_H_ +#define _ADM5120_PLATFORM_H_ + +#include <linux/mtd/mtd.h> +#include <linux/mtd/map.h> +#include <linux/mtd/partitions.h> + +struct adm5120_flash_platform_data { + void (*set_vpp)(struct map_info *, int); + void (*switch_bank)(unsigned); + unsigned int nr_parts; + struct mtd_partition *parts; +}; + +struct adm5120_switch_platform_data { + /* TODO: not yet implemented */ +}; + +struct adm5120_pci_irq { + u8 slot; + u8 func; + u8 pin; + unsigned irq; +}; + +struct adm5120_pci_platform_data { + unsigned int nr_irqs; + struct adm5120_pci_irq *irqs; +}; + +extern struct adm5120_flash_platform_data adm5120_flash0_data; +extern struct adm5120_flash_platform_data adm5120_flash1_data; +extern struct adm5120_pci_platform_data adm5120_pci_data; +extern struct adm5120_switch_platform_data adm5120_switch_data; + +extern struct platform_device adm5120_flash0_device; +extern struct platform_device adm5120_flash1_device; +extern struct platform_device adm5120_usbc_device; +extern struct platform_device adm5120_pci_device; +extern struct platform_device adm5120_switch_device; + +#endif /* _ADM5120_PLATFORM_H_ */ diff --git a/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/adm5120_uart.h b/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/adm5120_uart.h new file mode 100755 index 000000000..54aacffa7 --- /dev/null +++ b/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/adm5120_uart.h @@ -0,0 +1,75 @@ +/* + * ADM5120 UART definitions + * + * This header file defines the hardware registers of the ADM5120 SoC + * built-in UARTs. + * + * 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_UART_H_ +#define _ADM5120_UART_H_ + +#define UART_BAUDDIV(clk, baud) ((clk/(16 * (baud)))-1) + +#define UART_REG_DATA 0x00 +#define UART_REG_RSR 0x04 +#define UART_REG_ECR UART_REG_RSR +#define UART_REG_LCRH 0x08 +#define UART_REG_LCRM 0x0C +#define UART_REG_LCRL 0x10 +#define UART_REG_CTRL 0x14 +#define UART_REG_FLAG 0x18 + +/* Receive Status Register bits */ +#define UART_RSR_FE ( 1 << 0 ) +#define UART_RSR_PE ( 1 << 1 ) +#define UART_RSR_BE ( 1 << 2 ) +#define UART_RSR_OE ( 1 << 3 ) +#define UART_RSR_ERR ( UART_RSR_FE | UART_RSR_PE | UART_RSR_BE ) + +#define UART_ECR_ALL 0xFF + +/* Line Control High register bits */ +#define UART_LCRH_BRK ( 1 << 0 ) /* send break */ +#define UART_LCRH_PEN ( 1 << 1 ) /* parity enable */ +#define UART_LCRH_EPS ( 1 << 2 ) /* even parity select */ +#define UART_LCRH_STP1 ( 0 << 3 ) /* one stop bits select */ +#define UART_LCRH_STP2 ( 1 << 3 ) /* two stop bits select */ +#define UART_LCRH_FEN ( 1 << 4 ) /* FIFO enable */ + +#define UART_LCRH_WLEN5 ( 0 << 5 ) +#define UART_LCRH_WLEN6 ( 1 << 5 ) +#define UART_LCRH_WLEN7 ( 2 << 5 ) +#define UART_LCRH_WLEN8 ( 3 << 5 ) + +/* Control register bits */ +#define UART_CTRL_EN ( 1 << 0 ) + +/* Flag register bits */ +#define UART_FLAG_CTS ( 1 << 0 ) +#define UART_FLAG_DSR ( 1 << 1 ) +#define UART_FLAG_DCD ( 1 << 2 ) +#define UART_FLAG_BUSY ( 1 << 3 ) +#define UART_FLAG_RXFE ( 1 << 4 ) +#define UART_FLAG_TXFF ( 1 << 5 ) +#define UART_FLAG_RXFF ( 1 << 6 ) +#define UART_FLAG_TXFE ( 1 << 7 ) + +#endif /* _ADM5120_UART_H_ */ diff --git a/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/prom/cfe.h b/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/prom/cfe.h new file mode 100644 index 000000000..128d0cab3 --- /dev/null +++ b/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/prom/cfe.h @@ -0,0 +1,31 @@ +/* + * $Id$ + * + * Broadcom's CFE definitions + * + * Copyright (C) 2006,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. + */ + +#ifndef _PROM_CFE_H_ +#define _PROM_CFE_H_ + +extern int cfe_present(void) __init; +extern char *cfe_getenv(char *); + +#endif /*_PROM_CFE_H_*/ diff --git a/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/prom/generic.h b/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/prom/generic.h new file mode 100644 index 000000000..699e60cc8 --- /dev/null +++ b/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/prom/generic.h @@ -0,0 +1,31 @@ +/* + * $Id$ + * + * Generic prom definitions + * + * Copyright (C) 2006,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. + */ + +#ifndef _PROM_GENERIC_H_ +#define _PROM_GENERIC_H_ + +extern int generic_prom_present(void) __init; +extern char *generic_prom_getenv(char *); + +#endif /*_PROM_GENERIC_H_*/ diff --git a/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/myloader.h b/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/prom/myloader.h index 3c0c6021b..e034be8f3 100644 --- a/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/myloader.h +++ b/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/prom/myloader.h @@ -1,11 +1,25 @@ /* - * Copyright (C) 2006,2007 Gabor Juhos + * $Id$ * - * 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. + * Compex's MyLoader specific definitions * + * Copyright (C) 2006,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. */ #ifndef _MYLOADER_H_ @@ -164,4 +178,14 @@ struct mylo_board_params { struct mylo_eth_addr addr[MYLO_ETHADDR_COUNT]; }; +struct myloader_info { + u32 vid; + u32 did; + u32 svid; + u32 sdid; +}; + +extern struct myloader_info myloader_info; +extern int myloader_present(void) __init; + #endif /* _MYLOADER_H_*/ diff --git a/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/routerboot.h b/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/prom/routerboot.h index 2a593e933..e37b066bd 100644 --- a/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/routerboot.h +++ b/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/prom/routerboot.h @@ -1,14 +1,25 @@ /* * $Id$ * + * Mikrotik's RouterBOOT 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 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 _ROUTERBOOT_H @@ -120,4 +131,7 @@ struct rb_hard_settings { #define RB_BOOT_PROTOCOL_BOOTP 0 #define RB_BOOT_PROTOCOL_DHCP 1 +extern int routerboot_present(void) __init; +extern char *routerboot_get_boardname(void); + #endif /* _ROUTERBOOT_H */ diff --git a/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/zynos.h b/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/prom/zynos.h index ba372d3d3..d2aaae048 100644 --- a/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/zynos.h +++ b/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/prom/zynos.h @@ -1,14 +1,25 @@ /* * $Id$ * + * ZyNOS (ZyXEL's Networking OS) 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 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 _ZYNOS_H @@ -75,4 +86,13 @@ struct zynos_board_info { #define ZYNOS_MAGIC_DBGAREA1 0x48646267 /* "Hdbg" */ #define ZYNOS_MAGIC_DBGAREA2 0x61726561 /* "area" */ +struct bootbase_info { + u16 vendor_id; + u16 board_id; + u8 mac[6]; +}; + +extern struct bootbase_info bootbase_info; +extern int bootbase_present(void) __init; + #endif /* _ZYNOS_H */ diff --git a/target/linux/adm5120-2.6/patches-2.6.22/001-adm5120.patch b/target/linux/adm5120-2.6/patches-2.6.22/001-adm5120.patch index da601b919..71db5fd86 100644 --- a/target/linux/adm5120-2.6/patches-2.6.22/001-adm5120.patch +++ b/target/linux/adm5120-2.6/patches-2.6.22/001-adm5120.patch @@ -1,14 +1,15 @@ -Index: linux-2.6.22-rc6/arch/mips/Kconfig +Index: linux-2.6.22/arch/mips/Kconfig =================================================================== ---- linux-2.6.22-rc6.orig/arch/mips/Kconfig -+++ linux-2.6.22-rc6/arch/mips/Kconfig -@@ -15,6 +15,17 @@ choice +--- linux-2.6.22.orig/arch/mips/Kconfig ++++ linux-2.6.22/arch/mips/Kconfig +@@ -15,6 +15,18 @@ choice prompt "System type" default SGI_IP22 +config MIPS_ADM5120 + bool "Support for ADM5120 SoC" + select SYS_HAS_CPU_MIPS32_R1 ++ select SYS_HAS_EARLY_PRINTK + select DMA_NONCOHERENT + select HW_HAS_PCI + select IRQ_CPU @@ -20,7 +21,7 @@ Index: linux-2.6.22-rc6/arch/mips/Kconfig config MACH_ALCHEMY bool "Alchemy processor based machines" -@@ -658,6 +669,7 @@ config TOSHIBA_RBTX4938 +@@ -658,6 +670,7 @@ config TOSHIBA_RBTX4938 endchoice @@ -28,18 +29,20 @@ Index: linux-2.6.22-rc6/arch/mips/Kconfig source "arch/mips/au1000/Kconfig" source "arch/mips/ddb5xxx/Kconfig" source "arch/mips/gt64120/ev64120/Kconfig" -Index: linux-2.6.22-rc6/arch/mips/Makefile +Index: linux-2.6.22/arch/mips/Makefile =================================================================== ---- linux-2.6.22-rc6.orig/arch/mips/Makefile -+++ linux-2.6.22-rc6/arch/mips/Makefile -@@ -165,6 +165,14 @@ cflags-$(CONFIG_MACH_JAZZ) += -Iinclude/ +--- linux-2.6.22.orig/arch/mips/Makefile ++++ linux-2.6.22/arch/mips/Makefile +@@ -165,6 +165,16 @@ cflags-$(CONFIG_MACH_JAZZ) += -Iinclude/ load-$(CONFIG_MACH_JAZZ) += 0xffffffff80080000 # +# ADMtek 5120 +# + ++libs-$(CONFIG_MIPS_ADM5120) += arch/mips/adm5120/prom/ +core-$(CONFIG_MIPS_ADM5120) += arch/mips/adm5120/ ++core-$(CONFIG_MIPS_ADM5120) += arch/mips/adm5120/boards/ +cflags-$(CONFIG_MIPS_ADM5120) += -Iinclude/asm-mips/mach-adm5120 +load-$(CONFIG_MIPS_ADM5120) += 0xffffffff80001000 + @@ -47,10 +50,10 @@ Index: linux-2.6.22-rc6/arch/mips/Makefile # Common Alchemy Au1x00 stuff # core-$(CONFIG_SOC_AU1X00) += arch/mips/au1000/common/ -Index: linux-2.6.22-rc6/include/asm-mips/bootinfo.h +Index: linux-2.6.22/include/asm-mips/bootinfo.h =================================================================== ---- linux-2.6.22-rc6.orig/include/asm-mips/bootinfo.h -+++ linux-2.6.22-rc6/include/asm-mips/bootinfo.h +--- linux-2.6.22.orig/include/asm-mips/bootinfo.h ++++ linux-2.6.22/include/asm-mips/bootinfo.h @@ -213,6 +213,57 @@ #define MACH_GROUP_NEC_EMMA2RH 25 /* NEC EMMA2RH (was 23) */ #define MACH_NEC_MARKEINS 0 /* NEC EMMA2RH Mark-eins */ @@ -59,7 +62,7 @@ Index: linux-2.6.22-rc6/include/asm-mips/bootinfo.h + * Valid machtype for group ADMtek ADM5120 + */ +#define MACH_GROUP_ADM5120 26 -+#define MACH_ADM5120_UNKNOWN 0 /* Unknown board */ ++#define MACH_ADM5120_GENERIC 0 /* Generic board */ +#define MACH_ADM5120_WP54G_WRT 1 /* Compex WP54G-WRT */ +#define MACH_ADM5120_WP54G 2 /* Compex WP54G */ +#define MACH_ADM5120_WP54AG 3 /* Compex WP54AG */ diff --git a/target/linux/adm5120-2.6/patches-2.6.22/002-adm5120_flash.patch b/target/linux/adm5120-2.6/patches-2.6.22/002-adm5120_flash.patch index 355c126c9..b84a62c49 100644 --- a/target/linux/adm5120-2.6/patches-2.6.22/002-adm5120_flash.patch +++ b/target/linux/adm5120-2.6/patches-2.6.22/002-adm5120_flash.patch @@ -1,27 +1,26 @@ -Index: linux-2.6.22-rc6/drivers/mtd/maps/Kconfig +Index: linux-2.6.22/drivers/mtd/maps/Kconfig =================================================================== ---- linux-2.6.22-rc6.orig/drivers/mtd/maps/Kconfig -+++ linux-2.6.22-rc6/drivers/mtd/maps/Kconfig -@@ -620,5 +620,10 @@ config MTD_PLATRAM +--- linux-2.6.22.orig/drivers/mtd/maps/Kconfig ++++ linux-2.6.22/drivers/mtd/maps/Kconfig +@@ -620,5 +620,9 @@ config MTD_PLATRAM This selection automatically selects the map_ram driver. +config MTD_ADM5120 -+ tristate "Map driver for ADMtek ADM5120 boards" ++ tristate "Map driver for ADM5120 based boards" + depends on MIPS_ADM5120 -+ select MTD_CFI_AMDSTD + endmenu -Index: linux-2.6.22-rc6/drivers/mtd/maps/Makefile +Index: linux-2.6.22/drivers/mtd/maps/Makefile =================================================================== ---- linux-2.6.22-rc6.orig/drivers/mtd/maps/Makefile -+++ linux-2.6.22-rc6/drivers/mtd/maps/Makefile +--- linux-2.6.22.orig/drivers/mtd/maps/Makefile ++++ linux-2.6.22/drivers/mtd/maps/Makefile @@ -47,6 +47,7 @@ obj-$(CONFIG_MTD_OCELOT) += ocelot.o obj-$(CONFIG_MTD_SOLUTIONENGINE)+= solutionengine.o obj-$(CONFIG_MTD_PCI) += pci.o obj-$(CONFIG_MTD_ALCHEMY) += alchemy-flash.o -+obj-$(CONFIG_MTD_ADM5120) += adm5120_mtd.o ++obj-$(CONFIG_MTD_ADM5120) += adm5120-flash.o obj-$(CONFIG_MTD_LASAT) += lasat.o obj-$(CONFIG_MTD_AUTCPU12) += autcpu12-nvram.o obj-$(CONFIG_MTD_EDB7312) += edb7312.o diff --git a/target/linux/adm5120-2.6/patches-2.6.22/003-adm5120_switch.patch b/target/linux/adm5120-2.6/patches-2.6.22/003-adm5120_switch.patch index 9dde78250..83c1ff942 100644 --- a/target/linux/adm5120-2.6/patches-2.6.22/003-adm5120_switch.patch +++ b/target/linux/adm5120-2.6/patches-2.6.22/003-adm5120_switch.patch @@ -1,7 +1,7 @@ -Index: linux-2.6.22-rc6/drivers/net/Kconfig +Index: linux-2.6.22/drivers/net/Kconfig =================================================================== ---- linux-2.6.22-rc6.orig/drivers/net/Kconfig -+++ linux-2.6.22-rc6/drivers/net/Kconfig +--- linux-2.6.22.orig/drivers/net/Kconfig ++++ linux-2.6.22/drivers/net/Kconfig @@ -574,6 +574,10 @@ config MIPS_AU1X00_ENET If you have an Alchemy Semi AU1X00 based system say Y. Otherwise, say N. @@ -13,10 +13,10 @@ Index: linux-2.6.22-rc6/drivers/net/Kconfig config NET_SB1250_MAC tristate "SB1250 Ethernet support" depends on NET_ETHERNET && SIBYTE_SB1xxx_SOC -Index: linux-2.6.22-rc6/drivers/net/Makefile +Index: linux-2.6.22/drivers/net/Makefile =================================================================== ---- linux-2.6.22-rc6.orig/drivers/net/Makefile -+++ linux-2.6.22-rc6/drivers/net/Makefile +--- linux-2.6.22.orig/drivers/net/Makefile ++++ linux-2.6.22/drivers/net/Makefile @@ -165,6 +165,7 @@ obj-$(CONFIG_SC92031) += sc92031.o # This is also a 82596 and should probably be merged obj-$(CONFIG_LP486E) += lp486e.o diff --git a/target/linux/adm5120-2.6/patches-2.6.22/004-adm5120_uart.patch b/target/linux/adm5120-2.6/patches-2.6.22/004-adm5120_uart.patch index eb78e0357..089221eb4 100644 --- a/target/linux/adm5120-2.6/patches-2.6.22/004-adm5120_uart.patch +++ b/target/linux/adm5120-2.6/patches-2.6.22/004-adm5120_uart.patch @@ -1,7 +1,7 @@ -Index: linux-2.6.22-rc6/drivers/serial/Makefile +Index: linux-2.6.22/drivers/serial/Makefile =================================================================== ---- linux-2.6.22-rc6.orig/drivers/serial/Makefile -+++ linux-2.6.22-rc6/drivers/serial/Makefile +--- linux-2.6.22.orig/drivers/serial/Makefile ++++ linux-2.6.22/drivers/serial/Makefile @@ -21,6 +21,7 @@ obj-$(CONFIG_SERIAL_8250_EXAR_ST16C554) obj-$(CONFIG_SERIAL_8250_HUB6) += 8250_hub6.o obj-$(CONFIG_SERIAL_8250_MCA) += 8250_mca.o @@ -10,10 +10,10 @@ Index: linux-2.6.22-rc6/drivers/serial/Makefile obj-$(CONFIG_SERIAL_AMBA_PL010) += amba-pl010.o obj-$(CONFIG_SERIAL_AMBA_PL011) += amba-pl011.o obj-$(CONFIG_SERIAL_CLPS711X) += clps711x.o -Index: linux-2.6.22-rc6/include/linux/serial_core.h +Index: linux-2.6.22/include/linux/serial_core.h =================================================================== ---- linux-2.6.22-rc6.orig/include/linux/serial_core.h -+++ linux-2.6.22-rc6/include/linux/serial_core.h +--- linux-2.6.22.orig/include/linux/serial_core.h ++++ linux-2.6.22/include/linux/serial_core.h @@ -143,6 +143,9 @@ #define PORT_KS8695 76 @@ -24,10 +24,10 @@ Index: linux-2.6.22-rc6/include/linux/serial_core.h #ifdef __KERNEL__ #include <linux/compiler.h> -Index: linux-2.6.22-rc6/drivers/serial/Kconfig +Index: linux-2.6.22/drivers/serial/Kconfig =================================================================== ---- linux-2.6.22-rc6.orig/drivers/serial/Kconfig -+++ linux-2.6.22-rc6/drivers/serial/Kconfig +--- linux-2.6.22.orig/drivers/serial/Kconfig ++++ linux-2.6.22/drivers/serial/Kconfig @@ -270,6 +270,22 @@ config SERIAL_8250_RM9K comment "Non-8250 serial port support" diff --git a/target/linux/adm5120-2.6/patches-2.6.22/005-adm5120_usb.patch b/target/linux/adm5120-2.6/patches-2.6.22/005-adm5120_usb.patch index c862f906e..06734a172 100644 --- a/target/linux/adm5120-2.6/patches-2.6.22/005-adm5120_usb.patch +++ b/target/linux/adm5120-2.6/patches-2.6.22/005-adm5120_usb.patch @@ -1,7 +1,7 @@ -Index: linux-2.6.22-rc6/drivers/usb/core/hub.c +Index: linux-2.6.22/drivers/usb/core/hub.c =================================================================== ---- linux-2.6.22-rc6.orig/drivers/usb/core/hub.c -+++ linux-2.6.22-rc6/drivers/usb/core/hub.c +--- linux-2.6.22.orig/drivers/usb/core/hub.c ++++ linux-2.6.22/drivers/usb/core/hub.c @@ -464,7 +464,7 @@ void usb_hub_tt_clear_buffer (struct usb : (USB_ENDPOINT_XFER_BULK << 11); if (usb_pipein (pipe)) @@ -182,21 +182,21 @@ Index: linux-2.6.22-rc6/drivers/usb/core/hub.c re_enumerate: hub_port_logical_disconnect(parent_hub, port1); return -ENODEV; -Index: linux-2.6.22-rc6/drivers/usb/host/Kconfig +Index: linux-2.6.22/drivers/usb/host/Kconfig =================================================================== ---- linux-2.6.22-rc6.orig/drivers/usb/host/Kconfig -+++ linux-2.6.22-rc6/drivers/usb/host/Kconfig -@@ -224,3 +224,6 @@ config USB_SL811_CS +--- linux-2.6.22.orig/drivers/usb/host/Kconfig ++++ linux-2.6.22/drivers/usb/host/Kconfig +@@ -237,3 +237,6 @@ config USB_SL811_CS To compile this driver as a module, choose M here: the module will be called "sl811_cs". +config USB_ADM5120_HCD + tristate "ADM5120 HCD support" + depends on USB && MIPS_ADM5120 -Index: linux-2.6.22-rc6/drivers/usb/host/Makefile +Index: linux-2.6.22/drivers/usb/host/Makefile =================================================================== ---- linux-2.6.22-rc6.orig/drivers/usb/host/Makefile -+++ linux-2.6.22-rc6/drivers/usb/host/Makefile +--- linux-2.6.22.orig/drivers/usb/host/Makefile ++++ linux-2.6.22/drivers/usb/host/Makefile @@ -8,6 +8,7 @@ endif obj-$(CONFIG_PCI) += pci-quirks.o @@ -205,10 +205,10 @@ Index: linux-2.6.22-rc6/drivers/usb/host/Makefile obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o obj-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o obj-$(CONFIG_USB_OHCI_HCD) += ohci-hcd.o -Index: linux-2.6.22-rc6/drivers/usb/Kconfig +Index: linux-2.6.22/drivers/usb/Kconfig =================================================================== ---- linux-2.6.22-rc6.orig/drivers/usb/Kconfig -+++ linux-2.6.22-rc6/drivers/usb/Kconfig +--- linux-2.6.22.orig/drivers/usb/Kconfig ++++ linux-2.6.22/drivers/usb/Kconfig @@ -88,8 +88,6 @@ source "drivers/usb/storage/Kconfig" source "drivers/usb/image/Kconfig" @@ -218,10 +218,10 @@ Index: linux-2.6.22-rc6/drivers/usb/Kconfig comment "USB port drivers" depends on USB -Index: linux-2.6.22-rc6/drivers/usb/Makefile +Index: linux-2.6.22/drivers/usb/Makefile =================================================================== ---- linux-2.6.22-rc6.orig/drivers/usb/Makefile -+++ linux-2.6.22-rc6/drivers/usb/Makefile +--- linux-2.6.22.orig/drivers/usb/Makefile ++++ linux-2.6.22/drivers/usb/Makefile @@ -16,6 +16,7 @@ obj-$(CONFIG_USB_UHCI_HCD) += host/ obj-$(CONFIG_USB_SL811_HCD) += host/ obj-$(CONFIG_USB_U132_HCD) += host/ diff --git a/target/linux/adm5120-2.6/patches-2.6.22/006-adm5120_leds.patch b/target/linux/adm5120-2.6/patches-2.6.22/006-adm5120_leds.patch index 91ca638de..c7c65613d 100644 --- a/target/linux/adm5120-2.6/patches-2.6.22/006-adm5120_leds.patch +++ b/target/linux/adm5120-2.6/patches-2.6.22/006-adm5120_leds.patch @@ -1,7 +1,7 @@ -Index: linux-2.6.22-rc6/drivers/leds/Kconfig +Index: linux-2.6.22/drivers/leds/Kconfig =================================================================== ---- linux-2.6.22-rc6.orig/drivers/leds/Kconfig -+++ linux-2.6.22-rc6/drivers/leds/Kconfig +--- linux-2.6.22.orig/drivers/leds/Kconfig ++++ linux-2.6.22/drivers/leds/Kconfig @@ -20,6 +20,27 @@ config LEDS_CLASS comment "LED drivers" @@ -30,10 +30,10 @@ Index: linux-2.6.22-rc6/drivers/leds/Kconfig config LEDS_CORGI tristate "LED Support for the Sharp SL-C7x0 series" depends on LEDS_CLASS && PXA_SHARP_C7xx -Index: linux-2.6.22-rc6/drivers/leds/Makefile +Index: linux-2.6.22/drivers/leds/Makefile =================================================================== ---- linux-2.6.22-rc6.orig/drivers/leds/Makefile -+++ linux-2.6.22-rc6/drivers/leds/Makefile +--- linux-2.6.22.orig/drivers/leds/Makefile ++++ linux-2.6.22/drivers/leds/Makefile @@ -5,6 +5,8 @@ obj-$(CONFIG_LEDS_CLASS) += led-class.o obj-$(CONFIG_LEDS_TRIGGERS) += led-triggers.o diff --git a/target/linux/adm5120-2.6/patches-2.6.22/007-adm5120_pci.patch b/target/linux/adm5120-2.6/patches-2.6.22/007-adm5120_pci.patch index 18839cf36..3fe345e53 100644 --- a/target/linux/adm5120-2.6/patches-2.6.22/007-adm5120_pci.patch +++ b/target/linux/adm5120-2.6/patches-2.6.22/007-adm5120_pci.patch @@ -1,17 +1,17 @@ -Index: linux-2.6.22-rc6/arch/mips/pci/Makefile +Index: linux-2.6.22/arch/mips/pci/Makefile =================================================================== ---- linux-2.6.22-rc6.orig/arch/mips/pci/Makefile -+++ linux-2.6.22-rc6/arch/mips/pci/Makefile +--- linux-2.6.22.orig/arch/mips/pci/Makefile ++++ linux-2.6.22/arch/mips/pci/Makefile @@ -50,3 +50,4 @@ obj-$(CONFIG_TOSHIBA_RBTX4938) += fixup- obj-$(CONFIG_VICTOR_MPC30X) += fixup-mpc30x.o obj-$(CONFIG_ZAO_CAPCELLA) += fixup-capcella.o obj-$(CONFIG_WR_PPMC) += fixup-wrppmc.o +obj-$(CONFIG_PCI_ADM5120) += fixup-adm5120.o ops-adm5120.o pci-adm5120.o -Index: linux-2.6.22-rc6/include/linux/pci_ids.h +Index: linux-2.6.22/include/linux/pci_ids.h =================================================================== ---- linux-2.6.22-rc6.orig/include/linux/pci_ids.h -+++ linux-2.6.22-rc6/include/linux/pci_ids.h -@@ -1712,6 +1712,9 @@ +--- linux-2.6.22.orig/include/linux/pci_ids.h ++++ linux-2.6.22/include/linux/pci_ids.h +@@ -1713,6 +1713,9 @@ #define PCI_VENDOR_ID_ESDGMBH 0x12fe #define PCI_DEVICE_ID_ESDGMBH_CPCIASIO4 0x0111 diff --git a/target/linux/adm5120-2.6/patches-2.6.22/008-adm5120_hardware_swab.patch b/target/linux/adm5120-2.6/patches-2.6.22/008-adm5120_hardware_swab.patch deleted file mode 100644 index c0fd645b5..000000000 --- a/target/linux/adm5120-2.6/patches-2.6.22/008-adm5120_hardware_swab.patch +++ /dev/null @@ -1,40 +0,0 @@ -Index: linux-2.6.22-rc6/include/asm-mips/byteorder.h -=================================================================== ---- linux-2.6.22-rc6.orig/include/asm-mips/byteorder.h -+++ linux-2.6.22-rc6/include/asm-mips/byteorder.h -@@ -58,6 +58,35 @@ static __inline__ __attribute_const__ __ - - #endif /* CONFIG_CPU_MIPSR2 */ - -+#ifdef CONFIG_ADM5120_HARDWARE_SWAB -+ -+static __inline__ __attribute_const__ __u16 ___adm5120__swab16(__u16 x) -+{ -+ __asm__ ( -+ " sh %2, 0xCA(%1) \n" -+ " lhu %0, 0xCC(%1) \n" -+ : "=r" (x) -+ : "r" (0xB2000000), "r" (x)); -+ -+ return x; -+} -+ -+static __inline__ __attribute_const__ __u32 ___adm5120__swab32(__u32 x) -+{ -+ __asm__ ( -+ " sw %2, 0xC8(%1) \n" -+ " lw %0, 0xCC(%1) \n" -+ : "=r" (x) -+ : "r" (0xB2000000), "r" (x)); -+ -+ return x; -+} -+ -+#define __arch__swab16(x) ___adm5120__swab16(x) -+#define __arch__swab32(x) ___adm5120__swab32(x) -+ -+#endif /* CONFIG_ADM5120_HARDWARE_SWAB */ -+ - #if !defined(__STRICT_ANSI__) || defined(__KERNEL__) - # define __BYTEORDER_HAS_U64__ - # define __SWAB_64_THRU_32__ diff --git a/target/linux/adm5120-2.6/patches-2.6.22/100-mtd-myloder-partition-parser.patch b/target/linux/adm5120-2.6/patches-2.6.22/100-mtd-myloder-partition-parser.patch index 2b4381cd9..6e6d748a8 100644 --- a/target/linux/adm5120-2.6/patches-2.6.22/100-mtd-myloder-partition-parser.patch +++ b/target/linux/adm5120-2.6/patches-2.6.22/100-mtd-myloder-partition-parser.patch @@ -1,7 +1,7 @@ -Index: linux-2.6.22-rc6/drivers/mtd/Kconfig +Index: linux-2.6.22/drivers/mtd/Kconfig =================================================================== ---- linux-2.6.22-rc6.orig/drivers/mtd/Kconfig -+++ linux-2.6.22-rc6/drivers/mtd/Kconfig +--- linux-2.6.22.orig/drivers/mtd/Kconfig ++++ linux-2.6.22/drivers/mtd/Kconfig @@ -155,6 +155,22 @@ config MTD_AFS_PARTS for your particular device. It won't happen automatically. The 'armflash' map driver (CONFIG_MTD_ARMFLASH) does this, for example. @@ -25,10 +25,10 @@ Index: linux-2.6.22-rc6/drivers/mtd/Kconfig comment "User Modules And Translation Layers" config MTD_CHAR -Index: linux-2.6.22-rc6/drivers/mtd/Makefile +Index: linux-2.6.22/drivers/mtd/Makefile =================================================================== ---- linux-2.6.22-rc6.orig/drivers/mtd/Makefile -+++ linux-2.6.22-rc6/drivers/mtd/Makefile +--- linux-2.6.22.orig/drivers/mtd/Makefile ++++ linux-2.6.22/drivers/mtd/Makefile @@ -11,6 +11,7 @@ obj-$(CONFIG_MTD_CONCAT) += mtdconcat.o obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o obj-$(CONFIG_MTD_CMDLINE_PARTS) += cmdlinepart.o diff --git a/target/linux/adm5120-2.6/patches-2.6.22/101-cfi-fixup-macronix-bootloc.patch b/target/linux/adm5120-2.6/patches-2.6.22/101-cfi-fixup-macronix-bootloc.patch index 5740d4ac6..b68eade91 100644 --- a/target/linux/adm5120-2.6/patches-2.6.22/101-cfi-fixup-macronix-bootloc.patch +++ b/target/linux/adm5120-2.6/patches-2.6.22/101-cfi-fixup-macronix-bootloc.patch @@ -1,7 +1,7 @@ -Index: linux-2.6.22-rc6/drivers/mtd/chips/cfi_cmdset_0002.c +Index: linux-2.6.22/drivers/mtd/chips/cfi_cmdset_0002.c =================================================================== ---- linux-2.6.22-rc6.orig/drivers/mtd/chips/cfi_cmdset_0002.c -+++ linux-2.6.22-rc6/drivers/mtd/chips/cfi_cmdset_0002.c +--- linux-2.6.22.orig/drivers/mtd/chips/cfi_cmdset_0002.c ++++ linux-2.6.22/drivers/mtd/chips/cfi_cmdset_0002.c @@ -47,12 +47,19 @@ #define MANUFACTURER_AMD 0x0001 #define MANUFACTURER_ATMEL 0x001F @@ -74,10 +74,10 @@ Index: linux-2.6.22-rc6/drivers/mtd/chips/cfi_cmdset_0002.c { 0, 0, NULL, NULL } }; static struct cfi_fixup jedec_fixup_table[] = { -Index: linux-2.6.22-rc6/drivers/mtd/chips/Kconfig +Index: linux-2.6.22/drivers/mtd/chips/Kconfig =================================================================== ---- linux-2.6.22-rc6.orig/drivers/mtd/chips/Kconfig -+++ linux-2.6.22-rc6/drivers/mtd/chips/Kconfig +--- linux-2.6.22.orig/drivers/mtd/chips/Kconfig ++++ linux-2.6.22/drivers/mtd/chips/Kconfig @@ -196,6 +196,14 @@ config MTD_CFI_AMDSTD provides support for one of those command sets, used on chips including the AMD Am29LV320. diff --git a/target/linux/adm5120-2.6/patches-2.6.22/102-jedec-pmc-39lvxxx-chips.patch b/target/linux/adm5120-2.6/patches-2.6.22/102-jedec-pmc-39lvxxx-chips.patch new file mode 100644 index 000000000..fa9d35dd1 --- /dev/null +++ b/target/linux/adm5120-2.6/patches-2.6.22/102-jedec-pmc-39lvxxx-chips.patch @@ -0,0 +1,74 @@ +Index: linux-2.6.22/drivers/mtd/chips/jedec_probe.c +=================================================================== +--- linux-2.6.22.orig/drivers/mtd/chips/jedec_probe.c ++++ linux-2.6.22/drivers/mtd/chips/jedec_probe.c +@@ -121,6 +121,10 @@ + #define UPD29F064115 0x221C + + /* PMC */ ++#define PM39LV512 0x001B ++#define PM39LV010 0x001C ++#define PM39LV020 0x003D ++#define PM39LV040 0x003E + #define PM49FL002 0x006D + #define PM49FL004 0x006E + #define PM49FL008 0x006A +@@ -1246,6 +1250,58 @@ static const struct amd_flash_info jedec + ERASEINFO(0x02000,2), + ERASEINFO(0x04000,1), + } ++ }, { ++ .mfr_id = MANUFACTURER_PMC, ++ .dev_id = PM39LV512, ++ .name = "PMC Pm39LV512", ++ .uaddr = { ++ [0] = MTD_UADDR_0x0555_0x02AA /* x8 */ ++ }, ++ .DevSize = SIZE_64KiB, ++ .CmdSet = P_ID_AMD_STD, ++ .NumEraseRegions= 1, ++ .regions = { ++ ERASEINFO(0x01000,16), ++ } ++ }, { ++ .mfr_id = MANUFACTURER_PMC, ++ .dev_id = PM39LV010, ++ .name = "PMC Pm39LV010", ++ .uaddr = { ++ [0] = MTD_UADDR_0x0555_0x02AA /* x8 */ ++ }, ++ .DevSize = SIZE_128KiB, ++ .CmdSet = P_ID_AMD_STD, ++ .NumEraseRegions= 1, ++ .regions = { ++ ERASEINFO(0x01000,32), ++ } ++ }, { ++ .mfr_id = MANUFACTURER_PMC, ++ .dev_id = PM39LV020, ++ .name = "PMC Pm39LV020", ++ .uaddr = { ++ [0] = MTD_UADDR_0x0555_0x02AA /* x8 */ ++ }, ++ .DevSize = SIZE_256KiB, ++ .CmdSet = P_ID_AMD_STD, ++ .NumEraseRegions= 1, ++ .regions = { ++ ERASEINFO(0x01000,64), ++ } ++ }, { ++ .mfr_id = MANUFACTURER_PMC, ++ .dev_id = PM39LV040, ++ .name = "PMC Pm39LV040", ++ .uaddr = { ++ [0] = MTD_UADDR_0x0555_0x02AA /* x8 */ ++ }, ++ .DevSize = SIZE_512KiB, ++ .CmdSet = P_ID_AMD_STD, ++ .NumEraseRegions= 1, ++ .regions = { ++ ERASEINFO(0x01000,128), ++ } + }, { + .mfr_id = MANUFACTURER_PMC, + .dev_id = PM49FL002, diff --git a/target/linux/adm5120-2.6/patches-2.6.22/140-cmdline_hack.patch b/target/linux/adm5120-2.6/patches-2.6.22/140-cmdline_hack.patch index 47378e5a9..de3ffa078 100644 --- a/target/linux/adm5120-2.6/patches-2.6.22/140-cmdline_hack.patch +++ b/target/linux/adm5120-2.6/patches-2.6.22/140-cmdline_hack.patch @@ -1,7 +1,7 @@ -Index: linux-2.6.22-rc6/arch/mips/kernel/head.S +Index: linux-2.6.22/arch/mips/kernel/head.S =================================================================== ---- linux-2.6.22-rc6.orig/arch/mips/kernel/head.S -+++ linux-2.6.22-rc6/arch/mips/kernel/head.S +--- linux-2.6.22.orig/arch/mips/kernel/head.S ++++ linux-2.6.22/arch/mips/kernel/head.S @@ -129,14 +129,19 @@ #endif .endm diff --git a/target/linux/adm5120-2.6/patches-2.6.22/500-Nand.patch b/target/linux/adm5120-2.6/patches-2.6.22/500-Nand.patch index fb503c5dc..de96babbe 100644 --- a/target/linux/adm5120-2.6/patches-2.6.22/500-Nand.patch +++ b/target/linux/adm5120-2.6/patches-2.6.22/500-Nand.patch @@ -1,7 +1,7 @@ -Index: linux-2.6.22-rc6/drivers/mtd/nand/Kconfig +Index: linux-2.6.22/drivers/mtd/nand/Kconfig =================================================================== ---- linux-2.6.22-rc6.orig/drivers/mtd/nand/Kconfig -+++ linux-2.6.22-rc6/drivers/mtd/nand/Kconfig +--- linux-2.6.22.orig/drivers/mtd/nand/Kconfig ++++ linux-2.6.22/drivers/mtd/nand/Kconfig @@ -81,6 +81,12 @@ config MTD_NAND_TS7250 help Support for NAND flash on Technologic Systems TS-7250 platform. @@ -15,10 +15,10 @@ Index: linux-2.6.22-rc6/drivers/mtd/nand/Kconfig config MTD_NAND_IDS tristate -Index: linux-2.6.22-rc6/drivers/mtd/nand/Makefile +Index: linux-2.6.22/drivers/mtd/nand/Makefile =================================================================== ---- linux-2.6.22-rc6.orig/drivers/mtd/nand/Makefile -+++ linux-2.6.22-rc6/drivers/mtd/nand/Makefile +--- linux-2.6.22.orig/drivers/mtd/nand/Makefile ++++ linux-2.6.22/drivers/mtd/nand/Makefile @@ -10,6 +10,7 @@ obj-$(CONFIG_MTD_NAND_CAFE) += cafe_nan obj-$(CONFIG_MTD_NAND_SPIA) += spia.o obj-$(CONFIG_MTD_NAND_AMS_DELTA) += ams-delta.o diff --git a/target/linux/adm5120eb-2.6/Makefile b/target/linux/adm5120eb-2.6/Makefile index 8b02fc86e..832d26923 100644 --- a/target/linux/adm5120eb-2.6/Makefile +++ b/target/linux/adm5120eb-2.6/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk ARCH:=mips BOARD:=adm5120eb BOARDNAME:=ADM5120 (Big Endian) -FEATURES:=squashfs pci usb +FEATURES:=squashfs pci usb broken LINUX_VERSION:=2.6.22.1 |