Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Add optical joystick support for NetWalker.
details: https://anonhg.NetBSD.org/src/rev/d74d713cce4f
branches: trunk
changeset: 328194:d74d713cce4f
user: hkenken <hkenken%NetBSD.org@localhost>
date: Sat Mar 29 12:00:27 2014 +0000
description:
Add optical joystick support for NetWalker.
+ OJ6SH-T25 (Sharp "Optical TOUCH CRUISER" sensor)
+ 2 Mouse buttons (GPIO)
diffstat:
sys/arch/arm/imx/imxspi.c | 8 +-
sys/arch/evbarm/conf/NETWALKER | 63 +++-
sys/arch/evbarm/conf/files.netwalker | 24 +-
sys/arch/evbarm/netwalker/netwalker_btn.c | 325 ++++++++++++++++++++++
sys/arch/evbarm/netwalker/netwalker_machdep.c | 27 +-
sys/arch/evbarm/netwalker/netwalker_spi.c | 152 ++++++++++
sys/dev/spi/oj6sh.c | 379 ++++++++++++++++++++++++++
7 files changed, 952 insertions(+), 26 deletions(-)
diffs (truncated from 1129 to 300 lines):
diff -r bfc1bbb4472d -r d74d713cce4f sys/arch/arm/imx/imxspi.c
--- a/sys/arch/arm/imx/imxspi.c Sat Mar 29 11:34:13 2014 +0000
+++ b/sys/arch/arm/imx/imxspi.c Sat Mar 29 12:00:27 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: imxspi.c,v 1.1 2014/03/22 09:28:08 hkenken Exp $ */
+/* $NetBSD: imxspi.c,v 1.2 2014/03/29 12:00:27 hkenken Exp $ */
/*-
* Copyright (c) 2014 Genetec Corporation. All rights reserved.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: imxspi.c,v 1.1 2014/03/22 09:28:08 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imxspi.c,v 1.2 2014/03/29 12:00:27 hkenken Exp $");
#include "opt_imx.h"
#include "opt_imxspi.h"
@@ -391,7 +391,7 @@
/* RXFIFO ready */
if (sr & IMXSPI(INTR_RR_EN)) {
imxspi_recv(sc);
- if(sc->sc_wchunk == NULL &&sc->sc_rchunk == NULL)
+ if (sc->sc_wchunk == NULL && sc->sc_rchunk == NULL)
imxspi_done(sc, err);
}
@@ -408,7 +408,7 @@
int s;
/* make sure we select the right chip */
- s = splserial();
+ s = splbio();
spi_transq_enqueue(&sc->sc_q, st);
if (sc->sc_running == FALSE)
imxspi_sched(sc);
diff -r bfc1bbb4472d -r d74d713cce4f sys/arch/evbarm/conf/NETWALKER
--- a/sys/arch/evbarm/conf/NETWALKER Sat Mar 29 11:34:13 2014 +0000
+++ b/sys/arch/evbarm/conf/NETWALKER Sat Mar 29 12:00:27 2014 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: NETWALKER,v 1.24 2014/03/24 14:15:37 szptvlfn Exp $
+# $NetBSD: NETWALKER,v 1.25 2014/03/29 12:00:27 hkenken Exp $
#
# NETWALKER -- http://www.sharp.co.jp/netwalker/
#
@@ -128,7 +128,7 @@
# Development and Debugging options
#options PERFCTRS # performance counters
-options DIAGNOSTIC # internally consistency checks
+#options DIAGNOSTIC # internally consistency checks
#options DEBUG
#options KMEMSTATS # kernel memory statistics (vmstat -m)
options DDB # in-kernel debugger
@@ -151,6 +151,7 @@
# Kernel root file system and dump configuration.
config netbsd root on ? type ?
+config netbsd-ld0 root on ld0 type ffs
# The main bus device
mainbus0 at root
@@ -175,6 +176,7 @@
# Clock Control
imxccm0 at axi? addr 0x73fd4000
options IMX51_CKIL_FREQ=32768
+#options IMXCCMDEBUG
# Enhanced Periodic Interrupt Timer
imxclock0 at axi? addr 0x73fac000 size 0x4000 irq 40
@@ -183,11 +185,46 @@
# IOMUX
imxiomux0 at axi? addr 0x73fa8000
+# WatchDog
+imxwdog0 at axi? addr 0x73f98000 irq 58 flags 0
+
# GPIO
-imxgpio0 at axi? addr 0x73f84000
-imxgpio1 at axi? addr 0x73f88000
-imxgpio2 at axi? addr 0x73f8c000
-imxgpio3 at axi? addr 0x73f90000
+imxgpio0 at axi? addr 0x73f84000 irqbase 128 irq 50
+imxgpio1 at axi? addr 0x73f88000 irqbase 160 irq 52
+imxgpio2 at axi? addr 0x73f8c000 irqbase 192 irq 54
+imxgpio3 at axi? addr 0x73f90000 irqbase 224 irq 56
+gpio* at imxgpio?
+options IMX_GPIO_INTR_SPLIT
+
+# I2C
+#imxi2c0 at axi? addr 0x83fc8000 irq 62
+#imxi2c1 at axi? addr 0x83fc4000 irq 63
+
+# IIC
+#iic* at imxi2c?
+
+# SPI bus
+imxspi0 at axi? addr 0x70010000 irq 36 flags 1
+#imxspi1 at axi? addr 0x83fac000 irq 37 flags 1
+#imxspi2 at axi? addr 0x83fc0000 irq 38 flags 0
+spi0 at imxspi0 # eCSPI1
+#spi1 at imxspi1 # eCSPI2
+#spi2 at imxspi2 # CSPI1
+options IMXSPINSLAVES=3
+#options IMXSPI_DEBUG=10
+
+# Optical Joystick
+mousebtn0 at gpio1 offset 22 mask 0x03 # intr 182, 183
+#options MOUSEBTN_POLLING
+oj6sh0 at spi0 slave 2
+#options OJ6SH_DEBUG=4
+options OJ6SH_UP_X_LEFT_Y
+wsmouse* at oj6sh? mux 0
+wsmouse* at mousebtn? mux 0
+
+# SPI NOR-Flash
+#spiflash0 at spiflashbus?
+#m25p0 at spi0 slave 1
# SD/MMC
sdhc0 at axi? addr 0x70004000 irq 1 # eSDHC1
@@ -238,9 +275,9 @@
# disk/mass storage pseudo-devices
#pseudo-device md # memory disk device (ramdisk)
-#pseudo-device vnd # disk-like interface to files
+pseudo-device vnd # disk-like interface to files
#pseudo-device fss # file system snapshot device
-#pseudo-device putter # for puffs and pud
+pseudo-device putter # for puffs and pud
# network pseudo-devices
pseudo-device bpfilter # Berkeley packet filter
@@ -250,12 +287,20 @@
# miscellaneous pseudo-devices
pseudo-device pty # pseudo-terminals
+pseudo-device clockctl # NTP clockctl
pseudo-device ksyms # /dev/ksyms
-pseudo-device clockctl # NTP clockctl
+pseudo-device lockstat # lock profiling
# wscons pseudo-devices
pseudo-device wsmux # mouse & keyboard multiplexor
pseudo-device wsfont
+# data mover pseudo-devices
+#pseudo-device swdmover # software dmover(9) back-end
+#pseudo-device dmoverio # /dev/dmover dmover(9) interface
+
+# userland interface to drivers, including autoconf and properties retrieval
+pseudo-device drvctl
+
# local configuration
cinclude "arch/evbarm/conf/NETWALKER.local"
diff -r bfc1bbb4472d -r d74d713cce4f sys/arch/evbarm/conf/files.netwalker
--- a/sys/arch/evbarm/conf/files.netwalker Sat Mar 29 11:34:13 2014 +0000
+++ b/sys/arch/evbarm/conf/files.netwalker Sat Mar 29 12:00:27 2014 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: files.netwalker,v 1.4 2014/01/24 02:06:03 hkenken Exp $
+# $NetBSD: files.netwalker,v 1.5 2014/03/29 12:00:27 hkenken Exp $
#
-# Sharp Netwalker
+# Sharp Netwalker configuration info
#
file arch/arm/arm32/arm32_boot.c
@@ -23,3 +23,23 @@
attach ipu at axi with lcd_netwalker
file arch/evbarm/netwalker/netwalker_lcd.c lcd_netwalker
defflag opt_netwalker_lcd.h LCD_DEBUG
+
+# CSPI & eCSPI Controller
+attach imxspi at axi with spi_netwalker
+file arch/evbarm/netwalker/netwalker_spi.c spi_netwalker
+
+# Mouse button
+device mousebtn: wsmousedev
+attach mousebtn at gpio with btn_netwalker
+file arch/evbarm/netwalker/netwalker_btn.c btn_netwalker
+defflag opt_mousebtn.h MOUSEBTN_POLLING
+
+# OJ6SH-T25 Optical Joystick
+device oj6sh: wsmousedev
+attach oj6sh at spi
+file dev/spi/oj6sh.c oj6sh
+defflag opt_oj6sh.h OJ6SH_UP_Y_RIGHT_X
+ OJ6SH_DOWN_Y_LEFT_X
+ OJ6SH_UP_X_LEFT_Y
+ OJ6SH_DOWN_X_RIGHT_Y
+
diff -r bfc1bbb4472d -r d74d713cce4f sys/arch/evbarm/netwalker/netwalker_btn.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/evbarm/netwalker/netwalker_btn.c Sat Mar 29 12:00:27 2014 +0000
@@ -0,0 +1,325 @@
+/* $NetBSD: netwalker_btn.c,v 1.1 2014/03/29 12:00:27 hkenken Exp $ */
+
+/*
+ * Copyright (c) 2014 Genetec Corporation. All rights reserved.
+ * Written by Hashimoto Kenichi for Genetec Corporation.
+ *
+ * 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 GENETEC CORPORATION ``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 GENETEC CORPORATION
+ * 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: netwalker_btn.c,v 1.1 2014/03/29 12:00:27 hkenken Exp $");
+
+#include "opt_imxspi.h"
+#include "opt_mousebtn.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/device.h>
+#include <sys/lock.h>
+#include <sys/callout.h>
+#include <sys/gpio.h>
+#include <sys/bus.h>
+#include <sys/mutex.h>
+
+#include <dev/wscons/wsconsio.h>
+#include <dev/wscons/wsmousevar.h>
+
+#include <dev/gpio/gpiovar.h>
+
+#define GPIO1_BASE 160
+
+#define MOUSEBTN_PIN_LEFT 0
+#define MOUSEBTN_PIN_RIGHT 1
+#define MOUSEBTN_NPINS 2
+
+#define POLLRATE (hz/10)
+
+struct mousebtn_softc
+{
+ device_t sc_dev;
+ void *sc_gpio;
+ void *sc_intr[MOUSEBTN_NPINS];
+
+ struct gpio_pinmap sc_map;
+ int sc_map_pins[MOUSEBTN_NPINS];
+
+ int sc_buttons;
+
+ struct callout sc_c;
+ kmutex_t sc_lock;
+
+ int sc_enabled;
+ struct device *sc_wsmousedev;
+};
+
+static int mousebtn_match(device_t, cfdata_t, void *);
+static void mousebtn_attach(device_t, device_t, void *);
+static int mousebtn_detach(device_t, int);
+
+CFATTACH_DECL_NEW(btn_netwalker, sizeof(struct mousebtn_softc),
+ mousebtn_match, mousebtn_attach, mousebtn_detach, NULL);
+
+static void mousebtn_poll(void *);
+static int mousebtn_intr(void *);
+
+static int mousebtn_enable(void *v);
+static void mousebtn_disable(void *v);
+static int mousebtn_ioctl(void *, u_long, void *, int, struct lwp *);
+
+static bool mousebtn_resume(device_t, const pmf_qual_t *);
+static bool mousebtn_suspend(device_t, const pmf_qual_t *);
+
+static const struct wsmouse_accessops mousebtn_accessops = {
+ .enable = mousebtn_enable,
+ .ioctl = mousebtn_ioctl,
+ .disable = mousebtn_disable
+};
+
+static int
+mousebtn_match(device_t parent, cfdata_t cf, void * aux)
+{
+ struct gpio_attach_args *ga = aux;
+
+ if (strcmp(ga->ga_dvname, cf->cf_name))
+ return 0;
Home |
Main Index |
Thread Index |
Old Index