Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/hpcarm Added touchpad driver for WS003SH.
details: https://anonhg.NetBSD.org/src/rev/c297b912f1de
branches: trunk
changeset: 754813:c297b912f1de
user: nonaka <nonaka%NetBSD.org@localhost>
date: Thu May 13 21:01:59 2010 +0000
description:
Added touchpad driver for WS003SH.
diffstat:
sys/arch/hpcarm/dev/wzero3_reg.h | 15 +-
sys/arch/hpcarm/dev/wzero3_ssp.c | 139 +++++-
sys/arch/hpcarm/dev/wzero3_sspvar.h | 10 +-
sys/arch/hpcarm/dev/wzero3_tp.c | 562 +++++++++++++++++++--------
sys/arch/hpcarm/hpcarm/pxa2x0_hpc_machdep.c | 20 +-
5 files changed, 534 insertions(+), 212 deletions(-)
diffs (truncated from 1163 to 300 lines):
diff -r 93aa8ba27699 -r c297b912f1de sys/arch/hpcarm/dev/wzero3_reg.h
--- a/sys/arch/hpcarm/dev/wzero3_reg.h Thu May 13 20:30:01 2010 +0000
+++ b/sys/arch/hpcarm/dev/wzero3_reg.h Thu May 13 21:01:59 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wzero3_reg.h,v 1.2 2010/05/09 10:39:59 nonaka Exp $ */
+/* $NetBSD: wzero3_reg.h,v 1.3 2010/05/13 21:01:59 nonaka Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 NONAKA Kimihiro <nonaka%netbsd.org@localhost>
@@ -35,24 +35,31 @@
* WS003SH/WS004SH specific parameter
*/
#define GPIO_WS003SH_SD_DETECT 9 /* In */
+#define GPIO_WS003SH_TOUCH_PANEL 11 /* In */
#define GPIO_WS003SH_SLIDE 12 /* In */
#define GPIO_WS003SH_FULLKEY_LED 17 /* Out: H:ON, L:OFF */
#define GPIO_WS003SH_ANTENNA_LED 37 /* Out: H:ON, L:OFF */
+#define GPIO_WS003SH_MAX1233_CS 48 /* Out */
#define GPIO_WS003SH_RESET 89 /* Out */
#define GPIO_WS003SH_POWER_BUTTON 95 /* In */
#define GPIO_WS003SH_VIB 97 /* Out */
#define GPIO_WS003SH_USB_CLIENT_DETECT 103 /* In */
#define GPIO_WS003SH_SD_POWER 107 /* Out: H:ON, L:OFF */
-#define GPIO_WS003SH_LCD_POWER 114 /* Out: H:ON, L:OFF XXX */
+#define GPIO_WS003SH_CHARGE 114 /* Out: H:ON, L:OFF */
#define GPIO_WS003SH_AC_DETECT 115 /* In */
+/* WS003SH: GPIO OUT pin
+ * CLR: 10,16,18,19,20,21,23,33,40,56,87,90,91,104,119,120
+ * SET: 39,54,57
+ */
+
/*
* WS007SH specific parameter
*/
#define GPIO_WS007SH_RESET_BUTTON 1 /* In: L: press, H: release */
#define GPIO_WS007SH_POWER_BUTTON 9 /* In */
#define GPIO_WS007SH_TOUCH_PANEL 21 /* In */
-#define GPIO_WS007SH_ADS7846_CS 33 /* Out: SSP SFRM */
+#define GPIO_WS007SH_ADS7846_CS 33 /* Out */
#define GPIO_WS007SH_USB_CLIENT_DETECT 35 /* In */
#define GPIO_WS007SH_USB_HOST_POWER 37 /* Out */
#define GPIO_WS007SH_USB_HOST_DETECT 41 /* In */
@@ -86,12 +93,14 @@
*/
#define GPIO_WS011SH_RESET_BUTTON 1 /* In */
#define GPIO_WS011SH_POWER_BUTTON 9 /* In */
+#define GPIO_WS011SH_TENKEY 14 /* In */
#define GPIO_WS011SH_TOUCH_PANEL 21 /* In */
#define GPIO_WS011SH_USB_HOST_POWER 37 /* Out */
#define GPIO_WS011SH_USB_HOST_DETECT 41 /* In */
#define GPIO_WS011SH_SD_DETECT 48 /* In */
#define GPIO_WS011SH_SLIDE 51 /* In */
#define GPIO_WS011SH_KEY_LOCK 52 /* In */
+#define GPIO_WS011SH_HSYNC 75 /* In */
#define GPIO_WS011SH_SD_POWER 107 /* Out */
#define GPIO_WS011SH_USB_CLIENT_DETECT 116 /* In */
diff -r 93aa8ba27699 -r c297b912f1de sys/arch/hpcarm/dev/wzero3_ssp.c
--- a/sys/arch/hpcarm/dev/wzero3_ssp.c Thu May 13 20:30:01 2010 +0000
+++ b/sys/arch/hpcarm/dev/wzero3_ssp.c Thu May 13 21:01:59 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wzero3_ssp.c,v 1.1 2010/05/09 10:40:00 nonaka Exp $ */
+/* $NetBSD: wzero3_ssp.c,v 1.2 2010/05/13 21:01:59 nonaka Exp $ */
/*
* Copyright (c) 2010 NONAKA Kimihiro <nonaka%netbsd.org@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wzero3_ssp.c,v 1.1 2010/05/09 10:40:00 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wzero3_ssp.c,v 1.2 2010/05/13 21:01:59 nonaka Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -47,13 +47,18 @@
#include <hpcarm/dev/wzero3_reg.h>
#include <hpcarm/dev/wzero3_sspvar.h>
-#define WS007SH_SSCR0_ADS7846 0x06ab /* 12bit/Microwire/div by 7 */
+#define WS003SH_SSCR0_MAX1233 0x0000048f /* 16bit/SPI/div by 5 */
+#define WS007SH_SSCR0_ADS7846 0x000006ab /* 12bit/Microwire/div by 7 */
+#define WS011SH_SSCR0_TP 0x0010068f /* 32bit/SPI/div by 7 */
+#define WS011SH_SSCR0_TENKEY 0x0000068f /* 16bit/SPI/div by 7 */
+struct wzero3ssp_model;
struct wzero3ssp_softc {
device_t sc_dev;
bus_space_tag_t sc_iot;
bus_space_handle_t sc_ioh;
kmutex_t sc_mtx;
+ const struct wzero3ssp_model *sc_model;
};
static int wzero3ssp_match(device_t, cfdata_t, void *);
@@ -64,39 +69,45 @@
static void wzero3ssp_init(struct wzero3ssp_softc *);
static bool wzero3ssp_resume(device_t dv, const pmf_qual_t *);
-static uint32_t wzero3ssp_read_ads7846(uint32_t);
+static uint32_t wzero3ssp_read_ads7846(struct wzero3ssp_softc *, uint32_t);
+static uint32_t wzero3ssp_read_max1233(struct wzero3ssp_softc *, uint32_t,
+ uint32_t);
static struct wzero3ssp_softc *wzero3ssp_sc;
static const struct wzero3ssp_model {
platid_mask_t *platid;
+ u_long sspaddr;
} wzero3ssp_table[] = {
-#if 0
/* WS003SH */
{
&platid_mask_MACH_SHARP_WZERO3_WS003SH,
+ PXA2X0_SSP2_BASE,
},
/* WS004SH */
{
&platid_mask_MACH_SHARP_WZERO3_WS004SH,
+ PXA2X0_SSP2_BASE,
},
-#endif
/* WS007SH */
{
&platid_mask_MACH_SHARP_WZERO3_WS007SH,
+ PXA2X0_SSP1_BASE,
},
-#if 0
/* WS011SH */
{
&platid_mask_MACH_SHARP_WZERO3_WS011SH,
+ PXA2X0_SSP1_BASE,
},
+#if 0
/* WS0020H */
{
&platid_mask_MACH_SHARP_WZERO3_WS020SH,
+ PXA2X0_SSP1_BASE,
},
#endif
{
- NULL,
+ NULL, 0,
},
};
@@ -137,10 +148,16 @@
aprint_normal("\n");
aprint_naive("\n");
+ sc->sc_model = wzero3ssp_lookup();
+ if (sc->sc_model == NULL) {
+ aprint_error_dev(self, "unknown model\n");
+ return;
+ }
+
mutex_init(&sc->sc_mtx, MUTEX_DEFAULT, IPL_TTY);
sc->sc_iot = &pxa2x0_bs_tag;
- if (bus_space_map(sc->sc_iot, PXA2X0_SSP1_BASE, PXA2X0_SSP_SIZE, 0,
+ if (bus_space_map(sc->sc_iot, sc->sc_model->sspaddr, PXA2X0_SSP_SIZE, 0,
&sc->sc_ioh)) {
aprint_error_dev(sc->sc_dev, "can't map bus space\n");
return;
@@ -161,12 +178,26 @@
wzero3ssp_init(struct wzero3ssp_softc *sc)
{
- pxa2x0_clkman_config(CKEN_SSP, 1);
+ if (sc->sc_model->sspaddr == PXA2X0_SSP1_BASE)
+ pxa2x0_clkman_config(CKEN_SSP2, 1);
+ else if (sc->sc_model->sspaddr == PXA2X0_SSP2_BASE)
+ pxa2x0_clkman_config(CKEN_SSP3, 1);
bus_space_write_4(sc->sc_iot, sc->sc_ioh, SSP_SSCR0, 0);
bus_space_write_4(sc->sc_iot, sc->sc_ioh, SSP_SSCR1, 0);
- pxa2x0_gpio_set_function(GPIO_WS007SH_ADS7846_CS, GPIO_OUT|GPIO_SET);
+ /* XXX */
+ if (platid_match(&platid, &platid_mask_MACH_SHARP_WZERO3_WS003SH)
+ || platid_match(&platid, &platid_mask_MACH_SHARP_WZERO3_WS004SH)) {
+ pxa2x0_gpio_set_function(39/*GPIO_WS003SH_XXX*/,
+ GPIO_OUT|GPIO_SET);
+ pxa2x0_gpio_set_function(GPIO_WS003SH_MAX1233_CS,
+ GPIO_OUT|GPIO_SET);
+ }
+ if (platid_match(&platid, &platid_mask_MACH_SHARP_WZERO3_WS007SH)) {
+ pxa2x0_gpio_set_function(GPIO_WS007SH_ADS7846_CS,
+ GPIO_OUT|GPIO_SET);
+ }
}
static bool
@@ -213,6 +244,10 @@
& SSSR_TNF) != SSSR_TNF)
continue; /* poll */
break;
+ case WZERO3_SSP_IC_MAX1233:
+ case WZERO3_SSP_IC_NUM:
+ default:
+ break;
}
}
@@ -235,14 +270,15 @@
& SSSR_RNE) != SSSR_RNE)
continue; /* poll */
rv = bus_space_read_4(sc->sc_iot, sc->sc_ioh, SSP_SSDR);
+ pxa2x0_gpio_set_bit(GPIO_WS007SH_ADS7846_CS);
break;
+ case WZERO3_SSP_IC_MAX1233:
+ case WZERO3_SSP_IC_NUM:
default:
rv = 0;
break;
}
- pxa2x0_gpio_set_bit(GPIO_WS007SH_ADS7846_CS);
-
mutex_exit(&sc->sc_mtx);
return rv;
@@ -253,30 +289,33 @@
* each direction, and deactivate the chip-select again.
*/
uint32_t
-wzero3ssp_ic_send(int ic, uint32_t data)
+wzero3ssp_ic_send(int ic, uint32_t data, uint32_t data2)
{
+ struct wzero3ssp_softc *sc;
+
+ if (wzero3ssp_sc == NULL) {
+ aprint_error("%s: not configured\n", __func__);
+ return 0;
+ }
+ sc = wzero3ssp_sc;
switch (ic) {
case WZERO3_SSP_IC_ADS7846:
- return wzero3ssp_read_ads7846(data);
+ return wzero3ssp_read_ads7846(sc, data);
+ case WZERO3_SSP_IC_MAX1233:
+ return wzero3ssp_read_max1233(sc, data, data2);
+ case WZERO3_SSP_IC_NUM:
default:
- aprint_error("wzero3ssp: wzero3ssp_ic_send: invalid IC %d\n", ic);
+ aprint_error("%s: invalid IC %d\n", __func__, ic);
return 0;
}
}
static uint32_t
-wzero3ssp_read_ads7846(uint32_t cmd)
+wzero3ssp_read_ads7846(struct wzero3ssp_softc *sc, uint32_t cmd)
{
- struct wzero3ssp_softc *sc;
uint32_t rv;
- if (wzero3ssp_sc == NULL) {
- printf("wzero3ssp_read_ads7846: not configured\n");
- return 0;
- }
- sc = wzero3ssp_sc;
-
mutex_enter(&sc->sc_mtx);
bus_space_write_4(sc->sc_iot, sc->sc_ioh, SSP_SSCR0, 0);
@@ -286,13 +325,13 @@
pxa2x0_gpio_clear_bit(GPIO_WS007SH_ADS7846_CS);
/* send cmd */
- bus_space_write_4(sc->sc_iot, sc->sc_ioh, SSP_SSDR, cmd);
- while ((bus_space_read_4(sc->sc_iot, sc->sc_ioh, SSP_SSSR)
- & SSSR_TNF) != SSSR_TNF)
+ while (!(bus_space_read_4(sc->sc_iot, sc->sc_ioh, SSP_SSSR) & SSSR_TNF))
continue; /* poll */
- delay(1);
- while ((bus_space_read_4(sc->sc_iot, sc->sc_ioh, SSP_SSSR)
- & SSSR_RNE) != SSSR_RNE)
+ bus_space_write_4(sc->sc_iot, sc->sc_ioh, SSP_SSDR, cmd);
+ while (bus_space_read_4(sc->sc_iot, sc->sc_ioh, SSP_SSSR) & SSSR_BUSY)
+ continue; /* poll */
+
+ while (!(bus_space_read_4(sc->sc_iot, sc->sc_ioh, SSP_SSSR) & SSSR_RNE))
continue; /* poll */
rv = bus_space_read_4(sc->sc_iot, sc->sc_ioh, SSP_SSDR);
@@ -302,3 +341,43 @@
return rv;
}
+
+static uint32_t
+wzero3ssp_read_max1233(struct wzero3ssp_softc *sc, uint32_t cmd, uint32_t data)
+{
+ uint32_t rv;
+
+ mutex_enter(&sc->sc_mtx);
+
Home |
Main Index |
Thread Index |
Old Index