diff options
| author | ober <ober@NetBSD.org> | 2006-12-16 05:07:52 +0000 |
|---|---|---|
| committer | ober <ober@NetBSD.org> | 2006-12-16 05:07:52 +0000 |
| commit | d429c3dc7655b49f6cf2eed8a0834012fa0c1933 (patch) | |
| tree | e62bd915515829a2c9328fbf12e9609fe6d6a7a4 /sys | |
| parent | b6131134e7ee1c2b90e9e8e3ea1efe7c309e2006 (diff) | |
Zaurus Port from OpenBSD by Nonaka Kimihiro
OK gimpy
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/arch/zaurus/conf/GENERIC | 253 | ||||
| -rw-r--r-- | sys/arch/zaurus/conf/Makefile.zaurus.inc | 22 | ||||
| -rw-r--r-- | sys/arch/zaurus/conf/files.zaurus | 90 | ||||
| -rw-r--r-- | sys/arch/zaurus/conf/ldscript.zaurus | 75 | ||||
| -rw-r--r-- | sys/arch/zaurus/conf/majors.zaurus | 111 | ||||
| -rw-r--r-- | sys/arch/zaurus/conf/std.zaurus | 20 | ||||
| -rw-r--r-- | sys/arch/zaurus/dev/scoop.c | 350 | ||||
| -rw-r--r-- | sys/arch/zaurus/dev/scoop_pcic.c | 262 |
8 files changed, 1183 insertions, 0 deletions
diff --git a/sys/arch/zaurus/conf/GENERIC b/sys/arch/zaurus/conf/GENERIC new file mode 100644 index 00000000000..5f2f9d0e1b0 --- /dev/null +++ b/sys/arch/zaurus/conf/GENERIC @@ -0,0 +1,253 @@ +# $NetBSD: GENERIC,v 1.1 2006/12/16 05:07:52 ober Exp $ +# +# GENERIC machine description file +# +# This machine description file is used to generate the default NetBSD +# kernel. The generic kernel does not include all options, subsystems +# and device drivers, but should be useful for most applications. +# +# The machine description file can be customised for your specific +# machine to reduce the kernel size and improve its performance. +# +# For further information on compiling NetBSD kernels, see the config(8) +# man page. +# +# For further information on hardware support for this architecture, see +# the intro(4) man page. For further information about kernel options +# for this architecture, see the options(4) man page. For an explanation +# of each device driver in this file see the section 4 man page for the +# device. + +include "arch/zaurus/conf/std.zaurus" + +#options INCLUDE_CONFIG_FILE # embed config file in kernel binary + +maxusers 32 # estimated number of users + +# CPU options + +# For XScale systems +#options CPU_XSCALE_PXA250 # Support the XScale PXA25x core +options CPU_XSCALE_PXA270 # Support the XScale PXA27x core +makeoptions CPUFLAGS="-mcpu=xscale" + +# Architecture options +options XSCALE_CACHE_READ_WRITE_ALLOCATE +options PXAGPIO_HAS_GPION_INTRS + +# Standard system options + +options RTC_OFFSET=0 # hardware clock is this many mins. west of GMT +#options HZ=512 # clock interrupt generates every 1/HZ sec +#options NTP # NTP phase/frequency locked loop + +# File systems +file-system FFS # UFS +#file-system EXT2FS # second extended file system (linux) +#file-system LFS # log-structured file system +file-system MFS # memory file system +#file-system NFS # Network File System client +#file-system NTFS # Windows/NT file system (experimental) +#file-system CD9660 # ISO 9660 + Rock Ridge file system +#file-system MSDOSFS # MS-DOS file system +#file-system FDESC # /dev/fd +file-system KERNFS # /kern +#file-system NULLFS # loopback file system +#file-system OVERLAY # overlay file system +#file-system PORTAL # portal filesystem (still experimental) +#file-system PROCFS # /proc +#file-system UMAPFS # NULLFS + uid and gid remapping +#file-system UNION # union file system +#file-system CODA # Coda File System; also needs vcoda (below) +#file-system PTYFS # /dev/pts/N support +file-system TMPFS # Efficient memory file-system +#file-system UDF # experimental - OSTA UDF CD/DVD file-system + +# File system options +#options QUOTA # UFS quotas +#options FFS_EI # FFS Endian Independant support +#options NFSSERVER +#options SOFTDEP +#options UFS_DIRHASH # UFS Large Directory Hashing - Experimental +options FFS_NO_SNAPSHOT # No FFS snapshot support +#options EXT2FS_SYSTEM_FLAGS # makes ext2fs file flags (append and + # immutable) behave as system flags. + +# Networking options +#options GATEWAY # packet forwarding +options INET # IP + ICMP + TCP + UDP +#options INET6 # IPv6 + +# Compatibility options +#options COMPAT_13 # NetBSD 1.3, +#options COMPAT_14 # NetBSD 1.4, +#options COMPAT_15 # NetBSD 1.5, +#options COMPAT_16 # NetBSD 1.6, +#options COMPAT_20 # NetBSD 2.0, +#options COMPAT_30 # NetBSD 3.0 compatibility. +options COMPAT_43 # and 4.3BSD +#options TCP_COMPAT_42 # 4.2BSD TCP/IP bug compat. Not recommended. +options COMPAT_OSSAUDIO # OSS (Voxware) audio driver compatibility +options COMPAT_BSDPTY # /dev/[pt]ty?? ptys. + +# Shared memory options + +options SYSVMSG # System V-like message queues +options SYSVSEM # System V-like semaphores +#options SEMMNI=10 # number of semaphore identifiers +#options SEMMNS=60 # number of semaphores in system +#options SEMUME=10 # max number of undo entries per process +#options SEMMNU=30 # number of undo structures in system +options SYSVSHM # System V-like memory sharing +#options SHMMAXPGS=1024 # 1024 pages is the default +options P1003_1B_SEMAPHORE # p1003.1b semaphore support + +# Device options + +# Miscellaneous kernel options +#options KTRACE # system call tracing via ktrace(1) +#options SYSTRACE # system call vetting via systrace(1) +#options IRQSTATS # manage IRQ statistics +#options LKM # loadable kernel modules +#options KMEMSTATS # kernel memory statistics +#options SCSIVERBOSE # Verbose SCSI errors +#options MIIVERBOSE # Verbose MII autoconfuration messages +#options USBVERBOSE # verbose USB device autoconfig messages +#options USERCONF # userconf(4) support +#options PIPE_SOCKETPAIR # smaller, but slower pipe(2) +#options SYSCTL_INCLUDE_DESCR # Include sysctl descriptions in kernel + +# +# wscons options +# +# builtin terminal emulations +#options WSEMUL_VT100 +# allocate a number of virtual screens at autoconfiguration time +#options WSDISPLAY_DEFAULTSCREENS=4 + +# customization of console and kernel output - see dev/wscons/wsdisplayvar.h +#options WSDISPLAY_CUSTOM_OUTPUT # color customization from wsconsctl(8) +#options WS_DEFAULT_FG=WSCOL_WHITE +#options WS_DEFAULT_BG=WSCOL_BLACK +#options WS_DEFAULT_COLATTR="(0)" +#options WS_DEFAULT_MONOATTR="(0)" +#options WS_KERNEL_FG=WSCOL_BROWN +#options WS_KERNEL_BG=WSCOL_BLUE +#options WS_KERNEL_COLATTR="" +#options WS_KERNEL_MONOATTR="" + +# compatibility to other console drivers +#options WSDISPLAY_COMPAT_PCVT # emulate some ioctls +#options WSDISPLAY_COMPAT_USL # VT handling +#options WSDISPLAY_COMPAT_RAWKBD # can get raw scancodes + +#options FONT_VT220L8x10 # the console font + +# Development and Debugging options + +options DIAGNOSTIC # internally consistency checks +options DEBUG +#options VERBOSE_INIT_ARM # verbose bootstraping messages +options DDB # in-kernel debugger +options DDB_HISTORY_SIZE=100 # Enable history editing in DDB +#options KGDB +#makeoptions DEBUG="-g" # compile full symbol table +#options SYMTAB_SPACE=512000 + + +# Kernel root file system and dump configuration. +config netbsd root on ? type ? + + +# The main bus device +mainbus0 at root + +# The boot cpu +cpu0 at mainbus? + +# integrated peripherals +pxaip0 at mainbus? + +pxaintc0 at pxaip? # interrupt controller +pxagpio0 at pxaip? # GPIO +pxadmac0 at pxaip? # DMA controller + +# PCMCIA/CF socket and GPIO controllers +scoop0 at pxaip? +scoop1 at pxaip? + +# ADC, touch screen, backlight +#zssp0 at pxaip? + +# touch screen +#zts0 at pxaip? +#wsmouse* at zts? mux 0 + +# keyboard +#zkbd0 at pxaip? +#wskbd* at zkbd? mux 1 + +# Zaurus remote controller +#zrc0 at pxaip? +#wskbd* at zrc? mux 1 + +# LCD +#lcd0 at pxaip? +#wsdisplay* at lcd? console ? + +## Audio +#zaudio0 at pxaip? +#audio* at zaudio? + +# cotulla integrated 16550 UARTs +options COM_PXA2X0 +com0 at pxaip? addr 0x40100000 intr 22 # Full Function UART +com1 at pxaip? addr 0x40200000 intr 21 # Bluetooth UART +com2 at pxaip? addr 0x40700000 intr 20 # Standard UART (for IrDA) + +# integrated PCMCIA/CF controller +pxapcic0 at pxaip? + +# PCMCIA bus support +pcmcia* at pxapcic? + +# PCMCIA (CF) devices +com* at pcmcia? # PCMCIA modems/serial ports +wi* at pcmcia? # WaveLAN IEEE 802.11DS +ne* at pcmcia? # PCMCIA based NE2000 ethernet +wdc* at pcmcia? # hard disk controller + +atabus* at wdc? channel ? + +# IDE hard drives +wd* at atabus? drive ? flags 0x0000 + +# Pseudo-Devices + +# disk/mass storage pseudo-devices +#pseudo-device md 1 # memory disk device (ramdisk) +#pseudo-device vnd 4 # disk-like interface to files +#options VND_COMPRESSION # compressed vnd(4) + +# network pseudo-devices +pseudo-device loop # network loopback + +# miscellaneous pseudo-devices +pseudo-device pty # pseudo-terminals +#pseudo-device sequencer # MIDI sequencer +pseudo-device rnd # /dev/random and in-kernel generator +pseudo-device clockctl # user control of clock subsystem +pseudo-device ksyms # /dev/ksyms + +# a pseudo device needed for Coda # also needs CODA (above) +#pseudo-device vcoda 4 # coda minicache <-> venus comm. + +# a pseudo device needed for SMBFS +#pseudo-device nsmb # experimental - SMB requester + +# a pseudo device needed for verified exec +#pseudo-device veriexec 1 + +# wscons pseudo-devices +#pseudo-device wsmux # mouse & keyboard multiplexor +#pseudo-device wsfont diff --git a/sys/arch/zaurus/conf/Makefile.zaurus.inc b/sys/arch/zaurus/conf/Makefile.zaurus.inc new file mode 100644 index 00000000000..346bc97d4b4 --- /dev/null +++ b/sys/arch/zaurus/conf/Makefile.zaurus.inc @@ -0,0 +1,22 @@ +# $NetBSD: Makefile.zaurus.inc,v 1.1 2006/12/16 05:08:47 ober Exp $ + +MACHINE_ARCH= arm +CPPFLAGS+= -D${MACHINE} + +SYSTEM_FIRST_OBJ= zaurus_start.o +SYSTEM_FIRST_SFILE= ${THISARM}/zaurus/zaurus_start.S + +KERNEL_BASE_PHYS= 0xa0200000 +KERNEL_BASE_VIRT= 0xc0200000 + +LINKFLAGS= -T ldscript + +netbsd: ldscript # XXX +EXTRA_CLEAN+= ldscript tmp + +# generate ldscript from common template +ldscript: ${THISARM}/conf/ldscript.zaurus ${THISARM}/conf/Makefile.zaurus.inc + echo ${KERNELS} + sed -e 's/@KERNEL_BASE_PHYS@/${KERNEL_BASE_PHYS}/' \ + -e 's/@KERNEL_BASE_VIRT@/${KERNEL_BASE_VIRT}/' \ + ${THISARM}/conf/ldscript.zaurus > tmp && mv tmp $@ diff --git a/sys/arch/zaurus/conf/files.zaurus b/sys/arch/zaurus/conf/files.zaurus new file mode 100644 index 00000000000..3cc4ed76dc0 --- /dev/null +++ b/sys/arch/zaurus/conf/files.zaurus @@ -0,0 +1,90 @@ +# $NetBSD: files.zaurus,v 1.1 2006/12/16 05:09:31 ober Exp $ +# +# zaurus specific configuration info +# + +maxpartitions 16 +maxusers 2 8 64 + +# Maintain Interrupt statistics +defflag IRQSTATS + +# Include WSCONS stuff +include "dev/wscons/files.wscons" +include "dev/rasops/files.rasops" +include "dev/wsfont/files.wsfont" + +# Machine-independent SCSI drivers +include "dev/scsipi/files.scsipi" + +# Machine-independent ATA drivers +include "dev/ata/files.ata" + +# Machine-independent I2O drivers. +include "dev/i2o/files.i2o" + +# Memory disk driver +file dev/md_root.c memory_disk_hooks + +# Generic MD files +file arch/zaurus/zaurus/autoconf.c +file arch/zaurus/zaurus/machdep.c + +file kern/subr_disk_mbr.c disk + +# ARM FPE +file arch/arm32/fpe-arm/armfpe_glue.S armfpe +file arch/arm32/fpe-arm/armfpe_init.c armfpe +file arch/arm32/fpe-arm/armfpe.s armfpe + +# Include Intel XScale PXA2x0 config definitions. +include "arch/arm/xscale/files.pxa2x0" + +# USB drivers +#include "dev/usb/files.usb" + +# 16-bit GPIO controller +device scoop +attach scoop at pxaip +file arch/zaurus/dev/scoop.c scoop + +# PCMCIA/CF socket controller +attach pxapcic at pxaip with pxapcic_scoop +file arch/zaurus/dev/scoop_pcic.c pxapcic_scoop + +# Dedicated SSP unit for ADC, touch screen, and backlight +device zssp +attach zssp at pxaip +file arch/zaurus/dev/zssp.c zssp + +# LCD frame buffer +attach lcd at pxaip with zlcd +file arch/zaurus/dev/zlcd.c zlcd + +# GPIO keyboard +device zkbd: wskbddev +attach zkbd at pxaip +file arch/zaurus/dev/zkbd.c zkbd + +# Zaurus touchpad +device zts: wsmousedev +attach zts at pxaip +file arch/zaurus/dev/zts.c zts needs-flag + +# Zaurus sound +device zaudio: audiobus, auconv, mulaw, aurateconv, pxaiis, pxaiic +attach zaudio at pxaip +file arch/zaurus/dev/zaudio.c zaudio + +# Zaurus remote control +device zrc: wskbddev +attach zrc at pxaip +file arch/zaurus/dev/zrc.c zrc + +# Power manager and APM emulation +#attach apm at pxaip with zapm +#file arch/zaurus/dev/zapm.c zapm + +include "dev/pcmcia/files.pcmcia" + +include "arch/zaurus/conf/majors.zaurus" diff --git a/sys/arch/zaurus/conf/ldscript.zaurus b/sys/arch/zaurus/conf/ldscript.zaurus new file mode 100644 index 00000000000..57def1e2508 --- /dev/null +++ b/sys/arch/zaurus/conf/ldscript.zaurus @@ -0,0 +1,75 @@ +/* $NetBSD: ldscript.zaurus,v 1.1 2006/12/16 05:09:56 ober Exp $ */ + +OUTPUT_ARCH(arm) +ENTRY(KERNEL_BASE_phys) +SECTIONS +{ + KERNEL_BASE_phys = @KERNEL_BASE_PHYS@; + KERNEL_BASE_virt = @KERNEL_BASE_VIRT@; + + /* Kernel start: */ + .start (KERNEL_BASE_phys) : + { + *(.start) + } =0 + + /* Read-only sections, merged into text segment: */ + .text (KERNEL_BASE_virt + SIZEOF(.start)) : + AT (LOADADDR(.start) + SIZEOF(.start)) + { + *(.text) + *(.text.*) + *(.stub) + *(.glue_7t) *(.glue_7) + *(.rodata) *(.rodata.*) + } =0 + PROVIDE (__etext = .); + PROVIDE (_etext = .); + PROVIDE (etext = .); + /* Adjust the address for the data segment to start on the next page + boundary. */ + . = ALIGN(0x8000); + .data : + AT (LOADADDR(.text) + (ADDR(.data) - ADDR(.text))) + { + __data_start = . ; + *(.data) + *(.data.*) + } + .sdata : + AT (LOADADDR(.data) + (ADDR(.sdata) - ADDR(.data))) + { + *(.sdata) + *(.sdata.*) + } + _edata = .; + PROVIDE (edata = .); + __bss_start = .; + __bss_start__ = .; + .sbss : + { + PROVIDE (__sbss_start = .); + PROVIDE (___sbss_start = .); + *(.dynsbss) + *(.sbss) + *(.sbss.*) + *(.scommon) + PROVIDE (__sbss_end = .); + PROVIDE (___sbss_end = .); + } + .bss : + { + *(.dynbss) + *(.bss) + *(.bss.*) + *(COMMON) + /* Align here to ensure that the .bss section occupies space up to + _end. Align after .bss to ensure correct alignment even if the + .bss section disappears because there are no input sections. */ + . = ALIGN(32 / 8); + } + . = ALIGN(32 / 8); + _end = .; + _bss_end__ = . ; __bss_end__ = . ; __end__ = . ; + PROVIDE (end = .); +} diff --git a/sys/arch/zaurus/conf/majors.zaurus b/sys/arch/zaurus/conf/majors.zaurus new file mode 100644 index 00000000000..412c791e2f2 --- /dev/null +++ b/sys/arch/zaurus/conf/majors.zaurus @@ -0,0 +1,111 @@ +# $NetBSD: majors.zaurus,v 1.1 2006/12/16 05:10:19 ober Exp $ +# +# Device majors for zaurus +# + +device-major mem char 0 +device-major swap char 1 block 1 vmswap +device-major cons char 2 +device-major ctty char 3 +device-major physcon char 4 vt +device-major log char 5 +device-major ptc char 6 pty +device-major pts char 7 pty +device-major lpt char 8 lpt +device-major qms char 9 qms + +device-major kbd char 11 kbd +device-major com char 12 com + +device-major ofcons char 15 ofcons +device-major wd char 16 block 16 wd +device-major fd char 17 block 17 fdc +device-major md char 18 block 18 md +device-major vnd char 19 block 19 vnd + +device-major ccd char 21 block 21 ccd +device-major cgd char 22 block 22 cgd + +device-major sd char 24 block 24 sd +device-major st char 25 block 25 st +device-major cd char 26 block 26 cd +device-major ch char 27 ch +device-major uk char 28 uk +device-major ss char 29 ss +device-major ses char 30 ses + +device-major bpf char 32 bpfilter +device-major tun char 33 tun +device-major filedesc char 34 +device-major lkm char 35 lkm +device-major audio char 36 audio +device-major vidcconsole char 37 vidcconsole + +device-major opms char 40 opms + +device-major ipl char 46 ipfilter + +device-major ofrom char 49 ofrom +device-major scr char 50 scr + +device-major rnd char 52 rnd +device-major prof char 53 profiler +device-major fcom char 54 fcom + +device-major joy char 56 joy +device-major midi char 57 midi +device-major sequencer char 58 sequencer +device-major vcoda char 59 vcoda +device-major wsdisplay char 60 wsdisplay +device-major wskbd char 61 wskbd +device-major wsmouse char 62 wsmouse + +device-major usb char 64 usb +device-major uhid char 65 uhid +device-major ulpt char 66 ulpt + +device-major scsibus char 70 scsibus +device-major raid char 71 block 71 raid +device-major ugen char 72 ugen +device-major wsmux char 73 wsmux +device-major ucom char 74 ucom +device-major urio char 75 urio +device-major uscanner char 76 uscanner +device-major openfirm char 77 openfirm +device-major biconsdev char 78 biconsdev +device-major isdn char 79 isdn +device-major isdnctl char 80 isdnctl +device-major isdnrchan char 81 isdnbchan +device-major isdntrc char 82 isdntrc +device-major isdntel char 83 isdntel +device-major sacom char 84 sacom +device-major mly char 85 mly +device-major wsfont char 86 wsfont +device-major agp char 87 agp +device-major pci char 88 pci +device-major iop char 89 iop +device-major altq char 90 altq +device-major mlx char 91 mlx +device-major ld char 92 block 92 ld +device-major plcom char 93 plcom +device-major clockctl char 94 clockctl +device-major irframe char 95 irframedrv +device-major cir char 96 cir +device-major radio char 97 radio +device-major systrace char 98 systrace +device-major kttcp char 99 kttcp +device-major ixpcom char 100 ixpcom +device-major sysmon char 101 sysmon_envsys | sysmon_wdog | sysmon_power +device-major dmoverio char 102 dmoverio +device-major apmdev char 103 apmdev +device-major sscom char 104 sscom +device-major ksyms char 105 ksyms +device-major isdnbchan char 106 isdnbchan +device-major epcom char 107 epcom +device-major tslcd char 108 tslcd +device-major twe char 109 twe +device-major nsmb char 110 nsmb + +# Majors up to 143 are reserved for machine-dependant drivers. +# New machine-independant driver majors are assigned in +# sys/conf/majors. diff --git a/sys/arch/zaurus/conf/std.zaurus b/sys/arch/zaurus/conf/std.zaurus new file mode 100644 index 00000000000..3dbacc4edc4 --- /dev/null +++ b/sys/arch/zaurus/conf/std.zaurus @@ -0,0 +1,20 @@ +# $NetBSD: std.zaurus,v 1.1 2006/12/16 05:10:42 ober Exp $ +# +# standard NetBSD/zaurus options + +machine zaurus arm +include "conf/std" # MI standard options + +options EXEC_AOUT +options EXEC_ELF32 +options EXEC_SCRIPT + +# To support easy transit to ../arch/arm/arm32 +options ARM32 + +#options ARM32_NEW_VM_LAYOUT # Not yet ready for prime-time + +options ARM_INTR_IMPL="<arch/arm/xscale/pxa2x0_intr.h>" + +# OS Timer +saost* at pxaip? addr 0x40a00000 size 0x20 diff --git a/sys/arch/zaurus/dev/scoop.c b/sys/arch/zaurus/dev/scoop.c new file mode 100644 index 00000000000..7d82c66931d --- /dev/null +++ b/sys/arch/zaurus/dev/scoop.c @@ -0,0 +1,350 @@ +/* $NetBSD: scoop.c,v 1.1 2006/12/16 05:15:16 ober Exp $ */ +/* $OpenBSD: zaurus_scoop.c,v 1.12 2005/11/17 05:26:31 uwe Exp $ */ + +/* + * Copyright (c) 2005 Uwe Stuehler <uwe@bsdx.de> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <sys/cdefs.h> +__KERNEL_RCSID(0, "$NetBSD: scoop.c,v 1.1 2006/12/16 05:15:16 ober Exp $"); + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/device.h> +#include <sys/conf.h> +#include <sys/gpio.h> + +#include <machine/bus.h> + +#include <arm/xscale/pxa2x0var.h> + +#include <zaurus/zaurus/zaurus_reg.h> +#include <zaurus/zaurus/zaurus_var.h> + +#include <zaurus/dev/scoopreg.h> +#include <zaurus/dev/scoopvar.h> + +#include "ioconf.h" + +struct scoop_softc { + struct device sc_dev; + bus_space_tag_t sc_iot; + bus_space_handle_t sc_ioh; + uint16_t sc_gpwr; /* GPIO state before suspend */ +}; + +static int scoopmatch(struct device *, struct cfdata *, void *); +static void scoopattach(struct device *, struct device *, void *); + +CFATTACH_DECL(scoop, sizeof(struct scoop_softc), + scoopmatch, scoopattach, NULL, NULL); + +int scoop_gpio_pin_read(struct scoop_softc *sc, int); +void scoop_gpio_pin_write(struct scoop_softc *sc, int, int); +void scoop_gpio_pin_ctl(struct scoop_softc *sc, int, int); + +static int +scoopmatch(struct device *parent, struct cfdata *cf, void *aux) +{ + + /* + * Only C3000-like models are known to have two SCOOPs. + */ + if (ZAURUS_ISC3000) + return (cf->cf_unit < 2); + return (cf->cf_unit == 0); +} + +static void +scoopattach(struct device *parent, struct device *self, void *aux) +{ + struct pxaip_attach_args *pxa = (struct pxaip_attach_args *)aux; + struct scoop_softc *sc = (struct scoop_softc *)self; + bus_addr_t addr; + bus_size_t size; + + sc->sc_iot = pxa->pxa_iot; + + if (pxa->pxa_addr != -1) + addr = pxa->pxa_addr; + else if (sc->sc_dev.dv_unit == 0) + addr = C3000_SCOOP0_BASE; + else + addr = C3000_SCOOP1_BASE; + + size = pxa->pxa_size < SCOOP_SIZE ? SCOOP_SIZE : pxa->pxa_size; + + if (bus_space_map(sc->sc_iot, addr, size, 0, &sc->sc_ioh) != 0) { + printf(": failed to map %s\n", sc->sc_dev.dv_xname); + return; + } + + if (ZAURUS_ISC3000 && sc->sc_dev.dv_unit == 1) { + scoop_gpio_pin_ctl(sc, SCOOP1_AKIN_PULLUP, GPIO_PIN_OUTPUT); + scoop_gpio_pin_write(sc, SCOOP1_AKIN_PULLUP, GPIO_PIN_LOW); + } else if (!ZAURUS_ISC3000) { + scoop_gpio_pin_ctl(sc, SCOOP0_AKIN_PULLUP, GPIO_PIN_OUTPUT); + scoop_gpio_pin_write(sc, SCOOP0_AKIN_PULLUP, GPIO_PIN_LOW); + } + + printf(": PCMCIA/GPIO controller\n"); +} + +int +scoop_gpio_pin_read(struct scoop_softc *sc, int pin) +{ + uint16_t bit = (1 << pin); + uint16_t rv; + + rv = bus_space_read_2(sc->sc_iot, sc->sc_ioh, SCOOP_GPWR); + return (rv & bit) != 0 ? 1 : 0; +} + +void +scoop_gpio_pin_write(struct scoop_softc *sc, int pin, int level) +{ + uint16_t bit = (1 << pin); + uint16_t rv; + + rv = bus_space_read_2(sc->sc_iot, sc->sc_ioh, SCOOP_GPWR); + bus_space_write_2(sc->sc_iot, sc->sc_ioh, SCOOP_GPWR, + level == GPIO_PIN_LOW ? (rv & ~bit) : (rv | bit)); +} + +void +scoop_gpio_pin_ctl(struct scoop_softc *sc, int pin, int flags) +{ + uint16_t bit = (1 << pin); + uint16_t rv; + + rv = bus_space_read_2(sc->sc_iot, sc->sc_ioh, SCOOP_GPCR); + switch (flags & (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT)) { + case GPIO_PIN_INPUT: + rv &= ~bit; + break; + case GPIO_PIN_OUTPUT: + rv |= bit; + break; + } + bus_space_write_2(sc->sc_iot, sc->sc_ioh, SCOOP_GPCR, rv); +} + +/* + * Turn the LCD background light and contrast signal on or off. + */ +void +scoop_set_backlight(int on, int cont) +{ + + if (scoop_cd.cd_ndevs > 1 && scoop_cd.cd_devs[1] != NULL) { + /* C3000 */ + scoop_gpio_pin_write(scoop_cd.cd_devs[1], + SCOOP1_BACKLIGHT_CONT, !cont); + scoop_gpio_pin_write(scoop_cd.cd_devs[1], + SCOOP1_BACKLIGHT_ON, on); + } +#if 0 + else if (scoop_cd.cd_ndevs > 0 && scoop_cd.cd_devs[0] != NULL) { + scoop_gpio_pin_write(scoop_cd.cd_devs[0], + SCOOP0_BACKLIGHT_CONT, cont); + } +#endif +} + +/* + * Turn the infrared LED on or off (must be on while transmitting). + */ +void +scoop_set_irled(int on) +{ + if (scoop_cd.cd_ndevs > 1 && scoop_cd.cd_devs[1] != NULL) + /* IR_ON is inverted */ + scoop_gpio_pin_write(scoop_cd.cd_devs[1], + SCOOP1_IR_ON, !on); +} + +/* + * Turn the green and orange LEDs on or off. If the orange LED is on, + * then it is wired to indicate if A/C is connected. The green LED has + * no such predefined function. + */ +void +scoop_led_set(int led, int on) +{ + + if (scoop_cd.cd_ndevs > 0 && scoop_cd.cd_devs[0] != NULL) { + if ((led & SCOOP_LED_GREEN) != 0) { + scoop_gpio_pin_write(scoop_cd.cd_devs[0], + SCOOP0_LED_GREEN, on); + } + if (scoop_cd.cd_ndevs > 1 && (led & SCOOP_LED_ORANGE) != 0) { + scoop_gpio_pin_write(scoop_cd.cd_devs[0], + SCOOP0_LED_ORANGE_C3000, on); + } + } +} + +/* + * Enable or disable the headphone output connection. + */ +void +scoop_set_headphone(int on) +{ + + if (scoop_cd.cd_ndevs < 1 || scoop_cd.cd_devs[0] == NULL) + return; + + scoop_gpio_pin_ctl(scoop_cd.cd_devs[0], SCOOP0_MUTE_L, + GPIO_PIN_OUTPUT); + scoop_gpio_pin_ctl(scoop_cd.cd_devs[0], SCOOP0_MUTE_R, + GPIO_PIN_OUTPUT); + + if (on) { + scoop_gpio_pin_write(scoop_cd.cd_devs[0], SCOOP0_MUTE_L, + GPIO_PIN_HIGH); + scoop_gpio_pin_write(scoop_cd.cd_devs[0], SCOOP0_MUTE_R, + GPIO_PIN_HIGH); + } else { + scoop_gpio_pin_write(scoop_cd.cd_devs[0], SCOOP0_MUTE_L, + GPIO_PIN_LOW); + scoop_gpio_pin_write(scoop_cd.cd_devs[0], SCOOP0_MUTE_R, + GPIO_PIN_LOW); + } +} + +/* + * Turn on pullup resistor while not reading the remote control. + */ +void +scoop_akin_pullup(int enable) +{ + + if (scoop_cd.cd_ndevs > 1 && scoop_cd.cd_devs[1] != NULL) { + scoop_gpio_pin_write(scoop_cd.cd_devs[1], + SCOOP1_AKIN_PULLUP, enable); + } else { + scoop_gpio_pin_write(scoop_cd.cd_devs[0], + SCOOP0_AKIN_PULLUP, enable); + } +} + +void +scoop_battery_temp_adc(int enable) +{ + + if (scoop_cd.cd_ndevs > 0 && scoop_cd.cd_devs[0] != NULL) { + scoop_gpio_pin_write(scoop_cd.cd_devs[0], + SCOOP0_ADC_TEMP_ON_C3000, enable); + } +} + +void +scoop_charge_battery(int enable, int voltage_high) +{ + + if (scoop_cd.cd_ndevs > 0 && scoop_cd.cd_devs[0] != NULL) { + scoop_gpio_pin_write(scoop_cd.cd_devs[0], + SCOOP0_JK_B_C3000, voltage_high); + scoop_gpio_pin_write(scoop_cd.cd_devs[0], + SCOOP0_CHARGE_OFF_C3000, !enable); + } +} + +void +scoop_discharge_battery(int enable) +{ + + if (scoop_cd.cd_ndevs > 0 && scoop_cd.cd_devs[0] != NULL) { + scoop_gpio_pin_write(scoop_cd.cd_devs[0], + SCOOP0_JK_A_C3000, enable); + } +} + +/* XXX */ +void scoop_check_mcr(void); +void +scoop_check_mcr(void) +{ + struct scoop_softc *sc; + uint16_t v; + + /* C3000 */ + if (scoop_cd.cd_ndevs > 1 && scoop_cd.cd_devs[1] != NULL) { + sc = scoop_cd.cd_devs[0]; + v = bus_space_read_2(sc->sc_iot, sc->sc_ioh, SCOOP_MCR); + if ((v & 0x100) == 0) { + bus_space_write_2(sc->sc_iot, sc->sc_ioh, SCOOP_MCR, + 0x0101); + } + + sc = scoop_cd.cd_devs[1]; + v = bus_space_read_2(sc->sc_iot, sc->sc_ioh, SCOOP_MCR); + if ((v & 0x100) == 0) { + bus_space_write_2(sc->sc_iot, sc->sc_ioh, SCOOP_MCR, + 0x0101); + } + } +} + +void +scoop_suspend(void) +{ + struct scoop_softc *sc; + uint32_t rv; + + if (scoop_cd.cd_ndevs > 0 && scoop_cd.cd_devs[0] != NULL) { + sc = scoop_cd.cd_devs[0]; + sc->sc_gpwr = bus_space_read_2(sc->sc_iot, sc->sc_ioh, + SCOOP_GPWR); + /* C3000 */ + bus_space_write_2(sc->sc_iot, sc->sc_ioh, SCOOP_GPWR, + sc->sc_gpwr & ~((1<<SCOOP0_MUTE_L) | (1<<SCOOP0_MUTE_R) | + (1<<SCOOP0_JK_A_C3000) | (1<<SCOOP0_ADC_TEMP_ON_C3000) | + (1<<SCOOP0_LED_GREEN))); + } + + /* C3000 */ + if (scoop_cd.cd_ndevs > 1 && scoop_cd.cd_devs[1] != NULL) { + sc = scoop_cd.cd_devs[1]; + sc->sc_gpwr = bus_space_read_2(sc->sc_iot, sc->sc_ioh, + SCOOP_GPWR); + bus_space_write_2(sc->sc_iot, sc->sc_ioh, SCOOP_GPWR, + sc->sc_gpwr & ~((1<<SCOOP1_RESERVED_4) | + (1<<SCOOP1_RESERVED_5) | (1<<SCOOP1_RESERVED_6) | + (1<<SCOOP1_BACKLIGHT_CONT) | (1<<SCOOP1_BACKLIGHT_ON) | + (1<<SCOOP1_MIC_BIAS))); + rv = bus_space_read_2(sc->sc_iot, sc->sc_ioh, SCOOP_GPWR); + bus_space_write_2(sc->sc_iot, sc->sc_ioh, SCOOP_GPWR, + rv | ((1<<SCOOP1_IR_ON) | (1<<SCOOP1_RESERVED_3))); + } +} + +void +scoop_resume(void) +{ + struct scoop_softc *sc; + + if (scoop_cd.cd_ndevs > 0 && scoop_cd.cd_devs[0] != NULL) { + sc = scoop_cd.cd_devs[0]; + bus_space_write_2(sc->sc_iot, sc->sc_ioh, SCOOP_GPWR, + sc->sc_gpwr); + } + + if (scoop_cd.cd_ndevs > 1 && scoop_cd.cd_devs[1] != NULL) { + sc = scoop_cd.cd_devs[1]; + bus_space_write_2(sc->sc_iot, sc->sc_ioh, SCOOP_GPWR, + sc->sc_gpwr); + } +} diff --git a/sys/arch/zaurus/dev/scoop_pcic.c b/sys/arch/zaurus/dev/scoop_pcic.c new file mode 100644 index 00000000000..8b4dfd9ff1e --- /dev/null +++ b/sys/arch/zaurus/dev/scoop_pcic.c @@ -0,0 +1,262 @@ +/* $NetBSD: scoop_pcic.c,v 1.1 2006/12/16 05:17:30 ober Exp $ */ +/* $OpenBSD: scoop_pcic.c,v 1.1 2005/07/01 23:51:55 uwe Exp $ */ + +/* + * Copyright (c) 2005 Uwe Stuehler <uwe@bsdx.de> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <sys/cdefs.h> +__KERNEL_RCSID(0, "$NetBSD: scoop_pcic.c,v 1.1 2006/12/16 05:17:30 ober Exp $"); + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/device.h> + +#include <uvm/uvm.h> + +#include <arch/arm/xscale/pxa2x0var.h> +#include <arch/arm/xscale/pxa2x0_pcicvar.h> + +#include <zaurus/zaurus/zaurus_reg.h> +#include <zaurus/zaurus/zaurus_var.h> + +#include <zaurus/dev/scoopreg.h> + +static int scoop_pcic_match(struct device *, struct cfdata *, void *); +static void scoop_pcic_attach(struct device *, struct device *, void *); + +CFATTACH_DECL(pxapcic_scoop, sizeof(struct pxapcic_softc), + scoop_pcic_match, scoop_pcic_attach, NULL, NULL); + +static void scoop_pcic_socket_setup(struct pxapcic_socket *); +static u_int scoop_pcic_read(struct pxapcic_socket *, int); +static void scoop_pcic_write(struct pxapcic_socket *, int, u_int); +static void scoop_pcic_set_power(struct pxapcic_socket *, int); +static void scoop_pcic_clear_intr(struct pxapcic_socket *); + +struct pxapcic_tag scoop_pcic_functions = { + scoop_pcic_read, + scoop_pcic_write, + scoop_pcic_set_power, + scoop_pcic_clear_intr, + 0, /* intr_establish */ + 0, /* intr_disestablish */ + 0 /* intr_string */ +}; + +static int +scoop_pcic_match(struct device *parent, struct cfdata *cf, void *aux) +{ + + return (ZAURUS_ISC860 || ZAURUS_ISC3000); +} + +static void +scoop_pcic_attach(struct device *parent, struct device *self, void *aux) +{ + struct pxapcic_softc *sc = (struct pxapcic_softc *)self; + struct pxaip_attach_args *pxa = (struct pxaip_attach_args *)aux; + + sc->sc_iot = pxa->pxa_iot; + + if (ZAURUS_ISC860) { + sc->sc_nslots = 1; + sc->sc_irqpin[0] = C860_CF0_IRQ; + sc->sc_irqcfpin[0] = C860_CF0_IRQ_PIN; + } else if (ZAURUS_ISC3000) { + sc->sc_nslots = 2; + sc->sc_irqpin[0] = C3000_CF0_IRQ; + sc->sc_irqcfpin[0] = C3000_CF0_IRQ_PIN; + sc->sc_irqpin[1] = C3000_CF1_IRQ; + sc->sc_irqcfpin[1] = C3000_CF1_IRQ_PIN; + } + sc->sc_flags |= PXAPCIC_FLAG_REVERSE_ATTACH; + + pxapcic_attach(sc, &scoop_pcic_socket_setup); +} + +static void +scoop_pcic_socket_setup(struct pxapcic_socket *so) +{ + struct pxapcic_softc *sc; + bus_addr_t pa; + bus_size_t size = SCOOP_SIZE; + bus_space_tag_t iot; + bus_space_handle_t scooph; + int error; + + sc = so->sc; + iot = sc->sc_iot; + + if (so->socket == 0) { + pa = C3000_SCOOP0_BASE; + } else if (so->socket == 1) { + pa = C3000_SCOOP1_BASE; + } else { + panic("%s: invalid CF slot %d", sc->sc_dev.dv_xname, + so->socket); + } + + error = bus_space_map(iot, trunc_page(pa), round_page(size), + 0, &scooph); + if (error) { + panic("%s: failed to map memory %x for scoop", + sc->sc_dev.dv_xname, (uint32_t)pa); + } + scooph += pa - trunc_page(pa); + + bus_space_write_2(iot, scooph, SCOOP_IMR, + SCP_IMR_UNKN0 | SCP_IMR_UNKN1); + + /* setup */ + bus_space_write_2(iot, scooph, SCOOP_MCR, 0x0100); + bus_space_write_2(iot, scooph, SCOOP_CDR, 0x0000); + bus_space_write_2(iot, scooph, SCOOP_CPR, 0x0000); + bus_space_write_2(iot, scooph, SCOOP_IMR, 0x0000); + bus_space_write_2(iot, scooph, SCOOP_IRM, 0x00ff); + bus_space_write_2(iot, scooph, SCOOP_ISR, 0x0000); + bus_space_write_2(iot, scooph, SCOOP_IRM, 0x0000); + + /* C3000 */ + if (so->socket == 1) { + bus_space_write_2(iot, scooph, SCOOP_CPR, 0x80c1); + bus_space_write_2(iot, scooph, SCOOP_IMR, 0x00c4); + bus_space_write_2(iot, scooph, SCOOP_MCR, 0x0111); + } else { + bus_space_write_2(iot, scooph, SCOOP_CPR, + SCP_CPR_PWR|SCP_CPR_5V); + } + + bus_space_write_2(iot, scooph, SCOOP_IMR, 0x00ce); + bus_space_write_2(iot, scooph, SCOOP_MCR, 0x0111); + + /* C3000 */ + so->power_capability = PXAPCIC_POWER_3V; + if (so->socket == 0) + so->power_capability |= PXAPCIC_POWER_5V; + + so->pcictag_cookie = (void *)scooph; + so->pcictag = &scoop_pcic_functions; +} + +static u_int +scoop_pcic_read(struct pxapcic_socket *so, int reg) +{ + bus_space_tag_t iot = so->sc->sc_iot; + bus_space_handle_t ioh = (bus_space_handle_t)so->pcictag_cookie; + uint16_t csr; + + csr = bus_space_read_2(iot, ioh, SCOOP_CSR); + + switch (reg) { + case PXAPCIC_CARD_STATUS: + if (csr & SCP_CSR_MISSING) + return (PXAPCIC_CARD_INVALID); + else + return (PXAPCIC_CARD_VALID); + + case PXAPCIC_CARD_READY: + return ((bus_space_read_2(iot, ioh, SCOOP_CSR) & + SCP_CSR_READY) != 0); + + default: + panic("scoop_pcic_read: bogus register"); + } + /*NOTREACHED*/ +} + +static void +scoop_pcic_write(struct pxapcic_socket *so, int reg, u_int val) +{ + bus_space_tag_t iot = so->sc->sc_iot; + bus_space_handle_t ioh = (bus_space_handle_t)so->pcictag_cookie; + uint16_t newval; + int s; + + s = splhigh(); + + switch (reg) { + case PXAPCIC_CARD_POWER: + newval = bus_space_read_2(iot, ioh, SCOOP_CPR); + newval &= ~(SCP_CPR_PWR | SCP_CPR_3V | SCP_CPR_5V); + + if (val == PXAPCIC_POWER_3V) + newval |= (SCP_CPR_PWR | SCP_CPR_3V); + else if (val == PXAPCIC_POWER_5V) + newval |= (SCP_CPR_PWR | SCP_CPR_5V); + + bus_space_write_2(iot, ioh, SCOOP_CPR, newval); + break; + + case PXAPCIC_CARD_RESET: + bus_space_write_2(iot, ioh, SCOOP_CCR, + val ? SCP_CCR_RESET : 0); + break; + + default: + panic("scoop_pcic_write: bogus register"); + } + + splx(s); +} + +static void +scoop_pcic_set_power(struct pxapcic_socket *so, int pwr) +{ + bus_space_tag_t iot = so->sc->sc_iot; + bus_space_handle_t ioh = (bus_space_handle_t)so->pcictag_cookie; + u_int16_t reg; + int s; + + s = splhigh(); + + switch (pwr) { + case PXAPCIC_POWER_OFF: +#if 0 + /* XXX does this disable power to both sockets? */ + reg = bus_space_read_2(iot, ioh, SCOOP_GPWR); + bus_space_write_2(iot, ioh, SCOOP_GPWR, + reg & ~(1 << SCOOP0_CF_POWER_C3000)); +#endif + break; + + case PXAPCIC_POWER_3V: + case PXAPCIC_POWER_5V: + /* XXX */ + if (so->socket == 0) { + reg = bus_space_read_2(iot, ioh, SCOOP_GPWR); + bus_space_write_2(iot, ioh, SCOOP_GPWR, + reg | (1 << SCOOP0_CF_POWER_C3000)); + } + break; + + default: + splx(s); + panic("scoop_pcic_set_power: bogus power state"); + } + + splx(s); +} + +static void +scoop_pcic_clear_intr(struct pxapcic_socket *so) +{ + bus_space_tag_t iot = so->sc->sc_iot; + bus_space_handle_t ioh = (bus_space_handle_t)so->pcictag_cookie; + + bus_space_write_2(iot, ioh, SCOOP_IRM, 0x00ff); + bus_space_write_2(iot, ioh, SCOOP_ISR, 0x0000); + bus_space_write_2(iot, ioh, SCOOP_IRM, 0x0000); +} |
