Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Adding ibmcd(4), a device driver for the IBM 4810 BSP cash d...



details:   https://anonhg.NetBSD.org/src/rev/c60d7d401654
branches:  trunk
changeset: 783378:c60d7d401654
user:      mbalmer <mbalmer%NetBSD.org@localhost>
date:      Mon Dec 17 20:37:59 2012 +0000

description:
Adding ibmcd(4), a device driver for the IBM 4810 BSP cash drawer port as
found e.g. in SurePOS 300 series point of sale terminals.  The driver
provides a gpio(4) device with three pins:  pin 0 to open drawer, pin 1
to read the status and pin 2 to read whether a cash drawer is connected or
not.

diffstat:

 distrib/sets/lists/man/mi  |    5 +-
 share/man/man4/Makefile    |    4 +-
 share/man/man4/ibmcd.4     |   68 ++++++++++++
 sys/arch/i386/conf/ALL     |    8 +-
 sys/arch/i386/conf/GENERIC |    7 +-
 sys/dev/pci/files.pci      |    7 +-
 sys/dev/pci/ibmcd.c        |  238 +++++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 329 insertions(+), 8 deletions(-)

diffs (truncated from 443 to 300 lines):

diff -r 4e3a6bcd0928 -r c60d7d401654 distrib/sets/lists/man/mi
--- a/distrib/sets/lists/man/mi Mon Dec 17 18:20:50 2012 +0000
+++ b/distrib/sets/lists/man/mi Mon Dec 17 20:37:59 2012 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1412 2012/12/16 20:33:43 christos Exp $
+# $NetBSD: mi,v 1.1413 2012/12/17 20:38:00 mbalmer Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -1180,6 +1180,7 @@
 ./usr/share/man/cat4/i4btrc.0                  man-obsolete            obsolete
 ./usr/share/man/cat4/i915drm.0                 man-sys-catman          .cat
 ./usr/share/man/cat4/iavc.0                    man-sys-catman          .cat
+./usr/share/man/cat4/ibmcd.0                   man-sys-catman          .cat
 ./usr/share/man/cat4/ibmhawk.0                 man-sys-catman          .cat
 ./usr/share/man/cat4/ichlpcib.0                        man-obsolete            obsolete
 ./usr/share/man/cat4/ichsmb.0                  man-sys-catman          .cat
@@ -4074,6 +4075,7 @@
 ./usr/share/man/html4/i386/viac7temp.html      man-sys-htmlman         html
 ./usr/share/man/html4/i915drm.html             man-sys-htmlman         html
 ./usr/share/man/html4/iavc.html                        man-sys-htmlman         html
+./usr/share/man/html4/ibmcd.html               man-sys-htmlman         html
 ./usr/share/man/html4/ibmhawk.html             man-sys-htmlman         html
 ./usr/share/man/html4/ichlpcib.html            man-obsolete            obsolete
 ./usr/share/man/html4/ichsmb.html              man-sys-htmlman         html
@@ -6798,6 +6800,7 @@
 ./usr/share/man/man4/i4btrc.4                  man-obsolete            obsolete
 ./usr/share/man/man4/i915drm.4                 man-sys-man             .man
 ./usr/share/man/man4/iavc.4                    man-sys-man             .man
+./usr/share/man/man4/ibmcd.4                   man-sys-man             .man
 ./usr/share/man/man4/ibmhawk.4                 man-sys-man             .man
 ./usr/share/man/man4/ichlpcib.4                        man-obsolete            obsolete
 ./usr/share/man/man4/ichsmb.4                  man-sys-man             .man
diff -r 4e3a6bcd0928 -r c60d7d401654 share/man/man4/Makefile
--- a/share/man/man4/Makefile   Mon Dec 17 18:20:50 2012 +0000
+++ b/share/man/man4/Makefile   Mon Dec 17 20:37:59 2012 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.593 2012/12/16 13:09:18 mbalmer Exp $
+#      $NetBSD: Makefile,v 1.594 2012/12/17 20:37:59 mbalmer Exp $
 #      @(#)Makefile    8.1 (Berkeley) 6/18/93
 
 MAN=   aac.4 ac97.4 acardide.4 aceride.4 acphy.4 \
