Module Name:    src
Committed By:   kiyohara
Date:           Sun Aug  9 07:10:13 UTC 2009

Modified Files:
        src/sys/arch/evbarm/conf: GUMSTIX GUMSTIX_INSTALL files.gumstix
        src/sys/arch/evbarm/gumstix: gumstix_machdep.c gumstix_start.S
            gumstixreg.h gumstixvar.h gxio.c gxpcic.c if_sm_gxio.c
Added Files:
        src/sys/arch/evbarm/gumstix: gxlcd.c if_smsh_gxio.c

Log Message:
Support verdex and verdex-pro.
  And
    + Support LCD controller.
    + Support SMSC LAN 9117 Ethernet controller.
    + Comment outed 'options GXIO_DEFAULT_EXPANSION'.  As for verdex-pro being
      sold now, this option becomes obstructive.
    + Remove some usb devices in GUMSTIX.
    + Update GUMSTIX.

Also
 Fix ARM ABI in gumstix_start.S.  Thanks Brett Slager <bds at ifgd.net>.
 Calculate RAM size in gumstix_start.S.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/evbarm/conf/GUMSTIX
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/evbarm/conf/GUMSTIX_INSTALL
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/evbarm/conf/files.gumstix
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/evbarm/gumstix/gumstix_machdep.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/evbarm/gumstix/gumstix_start.S
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/evbarm/gumstix/gumstixreg.h \
    src/sys/arch/evbarm/gumstix/gumstixvar.h
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/evbarm/gumstix/gxio.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/evbarm/gumstix/gxlcd.c \
    src/sys/arch/evbarm/gumstix/if_smsh_gxio.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/evbarm/gumstix/gxpcic.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/evbarm/gumstix/if_sm_gxio.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/evbarm/conf/GUMSTIX
diff -u src/sys/arch/evbarm/conf/GUMSTIX:1.36 src/sys/arch/evbarm/conf/GUMSTIX:1.37
--- src/sys/arch/evbarm/conf/GUMSTIX:1.36	Tue Apr 21 03:00:29 2009
+++ src/sys/arch/evbarm/conf/GUMSTIX	Sun Aug  9 07:10:13 2009
@@ -1,4 +1,4 @@
-#	$NetBSD: GUMSTIX,v 1.36 2009/04/21 03:00:29 nonaka Exp $
+#	$NetBSD: GUMSTIX,v 1.37 2009/08/09 07:10:13 kiyohara Exp $
 #
 #	GUMSTIX -- Gumstix. Inc. gumstix platforms kernel
 #
@@ -14,7 +14,8 @@
 # CPU options
 
 # For XScale systems
-options 	CPU_XSCALE_PXA250	# Support the XScale core
+options 	CPU_XSCALE_PXA250	# Support the basix/connex motherboards
+options 	CPU_XSCALE_PXA270	# Support the verdex motherboards
 makeoptions	CPUFLAGS="-mcpu=xscale"
 
 # Architecture options
@@ -146,6 +147,7 @@
 #options 	PERFCTRS	# performance counters
 options 	DIAGNOSTIC	# internally consistency checks
 options 	DEBUG
+#options 	LOCKDEBUG
 #options 	PMAP_DEBUG	# Enable pmap_debug_level code
 #options 	VERBOSE_INIT_ARM # verbose bootstraping messages
 options 	DDB		# in-kernel debugger
@@ -153,11 +155,12 @@
 #options 	KGDB
 #options 	DEBUG_KGDB
 makeoptions	DEBUG="-g -O2"	# compile full symbol table
-options 	SYMTAB_SPACE=420000
+options 	SYMTAB_SPACE=450000
 #options 	AUDIO_DEBUG=2
 
 config		netbsd		root on ? type ?
 config		netbsd-sm0	root on sm0 type nfs
+config		netbsd-smsh0	root on smsh0 type nfs
 
 # The main bus device
 mainbus0 at root
@@ -172,14 +175,14 @@
 options 	PXAGPIO_HAS_GPION_INTRS
 
 pxagpio0 at pxaip?				# GPIO
-pxartc0	at pxaip?				# RTC
+pxartc0	at pxaip? addr 0x40900000		# RTC
 
 # cotulla integrated 16550 UARTs
 options COM_PXA2X0
 com0	at pxaip? addr 0x40100000 intr 22	# Full Function UART
 com1	at pxaip? addr 0x40700000 intr 20	# Standard UART (console-st)
-com2	at pxaip? addr 0x40200000 intr 21	# Bluetooth UART (older -bt)
-com3	at pxaip? addr 0x41600000 intr 7	# Hardware UART(console-hw, -bt)
+com2	at pxaip? addr 0x40200000 intr 21	# Bluetooth UART (older bt)
+com3	at pxaip? addr 0x41600000 intr 7	# Hardware UART(console-hw, bt)
 options 	FFUARTCONSOLE
 #options 	STUARTCONSOLE
 #options 	BTUARTCONSOLE
@@ -193,17 +196,19 @@
 #options 	PXA2X0_DMAC_FIXED_PRIORITY	# Don't want multiple priority
 
 # AC97 Audio support
-pxaacu0	at pxaip? addr 0x40500000 intr 14
+pxaacu0	at pxaip? addr 0x40500000 intr 14	# Audiostix, Audiostx2, GPSstix
 
 # Audio support
 audio*	at audiobus?
 
 # LCD
-#lcd0	at pxaip?
-#wsdisplay* at lcd? console ?
+lcd0	at pxaip? addr 0x44000000		# consoleLCD-vx,consoleLCD16-vx
+wsdisplay* at lcd? console ?
 
-# USB Controller and Devices
-pxaudc0	at pxaip?				# USB Device Controller
+# USB Host/Device Controller
+ohci0	at pxaip? addr 0x4c000000 intr 3	# consoleLCD-vx,consoleLCD16-vx
+						# ALSO NEEDS pxaudc
+pxaudc0	at pxaip? addr 0x40600000
 
 # integrated MMC/SD contoller
 pxamci0	at pxaip? addr 0x41100000 size 0x48
@@ -217,25 +222,34 @@
 # gumstix device support
 gxio0	at pxaip?
 options 	GXIO_BLUETOOTH_ON_HWUART	# Bluetooth module on HWUART
-options 	GXIO_DEFAULT_EXPANSION="\"netCF\""
+#options 	GXIO_DEFAULT_EXPANSION="\"netCF\""
 
 # gumstix expantion boards
 
 # SMC 91C111
-sm0	at gxio? addr 0x04000300 gpirq 36	# etherstix, net{MMC,CF,DUO}
+sm0	at gxio? addr 0x04000300 gpirq ?
+#sm0	at gxio? addr 0x04000300 gpirq 36	# etherstix,netMMC,netCF,netDUO
+#sm0	at gxio? addr 0x04000300 gpirq 99	# netCF-vx
 sm1	at gxio? addr 0x08000300 gpirq 27	# netDUO(2nd NIC)
 
+# SMSC LAN9117
+smsh0	at gxio? addr 0x04000300 gpirq 99	# netmicroSD-vx, netpro-vx
+
 # Inter-Integrated Circuit controller
-gxiic0	at pxaip?
+gxiic0	at pxaip? addr 0x40300000
 iic*	at gxiic?
 #dsrtc*	at iic? addr 0x68		# Can mount DS1307 at console, breakout
 
 # integrated PCMCIA/CF controller
-pxapcic0 at pxaip?				# cfstix, netCF
+pxapcic0 at pxaip? addr 0x20000000		# cfstix, netCF
 
 # PCMCIA bus support
 pcmcia*	at pxapcic?
 
+# Marvell 88W8385
+#malo*	at pcmcia? function ?		# wifistix, netwifimicrosd, netpro-vx
+
+
 # PCMCIA serial interfaces
 com*	at pcmcia? function ?		# Modems and serial cards
 
@@ -258,182 +272,61 @@
 #slhci*	at pcmcia? function ?		# ScanLogic SL811HS
 
 # USB bus support
+usb*	at ohci?
 #usb*	at slhci?
 
 # USB Hubs
-#uhub*	at usb?
-#uhub*	at uhub? port ?
+uhub*	at usb?
+uhub*	at uhub? port ?
 
 # USB HID device
-#uhidev*	at uhub? port ? configuration ? interface ?
-
-# USB Mice
-#ums*	at uhidev? reportid ?
-#wsmouse* at ums? mux 0
-
-# USB eGalax touch-panel
-#uep*	at uhub? port ?
-#wsmouse* at uep? mux 0
-
-# USB Keyboards
-#ukbd*	at uhidev? reportid ?
-#wskbd*	at ukbd? console ? mux 1
-
-# USB serial adapter
-#ucycom*	at uhidev? reportid ?
-
-# USB Generic HID devices
-#uhid*	at uhidev? reportid ?
-
-# USB Printer
-#ulpt*	at uhub? port ? configuration ? interface ?
+uhidev* at uhub? port ? configuration ? interface ?
 
