From fde984555f933ff141ddc9bb3776096c5787e80d Mon Sep 17 00:00:00 2001
From: Tuomas Kulve <tuomas@kulve.fi>
Date: Sun, 27 Apr 2008 19:26:10 +0300
Subject: [PATCH] Applied header.patch, board-init.patch, and arch-config.patch. Changed pxa_init_irq to pxa27x_init_irq in MACHINE_START in gumstix.c.

---
 arch/arm/mach-pxa/Kconfig          |   35 ++++++---
 arch/arm/mach-pxa/gumstix.c        |  130 +++++++-----------------------
 include/asm-arm/arch-pxa/gumstix.h |  157 ++++++++++++++++++++++++++----------
 3 files changed, 167 insertions(+), 155 deletions(-)

diff --git a/arch/arm/mach-pxa/Kconfig b/arch/arm/mach-pxa/Kconfig
index 5da7a68..ed63963 100644
--- a/arch/arm/mach-pxa/Kconfig
+++ b/arch/arm/mach-pxa/Kconfig
@@ -24,10 +24,8 @@ choice
 	prompt "Select target board"
 
 config ARCH_GUMSTIX
-	bool "Gumstix XScale boards"
-	help
-	  Say Y here if you intend to run this kernel on a
-	  Gumstix Full Function Minature Computer.
+        bool "Gumstix Platform"
+        depends on ARCH_PXA
 
 config ARCH_LUBBOCK
 	bool "Intel DBPXA250 Development Platform"
@@ -166,18 +164,33 @@ endchoice
 
 endif
 
-if ARCH_GUMSTIX
-
 choice
-	prompt "Select target Gumstix board"
+	depends on ARCH_GUMSTIX
+	prompt "Gumstix Platform Version"
+	default ARCH_GUMSTIX_F
 
-config MACH_GUMSTIX_F
-	bool "Basix, Connex, ws-200ax, ws-400ax systems"
+config ARCH_GUMSTIX_ORIG
+	bool "Original Gumstix"
 	select PXA25x
+	help
+		The original gumstix platform, including the gs-200x and gs-400x and the waysmall
+		systems using these boards. (Almost nobody has one of these)
 
-endchoice
+config ARCH_GUMSTIX_F
+	bool "Gumstix-F"
+	select PXA25x
+	help
+		The updated Gumstix basix and connex boards with 60-pin connector, and
+		waysmall systems using these boards, including ws-200ax and ws-400ax.
 
-endif
+config ARCH_GUMSTIX_VERDEX
+	bool "Gumstix Verdex"
+	select PXA27x
+	help
+		The Gumstix verdex boards with 24, 60, and 120-pin connectors, and
+		computer systems using these boards.
+
+endchoice
 
 
 if MACH_TRIZEPS4
diff --git a/arch/arm/mach-pxa/gumstix.c b/arch/arm/mach-pxa/gumstix.c
index f01d185..59003f6 100644
--- a/arch/arm/mach-pxa/gumstix.c
+++ b/arch/arm/mach-pxa/gumstix.c
@@ -1,94 +1,38 @@
 /*
  *  linux/arch/arm/mach-pxa/gumstix.c
  *
- *  Support for the Gumstix motherboards.
+ *  Support for the Gumstix computer platform
  *
- *  Original Author:	Craig Hughes
- *  Created:	Feb 14, 2008
- *  Copyright:	Craig Hughes
+ *  Author:	Craig Hughes
+ *  Created:	December 8 2004
+ *  Copyright:	(C) 2004, Craig Hughes
  *
  *  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.
- *
- *  Implemented based on lubbock.c by Nicolas Pitre and code from Craig
- *  Hughes
  */
 
-#include <linux/module.h>
-#include <linux/kernel.h>
+#include <asm/types.h>
+
 #include <linux/init.h>
+#include <linux/device.h>
 #include <linux/platform_device.h>
-#include <linux/interrupt.h>
-#include <linux/mtd/mtd.h>
-#include <linux/mtd/partitions.h>
 