@@ -29,7 +29,7 @@
        glxtphy.4 gpib.4 gpio.4 gpiolock.4 gpiopwm.4 gpiosim.4 gre.4 \
        gphyter.4 gsip.4 \
        hdaudio.4 hifn.4 hme.4 hpacel.4 hpqlb.4 hptide.4 \
-       ibmhawk.4 ichsmb.4 icmp.4 icp.4 icsphy.4 iee.4 ieee80211.4 \
+       ibmcd.4 ibmhawk.4 ichsmb.4 icmp.4 icp.4 icsphy.4 iee.4 ieee80211.4 \
        ifmedia.4 igphy.4 igsfb.4 iha.4 ihphy.4 iic.4 inet.4 ikphy.4 inphy.4 \
        intersil7170.4 \
        ioasic.4 ioat.4 iop.4 iophy.4 iopsp.4 ip.4 ipkdb.4 ipmi.4 ipw.4 \
diff -r 4e3a6bcd0928 -r c60d7d401654 share/man/man4/ibmcd.4
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/share/man/man4/ibmcd.4    Mon Dec 17 20:37:59 2012 +0000
@@ -0,0 +1,68 @@
+.\"    $NetBSD: ibmcd.4,v 1.1 2012/12/17 20:37:59 mbalmer Exp $
+.\"
+.\" Copyright (c) 2012 Marc Balmer <marc%msys.ch@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 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 IBMCD 4
+.Os
+.Sh NAME
+.Nm ibmcd
+.Nd support for the IBM 4810 BSP cash drawer port
+.Sh SYNOPSIS
+.Cd "ibmcd* at at pci ? dev ? function ?"
+.Cd "gpio* at ibmcd?"
+.Sh DESCRIPTION
+The
+.Nm
+driver controls the cash drawer port of the IBM 4810 BSP PCI device found
+in IBM point of sale terminals (e.g. in the SurePOS 300 series) using the GPIO
+subsystem.
+.Pp
+.Nm
+provides a GPIO device with three 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
+Pin 2 reports if a cash drawer is connected.
+A logical 0 means there is no cash drawer connected, a logical 1 means the cash drawer is connected.
+.Pp
+To open the cash drawer, set pin 0 to logical 1.
+There is no need to reset pin 0 to logical 0 afterwards as the device generates
+a oneshot impulse.
+.Sh SEE ALSO
+.Xr gpio 4 ,
+.Xr gpioctl 8 ,
+.Xr ptcd 4
+.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 marc%msys.ch@localhost .
diff -r 4e3a6bcd0928 -r c60d7d401654 sys/arch/i386/conf/ALL
--- a/sys/arch/i386/conf/ALL    Mon Dec 17 18:20:50 2012 +0000
+++ b/sys/arch/i386/conf/ALL    Mon Dec 17 20:37:59 2012 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.348 2012/12/16 18:52:17 mbalmer Exp $
+# $NetBSD: ALL,v 1.349 2012/12/17 20:38:00 mbalmer Exp $
 # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
 #
 # ALL machine description file
@@ -17,7 +17,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident                 "ALL-$Revision: 1.348 $"
+#ident                 "ALL-$Revision: 1.349 $"
 
 maxusers       64              # estimated number of users
 
@@ -521,6 +521,10 @@
 ptcd0  at isa?
 gpio*  at ptcd?
 
+# IBM 4810 BSP cash drawer port
+ibmcd* at pci? dev ? function ?
+gpio*  at ibmcd?
+
 # PCMCIA bus support
 pcmcia* at pcic? controller ? socket ?
 pcmcia* at tcic? controller ? socket ?
diff -r 4e3a6bcd0928 -r c60d7d401654 sys/arch/i386/conf/GENERIC
--- a/sys/arch/i386/conf/GENERIC        Mon Dec 17 18:20:50 2012 +0000
+++ b/sys/arch/i386/conf/GENERIC        Mon Dec 17 20:37:59 2012 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.1084 2012/12/10 02:03:45 dholland Exp $
+# $NetBSD: GENERIC,v 1.1085 2012/12/17 20:38:00 mbalmer Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident                 "GENERIC-$Revision: 1.1084 $"
+#ident                 "GENERIC-$Revision: 1.1085 $"
 
 maxusers       64              # estimated number of users
 
