summaryrefslogtreecommitdiffstats
path: root/sys/dev/gpio
Commit message (Collapse)AuthorAgeFilesLines
* MFC r274670, r274671, r276168:loos2015-02-144-14/+38
| | | | | | | | | | | | | | Moves all the duplicate code to a single function. Verify for invalid modes and unwanted flags before pass the new flags to driver. Make gpio_default_map_gpios() static. No functional changes. Improves the GPIO API description a little bit. gpio_pin_max must return the maximum supported pin number and not the total number of pins on the system.
* MFC r274642, 274643:loos2015-02-143-32/+30
| | | | | | | | | | | | Remove unnecessary code. After r273566, the gpiobus version of bus_print_child() also works on FDT systems. Fix gpiobus_child_location_str() to return a real string with the mapped pins. Make gpiobus_print_pins() static again.
* MFC r274638:loos2015-02-143-2/+128
| | | | | | | | | | | | Add basic interrupt management code to gpiobus and ofw_gpiobus. This is the general support to allow the use of GPIO pins as interrupt sources for direct gpiobus children. The use of GPIO pins as generic interrupt sources (for an ethernet driver for example) will only be possible when arm/intrng is complete. Then, most of this code will need to be rewritten, but it works for now, is better than what we have and will allow further developments.
* MFC r273917, r273926:loos2015-02-145-66/+47
| | | | | | | | | | | | | | | | | | | | | | Fix the gpiobus locking by using a more sane model where it isn't necessary hold the gpiobus lock between the gpio calls. gpiobus_acquire_lock() now accepts a third parameter which tells gpiobus what to do when the bus is already busy. When GPIOBUS_WAIT wait is used, the calling thread will be put to sleep until the bus became free. With GPIOBUS_DONTWAIT the calling thread will receive EWOULDBLOCK right away and then it can act upon. This fixes the gpioiic(4) locking issues that arises when doing multiple concurrent access on the bus. Fix the build of non-FDT systems by moving the gpiobusvar.h header outside the FDT #ifdef. While here remove a few unused headers.
* MFC r273566, r273569:loos2015-02-143-48/+43
| | | | | | | | Provide a working GPIOBUS_IVAR() macro for FDT systems. Move the duplicated code to a single function. No functional changes.
* MFC r270945:ian2014-10-261-2/+2
| | | | | Rename OF_xref_phandle() to OF_node_from_xref() and add a new function that provides the inverse translation, OF_xref_from_node().
* MFC r266922:loos2014-08-201-9/+16
| | | | | | | | | | | | Add a bounds verification to the SCL and SDA pin values. At attach, print the SCL and SDA pin numbers. Remove a stray blank line. Remove the GPIOBUS locking from gpioiic_reset(), it is already called with this lock held. This fixes a crash when you try to scan the iicbus with i2c(8).
* MFC r265012, r265191, r265289, r265310loos2014-05-154-56/+154
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r265012: Fix the gpio-specifier decoding by respecting the GPIO controller's #gpio-cells property. Add a new ofw_bus method (OFW_BUS_MAP_GPIOS()) that allows the GPIO controller to implement its own mapping to deal with gpio-specifiers, allowing the decoding of gpio-specifiers to be controller specific. The default ofw_bus_map_gpios() decodes the linux standard (#gpio-cells = <2>) and the FreeBSD standard (#gpio-cells = <3>). It pass the gpio-specifier flag field to the children as an ivar variable so they can act upon. r265191: Remove unnecessary headers. Sort out the headers. Add a missing header on ofw_gpiobus.c (it was working because of sys/libkern.h). r265289: eally sort out the headers. sys/systm.h must always come after sys/param.h. Remove sys/types.h which should never be included together with sys/param.h. Add sys/malloc.h for correctness even if it seems to don't be needed. Remove more unused headers found by unusedinc (from bde@). r265310: Move gpiobus routines to dev/gpio. Avoid polluting ofw_bus with bus specific parts.
* MFC r258046, r258047, r258050, r259035, r259036, r259037, r261842, r261843,loos2014-05-155-27/+493
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r261844, r261845, r261846, r262194, r262522, r262559 r258046: Fix a typo on a comment in ofw_bus_if.m, the default method will return -1 when a node doesn't exist. r258047: Move the KASSERT() check to the point before the increase of number of pins. r258050: Fix gpiobus to return BUS_PROBE_GENERIC insted of BUS_PROBE_SPECIFIC (0) so it can be overriden by its OFW/FDT version. Give a chance for GPIO devices that implement the device_identify method to attach. r259035: Remove unnecessary includes and an unused softc variable. While here apply two minor style(9) fixes. r259036: Move the GPIOBUS_SET_PINFLAGS(..., ..., pin, GPIO_PIN_OUTPUT) to led(4) control callback function. This makes gpioled(4) works even if the pin is accidentally set to an input. r259037: Fix the pin value reading on AM335x. Because of the inverted logic it was always returning '0' for all the reads, even for the outputs. It is now known to work with gpioiic(4) and gpioled(4). r261842: Add an OFW GPIO compatible bus. This allows the use of the DTS files to describe GPIO bindings in the system. Move the GPIOBUS lock macros to gpiobusvar.h as they are now shared between the OFW and the non OFW versions of GPIO bus. Export gpiobus_print_pins() so it can also be used on the OFW GPIO bus. r261843: Add OFW support to the in tree gpio compatible devices: gpioiic(4) and gpioled(4). Tested on RPi and BBB (using the hardware I2C controller and gpioiic(4) for the I2C tests). It was also verified for regressions on RSPRO (MIPS/ar71xx) used as reference for a non OFW-based system. Update the gpioled(4) and gpioiic(4) man pages with some details and examples about the FDT/OFW support. Some compatibility details pointed out by imp@ will follow in subsequent commits. r261844: Allow the use of OFW I2C bus together with iicbb(4) on OFW-based systems. This change makes ofw_iicbus attach to iicbb(4) controllers in addition to the already supported i2c host bridges (iichb). On iicbb(4) allow the direct access of the OFW parent node by its children, so they can be directly attached to iicbb(4) node on the DTS without the need of describing the i2c bus. r261845: Allow the use of the OFW GPIO bus for ti_gpio and bcm2835_gpio. With this change the gpio children can be described as directly connected to the GPIO controller without the need of describing the OFW GPIO bus itself on the DTS file. With this commit the OFW GPIO bus is fully functional on BBB and RPi. GPIO controllers which want to use the OFW GPIO bus will need similar changes. r261846: Make the gpioled(4) work out of the box on BBB. Add gpioled(4) to BEAGLEBONE kernel and add the description of the four on-board leds of beaglebone-black to its DTS file. r262194: Remove an unnecessary header. r262522: Fix make depend for iicbus. r262559: Inspired by r262522, fix make depend. This fixes the build of gpio modules.
* Minor printf nit to keep out cleansbruno2013-09-051-1/+1
|
* Properly free gpiobus ivars when gpiobus_parse_pins() fails and also onloos2013-08-281-4/+18
| | | | | | | gpiobus detachment. Suggested by: imp Approved by: adrian (mentor)
* Style fixesgonzo2012-11-231-4/+3
| | | | | - Remove C++ - style comments - Use proper device name in panic messages
* Remove extra semicolon which rendered condition uselessgonzo2012-04-021-1/+1
| | | | Submitted by: Stefan Farfelder <stefanf@FreeBSD.org>
* Fix broken locking that I introduced in the previous commit.adrian2011-12-201-0/+2
|
* Remove these locks - they aren't strictly needed and cause measurableadrian2011-12-201-11/+0
| | | | | | | | | | | | | | | | | | | | performance issues. * Access to the GPIO bus is already locked by requesting and releasing the bus - thus the lock isn't really needed for each GPIO pin change. * Don't lock and unlock the GPIO bus for -each- i2c access - the i2c bus code is already doing this by calling the upper layer callback to request/release the bus. This thus locks the bus for the entirety of the transaction. TODO: * Further verify that everything is correctly requesting/ releasing the GPIO bus. * Look at how to lock the GPIO pin configuration stuff, potentially by locking/unlocking the bus at the gpiobus layer.
* Modify the GPIO i2c bus code to allow for arbitrary data/clockadrian2011-12-041-14/+22
| | | | | | | | | pins, rather than defaulting to 0 and 1. This way the pin order can be reversed. It is reversed with the TP-Link TL-WR1043nd. Submitted by: Stefan Bethke <stb@lassitu.de>
* Rename device_delete_all_children() into device_delete_children().hselasky2011-11-221-1/+1
| | | | | Suggested by: jhb @ and marius @ MFC after: 1 week
* - There's no need to overwrite the default device method with the defaultmarius2011-11-221-2/+1
| | | | | | | | | | one. Interestingly, these are actually the default for quite some time (bus_generic_driver_added(9) since r52045 and bus_generic_print_child(9) since r52045) but even recently added device drivers do this unnecessarily. Discussed with: jhb, marcel - While at it, use DEVMETHOD_END. Discussed with: jhb - Also while at it, use __FBSDID.
* Move the device_delete_all_children() function from usb_util.chselasky2011-11-191-7/+4
| | | | | | | | to kern/subr_bus.c. Simplify this function so that it no longer depends on malloc() to execute. Identify a few other places where it makes sense to use device_delete_all_children(). MFC after: 1 week
* Get rid of D_PSEUDO.ed2011-10-181-3/+0
| | | | | | | | | | It seems the D_PSEUDO flag was meant to allow make_dev() to return NULL. Nowadays we have a different interface for that; make_dev_p(). There's no need to keep it there. While there, remove an unneeded D_NEEDMINOR from the gpio driver. Discussed with: gonzo@ (gpio)
* Add a GPIO driver for the Gateworks Cambria platform.thompsa2010-11-112-2/+2
| | | | | | | | | The external gpio pins are connected to a PLD on the i2c bus, unfortunatley this device does not conform by failing to send an ack after each byte written. The iicbb driver will abort the transfer when the address is not ack'd and it would introduce a lot of churn to be able to pass a flag down to iicbb_start/iicbb_write. Instead we do bad things by grabbing the iicbus but then doing our own bit banging.
* Set the pin to output on attach, we can't assume it already is.thompsa2010-11-081-0/+3
| | | | Reviewed by: gonzo
* Fix legal staff in GPIO sources:gonzo2010-09-295-40/+70
| | | | | | | | - license clause now contains "AUTHOR AND CONTRIBUTORS" instead of just "AUTHOR" - Add license/copyright to gpioc.c Spotted by: Edward Tomasz Napierala, Andrew Turner
* Initial GPIO bus support. Includes:gonzo2010-09-287-0/+1332
- GPIO bus controller interface - GPIO bus interface - Implementation of GPIO led(4) compatible device - Implementation of iic(4) bus over GPIO (author: Luiz Otavio O Souza) Tested by: Luiz Otavio O Souza, Alexandr Rybalko
OpenPOWER on IntegriCloud