-#include <asm/setup.h>
-#include <asm/memory.h>
-#include <asm/mach-types.h>
 #include <asm/hardware.h>
-#include <asm/irq.h>
-#include <asm/sizes.h>
-
+#include <asm/mach-types.h>
 #include <asm/mach/arch.h>
-#include <asm/mach/map.h>
 #include <asm/mach/irq.h>
-#include <asm/mach/flash.h>
-#include <asm/arch/mmc.h>
 #include <asm/arch/udc.h>
-#include <asm/arch/gumstix.h>
-
+#include <asm/arch/mmc.h>
 #include <asm/arch/pxa-regs.h>
-#include <asm/arch/pxa2xx-regs.h>
+#include <asm/arch/pxa2xx-gpio.h>
+#include <asm/arch/gumstix.h>
 
 #include "generic.h"
 
-static struct resource flash_resource = {
-	.start	= 0x00000000,
-	.end	= SZ_64M - 1,
-	.flags	= IORESOURCE_MEM,
-};
-
-static struct mtd_partition gumstix_partitions[] = {
-	{
-		.name =		"Bootloader",
-		.size =		0x00040000,
-		.offset =	0,
-		.mask_flags =	MTD_WRITEABLE  /* force read-only */
-	} , {
-		.name =		"rootfs",
-		.size =		MTDPART_SIZ_FULL,
-		.offset =	MTDPART_OFS_APPEND
-	}
-};
-
-static struct flash_platform_data gumstix_flash_data = {
-	.map_name	= "cfi_probe",
-	.parts		= gumstix_partitions,
-	.nr_parts	= ARRAY_SIZE(gumstix_partitions),
-	.width		= 2,
-};
-
-static struct platform_device gumstix_flash_device = {
-	.name		= "pxa2xx-flash",
-	.id		= 0,
-	.dev = {
-		.platform_data = &gumstix_flash_data,
-	},
-	.resource = &flash_resource,
-	.num_resources = 1,
-};
-
-static struct platform_device *devices[] __initdata = {
-	&gumstix_flash_device,
-};
-
-#ifdef CONFIG_MMC_PXA
-static struct pxamci_platform_data gumstix_mci_platform_data;
-
-static int gumstix_mci_init(struct device *dev, irq_handler_t detect_int,
-				void *data)
+static int gumstix_mci_init(struct device *dev, irqreturn_t (*lubbock_detect_int)(int, void *, struct pt_regs *), void *data)
 {
+	// Set up MMC controller
 	pxa_gpio_mode(GPIO6_MMCCLK_MD);
 	pxa_gpio_mode(GPIO53_MMCCLK_MD);
 	pxa_gpio_mode(GPIO8_MMCCS0_MD);
@@ -98,50 +42,36 @@ static int gumstix_mci_init(struct device *dev, irq_handler_t detect_int,
 
 static struct pxamci_platform_data gumstix_mci_platform_data = {
 	.ocr_mask	= MMC_VDD_32_33|MMC_VDD_33_34,
-	.init		= gumstix_mci_init,
+	.init		= &gumstix_mci_init,
 };
 
-static void __init gumstix_mmc_init(void)
-{
-	pxa_set_mci_info(&gumstix_mci_platform_data);
-}
-#else
-static void __init gumstix_mmc_init(void)
-{
-	printk(KERN_INFO "Gumstix mmc disabled\n");
-}
-#endif
-
-#ifdef CONFIG_USB_GADGET_PXA2XX
 static struct pxa2xx_udc_mach_info gumstix_udc_info __initdata = {
-	.gpio_vbus		= GPIO_GUMSTIX_USB_GPIOn,
-	.gpio_pullup		= GPIO_GUMSTIX_USB_GPIOx,
+	.gpio_vbus	= GPIO_GUMSTIX_USB_GPIOn,
+	.gpio_pullup	= GPIO_GUMSTIX_USB_GPIOx,
 };
 
-static void __init gumstix_udc_init(void)
-{
-	pxa_set_udc_info(&gumstix_udc_info);
-}
-#else
-static void gumstix_udc_init(void)
-{
-	printk(KERN_INFO "Gumstix udc is disabled\n");
-}
-#endif
+static struct platform_device gum_audio_device = {
+	.name		= "pxa2xx-ac97",
+	.id		= -1,
+};
+
+static struct platform_device *devices[] __initdata = {
+	&gum_audio_device,
+};
 
 static void __init gumstix_init(void)
 {
-	gumstix_udc_init();
-	gumstix_mmc_init();
+	pxa_set_mci_info(&gumstix_mci_platform_data);
+	pxa_set_udc_info(&gumstix_udc_info);
 	(void) platform_add_devices(devices, ARRAY_SIZE(devices));
 }
 
-MACHINE_START(GUMSTIX, "Gumstix")
+MACHINE_START(GUMSTIX, "The Gumstix Platform")
 	.phys_io	= 0x40000000,
-	.boot_params	= 0xa0000100, /* match u-boot bi_boot_params */
+	.boot_params	= 0xa0000100,
 	.io_pg_offst	= (io_p2v(0x40000000) >> 18) & 0xfffc,
+	.timer          = &pxa_timer,
 	.map_io		= pxa_map_io,
-	.init_irq	= pxa25x_init_irq,
-	.timer		= &pxa_timer,
+	.init_irq	= pxa27x_init_irq,
 	.init_machine	= gumstix_init,
 MACHINE_END
diff --git a/include/asm-arm/arch-pxa/gumstix.h b/include/asm-arm/arch-pxa/gumstix.h
index 6fa85c4..9c01373 100644
--- a/include/asm-arm/arch-pxa/gumstix.h
+++ b/include/asm-arm/arch-pxa/gumstix.h
@@ -12,14 +12,12 @@
 #define GPIO_GUMSTIX_BTRESET_MD		(GPIO_GUMSTIX_BTRESET | GPIO_OUT)
 
 
-/*
-GPIOn - Input from MAX823 (or equiv), normalizing USB +5V into a clean
-interrupt signal for determining cable presence. On the original gumstix,
-this is GPIO81, and GPIO83 needs to be defined as well. On the gumstix F,
-this moves to GPIO17 and GPIO37. */
-
-/* GPIOx - Connects to USB D+ and used as a pull-up after GPIOn
-has detected a cable insertion; driven low otherwise. */
+/* GPIOn - Input from MAX823 (or equiv), normalizing USB +5V 
+     into a clean interrupt signal for determining cable presence 
+     On the original gumstix, this is GPIO81, and GPIO83 needs to be defined as well.
+     On the gumstix F, this moves to GPIO17 and GPIO37 */
+/* GPIOx - Connects to USB D+ and used as a pull-up after GPIOn 
+     has detected a cable insertion; driven low otherwise. */
 
 #ifdef CONFIG_ARCH_GUMSTIX_ORIG
 
@@ -33,64 +31,135 @@ has detected a cable insertion; driven low otherwise. */
 
 #endif
 
-/* usb state change */
-#define GUMSTIX_USB_INTR_IRQ		IRQ_GPIO(GPIO_GUMSTIX_USB_GPIOn)
-
+#define GUMSTIX_USB_INTR_IRQ		IRQ_GPIO(GPIO_GUMSTIX_USB_GPIOn)    /* usb state change */
 #define GPIO_GUMSTIX_USB_GPIOn_MD	(GPIO_GUMSTIX_USB_GPIOn | GPIO_IN)
 #define GPIO_GUMSTIX_USB_GPIOx_CON_MD	(GPIO_GUMSTIX_USB_GPIOx | GPIO_OUT)
 #define GPIO_GUMSTIX_USB_GPIOx_DIS_MD	(GPIO_GUMSTIX_USB_GPIOx | GPIO_IN)
 
-/*
- * SD/MMC definitions
- */
-#define GUMSTIX_GPIO_nSD_WP		22 /* SD Write Protect */
-#define GUMSTIX_GPIO_nSD_DETECT		11 /* MMC/SD Card Detect */
-#define GUMSTIX_IRQ_GPIO_nSD_DETECT	IRQ_GPIO(GUMSTIX_GPIO_nSD_DETECT)
 
 /*
  * SMC Ethernet definitions
  * ETH_RST provides a hardware reset line to the ethernet chip
  * ETH is the IRQ line in from the ethernet chip to the PXA
  */
+#ifndef CONFIG_ARCH_GUMSTIX_VERDEX
 #define GPIO_GUMSTIX_ETH0_RST		80
-#define GPIO_GUMSTIX_ETH0_RST_MD	(GPIO_GUMSTIX_ETH0_RST | GPIO_OUT)
+#define GPIO_GUMSTIX_ETH0		36
+#else
+#define GPIO_GUMSTIX_ETH0_RST		32
+#define GPIO_GUMSTIX_ETH0		99
+#endif
 #define GPIO_GUMSTIX_ETH1_RST		52
-#define GPIO_GUMSTIX_ETH1_RST_MD	(GPIO_GUMSTIX_ETH1_RST | GPIO_OUT)
+#define GPIO_GUMSTIX_ETH1		27
 
-#define GPIO_GUMSTIX_ETH0		36
+#define GPIO_GUMSTIX_ETH0_RST_MD	(GPIO_GUMSTIX_ETH0_RST | GPIO_OUT)
+#define GPIO_GUMSTIX_ETH1_RST_MD	(GPIO_GUMSTIX_ETH1_RST | GPIO_OUT)
 #define GPIO_GUMSTIX_ETH0_MD		(GPIO_GUMSTIX_ETH0 | GPIO_IN)
-#define GUMSTIX_ETH0_IRQ		IRQ_GPIO(GPIO_GUMSTIX_ETH0)
-#define GPIO_GUMSTIX_ETH1		27
 #define GPIO_GUMSTIX_ETH1_MD		(GPIO_GUMSTIX_ETH1 | GPIO_IN)
+
+#define GUMSTIX_ETH0_IRQ		IRQ_GPIO(GPIO_GUMSTIX_ETH0)
 #define GUMSTIX_ETH1_IRQ		IRQ_GPIO(GPIO_GUMSTIX_ETH1)
 
 
 /* CF reset line */
-#define GPIO8_RESET			8
+#define GPIO8_CF_RESET			8
+#define GPIO97_CF_RESET			97
+#define GPIO110_CF_RESET		110
+#ifndef CONFIG_ARCH_GUMSTIX_VERDEX
+#define GPIO_GUMSTIX_CF_RESET		GPIO8_CF_RESET
+#else
+#define GPIO_GUMSTIX_CF_RESET		GPIO97_CF_RESET
+#endif
+#define GPIO_GUMSTIX_CF_OLD_RESET	GPIO110_CF_RESET
+
+
+/* CF signals shared by both sockets */
+#define GPIO_GUMSTIX_nPOE GPIO48_nPOE
+#define GPIO_GUMSTIX_nPWE GPIO49_nPWE
+#define GPIO_GUMSTIX_nPIOR GPIO50_nPIOR
+#define GPIO_GUMSTIX_nPIOW GPIO51_nPIOW
+#ifndef CONFIG_ARCH_GUMSTIX_VERDEX
+#define GPIO_GUMSTIX_nPCE_1 GPIO52_nPCE_1
+#define GPIO_GUMSTIX_nPCE_2 GPIO53_nPCE_2
+#define GPIO_GUMSTIX_pSKTSEL GPIO54_pSKTSEL
+#else
+#define GPIO_GUMSTIX_nPCE_1 GPIO102_nPCE_1
+#define GPIO_GUMSTIX_nPCE_2 GPIO105_nPCE_2
+#define GPIO_GUMSTIX_pSKTSEL GPIO79_pSKTSEL
+#endif
+#define GPIO_GUMSTIX_nPREG GPIO55_nPREG
+#define GPIO_GUMSTIX_nPWAIT GPIO56_nPWAIT
+#define GPIO_GUMSTIX_nIOIS16 GPIO57_nIOIS16
+
+#define GPIO_GUMSTIX_nPOE_MD GPIO48_nPOE_MD
+#define GPIO_GUMSTIX_nPWE_MD GPIO49_nPWE_MD
+#define GPIO_GUMSTIX_nPIOR_MD GPIO50_nPIOR_MD
+#define GPIO_GUMSTIX_nPIOW_MD GPIO51_nPIOW_MD
+#ifndef CONFIG_ARCH_GUMSTIX_VERDEX
+#define GPIO_GUMSTIX_nPCE_1_MD GPIO52_nPCE_1_MD
+#define GPIO_GUMSTIX_nPCE_2_MD GPIO53_nPCE_2_MD
+#define GPIO_GUMSTIX_pSKTSEL_MD GPIO54_pSKTSEL_MD
+#else
+#define GPIO_GUMSTIX_nPCE_1_MD GPIO102_nPCE_1_MD
+#define GPIO_GUMSTIX_nPCE_2_MD GPIO105_nPCE_2_MD
+#define GPIO_GUMSTIX_pSKTSEL_MD GPIO79_pSKTSEL_MD
+#endif
+#define GPIO_GUMSTIX_nPREG_MD GPIO55_nPREG_MD
+#define GPIO_GUMSTIX_nPWAIT_MD GPIO56_nPWAIT_MD
+#define GPIO_GUMSTIX_nIOIS16_MD GPIO57_nIOIS16_MD
 
 /* CF slot 0 */
-#define GPIO4_nBVD1			4
-#define GPIO4_nSTSCHG			GPIO4_nBVD1
-#define GPIO11_nCD			11
-#define GPIO26_PRDY_nBSY		26
-#define GUMSTIX_S0_nSTSCHG_IRQ		IRQ_GPIO(GPIO4_nSTSCHG)
-#define GUMSTIX_S0_nCD_IRQ		IRQ_GPIO(GPIO11_nCD)
-#define GUMSTIX_S0_PRDY_nBSY_IRQ	IRQ_GPIO(GPIO26_PRDY_nBSY)
+#define GPIO4_nBVD1_0			4
+#define GPIO4_nSTSCHG_0			GPIO4_nBVD1_0
+#define GPIO11_nCD_0			11
+#define GPIO26_PRDY_nBSY_0		26
+
+#define GPIO111_nBVD1_0			111
+#define GPIO111_nSTSCHG_0		GPIO111_nBVD1_0
+#define GPIO104_nCD_0			104
+#define GPIO96_PRDY_nBSY_0		96
+#define GPIO109_PRDY_nBSY_0		109
+
+#ifndef CONFIG_ARCH_GUMSTIX_VERDEX
+#define GPIO_GUMSTIX_nBVD1_0		GPIO4_nBVD1_0
+#define GPIO_GUMSTIX_nSTSCHG_0		GPIO4_nSTSCHG_0
+#define GPIO_GUMSTIX_nCD_0		GPIO11_nCD_0
+#define GPIO_GUMSTIX_PRDY_nBSY_0	GPIO26_PRDY_nBSY_0
+#else
+#define GPIO_GUMSTIX_nBVD1_0		GPIO111_nBVD1_0
+#define GPIO_GUMSTIX_nSTSCHG_0		GPIO111_nSTSCHG_0
+#define GPIO_GUMSTIX_nCD_0		GPIO104_nCD_0
+#define GPIO_GUMSTIX_PRDY_nBSY_0	GPIO96_PRDY_nBSY_0
+#endif
+#define GPIO_GUMSTIX_PRDY_nBSY_0_OLD	GPIO109_PRDY_nBSY_0
+
+#define GUMSTIX_S0_nSTSCHG_IRQ		IRQ_GPIO(GPIO_GUMSTIX_nSTSCHG_0)
+#define GUMSTIX_S0_nCD_IRQ		IRQ_GPIO(GPIO_GUMSTIX_nCD_0)
+#define GUMSTIX_S0_PRDY_nBSY_IRQ	IRQ_GPIO(GPIO_GUMSTIX_PRDY_nBSY_0)
+#define GUMSTIX_S0_PRDY_nBSY_OLD_IRQ	IRQ_GPIO(GPIO_GUMSTIX_PRDY_nBSY_0_OLD)
 
 /* CF slot 1 */
-#define GPIO18_nBVD1			18
-#define GPIO18_nSTSCHG			GPIO18_nBVD1
-#define GPIO36_nCD			36
-#define GPIO27_PRDY_nBSY		27
-#define GUMSTIX_S1_nSTSCHG_IRQ		IRQ_GPIO(GPIO18_nSTSCHG)
-#define GUMSTIX_S1_nCD_IRQ		IRQ_GPIO(GPIO36_nCD)
-#define GUMSTIX_S1_PRDY_nBSY_IRQ	IRQ_GPIO(GPIO27_PRDY_nBSY)
+#define GPIO18_nBVD1_1			18
+#define GPIO18_nSTSCHG_1		GPIO18_nBVD1_1
+#define GPIO36_nCD_1			36
+#define GPIO27_PRDY_nBSY_1		27
+
+#define GPIO_GUMSTIX_nBVD1_1		GPIO18_nBVD1_1
+#define GPIO_GUMSTIX_nSTSCHG_1		GPIO18_nSTSCHG_1
+#define GPIO_GUMSTIX_nCD_1		GPIO36_nCD_1
+#define GPIO_GUMSTIX_PRDY_nBSY_1	GPIO27_PRDY_nBSY_1
+
+#define GUMSTIX_S1_nSTSCHG_IRQ		IRQ_GPIO(GPIO_GUMSTIX_nSTSCHG_1)
+#define GUMSTIX_S1_nCD_IRQ		IRQ_GPIO(GPIO_GUMSTIX_nCD_1)
+#define GUMSTIX_S1_PRDY_nBSY_IRQ	IRQ_GPIO(GPIO_GUMSTIX_PRDY_nBSY_1)
 
 /* CF GPIO line modes */
-#define GPIO4_nSTSCHG_MD		(GPIO4_nSTSCHG | GPIO_IN)
-#define GPIO8_RESET_MD			(GPIO8_RESET | GPIO_OUT)
-#define GPIO11_nCD_MD			(GPIO11_nCD | GPIO_IN)
-#define GPIO18_nSTSCHG_MD		(GPIO18_nSTSCHG | GPIO_IN)
-#define GPIO26_PRDY_nBSY_MD		(GPIO26_PRDY_nBSY | GPIO_IN)
-#define GPIO27_PRDY_nBSY_MD		(GPIO27_PRDY_nBSY | GPIO_IN)
-#define GPIO36_nCD_MD			(GPIO36_nCD | GPIO_IN)
+#define GPIO_GUMSTIX_CF_RESET_MD	( GPIO_GUMSTIX_CF_RESET | GPIO_OUT )
+#define GPIO_GUMSTIX_CF_OLD_RESET_MD	( GPIO_GUMSTIX_CF_OLD_RESET | GPIO_OUT )
+#define GPIO_GUMSTIX_nSTSCHG_0_MD	( GPIO_GUMSTIX_nSTSCHG_0 | GPIO_IN )
+#define GPIO_GUMSTIX_nCD_0_MD		( GPIO_GUMSTIX_nCD_0 | GPIO_IN )
+#define GPIO_GUMSTIX_PRDY_nBSY_0_MD	( GPIO_GUMSTIX_PRDY_nBSY_0 | GPIO_IN )
+#define GPIO_GUMSTIX_PRDY_nBSY_0_OLD_MD	( GPIO_GUMSTIX_PRDY_nBSY_0_OLD | GPIO_IN )
+#define GPIO_GUMSTIX_nSTSCHG_1_MD	( GPIO_GUMSTIX_nSTSCHG_1 | GPIO_IN )
+#define GPIO_GUMSTIX_nCD_1_MD		( GPIO_GUMSTIX_nCD_1 | GPIO_IN )
+#define GPIO_GUMSTIX_PRDY_nBSY_1_MD	( GPIO_GUMSTIX_PRDY_nBSY_1 | GPIO_IN )
-- 
1.5.3.7


