Commit Graph

108 Commits

Author SHA1 Message Date
thorpej fe989590a3 Fix a paste-o that prevented the 2-pin interrupt messages from being
printed correctly (but no other harmful effects).  Pointed out by
Brad Spencer.
2018-06-01 13:42:14 +00:00
thorpej 266bca89c9 Add a 1PPS-over-GPIO driver, originally by Brad Spencer, with changes by
me to adapt to the new GPIO interrupt interface and support a wider variety
of GPIO pin configuations.

PR kern/51676
2018-05-20 14:08:32 +00:00
thorpej ce735ef0b5 Add an example "gpioirq" driver that demonstrates interrupts on GPIO
pins.  Will be enhanced in the future to support sending events to
user space on edge-triggered interrupt events.

Based on initial work by Brad Spencer.
PR kern/51676
2018-05-19 14:15:39 +00:00
thorpej b936dffb43 Overhaul of GPIO interrupt support (that wasn't even used by anything).
- Remove the old, not-expressive-enough interrupt flags, and replace them
  with a new set of interrupt-specific flags that can express a wide
  variety of interrupt configurations (pos, neg, and double-edge, high
  and low level).
- Remove old, unused gpio_pin_ctl_intr() and gpio_pin_irqen(), and
  replace them with gpio_intr_establish(), gpio_intr_disestablish(),
  and gpio_intr_str().  Corresponding fields in the gpio_chipset_tag
  are also added for back-end controllers, which now handle the actual
  dispatch of GPIO interrupts in order to properly support level-triggered
  interrupts as well as interoperate properly with FDT-registered
  interrupts.

Piggy-back on the 8.99.18 version bump.

Inspired by initial work from Brad Spencer.
PR kern/51676
2018-05-19 13:59:06 +00:00
riastradh 82b8caba92 Kill some more extern struct cfdriver declarations.
Down with externs in .c!
2017-10-28 04:53:54 +00:00
jmcneill 5dbac04a82 Let the controller provide a default name for pins. This makes pins easier
to locate when we have multiple banks and a variable number of pins per
bank.
2017-07-06 10:43:06 +00:00
maya b8f12c7fce Check pmf_device_register return value. NFC
Appeases static analyzers.
2017-01-20 12:25:07 +00:00
msaitoh d21ffc75e5 - Use aprint*() instead of printf() in xxx_attach().
- Add missing aprint_naive("\n");
- KNF
2016-07-14 04:00:45 +00:00
bouyer ba413bf9c2 As proposed in
http://mail-index.netbsd.org/tech-kern/2016/04/28/msg020504.html
add gpio interrupt support to the gpio framework, and an implementation
for the allwinner gpio backend (tested on A20 only).
gpio(4) has new public functions:
- gpio_intr() called by backends when an interrupt condition for
  a gpio pin is present
- gpio_find_device() and gpio_get_name(), support functions for
  gpio(4) users, wich respectively returns a void * cookie for a gpio device
  given its name, and returns the name given the cookie.
- gpio_pin_ctl_intr(), which is used to configure interrupts on a gpio pin and
  registers a callback.
- gpio_pin_irqen(), which is used to mask/unmask interrupts on a pin.

Nothing in the NetBSD tree uses this yet, but I have a i2c driver
(at https://github.com/mbouyer/marine_chartplotter/tree/master/software/NetBSD/driver) which uses it.
2016-05-11 18:33:40 +00:00
jmcneill ccd2fe2bbc pull in sysmon_taskq 2015-10-15 09:07:49 +00:00
jmcneill c7ce4b6914 Use sysmon_taskq instead of our own workqueue for submitting button events. 2015-10-04 18:35:44 +00:00
phx edb5a34700 i2c_acquire_bus() should return 0 on success.
Fixed bug in gpioiic_bb_set_bits(), which was introduced with the SDA/SCL-
reverse feature.
Now the driver is confirmed to work. Tested with Raspberry Pi GPIO.
2015-09-01 19:25:32 +00:00
christos e7ae23fd9e include "ioconf.h" to get the 'void <driver>attach(int count);' prototype. 2015-08-20 14:40:16 +00:00
uebayasi 7a225a7a3f Use needs-count for # of pseudo instances; suggested by cube@. 2015-08-20 12:09:22 +00:00
jmcneill b340c54a1a remove debug printf 2015-05-30 17:12:16 +00:00
jmcneill 710e0b7953 Simple driver for GPIO power/sleep buttons. 2015-05-30 15:35:51 +00:00
jmcneill 252766dfd0 Simple driver for gpio control of rf enable/disable pins. 2015-05-29 23:17:13 +00:00
dholland f9228f4225 Add d_discard to all struct cdevsw instances I could find.
All have been set to "nodiscard"; some should get a real implementation.
2014-07-25 08:10:31 +00:00
kardel d70c01ba15 make implementation match gpio(4) man entry. do no change configuration
if no flags are being set (allows non-destructive inquiry via GPIOSET again).
2014-06-29 09:32:24 +00:00
msaitoh 5ac82b4202 Add aprint_naive("\n") for boot -q 2014-05-23 13:57:04 +00:00
christos d18a4ca216 PR/48701: Timo Buhrmester: spurious messages while booting silently (gpio,
glxsb); use aprint_normal()
>Category:       kern
>Synopsis:       spurious messages while booting silently (gpio, glxsb)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
2014-04-04 14:47:26 +00:00
dholland a68f9396b6 Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
2014-03-16 05:20:22 +00:00
pooka 4f6fb3bf35 Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
2014-02-25 18:30:08 +00:00
mbalmer 1c2221476f Make the gpiosim(4) device a 64 bit wide GPIO. 2013-05-20 15:48:25 +00:00
mbalmer 25f2bfbcb3 When returning the old value, use the value read from the device. 2013-05-20 15:46:41 +00:00
chs cbab9cadce split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
2012-10-27 17:17:22 +00:00
dyoung 818ff29c73 Quiet down autoconfiguration by changing some printf() calls to
aprint_normal() calls.
2012-10-17 21:35:38 +00:00
dsl e21a34c25e Add some pre-processor magic to verify that the type of the data item
passed to sysctl_createv() actually matches the declared type for
  the item itself.
In the places where the caller specifies a function and a structure
  address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
  sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
  AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
  fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.
2012-06-02 21:36:41 +00:00
mbalmer 70a43050a4 Don't ignore the gpiobus_close() return value. Found by joerg@ using clang. 2011-11-25 13:49:43 +00:00
mbalmer e6dceed514 Initialize ga.ga_dvname in gpio_search to prevent a stack fault in config_match 2011-11-14 07:45:54 +00:00
mbalmer 092935d865 Remove an unused variable. 2011-11-13 14:02:01 +00:00
mbalmer a2091c8232 Remove software pulsing in gpio(4), this functionality is now provided
by the gpiopwm(4) driver.
2011-11-13 13:20:02 +00:00
mbalmer 0826f67b74 On detach, set the pin to low state. 2011-11-13 13:16:33 +00:00
mbalmer d4bc0f70c1 gpiopwm(4) is a driver to pulse GPIO pins in software. This obsoletes
the software pulsing facilities in gpio(4) (and gpioctl(8)) which will
later be removed.
2011-11-13 12:33:00 +00:00
mbalmer cf39ee7883 Fix non-COMPAT_50 compilation. 2011-10-03 11:31:56 +00:00
mbalmer de05db530c Unbreak and move the list of child devices to COMPAT_50. 2011-10-03 11:28:28 +00:00
mbalmer d394843f35 Remove the GPIODETACH gpio(4) ioctl (it is still available in COMPAT_50) and
the 'detach' command line option from gpioctl(8).  Drivers that are
attached to gpio pins can be detached using the drvctl(8) command.
2011-10-03 11:16:47 +00:00
mbalmer a429601b29 Don't cast void pointers. 2011-10-03 08:23:58 +00:00
mbalmer 550019b8a7 Add the flag locator (missed in the previous commit). 2011-10-02 10:01:25 +00:00
mbalmer 90077b6e6d Add a ga_flags field to the gpio_attach structure to hand driver
specific flags to drivers being attached at gpio pins.  gpioiic(4)
uses this to reverse the SDA/SCL signal order.  gpioctl(8) accepts
the flag values as optional argument to the attach command.
While here, make sure we retain backwards compatability and wrap compat
code in #ifdef COMPAT_50/#endif.
2011-10-02 09:33:18 +00:00
mbalmer 5ff9b946b6 Newline is \n, not /n. 2011-09-07 07:43:05 +00:00
mbalmer 44d0145a0a Make sure error is not used unitialized when sc->sc_attach_busy is 0. 2011-09-02 06:50:20 +00:00
mbalmer aeaf43d1cc Switch von u_int_XY to uintXY 2011-08-31 12:25:05 +00:00
mbalmer 5d1f2a00ee Add glue code to build as module. 2011-08-31 12:23:32 +00:00
mbalmer d020095c80 Remove what I committed accidentally... 2011-08-31 12:20:35 +00:00
mbalmer 582e442d26 gpio(4) keeps track of child devices attached using the GPIOATTACH ioctl(),
so remove those references and free the memory in gpio_childdetached().
Protect access to the list of child devices with a kcondvar.
2011-08-31 12:07:26 +00:00
mbalmer 86a49d8281 Unconditionally include <sys/modules.h>. 2011-08-30 07:22:11 +00:00
mbalmer ffbe93dc4f Register as built-in module when compiled wo/ _MODULE. 2011-08-29 15:14:04 +00:00
jmcneill 1343ee48da build with WARNS=3 2011-08-28 11:36:17 +00:00
mbalmer 92ced822d1 Add a new ioctl, GPIOPULSE to gpio(4) to allow for pulsing a pin.
If a pin can pulse in hardware, that will be used, else it will
be pulsed in software.  There is no way yet to set the pulse frequency
for pins that pulse in hardware.  While here, make the code mpsafe and
allow more than one thread in the driver (access to ioctl is serialized).
2011-08-28 07:48:50 +00:00