@@ -477,6 +477,9 @@
 
 pwdog* at pci ? dev ? function ?       # QUANCOM PWDOG1
 
+#ibmcd*        at pci ? dev ? function ?       # IBM 4810 BSP cash drawer port
+#gpio* at ibmcd?
+
 agp*   at pchb?
 
 
diff -r 4e3a6bcd0928 -r c60d7d401654 sys/dev/pci/files.pci
--- a/sys/dev/pci/files.pci     Mon Dec 17 18:20:50 2012 +0000
+++ b/sys/dev/pci/files.pci     Mon Dec 17 20:37:59 2012 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.pci,v 1.360 2012/08/02 00:17:44 macallan Exp $
+#      $NetBSD: files.pci,v 1.361 2012/12/17 20:37:59 mbalmer Exp $
 #
 # Config file and device description for machine-independent PCI code.
 # Included by ports that need it.  Requires that the SCSI files be
@@ -1091,6 +1091,11 @@
 attach pwdog at pci
 file   dev/pci/pwdog.c         pwdog
 
+# IBM 4810 BSP cash drawer port
+device ibmcd: gpiobus
+attach ibmcd at pci
+file   dev/pci/ibmcd.c         ibmcd
+
 # SIS 315 Pro frame buffer
 device  sisfb: wsemuldisplaydev, rasops8, rasops15, rasops16, rasops32, vcons
 attach  sisfb at pci
diff -r 4e3a6bcd0928 -r c60d7d401654 sys/dev/pci/ibmcd.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/pci/ibmcd.c       Mon Dec 17 20:37:59 2012 +0000
@@ -0,0 +1,238 @@
+/* $NetBSD: ibmcd.c,v 1.1 2012/12/17 20:38:00 mbalmer Exp $ */
+
+/*
+ * Copyright (c) 2012 Marc Balmer <marc%msys.ch@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 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 IBM 4810 BSP cash drawer port.
+ */
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/device.h>
+#include <sys/gpio.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/systm.h>
+
+#include <dev/gpio/gpiovar.h>
+
+#include <dev/pci/pcivar.h>
+#include <dev/pci/pcireg.h>
+#include <dev/pci/pcidevs.h>
+
+/* registers */
+#define IBMCD_STATUS           0x00
+#define IBMCD_CONTROL          0x01
+
+#define IBMCD_CMD_OPEN         0x6d
+#define IBMCD_DO_OPEN          0x01
+
+#define IBMCD_CLOSED           0x80
+#define IBMCD_NOT_CONNECTED    0x40
+
+/* GPIO constants */
+#define IBMCD_NPINS            3
+#define PIN_OPEN               0
+#define        PIN_STATUS              1
+#define PIN_CONNECTED          2
+
+struct ibmcd_softc {
+       bus_space_tag_t         sc_iot;
+       bus_space_handle_t      sc_ioh;
+       bus_size_t              sc_iosize;
+
+       /* GPIO interface */
+       struct gpio_chipset_tag sc_gpio_gc;
+       gpio_pin_t              sc_gpio_pins[IBMCD_NPINS];
+};
+
+static int ibmcd_match(device_t, cfdata_t, void *);
+static void ibmcd_attach(device_t, device_t, void *);
+static int ibmcd_detach(device_t, int);
+#if (__NetBSD_Version__ >= 600000000)
+static bool ibmcd_suspend(device_t, const pmf_qual_t *);
+static bool ibmcd_resume(device_t, const pmf_qual_t *);
+#endif
+int ibmcd_gpio_pin_read(void *, int);
+void ibmcd_gpio_pin_write(void *, int, int);
+void ibmcd_gpio_pin_ctl(void *, int, int);
+
+CFATTACH_DECL2_NEW(ibmcd, sizeof(struct ibmcd_softc), ibmcd_match,
+    ibmcd_attach, ibmcd_detach, NULL, NULL, NULL);
+
+static int
+ibmcd_match(device_t parent, cfdata_t match, void *aux)
+{
+       struct pci_attach_args *pa = (struct pci_attach_args *)aux;
+
+       if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_IBM &&
+           PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_IBM_4810_BSP)
+               return 1;
+       return 0;
+}



Home | Main Index | Thread Index | Old Index