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 WS007SH.



details:   https://anonhg.NetBSD.org/src/rev/d240d0b83c5c
branches:  trunk
changeset: 754705:d240d0b83c5c
user:      nonaka <nonaka%NetBSD.org@localhost>
date:      Sun May 09 10:39:59 2010 +0000

description:
Added touchpad driver for WS007SH.

diffstat:

 sys/arch/hpcarm/conf/WZERO3                 |   11 +-
 sys/arch/hpcarm/conf/files.pxa2x0           |   12 +-
 sys/arch/hpcarm/dev/wzero3_reg.h            |    8 +-
 sys/arch/hpcarm/dev/wzero3_ssp.c            |  304 +++++++++++++++
 sys/arch/hpcarm/dev/wzero3_sspvar.h         |   38 +
 sys/arch/hpcarm/dev/wzero3_tp.c             |  549 ++++++++++++++++++++++++++++
 sys/arch/hpcarm/hpcarm/pxa2x0_hpc_machdep.c |   36 +-
 7 files changed, 945 insertions(+), 13 deletions(-)

diffs (truncated from 1076 to 300 lines):

diff -r ceb16a3be9bd -r d240d0b83c5c sys/arch/hpcarm/conf/WZERO3
--- a/sys/arch/hpcarm/conf/WZERO3       Sun May 09 05:44:43 2010 +0000
+++ b/sys/arch/hpcarm/conf/WZERO3       Sun May 09 10:39:59 2010 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: WZERO3,v 1.3 2010/05/09 02:03:35 nonaka Exp $
+#      $NetBSD: WZERO3,v 1.4 2010/05/09 10:39:59 nonaka Exp $
 #
 #      WZERO3 -- Sharp Windows Mobile 5 based PDA
 #
@@ -7,7 +7,7 @@
 
 #options       INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident                 "GENERIC-$Revision: 1.3 $"
+#ident                 "GENERIC-$Revision: 1.4 $"
 
 # estimated number of users
 maxusers       32
@@ -175,6 +175,13 @@
 lcd* at pxaip?
 wsdisplay* at lcd? console ?
 
+# for touchpad
+wzero3ssp0 at pxaip?
+
+# touchpad
+wzero3tp0 at pxaip?
+wsmouse* at wzero3tp? mux 0
+
 # Keyboard
 wzero3kbd0 at pxaip?
 hpckbd*        at wzero3kbd?
diff -r ceb16a3be9bd -r d240d0b83c5c sys/arch/hpcarm/conf/files.pxa2x0
--- a/sys/arch/hpcarm/conf/files.pxa2x0 Sun May 09 05:44:43 2010 +0000
+++ b/sys/arch/hpcarm/conf/files.pxa2x0 Sun May 09 10:39:59 2010 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.pxa2x0,v 1.1 2010/04/17 13:36:21 nonaka Exp $
+#      $NetBSD: files.pxa2x0,v 1.2 2010/05/09 10:39:59 nonaka Exp $
 #
 # PXA2x0 specific configuration info
 #
@@ -12,6 +12,11 @@
 # W-ZERO3 specific configuration info
 #
 
+# Dedicated SSP unit for touch screen
+device wzero3ssp
+attach wzero3ssp at pxaip
+file arch/hpcarm/dev/wzero3_ssp.c      wzero3ssp
+
 # LCD frame buffer
 attach lcd at pxaip with wzero3lcd
 file arch/hpcarm/dev/wzero3_lcd.c      wzero3lcd needs-flag
@@ -21,6 +26,11 @@
 attach wzero3kbd at pxaip
 file arch/hpcarm/dev/wzero3_kbd.c      wzero3kbd
 
+# touchpad
+device wzero3tp: wsmousedev, hpctpanel
+attach wzero3tp at pxaip
+file arch/hpcarm/dev/wzero3_tp.c       wzero3tp
+
 # MMC/SD controller
 attach pxamci at pxaip with wzero3mci
 file arch/hpcarm/dev/wzero3_mci.c      wzero3mci
diff -r ceb16a3be9bd -r d240d0b83c5c sys/arch/hpcarm/dev/wzero3_reg.h
--- a/sys/arch/hpcarm/dev/wzero3_reg.h  Sun May 09 05:44:43 2010 +0000
+++ b/sys/arch/hpcarm/dev/wzero3_reg.h  Sun May 09 10:39:59 2010 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: wzero3_reg.h,v 1.1 2010/04/17 13:36:21 nonaka Exp $    */
+/*     $NetBSD: wzero3_reg.h,v 1.2 2010/05/09 10:39:59 nonaka Exp $    */
 
 /*
- * Copyright (c) 2008, 2009 NONAKA Kimihiro <nonaka%netbsd.org@localhost>
+ * Copyright (c) 2008, 2009, 2010 NONAKA Kimihiro <nonaka%netbsd.org@localhost>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -38,7 +38,7 @@
 #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 */
-//     DONT_TOUCH(RESET?)              89      /* 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 */
@@ -52,10 +52,12 @@
 #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_USB_CLIENT_DETECT  35      /* In */
 #define        GPIO_WS007SH_USB_HOST_POWER     37      /* Out */
 #define        GPIO_WS007SH_USB_HOST_DETECT    41      /* In */
 #define        GPIO_WS007SH_SD_DETECT          48      /* In */
+#define        GPIO_WS007SH_HSYNC              75      /* In */
 #define        GPIO_WS007SH_SLIDE              104     /* In */
 #define        GPIO_WS007SH_SD_POWER           107     /* Out: H:ON, L:OFF */
 
