aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/gpio
Commit message (Collapse)AuthorAgeFilesLines
* INTRNG: As follow up of r301451, implement mapping and configurationMichal Meloun2016-06-072-10/+42
| | | | | | | | | | of gpio pin interrupts by new way. Note: This removes last consumer of intr_ddata machinery and we remove it in separate commit. Notes: svn path=/head/; revision=301539
* INTRNG - change the way how an interrupt mapping data are providedSvatopluk Kraus2016-06-051-0/+2
| | | | | | | | | | | to the framework in OFW (FDT) case. This is a follow-up to r301451. Differential Revision: https://reviews.freebsd.org/D6634 Notes: svn path=/head/; revision=301453
* Don't wrap the declaration of gpio_alloc_intr_resource() in #ifdef INTRNG,Ian Lepore2016-05-272-2/+8
| | | | | | | | | | | wrap the implementation so that it returns an error if INTRNG support is not available. It should be possible to write a non-INTRNG implementation of this function some day. In the meantime, there is code that contains calls to this function (so the decl is needed), but have runtime checks to avoid calling it in the non-INTRNG case. Notes: svn path=/head/; revision=300871
* Add a PPS driver that takes the timing pulse from a gpio pin. CurrentlyIan Lepore2016-05-261-0/+294
| | | | | | | | supports only ofw/fdt systems. Some day, hinted attachment for non-fdt systems should be possible too. Notes: svn path=/head/; revision=300811
* Add a convenience function to get a gpio pin's capabilties.Ian Lepore2016-05-262-0/+10
| | | | Notes: svn path=/head/; revision=300787
* Rename gpiobus_map_pin() to gpiobus_acquire_pin(), to better reflect theIan Lepore2016-05-263-7/+7
| | | | | | | | fact that the caller is requesting exclusive use of the pin, and also to better match the inverse operation which is named gpiobus_release_pin(). Notes: svn path=/head/; revision=300750
* [gpiospi] add initial gpio SPI bit bang driver.Adrian Chadd2016-05-261-0/+402
| | | | | | | | Submitted by: ray Obtained from: zrouter Notes: svn path=/head/; revision=300715
* Sort and remove a couple of unnecessary headers.Luiz Otavio O Souza2016-05-221-7/+3
| | | | Notes: svn path=/head/; revision=300393
* Get rid of two consumers of gpiobus acquire/release.Luiz Otavio O Souza2016-05-222-37/+3
| | | | | | | | | | | | | The GPIO hardware should not be owned by a single device, this defeats any chance of use of the GPIO controller as an interrupt source. ow(4) is now the only consumer of this 'feature' before we can remove it for good. Discussed with: ian, bsdimp Notes: svn path=/head/; revision=300392
* Use a better prefix for defines, return BUS_PROBE_DEFAULT for probe routine.Luiz Otavio O Souza2016-05-221-7/+18
| | | | | | | Refuse to attach if the number of given pins is not enough for our needs. Notes: svn path=/head/; revision=300391
* Fix probe routine to return BUS_PROBE_DEFAULT instead of BUS_PROBE_SPECIFIC.Luiz Otavio O Souza2016-05-221-6/+5
| | | | | | | While here fix a few style(9) issues. Notes: svn path=/head/; revision=300390
* OFWGPIOBUS: Make ofwgpiobus_devclass externaly visible.Michal Meloun2016-05-151-1/+1
| | | | | | | It's needed for binding of gpio controllers. Notes: svn path=/head/; revision=299853
* Fix detach routine for gpiokeysOleksandr Tymoshenko2016-05-121-3/+14
| | | | | | | | - Release pin only when all per=key callouts are stopped - Unregister keyboard when detaching device node Notes: svn path=/head/; revision=299566
* Properly release mapped pin in gpio_pin_releaseOleksandr Tymoshenko2016-05-121-0/+7
| | | | Notes: svn path=/head/; revision=299564
* Add gpiobus_release_pin function to release mapped pinOleksandr Tymoshenko2016-05-122-0/+25
| | | | | | | | | Add gpiobus_release_pin as a counterpart for gpiobus_map_pin. Without it it's impossible to properly release pin so if kernel module is reloaded it can't re-use pins again Notes: svn path=/head/; revision=299563
* Add OF_prop_free function as a counterpart for OF_*prop_allocOleksandr Tymoshenko2016-05-113-15/+15
| | | | | | | | | | | | | | | | | | | - Introduce new OF API function OF_prop_free to free memory allocated by OF_getprop_alloc and OF_getencprop_alloc. Current code just calls free(9) with M_OFWPROP memory class which assumes knowledge about OF_*prop_alloc functions' internals and leads to unneccessary code coupling - Convert some of the free(..., M_OFWPROP) instances to OF_prop_free Files affected by this commit are the ones I was able to test on real hardware. The rest of free(..., M_OFWPROP) instances will be handled with idividual maintainers Reviewed by: andrew Differential Revision: https://reviews.freebsd.org/D6315 Notes: svn path=/head/; revision=299477
* Add gpiokeys driverOleksandr Tymoshenko2016-05-113-0/+1191
| | | | | | | | | | | | | | | | | gpiokey driver implements functional subset of gpiokeys device-tree bindings: https://www.kernel.org/doc/Documentation/devicetree/bindings/input/gpio-keys.txt It acts as a virtual keyboard, so keys are visible through kbdmux(4) Driver maps linux scancodes for most common keys to FreeBSD scancodes and also extends spec by introducing freebsd,code property to specify FreeBSD-native scancodes. Reviewed by: mmel, jmcneill Differential Revision: https://reviews.freebsd.org/D6279 Notes: svn path=/head/; revision=299475
* Use DEVMETHOD_END instead of its value to indicate end of methods tableOleksandr Tymoshenko2016-05-113-3/+3
| | | | Notes: svn path=/head/; revision=299396
* Use GPIO pin management API in gpiobacklightOleksandr Tymoshenko2016-05-111-68/+29
| | | | | | | | | - Get rid of hack with re-parenting gpio-leds node to gpiobus - Use gpio_pin_set_active to enable/disable backlight, it automatically takes care of active-low pins Notes: svn path=/head/; revision=299395
* Pass device tree node as a part of gpio_pin_get_by_ofw_XXX APIOleksandr Tymoshenko2016-05-102-33/+26
| | | | | | | | | | | | | | Current API assumes that "gpios" property belongs to the device's node but for some binding it's not true: gpiokeys has set of child nodes with this property. Patch adds new argument instead of replacing device_t because device_t will be used to track ownership for allocated pins Reviewed by: mmel Differential Revision: https://reviews.freebsd.org/D6277 Notes: svn path=/head/; revision=299384
* INTRNG: Define 'INTR_IRQ_INVALID' constant and use it consistentlyMichal Meloun2016-04-281-1/+1
| | | | | | | as error indicator. Notes: svn path=/head/; revision=298739
* GPIO: Add support for gpio pin interrupts.Michal Meloun2016-04-282-0/+33
| | | | | | | | | | | | Add new function gpio_alloc_intr_resource(), which allows an allocation of interrupt resource associated to given gpio pin. It also allows to specify interrupt configuration. Note: This functionality is dependent on INTRNG, and must be implemented in each GPIO controller. Notes: svn path=/head/; revision=298738
* Fix IIC "how" argument dereferencing on big-endian platformsOleksandr Tymoshenko2016-04-101-1/+1
| | | | | | | | | | | | | | "how" argument is passed as value of int* pointer to callback function but dereferenced as char* so only one byte taken into into account. On little-endian systems it happens to work because first byte is LSB that contains actual value, on big-endian it's MSB and in this case it's always equal zero PR: 207786 Submitted by: chadf@triularity.org Notes: svn path=/head/; revision=297794
* Fix the resource_list_print_type() calls to use uintmax_t.Justin Hibbits2016-03-221-2/+2
| | | | | | | Missed a bunch from r297000. Notes: svn path=/head/; revision=297199
* Use EARLY_DRIVER_MODULE() with BUS_PASS_BUS priority for ofw_gpiobusMichal Meloun2016-03-151-1/+2
| | | | | | | | and ofw_iicbus. This causes enumeration of gpiobus/iicbus at the base driver attach time. Due to this, childern drivers can be also attached early. Notes: svn path=/head/; revision=296901
* OFW_GPIOBUS: Add utility functions for easier handling of OFW GPIO pins.Michal Meloun2016-03-012-0/+172
| | | | | | | Reviewed by: ian, loos (paritaly) Notes: svn path=/head/; revision=296269
* Introduce a RMAN_IS_DEFAULT_RANGE() macro, and use it.Justin Hibbits2016-02-201-1/+1
| | | | | | | | | | | | | | This simplifies checking for default resource range for bus_alloc_resource(), and improves readability. This is part of, and related to, the migration of rman_res_t from u_long to uintmax_t. Discussed with: jhb Suggested by: marcel Notes: svn path=/head/; revision=295832
* Convert rman to use rman_res_t instead of u_longJustin Hibbits2016-01-271-2/+2
| | | | | | | | | | | | | | | | | | | | | | | Summary: Migrate to using the semi-opaque type rman_res_t to specify rman resources. For now, this is still compatible with u_long. This is step one in migrating rman to use uintmax_t for resources instead of u_long. Going forward, this could feasibly be used to specify architecture-specific definitions of resource ranges, rather than baking a specific integer type into the API. This change has been broken out to facilitate MFC'ing drivers back to 10 without breaking ABI. Reviewed By: jhb Sponsored by: Alex Perez/Inertial Computing Differential Revision: https://reviews.freebsd.org/D5075 Notes: svn path=/head/; revision=294883
* [gpiobus] handle the case of there being a single GPIO pin available.Adrian Chadd2016-01-141-1/+1
| | | | | | | | PR: kern/206035 Submitted by: Stanislav Galabov <sgalabov@gmail.com> Notes: svn path=/head/; revision=293872
* Fix the use of plural in two cases that I missed on r285784.Luiz Otavio O Souza2015-08-181-2/+8
| | | | | | | This should cause no functional change. Notes: svn path=/head/; revision=286909
* gpioled(4) depends on gpiobus.Luiz Otavio O Souza2015-08-171-0/+1
| | | | | | | | | This fixes the loading of gpioled as a module. Sponsored by: Rubicon Communications (Netgate) Notes: svn path=/head/; revision=286847
* Fix a few bugs when gpiobus is detaching:Luiz Otavio O Souza2015-08-171-4/+14
| | | | | | | | | | | | | | | | | | - Detach the gpiobus and the gpioc devices from the GPIO controller. - Fix the leak of gpiobus IRQ rman(9) region descriptor. - Fix the leak of child ivars and IRQ resource list. While here return NULL (instead of 0) for a device_t that fails to allocate the ivar memory. Tested with gpiobus built as a module. Sponsored by: Rubicon Communications (Netgate) Notes: svn path=/head/; revision=286845
* Add GPIO backlight driver compatible with Linux FDT bindings.Oleksandr Tymoshenko2015-07-301-0/+211
| | | | | | | | | | | | Brightness is controlled through sysctl dev.gpiobacklight.X.brightness: - any value greater than 0: backlight is on - any value less than or equal to 0: backlight is off FDT bindings docs in Linux tree: Documentation/devicetree/bindings/video/backlight/gpio-backlight.txt Notes: svn path=/head/; revision=286089
* Panic when a device is trying to recursively acquire rather than hangWarner Losh2015-07-241-2/+11
| | | | | | | indefinitely. Improve error messages from other panics. Notes: svn path=/head/; revision=285833
* Cosmetic change. When printing the child's mapped pins, use the pluralLuiz Otavio O Souza2015-07-221-3/+8
| | | | | | | | | | only when necessary. Reported by: Daniel O'Connor <darius@dons.net.au>, Sulev-Madis Silber (ketas) Notes: svn path=/head/; revision=285784
* Use ofw_bus_find_child_device_by_phandle to see if the child we'reWarner Losh2015-06-201-0/+8
| | | | | | | | | | | | adding already exists and if so just return that. The typical use case is from identify routines, which shouldn't be adding multiple copies of the same phandle_t to the gpiobus. Only one per phandle_t is needed (or expected by the current code). Differential Revision: https://reviews.freebsd.org/D2871 Notes: svn path=/head/; revision=284625
* This implements default-state support as described in:Ganbold Tsagaankhuu2015-05-241-3/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://www.kernel.org/doc/Documentation/devicetree/bindings/leds/leds-gpio.txt Without this booting the VSATV102 causes the blue "working" led to turn off when the kernel starts up. With this the led (which is turned on by the firmware) stays on since that's the default state specified in the FDT. Expanded the meaning of the led_create_state state parameter in order to implement support for "keep". The original values were: == 0 Off != 0 On The new values are: == -1 don't change / keep current setting == 0 Off != -1 && != 0 On This should have no effect on acpi_asus_attach which only calls led_create_state with state set to 1. Updated acpi_ibm_attach in order to avoid surprises. Differential Revision: https://reviews.freebsd.org/D2615 Submitted by: John Wehle Reviewed by: gonzo, loos Notes: svn path=/head/; revision=283360
* Provide the number of interrupt resources added to the listRuslan Bukin2015-05-151-1/+1
| | | | | | | by using extra argument, so caller will know that. Notes: svn path=/head/; revision=282972
* Handle multiple "gpio-leds"-compatible nodesOleksandr Tymoshenko2015-04-021-8/+9
| | | | | | | | | | There are cases when gpioled nodes in DTS come from different sources (e.g. standard Beaglebone Black LEDs in main DTS + shield LEDs in overlay DTS) so instead of handling only first compatible node go through all child nodes Notes: svn path=/head/; revision=280978
* Add a new ioctl to allow the setting of GPIO pin names.Luiz Otavio O Souza2015-03-085-11/+101
| | | | | | | | | | | | | | | | When a gpiobus child is added, use its name to identify the mapped pin names. Make the respective changes to libgpio. Add a new '-n' flag to gpioctl(8) to set the pin name. Differential Revision: https://reviews.freebsd.org/D2002 Reviewed by: rpaulo Requested by: many Notes: svn path=/head/; revision=279761
* Use the child device name here is lame because at the point that thisLuiz Otavio O Souza2015-03-053-8/+6
| | | | | | | happens, the child device is not yet specified. Notes: svn path=/head/; revision=279622
* Change ofw_gpiobus_destroy_devinfo() to unmap the GPIO pins and thenLuiz Otavio O Souza2015-03-051-15/+24
| | | | | | | | | | | rework the code a little bit to use this function consistently to cleanup all the changes made as part of the probe phase. This fixes an issue where a FDT child node without a matching driver could leave the GPIO pins mapped and prevent the further use of them. Notes: svn path=/head/; revision=279621
* Add a bus_probe_nomatch() method for gpiobus/ofw_gpiobus.Luiz Otavio O Souza2015-03-051-0/+16
| | | | | | | | | | This prints a warning when your system have a hinted child or a FDT child node for which you don't have a matching driver: gpiobus0: <unknown device> at pin(s) 24 irq 24 Notes: svn path=/head/; revision=279620
* Move duplicate code to a new public function.Luiz Otavio O Souza2015-03-023-29/+29
| | | | | | | | | | | | This new function can be used by other drivers to reserve the use of GPIO pins. Anyway, the use of ofw_gpiobus_parse_gpios() is preferred when possible. Requested by: Michal Meloun Notes: svn path=/head/; revision=279553
* Add ofw_gpiobus_parse_gpios(), a new public function, to parse the gpiosLuiz Otavio O Souza2015-02-283-148/+211
| | | | | | | | | | | | | | | | property for devices that doesn't descend directly from gpiobus. The parser supports multiple pins, different GPIO controllers and can use arbitrary names for the property (to match the many linux variants: cd-gpios, power-gpios, wp-gpios, etc.). Pass the driver name on ofw_gpiobus_add_fdt_child(). Update gpioled to match. An usage example of ofw_gpiobus_parse_gpios() will follow soon. Notes: svn path=/head/; revision=279408
* Rename and move gpiobus_alloc_ivars() and gpiobus_free_ivars() so they canLuiz Otavio O Souza2015-02-283-48/+47
| | | | | | | | | | be used on non FDT systems. This prevents access to uninitialized memory on drivers that try to access pin flags on non FDT systems. Notes: svn path=/head/; revision=279402
* Register the GPIO controller device reference on xref table for FDT systems.Luiz Otavio O Souza2015-02-023-0/+27
| | | | Notes: svn path=/head/; revision=278108
* Implement GPIO_GET_BUS() method for all GPIO drivers.Luiz Otavio O Souza2015-01-312-0/+26
| | | | | | | | Add helper routines to deal with attach and detach of gpiobus and gpioc devices that are common to all drivers. Notes: svn path=/head/; revision=277996
* Implement a new method to retrieve the gpiobus reference from a GPIOLuiz Otavio O Souza2015-01-311-0/+14
| | | | | | | | | | | | | | | controller. The gpiobus is responsible to keep track of the used pins and serialize the access to pins. Some of these features are important to devices that do not descend directly from gpiobus and as such cannot make use of its features (one classic example is gpioc that is attached to the GPIO controller and could not, until now, make use of the gpiobus locking). Notes: svn path=/head/; revision=277980
* Improves the GPIO API description a little bit.Luiz Otavio O Souza2014-12-241-2/+2
| | | | | | | | | | | gpio_pin_max must return the maximum supported pin number and not the total number of pins on the system. PR: 157070 Submitted by: brix Notes: svn path=/head/; revision=276168