Commit Graph

55 Commits

Author SHA1 Message Date
mbalmer
57a529d87b When reading the bits from the I2C bus, also report SCL. Fixes PR43275.
Fix originally from Maxim Weber, thanks.
2011-07-23 09:03:38 +00:00
joerg
d4d21d35eb Annotate that gpiobus_close's return value is undesired here 2011-06-09 14:46:06 +00:00
ad
9b61e54ab7 console spam 2010-04-25 11:23:34 +00:00
dyoung
c1b390d493 A pointer typedef entails trading too much flexibility to declare const
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-02-24 22:37:54 +00:00
mbalmer
26bb6ca79d Unfold, bump copyright. 2010-01-24 12:25:20 +00:00
dyoung
3022acc4eb Expand PMF_FN_* macros. 2010-01-08 19:42:11 +00:00
dyoung
711b27c90c Delete unnecessary device-activation hooks. Simplify the rest. 2009-12-06 22:33:44 +00:00
dyoung
171b2851cf Simplify activation hook. 2009-11-12 19:22:08 +00:00
dyoung
bb8630fab4 Delete the useless activation hook. Add a child-detached hook and
a rescan hook.  Detach children before detaching self.
2009-11-05 18:20:40 +00:00
mbalmer
bf79ac9a26 Prevent the creation of duplicate pin names in GPIOSET.
Problem noticed by rmind a while ago.
2009-08-23 12:08:56 +00:00
mbalmer
adac122864 Before trying to attach a child device driver, make sure the GPIO pins can
be mapped.  This prevents drivers from later failing in the attach routine.
Problem found by me, solution suggested by jmcneill.
2009-08-21 12:53:42 +00:00
mbalmer
066a225399 unfold short lines, fold long line. 2009-08-17 12:44:44 +00:00
mbalmer
385b2e3631 Move the keylock.h header from sys/sys to sys/dev where it really belongs.
Add keylock options to the ALL kernel configuration.
2009-08-15 09:43:58 +00:00
mbalmer
3ab4ce4739 Add support for multi-position electro-mechanical keylocks. An example
driver, gpiolock(4), is provided as an example how to interface real hardware.
A new securemodel, securemodel_keylock, is provided to show how this can
be used to tie keylocks to overall system security.  This is experimental
code.  The diff has been on tech-kern for several weeks.

Reviewed by many, kauth(9) integration reviewed by Elad Efrat; approved by
tonnerre@ and tron@.  Thanks to everyone who provided feedback.
2009-08-14 21:17:21 +00:00
mbalmer
8fc23e3158 gpioiic(4), a driver to do use GPIO pins in bit-banging mode to form an I2C
bus.  Ported from OpenBSD.
2009-08-09 08:18:00 +00:00
mbalmer
fa4785b09a Register with the PMF, and when detaching, just the right order. 2009-08-08 10:38:17 +00:00
mbalmer
61e768bf92 Don't use an identifier name that probably clashes with the C standard.
Requested by many.
2009-08-07 08:15:52 +00:00
mbalmer
2ce40e808d Properly teardown the sysctl node and detach child driver if gpiosim gets
detached itself (e.g. when the 'drvctl -d gpiosimX' command is entered).
2009-08-07 08:08:18 +00:00
mbalmer
d2c70191a8 Fold long line. 2009-08-07 08:05:48 +00:00
mbalmer
133c6e2a65 For the sake of correctness, call pmf_device_deregister() in the detach
function.
2009-08-06 13:16:49 +00:00
mbalmer
4b41fced4d unfold short line; debracket 2009-08-03 17:24:40 +00:00
mbalmer
38b252cce6 Be more careful when attaching drivers at runtime, call the drivers match
routine before attaching the device.  Prevents non-working driver instances
from being created.
2009-08-03 12:43:56 +00:00
mbalmer
e1a16b3665 A better match routine that checks also the number of pins instead
of checking the pins in the attach routine; malconfigured devices will
no longer attach.  While here, replace some printf uses by aprint_....
2009-08-03 12:42:45 +00:00
drochner
c07937acdd add dummy pmf registration to allow suspend 2009-07-28 15:28:24 +00:00
mbalmer
9d8b69b23a Do not attach gpiosim(4) at root, but make it a pseudo device.
With help from Matthias Drochner, thanks!
2009-07-27 17:40:57 +00:00
mbalmer
bf5ef89e58 Fold long line, add comment to fix possible creation of duplicates. 2009-07-26 14:06:05 +00:00
mbalmer
9e8bcf597e Simplify the use _a lot_ by hooking this to sysctl instead of bio(4).
When it attaches, it creates a hw.gpiosimN.value sysctl node which can
then be used to manipulate the simulated device state.
2009-07-26 13:45:20 +00:00
cegger
97eb6082f5 use device_xname 2009-07-25 19:18:01 +00:00
cegger
585d03dbd7 make this build w/ GPIO_DEBUG 2009-07-25 19:01:55 +00:00
mbalmer
4e71b44621 Change one more struct device * to device_t, noticed by cegger. 2009-07-25 16:41:58 +00:00
mbalmer
3270b18844 Use device_t instead of struct device * per cegger's request. 2009-07-25 16:30:44 +00:00
mbalmer
8964d40bc5 Rework the GPIO framework. Tie it to the kauth(9) framework to control
access to the GPIO pins.  Device drivers using GPIO pins can now be
attached and detached at runtime.  GPIO pins can be named for easier
reference from userland programs.  Introduce a new gpiosim(4) driver,
which is used for development.

