From 3260740c920ea811e18bc1743c863fce74ac89b7 Mon Sep 17 00:00:00 2001 From: florian Date: Mon, 2 Apr 2007 16:59:59 +0000 Subject: Add preliminary RouterBoard RB1xx support git-svn-id: svn://svn.openwrt.org/openwrt/trunk@6839 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- target/linux/rb1xx-2.6/patches/001-adm5120.patch | 64 ++ .../rb1xx-2.6/patches/002-adm5120_flash.patch | 25 + .../rb1xx-2.6/patches/003-adm5120_switch.patch | 25 + .../linux/rb1xx-2.6/patches/004-adm5120_uart.patch | 50 + .../linux/rb1xx-2.6/patches/005-adm5120_usb.patch | 53 + .../linux/rb1xx-2.6/patches/006-adm5120_gpio.patch | 25 + .../patches/100-mtd-myloder-partition-parser.patch | 37 + .../linux/rb1xx-2.6/patches/101-mtd-mxflash.patch | 31 + target/linux/rb1xx-2.6/patches/120-cf.patch | 1011 ++++++++++++++++++++ target/linux/rb1xx-2.6/patches/500-Nand.patch | 27 + 10 files changed, 1348 insertions(+) create mode 100644 target/linux/rb1xx-2.6/patches/001-adm5120.patch create mode 100644 target/linux/rb1xx-2.6/patches/002-adm5120_flash.patch create mode 100644 target/linux/rb1xx-2.6/patches/003-adm5120_switch.patch create mode 100644 target/linux/rb1xx-2.6/patches/004-adm5120_uart.patch create mode 100644 target/linux/rb1xx-2.6/patches/005-adm5120_usb.patch create mode 100644 target/linux/rb1xx-2.6/patches/006-adm5120_gpio.patch create mode 100644 target/linux/rb1xx-2.6/patches/100-mtd-myloder-partition-parser.patch create mode 100755 target/linux/rb1xx-2.6/patches/101-mtd-mxflash.patch create mode 100644 target/linux/rb1xx-2.6/patches/120-cf.patch create mode 100644 target/linux/rb1xx-2.6/patches/500-Nand.patch (limited to 'target/linux/rb1xx-2.6/patches') diff --git a/target/linux/rb1xx-2.6/patches/001-adm5120.patch b/target/linux/rb1xx-2.6/patches/001-adm5120.patch new file mode 100644 index 000000000..ed7a30744 --- /dev/null +++ b/target/linux/rb1xx-2.6/patches/001-adm5120.patch @@ -0,0 +1,64 @@ +diff -urN linux-2.6.19.2/arch/mips/Kconfig linux-2.6.19.2.new/arch/mips/Kconfig +--- linux-2.6.19.2/arch/mips/Kconfig 2007-01-10 20:10:37.000000000 +0100 ++++ linux-2.6.19.2.new/arch/mips/Kconfig 2007-01-23 14:49:38.000000000 +0100 +@@ -12,6 +12,18 @@ + prompt "System type" + default SGI_IP22 + ++config MIPS_ADM5120 ++ bool "Support for ADM5120 SoC" ++ select SYS_HAS_CPU_MIPS32_R1 ++ select DMA_NONCOHERENT ++ select HW_HAS_PCI ++ select SYS_SUPPORTS_LITTLE_ENDIAN ++ select SYS_SUPPORTS_32BIT_KERNEL ++ ++config PCI_ADM5120 ++ bool "Add PCI control support for ADM5120" ++ depends on MIPS_ADM5120 && PCI ++ + config MIPS_MTX1 + bool "4G Systems MTX-1 board" + select DMA_NONCOHERENT +diff -urN linux-2.6.19.2/arch/mips/Makefile linux-2.6.19.2.new/arch/mips/Makefile +--- linux-2.6.19.2/arch/mips/Makefile 2007-01-23 14:02:57.000000000 +0100 ++++ linux-2.6.19.2.new/arch/mips/Makefile 2007-01-23 14:49:39.000000000 +0100 +@@ -165,6 +165,14 @@ + load-$(CONFIG_MACH_JAZZ) += 0xffffffff80080000 + + # ++# ADMtek 5120 ++# ++ ++core-$(CONFIG_MIPS_ADM5120) += arch/mips/adm5120/ ++cflags-$(CONFIG_MIPS_ADM5120) += -Iinclude/asm-mips/mach-adm5120 ++load-$(CONFIG_MIPS_ADM5120) += 0xffffffff80101000 ++ ++# + # Common Alchemy Au1x00 stuff + # + core-$(CONFIG_SOC_AU1X00) += arch/mips/au1000/common/ +diff -urN linux-2.6.19.2/arch/mips/pci/Makefile linux-2.6.19.2.new/arch/mips/pci/Makefile +--- linux-2.6.19.2/arch/mips/pci/Makefile 2007-01-10 20:10:37.000000000 +0100 ++++ linux-2.6.19.2.new/arch/mips/pci/Makefile 2007-01-23 14:49:40.000000000 +0100 +@@ -53,3 +53,4 @@ + 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) += ops-adm5120.o pci-adm5120.o +diff -urN linux-2.6.19.2/include/asm-mips/bootinfo.h linux-2.6.19.2.new/include/asm-mips/bootinfo.h +--- linux-2.6.19.2/include/asm-mips/bootinfo.h 2007-01-10 20:10:37.000000000 +0100 ++++ linux-2.6.19.2.new/include/asm-mips/bootinfo.h 2007-01-23 14:49:40.000000000 +0100 +@@ -212,6 +212,12 @@ + #define MACH_GROUP_NEC_EMMA2RH 25 /* NEC EMMA2RH (was 23) */ + #define MACH_NEC_MARKEINS 0 /* NEC EMMA2RH Mark-eins */ + ++/* ++ * Valid machtype for group ADMtek ++ */ ++#define MACH_GROUP_ADM_GW 23 ++#define MACH_ADM_GW_5120 0 ++ + #define CL_SIZE COMMAND_LINE_SIZE + + const char *get_system_type(void); diff --git a/target/linux/rb1xx-2.6/patches/002-adm5120_flash.patch b/target/linux/rb1xx-2.6/patches/002-adm5120_flash.patch new file mode 100644 index 000000000..503a49567 --- /dev/null +++ b/target/linux/rb1xx-2.6/patches/002-adm5120_flash.patch @@ -0,0 +1,25 @@ +diff -urN linux-2.6.19.2/drivers/mtd/maps/Kconfig linux-2.6.19.2-adm5120/drivers/mtd/maps/Kconfig +--- linux-2.6.19.2/drivers/mtd/maps/Kconfig 2007-01-10 20:10:37.000000000 +0100 ++++ linux-2.6.19.2-adm5120/drivers/mtd/maps/Kconfig 2007-01-23 01:13:39.000000000 +0100 +@@ -622,5 +622,10 @@ + + This selection automatically selects the map_ram driver. + ++config MTD_ADM5120 ++ tristate "Map driver for ADMtek ADM5120 boards" ++ depends on MIPS_ADM5120 ++ select MTD_CFI_AMDSTD ++ + endmenu + +diff -urN linux-2.6.19.2/drivers/mtd/maps/Makefile linux-2.6.19.2-adm5120/drivers/mtd/maps/Makefile +--- linux-2.6.19.2/drivers/mtd/maps/Makefile 2007-01-10 20:10:37.000000000 +0100 ++++ linux-2.6.19.2-adm5120/drivers/mtd/maps/Makefile 2007-01-23 01:20:52.000000000 +0100 +@@ -43,6 +43,7 @@ + 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_LASAT) += lasat.o + obj-$(CONFIG_MTD_AUTCPU12) += autcpu12-nvram.o + obj-$(CONFIG_MTD_EDB7312) += edb7312.o diff --git a/target/linux/rb1xx-2.6/patches/003-adm5120_switch.patch b/target/linux/rb1xx-2.6/patches/003-adm5120_switch.patch new file mode 100644 index 000000000..f6fec30bc --- /dev/null +++ b/target/linux/rb1xx-2.6/patches/003-adm5120_switch.patch @@ -0,0 +1,25 @@ +diff -urN linux-2.6.19.2/drivers/net/Kconfig linux-2.6.19.2-adm5120/drivers/net/Kconfig +--- linux-2.6.19.2/drivers/net/Kconfig 2007-01-10 20:10:37.000000000 +0100 ++++ linux-2.6.19.2-adm5120/drivers/net/Kconfig 2007-01-23 01:13:39.000000000 +0100 +@@ -450,6 +450,10 @@ + If you have an Alchemy Semi AU1X00 based system + say Y. Otherwise, say N. + ++config MIPS_ADM5120_ENET ++ tristate "MIPS ADM5120 Ethernet switch support" ++ depends on NET_ETHERNET && MIPS_ADM5120 ++ + config NET_SB1250_MAC + tristate "SB1250 Ethernet support" + depends on NET_ETHERNET && SIBYTE_SB1xxx_SOC +diff -urN linux-2.6.19.2/drivers/net/Makefile linux-2.6.19.2-adm5120/drivers/net/Makefile +--- linux-2.6.19.2/drivers/net/Makefile 2007-01-10 20:10:37.000000000 +0100 ++++ linux-2.6.19.2-adm5120/drivers/net/Makefile 2007-01-23 01:13:39.000000000 +0100 +@@ -164,6 +164,7 @@ + # This is also a 82596 and should probably be merged + obj-$(CONFIG_LP486E) += lp486e.o + ++obj-$(CONFIG_MIPS_ADM5120_ENET) += adm5120sw.o + obj-$(CONFIG_ETH16I) += eth16i.o + obj-$(CONFIG_ZORRO8390) += zorro8390.o 8390.o + obj-$(CONFIG_HPLANCE) += hplance.o 7990.o diff --git a/target/linux/rb1xx-2.6/patches/004-adm5120_uart.patch b/target/linux/rb1xx-2.6/patches/004-adm5120_uart.patch new file mode 100644 index 000000000..6f2ef7bb3 --- /dev/null +++ b/target/linux/rb1xx-2.6/patches/004-adm5120_uart.patch @@ -0,0 +1,50 @@ +diff -urN linux-2.6.19.2/drivers/serial/Kconfig linux-2.6.19.2-adm5120/drivers/serial/Kconfig +--- linux-2.6.19.2/drivers/serial/Kconfig 2007-01-10 20:10:37.000000000 +0100 ++++ linux-2.6.19.2-adm5120/drivers/serial/Kconfig 2007-01-23 01:13:39.000000000 +0100 +@@ -246,6 +246,22 @@ + + comment "Non-8250 serial port support" + ++config SERIAL_ADM5120 ++ bool "ADM5120 serial port support" ++ depends on MIPS_ADM5120 ++ select SERIAL_CORE ++ select SERIAL_CORE_CONSOLE ++ help ++ Driver for the on chip UARTs on the ADM5120 SoC ++ ++config ADM5120_NR_UARTS ++ int "Maximum number of ADM5120 serial ports" ++ depends on SERIAL_ADM5120 ++ default "2" ++ ---help--- ++ Set this to the number of serial ports you want the driver to ++ support. ++ + config SERIAL_AMBA_PL010 + tristate "ARM AMBA PL010 serial port support" + depends on ARM_AMBA && (BROKEN || !ARCH_VERSATILE) +diff -urN linux-2.6.19.2/drivers/serial/Makefile linux-2.6.19.2-adm5120/drivers/serial/Makefile +--- linux-2.6.19.2/drivers/serial/Makefile 2007-01-10 20:10:37.000000000 +0100 ++++ linux-2.6.19.2-adm5120/drivers/serial/Makefile 2007-01-23 01:21:45.000000000 +0100 +@@ -20,6 +20,7 @@ + obj-$(CONFIG_SERIAL_8250_HUB6) += 8250_hub6.o + obj-$(CONFIG_SERIAL_8250_MCA) += 8250_mca.o + obj-$(CONFIG_SERIAL_8250_AU1X00) += 8250_au1x00.o ++obj-$(CONFIG_SERIAL_ADM5120) += adm5120_uart.o + obj-$(CONFIG_SERIAL_AMBA_PL010) += amba-pl010.o + obj-$(CONFIG_SERIAL_AMBA_PL011) += amba-pl011.o + obj-$(CONFIG_SERIAL_CLPS711X) += clps711x.o +diff -urN linux-2.6.19.2/include/linux/serial_core.h linux-2.6.19.2-adm5120/include/linux/serial_core.h +--- linux-2.6.19.2/include/linux/serial_core.h 2007-01-10 20:10:37.000000000 +0100 ++++ linux-2.6.19.2-adm5120/include/linux/serial_core.h 2007-01-23 01:13:39.000000000 +0100 +@@ -133,6 +133,9 @@ + #define PORT_S3C2412 73 + + ++/* ADMtek ADM5120 SoC */ ++#define PORT_ADM5120 68 ++ + #ifdef __KERNEL__ + + #include diff --git a/target/linux/rb1xx-2.6/patches/005-adm5120_usb.patch b/target/linux/rb1xx-2.6/patches/005-adm5120_usb.patch new file mode 100644 index 000000000..40e4fbedf --- /dev/null +++ b/target/linux/rb1xx-2.6/patches/005-adm5120_usb.patch @@ -0,0 +1,53 @@ +diff -urN linux-2.6.19.2/drivers/usb/core/hub.c linux-2.6.19.2-adm5120/drivers/usb/core/hub.c +--- linux-2.6.19.2/drivers/usb/core/hub.c 2007-01-10 20:10:37.000000000 +0100 ++++ linux-2.6.19.2-adm5120/drivers/usb/core/hub.c 2007-01-23 01:13:39.000000000 +0100 +@@ -2156,6 +2156,8 @@ + USB_DT_DEVICE << 8, 0, + buf, GET_DESCRIPTOR_BUFSIZE, + (i ? USB_CTRL_GET_TIMEOUT : 1000)); ++printk(KERN_CRIT "usb_control_msg: %d %d %d (%d)\n", r, buf->bMaxPacketSize0, ++buf->bDescriptorType, USB_DT_DEVICE); + switch (buf->bMaxPacketSize0) { + case 8: case 16: case 32: case 64: case 255: + if (buf->bDescriptorType == +diff -urN linux-2.6.19.2/drivers/usb/host/Kconfig linux-2.6.19.2-adm5120/drivers/usb/host/Kconfig +--- linux-2.6.19.2/drivers/usb/host/Kconfig 2007-01-10 20:10:37.000000000 +0100 ++++ linux-2.6.19.2-adm5120/drivers/usb/host/Kconfig 2007-01-23 01:13:39.000000000 +0100 +@@ -192,3 +192,6 @@ + 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 +diff -urN linux-2.6.19.2/drivers/usb/host/Makefile linux-2.6.19.2-adm5120/drivers/usb/host/Makefile +--- linux-2.6.19.2/drivers/usb/host/Makefile 2007-01-10 20:10:37.000000000 +0100 ++++ linux-2.6.19.2-adm5120/drivers/usb/host/Makefile 2007-01-23 01:13:39.000000000 +0100 +@@ -16,3 +16,4 @@ + obj-$(CONFIG_USB_SL811_CS) += sl811_cs.o + obj-$(CONFIG_USB_U132_HCD) += u132-hcd.o + obj-$(CONFIG_ETRAX_ARCH_V10) += hc_crisv10.o ++obj-$(CONFIG_USB_ADM5120_HCD) += adm5120-hcd.o +diff -urN linux-2.6.19.2/drivers/usb/Kconfig linux-2.6.19.2-adm5120/drivers/usb/Kconfig +--- linux-2.6.19.2/drivers/usb/Kconfig 2007-01-10 20:10:37.000000000 +0100 ++++ linux-2.6.19.2-adm5120/drivers/usb/Kconfig 2007-01-23 01:13:39.000000000 +0100 +@@ -91,8 +91,6 @@ + + source "drivers/usb/net/Kconfig" + +-source "drivers/usb/mon/Kconfig" +- + comment "USB port drivers" + depends on USB + +diff -urN linux-2.6.19.2/drivers/usb/Makefile linux-2.6.19.2-adm5120/drivers/usb/Makefile +--- linux-2.6.19.2/drivers/usb/Makefile 2007-01-10 20:10:37.000000000 +0100 ++++ linux-2.6.19.2-adm5120/drivers/usb/Makefile 2007-01-23 01:22:18.000000000 +0100 +@@ -17,6 +17,7 @@ + obj-$(CONFIG_USB_U132_HCD) += host/ + obj-$(CONFIG_ETRAX_USB_HOST) += host/ + obj-$(CONFIG_USB_OHCI_AT91) += host/ ++obj-$(CONFIG_USB_ADM5120_HCD) += host/ + + obj-$(CONFIG_USB_ACM) += class/ + obj-$(CONFIG_USB_PRINTER) += class/ diff --git a/target/linux/rb1xx-2.6/patches/006-adm5120_gpio.patch b/target/linux/rb1xx-2.6/patches/006-adm5120_gpio.patch new file mode 100644 index 000000000..593743d7b --- /dev/null +++ b/target/linux/rb1xx-2.6/patches/006-adm5120_gpio.patch @@ -0,0 +1,25 @@ +diff -urN linux-2.6.19.2/drivers/char/Kconfig linux-2.6.19.2-adm5120/drivers/char/Kconfig +--- linux-2.6.19.2/drivers/char/Kconfig 2007-01-10 20:10:37.000000000 +0100 ++++ linux-2.6.19.2-adm5120/drivers/char/Kconfig 2007-01-23 01:13:39.000000000 +0100 +@@ -1034,7 +1034,9 @@ + The mmtimer device allows direct userspace access to the + Altix system timer. + +-source "drivers/char/tpm/Kconfig" ++config ADM5120_GPIO ++ tristate "ADM5120 GPIO" ++ depends on MIPS_ADM5120 + + config TELCLOCK + tristate "Telecom clock driver for MPBL0010 ATCA SBC" +diff -urN linux-2.6.19.2/drivers/char/Makefile linux-2.6.19.2-adm5120/drivers/char/Makefile +--- linux-2.6.19.2/drivers/char/Makefile 2007-01-10 20:10:37.000000000 +0100 ++++ linux-2.6.19.2-adm5120/drivers/char/Makefile 2007-01-23 01:20:01.000000000 +0100 +@@ -90,6 +90,7 @@ + obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o + obj-$(CONFIG_TANBAC_TB0219) += tb0219.o + obj-$(CONFIG_TELCLOCK) += tlclk.o ++obj-$(CONFIG_ADM5120_GPIO) += adm5120_gpio.o + + obj-$(CONFIG_WATCHDOG) += watchdog/ + obj-$(CONFIG_MWAVE) += mwave/ diff --git a/target/linux/rb1xx-2.6/patches/100-mtd-myloder-partition-parser.patch b/target/linux/rb1xx-2.6/patches/100-mtd-myloder-partition-parser.patch new file mode 100644 index 000000000..81ec37d05 --- /dev/null +++ b/target/linux/rb1xx-2.6/patches/100-mtd-myloder-partition-parser.patch @@ -0,0 +1,37 @@ +diff -Nur linux-2.6.19.2/drivers/mtd/Kconfig.old linux-2.6.19.2/drivers/mtd/Kconfig +--- linux-2.6.19.2/drivers/mtd/Kconfig.old 2007-03-25 08:13:02.000000000 +0200 ++++ linux-2.6.19.2/drivers/mtd/Kconfig 2007-03-26 13:37:47.000000000 +0200 +@@ -157,6 +157,22 @@ + for your particular device. It won't happen automatically. The + 'armflash' map driver (CONFIG_MTD_ARMFLASH) does this, for example. + ++config MTD_MYLOADER_PARTS ++ tristate "MyLoader partition parsing" ++ depends on MIPS_ADM5120 && MTD_PARTITIONS ++ ---help--- ++ MyLoader is a bootloader which allows the user to define partitions ++ in flash devices, by putting a table in the second erase block ++ on the device, similar to a partition table. This table gives the ++ offsets and lengths of the user defined partitions. ++ ++ If you need code which can detect and parse these tables, and ++ register MTD 'partitions' corresponding to each image detected, ++ enable this option. ++ ++ You will still need the parsing functions to be called by the driver ++ for your particular device. It won't happen automatically. ++ + comment "User Modules And Translation Layers" + depends on MTD + +diff -Nur linux-2.6.19.2/drivers/mtd/Makefile.old linux-2.6.19.2/drivers/mtd/Makefile +--- linux-2.6.19.2/drivers/mtd/Makefile.old 2007-01-10 20:10:37.000000000 +0100 ++++ linux-2.6.19.2/drivers/mtd/Makefile 2007-03-26 13:28:23.000000000 +0200 +@@ -12,6 +12,7 @@ + obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o + obj-$(CONFIG_MTD_CMDLINE_PARTS) += cmdlinepart.o + obj-$(CONFIG_MTD_AFS_PARTS) += afs.o ++obj-$(CONFIG_MTD_MYLOADER_PARTS) += myloader.o + + # 'Users' - code which presents functionality to userspace. + obj-$(CONFIG_MTD_CHAR) += mtdchar.o diff --git a/target/linux/rb1xx-2.6/patches/101-mtd-mxflash.patch b/target/linux/rb1xx-2.6/patches/101-mtd-mxflash.patch new file mode 100755 index 000000000..754a91e09 --- /dev/null +++ b/target/linux/rb1xx-2.6/patches/101-mtd-mxflash.patch @@ -0,0 +1,31 @@ +--- linux-2.6.19.2/drivers/mtd/chips/Kconfig.old 2007-01-11 03:10:36.000000000 +0800 ++++ linux-2.6.19.2/drivers/mtd/chips/Kconfig 2007-03-29 14:43:32.000000000 +0800 +@@ -199,6 +199,14 @@ + provides support for one of those command sets, used on chips + including the AMD Am29LV320. + ++config MTD_CFI_AMDSTD_FORCE_BOTTOM_BOOT ++ bool "Force bottom boot for Macronix flash chips" ++ depends on MTD_CFI_AMDSTD ++ help ++ Some Macronix flash chips have wrong CFI info, and the driver may ++ detect the type incorrectly. Select this if the chip part number ++ ends with BTC. ++ + config MTD_CFI_STAA + tristate "Support for ST (Advanced Architecture) flash chips" + depends on MTD_GEN_PROBE +--- linux-2.6.19.2/drivers/mtd/chips/cfi_cmdset_0002.c.old 2007-03-22 16:14:56.000000000 +0800 ++++ linux-2.6.19.2/drivers/mtd/chips/cfi_cmdset_0002.c 2007-03-29 14:07:28.000000000 +0800 +@@ -320,6 +320,11 @@ + cfi_tell_features(extp); + #endif + ++#ifdef CONFIG_MTD_CFI_AMDSTD_FORCE_BOTTOM_BOOT ++ extp->TopBottom = 2; ++ bootloc = extp->TopBottom; ++#endif ++ + bootloc = extp->TopBottom; + if ((bootloc != 2) && (bootloc != 3)) { + printk(KERN_WARNING "%s: CFI does not contain boot " diff --git a/target/linux/rb1xx-2.6/patches/120-cf.patch b/target/linux/rb1xx-2.6/patches/120-cf.patch new file mode 100644 index 000000000..a22c52613 --- /dev/null +++ b/target/linux/rb1xx-2.6/patches/120-cf.patch @@ -0,0 +1,1011 @@ +diff -urN linux.old/drivers/block/Kconfig linux.dev/drivers/block/Kconfig +--- linux.old/drivers/block/Kconfig 2006-10-26 02:43:39.000000000 +0200 ++++ linux.dev/drivers/block/Kconfig 2006-10-26 00:11:14.000000000 +0200 +@@ -456,4 +456,12 @@ + This driver provides Support for ATA over Ethernet block + devices like the Coraid EtherDrive (R) Storage Blade. + ++config BLK_DEV_CF_MIPS ++ bool "CF slot of RB532 board" ++ depends on MIKROTIK_RB500 || MIPS_ADM5120 ++ default y ++ help ++ The Routerboard 532 has a CF slot on it. Enable the special block ++ device driver for it. ++ + endmenu +diff -urN linux.old/drivers/block/Makefile linux.dev/drivers/block/Makefile +--- linux.old/drivers/block/Makefile 2006-06-18 03:49:35.000000000 +0200 ++++ linux.dev/drivers/block/Makefile 2006-10-26 02:44:10.000000000 +0200 +@@ -29,4 +29,5 @@ + obj-$(CONFIG_VIODASD) += viodasd.o + obj-$(CONFIG_BLK_DEV_SX8) += sx8.o + obj-$(CONFIG_BLK_DEV_UB) += ub.o ++obj-$(CONFIG_BLK_DEV_CF_MIPS) += rb500/ + +diff -urN linux.old/drivers/block/rb500/ata.c linux.dev/drivers/block/rb500/ata.c +--- linux.old/drivers/block/rb500/ata.c 1970-01-01 01:00:00.000000000 +0100 ++++ linux.dev/drivers/block/rb500/ata.c 2006-10-26 00:11:14.000000000 +0200 +@@ -0,0 +1,485 @@ ++/* CF-mips driver ++ This is a block driver for the direct (mmaped) interface to the CF-slot, ++ found in Routerboard.com's RB532 board ++ See SDK provided from routerboard.com. ++ ++ Module adapted By P.Christeas , 2005-6. ++ Cleaned up and adapted to platform_device by Felix Fietkau ++ ++ This work is redistributed under the terms of the GNU General Public License. ++*/ ++ ++#include /* printk() */ ++#include /* module to be loadable */ ++#include ++#include ++#include ++#include /* request_mem_region() */ ++#include /* ioremap() */ ++#include /* ioremap() */ ++#include ++ ++#include "ata.h" ++ ++#define REQUEST_MEM_REGION 0 ++#define DEBUG 1 ++ ++#if DEBUG ++#define DEBUGP printk ++#else ++#define DEBUGP(format, args...) ++#endif ++ ++#define SECS 1000000 /* unit for wait_not_busy() is 1us */ ++ ++unsigned cf_head = 0; ++unsigned cf_cyl = 0; ++unsigned cf_spt = 0; ++unsigned cf_sectors = 0; ++static unsigned cf_block_size = 1; ++static void *baddr = 0; ++ ++#define DBUF32 ((volatile u32 *)((unsigned long)dev->baddr | ATA_DBUF_OFFSET)) ++ ++ ++static void cf_do_tasklet(unsigned long dev_l); ++ ++ ++static inline void wareg(u8 val, unsigned reg, struct cf_mips_dev* dev) ++{ ++ writeb(val, dev->baddr + ATA_REG_OFFSET + reg); ++} ++ ++static inline u8 rareg(unsigned reg, struct cf_mips_dev* dev) ++{ ++ return readb(dev->baddr + ATA_REG_OFFSET + reg); ++} ++ ++static inline int get_gpio_bit(gpio_func ofs, struct cf_mips_dev *dev) ++{ ++ return (gpio_get(ofs) >> dev->pin) & 1; ++} ++ ++static inline void set_gpio_bit(int bit, gpio_func ofs, struct cf_mips_dev *dev) ++{ ++ gpio_set(ofs, (1 << dev->pin), ((bit & 1) << dev->pin)); ++} ++ ++static inline int cfrdy(struct cf_mips_dev *dev) ++{ ++ return get_gpio_bit(DATA, dev); ++} ++ ++static inline void prepare_cf_irq(struct cf_mips_dev *dev) ++{ ++ set_gpio_bit(1, ILEVEL, dev); /* interrupt on cf ready (not busy) */ ++ set_gpio_bit(0, ISTAT, dev); /* clear interrupt status */ ++} ++ ++static inline int cf_present(struct cf_mips_dev* dev) ++{ ++ /* TODO: read and configure CIS into memory mapped mode ++ * TODO: parse CISTPL_CONFIG on CF+ cards to get base address (0x200) ++ * TODO: maybe adjust power saving setting for Hitachi Microdrive ++ */ ++ int i; ++ ++ /* setup CFRDY GPIO as input */ ++ set_gpio_bit(0, FUNC, dev); ++ set_gpio_bit(0, CFG, dev); ++ ++ for (i = 0; i < 0x10; ++i) { ++ if (rareg(i,dev) != 0xff) ++ return 1; ++ } ++ return 0; ++} ++ ++static inline int is_busy(struct cf_mips_dev *dev) ++{ ++ return !cfrdy(dev); ++} ++ ++static int wait_not_busy(int to_us, int wait_for_busy,struct cf_mips_dev *dev) ++{ ++ int us_passed = 0; ++ if (wait_for_busy && !is_busy(dev)) { ++ /* busy must appear within 400ns, ++ * but it may dissapear before we see it ++ * => must not wait for busy in a loop ++ */ ++ ndelay(400); ++ } ++ ++ do { ++ if (us_passed) ++ udelay(1); /* never reached in async mode */ ++ if (!is_busy(dev)) { ++ if (us_passed > 1 * SECS) { ++ printk(KERN_WARNING "cf-mips: not busy ok (after %dus)" ++ ", status 0x%02x\n", us_passed, (unsigned) rareg(ATA_REG_ST,dev)); ++ } ++ return CF_TRANS_OK; ++ } ++ if (us_passed == 1 * SECS) { ++ printk(KERN_WARNING "cf-mips: wait not busy %dus..\n", to_us); ++ } ++ if (dev->async_mode) { ++ dev->to_timer.expires = jiffies + (to_us * HZ / SECS); ++ dev->irq_enable_time = jiffies; ++ prepare_cf_irq(dev); ++ if (is_busy(dev)) { ++ add_timer(&dev->to_timer); ++ enable_irq(dev->irq); ++ return CF_TRANS_IN_PROGRESS; ++ } ++ continue; ++ } ++ ++us_passed; ++ } while (us_passed < to_us); ++ ++ printk(KERN_ERR "cf-mips: wait not busy timeout (%dus)" ++ ", status 0x%02x, state %d\n", ++ to_us, (unsigned) rareg(ATA_REG_ST,dev), dev->tstate); ++ return CF_TRANS_FAILED; ++} ++ ++static irqreturn_t cf_irq_handler(int irq, void *dev_id) ++{ ++ /* While tasklet has not disabled irq, irq will be retried all the time ++ * because of ILEVEL matching GPIO pin status => deadlock. ++ * To avoid this, we change ILEVEL to 0. ++ */ ++ struct cf_mips_dev *dev=dev_id; ++ ++ set_gpio_bit(0, ILEVEL, dev); ++ set_gpio_bit(0, ISTAT, dev); ++ ++ del_timer(&dev->to_timer); ++ tasklet_schedule(&dev->tasklet); ++ return IRQ_HANDLED; ++} ++ ++static int do_reset(struct cf_mips_dev *dev) ++{ ++ printk(KERN_INFO "cf-mips: resetting..\n"); ++ ++ wareg(ATA_REG_DC_SRST, ATA_REG_DC,dev); ++ udelay(1); /* FIXME: how long should we wait here? */ ++ wareg(0, ATA_REG_DC,dev); ++ ++ return wait_not_busy(30 * SECS, 1,dev); ++} ++ ++static int set_multiple(struct cf_mips_dev *dev) ++{ ++ if (dev->block_size <= 1) ++ return CF_TRANS_OK; ++ ++ wareg(dev->block_size, ATA_REG_SC,dev); ++ wareg(ATA_REG_DH_BASE | ATA_REG_DH_LBA, ATA_REG_DH,dev); ++ wareg(ATA_CMD_SET_MULTIPLE, ATA_REG_CMD,dev); ++ ++ return wait_not_busy(10 * SECS, 1,dev); ++} ++ ++static int set_cmd(struct cf_mips_dev *dev) ++{ ++ //DEBUGP(KERN_INFO "cf-mips: ata cmd 0x%02x\n", dev->tcmd); ++ // sector_count should be <=24 bits.. ++ BUG_ON(dev->tsect_start>=0x10000000); ++ // This way, it addresses 2^24 * 512 = 128G ++ ++ if (dev->tsector_count) { ++ wareg(dev->tsector_count & 0xff, ATA_REG_SC,dev); ++ wareg(dev->tsect_start & 0xff, ATA_REG_SN,dev); ++ wareg((dev->tsect_start >> 8) & 0xff, ATA_REG_CL,dev); ++ wareg((dev->tsect_start >> 16) & 0xff, ATA_REG_CH,dev); ++ } ++ wareg(((dev->tsect_start >> 24) & 0x0f) | ATA_REG_DH_BASE | ATA_REG_DH_LBA, ++ ATA_REG_DH,dev); /* select drive on all commands */ ++ wareg(dev->tcmd, ATA_REG_CMD,dev); ++ return wait_not_busy(10 * SECS, 1,dev); ++} ++ ++static int do_trans(struct cf_mips_dev *dev) ++{ ++ int res; ++ unsigned st; ++ int transfered; ++ ++ //printk("do_trans: %d sectors left\n",dev->tsectors_left); ++ while (dev->tsectors_left) { ++ transfered = 0; ++ ++ st = rareg(ATA_REG_ST,dev); ++ if (!(st & ATA_REG_ST_DRQ)) { ++ printk(KERN_ERR "cf-mips: do_trans without DRQ (status 0x%x)!\n", st); ++ if (st & ATA_REG_ST_ERR) { ++ int errId = rareg(ATA_REG_ERR,dev); ++ printk(KERN_ERR "cf-mips: %s error, status 0x%x, errid 0x%x\n", ++ (dev->tread ? "read" : "write"), st, errId); ++ } ++ return CF_TRANS_FAILED; ++ } ++ do { /* Fill/read the buffer one block */ ++ u32 *qbuf, *qend; ++ qbuf = (u32 *)dev->tbuf; ++ qend = qbuf + CF_SECT_SIZE / sizeof(u32); ++ if (dev->tread) { ++ while (qbuf!=qend) ++ put_unaligned(*DBUF32,qbuf++); ++ //*(qbuf++) = *DBUF32; ++ } ++ else { ++ while(qbuf!=qend) ++ *DBUF32 = get_unaligned(qbuf++); ++ } ++ ++ dev->tsectors_left--; ++ dev->tbuf += CF_SECT_SIZE; ++ dev->tbuf_size -= CF_SECT_SIZE; ++ transfered++; ++ } while (transfered != dev->block_size && dev->tsectors_left > 0); ++ ++ res = wait_not_busy(10 * SECS, 1,dev); ++ if (res != CF_TRANS_OK) ++ return res; ++ }; ++ ++ st = rareg(ATA_REG_ST,dev); ++ if (st & (ATA_REG_ST_DRQ | ATA_REG_ST_DWF | ATA_REG_ST_ERR)) { ++ if (st & ATA_REG_ST_DRQ) { ++ printk(KERN_ERR "cf-mips: DRQ after all %d sectors are %s" ++ ", status 0x%x\n", dev->tsector_count, (dev->tread ? "read" : "written"), st); ++ } else if (st & ATA_REG_ST_DWF) { ++ printk(KERN_ERR "cf-mips: write fault, status 0x%x\n", st); ++ } else { ++ int errId = rareg(ATA_REG_ERR,dev); ++ printk(KERN_ERR "cf-mips: %s error, status 0x%x, errid 0x%x\n", ++ (dev->tread ? "read" : "write"), st, errId); ++ } ++ return CF_TRANS_FAILED; ++ } ++ return CF_TRANS_OK; ++} ++ ++static int cf_do_state(struct cf_mips_dev *dev) ++{ ++ int res; ++ switch (dev->tstate) { /* fall through everywhere */ ++ case TS_IDLE: ++ dev->tstate = TS_READY; ++ if (is_busy(dev)) { ++ dev->tstate = TS_AFTER_RESET; ++ res = do_reset(dev); ++ if (res != CF_TRANS_OK) ++ break; ++ } ++ case TS_AFTER_RESET: ++ if (dev->tstate == TS_AFTER_RESET) { ++ dev->tstate = TS_READY; ++ res = set_multiple(dev); ++ if (res != CF_TRANS_OK) ++ break; ++ } ++ case TS_READY: ++ dev->tstate = TS_CMD; ++ res = set_cmd(dev); ++ if (res != CF_TRANS_OK) ++ break;; ++ case TS_CMD: ++ dev->tstate = TS_TRANS; ++ case TS_TRANS: ++ res = do_trans(dev); ++ break; ++ default: ++ printk(KERN_ERR "cf-mips: BUG: unknown tstate %d\n", dev->tstate); ++ return CF_TRANS_FAILED; ++ } ++ if (res != CF_TRANS_IN_PROGRESS) ++ dev->tstate = TS_IDLE; ++ return res; ++} ++ ++static void cf_do_tasklet(unsigned long dev_l) ++{ ++ struct cf_mips_dev* dev=(struct cf_mips_dev*) dev_l; ++ int res; ++ ++ disable_irq(dev->irq); ++ ++ if (dev->tstate == TS_IDLE) ++ return; /* can happen when irq is first registered */ ++ ++#if 0 ++ DEBUGP(KERN_WARNING "cf-mips: not busy ok (tasklet) status 0x%02x\n", ++ (unsigned) rareg(ATA_REG_ST,dev)); ++#endif ++ ++ res = cf_do_state(dev); ++ if (res == CF_TRANS_IN_PROGRESS) ++ return; ++ cf_async_trans_done(dev,res); ++} ++ ++static void cf_async_timeout(unsigned long dev_l) ++{ ++ struct cf_mips_dev* dev=(struct cf_mips_dev*) dev_l; ++ disable_irq(dev->irq); ++ /* Perhaps send abort to the device? */ ++ printk(KERN_ERR "cf-mips: wait not busy timeout (%lus)" ++ ", status 0x%02x, state %d\n", ++ jiffies - dev->irq_enable_time, (unsigned) rareg(ATA_REG_ST,dev), dev->tstate); ++ dev->tstate = TS_IDLE; ++ cf_async_trans_done(dev,CF_TRANS_FAILED); ++} ++ ++int cf_do_transfer(struct cf_mips_dev* dev,sector_t sector, unsigned long nsect, ++ char* buffer, int is_write) ++{ ++ BUG_ON(dev->tstate!=TS_IDLE); ++ if (nsect > ATA_MAX_SECT_PER_CMD) { ++ printk(KERN_WARNING "cf-mips: sector count %lu out of range\n",nsect); ++ return CF_TRANS_FAILED; ++ } ++ if (sector + nsect > dev->sectors) { ++ printk(KERN_WARNING "cf-mips: sector %lu out of range\n",sector); ++ return CF_TRANS_FAILED; ++ } ++ dev->tbuf = buffer; ++ dev->tbuf_size = nsect*512; ++ dev->tsect_start = sector; ++ dev->tsector_count = nsect; ++ dev->tsectors_left = dev->tsector_count; ++ dev->tread = (is_write)?0:1; ++ ++ dev->tcmd = (dev->block_size == 1 ? ++ (is_write ? ATA_CMD_WRITE_SECTORS : ATA_CMD_READ_SECTORS) : ++ (is_write ? ATA_CMD_WRITE_MULTIPLE : ATA_CMD_READ_MULTIPLE)); ++ ++ return cf_do_state(dev); ++} ++ ++static int do_identify(struct cf_mips_dev *dev) ++{ ++ u16 sbuf[CF_SECT_SIZE >> 1]; ++ int res; ++ char tstr[17]; //serial ++ BUG_ON(dev->tstate!=TS_IDLE); ++ dev->tbuf = (char *) sbuf; ++ dev->tbuf_size = CF_SECT_SIZE; ++ dev->tsect_start = 0; ++ dev->tsector_count = 0; ++ dev->tsectors_left = 1; ++ dev->tread = 1; ++ dev->tcmd = ATA_CMD_IDENTIFY_DRIVE; ++ ++ DEBUGP(KERN_INFO "cf-mips: identify drive..\n"); ++ res = cf_do_state(dev); ++ if (res == CF_TRANS_IN_PROGRESS) { ++ printk(KERN_ERR "cf-mips: BUG: async identify cmd\n"); ++ return CF_TRANS_FAILED; ++ } ++ if (res != CF_TRANS_OK) ++ return 0; ++ ++ dev->head = sbuf[3]; ++ dev->cyl = sbuf[1]; ++ dev->spt = sbuf[6]; ++ dev->sectors = ((unsigned long) sbuf[7] << 16) | sbuf[8]; ++ dev->dtype=sbuf[0]; ++ memcpy(tstr,&sbuf[12],16); ++ tstr[16]=0; ++ printk(KERN_INFO "cf-mips: %s detected, C/H/S=%d/%d/%d sectors=%u (%uMB) Serial=%s\n", ++ (sbuf[0] == 0x848A ? "CF card" : "ATA drive"), dev->cyl, dev->head, ++ dev->spt, dev->sectors, dev->sectors >> 11,tstr); ++ return 1; ++} ++ ++static void init_multiple(struct cf_mips_dev * dev) ++{ ++ int res; ++ DEBUGP(KERN_INFO "cf-mips: detecting block size\n"); ++ ++ dev->block_size = 128; /* max block size = 128 sectors (64KB) */ ++ do { ++ wareg(dev->block_size, ATA_REG_SC,dev); ++ wareg(ATA_REG_DH_BASE | ATA_REG_DH_LBA, ATA_REG_DH,dev); ++ wareg(ATA_CMD_SET_MULTIPLE, ATA_REG_CMD,dev); ++ ++ res = wait_not_busy(10 * SECS, 1,dev); ++ if (res != CF_TRANS_OK) { ++ printk(KERN_ERR "cf-mips: failed to detect block size: busy!\n"); ++ dev->block_size = 1; ++ return; ++ } ++ if ((rareg(ATA_REG_ST,dev) & ATA_REG_ST_ERR) == 0) ++ break; ++ dev->block_size /= 2; ++ } while (dev->block_size > 1); ++ ++ printk(KERN_INFO "cf-mips: multiple sectors = %d\n", dev->block_size); ++} ++ ++int cf_init(struct cf_mips_dev *dev) ++{ ++ tasklet_init(&dev->tasklet,cf_do_tasklet,(unsigned long)dev); ++ dev->baddr = ioremap_nocache((unsigned long)dev->base, CFDEV_BUF_SIZE); ++ if (!dev->baddr) { ++ printk(KERN_ERR "cf-mips: cf_init: ioremap for (%lx,%x) failed\n", ++ (unsigned long) dev->base, CFDEV_BUF_SIZE); ++ return -EBUSY; ++ } ++ ++ if (!cf_present(dev)) { ++ printk(KERN_WARNING "cf-mips: cf card not present\n"); ++ iounmap(dev->baddr); ++ return -ENODEV; ++ } ++ ++ if (do_reset(dev) != CF_TRANS_OK) { ++ printk(KERN_ERR "cf-mips: cf reset failed\n"); ++ iounmap(dev->baddr); ++ return -EBUSY; ++ } ++ ++ if (!do_identify(dev)) { ++ printk(KERN_ERR "cf-mips: cf identify failed\n"); ++ iounmap(dev->baddr); ++ return -EBUSY; ++ } ++ ++/* set_apm_level(ATA_APM_WITH_STANDBY); */ ++ init_multiple(dev); ++ ++ init_timer(&dev->to_timer); ++ dev->to_timer.function = cf_async_timeout; ++ dev->to_timer.data = (unsigned long)dev; ++ ++ prepare_cf_irq(dev); ++ if (request_irq(dev->irq, cf_irq_handler, 0, "CF Mips", dev)) { ++ printk(KERN_ERR "cf-mips: failed to get irq\n"); ++ iounmap(dev->baddr); ++ return -EBUSY; ++ } ++ /* Disable below would be odd, because request will enable, and the tasklet ++ will disable it itself */ ++ //disable_irq(dev->irq); ++ ++ dev->async_mode = 1; ++ ++ return 0; ++} ++ ++void cf_cleanup(struct cf_mips_dev *dev) ++{ ++ iounmap(dev->baddr); ++ free_irq(dev->irq, NULL); ++#if REQUEST_MEM_REGION ++ release_mem_region((unsigned long)dev->base, CFDEV_BUF_SIZE); ++#endif ++} ++ ++ ++/*eof*/ +diff -urN linux.old/drivers/block/rb500/ata.h linux.dev/drivers/block/rb500/ata.h +--- linux.old/drivers/block/rb500/ata.h 1970-01-01 01:00:00.000000000 +0100 ++++ linux.dev/drivers/block/rb500/ata.h 2006-10-26 00:11:14.000000000 +0200 +@@ -0,0 +1,143 @@ ++/* CF-mips driver ++ This is a block driver for the direct (mmaped) interface to the CF-slot, ++ found in Routerboard.com's RB532 board ++ See SDK provided from routerboard.com. ++ ++ Module adapted By P.Christeas , 2005-6. ++ Cleaned up and adapted to platform_device by Felix Fietkau ++ ++ This work is redistributed under the terms of the GNU General Public License. ++*/ ++ ++#ifndef __CFMIPS_ATA_H__ ++#define __CFMIPS_ATA_H__ ++ ++#include ++ ++#define CFG_DC_DEV1 (void*)0xb8010010 ++#define CFG_DC_DEVBASE 0x0 ++#define CFG_DC_DEVMASK 0x4 ++#define CFG_DC_DEVC 0x8 ++#define CFG_DC_DEVTC 0xC ++ ++#define CFDEV_BUF_SIZE 0x1000 ++#define ATA_CIS_OFFSET 0x200 ++#define ATA_REG_OFFSET 0x800 ++#define ATA_DBUF_OFFSET 0xC00 ++ ++#define ATA_REG_FEAT 0x1 ++#define ATA_REG_SC 0x2 ++#define ATA_REG_SN 0x3 ++#define ATA_REG_CL 0x4 ++#define ATA_REG_CH 0x5 ++#define ATA_REG_DH 0x6 ++#define ATA_REG_DH_BASE 0xa0 ++#define ATA_REG_DH_LBA 0x40 ++#define ATA_REG_DH_DRV 0x10 ++#define ATA_REG_CMD 0x7 ++#define ATA_REG_ST 0x7 ++#define ATA_REG_ST_BUSY 0x80 ++#define ATA_REG_ST_RDY 0x40 ++#define ATA_REG_ST_DWF 0x20 ++#define ATA_REG_ST_DSC 0x10 ++#define ATA_REG_ST_DRQ 0x08 ++#define ATA_REG_ST_CORR 0x04 ++#define ATA_REG_ST_ERR 0x01 ++#define ATA_REG_ERR 0xd ++#define ATA_REG_DC 0xe ++#define ATA_REG_DC_IEN 0x02 ++#define ATA_REG_DC_SRST 0x04 ++ ++#define ATA_CMD_READ_SECTORS 0x20 ++#define ATA_CMD_WRITE_SECTORS 0x30 ++#define ATA_CMD_EXEC_DRIVE_DIAG 0x90 ++#define ATA_CMD_READ_MULTIPLE 0xC4 ++#define ATA_CMD_WRITE_MULTIPLE 0xC5 ++#define ATA_CMD_SET_MULTIPLE 0xC6 ++#define ATA_CMD_IDENTIFY_DRIVE 0xEC ++#define ATA_CMD_SET_FEATURES 0xEF ++ ++#define ATA_FEATURE_ENABLE_APM 0x05 ++#define ATA_FEATURE_DISABLE_APM 0x85 ++#define ATA_APM_DISABLED 0x00 ++#define ATA_APM_MIN_POWER 0x01 ++#define ATA_APM_WITH_STANDBY 0x7f ++#define ATA_APM_WITHOUT_STANDBY 0x80 ++#define ATA_APM_MAX_PERFORMANCE 0xfe ++ ++#define CF_SECT_SIZE 0x200 ++/* That is the ratio CF_SECT_SIZE/512 (the kernel sector size) */ ++#define CF_KERNEL_MUL 1 ++#define ATA_MAX_SECT_PER_CMD 0x100 ++ ++#define CF_TRANS_FAILED 0 ++#define CF_TRANS_OK 1 ++#define CF_TRANS_IN_PROGRESS 2 ++ ++ ++enum trans_state { ++ TS_IDLE = 0, ++ TS_AFTER_RESET, ++ TS_READY, ++ TS_CMD, ++ TS_TRANS ++}; ++ ++// ++// #if DEBUG ++// static unsigned long busy_time; ++// #endif ++ ++/** Struct to hold the cfdev ++Actually, all the data here only has one instance. However, for ++reasons of programming conformity, it is passed around as a pointer ++*/ ++struct cf_mips_dev { ++ void *base; /* base address for I/O */ ++ void *baddr; /* remapped address */ ++ ++ int pin; /* gpio pin */ ++ int irq; /* gpio irq */ ++ ++ unsigned head; ++ unsigned cyl; ++ unsigned spt; ++ unsigned sectors; ++ ++ unsigned short block_size; ++ unsigned dtype ; // ATA or CF ++ struct request_queue *queue; ++ struct gendisk *gd; ++ ++ /* Transaction state */ ++ enum trans_state tstate; ++ char *tbuf; ++ unsigned long tbuf_size; ++ sector_t tsect_start; ++ unsigned tsector_count; ++ unsigned tsectors_left; ++ int tread; ++ unsigned tcmd; ++ int async_mode; ++ unsigned long irq_enable_time; ++ ++ struct request *active_req; /* A request is being carried out. Is that different from tstate? */ ++ int users; ++ struct timer_list to_timer; ++ struct tasklet_struct tasklet; ++ ++ /** This lock ensures that the requests to this device are all done ++ atomically. Transfers can run in parallel, requests are all queued ++ one-by-one */ ++ spinlock_t lock; ++}; ++ ++int cf_do_transfer(struct cf_mips_dev* dev,sector_t sector, unsigned long nsect, ++ char* buffer, int is_write); ++int cf_init(struct cf_mips_dev* dev); ++void cf_cleanup(struct cf_mips_dev* dev); ++ ++void cf_async_trans_done(struct cf_mips_dev* dev, int result); ++// void *cf_get_next_buf(unsigned long *buf_size); ++ ++#endif +diff -urN linux.old/drivers/block/rb500/bdev.c linux.dev/drivers/block/rb500/bdev.c +--- linux.old/drivers/block/rb500/bdev.c 1970-01-01 01:00:00.000000000 +0100 ++++ linux.dev/drivers/block/rb500/bdev.c 2006-10-26 00:11:14.000000000 +0200 +@@ -0,0 +1,339 @@ ++/* CF-mips driver ++ This is a block driver for the direct (mmaped) interface to the CF-slot, ++ found in Routerboard.com's RB532 board ++ See SDK provided from routerboard.com. ++ ++ Module adapted By P.Christeas , 2005-6. ++ Cleaned up and adapted to platform_device by Felix Fietkau ++ ++ This work is redistributed under the terms of the GNU General Public License. ++*/ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include ++#include ++ ++#include ++ ++#ifdef DEBUG ++#define DEBUGP printk ++#define DLEVEL 1 ++#else ++#define DEBUGP(format, args...) ++#define DLEVEL 0 ++#endif ++ ++#define CF_MIPS_MAJOR 13 ++#define MAJOR_NR CF_MIPS_MAJOR ++#define CF_MAX_PART 16 /* max 15 partitions */ ++ ++#include "ata.h" ++ ++//extern struct block_device_operations cf_bdops; ++ ++// static struct hd_struct cf_parts[CF_MAX_PART]; ++// static int cf_part_sizes[CF_MAX_PART]; ++// static int cf_hsect_sizes[CF_MAX_PART]; ++// static int cf_max_sectors[CF_MAX_PART]; ++// static int cf_blksize_sizes[CF_MAX_PART]; ++ ++// static spinlock_t lock = SPIN_LOCK_UNLOCKED; ++ ++// volatile int cf_busy = 0; ++ ++static struct request *active_req = NULL; ++ ++static int cf_open (struct inode *, struct file *); ++static int cf_release (struct inode *, struct file *); ++static int cf_ioctl (struct inode *, struct file *, unsigned, unsigned long); ++ ++static void cf_request(request_queue_t * q); ++static int cf_transfer(const struct request *req); ++ ++/*long (*unlocked_ioctl) (struct file *, unsigned, unsigned long); ++long (*compat_ioctl) (struct file *, unsigned, unsigned long);*/ ++// int (*direct_access) (struct block_device *, sector_t, unsigned long *); ++// int (*media_changed) (struct gendisk *); ++// int (*revalidate_disk) (struct gendisk *); ++ ++static struct block_device_operations cf_bdops = { ++ .owner = THIS_MODULE, ++ .open = cf_open, ++ .release = cf_release, ++ .ioctl = cf_ioctl, ++ .media_changed = NULL, ++ .unlocked_ioctl = NULL, ++ .revalidate_disk = NULL, ++ .compat_ioctl = NULL, ++ .direct_access = NULL ++}; ++ ++ ++int cf_mips_probe(struct platform_device *pdev) ++{ ++ struct gendisk* cf_gendisk=NULL; ++ struct cf_device *cdev = (struct cf_device *) pdev->dev.platform_data; ++ struct cf_mips_dev *dev; ++ struct resource *r; ++ int reg_result; ++ ++ reg_result = register_blkdev(MAJOR_NR, "cf-mips"); ++ if (reg_result < 0) { ++ printk(KERN_WARNING "cf-mips: can't get major %d\n", MAJOR_NR); ++ return reg_result; ++ } ++ ++ dev = (struct cf_mips_dev *)kmalloc(sizeof(struct cf_mips_dev),GFP_KERNEL); ++ if (!dev) ++ goto out_err; ++ memset(dev, 0, sizeof(struct cf_mips_dev)); ++ cdev->dev = dev; ++ ++ dev->pin = cdev->gpio_pin; ++ dev->irq = platform_get_irq_byname(pdev, "cf_irq"); ++ r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cf_membase"); ++ dev->base = (void *) r->start; ++ ++ if (cf_init(dev)) goto out_err; ++ printk("init done"); ++ ++ spin_lock_init(&dev->lock); ++ dev->queue = blk_init_queue(cf_request,&dev->lock); ++ if (!dev->queue){ ++ printk(KERN_ERR "cf-mips: no mem for queue\n"); ++ goto out_err; ++ } ++ blk_queue_max_sectors(dev->queue,ATA_MAX_SECT_PER_CMD); ++ ++ /* For memory devices, it is always better to avoid crossing segments ++ inside the same request. */ ++/* if (dev->dtype==0x848A){ ++ printk(KERN_INFO "Setting boundary for cf to 0x%x",(dev->block_size*512)-1); ++ blk_queue_segment_boundary(dev->queue, (dev->block_size*512)-1); ++ }*/ ++ ++ dev->gd = alloc_disk(CF_MAX_PART); ++ cf_gendisk = dev->gd; ++ cdev->gd = dev->gd; ++ if (!cf_gendisk) goto out_err; /* Last of these goto's */ ++ ++ cf_gendisk->major = MAJOR_NR; ++ cf_gendisk->first_minor = 0; ++ cf_gendisk->queue=dev->queue; ++ BUG_ON(cf_gendisk->minors != CF_MAX_PART); ++ strcpy(cf_gendisk->disk_name,"cfa"); ++ cf_gendisk->fops = &cf_bdops; ++ cf_gendisk->flags = 0 ; /* is not yet GENHD_FL_REMOVABLE */ ++ cf_gendisk->private_data=dev; ++ ++ set_capacity(cf_gendisk,dev->sectors * CF_KERNEL_MUL); ++ ++ /* Let the disk go live */ ++ add_disk(cf_gendisk); ++#if 0 ++ result = cf_init(); ++ ++ /* default cfg for all partitions */ ++ memset(cf_parts, 0, sizeof (cf_parts[0]) * CF_MAX_PART); ++ memset(cf_part_sizes, 0, sizeof (cf_part_sizes[0]) * CF_MAX_PART); ++ for (i = 0; i < CF_MAX_PART; ++i) { ++ cf_hsect_sizes[i] = CF_SECT_SIZE; ++ cf_max_sectors[i] = ATA_MAX_SECT_PER_CMD; ++ cf_blksize_sizes[i] = BLOCK_SIZE; ++ } ++ ++ /* setup info for whole disk (partition 0) */ ++ cf_part_sizes[0] = cf_sectors / 2; ++ cf_parts[0].nr_sects = cf_sectors; ++ ++ blk_size[MAJOR_NR] = cf_part_sizes; ++ blksize_size[MAJOR_NR] = cf_blksize_sizes; ++ max_sectors[MAJOR_NR] = cf_max_sectors; ++ hardsect_size[MAJOR_NR] = cf_hsect_sizes; ++ read_ahead[MAJOR_NR] = 8; /* (4kB) */ ++ ++ blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), DEVICE_REQUEST); ++ ++ add_gendisk(&cf_gendisk); ++#endif ++// printk(KERN_INFO "cf-mips partition check: \n"); ++// register_disk(cf_gendisk, MKDEV(MAJOR_NR, 0), CF_MAX_PART, ++// &cf_bdops, dev->sectors); ++ return 0; ++ ++out_err: ++ if (dev->queue){ ++ blk_cleanup_queue(dev->queue); ++ } ++ if (reg_result) { ++ unregister_blkdev(MAJOR_NR, "cf-mips"); ++ return reg_result; ++ } ++ if (dev){ ++ cf_cleanup(dev); ++ kfree(dev); ++ } ++ return 1; ++} ++ ++static int ++cf_mips_remove(struct platform_device *pdev) ++{ ++ struct cf_device *cdev = (struct cf_device *) pdev->dev.platform_data; ++ struct cf_mips_dev *dev = (struct cf_mips_dev *) cdev->dev; ++ ++ unregister_blkdev(MAJOR_NR, "cf-mips"); ++ blk_cleanup_queue(dev->queue); ++ ++ del_gendisk(dev->gd); ++ cf_cleanup(dev); ++ return 0; ++} ++ ++ ++static struct platform_driver cf_driver = { ++ .driver.name = "rb500-cf", ++ .probe = cf_mips_probe, ++ .remove = cf_mips_remove, ++}; ++ ++static int __init cf_mips_init(void) ++{ ++ printk(KERN_INFO "cf-mips module loaded\n"); ++ return platform_driver_register(&cf_driver); ++} ++ ++static void cf_mips_cleanup(void) ++{ ++ platform_driver_unregister(&cf_driver); ++ printk(KERN_INFO "cf-mips module removed\n"); ++} ++ ++module_init(cf_mips_init); ++module_exit(cf_mips_cleanup); ++ ++MODULE_LICENSE("GPL"); ++MODULE_ALIAS_BLOCKDEV_MAJOR(CF_MIPS_MAJOR); ++ ++ ++static int cf_open(struct inode *inode, struct file *filp) ++{ ++ struct cf_mips_dev *dev=inode->i_bdev->bd_disk->private_data; ++ int minor = MINOR(inode->i_rdev); ++ ++ if (minor >= CF_MAX_PART) ++ return -ENODEV; ++ //DEBUGP(KERN_INFO "cf-mips module opened, minor %d\n", minor); ++ spin_lock(&dev->lock); ++ dev->users++; ++ spin_unlock(&dev->lock); ++ filp->private_data=dev; ++ ++ /* dirty workaround to set CFRDY GPIO as an input when some other ++ program sets it as an output */ ++ gpio_set(CFG, (1 << dev->pin), 0); ++ return 0; /* success */ ++} ++ ++static int cf_release(struct inode *inode, struct file *filp) ++{ ++ int minor = MINOR(inode->i_rdev); ++ struct cf_mips_dev *dev=inode->i_bdev->bd_disk->private_data; ++ spin_lock(&dev->lock); ++ dev->users--; ++ spin_unlock(&dev->lock); ++ return 0; ++} ++ ++static int cf_ioctl(struct inode *inode, struct file *filp, ++ unsigned int cmd, unsigned long arg) ++{ ++ unsigned minor = MINOR(inode->i_rdev); ++ struct cf_mips_dev *dev=inode->i_bdev->bd_disk->private_data; ++ ++ DEBUGP(KERN_INFO "cf_ioctl cmd %u\n", cmd); ++ switch (cmd) { ++ case BLKRRPART: /* re-read partition table */ ++ if (!capable(CAP_SYS_ADMIN)) ++ return -EACCES; ++ printk(KERN_INFO "cf-mips partition check: \n"); ++ register_disk(dev->gd); ++ return 0; ++ ++ case HDIO_GETGEO: ++ { ++ struct hd_geometry geo; ++ geo.cylinders = dev->cyl; ++ geo.heads = dev->head; ++ geo.sectors = dev->spt; ++ geo.start = (*dev->gd->part)[minor].start_sect; ++ if (copy_to_user((void *) arg, &geo, sizeof (geo))) ++ return -EFAULT; ++ } ++ return 0; ++ } ++ ++ return -EINVAL; /* unknown command */ ++} ++ ++static void cf_request(request_queue_t * q) ++{ ++ struct cf_mips_dev* dev; ++ ++ struct request * req; ++ int status; ++ ++ /* We could have q->queuedata = dev , but haven't yet. */ ++ if (active_req) ++ return; ++ ++ while ((req=elv_next_request(q))!=NULL){ ++ dev=req->rq_disk->private_data; ++ status=cf_transfer(req); ++ if (status==CF_TRANS_IN_PROGRESS){ ++ active_req=req; ++ return; ++ } ++ end_request(req,status); ++ } ++} ++ ++static int cf_transfer(const struct request *req) ++{ ++ struct cf_mips_dev* dev=req->rq_disk->private_data; ++ ++ if (!blk_fs_request(req)){ ++ if (printk_ratelimit()) ++ printk(KERN_WARNING "cf-mips: skipping non-fs request 0x%x\n",req->cmd[0]); ++ return CF_TRANS_FAILED; ++ } ++ ++ return cf_do_transfer(dev,req->sector,req->current_nr_sectors,req->buffer,rq_data_dir(req)); ++} ++ ++void cf_async_trans_done(struct cf_mips_dev * dev,int result) ++{ ++ struct request *req; ++ ++ spin_lock(&dev->lock); ++ req=active_req; ++ active_req=NULL; ++ end_request(req,result); ++ spin_unlock(&dev->lock); ++ ++ spin_lock(&dev->lock); ++ cf_request(dev->queue); ++ spin_unlock(&dev->lock); ++} ++ +diff -urN linux.old/drivers/block/rb500/Makefile linux.dev/drivers/block/rb500/Makefile +--- linux.old/drivers/block/rb500/Makefile 1970-01-01 01:00:00.000000000 +0100 ++++ linux.dev/drivers/block/rb500/Makefile 2006-10-26 00:11:14.000000000 +0200 +@@ -0,0 +1,3 @@ ++## Makefile for the RB532 CF port ++ ++obj-y += bdev.o ata.o diff --git a/target/linux/rb1xx-2.6/patches/500-Nand.patch b/target/linux/rb1xx-2.6/patches/500-Nand.patch new file mode 100644 index 000000000..05cc800aa --- /dev/null +++ b/target/linux/rb1xx-2.6/patches/500-Nand.patch @@ -0,0 +1,27 @@ +diff -urN linux.old/drivers/mtd/nand/Kconfig linux.dev/drivers/mtd/nand/Kconfig +--- linux.old/drivers/mtd/nand/Kconfig 2006-11-29 22:57:37.000000000 +0100 ++++ linux.dev/drivers/mtd/nand/Kconfig 2006-12-14 04:38:51.000000000 +0100 +@@ -75,6 +75,12 @@ + help + Support for NAND flash on Technologic Systems TS-7250 platform. + ++config MTD_NAND_RB500 ++ tristate "NAND Flash device on RB500 board" ++ depends on MTD_NAND ++ help ++ Support for NAND flash on RB500 platform. ++ + config MTD_NAND_IDS + tristate + +diff -urN linux.old/drivers/mtd/nand/Makefile linux.dev/drivers/mtd/nand/Makefile +--- linux.old/drivers/mtd/nand/Makefile 2006-11-29 22:57:37.000000000 +0100 ++++ linux.dev/drivers/mtd/nand/Makefile 2006-12-14 04:38:51.000000000 +0100 +@@ -9,6 +9,7 @@ + obj-$(CONFIG_MTD_NAND_SPIA) += spia.o + obj-$(CONFIG_MTD_NAND_AMS_DELTA) += ams-delta.o + obj-$(CONFIG_MTD_NAND_TOTO) += toto.o ++obj-$(CONFIG_MTD_NAND_RB500) += rbmipsnand.o + obj-$(CONFIG_MTD_NAND_AUTCPU12) += autcpu12.o + obj-$(CONFIG_MTD_NAND_EDB7312) += edb7312.o + obj-$(CONFIG_MTD_NAND_AU1550) += au1550nd.o -- cgit v1.2.3