summaryrefslogtreecommitdiff
path: root/sys/dev/gpio/gpio.c
AgeCommit message (Collapse)Author
2022-12-13Never fib about pin count in GPIOINFO ioctl results. The number of pinsjakllsch
on a controller simply does not change depending on the privileges of the caller.
2022-04-27I have been using this for a while and forgot to commit it. This addbrad
a number of KERNEL_LOCK() calls and at the very least prevents gpioiic from panicing the system. This may be a fix for kern/56438.
2022-03-31For device modules that provide both auto-config and /dev/xxxpgoyette
interfaces, make sure that initialization and destruction follow the proper sequence. This is triggered by the recent changes to the devsw stuff; per riastradh@ the required call sequence is: devsw_attach() config_init_component() or config_cf*_attach() ... config_fini_component() or config_cf*_detach() devsw_detach() While here, add a few missing calls to some of the detach routines. Testing of these changes has been limited to: 1. compile without build break 2. no related test failures from atf 3. modload/modunload work as well as before. No functional device testing done, since I don't have any of these devices. Let me know of any damage I might cause here! XXX Some of the modules affected by this commit are already XXX broken; see kern/56772. This commit does not break any additional modules (as far as I know).
2022-01-17When initializing pins, try to get the default pin name from thethorpej
"gpio-line-names" property. If not present, then fall back on the default name for the pin from the parent, if there is one.
2021-09-21use l->l_cred since it is available.christos
2021-08-09fix various typos in compatibility, mainly in comments.andvar
2021-08-07Merge thorpej-cfargs2.thorpej
2021-04-24Merge thorpej-cfargs branch:thorpej
Simplify and make extensible the config_search() / config_found() / config_attach() interfaces: rather than having different variants for which arguments you want pass along, just have a single call that takes a variadic list of tag-value arguments. Adjust all call sites: - Simplify wherever possible; don't pass along arguments that aren't actually needed. - Don't be explicit about what interface attribute is attaching if the device only has one. (More simplification.) - Add a config_probe() function to be used in indirect configuiration situations, making is visibly easier to see when indirect config is in play, and allowing for future change in semantics. (As of now, this is just a wrapper around config_match(), but that is an implementation detail.) Remove unnecessary or redundant interface attributes where they're not needed. There are currently 5 "cfargs" defined: - CFARG_SUBMATCH (submatch function for direct config) - CFARG_SEARCH (search function for indirect config) - CFARG_IATTR (interface attribte) - CFARG_LOCATORS (locators array) - CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles) ...and a sentinel value CFARG_EOL. Add some extra sanity checking to ensure that interface attributes aren't ambiguous. Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark ports to associate those device handles with device_t instance. This will trickle trough to more places over time (need back-end for pre-OFW Sun OBP; any others?).
2019-10-20gpio: make GPIOREAD return also the symbolic name of the pin, if it is settnn
2019-10-15convert more KM_NOSLEEP to KM_SLEEP and remove code to handle failures.chs
2019-01-27Merge the [pgoyette-compat] branchpgoyette
2018-05-19Overhaul of GPIO interrupt support (that wasn't even used by anything).thorpej
- 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
2017-10-28Kill some more extern struct cfdriver declarations.riastradh
Down with externs in .c!
2017-07-06Let the controller provide a default name for pins. This makes pins easierjmcneill
to locate when we have multiple banks and a variable number of pins per bank.
2016-05-11As proposed inbouyer
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.
2014-07-25Add d_discard to all struct cdevsw instances I could find.dholland
All have been set to "nodiscard"; some should get a real implementation.
2014-06-29make implementation match gpio(4) man entry. do no change configurationkardel
if no flags are being set (allows non-destructive inquiry via GPIOSET again).
2014-05-23Add aprint_naive("\n") for boot -qmsaitoh
2014-04-04PR/48701: Timo Buhrmester: spurious messages while booting silently (gpio,christos
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-03-16Change (mostly mechanically) every cdevsw/bdevsw I can find to usedholland
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.
2013-05-20When returning the old value, use the value read from the device.mbalmer
2012-10-17Quiet down autoconfiguration by changing some printf() calls todyoung
aprint_normal() calls.
2011-11-25Don't ignore the gpiobus_close() return value. Found by joerg@ using clang.mbalmer
2011-11-14Initialize ga.ga_dvname in gpio_search to prevent a stack fault in config_matchmbalmer
2011-11-13Remove an unused variable.mbalmer
2011-11-13Remove software pulsing in gpio(4), this functionality is now providedmbalmer
by the gpiopwm(4) driver.
2011-10-03Fix non-COMPAT_50 compilation.mbalmer
2011-10-03Unbreak and move the list of child devices to COMPAT_50.mbalmer
2011-10-03Remove the GPIODETACH gpio(4) ioctl (it is still available in COMPAT_50) andmbalmer
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-03Don't cast void pointers.mbalmer
2011-10-02Add a ga_flags field to the gpio_attach structure to hand drivermbalmer
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-09-02Make sure error is not used unitialized when sc->sc_attach_busy is 0.mbalmer
2011-08-31Remove what I committed accidentally...mbalmer
2011-08-31gpio(4) keeps track of child devices attached using the GPIOATTACH ioctl(),mbalmer
so remove those references and free the memory in gpio_childdetached(). Protect access to the list of child devices with a kcondvar.
2011-08-30Unconditionally include <sys/modules.h>.mbalmer
2011-08-29Register as built-in module when compiled wo/ _MODULE.mbalmer
2011-08-28Add a new ioctl, GPIOPULSE to gpio(4) to allow for pulsing a pin.mbalmer
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-12gpio(4) and gpiosim(4) can now be built and used as modules. While here,mbalmer
make some functions static.
2011-06-09Annotate that gpiobus_close's return value is undesired herejoerg
2010-04-25console spamad
2010-02-24A pointer typedef entails trading too much flexibility to declare constdyoung
and non-const types, and the kernel uses both const and non-const PMF qualifiers and device suspensors, so change the pmf_qual_t and device_suspensor_t typedefs from "pointers to const" to non-pointer, non-const types.
2010-01-24Unfold, bump copyright.mbalmer
2010-01-08Expand PMF_FN_* macros.dyoung
2009-11-05Delete the useless activation hook. Add a child-detached hook anddyoung
a rescan hook. Detach children before detaching self.
2009-08-23Prevent the creation of duplicate pin names in GPIOSET.mbalmer
Problem noticed by rmind a while ago.
2009-08-21Before trying to attach a child device driver, make sure the GPIO pins canmbalmer
be mapped. This prevents drivers from later failing in the attach routine. Problem found by me, solution suggested by jmcneill.
2009-08-17unfold short lines, fold long line.mbalmer
2009-08-07Fold long line.mbalmer
2009-08-03Be more careful when attaching drivers at runtime, call the drivers matchmbalmer
routine before attaching the device. Prevents non-working driver instances from being created.
2009-07-26Fold long line, add comment to fix possible creation of duplicates.mbalmer