-# USB Modem
-#umodem*	at uhub? port ? configuration ?
-#ucom*	at umodem?
-
-# Huawei E220 3G/HSDPA modem
-#uhmodem* at uhub? port ? configuration ? interface ?
-#ucom*	at uhmodem? portno ?
+# USB Mice      
+ums*	at uhidev? reportid ?
+wsmouse* at ums? mux 0
+
+# USB Keyboards 
+ukbd*	at uhidev? reportid ?
+wskbd*	at ukbd? console ? mux 1
 
 # USB Mass Storage
-#umass*	at uhub? port ? configuration ? interface ?
+umass*	at uhub? port ? configuration ? interface ?
 #wd*	at umass?
 
-# USB audio
-#uaudio*	at uhub? port ? configuration ?
-
-# USB MIDI
-#umidi* at uhub? port ? configuration ?
-
-# USB IrDA
-# USB-IrDA bridge spec
-#uirda* at uhub? port ? configuration ? interface ?
-#irframe* at uirda?
-
-#stuirda* at uhub? port ? configuration ? interface ?
-#irframe* at stuirda?
-
-# SigmaTel STIr4200 USB/IrDA Bridge
-#ustir* at uhub? port ?
-#irframe* at ustir?
-
-# USB Ethernet adapters
-#aue*	at uhub? port ?		# ADMtek AN986 Pegasus based adapters
-#axe*	at uhub? port ?		# ASIX AX88172 based adapters
-#cdce*	at uhub? port ?		# CDC, Ethernet Networking Control Model
-#cue*	at uhub? port ?		# CATC USB-EL1201A based adapters
-#kue*	at uhub? port ?		# Kawasaki LSI KL5KUSB101B based adapters
-#udav*	at uhub? port ?		# Davicom DM9601 based adapters
-#url*	at uhub? port ?		# Realtek RTL8150L based adapters
-
-# USB 802.11 adapters
-#atu*	at uhub? port ?		# Atmel AT76C50XX based adapters
-#ral*	at uhub? port ?		# Ralink Technology RT25x0 802.11a/b/g
-#rum*	at uhub? port ?		# Ralink Technology RT2501/RT2601 802.11a/b/g
-#zyd*	at uhub? port ?		# Zydas ZD1211
-
-# Prolific PL2301/PL2302 host-to-host adapter
-#upl*	at uhub? port ?
-
-# Serial adapters
-#ubsa*	at uhub? port ?		# Belkin serial adapter
-#ucom*	at ubsa? portno ?
+# SCSI bus support
+scsibus* at scsi?
 
-#uchcom*	at uhub? port ?		# WinChipHead CH341/CH340 serial adapter
-#ucom*	at uchcom? portno ?
-
-#uftdi*	at uhub? port ?		# FTDI FT8U100AX serial adapter
-#ucom*	at uftdi? portno ?
-
-#uipaq*	at uhub? port ?		# iPAQ PDAs
-#ucom*	at uipaq? portno ?
-
-#umct*	at uhub? port ?		# MCT USB-RS232 serial adapter
-#ucom*	at umct? portno ?
-
-#uplcom* at uhub? port ? 	# I/O DATA USB-RSAQ2 serial adapter
-#ucom*	at uplcom? portno ?
-
-#uslsa*	at uhub? port ?		# Silicon Labs USB-RS232 serial adapter
-#ucom*	at uslsa? portno ?
-
-#uvscom* at uhub? port ? 	# SUNTAC Slipper U VS-10U serial adapter
-#ucom*	at uvscom? portno ?
-
-# Diamond Multimedia Rio 500
-#urio*	at uhub? port ?
-
-# USB Handspring Visor
-#uvisor*	at uhub? port ?
-#ucom*	at uvisor?
-
-# Kyocera AIR-EDGE PHONE
-#ukyopon* at uhub? port ?
-#ucom*	at ukyopon? portno ?
-
-# USB scanners
-#uscanner* at uhub? port ?
-
-# USB scanners that use SCSI emulation, e.g., HP5300
-#usscanner* at uhub? port ?
-
-# Topfield TF5000PVR range of DVB recorders
-#utoppy*	at uhub? port ?
-
-# y...@p firmware loader
-#uyap* at uhub? port ?
-
-# D-Link DSB-R100 USB radio
-#udsbr*	at uhub? port ?
-#radio*	at udsbr?
-
-# USB Generic driver
-#ugen*	at uhub? port ?
-# On ugen bulk endpoints, perform read-ahead and write-behind.
-#options UGEN_BULK_RA_WB
-
-# USB 3G datacards
-#u3g*	at uhub? port ?
-#ucom*	at u3g?
-
-# USB generic serial port (e.g., data over cellular)
-#ugensa*	at uhub? port ?
-#ucom*	at ugensa?
+# SCSI devices
+sd*	at scsibus? target ? lun ?	# SCSI disk drives
 
 # Bluetooth Controller and Device support
 
 # Bluetooth PCMCIA Controllers
-#bt3c*	at pcmcia? function ?		# 3Com 3CRWB6096-A
 #btbc*	at pcmcia? function ?		# AnyCom BlueCard LSE041/039/139
 
-# Bluetooth SDIO Controllers
-#sbt*	at sdmmc?
-
 # Bluetooth USB Controllers
 #ubt*	at uhub? port ?
 
 # Bluetooth Device Hub
-#bthub*	at bcsp?
-#bthub*	at bt3c?
+bthub*	at bcsp?
 #bthub*	at btbc?
 bthub*	at btuart?
-#bthub*	at sbt?
 #bthub*	at ubt?
 
 # Bluetooth HID support
-#bthidev* at bthub?
+bthidev* at bthub?
 
 # Bluetooth Mouse
-#btms*	at bthidev? reportid ?
-#wsmouse* at btms? mux 0
+btms*	at bthidev? reportid ?
+wsmouse* at btms? mux 0
 
 # Bluetooth Keyboard
-#btkbd*	at bthidev? reportid ?
-#wskbd*	at btkbd? console ? mux 1
+btkbd*	at bthidev? reportid ?
+wskbd*	at btkbd? console ? mux 1
 
 # Bluetooth Audio support
-#btsco*	at bthub?
+btsco*	at bthub?
 
 # Pseudo-Devices
 
@@ -456,7 +349,7 @@
 #options 	RF_INCLUDE_PARITY_DECLUSTERING_DS=1
 #pseudo-device	fss		4	# file system snapshot device
 
-pseudo-device	md		1	# memory disk device (ramdisk)
+#pseudo-device	md		1	# memory disk device (ramdisk)
 pseudo-device	vnd			# disk-like interface to files
 options 	VND_COMPRESSION		# compressed vnd(4)
 

Index: src/sys/arch/evbarm/conf/GUMSTIX_INSTALL
diff -u src/sys/arch/evbarm/conf/GUMSTIX_INSTALL:1.2 src/sys/arch/evbarm/conf/GUMSTIX_INSTALL:1.3
--- src/sys/arch/evbarm/conf/GUMSTIX_INSTALL:1.2	Mon Feb 19 05:36:13 2007
+++ src/sys/arch/evbarm/conf/GUMSTIX_INSTALL	Sun Aug  9 07:10:13 2009
@@ -1,11 +1,10 @@
-#	$NetBSD: GUMSTIX_INSTALL,v 1.2 2007/02/19 05:36:13 briggs Exp $
+#	$NetBSD: GUMSTIX_INSTALL,v 1.3 2009/08/09 07:10:13 kiyohara Exp $
 #
 #	GUMSTIX_INSTALL -- GUMSTIX kernel with installation-sized
 #	ramdisk
 #
 
 include "arch/evbarm/conf/GUMSTIX"
-no pseudo-device md
 include "arch/evbarm/conf/INSTALL"
 
 options BOOTHOWTO=RB_SINGLE

Index: src/sys/arch/evbarm/conf/files.gumstix
diff -u src/sys/arch/evbarm/conf/files.gumstix:1.13 src/sys/arch/evbarm/conf/files.gumstix:1.14
--- src/sys/arch/evbarm/conf/files.gumstix:1.13	Tue Apr 21 03:00:29 2009
+++ src/sys/arch/evbarm/conf/files.gumstix	Sun Aug  9 07:10:13 2009
@@ -1,4 +1,4 @@
-#	$NetBSD: files.gumstix,v 1.13 2009/04/21 03:00:29 nonaka Exp $
+#	$NetBSD: files.gumstix,v 1.14 2009/08/09 07:10:13 kiyohara Exp $
 #
 # Gumstix. Inc. Gumstix boards configuration info
 #
@@ -20,8 +20,8 @@
 file	arch/evbarm/gumstix/if_sm_gxio.c		sm_gxio
 
 # PCMCIA/CF socket
-attach	pxapcic at pxaip with pxapcic_gxpcic
-file	arch/evbarm/gumstix/gxpcic.c			pxapcic_gxpcic
+attach	pxapcic at pxaip with gxpcic
+file	arch/evbarm/gumstix/gxpcic.c			gxpcic
 
 # Inter-Integrated Circuit controller
 device	gxiic: pxaiic, i2cbus
