summaryrefslogtreecommitdiff
path: root/sys/arch/zaurus
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/zaurus')
-rw-r--r--sys/arch/zaurus/conf/GENERIC8
-rw-r--r--sys/arch/zaurus/conf/RAMDISK8
-rw-r--r--sys/arch/zaurus/conf/files.zaurus6
-rw-r--r--sys/arch/zaurus/dev/zaurus_scoop.c43
-rw-r--r--sys/arch/zaurus/dev/zaurus_scoopreg.h9
-rw-r--r--sys/arch/zaurus/dev/zaurus_scoopvar.h8
-rw-r--r--sys/arch/zaurus/zaurus/zaurus_apm.c90
7 files changed, 148 insertions, 24 deletions
diff --git a/sys/arch/zaurus/conf/GENERIC b/sys/arch/zaurus/conf/GENERIC
index d1d9e035b92..827715f48a7 100644
--- a/sys/arch/zaurus/conf/GENERIC
+++ b/sys/arch/zaurus/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.21 2005/01/19 02:02:34 uwe Exp $
+# $OpenBSD: GENERIC,v 1.22 2005/01/20 23:34:36 uwe Exp $
#
# GENERIC machine description file
#
@@ -60,8 +60,8 @@ pxaip0 at mainbus?
pxaintc0 at pxaip? # interrupt controller
pxagpio0 at pxaip? # GPIO
-#scoop0 at pxaip? addr 0x10800000 size 0x2c
-#scoop1 at pxaip? addr 0x14800000 size 0x2c
+scoop0 at pxaip?
+scoop1 at pxaip?
saost0 at pxaip? addr 0x40a00000 size 0x20
ohci0 at pxaip? addr 0x4c000000 size 0x70 intr 3
usb* at ohci?
@@ -183,7 +183,7 @@ lcd0 at pxaip?
wsdisplay* at lcd? console ?
# APM emulation
-#apm0 at pxaip?
+apm0 at pxaip?
# Pseudo-Devices
pseudo-device wsmux 2 # mouse & keyboard multiplexor
diff --git a/sys/arch/zaurus/conf/RAMDISK b/sys/arch/zaurus/conf/RAMDISK
index dc500a93516..00335981668 100644
--- a/sys/arch/zaurus/conf/RAMDISK
+++ b/sys/arch/zaurus/conf/RAMDISK
@@ -1,4 +1,4 @@
-# $OpenBSD: RAMDISK,v 1.16 2005/01/19 02:02:34 uwe Exp $
+# $OpenBSD: RAMDISK,v 1.17 2005/01/20 23:34:36 uwe Exp $
#
# GENERIC machine description file
#
@@ -66,8 +66,8 @@ pxaip0 at mainbus?
pxaintc0 at pxaip? # interrupt controller
pxagpio0 at pxaip? # GPIO
-#scoop0 at pxaip? addr 0x10800000 size 0x2c
-#scoop1 at pxaip? addr 0x14800000 size 0x2c
+scoop0 at pxaip?
+scoop1 at pxaip?
saost0 at pxaip? addr 0x40a00000 size 0x20
ohci0 at pxaip? addr 0x4c000000 size 0x70 intr 3
usb* at ohci?
@@ -163,7 +163,7 @@ lcd0 at pxaip?
wsdisplay* at lcd? console ?
# APM emulation
-#apm0 at pxaip?
+apm0 at pxaip?
# Pseudo-Devices
pseudo-device wsmux 2 # mouse & keyboard multiplexor
diff --git a/sys/arch/zaurus/conf/files.zaurus b/sys/arch/zaurus/conf/files.zaurus
index e14ff5b196f..defaaf6e15b 100644
--- a/sys/arch/zaurus/conf/files.zaurus
+++ b/sys/arch/zaurus/conf/files.zaurus
@@ -1,4 +1,4 @@
-# $OpenBSD: files.zaurus,v 1.12 2005/01/19 02:02:34 uwe Exp $
+# $OpenBSD: files.zaurus,v 1.13 2005/01/20 23:34:36 uwe Exp $
#
# First try for arm-specific configuration info
#
@@ -38,6 +38,10 @@ device scoop
attach scoop at pxaip with scoop_pxaip
file arch/zaurus/dev/zaurus_scoop.c scoop
+# Power manager and APM emulation
+attach apm at pxaip with apm_pxaip
+file arch/zaurus/zaurus/zaurus_apm.c apm_pxaip
+
#
# Machine-independent ATA drivers
#
diff --git a/sys/arch/zaurus/dev/zaurus_scoop.c b/sys/arch/zaurus/dev/zaurus_scoop.c
index 83364d7e4c3..9f851de62dc 100644
--- a/sys/arch/zaurus/dev/zaurus_scoop.c
+++ b/sys/arch/zaurus/dev/zaurus_scoop.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: zaurus_scoop.c,v 1.2 2005/01/19 15:56:44 uwe Exp $ */
+/* $OpenBSD: zaurus_scoop.c,v 1.3 2005/01/20 23:34:37 uwe Exp $ */
/*
* Copyright (c) 2005 Uwe Stuehler <uwe@bsdx.de>
@@ -44,9 +44,6 @@ struct cfdriver scoop_cd = {
NULL, "scoop", DV_DULL
};
-/* GPIO pin/bit numbers for the Zaurus C3000. */
-#define SCOOP1_BACKLIGHT_ON 8
-
int scoop_gpio_pin_read(struct scoop_softc *sc, int);
void scoop_gpio_pin_write(struct scoop_softc *sc, int, int);
@@ -54,12 +51,8 @@ void scoop_gpio_pin_write(struct scoop_softc *sc, int, int);
int
scoopmatch(struct device *parent, void *match, void *aux)
{
- struct pxaip_attach_args *pxa = aux;
struct cfdata *cf = match;
- if (pxa->pxa_addr == -1)
- return 0;
-
/*
* Only the C3000 models (pxa270) are known to have two SCOOPs,
* on other models we only find the first one.
@@ -75,13 +68,21 @@ scoopattach(struct device *parent, struct device *self, void *aux)
{
struct pxaip_attach_args *pxa = 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 = SCOOP0_BASE;
+ else
+ addr = SCOOP1_BASE;
+
size = pxa->pxa_size < SCOOP_SIZE ? SCOOP_SIZE : pxa->pxa_size;
- if (bus_space_map(sc->sc_iot, pxa->pxa_addr, size, 0,
- &sc->sc_ioh) != 0) {
+ 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;
}
@@ -111,12 +112,30 @@ scoop_gpio_pin_write(struct scoop_softc *sc, int pin, int value)
}
void
-scoop_backlight_on(int enable)
+scoop_backlight_set(int on)
{
#if 0 /* XXX no effect. maybe the pin is incorrectly configured? */
if (scoop_cd.cd_ndevs > 1 && scoop_cd.cd_devs[1] != NULL)
scoop_gpio_pin_write(scoop_cd.cd_devs[1],
- SCOOP1_BACKLIGHT_ON, enable);
+ SCOOP1_BACKLIGHT_ON, on);
#endif
}
+
+void
+scoop_led_set(int led, int on)
+{
+
+ if (scoop_cd.cd_ndevs > 0 && scoop_cd.cd_devs[0] != NULL) {
+ switch(led) {
+ case SCOOP_LED_GREEN:
+ scoop_gpio_pin_write(scoop_cd.cd_devs[0],
+ C3000_SCOOP0_LED_GREEN, on);
+ break;
+ case SCOOP_LED_ORANGE:
+ scoop_gpio_pin_write(scoop_cd.cd_devs[0],
+ C3000_SCOOP0_LED_ORANGE, on);
+ break;
+ }
+ }
+}
diff --git a/sys/arch/zaurus/dev/zaurus_scoopreg.h b/sys/arch/zaurus/dev/zaurus_scoopreg.h
index e0f68355572..67abaf93e67 100644
--- a/sys/arch/zaurus/dev/zaurus_scoopreg.h
+++ b/sys/arch/zaurus/dev/zaurus_scoopreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: zaurus_scoopreg.h,v 1.2 2005/01/19 15:56:44 uwe Exp $ */
+/* $OpenBSD: zaurus_scoopreg.h,v 1.3 2005/01/20 23:34:36 uwe Exp $ */
/*
* Copyright (c) 2005 Uwe Stuehler <uwe@bsdx.de>
@@ -16,6 +16,8 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#define SCOOP0_BASE 0x10800000
+#define SCOOP1_BASE 0x14800000
#define SCOOP_SIZE 0x2c
#define SCOOP_MCR 0x00
@@ -30,3 +32,8 @@
#define SCOOP_GPCR 0x20
#define SCOOP_GPWR 0x24
#define SCOOP_GPRR 0x28
+
+/* GPIO bit assignments for the Zaurus C3000. */
+#define C3000_SCOOP0_LED_GREEN 1
+#define C3000_SCOOP0_LED_ORANGE 7
+#define C3000_SCOOP1_BACKLIGHT_ON 8
diff --git a/sys/arch/zaurus/dev/zaurus_scoopvar.h b/sys/arch/zaurus/dev/zaurus_scoopvar.h
index 35354561dc8..497680e49f4 100644
--- a/sys/arch/zaurus/dev/zaurus_scoopvar.h
+++ b/sys/arch/zaurus/dev/zaurus_scoopvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: zaurus_scoopvar.h,v 1.2 2005/01/19 15:56:44 uwe Exp $ */
+/* $OpenBSD: zaurus_scoopvar.h,v 1.3 2005/01/20 23:34:37 uwe Exp $ */
/*
* Copyright (c) 2005 Uwe Stuehler <uwe@bsdx.de>
@@ -16,4 +16,8 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-void scoop_backlight_on(int);
+#define SCOOP_LED_GREEN 0
+#define SCOOP_LED_ORANGE 1
+
+void scoop_backlight_set(int);
+void scoop_led_set(int, int);
diff --git a/sys/arch/zaurus/zaurus/zaurus_apm.c b/sys/arch/zaurus/zaurus/zaurus_apm.c
new file mode 100644
index 00000000000..d4136a3b4a6
--- /dev/null
+++ b/sys/arch/zaurus/zaurus/zaurus_apm.c
@@ -0,0 +1,90 @@
+/* $OpenBSD: zaurus_apm.c,v 1.1 2005/01/20 23:34:37 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/param.h>
+#include <sys/conf.h>
+
+#include <arm/xscale/pxa2x0_apm.h>
+#include <arm/xscale/pxa2x0_gpio.h>
+
+#include <zaurus/dev/zaurus_scoopvar.h>
+
+int apm_match(struct device *, void *, void *);
+void apm_attach(struct device *, struct device *, void *);
+
+struct cfattach apm_pxaip_ca = {
+ sizeof (struct pxa2x0_apm_softc), apm_match, apm_attach
+};
+
+#define C3000_GPIO_AC_IN 115 /* active low */
+
+int zaurus_ac_present(void);
+void zaurus_battery_charge(int);
+void zaurus_battery_info(struct pxaapm_battery_info *);
+void zaurus_power_check(struct pxa2x0_apm_softc *);
+
+int
+apm_match(struct device *parent, void *match, void *aux)
+{
+ return 1;
+}
+
+void
+apm_attach(struct device *parent, struct device *self, void *aux)
+{
+ struct pxa2x0_apm_softc *sc = (struct pxa2x0_apm_softc *)self;
+
+ sc->sc_battery_info = zaurus_battery_info;
+ sc->sc_periodic_check = zaurus_power_check;
+
+ pxa2x0_apm_attach_sub(sc);
+}
+
+int
+zaurus_ac_present(void)
+{
+
+ return !pxa2x0_gpio_get_bit(C3000_GPIO_AC_IN);
+}
+
+void
+zaurus_battery_charge(int on)
+{
+
+ scoop_led_set(SCOOP_LED_ORANGE, on);
+}
+
+void
+zaurus_battery_info(struct pxaapm_battery_info *battp)
+{
+
+ if (zaurus_ac_present())
+ battp->flags |= PXAAPM_AC_PRESENT;
+ else
+ battp->flags &= ~PXAAPM_AC_PRESENT;
+}
+
+void
+zaurus_power_check(struct pxa2x0_apm_softc *sc)
+{
+
+ if (zaurus_ac_present())
+ zaurus_battery_charge(1);
+ else
+ zaurus_battery_charge(0);
+}