summaryrefslogtreecommitdiffstats
path: root/sys/dev/gpio
Commit message (Collapse)AuthorAgeFilesLines
* Add initial GPIO PWM support.Luiz Souza2017-07-172-3/+121
| | | | (cherry picked from commit a70ecde4228d0d6f81b0eb8117e102d01a9a36eb)
* MFC r310017-r310018mizhka2017-03-151-0/+2
| | | | | | | | | | | | | | | | | | | | | | r310017: [spi] reformat message and ar5315_spi minor fix This commit corrects print of nomatch (newline was too early) and fix unit number for new child in ar5315_spi (was 0, now is -1 to calculate it according to actual system state) Submitted by: Hiroki Mori <yamori813@yahoo.co.jp> Reviewed by: ray, loos, mizhka MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D8749 r310018: [gpiospi] add clock delay to avoid smashing of bits Submitted by: Hiroki Mori <yamori83@yahoo.co.jp> Reviewed by: loos, ray, mizhka MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D8749
* MFC r311658:ian2017-03-011-2/+3
| | | | Only write to *active once, even when GPIO_ACTIVE_LOW is set.
* MFC r311701:loos2017-01-131-5/+12
| | | | | | | Convert gpioc to use the make_dev_s(9) KPI. This fix a possible race where si_drv1 can be accessed before it gets set. This was inspired on r311700.
* MFC r310000:loos2016-12-311-3/+3
| | | | | | | Remove a too strict test and instead, just filter the passed flags with the supported capabilities. Spotted by: yamori813@yahoo.co.jp (Hiroki Mori)
* MFC r308898, r308940, r308942, r308944, r309112gonzo2016-12-011-36/+280
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r308898: [bytgpio] Fix USB disconnect event after listsing pins on gpioc2 - Do not set input flag when reading value from GPIO pin, it is not required and for gpioc2(S5 bank) setting both input and output flags leads to some kind of electric interference (curren drop?) that causes USB devices to disconnect - Check pad configuration when attaching device and provide IN/OUT capabilities only for pads that are configured as GPIO. Do not let user code to configure or change value of non-GPIO pads. There is no information for NC bank in intel's datasheet so for now function check is ignored for pins in it Reported by: Frank H. MFC after: 3 days r308940: [bytgpio] prepare bytgpio(4) for modularization - Add detach method - module should depend on gpiobus, not gpio r308942: [bytgpio] Add module for bytgpio(4) MFC after: 3 days r308944 by hiren@: r308942 broke kernel build. Add acpi_if.h to module makefile to fix it. Submitted by: peter r309112: [bytgpio] Fix pc98 build by disabling bytgpio module for this platform Reported by: dim
* MFC r308295:gonzo2016-11-151-0/+435
| | | | | | | | | | | [gpio] Add GPIO driver for Intel Bay Trail SoC Bay Trail has three banks of GPIOs exposed to userland as /dev/gpiocN, where N is 1, 2, and 3. Pins in each bank are pre-named to match names on boards schematics: GPIO_S0_SCnn, GPIO_S0_NCnn, and GPIO_S5_nn. Controller supports edge-triggered and level-triggered interrupts but current version of the driver does not have interrupts support
* MFC r308428:gonzo2016-11-152-99/+230
| | | | | | | | | | | Refactor FDT part of gpioled driver - Split driver in two parts: FDT and non-FDT - Instead of reattach gpioled nodes to GPIO bus use gpio_pin_get_by_ofw_idx and add ofwbus and simplebus as parrent buses Reviewed by: loos Differential Revision: https://reviews.freebsd.org/D8233
* MFC r304459,r305527:mmel2016-11-053-23/+8
| | | | | | | | | | | | | | | | | | r304459: INTRNG: Rework handling with resources. Partially revert r301453. - Read interrupt properties at bus enumeration time and store it into global mapping table. - At bus_activate_resource() time, given mapping entry is resolved and connected to real interrupt source. A copy of mapping entry is attached to given resource. - At bus_setup_intr() time, mapping entry stored in resource is used for delivery of requested interrupt configuration. - For MSI/MSIX interrupts, mapping entry is created within pci_alloc_msi()/pci_alloc_msix() call. - For legacy PCI interrupts, mapping entry must be created within pcib_route_interrupt() by pcib driver itself. r305527: Fix MIPS INTRNG (both FDT and non-FDT) behaviour broken by r304459
* INTRNG: As follow up of r301451, implement mapping and configurationmmel2016-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.
* INTRNG - change the way how an interrupt mapping data are providedskra2016-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
* Don't wrap the declaration of gpio_alloc_intr_resource() in #ifdef INTRNG,ian2016-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.
* Add a PPS driver that takes the timing pulse from a gpio pin. Currentlyian2016-05-261-0/+294
| | | | | supports only ofw/fdt systems. Some day, hinted attachment for non-fdt systems should be possible too.
* Add a convenience function to get a gpio pin's capabilties.ian2016-05-262-0/+10
|
* Rename gpiobus_map_pin() to gpiobus_acquire_pin(), to better reflect theian2016-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().
* [gpiospi] add initial gpio SPI bit bang driver.adrian2016-05-261-0/+402
| | | | | Submitted by: ray Obtained from: zrouter
* Sort and remove a couple of unnecessary headers.loos2016-05-221-7/+3
|
* Get rid of two consumers of gpiobus acquire/release.loos2016-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
* Use a better prefix for defines, return BUS_PROBE_DEFAULT for probe routine.loos2016-05-221-7/+18
| | | | Refuse to attach if the number of given pins is not enough for our needs.
* Fix probe routine to return BUS_PROBE_DEFAULT instead of BUS_PROBE_SPECIFIC.loos2016-05-221-6/+5
| | | | While here fix a few style(9) issues.
* OFWGPIOBUS: Make ofwgpiobus_devclass externaly visible.mmel2016-05-151-1/+1
| | | | It's needed for binding of gpio controllers.
* Fix detach routine for gpiokeysgonzo2016-05-121-3/+14
| | | | | - Release pin only when all per=key callouts are stopped - Unregister keyboard when detaching device node
* Properly release mapped pin in gpio_pin_releasegonzo2016-05-121-0/+7
|
* Add gpiobus_release_pin function to release mapped pingonzo2016-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
* Add OF_prop_free function as a counterpart for OF_*prop_allocgonzo2016-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
* Add gpiokeys drivergonzo2016-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
* Use DEVMETHOD_END instead of its value to indicate end of methods tablegonzo2016-05-113-3/+3
|
* Use GPIO pin management API in gpiobacklightgonzo2016-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
* Pass device tree node as a part of gpio_pin_get_by_ofw_XXX APIgonzo2016-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
* INTRNG: Define 'INTR_IRQ_INVALID' constant and use it consistentlymmel2016-04-281-1/+1
| | | | as error indicator.
* GPIO: Add support for gpio pin interrupts.mmel2016-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.
* Fix IIC "how" argument dereferencing on big-endian platformsgonzo2016-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
* Fix the resource_list_print_type() calls to use uintmax_t.jhibbits2016-03-221-2/+2
| | | | Missed a bunch from r297000.
* Use EARLY_DRIVER_MODULE() with BUS_PASS_BUS priority for ofw_gpiobusmmel2016-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.
* OFW_GPIOBUS: Add utility functions for easier handling of OFW GPIO pins.mmel2016-03-012-0/+172
| | | | Reviewed by: ian, loos (paritaly)
* Introduce a RMAN_IS_DEFAULT_RANGE() macro, and use it.jhibbits2016-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
* Convert rman to use rman_res_t instead of u_longjhibbits2016-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
* [gpiobus] handle the case of there being a single GPIO pin available.adrian2016-01-141-1/+1
| | | | | PR: kern/206035 Submitted by: Stanislav Galabov <sgalabov@gmail.com>
* Fix the use of plural in two cases that I missed on r285784.loos2015-08-181-2/+8
| | | | This should cause no functional change.
* gpioled(4) depends on gpiobus.loos2015-08-171-0/+1
| | | | | | This fixes the loading of gpioled as a module. Sponsored by: Rubicon Communications (Netgate)
* Fix a few bugs when gpiobus is detaching:loos2015-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)
* Add GPIO backlight driver compatible with Linux FDT bindings.gonzo2015-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
* Panic when a device is trying to recursively acquire rather than hangimp2015-07-241-2/+11
| | | | indefinitely. Improve error messages from other panics.
* Cosmetic change. When printing the child's mapped pins, use the pluralloos2015-07-221-3/+8
| | | | | | | only when necessary. Reported by: Daniel O'Connor <darius@dons.net.au>, Sulev-Madis Silber (ketas)
* Use ofw_bus_find_child_device_by_phandle to see if the child we'reimp2015-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
* This implements default-state support as described in:ganbold2015-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
* Provide the number of interrupt resources added to the listbr2015-05-151-1/+1
| | | | by using extra argument, so caller will know that.
* Handle multiple "gpio-leds"-compatible nodesgonzo2015-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
* Add a new ioctl to allow the setting of GPIO pin names.loos2015-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
* Use the child device name here is lame because at the point that thisloos2015-03-053-8/+6
| | | | happens, the child device is not yet specified.
OpenPOWER on IntegriCloud