Module Name: src
Committed By: tsutsui
Date: Wed Jan 25 16:51:17 UTC 2012
Modified Files:
src/sys/arch/zaurus/conf: GENERIC INSTALL files.zaurus
src/sys/arch/zaurus/dev: zkbd.c zlcd.c zlcdvar.h zssp.c zsspvar.h ztp.c
src/sys/arch/zaurus/zaurus: machdep.c
Added Files:
src/sys/arch/zaurus/dev: lcdctl.c lcdctlvar.h
Log Message:
Reorganlization zlcd(4) and ztp(4) device attachments from nonaka@:
- ztp depends on zssp so attach ztp at zssp rather than pxaip
- split LCD backlight controls from zlcd(4) into new lcdctl device
to share it among forthcoming SL-C7x0 variants
To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/zaurus/conf/GENERIC
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/zaurus/conf/INSTALL
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/zaurus/conf/files.zaurus
cvs rdiff -u -r0 -r1.1 src/sys/arch/zaurus/dev/lcdctl.c \
src/sys/arch/zaurus/dev/lcdctlvar.h
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/zaurus/dev/zkbd.c
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/zaurus/dev/zlcd.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/zaurus/dev/zlcdvar.h
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/zaurus/dev/zssp.c \
src/sys/arch/zaurus/dev/ztp.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/zaurus/dev/zsspvar.h
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/zaurus/zaurus/machdep.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/zaurus/conf/GENERIC
diff -u src/sys/arch/zaurus/conf/GENERIC:1.48 src/sys/arch/zaurus/conf/GENERIC:1.49
--- src/sys/arch/zaurus/conf/GENERIC:1.48 Sun Dec 18 05:49:33 2011
+++ src/sys/arch/zaurus/conf/GENERIC Wed Jan 25 16:51:17 2012
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.48 2011/12/18 05:49:33 dholland Exp $
+# $NetBSD: GENERIC,v 1.49 2012/01/25 16:51:17 tsutsui Exp $
#
# GENERIC machine description file
#
@@ -209,7 +209,7 @@ ioexp0 at iic? addr 0x18
zssp0 at pxaip?
# touchpad
-ztp0 at pxaip?
+ztp0 at zssp?
wsmouse* at ztp? mux 0
# keyboard
@@ -224,6 +224,7 @@ wskbd* at zrc? mux 1
lcd0 at pxaip?
options PXA2X0_LCD_WRITETHROUGH
wsdisplay* at lcd? console ?
+lcdctl0 at zssp0
# WM8750 Audio
zaudio0 at iic? addr 0x1b
Index: src/sys/arch/zaurus/conf/INSTALL
diff -u src/sys/arch/zaurus/conf/INSTALL:1.11 src/sys/arch/zaurus/conf/INSTALL:1.12
--- src/sys/arch/zaurus/conf/INSTALL:1.11 Sat Nov 19 17:17:41 2011
+++ src/sys/arch/zaurus/conf/INSTALL Wed Jan 25 16:51:17 2012
@@ -1,4 +1,4 @@
-# $NetBSD: INSTALL,v 1.11 2011/11/19 17:17:41 nonaka Exp $
+# $NetBSD: INSTALL,v 1.12 2012/01/25 16:51:17 tsutsui Exp $
#
# INSTALL config file (GENERIC with memory disk root)
#
@@ -49,7 +49,7 @@ no options SYMTAB_SPACE
no zrc0 at pxaip?
-no ztp0 at pxaip?
+no ztp0 at zssp?
no wsmouse* at ztp?
no zaudio0 at iic?
Index: src/sys/arch/zaurus/conf/files.zaurus
diff -u src/sys/arch/zaurus/conf/files.zaurus:1.9 src/sys/arch/zaurus/conf/files.zaurus:1.10
--- src/sys/arch/zaurus/conf/files.zaurus:1.9 Sun Jun 19 16:20:09 2011
+++ src/sys/arch/zaurus/conf/files.zaurus Wed Jan 25 16:51:17 2012
@@ -1,4 +1,4 @@
-# $NetBSD: files.zaurus,v 1.9 2011/06/19 16:20:09 nonaka Exp $
+# $NetBSD: files.zaurus,v 1.10 2012/01/25 16:51:17 tsutsui Exp $
#
# Sharp Zaurus specific configuration info
#
@@ -67,7 +67,7 @@ attach ioexp at iic
file arch/zaurus/dev/ioexp.c ioexp needs-flag
# Dedicated SSP unit for ADC, touch screen, and backlight
-device zssp
+device zssp {}
attach zssp at pxaip
file arch/zaurus/dev/zssp.c zssp
@@ -75,6 +75,11 @@ file arch/zaurus/dev/zssp.c zssp
attach lcd at pxaip with zlcd
file arch/zaurus/dev/zlcd.c zlcd
+# backlight, brightness Controller
+device lcdctl
+attach lcdctl at zssp
+file arch/zaurus/dev/lcdctl.c lcdctl needs-flag
+
# GPIO keyboard
device zkbd: wskbddev
attach zkbd at pxaip
@@ -82,7 +87,7 @@ file arch/zaurus/dev/zkbd.c zkbd
# Zaurus touchpad
device ztp: wsmousedev, hpctpanel
-attach ztp at pxaip
+attach ztp at zssp
file arch/zaurus/dev/ztp.c ztp
# WM8750 audio
Index: src/sys/arch/zaurus/dev/zkbd.c
diff -u src/sys/arch/zaurus/dev/zkbd.c:1.14 src/sys/arch/zaurus/dev/zkbd.c:1.15
--- src/sys/arch/zaurus/dev/zkbd.c:1.14 Tue Jun 21 18:13:19 2011
+++ src/sys/arch/zaurus/dev/zkbd.c Wed Jan 25 16:51:17 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: zkbd.c,v 1.14 2011/06/21 18:13:19 nonaka Exp $ */
+/* $NetBSD: zkbd.c,v 1.15 2012/01/25 16:51:17 tsutsui Exp $ */
/* $OpenBSD: zaurus_kbd.c,v 1.28 2005/12/21 20:36:03 deraadt Exp $ */
/*
@@ -18,12 +18,13 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: zkbd.c,v 1.14 2011/06/21 18:13:19 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zkbd.c,v 1.15 2012/01/25 16:51:17 tsutsui Exp $");
#include "opt_wsdisplay_compat.h"
#if 0 /* XXX */
#include "apm.h"
#endif
+#include "lcdctl.h"
#include <sys/param.h>
#include <sys/systm.h>
@@ -44,7 +45,9 @@ __KERNEL_RCSID(0, "$NetBSD: zkbd.c,v 1.1
#include <zaurus/zaurus/zaurus_var.h>
#include <zaurus/dev/zkbdmap.h>
-#include <zaurus/dev/zlcdvar.h>
+#if NLCDCTL > 0
+#include <zaurus/dev/lcdctlvar.h>
+#endif
static const int gpio_sense_pins_c3000[] = {
12,
@@ -513,9 +516,13 @@ zkbd_hinge(void *v)
if (lid_suspend)
apm_suspends++;
#endif
- lcd_blank(1);
+#if NLCDCTL > 0
+ lcdctl_blank(true);
+#endif
} else {
- lcd_blank(0);
+#if NLCDCTL > 0
+ lcdctl_blank(false);
+#endif
}
return 1;
Index: src/sys/arch/zaurus/dev/zlcd.c
diff -u src/sys/arch/zaurus/dev/zlcd.c:1.15 src/sys/arch/zaurus/dev/zlcd.c:1.16
--- src/sys/arch/zaurus/dev/zlcd.c:1.15 Tue Jul 19 15:11:49 2011
+++ src/sys/arch/zaurus/dev/zlcd.c Wed Jan 25 16:51:17 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: zlcd.c,v 1.15 2011/07/19 15:11:49 dyoung Exp $ */
+/* $NetBSD: zlcd.c,v 1.16 2012/01/25 16:51:17 tsutsui Exp $ */
/* $OpenBSD: zaurus_lcd.c,v 1.20 2006/06/02 20:50:14 miod Exp $ */
/* NetBSD: lubbock_lcd.c,v 1.1 2003/08/09 19:38:53 bsh Exp */
@@ -43,31 +43,28 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: zlcd.c,v 1.15 2011/07/19 15:11:49 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zlcd.c,v 1.16 2012/01/25 16:51:17 tsutsui Exp $");
+
+#include "lcdctl.h"
#include <sys/param.h>
#include <sys/systm.h>
-#include <sys/conf.h>
-#include <sys/uio.h>
-#include <sys/malloc.h>
-#include <sys/bus.h>
+#include <sys/device.h>
#include <dev/cons.h>
#include <dev/wscons/wsconsio.h>
#include <dev/wscons/wsdisplayvar.h>
-#include <dev/wscons/wscons_callbacks.h>
#include <dev/hpc/hpcfbio.h>
#include <arm/xscale/pxa2x0var.h>
-#include <arm/xscale/pxa2x0reg.h>
#include <arm/xscale/pxa2x0_lcd.h>
#include <zaurus/zaurus/zaurus_var.h>
#include <zaurus/dev/zlcdvar.h>
-#include <zaurus/dev/zsspvar.h>
-#include <zaurus/dev/scoopvar.h>
-#include <zaurus/dev/ioexpvar.h>
+#if NLCDCTL > 0
+#include <zaurus/dev/lcdctlvar.h>
+#endif
/*
* wsdisplay glue
@@ -94,8 +91,6 @@ static const struct wsscreen_list lcd_sc
};
static int lcd_ioctl(void *, void *, u_long, void *, int, struct lwp *);
-static int lcd_param(struct pxa2x0_lcd_softc *, u_long,
- struct wsdisplay_param *);
static int lcd_show_screen(void *, void *, int,
void (*)(void *, int, int), void *);
@@ -110,9 +105,7 @@ struct wsdisplay_accessops lcd_accessops
NULL,
};
-#define CURRENT_DISPLAY &sharp_zaurus_C3000
-
-const struct lcd_panel_geometry sharp_zaurus_C3000 =
+const struct lcd_panel_geometry lcd_panel_geometry_c3000 =
{
480, /* Width */
640, /* Height */
@@ -131,25 +124,6 @@ const struct lcd_panel_geometry sharp_za
0, /* EFW */
};
-struct sharp_lcd_backlight {
- int duty; /* LZ9JG18 DAC value */
- int cont; /* BACKLIGHT_CONT signal */
- int on; /* BACKLIGHT_ON signal */
-};
-
-#define CURRENT_BACKLIGHT sharp_zaurus_C3000_bl
-
-const struct sharp_lcd_backlight sharp_zaurus_C3000_bl[] = {
- { 0x00, 0, 0 }, /* 0: Off */
- { 0x00, 0, 1 }, /* 1: 0% */
- { 0x01, 0, 1 }, /* 2: 20% */
- { 0x07, 0, 1 }, /* 3: 40% */
- { 0x01, 1, 1 }, /* 4: 60% */
- { 0x07, 1, 1 }, /* 5: 80% */
- { 0x11, 1, 1 }, /* 6: 100% */
- { -1, -1, -1 }, /* 7: Invalid */
-};
-
static int lcd_match(device_t, cfdata_t, void *);
static void lcd_attach(device_t, device_t, void *);
@@ -158,17 +132,6 @@ CFATTACH_DECL_NEW(zlcd, sizeof(struct px
static bool lcd_suspend(device_t, const pmf_qual_t *);
static bool lcd_resume(device_t, const pmf_qual_t *);
-static void lcd_brightness_up(device_t);
-static void lcd_brightness_down(device_t);
-static void lcd_display_on(device_t);
-static void lcd_display_off(device_t);
-
-static int lcd_max_brightness(void);
-static int lcd_get_brightness(void);
-static void lcd_set_brightness(int);
-static void lcd_set_brightness_internal(int);
-static int lcd_get_backlight(void);
-static void lcd_set_backlight(int);
static int
lcd_match(device_t parent, cfdata_t cf, void *aux)
@@ -187,7 +150,7 @@ lcd_attach(device_t parent, device_t sel
sc->dev = self;
- pxa2x0_lcd_attach_sub(sc, aux, CURRENT_DISPLAY);
+ pxa2x0_lcd_attach_sub(sc, aux, &lcd_panel_geometry_c3000);
aa.console = glass_console;
aa.scrdata = &lcd_screen_list;
@@ -196,30 +159,15 @@ lcd_attach(device_t parent, device_t sel
(void) config_found(self, &aa, wsemuldisplaydevprint);
- /* Start with approximately 40% of full brightness. */
- lcd_set_brightness(3);
-
if (!pmf_device_register(self, lcd_suspend, lcd_resume))
aprint_error_dev(self, "couldn't establish power handler\n");
- if (!pmf_event_register(self, PMFE_DISPLAY_BRIGHTNESS_UP,
- lcd_brightness_up, true))
- aprint_error_dev(self, "couldn't register event handler\n");
- if (!pmf_event_register(self, PMFE_DISPLAY_BRIGHTNESS_DOWN,
- lcd_brightness_down, true))
- aprint_error_dev(self, "couldn't register event handler\n");
- if (!pmf_event_register(self, PMFE_DISPLAY_ON,
- lcd_display_on, true))
- aprint_error_dev(self, "couldn't register event handler\n");
- if (!pmf_event_register(self, PMFE_DISPLAY_OFF,
- lcd_display_off, true))
- aprint_error_dev(self, "couldn't register event handler\n");
}
void
lcd_cnattach(void)
{
- pxa2x0_lcd_cnattach(&lcd_std_screen, CURRENT_DISPLAY);
+ pxa2x0_lcd_cnattach(&lcd_std_screen, &lcd_panel_geometry_c3000);
}
/*
@@ -230,7 +178,9 @@ lcd_suspend(device_t dv, const pmf_qual_
{
struct pxa2x0_lcd_softc *sc = device_private(dv);
- lcd_set_brightness(0);
+#if NLCDCTL > 0
+ lcdctl_onoff(false);
+#endif
pxa2x0_lcd_suspend(sc);
return true;
@@ -242,41 +192,13 @@ lcd_resume(device_t dv, const pmf_qual_t
struct pxa2x0_lcd_softc *sc = device_private(dv);
pxa2x0_lcd_resume(sc);
- lcd_set_brightness(lcd_get_brightness());
+#if NLCDCTL > 0
+ lcdctl_onoff(true);
+#endif
return true;
}
-static void
-lcd_brightness_up(device_t dv)
-{
-
- lcd_set_brightness(lcd_get_brightness() + 1);
-}
-
-static void
-lcd_brightness_down(device_t dv)
-{
-
- lcd_set_brightness(lcd_get_brightness() - 1);
-}
-
-static void
-lcd_display_on(device_t dv)
-{
-
- lcd_blank(0);
- lcd_set_backlight(1);
-}
-
-static void
-lcd_display_off(device_t dv)
-{
-
- lcd_set_backlight(0);
- lcd_blank(1);
-}
-
/*
* wsdisplay accessops overrides
*/
@@ -289,10 +211,12 @@ lcd_ioctl(void *v, void *vs, u_long cmd,
int res = EINVAL;
switch (cmd) {
+#if NLCDCTL > 0
case WSDISPLAYIO_GETPARAM:
case WSDISPLAYIO_SETPARAM:
- res = lcd_param(sc, cmd, (struct wsdisplay_param *)data);
+ res = lcdctl_param(cmd, (struct wsdisplay_param *)data);
break;
+#endif
case HPCFBIO_GCONF:
fbconf = (struct hpcfb_fbconf *)data;
@@ -417,163 +341,10 @@ lcd_show_screen(void *v, void *cookie, i
if (error)
return (error);
+#if NLCDCTL > 0
/* Turn on LCD */
- lcd_set_brightness(lcd_get_brightness());
+ lcdctl_onoff(true);
+#endif
return 0;
}
-
-/*
- * wsdisplay I/O controls
- */
-static int
-lcd_param(struct pxa2x0_lcd_softc *sc, u_long cmd, struct wsdisplay_param *dp)
-{
- int res = EINVAL;
-
- switch (dp->param) {
- case WSDISPLAYIO_PARAM_BACKLIGHT:
- if (cmd == WSDISPLAYIO_GETPARAM) {
- dp->min = 0;
- dp->max = 1;
- dp->curval = lcd_get_backlight();
- res = 0;
- } else if (cmd == WSDISPLAYIO_SETPARAM) {
- lcd_set_backlight(dp->curval);
- res = 0;
- }
- break;
-
- case WSDISPLAYIO_PARAM_CONTRAST:
- /* unsupported */
- res = ENOTTY;
- break;
-
- case WSDISPLAYIO_PARAM_BRIGHTNESS:
- if (cmd == WSDISPLAYIO_GETPARAM) {
- dp->min = 1;
- dp->max = lcd_max_brightness();
- dp->curval = lcd_get_brightness();
- res = 0;
- } else if (cmd == WSDISPLAYIO_SETPARAM) {
- lcd_set_brightness(dp->curval);
- res = 0;
- }
- break;
- }
-
- return res;
-}
-
-/*
- * LCD backlight
- */
-
-static int lcdbrightnesscurval = 1;
-static int lcdislit = 1;
-static int lcdisblank = 0;
-
-static int
-lcd_max_brightness(void)
-{
- int i;
-
- for (i = 0; CURRENT_BACKLIGHT[i].duty != -1; i++)
- continue;
- return i - 1;
-}
-
-static int
-lcd_get_brightness(void)
-{
-
- return lcdbrightnesscurval;
-}
-
-static void
-lcd_set_brightness(int newval)
-{
- int maxval;
-
- maxval = lcd_max_brightness();
- if (newval < 0)
- newval = 0;
- else if (newval > maxval)
- newval = maxval;
-
- if (lcd_get_backlight() && !lcdisblank)
- lcd_set_brightness_internal(newval);
-
- if (newval > 0)
- lcdbrightnesscurval = newval;
-}
-
-static void
-lcd_set_brightness_internal(int newval)
-{
- static int curval = 1;
- int i;
-
- /*
- * It appears that the C3000 backlight can draw too much power if we
- * switch it from a low to a high brightness. Increasing brightness
- * in steps avoids this issue.
- */
- if (newval > curval) {
- for (i = curval + 1; i <= newval; i++) {
- (void)zssp_ic_send(ZSSP_IC_LZ9JG18,
- CURRENT_BACKLIGHT[i].duty);
- if (ZAURUS_ISC1000)
- ioexp_set_backlight(CURRENT_BACKLIGHT[i].on,
- CURRENT_BACKLIGHT[i].cont);
- else
- scoop_set_backlight(CURRENT_BACKLIGHT[i].on,
- CURRENT_BACKLIGHT[i].cont);
- delay(5000);
- }
- } else {
- (void)zssp_ic_send(ZSSP_IC_LZ9JG18,
- CURRENT_BACKLIGHT[newval].duty);
- if (ZAURUS_ISC1000)
- ioexp_set_backlight(CURRENT_BACKLIGHT[newval].on,
- CURRENT_BACKLIGHT[newval].cont);
- else
- scoop_set_backlight(CURRENT_BACKLIGHT[newval].on,
- CURRENT_BACKLIGHT[newval].cont);
- }
-
- curval = newval;
-}
-
-static int
-lcd_get_backlight(void)
-{
-
- return lcdislit;
-}
-
-static void
-lcd_set_backlight(int onoff)
-{
-
- if (!onoff) {
- lcd_set_brightness(0);
- lcdislit = 0;
- } else {
- lcdislit = 1;
- lcd_set_brightness(lcd_get_brightness());
- }
-}
-
-void
-lcd_blank(int blank)
-{
-
- if (blank) {
- lcd_set_brightness(0);
- lcdisblank = 1;
- } else {
- lcdisblank = 0;
- lcd_set_brightness(lcd_get_brightness());
- }
-}
Index: src/sys/arch/zaurus/dev/zlcdvar.h
diff -u src/sys/arch/zaurus/dev/zlcdvar.h:1.3 src/sys/arch/zaurus/dev/zlcdvar.h:1.4
--- src/sys/arch/zaurus/dev/zlcdvar.h:1.3 Tue Jun 21 18:13:19 2011
+++ src/sys/arch/zaurus/dev/zlcdvar.h Wed Jan 25 16:51:17 2012
@@ -1,7 +1,7 @@
-/* $NetBSD: zlcdvar.h,v 1.3 2011/06/21 18:13:19 nonaka Exp $ */
+/* $NetBSD: zlcdvar.h,v 1.4 2012/01/25 16:51:17 tsutsui Exp $ */
/*-
- * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * Copyright (c) 2011-2012 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -32,13 +32,6 @@
#ifndef _ZAURUS_DEV_ZLCDVAR_H_
#define _ZAURUS_DEV_ZLCDVAR_H_
-#include "lcd.h"
-
void lcd_cnattach(void);
-#if NLCD > 0
-void lcd_blank(int);
-#else
-#define lcd_blank(blank) do { } while (/*CONSTCOND*/0)
-#endif
#endif /* _ZAURUS_DEV_ZLCDVAR_H_ */
Index: src/sys/arch/zaurus/dev/zssp.c
diff -u src/sys/arch/zaurus/dev/zssp.c:1.11 src/sys/arch/zaurus/dev/zssp.c:1.12
--- src/sys/arch/zaurus/dev/zssp.c:1.11 Tue Jul 19 15:11:49 2011
+++ src/sys/arch/zaurus/dev/zssp.c Wed Jan 25 16:51:17 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: zssp.c,v 1.11 2011/07/19 15:11:49 dyoung Exp $ */
+/* $NetBSD: zssp.c,v 1.12 2012/01/25 16:51:17 tsutsui Exp $ */
/* $OpenBSD: zaurus_ssp.c,v 1.6 2005/04/08 21:58:49 uwe Exp $ */
/*
@@ -18,7 +18,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: zssp.c,v 1.11 2011/07/19 15:11:49 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zssp.c,v 1.12 2012/01/25 16:51:17 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -48,6 +48,8 @@ struct zssp_softc {
static int zssp_match(device_t, cfdata_t, void *);
static void zssp_attach(device_t, device_t, void *);
+static int zssp_search(device_t, cfdata_t, const int *, void *);
+static int zssp_print(void *, const char *);
CFATTACH_DECL_NEW(zssp, sizeof(struct zssp_softc),
zssp_match, zssp_attach, NULL, NULL);
@@ -89,6 +91,29 @@ zssp_attach(device_t parent, device_t se
"couldn't establish power handler\n");
zssp_init();
+
+ /* Attach all devices */
+ config_search_ia(zssp_search, self, "zssp", sc);
+}
+
+static int
+zssp_search(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
+{
+ struct zssp_attach_args aa;
+
+ aa.zaa_name = cf->cf_name;
+
+ if (config_match(parent, cf, &aa))
+ config_attach(parent, cf, &aa, zssp_print);
+
+ return 0;
+}
+
+static int
+zssp_print(void *aux, const char *name)
+{
+
+ return UNCONF;
}
/*
@@ -100,7 +125,10 @@ zssp_init(void)
{
struct zssp_softc *sc;
- KASSERT(zssp_sc != NULL);
+ if (__predict_false(zssp_sc == NULL)) {
+ aprint_error("%s: not configured.\n", __func__);
+ return;
+ }
sc = zssp_sc;
pxa2x0_clkman_config(CKEN_SSP, 1);
@@ -135,7 +163,10 @@ zssp_ic_start(int ic, uint32_t data)
{
struct zssp_softc *sc;
- KASSERT(zssp_sc != NULL);
+ if (__predict_false(zssp_sc == NULL)) {
+ aprint_error("%s: not configured.\n", __func__);
+ return;
+ }
sc = zssp_sc;
/* disable other ICs */
@@ -176,7 +207,10 @@ zssp_ic_stop(int ic)
struct zssp_softc *sc;
uint32_t rv;
- KASSERT(zssp_sc != NULL);
+ if (__predict_false(zssp_sc == NULL)) {
+ aprint_error("%s: not configured.\n", __func__);
+ return 0;
+ }
sc = zssp_sc;
switch (ic) {
@@ -233,7 +267,10 @@ zssp_read_max1111(uint32_t cmd)
int i;
int s;
- KASSERT(zssp_sc != NULL);
+ if (__predict_false(zssp_sc == NULL)) {
+ aprint_error("%s: not configured.\n", __func__);
+ return 0;
+ }
sc = zssp_sc;
s = splhigh();
@@ -286,8 +323,8 @@ zssp_read_ads7846(uint32_t cmd)
uint32_t val;
int s;
- if (zssp_sc == NULL) {
- printf("zssp_read_ads7846: not configured\n");
+ if (__predict_false(zssp_sc == NULL)) {
+ aprint_error("%s: not configured\n", __func__);
return 0;
}
sc = zssp_sc;
Index: src/sys/arch/zaurus/dev/ztp.c
diff -u src/sys/arch/zaurus/dev/ztp.c:1.11 src/sys/arch/zaurus/dev/ztp.c:1.12
--- src/sys/arch/zaurus/dev/ztp.c:1.11 Wed Jan 25 15:58:10 2012
+++ src/sys/arch/zaurus/dev/ztp.c Wed Jan 25 16:51:17 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: ztp.c,v 1.11 2012/01/25 15:58:10 tsutsui Exp $ */
+/* $NetBSD: ztp.c,v 1.12 2012/01/25 16:51:17 tsutsui Exp $ */
/* $OpenBSD: zts.c,v 1.9 2005/04/24 18:55:49 uwe Exp $ */
/*
@@ -18,7 +18,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ztp.c,v 1.11 2012/01/25 15:58:10 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ztp.c,v 1.12 2012/01/25 16:51:17 tsutsui Exp $");
#include "lcd.h"
@@ -41,11 +41,13 @@ __KERNEL_RCSID(0, "$NetBSD: ztp.c,v 1.11
#include <arm/xscale/pxa2x0reg.h>
#include <arm/xscale/pxa2x0var.h>
#include <arm/xscale/xscalereg.h>
-#include <arm/xscale/pxa2x0_lcd.h>
#include <arm/xscale/pxa2x0_gpio.h>
+#if NLCD > 0
+#include <arm/xscale/pxa2x0_lcd.h>
+#endif
+#include <zaurus/zaurus/zaurus_var.h>
#include <zaurus/dev/zsspvar.h>
-
#ifdef ZTP_DEBUG
#define DPRINTF(s) printf s
#else
@@ -70,9 +72,10 @@ __KERNEL_RCSID(0, "$NetBSD: ztp.c,v 1.11
#define CCNT_HS_400_VGA_C3K 6250 /* 15.024us */
-/* XXX need to ask zaurus_lcd.c for the screen dimension */
-#define CURRENT_DISPLAY (&sharp_zaurus_C3000)
-extern const struct lcd_panel_geometry sharp_zaurus_C3000;
+/* XXX need to ask lcd drivers for the screen dimension */
+#if NLCD > 0
+extern const struct lcd_panel_geometry lcd_panel_geometry_c3000;
+#endif
/* Settable via sysctl. */
int ztp_rawmode;
@@ -132,7 +135,10 @@ static const struct wsmouse_accessops zt
static int
ztp_match(device_t parent, cfdata_t cf, void *aux)
{
+ struct zssp_attach_args *aa = aux;
+ if (strcmp("ztp", aa->zaa_name))
+ return 0;
return 1;
}
@@ -157,8 +163,8 @@ ztp_attach(device_t parent, device_t sel
a.accesscookie = sc;
#if NLCD > 0
- sc->sc_resx = CURRENT_DISPLAY->panel_height;
- sc->sc_resy = CURRENT_DISPLAY->panel_width;
+ sc->sc_resx = lcd_panel_geometry_c3000.panel_height;
+ sc->sc_resy = lcd_panel_geometry_c3000.panel_width;
#else
sc->sc_resx = 480; /* XXX */
sc->sc_resy = 640; /* XXX */
Index: src/sys/arch/zaurus/dev/zsspvar.h
diff -u src/sys/arch/zaurus/dev/zsspvar.h:1.1 src/sys/arch/zaurus/dev/zsspvar.h:1.2
--- src/sys/arch/zaurus/dev/zsspvar.h:1.1 Sat Dec 16 05:24:13 2006
+++ src/sys/arch/zaurus/dev/zsspvar.h Wed Jan 25 16:51:17 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: zsspvar.h,v 1.1 2006/12/16 05:24:13 ober Exp $ */
+/* $NetBSD: zsspvar.h,v 1.2 2012/01/25 16:51:17 tsutsui Exp $ */
/* $OpenBSD: zaurus_sspvar.h,v 1.3 2005/04/08 21:58:49 uwe Exp $ */
/*
@@ -20,6 +20,10 @@
#ifndef _ZAURUS_DEV_ZSSPVAR_H_
#define _ZAURUS_DEV_ZSSPVAR_H_
+struct zssp_attach_args {
+ const char *zaa_name;
+};
+
#define ZSSP_IC_MAX1111 1 /* temperature/voltage ADC */
#define ZSSP_IC_LZ9JG18 2 /* LCD backlight controller */
#define ZSSP_IC_ADS7846 3 /* touch screen controller */
Index: src/sys/arch/zaurus/zaurus/machdep.c
diff -u src/sys/arch/zaurus/zaurus/machdep.c:1.28 src/sys/arch/zaurus/zaurus/machdep.c:1.29
--- src/sys/arch/zaurus/zaurus/machdep.c:1.28 Fri Jan 20 15:00:27 2012
+++ src/sys/arch/zaurus/zaurus/machdep.c Wed Jan 25 16:51:17 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.28 2012/01/20 15:00:27 nonaka Exp $ */
+/* $NetBSD: machdep.c,v 1.29 2012/01/25 16:51:17 tsutsui Exp $ */
/* $OpenBSD: zaurus_machdep.c,v 1.25 2006/06/20 18:24:04 todd Exp $ */
/*
@@ -107,7 +107,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.28 2012/01/20 15:00:27 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.29 2012/01/25 16:51:17 tsutsui Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@@ -1241,6 +1241,7 @@ parseopts(const char *opts, int *howto)
#include <dev/ic/comvar.h>
#endif
+#include "lcd.h"
#include "wsdisplay.h"
#ifndef CONSPEED
Added files:
Index: src/sys/arch/zaurus/dev/lcdctl.c
diff -u /dev/null src/sys/arch/zaurus/dev/lcdctl.c:1.1
--- /dev/null Wed Jan 25 16:51:17 2012
+++ src/sys/arch/zaurus/dev/lcdctl.c Wed Jan 25 16:51:17 2012
@@ -0,0 +1,341 @@
+/* $NetBSD: lcdctl.c,v 1.1 2012/01/25 16:51:17 tsutsui Exp $ */
+
+/*-
+ * Copyright (C) 2012 NONAKA Kimihiro <[email protected]>
+ * 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: lcdctl.c,v 1.1 2012/01/25 16:51:17 tsutsui Exp $");
+
+#include "ioexp.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/bus.h>
+
+#include <dev/wscons/wsconsio.h>
+#include <dev/wscons/wsdisplayvar.h>
+
+#include <zaurus/zaurus/zaurus_var.h>
+#include <zaurus/dev/lcdctlvar.h>
+#include <zaurus/dev/zsspvar.h>
+#include <zaurus/dev/scoopvar.h>
+#include <zaurus/dev/ioexpvar.h>
+
+struct lcdctl_backlight {
+ int duty; /* LZ9JG18 DAC value */
+ int cont; /* BACKLIGHT_CONT signal */
+ int on; /* BACKLIGHT_ON signal */
+};
+
+struct lcdctl_softc {
+ device_t sc_dev;
+
+ int sc_brightness;
+ int sc_brightnesscurval;
+ bool sc_islit;
+ bool sc_isblank;
+
+ int sc_nbacklighttbl;
+ const struct lcdctl_backlight *sc_backlighttbl;
+};
+
+/* for SL-C1000/SL-C3x00 */
+static const struct lcdctl_backlight lcdctl_backlight_c3000[] = {
+ { 0x00, 0, 0 }, /* 0: Off */
+ { 0x00, 0, 1 }, /* 1: 0% */
+ { 0x01, 0, 1 }, /* 2: 20% */
+ { 0x07, 0, 1 }, /* 3: 40% */
+ { 0x01, 1, 1 }, /* 4: 60% */
+ { 0x07, 1, 1 }, /* 5: 80% */
+ { 0x11, 1, 1 } /* 6: 100% */
+};
+
+static int lcdctl_match(device_t, cfdata_t, void *);
+static void lcdctl_attach(device_t, device_t, void *);
+
+CFATTACH_DECL_NEW(lcdctl, sizeof(struct lcdctl_softc),
+ lcdctl_match, lcdctl_attach, NULL, NULL);
+
+static int lcdctl_finalize(device_t);
+static void lcdctl_brightness_up(device_t);
+static void lcdctl_brightness_down(device_t);
+static void lcdctl_display_on(device_t);
+static void lcdctl_display_off(device_t);
+
+static void lcdctl_set_brightness(struct lcdctl_softc *, int);
+static void lcdctl_set_blank(struct lcdctl_softc *, bool);
+static void lcdctl_set_backlight(struct lcdctl_softc *, bool);
+
+static struct lcdctl_softc *lcdctl_sc;
+
+static int
+lcdctl_match(device_t parent, cfdata_t cf, void *aux)
+{
+ struct zssp_attach_args *aa = aux;
+
+ if (strcmp("lcdctl", aa->zaa_name))
+ return 0;
+
+ return 1;
+}
+
+static void
+lcdctl_attach(device_t parent, device_t self, void *aux)
+{
+ struct lcdctl_softc *sc = device_private(self);
+
+ sc->sc_dev = self;
+
+ aprint_normal("\n");
+ aprint_naive("\n");
+
+ sc->sc_brightness = sc->sc_brightnesscurval = 1;
+ sc->sc_islit = true;
+ sc->sc_isblank = false;
+
+ sc->sc_nbacklighttbl = __arraycount(lcdctl_backlight_c3000);
+ sc->sc_backlighttbl = lcdctl_backlight_c3000;
+
+ /* schedule adjustment of LCD brightness after all devices are ready */
+ config_finalize_register(self, lcdctl_finalize);
+
+ if (!pmf_event_register(self, PMFE_DISPLAY_BRIGHTNESS_UP,
+ lcdctl_brightness_up, true))
+ aprint_error_dev(self, "couldn't register event handler\n");
+ if (!pmf_event_register(self, PMFE_DISPLAY_BRIGHTNESS_DOWN,
+ lcdctl_brightness_down, true))
+ aprint_error_dev(self, "couldn't register event handler\n");
+ if (!pmf_event_register(self, PMFE_DISPLAY_ON,
+ lcdctl_display_on, true))
+ aprint_error_dev(self, "couldn't register event handler\n");
+ if (!pmf_event_register(self, PMFE_DISPLAY_OFF,
+ lcdctl_display_off, true))
+ aprint_error_dev(self, "couldn't register event handler\n");
+}
+
+static int
+lcdctl_finalize(device_t dv)
+{
+ struct lcdctl_softc *sc = device_private(dv);
+
+ /* Start with approximately 40% of full brightness. */
+ lcdctl_set_brightness(sc, 3);
+
+ lcdctl_sc = sc;
+
+ return 0;
+}
+
+static void
+lcdctl_brightness_up(device_t dv)
+{
+ struct lcdctl_softc *sc = device_private(dv);
+
+ lcdctl_set_brightness(sc, sc->sc_brightness + 1);
+}
+
+static void
+lcdctl_brightness_down(device_t dv)
+{
+ struct lcdctl_softc *sc = device_private(dv);
+
+ lcdctl_set_brightness(sc, sc->sc_brightness - 1);
+}
+
+static void
+lcdctl_display_on(device_t dv)
+{
+ struct lcdctl_softc *sc = device_private(dv);
+
+ lcdctl_set_blank(sc, false);
+ lcdctl_set_backlight(sc, true);
+}
+
+static void
+lcdctl_display_off(device_t dv)
+{
+ struct lcdctl_softc *sc = device_private(dv);
+
+ lcdctl_set_backlight(sc, false);
+ lcdctl_set_blank(sc, true);
+}
+
+static __inline void
+set_backlight(const struct lcdctl_backlight *bl)
+{
+
+ (void) zssp_ic_send(ZSSP_IC_LZ9JG18, bl->duty);
+ if (ZAURUS_ISC1000)
+ ioexp_set_backlight(bl->on, bl->cont);
+ else
+ scoop_set_backlight(bl->on, bl->cont);
+}
+
+static void
+lcdctl_set_brightness_internal(struct lcdctl_softc *sc, int newval)
+{
+ int i;
+
+ /*
+ * It appears that the C3000 backlight can draw too much power if we
+ * switch it from a low to a high brightness. Increasing brightness
+ * in steps avoids this issue.
+ */
+ if (newval > sc->sc_brightnesscurval) {
+ for (i = sc->sc_brightnesscurval + 1; i <= newval; i++) {
+ set_backlight(&sc->sc_backlighttbl[i]);
+ delay(5000);
+ }
+ } else
+ set_backlight(&sc->sc_backlighttbl[newval]);
+
+ sc->sc_brightnesscurval = newval;
+}
+
+static void
+lcdctl_set_brightness(struct lcdctl_softc *sc, int newval)
+{
+ int maxval = sc->sc_nbacklighttbl - 1;
+
+ if (newval < 0)
+ newval = 0;
+ else if (newval > maxval)
+ newval = maxval;
+
+ if (sc->sc_islit && !sc->sc_isblank)
+ lcdctl_set_brightness_internal(sc, newval);
+
+ if (newval > 0)
+ sc->sc_brightness = newval;
+}
+
+static void
+lcdctl_set_backlight(struct lcdctl_softc *sc, bool onoff)
+{
+
+ if (!onoff) {
+ lcdctl_set_brightness(sc, 0);
+ sc->sc_islit = false;
+ } else {
+ sc->sc_islit = true;
+ lcdctl_set_brightness(sc, sc->sc_brightness);
+ }
+}
+
+static void
+lcdctl_set_blank(struct lcdctl_softc *sc, bool isblank)
+{
+
+ if (isblank) {
+ lcdctl_set_brightness(sc, 0);
+ sc->sc_isblank = true;
+ } else {
+ sc->sc_isblank = false;
+ lcdctl_set_brightness(sc, sc->sc_brightness);
+ }
+}
+
+static void
+lcdctl_set_onoff(struct lcdctl_softc *sc, bool onoff)
+{
+
+ if (!onoff) {
+ lcdctl_set_brightness(sc, 0);
+ } else {
+ lcdctl_set_brightness(sc, sc->sc_brightness);
+ }
+}
+
+static int
+lcdctl_param_ioctl(struct lcdctl_softc *sc, u_long cmd, struct wsdisplay_param *dp)
+{
+ int rv = EINVAL;
+
+ switch (dp->param) {
+ case WSDISPLAYIO_PARAM_BACKLIGHT:
+ if (cmd == WSDISPLAYIO_GETPARAM) {
+ dp->min = 0;
+ dp->max = 1;
+ dp->curval = sc->sc_islit ? 1 : 0;
+ rv = 0;
+ } else if (cmd == WSDISPLAYIO_SETPARAM) {
+ lcdctl_set_backlight(sc, dp->curval != 0);
+ rv = 0;
+ }
+ break;
+
+ case WSDISPLAYIO_PARAM_CONTRAST:
+ /* unsupported */
+ rv = ENOTTY;
+ break;
+
+ case WSDISPLAYIO_PARAM_BRIGHTNESS:
+ if (cmd == WSDISPLAYIO_GETPARAM) {
+ dp->min = 1;
+ dp->max = sc->sc_nbacklighttbl - 1;
+ dp->curval = sc->sc_brightness;
+ rv = 0;
+ } else if (cmd == WSDISPLAYIO_SETPARAM) {
+ lcdctl_set_brightness(sc, dp->curval);
+ rv = 0;
+ }
+ break;
+ }
+ return rv;
+}
+
+void
+lcdctl_brightness(int newval)
+{
+
+ if (__predict_true(lcdctl_sc != NULL))
+ lcdctl_set_brightness(lcdctl_sc, newval);
+}
+
+void
+lcdctl_blank(bool isblank)
+{
+
+ if (__predict_true(lcdctl_sc != NULL))
+ lcdctl_set_blank(lcdctl_sc, isblank);
+}
+
+void
+lcdctl_onoff(bool onoff)
+{
+
+ if (__predict_true(lcdctl_sc != NULL))
+ lcdctl_set_onoff(lcdctl_sc, onoff);
+}
+
+int
+lcdctl_param(u_long cmd, struct wsdisplay_param *dp)
+{
+
+ if (__predict_true(lcdctl_sc != NULL))
+ return lcdctl_param_ioctl(lcdctl_sc, cmd, dp);
+ return ENOTTY; /* unsupported */
+}
Index: src/sys/arch/zaurus/dev/lcdctlvar.h
diff -u /dev/null src/sys/arch/zaurus/dev/lcdctlvar.h:1.1
--- /dev/null Wed Jan 25 16:51:17 2012
+++ src/sys/arch/zaurus/dev/lcdctlvar.h Wed Jan 25 16:51:17 2012
@@ -0,0 +1,36 @@
+/* $NetBSD: lcdctlvar.h,v 1.1 2012/01/25 16:51:17 tsutsui Exp $ */
+
+/*-
+ * Copyright (C) 2012 NONAKA Kimihiro <[email protected]>
+ * 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.
+ */
+
+#ifndef _ZAURUS_DEV_LCDCTLVAR_H_
+#define _ZAURUS_DEV_LCDCTLVAR_H_
+
+void lcdctl_brightness(int newval);
+void lcdctl_blank(bool isblank);
+void lcdctl_onoff(bool onoff);
+int lcdctl_param(u_long cmd, struct wsdisplay_param *dp);
+
+#endif /* _ZAURUS_DEV_LCDCTLVAR_H_ */