diff -urN linux-2.6.30.4-orig/arch/arm/mach-pxa/datr.c linux-2.6.30.4/arch/arm/mach-pxa/datr.c --- linux-2.6.30.4-orig/arch/arm/mach-pxa/datr.c 1970-01-01 01:00:00.000000000 +0100 +++ linux-2.6.30.4/arch/arm/mach-pxa/datr.c 2009-08-06 15:14:38.000000000 +0200 @@ -0,0 +1,447 @@ +/* + * linux/arch/arm/mach-pxa/datr.c + * + * Support for the HaslerRail DATR board. + * + * Author: Marco Hoefle + * Created: June 03, 2009 + * Copyright: HasleRail, Inc. + * e-mail: marco.hoefle@nanotronic.ch + * + * Author: Daniel Marmier + * Created: March 15, 2007 + * Copyright: HasleRail, Inc. + * e-mail: daniel.marmier@haslerrail.com + * + * based on the Phytec phyCORE-PXA270: + * + * Author: Juergen Kilb + * Created: April 05, 2005 + * Copyright: Phytec Messtechnik GmbH + * e-Mail: armlinux@phytec.de + * + * 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 +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "generic.h" + +/* + * ABSTRACT: + * + * The PXA270 processor comes with a bunch of hardware on its silicon. + * Not all of this hardware can be used at the same time and not all + * is routed to module's connectors. Also it depends on the baseboard, what + * kind of hardware can be used in which way. + * -> So this file supports the main devices on the CPU card only! + * Refer pcm990-baseboard.c how to extend this features to get a full + * blown system with many common interfaces. + * + * The PCM-027 supports the following interfaces through its connectors and + * will be used in pcm990-baseboard.c: + * + * - LCD support + * - MMC support + * - IDE/CF card + * - FFUART + * - BTUART + * - IRUART + * - AC97 + * - SSP + * - SSP3 + * + * Claimed GPIOs: + * GPIO0 -> IRQ input from RTC + * GPIO2 -> SYS_ENA*) + * GPIO3 -> PWR_SCL + * GPIO4 -> PWR_SDA + * GPIO5 -> PowerCap0*) + * GPIO6 -> PowerCap1*) + * GPIO7 -> PowerCap2*) + * GPIO8 -> PowerCap3*) + * GPIO15 -> /CS1 + * GPIO20 -> /CS2 + * GPIO21 -> /CS3 + * GPIO33 -> /CS5 network controller select + * GPIO52 -> IRQ from network controller + * GPIO78 -> /CS2 + * GPIO80 -> /CS4 + * GPIO90 -> LED0 + * GPIO91 -> LED1 + * GPIO114 -> IRQ from CAN controller + * GPIO117 -> SCL + * GPIO118 -> SDA + * + * *) CPU internal use only + */ + +#define GPIO_ALT_FN_1_IN 0x100 +#define GPIO_ALT_FN_2_OUT 0x280 +#define GPIO18_RDY_MD (18 | GPIO_ALT_FN_1_IN) +#define GPIO49_nPWE_MD (49 | GPIO_ALT_FN_2_OUT) +#define GPIO15_nCS_1_MD (15 | GPIO_ALT_FN_2_OUT) + +#ifdef CONFIG_SMC91X +/* + * SMC91x network controller specific stuff + */ +static struct resource smc91x_resources[] __initdata = { + [0] = { + .start = DATR_ETH_PHYS + 0x300, + .end = DATR_ETH_PHYS + DATR_ETH_SIZE, + .flags = IORESOURCE_MEM, + }, + [1] = { + .start = DATR_ETH_IRQ, + .end = DATR_ETH_IRQ, + /* note: smc91x's driver doesn't use the trigger bits yet */ + .flags = IORESOURCE_IRQ | DATR_ETH_IRQ_EDGE, + } +}; + +static struct platform_device smc91x_device __initdata = { + .name = "smc91x", + .id = 0, + .num_resources = ARRAY_SIZE(smc91x_resources), + .resource = smc91x_resources, +}; +#endif + +#if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE) +#include +#define ISP1761_BASE PXA_CS4_PHYS +#define ISP1761_GPIO_IRQ 91 +#define ISP1761_IRQ IRQ_GPIO(ISP1761_GPIO_IRQ) +static struct resource datr_isp1760_resources[] __initdata = { + [0] = { + .start = ISP1761_BASE, + .end = ISP1761_BASE + 0x3FFFF, + .flags = IORESOURCE_MEM, + }, + [1] = { + .start = ISP1761_IRQ, + .end = ISP1761_IRQ, + .flags = IORESOURCE_IRQ, + }, +}; + +static struct isp1760_platform_data isp1760_platform_data __initdata = { + .is_isp1761 = 0, + .bus_width_16 = 0, + .port1_otg = 0, + .analog_oc = 1, + .dack_polarity_high = 0, + .dreq_polarity_high = 0, +}; + +static struct platform_device isp1760_device __initdata = { + .name = "isp1760", + .id = 0, + .dev = { + .platform_data = &isp1760_platform_data, + }, + .num_resources = ARRAY_SIZE(datr_isp1760_resources), + .resource = datr_isp1760_resources, +}; +#endif + +/* + * NOR flash + */ +static struct physmap_flash_data datr_flash_data __initdata = { + .width = 4, +}; + +static struct resource datr_flash_resource __initdata = { + .start = DATR_FLASH_PHYS, + .end = DATR_FLASH_PHYS + DATR_FLASH_SIZE - 1 , + .flags = IORESOURCE_MEM, +}; + +static struct platform_device datr_flash __initdata = { + .name = "physmap-flash", + .id = 0, + .dev = { + .platform_data = &datr_flash_data, + }, + .resource = &datr_flash_resource, + .num_resources = 1, +}; + + +/* + * Input device for LEDs, reset MAINB and buttons + */ +static u16 ledr = 0xffff; +#define GPIO_RESET_VME 12 +#define GPIO_RESET_VME_MD (GPIO_RESET_VME | GPIO_OUT) + +#define GPIO_DOOR 9 +#define DOOR_FLAGS (/*IRQF_DISABLED |*/ IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING) + +#define GPIO_nCS_CPLD_MD GPIO79_nCS_3_MD + +//#define GPIO_LEVEL(x) (GPLR(x) & GPIO_bit(x)) + +#define LEDR (*(volatile unsigned short *)DATR_LEDS_BASE) + +static irqreturn_t door_int(int irq, void *dev_id) { + struct input_dev *idev = dev_id; + int value = gpio_get_value(GPIO_DOOR); +#if 1 + printk("door button: %d\n", value); +#endif + input_report_key(idev, BTN_0, value); + input_sync(idev); + return IRQ_HANDLED; +} + +static int datr_event(struct input_dev *dev, unsigned int type, + unsigned int code, int value) { + if (type == EV_LED) { + if (15 == code) { + if (1 == value) { + /* force door event */ + /* Set the wrong bit value to ensure the creation of an event */ + unsigned long flags; + int val; + local_irq_save(flags); + val = gpio_get_value(GPIO_DOOR); + dev->key[BIT_MASK(BTN_0)] = !val; + input_report_key(dev, BTN_0, val); + local_irq_restore(flags); + input_sync(dev); + } + } else { + /** led status modification */ + ledr = (ledr & ~(1 << code)) | (value ? 0 : (1 << code)); + LEDR = ledr; + } + } else { + if (type == EV_FF) { + /** write a VME reset */ + if (1 == code) { + gpio_set_value(GPIO_RESET_VME, value); + } else { + /** read VME reset state */ + if (2 == code) { + input_report_key(dev, 1, gpio_get_value(GPIO_RESET_VME)); + input_sync(dev); + } + } + } else + return -1; + } + return 0; +} + +static int datr_input_init(void) { + struct input_dev *datr_input; + int err; + int irq; + + /* turn off all LEDs */ + LEDR = ledr; + datr_input = input_allocate_device(); + if (!datr_input) { + printk(KERN_ERR "failed to allocate input device\n"); + return 1; + } + datr_input->name = "datr"; + datr_input->evbit[0] = BIT_MASK(EV_KEY) | BIT(EV_LED) | BIT(EV_FF); + datr_input->keybit[BIT_WORD(BTN_0)] = BIT_MASK(BTN_0); + datr_input->ledbit[0] = 0x8fff; + datr_input->event = datr_event; + + if((err = input_register_device(datr_input))) { + printk("failed to register input device\n"); + goto fail; + } + + if((err = gpio_request(GPIO_DOOR, "door"))) { + printk("failed to obtain door GPIO: %d\n", err); + goto fail; + } + + if((err = gpio_direction_input(GPIO_DOOR))) { + printk("failed to setup door GPIO: %d\n", err); + goto fail; + } + + gpio_request(GPIO_RESET_VME, "vacfail"); + gpio_direction_output(GPIO_RESET_VME, 0); + + /* install door interrupt handler */ + irq = gpio_to_irq(GPIO_DOOR); + + if((err = request_irq(irq, door_int, DOOR_FLAGS, "door", datr_input))) { + printk("failed to obtain door irq %d: %d\n", irq, err); + } else { + printk("datra door irq: %d\n", irq); + } +#if 1 + printk(KERN_INFO "Finished datr_input_init()\n"); +#endif + return 0; + +fail: input_free_device(datr_input); + return 1; +} + +device_initcall(datr_input_init); + +/* + * USB Device Controller + */ + +static void datr_udc_command(int cmd) +{ + switch(cmd) { + case PXA2XX_UDC_CMD_CONNECT: + printk(KERN_INFO "UDC_conn0 %#x\n", DATR_CR(0)); + DATR_CR(0) |= 1; + printk(KERN_INFO "UDC_conn1 %#x\n", DATR_CR(0)); + break; + case PXA2XX_UDC_CMD_DISCONNECT: + printk(KERN_INFO "UDC_disc0 %#x\n", DATR_CR(0)); + DATR_CR(0) &= ~1; + printk(KERN_INFO "UDC_disc1 %#x\n", DATR_CR(0)); + break; + } +} + + +static int datr_udc_is_connected(void) +{ + printk(KERN_INFO "UDC_is_conn %#x\n", DATR_CR(0)); + return (DATR_CR(0) & 2) == 0; +} + + +static struct pxa2xx_udc_mach_info udc_info __initdata = { + .udc_command = datr_udc_command, + .udc_is_connected = datr_udc_is_connected, + .gpio_pullup = -1, + .gpio_vbus = -1 +}; + +static unsigned long datr_pin_config[] __initdata = { + GPIO49_nPWE, + GPIO18_RDY, + GPIO15_nCS_1, + GPIO80_nCS_4, + GPIO91_GPIO // ISP1760 interrupt +}; + + +/* + * declare the available device resources on this board + */ +static struct platform_device *devices[] __initdata = { + &datr_flash +#ifdef CONFIG_SMC91X + ,&smc91x_device +#endif +#if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE) + ,&isp1760_device +#endif +}; + +static void __init datr_init(void) +{ + /** @todo remove this temporary command which open the external bus */ + DATR_CR(0); + + /* system bus arbiter setting + * - Core_Park + * - LCD_wt:DMA_wt:CORE_Wt = 2:3:4 + */ + ARB_CNTRL = ARB_CORE_PARK | 0x234; + pxa2xx_mfp_config(ARRAY_AND_SIZE(datr_pin_config)); + +#if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE) + /* Configure timing of CS4 (USB2) */ + MSC2 = (MSC2 & 0xffff0000) | 0x0234; + set_irq_type(ISP1761_IRQ, IRQ_TYPE_EDGE_FALLING); +#endif + + platform_add_devices(devices, ARRAY_SIZE(devices)); + + pxa_set_udc_info(&udc_info); + + printk("Marco %s, %x\n", __FUNCTION__, DATR_CR(0)); + DATR_CR(0) = 0xff; + printk("Marco %s, %x\n", __FUNCTION__, DATR_CR(0)); + DATR_CR(0) = 0xff; + printk("Marco %s, %x\n", __FUNCTION__, DATR_CR(0)); + DATR_CR(0) = 0; + printk("Marco %s, %x\n", __FUNCTION__, DATR_CR(0)); +} + +static struct map_desc datr_io_desc[] __initdata = { + { /* CPLD regs */ + .virtual = DATR_CTRL_BASE, + .pfn = __phys_to_pfn(DATR_CTRL_PHYS), + .length = DATR_CTRL_SIZE, + .type = MT_DEVICE + }, + { /* LEDs */ + .virtual = DATR_LEDS_BASE, + .pfn = __phys_to_pfn(DATR_LEDS_PHYS), + .length = DATR_LEDS_SIZE, + .type = MT_DEVICE + } +}; + +static void __init datr_map_io(void) +{ + pxa_map_io(); + iotable_init(datr_io_desc, ARRAY_SIZE(datr_io_desc)); + + /* initialiye sleep mode regs (wake-up sources, etc) */ + PGSR0 = 0x01308000; + PGSR1 = 0x00CF0002; + PGSR2 = 0x0E294000; + PGSR3 = 0x0000C000; + PWER = 0xC0000003; + PRER = 0x00000000; + PFER = 0x00000003; + + printk("Marco %s, testpoint\n", __FUNCTION__); + + /* configure CPLD chip select */ + MSC0 = (MSC0 & 0x0000ffff) | 0x53dc0000; +} + +MACHINE_START(DATR, "HaslerRail, Inc. DATR") + /* Maintainer: HaslerRail, Inc. */ + .phys_io = 0x40000000, + .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, + .boot_params = 0xa0000100, + .map_io = datr_map_io, + .init_irq = pxa27x_init_irq, + .init_machine = datr_init, + .timer = &pxa_timer, +MACHINE_END diff -urN linux-2.6.30.4-orig/arch/arm/mach-pxa/include/mach/datr.h linux-2.6.30.4/arch/arm/mach-pxa/include/mach/datr.h --- linux-2.6.30.4-orig/arch/arm/mach-pxa/include/mach/datr.h 1970-01-01 01:00:00.000000000 +0100 +++ linux-2.6.30.4/arch/arm/mach-pxa/include/mach/datr.h 2009-08-05 16:11:13.000000000 +0200 @@ -0,0 +1,68 @@ +/* + * linux/include/asm-arm/arch-pxa/datr.h + * + * Copyright (C) 2007, HaslerRail, Inc. + * + * based on: + * + * linux/include/asm-arm/arch-pxa/pcm027.h + * + * (c) 2003 Phytec Messtechnik GmbH + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* + * GPIOs Interrupt Source + */ +#define GPIO_DATR_ETH 52 +#define GPIO_DATR_ACFAIL + +/* + * ethernet chip (SMSC91C111) + */ +#define DATR_ETH_PHYS PXA_CS5_PHYS +#define DATR_ETH_SIZE (1*1024*1024) +#define DATR_ETH_IRQ IRQ_GPIO(GPIO_DATR_ETH) +#define DATR_ETH_IRQ_EDGE IRQ_TYPE_EDGE_RISING + +/* + * Control PLD Regs + */ +#define DATR_CTRL_PHYS (PXA_CS1_PHYS + (0 << 23)) +#define DATR_CTRL_BASE 0xea000000 +#define DATR_CTRL_SIZE (1*1024*1024) + +/* Flash memory */ +#define DATR_FLASH_PHYS 0x00000000 +#define DATR_FLASH_SIZE 0x02000000 + +/* + * LEDs + */ +#define DATR_LEDS_PHYS (PXA_CS1_PHYS + (1 << 23)) +#define DATR_LEDS_BASE 0xea100000 +#define DATR_LEDS_SIZE (1*1024*1024) + +#define DATR_CTRL_P2V(x) ((x) - DATR_CTRL_PHYS + DATR_CTRL_BASE) +#define DATR_CTRL_V2P(x) ((x) - DATR_CTRL_BASE + DATR_CTRL_PHYS) + +#ifndef __ASSEMBLY__ +# define __DATR_CTRL_REG(x) (*((volatile unsigned short *)DATR_CTRL_P2V(x))) +#else +# define __DATR_CTRL_REG(x) DATR_CTRL_P2V(x) +#endif + +#define DATR_CR(x) __DATR_CTRL_REG(DATR_CTRL_PHYS + ((x) << 1)) diff -urN linux-2.6.30.4-orig/arch/arm/mach-pxa/include/mach/debug-macro.S linux-2.6.30.4/arch/arm/mach-pxa/include/mach/debug-macro.S --- linux-2.6.30.4-orig/arch/arm/mach-pxa/include/mach/debug-macro.S 2009-07-31 00:34:47.000000000 +0200 +++ linux-2.6.30.4/arch/arm/mach-pxa/include/mach/debug-macro.S 2009-08-05 16:11:13.000000000 +0200 @@ -18,7 +18,7 @@ tst \rx, #1 @ MMU enabled? moveq \rx, #0x40000000 @ physical movne \rx, #io_p2v(0x40000000) @ virtual - orr \rx, \rx, #0x00100000 + orr \rx, \rx, #0x00700000 .endm #define UART_SHIFT 2 diff -urN linux-2.6.30.4-orig/arch/arm/mach-pxa/Kconfig linux-2.6.30.4/arch/arm/mach-pxa/Kconfig --- linux-2.6.30.4-orig/arch/arm/mach-pxa/Kconfig 2009-07-31 00:34:47.000000000 +0200 +++ linux-2.6.30.4/arch/arm/mach-pxa/Kconfig 2009-08-05 16:11:13.000000000 +0200 @@ -339,6 +339,10 @@ select PXA_SSP select PXA_HAVE_BOARD_IRQS +config MACH_DATR + bool "HaslerRail DATR" + select PXA27x + config ARCH_PXA_PALM bool "PXA based Palm PDAs" select HAVE_PWM diff -urN linux-2.6.30.4-orig/arch/arm/mach-pxa/Makefile linux-2.6.30.4/arch/arm/mach-pxa/Makefile --- linux-2.6.30.4-orig/arch/arm/mach-pxa/Makefile 2009-07-31 00:34:47.000000000 +0200 +++ linux-2.6.30.4/arch/arm/mach-pxa/Makefile 2009-08-05 16:11:13.000000000 +0200 @@ -44,6 +44,7 @@ obj-$(CONFIG_CORGI_SSP_DEPRECATED) += corgi_ssp.o corgi_lcd.o obj-$(CONFIG_MACH_POODLE) += poodle.o obj-$(CONFIG_MACH_PCM027) += pcm027.o +obj-$(CONFIG_MACH_DATR) += datr.o obj-$(CONFIG_MACH_PCM990_BASEBOARD) += pcm990-baseboard.o obj-$(CONFIG_MACH_TOSA) += tosa.o obj-$(CONFIG_MACH_EM_X270) += em-x270.o diff -urN linux-2.6.30.4-orig/include/linux/usb/isp1760.h linux-2.6.30.4/include/linux/usb/isp1760.h --- linux-2.6.30.4-orig/include/linux/usb/isp1760.h 1970-01-01 01:00:00.000000000 +0100 +++ linux-2.6.30.4/include/linux/usb/isp1760.h 2009-08-05 16:11:14.000000000 +0200 @@ -0,0 +1,18 @@ +/* + * board initialization should put one of these into dev->platform_data + * and place the isp1760 onto platform_bus named "isp1760-hcd". + */ + +#ifndef __LINUX_USB_ISP1760_H +#define __LINUX_USB_ISP1760_H + +struct isp1760_platform_data { + unsigned is_isp1761:1; /* Chip is ISP1761 */ + unsigned bus_width_16:1; /* 16/32-bit data bus width */ + unsigned port1_otg:1; /* Port 1 supports OTG */ + unsigned analog_oc:1; /* Analog overcurrent */ + unsigned dack_polarity_high:1; /* DACK active high */ + unsigned dreq_polarity_high:1; /* DREQ active high */ +}; + +#endif /* __LINUX_USB_ISP1760_H */