Commit Graph

21 Commits

Author SHA1 Message Date
Luiz Otavio O Souza
9a2a079a51 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.

Approved by:	adrian (mentor, implicit)
2014-02-13 17:58:52 +00:00
Luiz Otavio O Souza
6d866ed35b 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.

Approved by:	adrian (mentor, implicit)
2014-02-13 17:08:29 +00:00
Luiz Otavio O Souza
d442709662 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.

Approved by:	adrian (mentor)
2013-12-06 17:56:20 +00:00
Luiz Otavio O Souza
41ec463c1e Remove unnecessary includes and an unused softc variable. While here apply
two minor style(9) fixes.

Approved by:	adrian (mentor)
2013-12-06 17:49:34 +00:00
Luiz Otavio O Souza
ea5d5118ae 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.

Approved by:	adrian (mentor)
2013-11-12 16:08:23 +00:00
Luiz Otavio O Souza
a1f621566e Move the KASSERT() check to the point before the increase of number of pins.
Approved by:	adrian (mentor)
2013-11-12 13:55:19 +00:00
Sean Bruno
7befb5c2ca Minor printf nit to keep out clean 2013-09-05 16:38:26 +00:00
Luiz Otavio O Souza
72405c6be0 Properly free gpiobus ivars when gpiobus_parse_pins() fails and also on
gpiobus detachment.

Suggested by:	imp
Approved by:	adrian (mentor)
2013-08-28 14:39:24 +00:00
Oleksandr Tymoshenko
12ad19bc4c Style fixes
- Remove C++ - style comments
- Use proper device name in panic messages
2012-11-23 19:20:38 +00:00
Oleksandr Tymoshenko
6de0a4fa84 Remove extra semicolon which rendered condition useless
Submitted by:	Stefan Farfelder <stefanf@FreeBSD.org>
2012-04-02 00:11:26 +00:00
Adrian Chadd
74ab90b71e Fix broken locking that I introduced in the previous commit. 2011-12-20 03:25:11 +00:00
Adrian Chadd
ddd7699151 Remove these locks - they aren't strictly needed and cause measurable
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.
2011-12-20 00:33:56 +00:00
Adrian Chadd
935225501b Modify the GPIO i2c bus code to allow for arbitrary data/clock
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>
2011-12-04 12:10:24 +00:00
Hans Petter Selasky
3b12bdb58f Rename device_delete_all_children() into device_delete_children().
Suggested by:	jhb @ and marius @
MFC after:	1 week
2011-11-22 21:56:55 +00:00
Marius Strobl
4b7ec27007 - There's no need to overwrite the default device method with the default
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.
2011-11-22 21:28:20 +00:00
Hans Petter Selasky
11bcf702f4 Move the device_delete_all_children() function from usb_util.c
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
2011-11-19 10:11:50 +00:00
Ed Schouten
a185bd12f3 Get rid of D_PSEUDO.
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)
2011-10-18 08:09:44 +00:00
Andrew Thompson
54873b4cd6 Add a GPIO driver for the Gateworks Cambria platform.
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.
2010-11-11 20:18:33 +00:00
Andrew Thompson
cac6df751b Set the pin to output on attach, we can't assume it already is.
Reviewed by:	gonzo
2010-11-08 03:08:01 +00:00
Oleksandr Tymoshenko
5f958b8534 Fix legal staff in GPIO sources:
- license clause now contains "AUTHOR AND CONTRIBUTORS"
        instead of just "AUTHOR"
    - Add license/copyright to gpioc.c

Spotted by: Edward Tomasz Napierala, Andrew Turner
2010-09-29 20:53:33 +00:00
Oleksandr Tymoshenko
6b34b16ea5 Initial GPIO bus support. Includes:
- 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
2010-09-28 03:24:53 +00:00