Module Name: src Committed By: kardel Date: Mon Jun 10 07:14:02 UTC 2013
Modified Files: src/distrib/sets/lists/man: mi src/doc: CHANGES src/share/man/man4: gpio.4 isa.4 src/share/man/man4/man4.x86: Makefile soekrisgpio.4 src/sys/arch/amd64/conf: GENERIC src/sys/arch/i386/conf: ALL GENERIC src/sys/dev/isa: files.isa soekrisgpio.c Log Message: adjust soekrisgpio driver to NetBSD To generate a diff of this commit: cvs rdiff -u -r1.1429 -r1.1430 src/distrib/sets/lists/man/mi cvs rdiff -u -r1.1826 -r1.1827 src/doc/CHANGES cvs rdiff -u -r1.24 -r1.25 src/share/man/man4/gpio.4 cvs rdiff -u -r1.42 -r1.43 src/share/man/man4/isa.4 cvs rdiff -u -r1.13 -r1.14 src/share/man/man4/man4.x86/Makefile cvs rdiff -u -r1.1.1.1 -r1.2 src/share/man/man4/man4.x86/soekrisgpio.4 cvs rdiff -u -r1.377 -r1.378 src/sys/arch/amd64/conf/GENERIC cvs rdiff -u -r1.359 -r1.360 src/sys/arch/i386/conf/ALL cvs rdiff -u -r1.1094 -r1.1095 src/sys/arch/i386/conf/GENERIC cvs rdiff -u -r1.162 -r1.163 src/sys/dev/isa/files.isa cvs rdiff -u -r1.1.1.1 -r1.2 src/sys/dev/isa/soekrisgpio.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.1429 src/distrib/sets/lists/man/mi:1.1430 --- src/distrib/sets/lists/man/mi:1.1429 Sun Jun 9 18:40:50 2013 +++ src/distrib/sets/lists/man/mi Mon Jun 10 07:14:01 2013 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1429 2013/06/09 18:40:50 christos Exp $ +# $NetBSD: mi,v 1.1430 2013/06/10 07:14:01 kardel Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -1910,6 +1910,7 @@ ./usr/share/man/cat4/x86/mem.0 man-sys-catman .cat ./usr/share/man/cat4/x86/odcm.0 man-sys-catman .cat ./usr/share/man/cat4/x86/powernow.0 man-sys-catman .cat +./usr/share/man/cat4/x86/soekrisgpio.0 man-sys-catman .cat ./usr/share/man/cat4/x86/tprof_pmi.0 man-sys-catman .cat ./usr/share/man/cat4/x86/tprof_amdpmi.0 man-sys-catman .cat ./usr/share/man/cat4/x86/vmt.0 man-sys-catman .cat @@ -4795,6 +4796,7 @@ ./usr/share/man/html4/x86/mem.html man-sys-htmlman html ./usr/share/man/html4/x86/odcm.html man-sys-htmlman html ./usr/share/man/html4/x86/powernow.html man-sys-htmlman html +./usr/share/man/html4/x86/soekrisgpio.html man-sys-htmlman html ./usr/share/man/html4/x86/tprof_amdpmi.html man-sys-htmlman html ./usr/share/man/html4/x86/tprof_pmi.html man-sys-htmlman html ./usr/share/man/html4/x86/vmt.html man-sys-htmlman html @@ -7610,6 +7612,7 @@ ./usr/share/man/man4/x86/mem.4 man-sys-man .man ./usr/share/man/man4/x86/odcm.4 man-sys-man .man ./usr/share/man/man4/x86/powernow.4 man-sys-man .man +./usr/share/man/man4/x86/soekrisgpio.4 man-sys-man .man ./usr/share/man/man4/x86/tprof_amdpmi.4 man-sys-man .man ./usr/share/man/man4/x86/tprof_pmi.4 man-sys-man .man ./usr/share/man/man4/x86/vmt.4 man-sys-man .man Index: src/doc/CHANGES diff -u src/doc/CHANGES:1.1826 src/doc/CHANGES:1.1827 --- src/doc/CHANGES:1.1826 Thu Jun 6 06:48:25 2013 +++ src/doc/CHANGES Mon Jun 10 07:14:01 2013 @@ -1,4 +1,4 @@ -# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.1826 $> +# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.1827 $> # # # [Note: This file does not mention every change made to the NetBSD source tree. @@ -247,3 +247,5 @@ Changes from NetBSD 6.0 to NetBSD 7.0: wm(4): Add support for I217 and I218 [msaitoh 20130602] X11: Updated all Xorg packages that could be, for Xorg SA 2003-05-23, and general. [mrg 20130605] + kernel: Add driver soekrisgpio for Soekris net6501 + Ported by kardel@ from a patch for OpenBSD. [kardel 20130609] Index: src/share/man/man4/gpio.4 diff -u src/share/man/man4/gpio.4:1.24 src/share/man/man4/gpio.4:1.25 --- src/share/man/man4/gpio.4:1.24 Sun Dec 16 13:13:35 2012 +++ src/share/man/man4/gpio.4 Mon Jun 10 07:14:01 2013 @@ -1,4 +1,4 @@ -.\" $NetBSD: gpio.4,v 1.24 2012/12/16 13:13:35 mbalmer Exp $ +.\" $NetBSD: gpio.4,v 1.25 2013/06/10 07:14:01 kardel Exp $ .\" $OpenBSD: gpio.4,v 1.5 2004/11/23 09:39:29 reyk Exp $ .\" .\" Copyright (c) 2004 Alexander Yurchenko <gra...@openbsd.org> @@ -29,6 +29,7 @@ .Cd "gpio* at gscpcib?" .Cd "gpio* at ichlpcib?" .Cd "gpio* at nsclpcsio?" +.Cd "gpio* at soekrisgpio?" .Cd "gpio* at ppbus?" .Cd "gpio* at ptcd?" .Pp Index: src/share/man/man4/isa.4 diff -u src/share/man/man4/isa.4:1.42 src/share/man/man4/isa.4:1.43 --- src/share/man/man4/isa.4:1.42 Sun Feb 21 09:02:19 2010 +++ src/share/man/man4/isa.4 Mon Jun 10 07:14:01 2013 @@ -1,4 +1,4 @@ -.\" $NetBSD: isa.4,v 1.42 2010/02/21 09:02:19 wiz Exp $ +.\" $NetBSD: isa.4,v 1.43 2013/06/10 07:14:01 kardel Exp $ .\" .\" Copyright (c) 1997 Jason R. Thorpe. All rights reserved. .\" Copyright (c) 1997 Jonathan Stone @@ -271,6 +271,8 @@ AIMS Lab Radiotrack FM radio. AIMS Lab Radiotrack II FM radio. .It sf2r SoundForte RadioLink SF16-FMR2 FM radio. +.It soekrisgpio +Soekris net6501 GPIO and LEDs driver .It tcic Databook DB86082, DB86084, DB86184, and DB86072 .Tn PCMCIA @@ -367,6 +369,7 @@ It is usually due to a suboptimally code .Xr sb 4 , .Xr sea 4 , .Xr sf2r 4 , +.Xr soekrisgpio 4 , .Xr sm 4 , .Xr tcic 4 , .Xr tcom 4 , Index: src/share/man/man4/man4.x86/Makefile diff -u src/share/man/man4/man4.x86/Makefile:1.13 src/share/man/man4/man4.x86/Makefile:1.14 --- src/share/man/man4/man4.x86/Makefile:1.13 Wed Jan 4 16:25:17 2012 +++ src/share/man/man4/man4.x86/Makefile Mon Jun 10 07:14:01 2013 @@ -1,8 +1,8 @@ -# $NetBSD: Makefile,v 1.13 2012/01/04 16:25:17 yamt Exp $ +# $NetBSD: Makefile,v 1.14 2013/06/10 07:14:01 kardel Exp $ MAN= amdpcib.4 apic.4 balloon.4 coretemp.4 est.4 fdc.4 \ fwhrng.4 hpet.4 ichlpcib.4 lpt.4 mem.4 odcm.4 powernow.4 \ - tprof_amdpmi.4 tprof_pmi.4 vmt.4 + soekrisgpio.4 tprof_amdpmi.4 tprof_pmi.4 vmt.4 MLINKS+=apic.4 ioapic.4 \ apic.4 lapic.4 Index: src/share/man/man4/man4.x86/soekrisgpio.4 diff -u src/share/man/man4/man4.x86/soekrisgpio.4:1.1.1.1 src/share/man/man4/man4.x86/soekrisgpio.4:1.2 --- src/share/man/man4/man4.x86/soekrisgpio.4:1.1.1.1 Mon Jun 10 06:04:35 2013 +++ src/share/man/man4/man4.x86/soekrisgpio.4 Mon Jun 10 07:14:01 2013 @@ -1,6 +1,7 @@ -.\" $OpenBSD$ +.\" $NetBSD: soekrisgpio.4,v 1.2 2013/06/10 07:14:01 kardel Exp $ +.\" from OpenBSD .\" -.\" Copyright (c) 2013 Matt Dainty <matt@...> +.\" Copyright (c) 2013 Matt Dainty <matt <at> bodgit-n-scarper.com> .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above @@ -15,14 +16,14 @@ .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" .Dd $Mdocdate$ -.Dt SOEKRIS 4 amd64 +.Dt SOEKRIS 4 x86 .Os .Sh NAME -.Nm soekris +.Nm soekrisgpio .Nd Soekris net6501 GPIO and LEDs .Sh SYNOPSIS -.Cd "soekris0 at isa? port 0x680" -.Cd "gpio* at soekris?" +.Cd "soekrisgpio0 at isa? port 0x680" +.Cd "gpio* at soekrisgpio?" .Sh DESCRIPTION The .Nm @@ -46,12 +47,17 @@ Both may be used with The .Nm driver first appeared in -.Ox 5.3 . +.Nx +7.0 . .Sh AUTHORS The .Nm driver was written by -.An Matt Dainty Aq matt@... . +.An Matt Dainty Aq matt@... +and imported from a patch for OpenBSD to +.Nx +by +.An Frank Kardel Aq kar...@netbsd.org . .Sh BUGS -If the Xilinx FPGA is programmed with a different bistream, the driver will -likely not function. +If the Xilinx FPGA is programmed with a different bitstream, the driver will +likely not function. \ No newline at end of file Index: src/sys/arch/amd64/conf/GENERIC diff -u src/sys/arch/amd64/conf/GENERIC:1.377 src/sys/arch/amd64/conf/GENERIC:1.378 --- src/sys/arch/amd64/conf/GENERIC:1.377 Wed Jun 5 23:08:00 2013 +++ src/sys/arch/amd64/conf/GENERIC Mon Jun 10 07:14:01 2013 @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC,v 1.377 2013/06/05 23:08:00 christos Exp $ +# $NetBSD: GENERIC,v 1.378 2013/06/10 07:14:01 kardel Exp $ # # GENERIC machine description file # @@ -22,7 +22,7 @@ include "arch/amd64/conf/std.amd64" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "GENERIC-$Revision: 1.377 $" +#ident "GENERIC-$Revision: 1.378 $" maxusers 64 # estimated number of users @@ -532,6 +532,9 @@ ld* at iop? tid ? # block devices # Pulsing GPIO pins in software #gpiopwm* at gpio? +# Soekris 6501 GPIO/LED driver (provides gpiobus, needs gpio) +#soekrisgpio0 at isa? port 0x680 + # SCSI Controllers and Devices # PCI SCSI controllers Index: src/sys/arch/i386/conf/ALL diff -u src/sys/arch/i386/conf/ALL:1.359 src/sys/arch/i386/conf/ALL:1.360 --- src/sys/arch/i386/conf/ALL:1.359 Sat Jun 8 02:43:10 2013 +++ src/sys/arch/i386/conf/ALL Mon Jun 10 07:14:01 2013 @@ -1,4 +1,4 @@ -# $NetBSD: ALL,v 1.359 2013/06/08 02:43:10 dholland Exp $ +# $NetBSD: ALL,v 1.360 2013/06/10 07:14:01 kardel 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.359 $" +#ident "ALL-$Revision: 1.360 $" maxusers 64 # estimated number of users @@ -777,6 +777,9 @@ owtemp* at onewire? # Temperature sen # Keylock support gpiolock* at gpio? +# Soekris 6501 GPIO/LED driver (provides gpiobus, needs gpio) +soekrisgpio0 at isa? port 0x680 + # SCSI Controllers and Devices # PCI SCSI controllers Index: src/sys/arch/i386/conf/GENERIC diff -u src/sys/arch/i386/conf/GENERIC:1.1094 src/sys/arch/i386/conf/GENERIC:1.1095 --- src/sys/arch/i386/conf/GENERIC:1.1094 Wed Jun 5 23:08:01 2013 +++ src/sys/arch/i386/conf/GENERIC Mon Jun 10 07:14:01 2013 @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC,v 1.1094 2013/06/05 23:08:01 christos Exp $ +# $NetBSD: GENERIC,v 1.1095 2013/06/10 07:14:01 kardel Exp $ # # GENERIC machine description file # @@ -22,7 +22,7 @@ include "arch/i386/conf/std.i386" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "GENERIC-$Revision: 1.1094 $" +#ident "GENERIC-$Revision: 1.1095 $" maxusers 64 # estimated number of users @@ -732,6 +732,9 @@ gpiolock* at gpio? # Software pulsing GPIO pins gpiopwm* at gpio? +# Soekris 6501 GPIO/LED driver (provides gpiobus, needs gpio) +#soekrisgpio0 at isa? port 0x680 + # SCSI Controllers and Devices # PCI SCSI controllers Index: src/sys/dev/isa/files.isa diff -u src/sys/dev/isa/files.isa:1.162 src/sys/dev/isa/files.isa:1.163 --- src/sys/dev/isa/files.isa:1.162 Sun Jan 22 06:44:28 2012 +++ src/sys/dev/isa/files.isa Mon Jun 10 07:14:02 2013 @@ -1,4 +1,4 @@ -# $NetBSD: files.isa,v 1.162 2012/01/22 06:44:28 christos Exp $ +# $NetBSD: files.isa,v 1.163 2013/06/10 07:14:02 kardel Exp $ # # Config file and device description for machine-independent ISA code. # Included by ports that need it. Requires that the SCSI files be @@ -527,6 +527,11 @@ file dev/isa/toaster.c toaster attach tpm at isa with tpm_isa file dev/isa/tpm_isa.c tpm_isa needs-flag +# Soekris GPIO & LEDs driver +device soekrisgpio: gpiobus +attach soekrisgpio at isa +file dev/isa/soekrisgpio.c soekrisgpio + # # ISA Plug 'n Play autoconfiguration glue. # THIS MUST COME AFTER ALL MI ISA DEVICES ARE DEFINED. This is because Index: src/sys/dev/isa/soekrisgpio.c diff -u src/sys/dev/isa/soekrisgpio.c:1.1.1.1 src/sys/dev/isa/soekrisgpio.c:1.2 --- src/sys/dev/isa/soekrisgpio.c:1.1.1.1 Mon Jun 10 06:04:35 2013 +++ src/sys/dev/isa/soekrisgpio.c Mon Jun 10 07:14:02 2013 @@ -1,6 +1,9 @@ -/* $OpenBSD$ */ +/* from $OpenBSD$ */ /* + * ported to NetBSD by Frank Kardel + * (http://permalink.gmane.org/gmane.os.openbsd.tech/31317) + * * Copyright (c) 2013 Matt Dainty <matt <at> bodgit-n-scarper.com> * * Permission to use, copy, modify, and distribute this software for any @@ -20,18 +23,24 @@ * Soekris net6501 GPIO and LEDs as implemented by the onboard Xilinx FPGA */ +#include <sys/cdefs.h> +__KERNEL_RCSID(0, "$NetBSD: soekrisgpio.c,v 1.2 2013/06/10 07:14:02 kardel Exp $"); + #include <sys/param.h> #include <sys/systm.h> +#include <sys/types.h> #include <sys/device.h> -#include <sys/gpio.h> -#include <machine/bus.h> -#include <machine/intr.h> +#include <sys/bus.h> +#include <machine/autoconf.h> #include <dev/isa/isavar.h> +#include <sys/gpio.h> #include <dev/gpio/gpiovar.h> +#include "gpio.h" + #define SOEKRIS_BASE 0x680 /* Base address of FPGA I/O */ #define SOEKRIS_IOSIZE 32 /* I/O region size */ @@ -51,7 +60,7 @@ const u_int soekris_led_offset[SOEKRIS_N }; struct soekris_softc { - struct device sc_dev; + device_t sc_dev; bus_space_tag_t sc_iot; bus_space_handle_t sc_ioh; @@ -64,62 +73,70 @@ struct soekris_softc { gpio_pin_t sc_led_pins[SOEKRIS_NLEDS]; }; -int soekris_match(struct device *, void *, void *); -void soekris_attach(struct device *, struct device *, void *); -int soekris_gpio_read(void *, int); -void soekris_gpio_write(void *, int, int); -void soekris_gpio_ctl(void *, int, int); -int soekris_led_read(void *, int); -void soekris_led_write(void *, int, int); -void soekris_led_ctl(void *, int, int); +static int soekris_match(device_t, cfdata_t , void *); +static void soekris_attach(device_t, device_t, void *); +static int soekris_detach(device_t, int); +static int soekris_gpio_read(void *, int); +static void soekris_gpio_write(void *, int, int); +static void soekris_gpio_ctl(void *, int, int); +static int soekris_led_read(void *, int); +static void soekris_led_write(void *, int, int); +static void soekris_led_ctl(void *, int, int); + +CFATTACH_DECL_NEW(soekrisgpio, + sizeof(struct soekris_softc), + soekris_match, + soekris_attach, + soekris_detach, + NULL); -struct cfattach soekris_ca = { - sizeof(struct soekris_softc), soekris_match, soekris_attach -}; - -struct cfdriver soekris_cd = { - NULL, "soekris", DV_DULL -}; - -int -soekris_match(struct device *parent, void *match, void *aux) +static int +soekris_match(device_t parent, cfdata_t match, void *aux) { struct isa_attach_args *ia = aux; bus_space_handle_t ioh; + int iobase; + + if (ia->ia_nio < 1) + return (0); + + /* Disallow wildcarded i/o address. */ + if (ia->ia_io[0].ir_addr == ISA_UNKNOWN_PORT) + return (0); + + iobase = ia->ia_io[0].ir_addr; /* Need some sort of heuristic to match the Soekris net6501 */ - if (ia->ia_iobase != SOEKRIS_BASE || bus_space_map(ia->ia_iot, - ia->ia_iobase, SOEKRIS_IOSIZE, 0, &ioh) != 0) + if (iobase != SOEKRIS_BASE || bus_space_map(ia->ia_iot, + iobase, SOEKRIS_IOSIZE, 0, &ioh) != 0) return (0); bus_space_unmap(ia->ia_iot, ioh, SOEKRIS_IOSIZE); - ia->ia_iosize = SOEKRIS_IOSIZE; - ia->ipa_nio = 1; - ia->ipa_nmem = 0; - ia->ipa_nirq = 0; - ia->ipa_ndrq = 0; + + ia->ia_io[0].ir_size = SOEKRIS_IOSIZE; return (1); } -void -soekris_attach(struct device *parent, struct device *self, void *aux) +static void +soekris_attach(device_t parent, device_t self, void *aux) { - struct soekris_softc *sc = (void *)self; + struct soekris_softc *sc = device_private(self); struct isa_attach_args *ia = aux; struct gpiobus_attach_args gba1, gba2; u_int data; int i; - if (bus_space_map(ia->ia_iot, ia->ia_iobase, ia->ia_iosize, 0, + if (bus_space_map(ia->ia_iot, ia->ia_io[0].ir_addr, ia->ia_io[0].ir_size, 0, &sc->sc_ioh) != 0) { - printf(": can't map i/o space\n"); + aprint_normal(": can't map i/o space\n"); return; } - printf("\n"); + aprint_normal("\n"); + sc->sc_dev = self; sc->sc_iot = ia->ia_iot; data = bus_space_read_2(sc->sc_iot, sc->sc_ioh, SOEKRIS_GPIO_DIR); @@ -138,13 +155,10 @@ soekris_attach(struct device *parent, st sc->sc_gpio_gc.gp_pin_write = soekris_gpio_write; sc->sc_gpio_gc.gp_pin_ctl = soekris_gpio_ctl; - gba1.gba_name = "gpio"; gba1.gba_gc = &sc->sc_gpio_gc; gba1.gba_pins = sc->sc_gpio_pins; gba1.gba_npins = SOEKRIS_NPINS; - (void)config_found(&sc->sc_dev, &gba1, gpiobus_print); - for (i = 0; i < SOEKRIS_NLEDS; i++) { sc->sc_led_pins[i].pin_num = i; sc->sc_led_pins[i].pin_caps = GPIO_PIN_OUTPUT; @@ -157,15 +171,26 @@ soekris_attach(struct device *parent, st sc->sc_led_gc.gp_pin_write = soekris_led_write; sc->sc_led_gc.gp_pin_ctl = soekris_led_ctl; - gba2.gba_name = "gpio"; gba2.gba_gc = &sc->sc_led_gc; gba2.gba_pins = sc->sc_led_pins; gba2.gba_npins = SOEKRIS_NLEDS; - (void)config_found(&sc->sc_dev, &gba2, gpiobus_print); +#if NGPIO > 0 + (void)config_found(sc->sc_dev, &gba1, gpiobus_print); + (void)config_found(sc->sc_dev, &gba2, gpiobus_print); +#endif +} + +static int +soekris_detach(device_t self, int flags) +{ + struct soekris_softc *sc = device_private(self); + + bus_space_unmap(sc->sc_iot, sc->sc_ioh, SOEKRIS_IOSIZE); + return 0; } -int +static int soekris_gpio_read(void *arg, int pin) { struct soekris_softc *sc = arg; @@ -176,7 +201,7 @@ soekris_gpio_read(void *arg, int pin) return (data & (1 << pin)) ? GPIO_PIN_HIGH : GPIO_PIN_LOW; } -void +static void soekris_gpio_write(void *arg, int pin, int value) { struct soekris_softc *sc = arg; @@ -192,7 +217,7 @@ soekris_gpio_write(void *arg, int pin, i bus_space_write_2(sc->sc_iot, sc->sc_ioh, SOEKRIS_GPIO_OUTPUT, data); } -void +static void soekris_gpio_ctl(void *arg, int pin, int flags) { struct soekris_softc *sc = arg; @@ -208,7 +233,7 @@ soekris_gpio_ctl(void *arg, int pin, int bus_space_write_2(sc->sc_iot, sc->sc_ioh, SOEKRIS_GPIO_DIR, data); } -int +static int soekris_led_read(void *arg, int pin) { struct soekris_softc *sc = arg; @@ -220,7 +245,7 @@ soekris_led_read(void *arg, int pin) return (value & 0x1) ? GPIO_PIN_HIGH : GPIO_PIN_LOW; } -void +static void soekris_led_write(void *arg, int pin, int value) { struct soekris_softc *sc = arg; @@ -229,7 +254,7 @@ soekris_led_write(void *arg, int pin, in value); } -void +static void soekris_led_ctl(void *arg, int pin, int flags) { }