summaryrefslogtreecommitdiff
path: root/sys/arch/arm
diff options
context:
space:
mode:
authorUwe Stuehler <uwe@cvs.openbsd.org>2005-01-26 06:34:55 +0000
committerUwe Stuehler <uwe@cvs.openbsd.org>2005-01-26 06:34:55 +0000
commit8d5992f42a303bf7855b57d7aa3a24fba59ffeee (patch)
treecf9833405207add16097ea76404d2dc202411a68 /sys/arch/arm
parentbdcf45340fd9d4ef44a2ace40aae2f9d2a636631 (diff)
New device for the dedicated SSP unit, automatic battery charging, and
reporting the remaining battery life to apmd(8). ok drahn@
Diffstat (limited to 'sys/arch/arm')
-rw-r--r--sys/arch/arm/xscale/pxa2x0_apm.c57
-rw-r--r--sys/arch/arm/xscale/pxa2x0_apm.h16
-rw-r--r--sys/arch/arm/xscale/pxa2x0reg.h29
3 files changed, 40 insertions, 62 deletions
diff --git a/sys/arch/arm/xscale/pxa2x0_apm.c b/sys/arch/arm/xscale/pxa2x0_apm.c
index 4af0b9ee836..242cdf2ca0e 100644
--- a/sys/arch/arm/xscale/pxa2x0_apm.c
+++ b/sys/arch/arm/xscale/pxa2x0_apm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pxa2x0_apm.c,v 1.2 2005/01/20 23:34:36 uwe Exp $ */
+/* $OpenBSD: pxa2x0_apm.c,v 1.3 2005/01/26 06:34:53 uwe Exp $ */
/*-
* Copyright (c) 2001 Alexander Guy. All rights reserved.
@@ -77,8 +77,8 @@ int apm_userstandbys;
int apm_suspends;
int apm_battlow;
-void apm_battery_info(struct pxa2x0_apm_softc *,
- struct pxaapm_battery_info *);
+void apm_power_info(struct pxa2x0_apm_softc *,
+ struct apm_power_info *);
void apm_standby(struct pxa2x0_apm_softc *);
void apm_suspend(struct pxa2x0_apm_softc *);
void apm_resume(struct pxa2x0_apm_softc *);
@@ -115,13 +115,17 @@ struct filterops apmread_filtops =
#define SCFLAG_OPEN (SCFLAG_OREAD|SCFLAG_OWRITE)
void
-apm_battery_info(struct pxa2x0_apm_softc *sc,
- struct pxaapm_battery_info *battp)
+apm_power_info(struct pxa2x0_apm_softc *sc,
+ struct apm_power_info *power)
{
- bzero(battp, sizeof(struct pxaapm_battery_info));
- if (sc->sc_battery_info != NULL)
- sc->sc_battery_info(battp);
+ power->ac_state = APM_AC_UNKNOWN;
+ power->battery_state = APM_BATT_UNKNOWN;;
+ power->battery_life = 0 /* APM_BATT_LIFE_UNKNOWN */;
+ power->minutes_left = 0;
+
+ if (sc->sc_power_info != NULL)
+ sc->sc_power_info(sc, power);
}
void
@@ -272,7 +276,6 @@ int
apmioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
{
struct pxa2x0_apm_softc *sc;
- struct pxaapm_battery_info batt;
struct apm_power_info *power;
int error = 0;
@@ -325,41 +328,7 @@ apmioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
break;
case APM_IOC_GETPOWER:
power = (struct apm_power_info *)data;
-
- apm_battery_info(sc, &batt);
-
- power->ac_state = ((batt.flags & PXAAPM_AC_PRESENT) ?
- APM_AC_ON : APM_AC_OFF);
- power->battery_life =
- ((batt.cur_charge * 100) / batt.max_charge);
-
- /*
- * If the battery is charging, return the minutes left until
- * charging is complete. apmd knows this.
- */
-
- if (!(batt.flags & PXAAPM_BATT_PRESENT)) {
- power->battery_state = APM_BATT_UNKNOWN;
- power->minutes_left = 0;
- power->battery_life = 0;
- } else if ((power->ac_state == APM_AC_ON) &&
- (batt.draw > 0)) {
- power->minutes_left =
- (((batt.max_charge - batt.cur_charge) * 3600) /
- batt.draw) / 60;
- power->battery_state = APM_BATT_CHARGING;
- } else {
- power->minutes_left =
- ((batt.cur_charge * 3600) / (-batt.draw)) / 60;
-
- /* XXX - Arbitrary */
- if (power->battery_life > 60)
- power->battery_state = APM_BATT_HIGH;
- else if (power->battery_life < 10)
- power->battery_state = APM_BATT_CRITICAL;
- else
- power->battery_state = APM_BATT_LOW;
- }
+ apm_power_info(sc, power);
break;
default:
diff --git a/sys/arch/arm/xscale/pxa2x0_apm.h b/sys/arch/arm/xscale/pxa2x0_apm.h
index 719f0e0ddfa..9891822b118 100644
--- a/sys/arch/arm/xscale/pxa2x0_apm.h
+++ b/sys/arch/arm/xscale/pxa2x0_apm.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pxa2x0_apm.h,v 1.2 2005/01/20 23:34:36 uwe Exp $ */
+/* $OpenBSD: pxa2x0_apm.h,v 1.3 2005/01/26 06:34:53 uwe Exp $ */
/*
* Copyright (c) 2005 Uwe Stuehler <uwe@bsdx.de>
@@ -22,16 +22,7 @@
#include <sys/event.h>
#include <machine/bus.h>
-
-#define PXAAPM_AC_PRESENT (1<<0)
-#define PXAAPM_BATT_PRESENT (1<<1)
-
-struct pxaapm_battery_info {
- int flags;
- u_int cur_charge;
- u_int max_charge;
- int draw;
-};
+#include <machine/apmvar.h>
struct pxa2x0_apm_softc {
struct device sc_dev;
@@ -41,8 +32,9 @@ struct pxa2x0_apm_softc {
int sc_flags;
bus_space_tag_t sc_iot;
bus_space_handle_t sc_pm_ioh;
- void (*sc_battery_info)(struct pxaapm_battery_info *);
void (*sc_periodic_check)(struct pxa2x0_apm_softc *);
+ void (*sc_power_info)(struct pxa2x0_apm_softc *,
+ struct apm_power_info *);
};
extern void pxa2x0_apm_attach_sub(struct pxa2x0_apm_softc *);
diff --git a/sys/arch/arm/xscale/pxa2x0reg.h b/sys/arch/arm/xscale/pxa2x0reg.h
index c77eff0ecde..7db654ec524 100644
--- a/sys/arch/arm/xscale/pxa2x0reg.h
+++ b/sys/arch/arm/xscale/pxa2x0reg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pxa2x0reg.h,v 1.8 2005/01/12 17:14:37 uwe Exp $ */
+/* $OpenBSD: pxa2x0reg.h,v 1.9 2005/01/26 06:34:53 uwe Exp $ */
/* $NetBSD: pxa2x0reg.h,v 1.4 2003/06/11 20:43:01 scw Exp $ */
/*
@@ -108,7 +108,10 @@
#define PXA2X0_GPIO_SIZE 0x70
#define PXA2X0_POWMAN_BASE 0x40f00000 /* Power management */
#define PXA2X0_POWMAN_SIZE 0x100
-#define PXA2X0_SSP_BASE 0x41000000
+#define PXA2X0_SSP_BASE 0x41000000 /* SSP serial port */
+#define PXA2X0_SSP1_BASE 0x41700000 /* PXA270 */
+#define PXA2X0_SSP2_BASE 0x41900000 /* PXA270 */
+#define PXA2X0_SSP_SIZE 0x40
#define PXA2X0_MMC_BASE 0x41100000 /* MultiMediaCard */
#define PXA2X0_MMC_SIZE 0x48
#define PXA2X0_CLKMAN_BASE 0x41300000 /* Clock Manager */
@@ -218,14 +221,20 @@ struct pxa2x0_dma_desc {
#define I2C_ISAR 0x16a0 /* Slave address */
/* Power Manager */
-#define POWMAN_RCSR 0x30 /* Reset Controller Status Register */
-#define RCSR_GPR (1<<3)
-#define RCSR_SMR (1<<2)
-#define RCSR_WDR (1<<1)
+#define POWMAN_PSSR 0x04 /* Sleep Status register */
+#define PSSR_RDH (1<<5)
+#define POWMAN_PCFR 0x1c /* General Configuration register */
+#define PCFR_GRP_EN (1<<4) /* PXA270 */
+#define PCFR_GP_ROD (1<<8) /* PXA270 */
+#define POWMAN_RCSR 0x30 /* Reset Controller Status register */
#define RCSR_HWR (1<<0)
+#define RCSR_WDR (1<<1)
+#define RCSR_SMR (1<<2)
+#define RCSR_GPR (1<<3)
/* Clock Manager */
#define CLKMAN_CCCR 0x00 /* Core Clock Configuration */
+#define CCCR_CPDIS (1<<31) /* PXA270 */
#define CCCR_TURBO_X1 (2<<7)
#define CCCR_TURBO_X15 (3<<7) /* x 1.5 */
#define CCCR_TURBO_X2 (4<<7)
@@ -715,4 +724,12 @@ struct pxa2x0_dma_desc {
#define OST_OIER 0x001c /* Interrupt Enable */
#define OIER_E3 (1<<3)
+/* Synchronous Serial Protocol (SSP) serial ports */
+#define SSP_SSCR0 0x00
+#define SSP_SSCR1 0x04
+#define SSP_SSSR 0x08
+#define SSSR_TNF (1<<2)
+#define SSSR_RNE (1<<3)
+#define SSP_SSDR 0x10
+
#endif /* _ARM_XSCALE_PXA2X0REG_H_ */