Reviewed by many.
2009-07-25 16:17:10 +00:00
dyoung
0d1ba3e899 During shutdown, detach devices in an orderly fashion.
Call the detach routine for every device in the device tree, starting
with the leaves and moving toward the root, expecting that each
(pseudo-)device driver will use the opportunity to gracefully commit
outstandings transactions to the underlying (pseudo-)device and to
relinquish control of the hardware to the system BIOS.

Detaching devices is not suitable for every shutdown: in an emergency,
or if the system state is inconsistent, we should resort to a fast,
simple shutdown that uses only the pmf(9) shutdown hooks and the
(deprecated) shutdownhooks.  For now, if the flag RB_NOSYNC is set in
boothowto, opt for the fast, simple shutdown.

Add a device flag, DVF_DETACH_SHUTDOWN, that indicates by its presence
that it is safe to detach a device during shutdown.  Introduce macros
CFATTACH_DECL3() and CFATTACH_DECL3_NEW() for creating autoconf
attachments with default device flags.  Add DVF_DETACH_SHUTDOWN
to configuration attachments for atabus(4), atw(4) at cardbus(4),
cardbus(4), cardslot(4), com(4) at isa(4), elanpar(4), elanpex(4),
elansc(4), gpio(4), npx(4) at isa(4), nsphyter(4), pci(4), pcib(4),
pcmcia(4), ppb(4), sip(4), wd(4), and wdc(4) at isa(4).

Add a device-detachment "reason" flag, DETACH_SHUTDOWN, that tells the
autoconf code and a device driver that the reason for detachment is
system shutdown.

Add a sysctl, kern.detachall, that tells the system to try to detach
every device at shutdown, regardless of any device's DVF_DETACH_SHUTDOWN
flag.  The default for kern.detachall is 0.  SET IT TO 1, PLEASE, TO
HELP TEST AND DEBUG DEVICE DETACHMENT AT SHUTDOWN.

This is a work in progress.  In future work, I aim to treat
pseudo-devices more thoroughly, and to gracefully tear down a stack of
(pseudo-)disk drivers and filesystems, including cgd(4), vnd(4), and
raid(4) instances at shutdown.

Also commit some changes that are not easily untangled from the rest:

(1) begin to simplify device_t locking: rename struct pmf_private to
device_lock, and incorporate device_lock into struct device.

(2) #include <sys/device.h> in sys/pmf.h in order to get some
definitions that it needs.  Stop unnecessarily #including <sys/device.h>
in sys/arch/x86/include/pic.h to keep the amd64, xen, and i386 releases
building.
2009-04-02 00:09:32 +00:00
cegger
c363a9cb62 bzero -> memset 2009-03-18 16:00:08 +00:00
gmcgarry
333aec56cb Both legs of a diagraph must return the same type. 2008-06-24 10:05:01 +00:00
dyoung
fef8b3ebea #include <sys/device.h> for device_t definition. 2008-05-27 19:26:27 +00:00
xtraeme
7ecae1b00d Finish device_t/softc split. Previous commit was incomplete. 2008-05-04 14:01:14 +00:00
cegger
8127f641e3 device_t / softc split. From Hans Rosenfeld. 2008-05-01 22:00:44 +00:00
cegger
b574865ea4 gpio(4): Extend with open/close to request/release the ppbus(4) on open/close.
ppbus(4): Extend to attach on gpiobus.
From Hans Rosenfeld from tech-kern:
http://mail-index.netbsd.org/tech-kern/2008/04/28/msg001168.html
Hint: Hans sent me this diff which differs in the one from tech-kern in:
- 2-clause license
- sprinkled some consts
2008-04-29 14:07:36 +00:00
dyoung
f612df5fb6 Use PMF_FN_ARGS, PMF_FN_PROTO. 2008-02-29 06:38:28 +00:00
dyoung
d3a283186c Use device_t. 2008-01-10 07:49:04 +00:00
dyoung
417afa7caa Bug fix: record the new state (high/low) set by gpio_pin_write().
I don't know why we gpio(4) didn't do that before, but it seems
harmless.

Add naive power handling: when a gpio(4) instance is resumed, write
each pin's configuration flags and output state from the softc to
the hardware using gpiobus_pin_ctl() and gpiobus_pin_write().
While suspended, fail every ioctl() except for GPIOINFO with EBUSY.
2007-12-14 01:49:23 +00:00
christos
53524e44ef Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
christos
168cd830d2 __unused removal on arguments; approved by core. 2006-11-16 01:32:37 +00:00
christos
4d595fd7b1 - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
2006-10-12 01:30:41 +00:00
christos
afca61baba add missing initializers 2006-08-30 02:09:40 +00:00
uwe
8398f3ff65 Whitespace nit. 2006-04-08 22:33:36 +00:00
riz
637bfc29f9 Dallas Semiconductor 1-Wire bus support, from OpenBSD. Currently includes
gpioow(4), attaching a bit-banging driver via a GPIO pin.  Also,
owtemp(4) which supports some of the 1-Wire temperature sensors, including
the DS18b20 and DS1920 - temperatures are returned via the envsys(4)
framework.

Original drivers by Alexander Yurchenko (grange@openbsd), with envsys(4)
support and a fix to the 1-wire search algorithm (for discovering
devices on the bus) by me.

As discussed on tech-kern earlier this week.
2006-04-07 18:55:21 +00:00
thorpej
92c7bba3df Use device_private(). 2006-03-29 06:28:38 +00:00
thorpej
39cd836ee1 Use device_unit(). 2006-03-28 17:38:24 +00:00