[PATCH] TurboStation support (Properly)

Kumar Gala galak at kernel.crashing.org
Thu May 10 00:18:18 EST 2007


On May 8, 2007, at 4:56 PM, Øyvind Repvik wrote:

> On Sunday 06 May 2007 14:46:05 Øyvind Repvik wrote:
>> Hi,
>>
>> 	This patch adds support for the QNAP TurboStation TS-101 and  
>> TS-201 devices.
>
> Of course, it probably helps if my mail client doesn't break the  
> patch completely.

Comments below.

Out of interesting, what's the difference between the TS-101 and TS-201?

>
>
> Signed-off-by: Øyvind Repvik <nail at nslu2-linux.org>
> Signed-off-by: Alessandro Zummo <a.zummo at towertech.it>
>
> --- linux-2.6.21.1/arch/powerpc/boot/dts/qnap-ts101.dts	1970-01-01  
> 01:00:00.000000000 +0100
> +++ linux-2.6.21.1.ts/arch/powerpc/boot/dts/qnap-ts101.dts	 
> 2007-05-03 22:44:59.000000000 +0200
> @@ -0,0 +1,166 @@
> +/*
> + * Device Tree Souce for QNAP Turbostation 101/201
> + *
> + * Choose CONFIG_TURBOSTATION to build a kernel for turbostation
> + *
> + *
> + * Based on kuroboxHD.dts by G. Liakhovetski
> + *
> + * 2007 (c) Oyvind Repvik <nail at nslu2-linux.org>
> + *
> + * 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.
> + *
> + * build with: "dtc -f -I dts -O dtb -o qnap-ts101.dtb -V 16 qnap- 
> ts101.dts"
> + *
> + *
> + */
> +
> +/ {
> +	linux,phandle = <1000>;
> +	model = "TurboStation TSx01";
> +	compatible = "turbostation";
> +	#address-cells = <1>;
> +	#size-cells = <1>;
> +
> +	cpus {
> +		linux,phandle = <2000>;

Can you removal all linux,phandle's and use the new reference syntax.

> +		#cpus = <1>;
> +		#address-cells = <1>;
> +		#size-cells = <0>;
> +
> +		PowerPC,603e { /* Really 8241 */
> +			linux,phandle = <2100>;
> +			device_type = "cpu";
> +			reg = <0>;
> +			clock-frequency = <fdad680>;	/* 266 MHz */
> +			timebase-frequency = <1fca055>;	/* 33.3333333 MHz */
> +			bus-frequency = <0>;
> +			/* Following required by dtc but not used */
> +			i-cache-line-size = <0>;
> +			d-cache-line-size = <0>;

No reason not to set the line-size properly to <20>

> +			i-cache-size = <4000>;
> +			d-cache-size = <4000>;
> +		};
> +	};
> +
> +	/* 64MB @ 0x0 */
> +	memory {
> +		linux,phandle = <3000>;
> +		device_type = "memory";
> +		reg = <00000000 04000000>;
> +	};
> +
> +	flash at ff000000 {
> +		linux,phandle = <3100>;
> +		device_type = "rom";
> +		compatible = "direct-mapped";
> +		probe-type = "CFI";
> +		reg = <ff000000 01000000>;
> +		bank-width = <1>;
> +		partitions = <
> +				00000000 00200000
> +				00200000 00d00000
> +				00f00000 00040001
> +				00f40000 00020000
> +				00f60000 00040000
> +				00fa0000 00020000
> +				00fc0000 00040000
> +		>;
> +		partition-names = "kernel\0rootfs\0uboot1\0uboot1-env\0uboot2 
> \0uboot2-env\0SysConf";
> +	};
> +
> +
> +	soc10x { /* AFAICT need to make soc for 8245's uarts to be  
> defined */
> +		linux,phandle = <4000>;
> +		#address-cells = <1>;
> +		#size-cells = <1>;
> +		#interrupt-cells = <2>;
> +		device_type = "soc";
> +		compatible = "mpc10x";
> +		store-gathering = <0>; /* 0 == off, !0 == on */
> +		reg = <80000000 00100000>;
> +		ranges = <80000000 80000000 70000000	/* pci mem space */
> +			  fc000000 fc000000 00100000	/* EUMB */
> +			  fe000000 fe000000 00c00000	/* pci i/o space */
> +			  fec00000 fec00000 00300000	/* pci cfg regs */
> +			  fef00000 fef00000 00100000>;	/* pci iack */
> +
> +		i2c at fc003000 {
> +			linux,phandle = <4300>;
> +			device_type = "i2c";
> +			compatible = "fsl-i2c";
> +			reg = <fc003000 1000>;
> +			interrupts = <5 2>;
> +			interrupt-parent = <4400>;
> +		};
> +
> +		serial at fc004500 {
> +			linux,phandle = <4511>;
> +			device_type = "serial";
> +			compatible = "ns16550";
> +			reg = <fc004500 8>;
> +			clock-frequency = <7ed6b40>;	/* 133 MHz */
> +			current-speed = <1c200>;	/* 115200 */
> +			interrupts = <9 2>;
> +			interrupt-parent = <4400>;
> +		};
> +
> +		serial at fc004600 {
> +			linux,phandle = <4512>;
> +			device_type = "serial";
> +			compatible = "ns16550";
> +			reg = <fc004600 8>;
> +			clock-frequency = <7ed6b40>;
> +			current-speed = <4b00>;		/* 19200 */
> +			interrupts = <a 2>;
> +			interrupt-parent = <4400>;
> +		};
> +
> +		pic at fc040000 {
> +			linux,phandle = <4400>;
> +			#interrupt-cells = <2>;
> +			#address-cells = <0>;
> +			device_type = "open-pic";
> +			compatible = "chrp,open-pic";
> +			interrupt-controller;
> +			reg = <fc040000 40000>;
> +			built-in;
> +		};
> +
> +		pci at fe800000 {
> +			linux,phandle = <4500>;
> +			#address-cells = <3>;
> +			#size-cells = <2>;
> +			#interrupt-cells = <1>;
> +			device_type = "pci";
> +			compatible = "mpc10x-pci";
> +			reg = <fc000000 400000>;
> +			ranges = <01000000 0        0 fe000000 0 00c00000
> +				  02000000 0 80000000 80000000 0 70000000>;
> +			bus-range = <0 ff>;
> +			clock-frequency = <7ed6b40>;	/* 133 MHz */
> +			interrupt-parent = <4400>;
> +			interrupt-map-mask = <f800 0 0 7>;
> +			interrupt-map = <
> +				/* IDSEL 0x13 - SATA*/
> +				6800 0 0 1 4400 0 1
> +				6800 0 0 2 4400 0 1
> +				6800 0 0 3 4400 0 1
> +				6800 0 0 4 4400 0 1
> +				/* IDSEL 0x14 - USB */
> +				7000 0 0 1 4400 1 1
> +				7000 0 0 2 4400 1 1
> +				7000 0 0 3 4400 1 1
> +				7000 0 0 4 4400 1 1
> +				/* IDSEL 0x15 - ETH */
> +				7800 0 0 1 4400 2 1
> +				7800 0 0 2 4400 2 1
> +				7800 0 0 3 4400 2 1
> +				7800 0 0 4 4400 2 1
> +			>;
> +		};
> +	};
> +};
> Binary files linux-2.6.21.1/arch/powerpc/boot/dts/storcenter.dtb  
> and linux-2.6.21.1.ts/arch/powerpc/boot/dts/storcenter.dtb differ
> --- linux-2.6.21.1/arch/powerpc/platforms/embedded6xx/Kconfig	 
> 2007-04-27 23:49:26.000000000 +0200
> +++ linux-2.6.21.1.ts/arch/powerpc/platforms/embedded6xx/Kconfig	 
> 2007-05-06 14:31:55.000000000 +0200
> @@ -87,6 +87,13 @@
>  	  Linkstation-I HD-HLAN and HD-HGLAN versions, and PPC-based
>  	  Terastation systems should be supported too.
>
> +config TURBOSTATION
> +	bool "QNap TS-101/TS-102 TurboStation"
> +	select MPIC
> +	select FSL_SOC
> +	select PPC_UDBG_16550 if SERIAL_8250
> +	select DEFAULT_UIMAGE
> +
>  config MPC7448HPC2
>  	bool "Freescale MPC7448HPC2(Taiga)"
>  	select TSI108_BRIDGE
> @@ -200,7 +207,7 @@
>  	depends on SANDPOINT || SPRUCE || PPLUS || \
>  		PRPMC750 || PRPMC800 || LOPEC || \
>  		(EV64260 && !SERIAL_MPSC) || CHESTNUT || RADSTONE_PPC7D || \
> -		83xx || LINKSTATION
> +		83xx || LINKSTATION || TURBOSTATION
>  	default y
>
>  config FORCE
> @@ -274,13 +281,15 @@
>
>  config MPC10X_BRIDGE
>  	bool
> -	depends on POWERPMC250 || LOPEC || SANDPOINT || LINKSTATION
> +	depends on POWERPMC250 || LOPEC || SANDPOINT || LINKSTATION || \
> +	TURBOSTATION
>  	select PPC_INDIRECT_PCI
>  	default y
>
>  config MPC10X_OPENPIC
>  	bool
> -	depends on POWERPMC250 || LOPEC || SANDPOINT || LINKSTATION
> +	depends on POWERPMC250 || LOPEC || SANDPOINT || LINKSTATION || \
> +	TURBOSTATION
>  	default y
>
>  config MPC10X_STORE_GATHERING
> --- linux-2.6.21.1/arch/powerpc/platforms/embedded6xx/Makefile	 
> 2007-04-27 23:49:26.000000000 +0200
> +++ linux-2.6.21.1.ts/arch/powerpc/platforms/embedded6xx/Makefile	 
> 2007-05-06 14:30:58.000000000 +0200
> @@ -3,3 +3,4 @@
>  #
>  obj-$(CONFIG_MPC7448HPC2)	+= mpc7448_hpc2.o
>  obj-$(CONFIG_LINKSTATION)	+= linkstation.o ls_uart.o
> +obj-$(CONFIG_TURBOSTATION)	+= turbostation.o
> --- linux-2.6.21.1/arch/powerpc/platforms/embedded6xx/ 
> turbostation.c	1970-01-01 01:00:00.000000000 +0100
> +++ linux-2.6.21.1.ts/arch/powerpc/platforms/embedded6xx/ 
> turbostation.c	2007-05-03 22:45:03.000000000 +0200
> @@ -0,0 +1,141 @@
> +/*
> + * Board setup routines for the QNAP Turbostation platform (TS-101/ 
> TS-201)
> + *
> + * Copyright (C) 2007 Oyvind Repvik (nail at nslu2-linux.org)
> + *
> + * Based on linkstation.c by G. Liakhovetski
> + *
> + * 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.
> + */
> +
> +#include <linux/kernel.h>
> +#include <linux/pci.h>
> +#include <linux/initrd.h>
> +#include <linux/mtd/physmap.h>
> +
> +#include <asm/time.h>
> +#include <asm/prom.h>
> +#include <asm/mpic.h>
> +#include <asm/mpc10x.h>
> +#include <asm/pci-bridge.h>
> +
> +static int __init add_bridge(struct device_node *dev)
> +{
> +	int len;
> +	struct pci_controller *hose;
> +	int *bus_range;
> +
> +	printk("Adding PCI host bridge %s\n", dev->full_name);
> +
> +	bus_range = (int *) get_property(dev, "bus-range", &len);
> +	if (bus_range == NULL || len < 2 * sizeof(int))
> +		printk(KERN_WARNING "Can't get bus-range for %s, assume"
> +				" bus 0\n", dev->full_name);
> +
> +	hose = pcibios_alloc_controller();
> +	if (hose == NULL)
> +		return -ENOMEM;
> +	hose->first_busno = bus_range ? bus_range[0] : 0;
> +	hose->last_busno = bus_range ? bus_range[1] : 0xff;
> +	hose->arch_data = dev;
> +	setup_indirect_pci(hose, 0xfec00000, 0xfee00000);
> +
> +	/* Interpret the "ranges" property */
> +	/* This also maps the I/O region and sets isa_io/mem_base */
> +	pci_process_bridge_OF_ranges(hose, dev, 1);
> +
> +	return 0;
> +}
> +
> +static void __init turbostation_setup_arch(void)
> +{
> +	struct device_node *np;
> +
> +	/* Lookup PCI host bridges */
> +	for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
> +		add_bridge(np);
> +
> +	printk(KERN_INFO "QNAP Turbostation series\n");
> +}
> +
> +/*
> + * Interrupt setup and service.  Interrrupts on the turbostation come
> + * from the four PCI slots plus onboard 8241 devices: I2C, DUART.
> + */
> +static void __init turbostation_init_IRQ(void)
> +{
> +	struct mpic *mpic;
> +	struct device_node *dnp;
> +	void *prop;
> +	int size;
> +	phys_addr_t paddr;
> +
> +	dnp = of_find_node_by_type(NULL, "open-pic");
> +	if (dnp == NULL)
> +		return;
> +
> +	prop = (struct device_node *)get_property(dnp, "reg", &size);
> +	paddr = (phys_addr_t)of_translate_address(dnp, prop);
> +
> +	mpic = mpic_alloc(dnp, paddr, MPIC_PRIMARY | MPIC_WANTS_RESET,
> +			4, 32, " EPIC     ");
> +	BUG_ON(mpic == NULL);
> +
> +	/* PCI IRQs */
> +	mpic_assign_isu(mpic, 0, paddr + 0x10200);
> +
> +	/* I2C */
> +	mpic_assign_isu(mpic, 1, paddr + 0x11000);
> +
> +	/* ttyS0, ttyS1 */
> +	mpic_assign_isu(mpic, 2, paddr + 0x11100);
> +
> +	mpic_init(mpic);
> +}
> +
> +static void turbostation_restart(char *cmd)
> +{
> +	/* Insert restart-stuff */
> +}
> +
> +static void turbostation_power_off(void)
> +{
> +	/* Insert powerdown-stuff */
> +}
> +
> +static void turbostation_halt(void)
> +{
> +	turbostation_power_off();
> +}
> +
> +static void turbostation_show_cpuinfo(struct seq_file *m)
> +{
> +	seq_printf(m, "vendor\t\t: QNAP Systems Inc.\n");
> +	seq_printf(m, "machine\t\t: Turbostation TS-101/TS-201\n");
> +}
> +
> +static int __init turbostation_probe(void)
> +{
> +	unsigned long root;
> +
> +	root = of_get_flat_dt_root();
> +
> +	if (!of_flat_dt_is_compatible(root, "turbostation"))
> +		return 0;
> +	return 1;
> +}
> +
> +define_machine(turbostation){
> +	.name 			= "QNAP Turbostation",
> +	.probe 			= turbostation_probe,
> +	.setup_arch 		= turbostation_setup_arch,
> +	.init_IRQ 		= turbostation_init_IRQ,
> +	.show_cpuinfo 		= turbostation_show_cpuinfo,
> +	.get_irq 		= mpic_get_irq,
> +	.restart 		= turbostation_restart,
> +	.power_off 		= turbostation_power_off,
> +	.halt	 		= turbostation_halt,
> +	.calibrate_decr 	= generic_calibrate_decr,
> +};
> _______________________________________________
> Linuxppc-embedded mailing list
> Linuxppc-embedded at ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-embedded




More information about the Linuxppc-embedded mailing list