Module Name: src
Committed By: snj
Date: Thu Apr 16 07:01:39 UTC 2015
Modified Files:
src/distrib/sets/lists/man [netbsd-6]: mi
src/share/man/man4 [netbsd-6]: Makefile gpio.4
src/sys/arch/i386/conf [netbsd-6]: ALL files.i386
Added Files:
src/share/man/man4 [netbsd-6]: ptcd.4
src/sys/dev/isa [netbsd-6]: ptcd.c
Log Message:
Pull up following revision(s) (requested by mbalmer in ticket #891):
distrib/sets/lists/man/mi: revision 1.1411
share/man/man4/Makefile: revision 1.593
share/man/man4/gpio.4: revision 1.24
share/man/man4/ptcd.4: revision 1.1-1.4
sys/arch/i386/conf/ALL: revision 1.348
sys/arch/i386/conf/files.i386: revision 1.369
sys/dev/isa/ptcd.c: revision 1.1
ptcd(4) is a device driver for the cash drawer port found on Protech PS3100
point of sale terminals. It controls the cash drawer using a gpio(4) device
that attaches at ptcd0: Pin 0 controls the drawer, pin 1 reports the current
state. For details read the manual page.
--
Mention ptcd(4) in the synopsis.
--
Add ptcd(4).
--
Mention ibmcd(4).
--
Sort sections.
--
Sort SEE ALSO.
To generate a diff of this commit:
cvs rdiff -u -r1.1379.2.13 -r1.1379.2.14 src/distrib/sets/lists/man/mi
cvs rdiff -u -r1.581.2.3 -r1.581.2.4 src/share/man/man4/Makefile
cvs rdiff -u -r1.23 -r1.23.2.1 src/share/man/man4/gpio.4
cvs rdiff -u -r0 -r1.5.6.2 src/share/man/man4/ptcd.4
cvs rdiff -u -r1.332.2.4 -r1.332.2.5 src/sys/arch/i386/conf/ALL
cvs rdiff -u -r1.362 -r1.362.6.1 src/sys/arch/i386/conf/files.i386
cvs rdiff -u -r0 -r1.3.22.2 src/sys/dev/isa/ptcd.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/distrib/sets/lists/man/mi
diff -u src/distrib/sets/lists/man/mi:1.1379.2.13 src/distrib/sets/lists/man/mi:1.1379.2.14
--- src/distrib/sets/lists/man/mi:1.1379.2.13 Thu Dec 25 02:34:20 2014
+++ src/distrib/sets/lists/man/mi Thu Apr 16 07:01:38 2015
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1379.2.13 2014/12/25 02:34:20 snj Exp $
+# $NetBSD: mi,v 1.1379.2.14 2015/04/16 07:01:38 snj Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -1442,6 +1442,7 @@
./usr/share/man/cat4/prep/nvram.0 man-sys-catman .cat
./usr/share/man/cat4/pseye.0 man-sys-catman .cat
./usr/share/man/cat4/pss.0 man-obsolete obsolete
+./usr/share/man/cat4/ptcd.0 man-sys-catman .cat
./usr/share/man/cat4/ptm.0 man-sys-catman .cat
./usr/share/man/cat4/pty.0 man-sys-catman .cat
./usr/share/man/cat4/puc.0 man-sys-catman .cat
@@ -4256,6 +4257,7 @@
./usr/share/man/html4/prep/intro.html man-sys-htmlman html
./usr/share/man/html4/prep/nvram.html man-sys-htmlman html
./usr/share/man/html4/pseye.html man-sys-htmlman html
+./usr/share/man/html4/ptcd.html man-sys-htmlman html
./usr/share/man/html4/ptm.html man-sys-htmlman html
./usr/share/man/html4/pty.html man-sys-htmlman html
./usr/share/man/html4/puc.html man-sys-htmlman html
@@ -6975,6 +6977,7 @@
./usr/share/man/man4/prep/nvram.4 man-sys-man .man
./usr/share/man/man4/pseye.4 man-sys-man .man
./usr/share/man/man4/pss.4 man-obsolete obsolete
+./usr/share/man/man4/ptcd.4 man-sys-man .man
./usr/share/man/man4/ptm.4 man-sys-man .man
./usr/share/man/man4/pty.4 man-sys-man .man
./usr/share/man/man4/puc.4 man-sys-man .man
Index: src/share/man/man4/Makefile
diff -u src/share/man/man4/Makefile:1.581.2.3 src/share/man/man4/Makefile:1.581.2.4
--- src/share/man/man4/Makefile:1.581.2.3 Fri Jun 15 08:48:47 2012
+++ src/share/man/man4/Makefile Thu Apr 16 07:01:38 2015
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.581.2.3 2012/06/15 08:48:47 sborrill Exp $
+# $NetBSD: Makefile,v 1.581.2.4 2015/04/16 07:01:38 snj Exp $
# @(#)Makefile 8.1 (Berkeley) 6/18/93
MAN= aac.4 ac97.4 acardide.4 aceride.4 acphy.4 \
@@ -46,7 +46,7 @@ MAN= aac.4 ac97.4 acardide.4 aceride.4 a
pad.4 pas.4 pcdisplay.4 pcf8563rtc.4 pciide.4 pckbc.4 pckbd.4 pcn.4 \
pcppi.4 pcscp.4 pcweasel.4 pdcide.4 pdcsata.4 piixide.4 piixpcib.4 \
piixpm.4 pim.4 plip.4 pms.4 pmu.4 pnaphy.4 ppbus.4 ppp.4 pppoe.4 \
- pseye.4 ptm.4 pty.4 puc.4 pud.4 puffs.4 pwdog.4 px.4 pxg.4 \
+ pseye.4 ptcd.4 ptm.4 pty.4 puc.4 pud.4 puffs.4 pwdog.4 px.4 pxg.4 \
qe.4 qec.4 qsphy.4 \
raid.4 ral.4 ray.4 rcons.4 rdcphy.4 re.4 rgephy.4 rlphy.4 \
rnd.4 route.4 rs5c372rtc.4 rtk.4 rtw.4 rum.4 \
Index: src/share/man/man4/gpio.4
diff -u src/share/man/man4/gpio.4:1.23 src/share/man/man4/gpio.4:1.23.2.1
--- src/share/man/man4/gpio.4:1.23 Sun Nov 13 17:00:04 2011
+++ src/share/man/man4/gpio.4 Thu Apr 16 07:01:38 2015
@@ -1,4 +1,4 @@
-.\" $NetBSD: gpio.4,v 1.23 2011/11/13 17:00:04 mbalmer Exp $
+.\" $NetBSD: gpio.4,v 1.23.2.1 2015/04/16 07:01:38 snj Exp $
.\" $OpenBSD: gpio.4,v 1.5 2004/11/23 09:39:29 reyk Exp $
.\"
.\" Copyright (c) 2004 Alexander Yurchenko <[email protected]>
@@ -15,7 +15,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd November 13, 2011
+.Dd December 16, 2012
.Dt GPIO 4
.Os
.Sh NAME
@@ -30,6 +30,7 @@
.Cd "gpio* at ichlpcib?"
.Cd "gpio* at nsclpcsio?"
.Cd "gpio* at ppbus?"
+.Cd "gpio* at ptcd?"
.Pp
.In sys/types.h
.In sys/gpio.h
Index: src/sys/arch/i386/conf/ALL
diff -u src/sys/arch/i386/conf/ALL:1.332.2.4 src/sys/arch/i386/conf/ALL:1.332.2.5
--- src/sys/arch/i386/conf/ALL:1.332.2.4 Mon Oct 27 05:37:28 2014
+++ src/sys/arch/i386/conf/ALL Thu Apr 16 07:01:38 2015
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.332.2.4 2014/10/27 05:37:28 msaitoh Exp $
+# $NetBSD: ALL,v 1.332.2.5 2015/04/16 07:01:38 snj Exp $
# From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
#
# ALL machine description file
@@ -17,7 +17,7 @@ include "arch/i386/conf/std.i386"
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
-#ident "ALL-$Revision: 1.332.2.4 $"
+#ident "ALL-$Revision: 1.332.2.5 $"
maxusers 64 # estimated number of users
@@ -515,6 +515,10 @@ isa0 at mainbus?
isa0 at pceb?
isa0 at pcib?
+# Protech PS3100 cash drawer port
+ptcd0 at isa?
+gpio* at ptcd?
+
# PCMCIA bus support
pcmcia* at pcic? controller ? socket ?
pcmcia* at tcic? controller ? socket ?
Index: src/sys/arch/i386/conf/files.i386
diff -u src/sys/arch/i386/conf/files.i386:1.362 src/sys/arch/i386/conf/files.i386:1.362.6.1
--- src/sys/arch/i386/conf/files.i386:1.362 Fri Nov 18 22:18:07 2011
+++ src/sys/arch/i386/conf/files.i386 Thu Apr 16 07:01:38 2015
@@ -1,4 +1,4 @@
-# $NetBSD: files.i386,v 1.362 2011/11/18 22:18:07 jmcneill Exp $
+# $NetBSD: files.i386,v 1.362.6.1 2015/04/16 07:01:38 snj Exp $
#
# new style config file for i386 architecture
#
@@ -245,6 +245,11 @@ include "dev/isa/files.isa"
file arch/x86/isa/clock.c isa
file arch/x86/isa/rtc.c isa
+# Protech PS3100 cash drawer
+device ptcd: gpiobus
+attach ptcd at isa
+file dev/isa/ptcd.c ptcd
+
# TSC support
file arch/x86/x86/tsc.c
Added files:
Index: src/share/man/man4/ptcd.4
diff -u /dev/null src/share/man/man4/ptcd.4:1.5.6.2
--- /dev/null Thu Apr 16 07:01:39 2015
+++ src/share/man/man4/ptcd.4 Thu Apr 16 07:01:38 2015
@@ -0,0 +1,67 @@
+.\" $NetBSD$
+.\"
+.\" Copyright (c) 2012 Marc Balmer <[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.
+.\"
+.Dd December 17, 2012
+.Dt PTCD 4
+.Os
+.Sh NAME
+.Nm ptcd
+.Nd support for the Protech PS3100 cash drawer port
+.Sh SYNOPSIS
+.Cd "ptcd* at isa? port 0x48d"
+.Cd "gpio* at ptcd?"
+.Sh DESCRIPTION
+The
+.Nm
+driver controls the cash drawer port of the Protech PS3100 point of sale
+terminal using the GPIO subsystem.
+.Pp
+.Nm
+provides a GPIO device with two pins: pin 0 is used to control the cash drawer
+while pin 1 can be used to read the current state of the sense input pin.
+A logical 0 means the cash drawer is closed, a logical 1 means the cash drawer
+is open.
+.Pp
+To open the cash drawer, set pin 0 to logical 1 for a short period
+of time (e.g. < 1 sec) and then reset the pin to logical 0.
+.Sh CAVEATS
+As it is not possible to detect the hardware at runtime, this driver, when
+enabled, will always attach.
+Only enable it in your kernel configuration if you have the proper hardware.
+.Sh SEE ALSO
+.Xr ibmcd 4 ,
+.Xr gpio 4 ,
+.Xr gpioctl 8
+.Sh HISTORY
+The
+.Nm
+driver first appeared in
+.Nx 6.1 .
+.Sh AUTHORS
+.An -nosplit
+The
+.Nm
+driver was written by
+.An Marc Balmer Aq [email protected] .
Index: src/sys/dev/isa/ptcd.c
diff -u /dev/null src/sys/dev/isa/ptcd.c:1.3.22.2
--- /dev/null Thu Apr 16 07:01:39 2015
+++ src/sys/dev/isa/ptcd.c Thu Apr 16 07:01:39 2015
@@ -0,0 +1,180 @@
+/* $NetBSD */
+
+/*
+ * Copyright (c) 2012 Marc Balmer <[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.
+ */
+
+/*
+ * Driver for the Protech PS3100 cash drawer port.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/gpio.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+
+#include <machine/pio.h>
+
+#include <dev/gpio/gpiovar.h>
+
+#include <dev/isa/isareg.h>
+#include <dev/isa/isavar.h>
+
+/*
+ * To assert the cash drawer pulse, 0x00 must be written to I/O register 0x48f
+ * To stop the cash drawer pulse, 0x02 must be written to I/O register 0x48f
+ * To read out the current cash drawer state (sense pin), read bit 7 of
+ * I/O register 0x48d
+ */
+
+#define PTCD_READ_REG 0x48d
+
+/* register offsets, counted from PTCD_READ_REG */
+#define PTCD_READ 0x00
+#define PTCD_WRITE 0x02
+
+/* Read mask */
+#define PTCD_SENSE 0x80
+
+/* Write values */
+#define PTCD_OPEN 0x00
+#define PTCD_CLOSE 0x02
+
+#define PTCD_NPINS 2
+#define PIN_WRITE 0
+#define PIN_READ 1
+
+#define PTCD_ADDR_SIZE 0x03
+
+struct ptcd_softc {
+ bus_space_tag_t sc_iot;
+ bus_space_handle_t sc_ioh;
+
+ /* GPIO interface */
+ struct gpio_chipset_tag sc_gpio_gc;
+ gpio_pin_t sc_gpio_pins[PTCD_NPINS];
+};
+
+int ptcd_match(device_t, struct cfdata *, void *);
+void ptcd_attach(device_t, device_t, void *);
+
+int ptcd_gpio_pin_read(void *, int);
+void ptcd_gpio_pin_write(void *, int, int);
+void ptcd_gpio_pin_ctl(void *, int, int);
+
+CFATTACH_DECL2_NEW(ptcd, sizeof(struct ptcd_softc), ptcd_match, ptcd_attach,
+ NULL, NULL, NULL, NULL);
+
+int
+ptcd_match(device_t parent, struct cfdata *match, void *aux)
+{
+ struct isa_attach_args *ia = aux;
+
+ if (ia->ia_nio < 1)
+ return 0;
+
+ if (ISA_DIRECT_CONFIG(ia))
+ return 0;
+
+ if (ia->ia_io[0].ir_addr != PTCD_READ_REG)
+ return 0;
+
+ ia->ia_io[0].ir_size = PTCD_ADDR_SIZE;
+ ia->ia_niomem = 0;
+ ia->ia_nirq = 0;
+ ia->ia_ndrq = 0;
+
+ return 1;
+}
+
+void
+ptcd_attach(device_t parent, device_t self, void *aux)
+{
+ struct ptcd_softc *sc;
+ struct isa_attach_args *ia = aux;
+ struct gpiobus_attach_args gba;
+
+ sc = device_private(self);
+
+ sc->sc_iot = ia->ia_iot;
+ if (bus_space_map(sc->sc_iot, ia->ia_io[0].ir_addr, PTCD_ADDR_SIZE, 0,
+ &sc->sc_ioh)) {
+ aprint_error(": can't map i/o space\n");
+ return;
+ }
+
+ aprint_normal(": Protech PS3100 cash drawer\n");
+
+ /* Initialize pins array */
+ sc->sc_gpio_pins[PIN_WRITE].pin_num = 0;
+ sc->sc_gpio_pins[PIN_WRITE].pin_caps = GPIO_PIN_OUTPUT;
+ sc->sc_gpio_pins[PIN_READ].pin_num = 1;
+ sc->sc_gpio_pins[PIN_READ].pin_caps = GPIO_PIN_INPUT;
+
+ /* Create controller tag */
+ sc->sc_gpio_gc.gp_cookie = sc;
+ sc->sc_gpio_gc.gp_pin_read = ptcd_gpio_pin_read;
+ sc->sc_gpio_gc.gp_pin_write = ptcd_gpio_pin_write;
+ sc->sc_gpio_gc.gp_pin_ctl = ptcd_gpio_pin_ctl;
+
+ gba.gba_gc = &sc->sc_gpio_gc;
+ gba.gba_pins = sc->sc_gpio_pins;
+ gba.gba_npins = PTCD_NPINS;
+
+ /* Attach GPIO framework */
+ config_found_ia(self, "gpiobus", &gba, gpiobus_print);
+}
+
+int
+ptcd_gpio_pin_read(void *arg, int pin)
+{
+ struct ptcd_softc *sc = arg;
+ uint8_t data;
+
+ if (pin != PIN_READ)
+ return 0;
+
+ data = bus_space_read_1(sc->sc_iot, sc->sc_ioh, PTCD_READ);
+ return data & PTCD_SENSE ? 0 : 1;
+}
+
+void
+ptcd_gpio_pin_write(void *arg, int pin, int value)
+{
+ struct ptcd_softc *sc = arg;
+
+ if (pin != PIN_WRITE)
+ return;
+
+ bus_space_write_1(sc->sc_iot, sc->sc_ioh, PTCD_WRITE,
+ value ? PTCD_OPEN : PTCD_CLOSE);
+}
+
+void
+ptcd_gpio_pin_ctl(void *arg, int pin, int flags)
+{
+ /* We ignore pin control requests since the pin functions are fixed. */
+}