@@ -33,3 +33,11 @@
 # MMC/SD controller
 attach	pxamci at pxaip with gxmci
 file	arch/evbarm/gumstix/gxmci.c			gxmci
+
+# SMSC LAN9118
+attach	smsh at gxio with smsh_gxio
+file	arch/evbarm/gumstix/if_smsh_gxio.c		smsh_gxio
+
+# LCD frame buffer
+attach	lcd at pxaip with gxlcd
+file	arch/evbarm/gumstix/gxlcd.c			gxlcd

Index: src/sys/arch/evbarm/gumstix/gumstix_machdep.c
diff -u src/sys/arch/evbarm/gumstix/gumstix_machdep.c:1.14 src/sys/arch/evbarm/gumstix/gumstix_machdep.c:1.15
--- src/sys/arch/evbarm/gumstix/gumstix_machdep.c:1.14	Wed Mar 18 10:22:27 2009
+++ src/sys/arch/evbarm/gumstix/gumstix_machdep.c	Sun Aug  9 07:10:13 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: gumstix_machdep.c,v 1.14 2009/03/18 10:22:27 cegger Exp $ */
+/*	$NetBSD: gumstix_machdep.c,v 1.15 2009/08/09 07:10:13 kiyohara Exp $ */
 /*
  * Copyright (C) 2005, 2006, 2007  WIDE Project and SOUM Corporation.
  * All rights reserved.
@@ -259,6 +259,7 @@
 /* Prototypes */
 static void	read_system_serial(void);
 static void	process_kernel_args(int, char *[]);
+static void	process_kernel_args_line(char *);
 #ifdef KGDB
 static void	kgdb_port_init(void);
 #endif
@@ -271,6 +272,8 @@
 #include <dev/ic/comvar.h>
 #endif
 
+#include "lcd.h"
+
 #ifndef CONSPEED
 #define CONSPEED B115200	/* It's a setting of the default of u-boot */
 #endif
@@ -423,6 +426,12 @@
 		_S(4 * COM_NPORTS),
 		VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE,
 	},
+	{
+		GUMSTIX_LCDC_VBASE,
+		_A(PXA2X0_LCDC_BASE),
+		_S(4 * COM_NPORTS),
+		VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE,
+	},
 	{0, 0, 0, 0, 0}
 };
 
@@ -448,7 +457,8 @@
 {
 	extern vaddr_t xscale_cache_clean_addr;
 	extern uint32_t *u_boot_args[];
-	enum { r3 = 0, r4 = 1, r5 = 2, r6 = 3 };	/* args from u-boot */
+	extern uint32_t ram_size;
+	enum { r0 = 0, r1 = 1, r2 = 2, r3 = 3 }; /* args from u-boot */
 	int loop;
 	int loop1;
 	u_int l1pagetable;
@@ -506,10 +516,20 @@
 	 * Examine the boot args string for options we need to know about
 	 * now.
 	 */
-	process_kernel_args((int)u_boot_args[r6], (char **)u_boot_args[r5]);
+#define SDRAM_START	0xa0000000UL
+	if (((uint32_t)u_boot_args[r0] & 0xf0000000) != SDRAM_START)
+		/* Maybe r0 is 'argc'.  We are booted by command 'go'. */
+		process_kernel_args((int)u_boot_args[r0],
+		    (char **)u_boot_args[r1]);
+	else
+		/*
+		 * Maybe r3 is 'boot args string' of 'bootm'.  This string is
+		 * linely.
+		 */
+		process_kernel_args_line((char *)u_boot_args[r3]);
 
-	memstart = 0xa0000000UL;
-	memsize = 0x04000000UL;		/* 64MB */
+	memstart = SDRAM_START;
+	memsize = ram_size;
 
 #ifdef VERBOSE_INIT_ARM
 	printf("initarm: Configuring system ...\n");
@@ -920,21 +940,14 @@
 	printf("\n");
 }
 
