arch/arm/mach-ixp4xx/Kconfig | 8 + arch/arm/mach-ixp4xx/Makefile | 2 arch/arm/mach-ixp4xx/ds101-pci.c | 66 +++++++++ arch/arm/mach-ixp4xx/ds101-setup.c | 234 +++++++++++++++++++++++++++++++++ include/asm-arm/arch-ixp4xx/ds101.h | 88 ++++++++++++ include/asm-arm/arch-ixp4xx/hardware.h | 1 include/asm-arm/arch-ixp4xx/irqs.h | 8 + 7 files changed, 406 insertions(+), 1 deletion(-) --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ linux-ixp4xx/include/asm-arm/arch-ixp4xx/ds101.h 2006-03-08 08:41:31.000000000 +0100 @@ -0,0 +1,88 @@ +/* + * DS101 platform specific definitions + * + * Author: Øyvind Repvik + * + * based on ixdp425.h: + * Copyright 2004 (c) MontaVista, Software, Inc. + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#ifndef __ASM_ARCH_HARDWARE_H__ +#error "Do not include this directly, instead #include " +#endif + +#define DS101_SCL_PIN DS101_GPIO0 +#define DS101_SDA_PIN DS101_GPIO1 +#define DS101_GPIO_BUZZ DS101_GPIO2 +#define DS101_POWER_LED DS101_GPIO3 +#define DS101_USBCOPYB_GPIO DS101_GPIO4 /* shared */ +#define DS101_USBCOPY_SOLID_LED DS101_GPIO4 /* shared */ +#define DS101_USBCOPY_BLINK_LED DS101_GPIO5 +/* GPIO6 is unknown */ +#define DS101_POWEROFF_GPIO DS101_GPIO7 +#define DS101_POWERB_GPIO DS101_GPIO8 +/*#define DS101_PCI_INTC_PIN DS101_GPIO9 +#define DS101_PCI_INTB_PIN DS101_GPIO10 +#define DS101_PCI_INTA_PIN DS101_GPIO11 +*/ +#define DS101_RESETB_GPIO DS101_GPIO12 +#define DS101_STATUSOK_LED DS101_GPIO14 +#define DS101_STATUSBAD_LED DS101_GPIO15 + +#define DS101_PCI_MAX_DEV 2 +#define DS101_PCI_IRQ_LINES 3 + +#define DS101_POWERB_IRQ IRQ_IXP4XX_GPIO8 +#define DS101_RESETB_IRQ IRQ_IXP4XX_GPIO12 +#define DS101_USBCOPYB_IRQ IRQ_IXP4XX_GPIO4 + +/* XXX use IXP4XX_GPIO_XX directly */ +#define DS101_GPIO_IN IXP4XX_GPIO_IN +#define DS101_GPIO_OUT IXP4XX_GPIO_OUT +#define DS101_GPIO_HIGH 1 +#define DS101_GPIO_LOW 0 + +/* GPIO */ + +#define DS101_GPIO0 0 +#define DS101_GPIO1 1 +#define DS101_GPIO2 2 +#define DS101_GPIO3 3 +#define DS101_GPIO4 4 +#define DS101_GPIO5 5 +#define DS101_GPIO6 6 +#define DS101_GPIO7 7 +#define DS101_GPIO8 8 +#define DS101_GPIO9 9 +#define DS101_GPIO10 10 +#define DS101_GPIO11 11 +#define DS101_GPIO12 12 +#define DS101_GPIO13 13 +#define DS101_GPIO14 14 +#define DS101_GPIO15 15 + +/* Stuff needed to setup the IXP expansion + * bus on the DS101 + */ + +#define DS101_EXP_RECOVERY_T(x) (((x) & 15) << 16) +#define DS101_EXP_HOLD_T(x) (((x) & 3) << 20) +#define DS101_EXP_STROBE_T(x) (((x) & 15) << 22) +#define DS101_EXP_SETUP_T(x) (((x) & 3) << 26) +#define DS101_EXP_ADDR_T(x) (((x) & 3) << 28) + +#define DS101_EXP_SZ_16M (15 << 10) +#define DS101_EXP_WR_EN (1 << 1) +#define DS101_EXP_BYTE_RD16 (1 << 6) +#define DS101_EXP_CS_EN (1 << 31) + +/* XXX nope. use the _EXP_ macros in the -setup.c */ +#define DS101_EXP_CS0_INIT (DS101_EXP_ADDR_T(1) | \ + DS101_EXP_SETUP_T(1) | DS101_EXP_STROBE_T(1) | \ + DS101_EXP_HOLD_T(1) | DS101_EXP_RECOVERY_T(1)| \ + DS101_EXP_SZ_16M | DS101_EXP_WR_EN | \ + DS101_EXP_BYTE_RD16 | DS101_EXP_CS_EN) --- linux-ixp4xx.orig/include/asm-arm/arch-ixp4xx/hardware.h 2006-03-08 08:41:02.000000000 +0100 +++ linux-ixp4xx/include/asm-arm/arch-ixp4xx/hardware.h 2006-03-08 08:41:31.000000000 +0100 @@ -47,5 +47,6 @@ extern unsigned int processor_id; #include "nslu2.h" #include "nas100d.h" #include "dsmg600.h" +#include "ds101.h" #endif /* _ASM_ARCH_HARDWARE_H */ --- linux-ixp4xx.orig/include/asm-arm/arch-ixp4xx/irqs.h 2006-03-08 08:41:02.000000000 +0100 +++ linux-ixp4xx/include/asm-arm/arch-ixp4xx/irqs.h 2006-03-08 08:41:31.000000000 +0100 @@ -110,6 +110,14 @@ #define IRQ_NAS100D_PCI_INTE IRQ_IXP4XX_GPIO7 /* + * Synology DS101 board IRQs + */ + +#define IRQ_DS101_PCI_INTA IRQ_IXP4XX_GPIO11 +#define IRQ_DS101_PCI_INTB IRQ_IXP4XX_GPIO10 +#define IRQ_DS101_PCI_INTC IRQ_IXP4XX_GPIO9 + +/* * D-Link DSM-G600 board IRQs */ #define IRQ_DSMG600_PCI_INTA IRQ_IXP4XX_GPIO11 --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ linux-ixp4xx/arch/arm/mach-ixp4xx/ds101-pci.c 2006-03-08 08:41:31.000000000 +0100 @@ -0,0 +1,66 @@ +/* + * DS101 board-level PCI initialization + * + * based on ixdp425-pci.c: + * Copyright (C) 2002 Intel Corporation. + * Copyright (C) 2003-2004 MontaVista Software, Inc. + * + * Maintainer: http://www.nslu2-linux.org/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ + +#include +#include +#include + +#include +#include + +void __init ds101_pci_preinit(void) +{ + set_irq_type(IRQ_DS101_PCI_INTA, IRQT_LOW); + set_irq_type(IRQ_DS101_PCI_INTB, IRQT_LOW); + set_irq_type(IRQ_DS101_PCI_INTC, IRQT_LOW); + + ixp4xx_pci_preinit(); +} + +static int __init ds101_map_irq(struct pci_dev *dev, u8 slot, u8 pin) +{ + static int pci_irq_table[DS101_PCI_MAX_DEV][DS101_PCI_IRQ_LINES] = + { + { IRQ_DS101_PCI_INTA, -1, -1 }, + { IRQ_DS101_PCI_INTB, IRQ_DS101_PCI_INTB, IRQ_DS101_PCI_INTC }, + }; + + int irq = -1; + + if (slot >= 1 && slot <= DS101_PCI_MAX_DEV && + pin >= 1 && pin <= DS101_PCI_IRQ_LINES) + irq = pci_irq_table[slot-1][pin-1]; + + return irq; +} + +struct hw_pci __initdata ds101_pci = { + .nr_controllers = 1, + .preinit = ds101_pci_preinit, + .swizzle = pci_std_swizzle, + .setup = ixp4xx_setup, + .scan = ixp4xx_scan_bus, + .map_irq = ds101_map_irq, +}; + +int __init ds101_pci_init(void) +{ + if (machine_is_ds101()) + pci_common_init(&ds101_pci); + + return 0; +} + +subsys_initcall(ds101_pci_init); --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ linux-ixp4xx/arch/arm/mach-ixp4xx/ds101-setup.c 2006-03-08 08:41:31.000000000 +0100 @@ -0,0 +1,234 @@ +/* + * Synology DS101 board setup + * + * based ixdp425-setup.c: + * Copyright (C) 2003-2004 MontaVista Software, Inc. + * + * Author: Alessandro Zummo + * Author: Rod Whitby + * Author: OEyvind Repvik + * Maintainers: http://www.nslu2-linux.org/ + * + */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#ifdef CONFIG_LEDS_CLASS +static struct resource ds101_led_resources[] = { + { + .name = "power", + .start = DS101_POWER_LED, + .end = DS101_POWER_LED, + .flags = IXP4XX_GPIO_LOW, + }, + { + .name = "usbcopy-solid", + .start = DS101_USBCOPY_SOLID_LED, + .end = DS101_USBCOPY_SOLID_LED, + .flags = IXP4XX_GPIO_LOW, + }, + { + .name = "usbcopy-blink", + .start = DS101_USBCOPY_BLINK_LED, + .end = DS101_USBCOPY_BLINK_LED, + .flags = IXP4XX_GPIO_LOW, + }, + { + .name = "status-ready", + .start = DS101_STATUSOK_LED, + .end = DS101_STATUSOK_LED, + .flags = IXP4XX_GPIO_LOW, + }, + { + .name = "status-error", + .start = DS101_STATUSBAD_LED, + .start = DS101_STATUSBAD_LED, + .flags = IXP4XX_GPIO_LOW, + } +}; + + +static struct platform_device ds101_leds = { + .name = "IXP4XX-GPIO-LED", + .id = -1, + .num_resources = ARRAY_SIZE(ds101_led_resources), + .resource = ds101_led_resources, +}; +#endif + +static struct ixp4xx_i2c_pins ds101_i2c_gpio_pins = { + .sda_pin = DS101_SDA_PIN, + .scl_pin = DS101_SCL_PIN, +}; + +static struct platform_device ds101_i2c_controller = { + .name = "IXP4XX-I2C", + .id = 0, + .dev.platform_data = &ds101_i2c_gpio_pins, + .num_resources = 0, +}; + +static struct platform_device ds101_beeper = { + .name = "ixp4xx-beeper", + .id = DS101_GPIO_BUZZ, + .num_resources = 0, +}; + +static struct resource ds101_uart_resources[] = { + { + .start = IXP4XX_UART1_BASE_PHYS, + .end = IXP4XX_UART1_BASE_PHYS + 0x0fff, + .flags = IORESOURCE_MEM, + }, + { + .start = IXP4XX_UART2_BASE_PHYS, + .end = IXP4XX_UART2_BASE_PHYS + 0x0fff, + .flags = IORESOURCE_MEM, + } +}; + +static struct plat_serial8250_port ds101_uart_data[] = { + { + .mapbase = IXP4XX_UART1_BASE_PHYS, + .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET, + .irq = IRQ_IXP4XX_UART1, + .flags = UPF_BOOT_AUTOCONF, + .iotype = UPIO_MEM, + .regshift = 2, + .uartclk = IXP4XX_UART_XTAL, + }, + { + .mapbase = IXP4XX_UART2_BASE_PHYS, + .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET, + .irq = IRQ_IXP4XX_UART2, + .flags = UPF_BOOT_AUTOCONF, + .iotype = UPIO_MEM, + .regshift = 2, + .uartclk = IXP4XX_UART_XTAL, + }, + { } +}; + +static struct platform_device ds101_uart = { + .name = "serial8250", + .id = PLAT8250_DEV_PLATFORM, + .dev.platform_data = ds101_uart_data, + .num_resources = 2, + .resource = ds101_uart_resources, +}; + +static struct platform_device *ds101_devices[] __initdata = { + &ds101_i2c_controller, + &ds101_beeper, +}; + +static void ds101_power_off(void) +{ + /* Simple, but effective */ + gpio_line_set(DS101_POWEROFF_GPIO, IXP4XX_GPIO_LOW); +} + +static void ds101_gpio_setup(void) +{ + /* Set up buzzer */ + gpio_line_config(DS101_GPIO_BUZZ, DS101_GPIO_OUT); + gpio_line_set(DS101_GPIO_BUZZ, DS101_GPIO_LOW); + + /* Set up power led */ + gpio_line_config(DS101_POWER_LED, DS101_GPIO_OUT); + gpio_line_set(DS101_POWER_LED, DS101_GPIO_LOW); + + /* Poweroff */ + gpio_line_config(DS101_POWEROFF_GPIO, DS101_GPIO_OUT); + gpio_line_set(DS101_POWEROFF_GPIO, DS101_GPIO_HIGH); + + /* Status leds */ + *IXP4XX_GPIO_GPCLKR = 0; + + /* XXX can't the leds subsystem take care of those? */ + gpio_line_config(DS101_STATUSOK_LED, DS101_GPIO_OUT); + gpio_line_config(DS101_STATUSBAD_LED, DS101_GPIO_OUT); + gpio_line_set(DS101_STATUSOK_LED, DS101_GPIO_HIGH); + gpio_line_set(DS101_STATUSBAD_LED, DS101_GPIO_LOW); +}; + +static void ds101_cs0_setup(void) +{ + /* XXX don't use macro */ + *IXP4XX_EXP_CS0 = DS101_EXP_CS0_INIT; +}; + +static void __init ds101_init(void) +{ + ixp4xx_sys_init(); + + ds101_cs0_setup(); /* Needed for DoC support */ + ds101_gpio_setup(); + pm_power_off = ds101_power_off; + + platform_add_devices(ds101_devices, ARRAY_SIZE(ds101_devices)); + + /* This is only useful on a modified machine, but it is valuable + * to have it first in order to see debug messages, and so that + * it does *not* get removed if platform_add_devices fails! + */ + (void)platform_device_register(&ds101_uart); + +#ifdef CONFIG_LEDS_CLASS + /* We don't care whether or not this works. */ + (void)platform_device_register(&ds101_leds); +#endif +} + +/* + * DS101 bootstrap may pass in parameters, but we zap the mem + * settings to be safe (DS101 always has 64MByte at 0, DS101J has + * 32MB). The passed in command line can override this default, we + * prepend to the config'ed default. + * + * NOTE: the startup sequence is: + * 1) Call the machine fixup + * 2) Parse the ATAG list, the ATAG_CMDLINE is copied in + * to default_command_line which is the value of *from + * 3) Parse the command line in *from (*not* + * default_command_line unless they are the same!) + * + * Setting mi->nr_banks causes (2) to 'squash' (set to ATAG_NONE) + * any ATAG_MEM tags, but mem= command line options cause nr_banks + * to be reset to 0 (on the first mem=) + */ + +static void __init ds101_fixup(struct machine_desc *desc, + struct tag *tags, char **cmdline, struct meminfo *mi) +{ + /* The DS101 has one bank of 64MByte memory. + * NOTE: setting nr_banks != 0 causes kernel/setup.c to remove + * the mem tags from the tag list. We need do nothing here! + */ + mi->nr_banks = 1; + mi->bank[0].start = 0; + mi->bank[0].size = (64*1024*1024); + mi->bank[0].node = PHYS_TO_NID(0); +} + +MACHINE_START(DS101, "Synology DiskStation DS101") + /* Maintainer: www.nslu2-linux.org */ + .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS, + .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xFFFC, + .boot_params = 0x00000100, + .fixup = ds101_fixup, + .map_io = ixp4xx_map_io, + .init_irq = ixp4xx_init_irq, + .timer = &ixp4xx_timer, + .init_machine = ds101_init, +MACHINE_END --- linux-ixp4xx.orig/arch/arm/mach-ixp4xx/Kconfig 2006-03-08 08:41:02.000000000 +0100 +++ linux-ixp4xx/arch/arm/mach-ixp4xx/Kconfig 2006-03-08 08:41:31.000000000 +0100 @@ -93,6 +93,14 @@ config MACH_DSMG600 DSM-G600 device. For more information on this platform, see http://www.nslu2-linux.org/ +config MACH_DS101 + bool + prompt "Synology DS101" + help + Say 'Y' here if you want your kernel to support Synology's + DiskStation DS101(j) device. For more information on this + platform see http://www.nslu2-linux.org/wiki/DS101/HomePage + # # Avila and IXDP share the same source for now. Will change in future # --- linux-ixp4xx.orig/arch/arm/mach-ixp4xx/Makefile 2006-03-08 08:41:02.000000000 +0100 +++ linux-ixp4xx/arch/arm/mach-ixp4xx/Makefile 2006-03-08 08:41:31.000000000 +0100 @@ -11,4 +11,4 @@ obj-$(CONFIG_MACH_GTWX5715) += gtwx5715- obj-$(CONFIG_MACH_NSLU2) += nslu2-pci.o nslu2-setup.o nslu2-power.o obj-$(CONFIG_MACH_NAS100D) += nas100d-pci.o nas100d-setup.o nas100d-power.o obj-$(CONFIG_MACH_DSMG600) += dsmg600-pci.o dsmg600-setup.o - +obj-$(CONFIG_MACH_DS101) += ds101-pci.o ds101-setup.o