diff -r ceb16a3be9bd -r d240d0b83c5c sys/arch/hpcarm/dev/wzero3_ssp.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/hpcarm/dev/wzero3_ssp.c  Sun May 09 10:39:59 2010 +0000
@@ -0,0 +1,304 @@
+/*     $NetBSD: wzero3_ssp.c,v 1.1 2010/05/09 10:40:00 nonaka Exp $    */
+
+/*
+ * Copyright (c) 2010 NONAKA Kimihiro <nonaka%netbsd.org@localhost>
+ * 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 REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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: wzero3_ssp.c,v 1.1 2010/05/09 10:40:00 nonaka Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/mutex.h>
+#include <sys/pmf.h>
+#include <sys/bus.h>
+
+#include <machine/bootinfo.h>
+#include <machine/platid.h>
+#include <machine/platid_mask.h>
+
+#include <arm/xscale/pxa2x0reg.h>
+#include <arm/xscale/pxa2x0var.h>
+#include <arm/xscale/pxa2x0_gpio.h>
+
+#include <hpcarm/dev/wzero3_reg.h>
+#include <hpcarm/dev/wzero3_sspvar.h>
+
+#define WS007SH_SSCR0_ADS7846  0x06ab  /* 12bit/Microwire/div by 7 */
+
+struct wzero3ssp_softc {
+       device_t sc_dev;
+       bus_space_tag_t sc_iot;
+       bus_space_handle_t sc_ioh;
+       kmutex_t sc_mtx;
+};
+
+static int     wzero3ssp_match(device_t, cfdata_t, void *);
+static void    wzero3ssp_attach(device_t, device_t, void *);
+
+CFATTACH_DECL_NEW(wzero3ssp, sizeof(struct wzero3ssp_softc),
+       wzero3ssp_match, wzero3ssp_attach, NULL, NULL);
+
+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 struct wzero3ssp_softc *wzero3ssp_sc;
+
+static const struct wzero3ssp_model {
+       platid_mask_t *platid;
+} wzero3ssp_table[] = {
+#if 0
+       /* WS003SH */
+       {
+               &platid_mask_MACH_SHARP_WZERO3_WS003SH,
+       },
+       /* WS004SH */
+       {
+               &platid_mask_MACH_SHARP_WZERO3_WS004SH,
+       },
+#endif
+       /* WS007SH */
+       {
+               &platid_mask_MACH_SHARP_WZERO3_WS007SH,
+       },
+#if 0
+       /* WS011SH */
+       {
+               &platid_mask_MACH_SHARP_WZERO3_WS011SH,
+       },
+       /* WS0020H */
+       {
+               &platid_mask_MACH_SHARP_WZERO3_WS020SH,
+       },
+#endif
+       {
+               NULL,
+       },
+};
+
+static const struct wzero3ssp_model *
+wzero3ssp_lookup(void)
+{
+       const struct wzero3ssp_model *model;
+
+       for (model = wzero3ssp_table; model->platid != NULL; model++) {
+               if (platid_match(&platid, model->platid)) {
+                       return model;
+               }
+       }
+       return NULL;
+}
+
+static int
+wzero3ssp_match(device_t parent, cfdata_t cf, void *aux)
+{
+
+       if (strcmp(cf->cf_name, "wzero3ssp") != 0)
+               return 0;
+       if (wzero3ssp_lookup() == NULL)
+               return 0;
+       if (wzero3ssp_sc != NULL)
+               return 0;
+       return 1;
+}
+
+static void
+wzero3ssp_attach(device_t parent, device_t self, void *aux)
+{
+       struct wzero3ssp_softc *sc = device_private(self);
+
+       sc->sc_dev = self;
+       wzero3ssp_sc = sc;
+
+       aprint_normal("\n");
+       aprint_naive("\n");
+
+       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,
+            &sc->sc_ioh)) {
+               aprint_error_dev(sc->sc_dev, "can't map bus space\n");
+               return;
+       }
+
+       if (!pmf_device_register(sc->sc_dev, NULL, wzero3ssp_resume))
+               aprint_error_dev(sc->sc_dev,
+                   "couldn't establish power handler\n");
+
+       wzero3ssp_init(sc);
+}
+
+/*
+ * Initialize the dedicated SSP unit and disable all chip selects.
+ * This function is called with interrupts disabled.
+ */
+static void
+wzero3ssp_init(struct wzero3ssp_softc *sc)
+{
+
+       pxa2x0_clkman_config(CKEN_SSP, 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);
+}
+
+static bool
+wzero3ssp_resume(device_t dv, const pmf_qual_t *qual)
+{
+       struct wzero3ssp_softc *sc = device_private(dv);
+
+       mutex_enter(&sc->sc_mtx);
+       wzero3ssp_init(sc);
+       mutex_exit(&sc->sc_mtx);
+
+       return true;
+}
+
+/*
+ * Transmit a single data word to one of the ICs, keep the chip selected
+ * afterwards, and don't wait for data to be returned in SSDR.  Interrupts
+ * must be held off until wzero3ssp_ic_stop() gets called.
+ */
+void
+wzero3ssp_ic_start(int ic, uint32_t cmd)
+{
+       struct wzero3ssp_softc *sc;
+
+       KASSERT(wzero3ssp_sc != NULL);
+       sc = wzero3ssp_sc;
+



Home | Main Index | Thread Index | Old Index