+static const char busheader_name[] = "busheader=";
 static void
 process_kernel_args(int argc, char *argv[])
 {
-	static const char busheader_name[] = "busheader=";
 	int gxio_configured = 0, i, j;
 
 	boothowto = 0;
 
-	/*
-	 * XXXXX: The value of argc is wrong.  The number of arguments is
-	 * corrected in the do_go() of u-boot.  However, it is not actually
-	 * corrected. 
-	 */
-	argc --;
-
 	for (i = 1, j = 0; i < argc; i++) {
 		if (!strncmp(argv[i], busheader_name, strlen(busheader_name))) {
 			/* configure for GPIOs of busheader side */
@@ -959,6 +972,34 @@
 		gxio_config_expansion(NULL);
 }
 
+static void
+process_kernel_args_line(char *args)
+{
+	int i;
+	char expansion[256], *p, c;
+
+	boothowto = 0;
+
+	strncpy(bootargs, args, sizeof(bootargs));
+	p = strstr(bootargs, busheader_name);
+	if (p == NULL)
+		gxio_config_expansion(NULL);
+	else {
+		i = 0;
+		do {
+			c = *(p + strlen(busheader_name) + i);
+			if (c == ' ')
+				c = '\0';
+			expansion[i++] = c;
+		} while (c != '\0');
+		gxio_config_expansion(expansion);
+		strcpy(p, p + i);
+	}
+	boot_args = bootargs;
+
+	parse_mi_bootargs(boot_args);
+}
+
 #ifdef KGDB
 #ifndef KGDB_DEVNAME
 #define KGDB_DEVNAME	"ffuart"
@@ -1060,6 +1101,13 @@
 
 #endif /* NCOM */
 
+#if NLCD > 0
+	{
+		extern void gxlcd_cnattach(void);
+
+		gxlcd_cnattach();
+	}
+#endif
 }
 
 #ifdef KGDB

Index: src/sys/arch/evbarm/gumstix/gumstix_start.S
diff -u src/sys/arch/evbarm/gumstix/gumstix_start.S:1.5 src/sys/arch/evbarm/gumstix/gumstix_start.S:1.6
--- src/sys/arch/evbarm/gumstix/gumstix_start.S:1.5	Wed Oct 17 19:54:12 2007
+++ src/sys/arch/evbarm/gumstix/gumstix_start.S	Sun Aug  9 07:10:13 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: gumstix_start.S,v 1.5 2007/10/17 19:54:12 garbled Exp $ */
+/*	$NetBSD: gumstix_start.S,v 1.6 2009/08/09 07:10:13 kiyohara Exp $ */
 /*
  * Copyright (C) 2005, 2006 WIDE Project and SOUM Corporation.
  * All rights reserved.
@@ -81,7 +81,7 @@
 	mrc	p15, 0, tmp, c2, c0, 0	/* arbitrary read of CP15 */	;\
 	mov	tmp, tmp		/* wait for it to complete */	;\
 	CPWAIT_BRANCH			/* branch to next insn */
-	
+
 /*
  * Kernel start routine for GUMSTIX
  * this code is excuted at the very first after the kernel is loaded
@@ -97,30 +97,53 @@
 	 *  in VA 0xc0200000..
 	 */
 	/* save u-boot's args */
-	adr	r0, u_boot_args
+	adr	r4, u_boot_args
 	nop
 	nop
 	nop
-	stmia	r0!, {r3, r4, r5, r6}
+	stmia	r4!, {r0, r1, r2, r3}
 	nop
 	nop
 	nop
 
+	/* Calculate RAM size */
+	adr	r4, ram_size
+	ldr	r0, [r4]
+0:
+	add	r3, r4, r0
+	ldr	r1, [r3]
+	cmp	r0, r1
+	beq	2f
+1:
+	add	r0, r0, r0	/* r0 <<= 1 */
+	str	r0, [r4]
+	b	0b
+2:
+	mvn	r1, r1		/* r1 ^= 0xffffffff */
+	str	r1, [r3]
+	ldr	r2, [r4]
+	cmp	r1, r2
+	beq	3f
+	str	r0, [r3]	/* restore */
+	b	1b
+3:
+	str	r0, [r4]
+
 	/* build page table from scratch */
 	ldr	r0, Lstartup_pagetable		/* pagetable */
 	adr	r4, mmu_init_table
-	b	3f
+	b	5f
 
-2:
+4:
 	str	r3, [r0, r2]
 	add	r2, r2, #4
 	add	r3, r3, #(L1_S_SIZE)
 	adds	r1, r1, #-1
-	bhi	2b
-3:	
+	bhi	4b
+5:
 	ldmia	r4!, {r1, r2, r3}	/* # of sections, PA|attr, VA */
 	cmp	r1, #0
-	bne	2b	
+	bne	4b
 
 	mcr	p15, 0, r0, c2, c0, 0	/* Set TTB */
 	mcr	p15, 0, r0, c8, c7, 0	/* Flush TLB */
@@ -151,7 +174,11 @@
 
 	.globl	_C_LABEL(u_boot_args)
 u_boot_args:
-	.space	16			/* r3, r4, r5, r6 */
+	.space	16			/* r0, r1, r2, r3 */
+
+	.globl	_C_LABEL(ram_size)
+ram_size:
+	.word	0x04000000		/* 64Mbyte */
 
 
 #define MMU_INIT(va,pa,n_sec,attr) \
@@ -159,7 +186,7 @@
 	.word	4 * ((va) >> L1_S_SHIFT)		    ; \
 	.word	(pa) | (attr)				    ;
 
-mmu_init_table:	
+mmu_init_table:
 	/* fill all table VA==PA */
 	MMU_INIT(0x00000000, 0x00000000,
 	    1 << (32 - L1_S_SHIFT), L1_TYPE_S | L1_S_AP(AP_KRW))

Index: src/sys/arch/evbarm/gumstix/gumstixreg.h
diff -u src/sys/arch/evbarm/gumstix/gumstixreg.h:1.3 src/sys/arch/evbarm/gumstix/gumstixreg.h:1.4
--- src/sys/arch/evbarm/gumstix/gumstixreg.h:1.3	Thu Jan 18 10:06:47 2007
+++ src/sys/arch/evbarm/gumstix/gumstixreg.h	Sun Aug  9 07:10:13 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: gumstixreg.h,v 1.3 2007/01/18 10:06:47 kiyohara Exp $  */
+/*	$NetBSD: gumstixreg.h,v 1.4 2009/08/09 07:10:13 kiyohara Exp $  */
 /*
  * Copyright (C) 2005, 2006 WIDE Project and SOUM Corporation.
  * All rights reserved.
@@ -48,6 +48,7 @@
 #define GUMSTIX_STUART_VBASE	0xfd400000
 #define GUMSTIX_BTUART_VBASE	0xfd500000
 #define GUMSTIX_HWUART_VBASE	0xfd600000
+#define GUMSTIX_LCDC_VBASE	0xfd700000
 
 
 #define ioreg_read(a)		(*(volatile unsigned *)(a))
Index: src/sys/arch/evbarm/gumstix/gumstixvar.h
diff -u src/sys/arch/evbarm/gumstix/gumstixvar.h:1.3 src/sys/arch/evbarm/gumstix/gumstixvar.h:1.4
--- src/sys/arch/evbarm/gumstix/gumstixvar.h:1.3	Sun May 11 08:23:17 2008
+++ src/sys/arch/evbarm/gumstix/gumstixvar.h	Sun Aug  9 07:10:13 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: gumstixvar.h,v 1.3 2008/05/11 08:23:17 kiyohara Exp $ */
+/*	$NetBSD: gumstixvar.h,v 1.4 2009/08/09 07:10:13 kiyohara Exp $ */
 /*
  * Copyright (C) 2005, 2006 WIDE Project and SOUM Corporation.
  * All rights reserved.
@@ -68,4 +68,16 @@
 #define gxio_intr_disestablish(sc, cookie) \
     pxa2x0_gpio_intr_disestablish((cookie))
 
+
+/*
+ * gxpcic
+ */
+struct gxpcic_slot_irqs {
+	int valid;
+	int cd;		/* PCDn */
+	int prdy;	/* PRDYn/~IRQn */
+};
+extern struct gxpcic_slot_irqs gxpcic_slot_irqs[2];
+extern int gxpcic_gpio_reset;
+
 #endif /* _EVBARM_GUMSTIXVAR_H_ */

Index: src/sys/arch/evbarm/gumstix/gxio.c
diff -u src/sys/arch/evbarm/gumstix/gxio.c:1.9 src/sys/arch/evbarm/gumstix/gxio.c:1.10
--- src/sys/arch/evbarm/gumstix/gxio.c:1.9	Wed Mar 18 10:22:27 2009
+++ src/sys/arch/evbarm/gumstix/gxio.c	Sun Aug  9 07:10:13 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: gxio.c,v 1.9 2009/03/18 10:22:27 cegger Exp $ */
+/*	$NetBSD: gxio.c,v 1.10 2009/08/09 07:10:13 kiyohara Exp $ */
 /*
  * Copyright (C) 2005, 2006, 2007 WIDE Project and SOUM Corporation.
  * All rights reserved.
@@ -31,13 +31,14 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gxio.c,v 1.9 2009/03/18 10:22:27 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gxio.c,v 1.10 2009/08/09 07:10:13 kiyohara Exp $");
 
 #include "opt_gxio.h"
 
 #include <sys/param.h>
 #include <sys/device.h>
 #include <sys/errno.h>
+#include <sys/kernel.h>
 
 #include <sys/systm.h>
 
@@ -57,9 +58,9 @@
 	void (*config)(void);
 };
 
-static int gxiomatch(device_t, struct cfdata *, void *);
+static int gxiomatch(device_t, cfdata_t, void *);
 static void gxioattach(device_t, device_t, void *);
-static int gxiosearch(device_t, struct cfdata *, const int *, void *);
+static int gxiosearch(device_t, cfdata_t, const int *, void *);
 static int gxioprint(void *, const char *);
 
 void gxio_config_pin(void);
@@ -71,7 +72,10 @@
 static void netcf_config(void);
 static void netduommc_config(void);
 static void netduo_config(void);
+static void netmicrosd_config(void);
+static void netwifimicrosd_config(void);
 static void netmmc_config(void);
+static void wifistix_config(void);
 static void wifistix_cf_config(void);
 
 CFATTACH_DECL_NEW(
@@ -79,24 +83,29 @@
 
 char busheader[MAX_BOOT_STRING];
 
-static struct pxa2x0_gpioconf boarddep_gpioconf[] = {
+#if defined(CPU_XSCALE_PXA250)
+static struct pxa2x0_gpioconf pxa255dep_gpioconf[] = {
 	/* Bluetooth module configuration */
 	{  7, GPIO_OUT | GPIO_SET },	/* power on */
 	{ 12, GPIO_ALT_FN_1_OUT },	/* 32kHz out. required by SingleStone */
 
 	/* AC97 configuration */
-	{ 29, GPIO_CLR | GPIO_ALT_FN_1_IN },	/* SDATA_IN0 */
+	{ 29, GPIO_ALT_FN_1_IN },	/* SDATA_IN0 */
+
+	/* FFUART configuration */
+	{ 35, GPIO_ALT_FN_1_IN },	/* CTS */
+	{ 41, GPIO_ALT_FN_2_OUT },	/* RTS */
 
 #ifndef GXIO_BLUETOOTH_ON_HWUART
 	/* BTUART configuration */
-	{ 44, GPIO_ALT_FN_1_IN },	/* BTCST */
-	{ 45, GPIO_ALT_FN_2_OUT },	/* BTRST */
+	{ 44, GPIO_ALT_FN_1_IN },	/* BTCTS */
+	{ 45, GPIO_ALT_FN_2_OUT },	/* BTRTS */
 #else
 	/* HWUART configuration */
 	{ 42, GPIO_ALT_FN_3_IN },	/* HWRXD */
 	{ 43, GPIO_ALT_FN_3_OUT },	/* HWTXD */
-	{ 44, GPIO_ALT_FN_3_IN },	/* HWCST */
-	{ 45, GPIO_ALT_FN_3_OUT },	/* HWRST */
+	{ 44, GPIO_ALT_FN_3_IN },	/* HWCTS */
+	{ 45, GPIO_ALT_FN_3_OUT },	/* HWRTS */
 #endif
 
 #ifndef GXIO_BLUETOOTH_ON_HWUART
@@ -109,28 +118,65 @@
 
 	{ -1 }
 };
+#endif
+#if defined(CPU_XSCALE_PXA270)
+static struct pxa2x0_gpioconf verdexdep_gpioconf[] = {
+	/* Bluetooth module configuration */
+	{   9, GPIO_ALT_FN_3_OUT },	/* CHOUT<0> */
+
+	/* FFUART configuration */
+	{  27, GPIO_ALT_FN_3_OUT },	/* FFRTS */
+	{  34, GPIO_ALT_FN_1_IN },	/* FFRXD */
+	{  39, GPIO_ALT_FN_2_OUT },	/* FFTXD */
+	{ 100, GPIO_ALT_FN_3_IN },	/* FFCTS */
+
+	/* BTUART configuration */
+	{  42, GPIO_ALT_FN_1_IN },	/* BTRXD */
+	{  43, GPIO_ALT_FN_2_OUT },	/* BTTXD */
+	{  44, GPIO_ALT_FN_1_IN },	/* BTCTS */
+	{  45, GPIO_ALT_FN_2_OUT },	/* BTRTS */
+
+	/* AC97 configuration */
+	{  29, GPIO_ALT_FN_1_IN },	/* SDATA_IN0 */
+
+	{ -1 }
+};
+#endif
 
 static const struct gxioconf busheader_conf[] = {
 	{ "basix",		basix_config },
 	{ "cfstix",		cfstix_config },
 	{ "etherstix",		etherstix_config },
 	{ "netcf",		netcf_config },
+	{ "netcf-vx",		netcf_config },
 	{ "netduo-mmc",		netduommc_config },
 	{ "netduo",		netduo_config },
+	{ "netmicrosd",		netmicrosd_config },
+	{ "netmicrosd-vx",	netmicrosd_config },
+	{ "netwifimicrosd",	netwifimicrosd_config },
 	{ "netmmc",		netmmc_config },
+	{ "netpro-vx",		netwifimicrosd_config },
 	{ "wifistix-cf",	wifistix_cf_config },
-	{ "wifistix",		cfstix_config },
+	{ "wifistix",		wifistix_config },
 	{ NULL }
 };
 
+int gxpcic_gpio_reset;
+struct gxpcic_slot_irqs gxpcic_slot_irqs[2] = { { 0, -1, -1 }, { 0, -1, -1 } };
+
 
 /* ARGSUSED */
 static int
-gxiomatch(device_t parent, struct cfdata *match, void *aux)
+gxiomatch(device_t parent, cfdata_t match, void *aux)
 {
+	struct pxaip_attach_args *pxa = aux;
 	bus_space_tag_t iot = &pxa2x0_bs_tag;
 	bus_space_handle_t ioh;
 
+	if (strcmp(pxa->pxa_name, match->cf_name) != 0 ||
+	    pxa->pxa_addr != PXAIPCF_ADDR_DEFAULT)
+		 return 0;
+
 	if (bus_space_map(iot,
 	    PXA2X0_MEMCTL_BASE, PXA2X0_MEMCTL_SIZE, 0, &ioh))
 		return (0);
@@ -164,7 +210,7 @@
 
 /* ARGSUSED */
 static int
-gxiosearch(device_t parent, struct cfdata *cf, const int *ldesc, void *aux)
+gxiosearch(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
 {
 	struct gxio_softc *sc = device_private(parent);
 	struct gxio_attach_args gxa;
@@ -200,6 +246,7 @@
 void
 gxio_config_pin(void)
 {
+#if defined(CPU_XSCALE_PXA250)
 	struct pxa2x0_gpioconf *gumstix_gpioconf[] = {
 		pxa25x_com_ffuart_gpioconf,
 		pxa25x_com_stuart_gpioconf,
@@ -209,32 +256,52 @@
 		pxa25x_com_hwuart_gpioconf,
 		pxa25x_i2c_gpioconf,
 		pxa25x_pxaacu_gpioconf,
-		boarddep_gpioconf,
+		pxa255dep_gpioconf,
+		NULL
+	};
+#endif
+#if defined(CPU_XSCALE_PXA270)
+	struct pxa2x0_gpioconf *verdex_gpioconf[] = {
+		pxa27x_com_ffuart_gpioconf,
+		pxa27x_com_stuart_gpioconf,
+		pxa27x_com_btuart_gpioconf,
+		pxa27x_i2c_gpioconf,
+		pxa27x_pxaacu_gpioconf,
+		pxa27x_pxamci_gpioconf,
+		pxa27x_ohci_gpioconf,
+		verdexdep_gpioconf,
 		NULL
 	};
+#endif
 
 	/* XXX: turn off for power of bluetooth module */
 	pxa2x0_gpio_set_function(7, GPIO_OUT | GPIO_CLR);
 	delay(100);
 
+#if defined(CPU_XSCALE_PXA270) && defined(CPU_XSCALE_PXA250)
+	pxa2x0_gpio_config(
+	    (CPU_IS_PXA250) ? gumstix_gpioconf : verdex_gpioconf);
+#else
+#if defined(CPU_XSCALE_PXA270)
+	pxa2x0_gpio_config(verdex_gpioconf);
+#else
 	pxa2x0_gpio_config(gumstix_gpioconf);
+#endif
+#endif
 }
 
 void
 gxio_config_expansion(char *expansion)
 {
-#ifdef GXIO_DEFAULT_EXPANSION
-	char default_expansion[] = GXIO_DEFAULT_EXPANSION;
-#endif
 
 	if (expansion == NULL) {
-#ifndef GXIO_DEFAULT_EXPANSION
-		return;
-#else
 		printf("not specified 'busheader=' in the boot args.\n");
+#ifdef GXIO_DEFAULT_EXPANSION
 		printf("configure default expansion (%s)\n",
 		    GXIO_DEFAULT_EXPANSION);
-		expansion = default_expansion;
+		expansion = GXIO_DEFAULT_EXPANSION;
+#else
+		return;
 #endif
 	}
 	gxio_config_gpio(busheader_conf, expansion);
@@ -275,14 +342,35 @@
 cfstix_config(void)
 {
 	u_int gpio, npoe_fn;
+#if defined(CPU_XSCALE_PXA270) && defined(CPU_XSCALE_PXA250)
+	int bvd = (CPU_IS_PXA250) ? 4 : 111;
+#else
+#if defined(CPU_XSCALE_PXA270)
+	const int bvd = 111;
+#else
+	const int bvd = 4;
+#endif
+#endif
+
+	if (CPU_IS_PXA250) {
+		gxpcic_slot_irqs[0].valid = 1;
+		gxpcic_slot_irqs[0].cd = 11;
+		gxpcic_slot_irqs[0].prdy = 26;
+		gxpcic_gpio_reset = 8;
+	} else {
+		gxpcic_slot_irqs[0].valid = 1;
+		gxpcic_slot_irqs[0].cd = 104;
+		gxpcic_slot_irqs[0].prdy = 96;
+		gxpcic_gpio_reset = 97;
+	}
 
 #if 1
-	/* this configuration set by pxa2x0_pcic.c::pxapcic_attach_common() */
+	/* PCD/PRDY set by pxa2x0_pcic.c::pxapcic_attach_common() */
 #else
 	pxa2x0_gpio_set_function(11, GPIO_IN);		/* PCD1 */
 	pxa2x0_gpio_set_function(26, GPIO_IN);		/* PRDY1/~IRQ1 */
 #endif
-	pxa2x0_gpio_set_function(4, GPIO_IN); 		/* BVD1/~STSCHG1 */
+	pxa2x0_gpio_set_function(bvd, GPIO_IN); 	/* BVD1/~STSCHG1 */
 
 	for (gpio = 48, npoe_fn = 0; gpio <= 53 ; gpio++)
 		npoe_fn |= pxa2x0_gpio_get_function(gpio);
@@ -292,9 +380,15 @@
 	pxa2x0_gpio_set_function(49, GPIO_ALT_FN_2_OUT);	/* nPWE */
 	pxa2x0_gpio_set_function(50, GPIO_ALT_FN_2_OUT);	/* nPIOR */
 	pxa2x0_gpio_set_function(51, GPIO_ALT_FN_2_OUT);	/* nPIOW */
-	pxa2x0_gpio_set_function(52, GPIO_ALT_FN_2_OUT);	/* nPCE1 */
-	pxa2x0_gpio_set_function(53, GPIO_ALT_FN_2_OUT);	/* nPCE2 */
-	pxa2x0_gpio_set_function(54, GPIO_ALT_FN_2_OUT);	/* pSKTSEL */
+	if (CPU_IS_PXA250) {
+		pxa2x0_gpio_set_function(52, GPIO_ALT_FN_2_OUT); /* nPCE1 */
+		pxa2x0_gpio_set_function(53, GPIO_ALT_FN_2_OUT); /* nPCE2 */
+		pxa2x0_gpio_set_function(54, GPIO_ALT_FN_2_OUT); /* pSKTSEL */
+	} else {
+		pxa2x0_gpio_set_function(102, GPIO_ALT_FN_1_OUT); /* nPCE1 */
+		pxa2x0_gpio_set_function(105, GPIO_ALT_FN_1_OUT); /* nPCE2 */
+		pxa2x0_gpio_set_function(79, GPIO_ALT_FN_1_OUT);  /* pSKTSEL */
+	}
 	pxa2x0_gpio_set_function(55, GPIO_ALT_FN_2_OUT);	/* nPREG */
 	pxa2x0_gpio_set_function(56, GPIO_ALT_FN_1_IN);		/* nPWAIT */
 	pxa2x0_gpio_set_function(57, GPIO_ALT_FN_1_IN);		/* nIOIS16 */
@@ -303,13 +397,32 @@
 static void
 etherstix_config(void)
 {
+	extern struct cfdata cfdata[];
+#if defined(CPU_XSCALE_PXA270) && defined(CPU_XSCALE_PXA250)
+	int rst = (CPU_IS_PXA250) ? 80 : 32;
+	int irq = (CPU_IS_PXA250) ? 36 : 99;
+#else
+#if defined(CPU_XSCALE_PXA270)
+	const int rst = 32, irq = 99;
+#else
+	const int rst = 80, irq = 36;
+#endif
+#endif
+	int i;
 
 	pxa2x0_gpio_set_function(49, GPIO_ALT_FN_2_OUT);	/* nPWE */
 	pxa2x0_gpio_set_function(15, GPIO_ALT_FN_2_OUT);	/* nCS 1 */
-	pxa2x0_gpio_set_function(80, GPIO_OUT | GPIO_SET);	/* RESET 1 */
+	pxa2x0_gpio_set_function(rst, GPIO_OUT | GPIO_SET);	/* RESET 1 */
 	delay(1);
-	pxa2x0_gpio_set_function(80, GPIO_OUT | GPIO_CLR);
+	pxa2x0_gpio_set_function(rst, GPIO_OUT | GPIO_CLR);
 	delay(50000);
+
+	for (i = 0; cfdata[i].cf_name != NULL; i++)
+		if (strcmp(cfdata[i].cf_name, "sm") == 0 &&
+		    strcmp(cfdata[i].cf_atname, "sm_gxio") == 0 &&
+		    cfdata[i].cf_loc[GXIOCF_ADDR] == 0x04000300 &&
+		    cfdata[i].cf_loc[GXIOCF_GPIRQ] == GXIOCF_GPIRQ_DEFAULT)
+			cfdata[i].cf_loc[GXIOCF_GPIRQ] = irq;
 }
 
 static void
@@ -318,6 +431,12 @@
 
 	etherstix_config();
 	cfstix_config();
+	if (CPU_IS_PXA270) {
+		/* Overwrite */
+		gxpcic_slot_irqs[0].cd = 104;
+		gxpcic_slot_irqs[0].prdy = 109;
+		gxpcic_gpio_reset = 110;
+	};
 }
 
 static void
@@ -342,6 +461,33 @@
 }
 
 static void
+netmicrosd_config(void)
+{
+
+	/* MicroSD(mci) always configure on PXA270 */
+
+	pxa2x0_gpio_set_function(49, GPIO_ALT_FN_2_OUT);	/* nPWE */
+	pxa2x0_gpio_set_function(15, GPIO_ALT_FN_2_OUT);	/* nCS 1 */
+	pxa2x0_gpio_set_function(107, GPIO_OUT | GPIO_CLR);	/* RESET 1 */
+	delay(hz / 2);
+	pxa2x0_gpio_set_function(107, GPIO_OUT | GPIO_SET);
+	delay(50000);
+}
+
+static void
+netwifimicrosd_config(void)
+{
+
+	netmicrosd_config();
+
+	cfstix_config();
+	/* However use pxamci. */
+	pxa2x0_gpio_set_function(111, GPIO_CLR | GPIO_ALT_FN_1_IN);
+	/* XXXX: Power to Marvell 88W8385??? */
+	pxa2x0_gpio_set_function(80, GPIO_OUT | GPIO_SET);
+}
+
+static void
 netmmc_config(void)
 {
 
@@ -350,9 +496,23 @@
 }
 
 static void
+wifistix_config(void)
+{
+
+	cfstix_config();
+
+	/* XXXX: Power to Marvell 88W8385??? */
+	pxa2x0_gpio_set_function(80, GPIO_OUT | GPIO_SET);
+}
+
+static void
 wifistix_cf_config(void)
 {
 
+	gxpcic_slot_irqs[1].valid = 1;
+	gxpcic_slot_irqs[1].cd = 36;
+	gxpcic_slot_irqs[1].prdy = 27;
+
 #if 1
 	/* this configuration set by pxa2x0_pcic.c::pxapcic_attach_common() */
 #else
@@ -362,4 +522,7 @@
 	pxa2x0_gpio_set_function(18, GPIO_IN); 		/* BVD2/~STSCHG2 */
 
 	cfstix_config();
+
+	/* XXXX: Power to Marvell 88W8385??? */
+	pxa2x0_gpio_set_function(80, GPIO_OUT | GPIO_SET);
 }

Index: src/sys/arch/evbarm/gumstix/gxpcic.c
diff -u src/sys/arch/evbarm/gumstix/gxpcic.c:1.10 src/sys/arch/evbarm/gumstix/gxpcic.c:1.11
--- src/sys/arch/evbarm/gumstix/gxpcic.c:1.10	Wed Mar 18 10:22:27 2009
+++ src/sys/arch/evbarm/gumstix/gxpcic.c	Sun Aug  9 07:10:13 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: gxpcic.c,v 1.10 2009/03/18 10:22:27 cegger Exp $ */
+/*	$NetBSD: gxpcic.c,v 1.11 2009/08/09 07:10:13 kiyohara Exp $ */
 /*
  * Copyright (C) 2005, 2006 WIDE Project and SOUM Corporation.
  * All rights reserved.
@@ -94,15 +94,10 @@
 
 #define HAVE_CARD(r)	(!((r) & GPIO_SET))
 
-#define GXIO_GPIRQ11_CD1	11
-#define GXIO_GPIRQ26_PRDY1	26
-#define GXIO_GPIRQ27_PRDY2	27
-#define GXIO_GPIRQ36_CD2	36
 
-
-static	int  	gxpcic_match(device_t, struct cfdata *, void *);
+static	int  	gxpcic_match(device_t, cfdata_t, void *);
 static	void  	gxpcic_attach(device_t, device_t, void *);
-static	void	gxpcic_pcic_socket_setup(struct pxapcic_socket *);
+static	void	gxpcic_socket_setup(struct pxapcic_socket *);
 
 static	u_int	gxpcic_read(struct pxapcic_socket *, int);
 static	void	gxpcic_write(struct pxapcic_socket *, int, u_int);
@@ -115,10 +110,10 @@
 __inline u_char gxpcic_cpld_read_bits(int bits);
 static	int	gxpcic_count_slot(struct pxapcic_softc *);
 
-CFATTACH_DECL_NEW(pxapcic_gxpcic, sizeof(struct pxapcic_softc),
+CFATTACH_DECL_NEW(gxpcic, sizeof(struct pxapcic_softc),
     gxpcic_match, gxpcic_attach, NULL, NULL);
 
-static struct pxapcic_tag gxpcic_pcic_functions = {
+static struct pxapcic_tag gxpcic_functions = {
 	gxpcic_read,
 	gxpcic_write,
 	gxpcic_set_power,
@@ -127,22 +122,18 @@
 	gxpcic_intr_disestablish,
 };
 
-static struct {
-	int cd;
-	int prdy;
-} gxpcic_slot_irqs[] = {
-	{ GXIO_GPIRQ11_CD1, GXIO_GPIRQ26_PRDY1 },
-	{ GXIO_GPIRQ36_CD2, GXIO_GPIRQ27_PRDY2 }
-};
-
 
 static int
-gxpcic_match(device_t parent, struct cfdata *cf, void *aux)
+gxpcic_match(device_t parent, cfdata_t match, void *aux)
 {
+	struct pxaip_attach_args *pxa = aux;
 	struct pxa2x0_gpioconf *gpioconf;
 	u_int reg;
 	int i;
 
+	if (strcmp(pxa->pxa_name, match->cf_name) != 0)
+		return 0;
+
 	/*
 	 * Check GPIO configuration.  If you use these, it is sure already
 	 * to have been set by gxio.
@@ -152,8 +143,11 @@
 	for (i = 0; gpioconf[i].pin != -1; i++) {
 		reg = pxa2x0_gpio_get_function(gpioconf[i].pin);
 		if (GPIO_FN(reg) != GPIO_FN(gpioconf[i].value) ||
-		    GPIO_FN_IS_OUT(reg) != GPIO_FN_IS_OUT(gpioconf[i].value))
-			return (0);
+		    GPIO_FN_IS_OUT(reg) != GPIO_FN_IS_OUT(gpioconf[i].value)) {
+			if (!CPU_IS_PXA250 && gpioconf[i].pin == 111)
+				continue;
+			return 0;
+		}
 	}
 
 	return	1;	/* match */
@@ -163,7 +157,7 @@
 gxpcic_attach(device_t parent, device_t self, void *aux)
 {
 	struct pxapcic_softc *sc = device_private(self);
-	struct pxaip_attach_args *pxa = (struct pxaip_attach_args *)aux;
+	struct pxaip_attach_args *pxa = aux;
 	int nslot, i;
 
 	sc->sc_dev = self;
@@ -172,30 +166,36 @@
 	nslot = gxpcic_count_slot(sc);
 
 	for (i = 0; i < nslot; i++) {
+		if (!gxpcic_slot_irqs[i].valid) 
+			continue;
 		sc->sc_irqpin[i] = gxpcic_slot_irqs[i].prdy;
 		sc->sc_irqcfpin[i] = gxpcic_slot_irqs[i].cd;
 	}
 	sc->sc_nslots = nslot;
 
-	pxapcic_attach_common(sc, &gxpcic_pcic_socket_setup);
+	pxapcic_attach_common(sc, &gxpcic_socket_setup);
 }
 
 static void
-gxpcic_pcic_socket_setup(struct pxapcic_socket *so)
+gxpcic_socket_setup(struct pxapcic_socket *so)
 {
+#if 0
 	struct pxapcic_softc *sc = so->sc;
+#endif
 
 	/* 3.3V only? */
 	so->power_capability = PXAPCIC_POWER_3V;
 	so->pcictag_cookie = NULL;
-	so->pcictag = &gxpcic_pcic_functions;
+	so->pcictag = &gxpcic_functions;
 
+#if 0	/* We use already set values by u-boot. */
 	bus_space_write_4(sc->sc_iot, sc->sc_memctl_ioh,
 	    MEMCTL_MCMEM(so->socket), MC_TIMING_VAL(9 ,9, 29));
 	bus_space_write_4(sc->sc_iot, sc->sc_memctl_ioh,
 	    MEMCTL_MCATT(so->socket), MC_TIMING_VAL(9 ,9, 29));
 	bus_space_write_4(sc->sc_iot, sc->sc_memctl_ioh,
 	    MEMCTL_MCIO(so->socket), MC_TIMING_VAL(5 ,5, 16));
+#endif
 }
 
 static u_int
@@ -317,8 +317,8 @@
 	pce1 = pxa2x0_gpio_get_function(52);
 	pce2 = pxa2x0_gpio_get_function(53);
 
-	/* Reset */
-	pxa2x0_gpio_set_function(8, GPIO_OUT | GPIO_SET);
+	/* RESET */
+	pxa2x0_gpio_set_function(gxpcic_gpio_reset, GPIO_OUT | GPIO_CLR);
 
 	/* Setup the shift register */
 	pxa2x0_gpio_set_function(52, GPIO_OUT | GPIO_SET);
@@ -340,7 +340,8 @@
 		nslot = 2;
 
 	delay(50);
-	pxa2x0_gpio_set_function(8, GPIO_OUT | GPIO_CLR);	/* clr RESET */
+	/* clear RESET */
+	pxa2x0_gpio_set_function(gxpcic_gpio_reset, GPIO_OUT | GPIO_CLR);
 
 	pxa2x0_gpio_set_function(48, poe);
 	pxa2x0_gpio_set_function(52, pce1);

Index: src/sys/arch/evbarm/gumstix/if_sm_gxio.c
diff -u src/sys/arch/evbarm/gumstix/if_sm_gxio.c:1.6 src/sys/arch/evbarm/gumstix/if_sm_gxio.c:1.7
--- src/sys/arch/evbarm/gumstix/if_sm_gxio.c:1.6	Sun May 11 08:23:17 2008
+++ src/sys/arch/evbarm/gumstix/if_sm_gxio.c	Sun Aug  9 07:10:13 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_sm_gxio.c,v 1.6 2008/05/11 08:23:17 kiyohara Exp $ */
+/*	$NetBSD: if_sm_gxio.c,v 1.7 2009/08/09 07:10:13 kiyohara Exp $ */
 /*
  * Copyright (C) 2005, 2006 WIDE Project and SOUM Corporation.
  * All rights reserved.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_sm_gxio.c,v 1.6 2008/05/11 08:23:17 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_sm_gxio.c,v 1.7 2009/08/09 07:10:13 kiyohara Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -114,18 +114,18 @@
 	struct gxio_attach_args *gxa = aux;
 	bus_space_tag_t iot = gxa->gxa_iot;
 	bus_space_handle_t ioh;
-	u_int16_t tmp;
+	uint16_t tmp;
 	int rv = 0;
 	extern const char *smc91cxx_idstrs[];
 
 	/* Disallow wildcarded values. */
 	if (gxa->gxa_addr == GXIOCF_ADDR_DEFAULT)
-		return (0);
+		return 0;
 	if (gxa->gxa_gpirq == GXIOCF_GPIRQ_DEFAULT)
-		return (0);
+		return 0;
 
 	if (bus_space_map(iot, gxa->gxa_addr, SMC_IOSIZE, 0, &ioh) != 0)
-		return (0);
+		return 0;
 
 	/* Check that high byte of BANK_SELECT is what we expect. */
 	tmp = bus_space_read_2(iot, ioh, BANK_SELECT_REG_W);
@@ -160,22 +160,24 @@
 
  out:
 	bus_space_unmap(iot, ioh, SMC_IOSIZE);
-	return (rv);
+	return rv;
 }
 
 /* ARGSUSED */
-void
+static void
 sm_gxio_attach(device_t parent, device_t self, void *aux)
 {
 	struct sm_gxio_softc *gsc = device_private(self);
 	struct smc91cxx_softc *sc = &gsc->sc_smc;
 	struct gxio_attach_args *gxa = aux;
 	bus_space_handle_t ioh;
-	u_int8_t myea[ETHER_ADDR_LEN];
+	uint8_t myea[ETHER_ADDR_LEN];
 
 	aprint_normal("\n");
 	aprint_naive("\n");
 
+	KASSERT(system_serial_high != 0 || system_serial_low != 0);
+
 	/* Map i/o space. */
 	if (bus_space_map(gxa->gxa_iot, gxa->gxa_addr, SMC_IOSIZE, 0, &ioh))
 		panic("sm_gxio_attach: can't map i/o space");
@@ -186,17 +188,14 @@
 	/* should always be enabled */
 	sc->sc_flags |= SMC_FLAGS_ENABLED;
 
-	if (system_serial_high != 0 || system_serial_low != 0) {
-		myea[0] = ((system_serial_high >> 8) & 0xfe) | 0x02;
-		myea[1] = system_serial_high;
-		myea[2] = system_serial_low >> 24;
-		myea[3] = system_serial_low >> 16;
-		myea[4] = system_serial_low >> 8;
-		myea[5] = (system_serial_low & 0xc0) |
-		    (1 << 4) | ((ether_serial_digit++) & 0x0f);
-		smc91cxx_attach(sc, myea);
-	} else
-		smc91cxx_attach(sc, NULL);
+	myea[0] = ((system_serial_high >> 8) & 0xfe) | 0x02;
+	myea[1] = system_serial_high;
+	myea[2] = system_serial_low >> 24;
+	myea[3] = system_serial_low >> 16;
+	myea[4] = system_serial_low >> 8;
+	myea[5] = (system_serial_low & 0xc0) |
+	    (1 << 4) | ((ether_serial_digit++) & 0x0f);
+	smc91cxx_attach(sc, myea);
 
 	/* Establish the interrupt handler. */
 	gsc->sc_ih = gxio_intr_establish(gxa->gxa_sc,

Added files:

Index: src/sys/arch/evbarm/gumstix/gxlcd.c
diff -u /dev/null src/sys/arch/evbarm/gumstix/gxlcd.c:1.1
--- /dev/null	Sun Aug  9 07:10:13 2009
+++ src/sys/arch/evbarm/gumstix/gxlcd.c	Sun Aug  9 07:10:13 2009
@@ -0,0 +1,217 @@
+/*	$NetBSD: gxlcd.c,v 1.1 2009/08/09 07:10:13 kiyohara Exp $	*/
+
+/*
+ * Copyright (c) 2002, 2003  Genetec Corporation.  All rights reserved.
+ * Written by Hiroyuki Bessho for Genetec Corporation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of Genetec Corporation may not be used to endorse or
+ *    promote products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL GENETEC CORPORATION
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * LCD driver for Gumstix consoleLCD-vx and compatible.
+ * (based on the Intel Lubbock driver).
+ *
+ * Controlling LCD is almost completely done through PXA2X0's
+ * integrated LCD controller.  Codes for it is arm/xscale/pxa2x0_lcd.c.
+ *
+ * Codes in this file provide platform specific things including:
+ *   LCD on/off switch and backlight
+ *   LCD panel geometry
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: gxlcd.c,v 1.1 2009/08/09 07:10:13 kiyohara Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/conf.h>
+#include <sys/uio.h>
+#include <sys/malloc.h>
+
+#include <dev/cons.h>
+#include <dev/wscons/wsconsio.h>
+#include <dev/wscons/wsdisplayvar.h>
+#include <dev/wscons/wscons_callbacks.h>
+
+#include <machine/bus.h>
+
+#include <arm/xscale/pxa2x0var.h>
+#include <arm/xscale/pxa2x0reg.h>
+#include <arm/xscale/pxa2x0_lcd.h>
+#include <arm/xscale/pxa2x0_gpio.h>
+
+
+#ifndef CURRENT_DISPLAY
+#define CURRENT_DISPLAY samsung_lte430wq_f0c
+#endif
+
+
+static int gxlcd_match(device_t, cfdata_t, void *);
+static void gxlcd_attach(device_t, device_t, void *);
+
+void gxlcd_cnattach(void);
+
+static int gxlcd_ioctl(void *, void *, u_long, void *, int, struct lwp *);
+static int gxlcd_show_screen(void *, void *, int,
+			     void (*)(void *, int, int), void *);
+
+
+/*
+ * wsdisplay glue
+ */
+static struct pxa2x0_wsscreen_descr gxlcd_std_screen = {
+	.c = {
+		.name = "std",
+		.textops = &pxa2x0_lcd_emulops,
+		.fontwidth = 8,
+		.fontheight = 16,
+		.capabilities = WSSCREEN_WSCOLORS,
+	},
+	.depth = 16,			/* bits per pixel */
+};
+
+static const struct wsscreen_descr *gxlcd_scr_descr[] = {
+	&gxlcd_std_screen.c
+};
+
+static const struct wsscreen_list gxlcd_screen_list = {
+	.nscreens = __arraycount(gxlcd_scr_descr),
+	.screens = gxlcd_scr_descr,
+};
+
+struct wsdisplay_accessops gxlcd_accessops = {
+	gxlcd_ioctl,
+	pxa2x0_lcd_mmap,
+	pxa2x0_lcd_alloc_screen,
+	pxa2x0_lcd_free_screen,
+	gxlcd_show_screen,
+	NULL,
+	NULL,
+	NULL,
+};
+
+const struct lcd_panel_geometry samsung_lte430wq_f0c =
+{
+	480,			/* Width */
+	272,			/* Height */
+	0,			/* No extra lines */
+
+	LCDPANEL_ACTIVE | LCDPANEL_PCP,
+	1,			/* clock divider */
+	0,			/* AC bias pin freq */
+
+	41,			/* horizontal sync pulse width */
+	4,			/* BLW */
+	8,			/* ELW */
+
+	10,			/* vertical sync pulse width */
+	2,			/* BFW */
+	4,			/* EFW */
+};
+
+static int gxlcd_console;
+
+
+CFATTACH_DECL_NEW(gxlcd, sizeof(struct pxa2x0_lcd_softc),
+    gxlcd_match, gxlcd_attach, NULL, NULL);
+
+
+static int
+gxlcd_match(device_t parent, cfdata_t match, void *aux)
+{
+	struct pxaip_attach_args *pxa = aux;
+
+	if (strcmp(pxa->pxa_name, match->cf_name) != 0)
+		return 0;
+
+	pxa->pxa_size = PXA2X0_LCDC_SIZE;
+	return 1;
+}
+
+static void
+gxlcd_attach(device_t parent, device_t self, void *aux)
+{
+	struct pxa2x0_lcd_softc *sc = (struct pxa2x0_lcd_softc *)self;
+	struct wsemuldisplaydev_attach_args aa;
+
+	pxa2x0_lcd_attach_sub(sc, aux, &CURRENT_DISPLAY);
+
+	aa.console = gxlcd_console;
+	aa.scrdata = &gxlcd_screen_list;
+	aa.accessops = &gxlcd_accessops;
+	aa.accesscookie = sc;
+
+	pxa2x0_lcd_setup_wsscreen(&gxlcd_std_screen, &CURRENT_DISPLAY, NULL);
+
+	(void) config_found(self, &aa, wsemuldisplaydevprint);
+}
+
+void
+gxlcd_cnattach(void)
+{
+
+	pxa2x0_lcd_cnattach(&gxlcd_std_screen, &CURRENT_DISPLAY);
+
+	gxlcd_console = 1;
+}
+
+
+/*
+ * wsdisplay accessops overrides
+ */
+static int
+gxlcd_ioctl(void *v, void *vs, u_long cmd, void *data, int flag, struct lwp *l)
+{
+	int res = EINVAL;
+
+	switch (cmd) {
+	case WSDISPLAYIO_SVIDEO:
+		if (*(int *)data == WSDISPLAYIO_VIDEO_ON)
+			pxa2x0_gpio_set_function(17, GPIO_IN);
+		else
+			pxa2x0_gpio_set_function(17, GPIO_OUT | GPIO_CLR);
+		break;
+	}
+
+	if (res == EINVAL)
+		res = pxa2x0_lcd_ioctl(v, vs, cmd, data, flag, l);
+	return res;
+}
+
+static int
+gxlcd_show_screen(void *v, void *cookie, int waitok,
+		  void (*cb_func)(void *, int, int), void *cb_arg)
+{
+	int error;
+
+	error = pxa2x0_lcd_show_screen(v, cookie, waitok, cb_func, cb_arg);
+	if (error)
+		return (error);
+
+	/* Turn on LCD */
+	pxa2x0_gpio_set_function(17, GPIO_IN);
+
+	return 0;
+}
Index: src/sys/arch/evbarm/gumstix/if_smsh_gxio.c
diff -u /dev/null src/sys/arch/evbarm/gumstix/if_smsh_gxio.c:1.1
--- /dev/null	Sun Aug  9 07:10:13 2009
+++ src/sys/arch/evbarm/gumstix/if_smsh_gxio.c	Sun Aug  9 07:10:13 2009
@@ -0,0 +1,146 @@
+/*	$NetBSD: if_smsh_gxio.c,v 1.1 2009/08/09 07:10:13 kiyohara Exp $	*/
+/*
+ * Copyright (c) 2008 KIYOHARA Takashi
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: if_smsh_gxio.c,v 1.1 2009/08/09 07:10:13 kiyohara Exp $");
+
+#include <sys/param.h>
+#include <sys/device.h>
+#include <sys/errno.h>
+#include <sys/bus.h>
+#include <sys/systm.h>
+
+#include <evbarm/gumstix/gumstixvar.h>
+
+#include <net/if.h>
+#include <net/if_ether.h>
+#include <net/if_media.h>
+
+#include <dev/mii/miivar.h>
+
+#include <dev/ic/lan9118var.h>
+#include <dev/ic/lan9118reg.h>
+
+#include "locators.h"
+
+
+static int smsh_gxio_match(device_t, struct cfdata *, void *);
+static void smsh_gxio_attach(device_t, device_t, void *);
+
+static int ether_serial_digit = 1;  
+
+struct smsh_gxio_softc {
+	struct lan9118_softc sc_smsh;
+	void *sc_ih;
+
+	/*
+	 * Board independent DMA stuffs, if uses master DMA.
+	 * We use PXA2x0's DMA.
+	 */
+	struct dmac_xfer *sc_txfer;
+	struct dmac_xfer *sc_rxfer;
+};
+
+CFATTACH_DECL_NEW(smsh_gxio, sizeof(struct smsh_gxio_softc),
+    smsh_gxio_match, smsh_gxio_attach, NULL, NULL);
+
+
+/* ARGSUSED */
+static int
+smsh_gxio_match(device_t parent, struct cfdata *match, void *aux)
+{
+	struct gxio_attach_args *gxa = aux;
+	bus_space_tag_t iot = gxa->gxa_iot;
+	bus_space_handle_t ioh;
+	uint32_t val;
+	int rv = 0;
+
+	/* Disallow wildcarded values. */
+	if (gxa->gxa_addr == GXIOCF_ADDR_DEFAULT)
+		return 0;
+	if (gxa->gxa_gpirq == GXIOCF_GPIRQ_DEFAULT)
+		return 0;
+
+	if (bus_space_map(iot, gxa->gxa_addr, LAN9118_IOSIZE, 0, &ioh) != 0)
+		return 0;
+
+	bus_space_write_4(iot, ioh, LAN9118_BYTE_TEST, 0);
+	val = bus_space_read_4(iot, ioh, LAN9118_BYTE_TEST);
+	if (val == LAN9118_BYTE_TEST_VALUE)
+		/* Assume we have an SMSC LAN9117 */
+		rv = 1;
+	if (ether_serial_digit > 15)
+		rv = 0;
+
+	bus_space_unmap(iot, ioh, LAN9118_IOSIZE);
+	return rv;
+}
+
+/* ARGSUSED */
+static void
+smsh_gxio_attach(device_t parent, device_t self, void *aux)
+{
+	struct smsh_gxio_softc *gsc = device_private(self);
+	struct lan9118_softc *sc = &gsc->sc_smsh;
+	struct gxio_attach_args *gxa = aux;
+
+	aprint_normal("\n");
+	aprint_naive("\n");
+
+	KASSERT(system_serial_high != 0 || system_serial_low != 0);
+
+	sc->sc_dev = self;
+
+	/* Map i/o space. */
+	if (bus_space_map(gxa->gxa_iot, gxa->gxa_addr, LAN9118_IOSIZE, 0,
+	    &sc->sc_ioh))
+		panic("sms_gxio_attach: can't map i/o space");
+	sc->sc_iot = gxa->gxa_iot;
+
+	sc->sc_enaddr[0] = ((system_serial_high >> 8) & 0xfe) | 0x02;
+	sc->sc_enaddr[1] = system_serial_high;
+	sc->sc_enaddr[2] = system_serial_low >> 24;
+	sc->sc_enaddr[3] = system_serial_low >> 16;
+	sc->sc_enaddr[4] = system_serial_low >> 8;
+	sc->sc_enaddr[5] = (system_serial_low & 0xc0) |
+	    (1 << 4) | ((ether_serial_digit++) & 0x0f);
+	sc->sc_flags = LAN9118_FLAGS_NO_EEPROM;
+	if (lan9118_attach(sc) != 0) {
+		bus_space_unmap(sc->sc_iot, sc->sc_ioh, LAN9118_IOSIZE);
+		return;
+	}
+
+	/* Establish the interrupt handler. */
+	gsc->sc_ih = gxio_intr_establish(gxa->gxa_sc,
+	    gxa->gxa_gpirq, IST_EDGE_FALLING, IPL_NET, lan9118_intr, sc);
+	if (gsc->sc_ih == NULL) {
+		aprint_error_dev(self,
+		    "couldn't establish interrupt handler\n");
+		bus_space_unmap(sc->sc_iot, sc->sc_ioh, LAN9118_IOSIZE);
+		return;
+	}
+}

Reply via email to