summaryrefslogtreecommitdiffstats
path: root/sys/dev/pcf
Commit message (Collapse)AuthorAgeFilesLines
* MFC r281828, r289083, r289084, r289091, r289093, r289095, r289097, r289098,ian2015-10-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r289104, r289105, r289118: various i2c fixes... Fix numerous issues in iic(4) and iicbus(4): --Allow multiple open iic fds by storing addressing state in cdevpriv --Fix, as much as possible, the baked-in race conditions in the iic ioctl interface by requesting bus ownership on I2CSTART, releasing it on I2CSTOP/I2CRSTCARD, and requiring bus ownership by the current cdevpriv to use the I/O ioctls --Reduce internal iic buffer size and remove 1K read/write limit by iteratively calling iicbus_read/iicbus_write --Eliminate dynamic allocation in I2CWRITE/I2CREAD --Move handling of I2CRDWR to separate function and improve error handling --Add new I2CSADDR ioctl to store address in current cdevpriv so that I2CSTART is not needed for read(2)/write(2) to work --Redesign iicbus_request_bus() and iicbus_release_bus(): --iicbus_request_bus() no longer falls through if the bus is already owned by the requesting device. Multiple threads on the same device may want exclusive access. Also, iicbus_release_bus() was never device-recursive anyway. --Previously, if IICBUS_CALLBACK failed in iicbus_release_bus(), but the following iicbus_poll() call succeeded, IICBUS_CALLBACK would not be issued again --Do not hold iicbus mtx during IICBUS_CALLBACK call. There are several drivers that may sleep in IICBUS_CALLBACK, if IIC_WAIT is passed. --Do not loop in iicbus_request_bus if IICBUS_CALLBACK returns EWOULDBLOCK; instead pass that to the caller so that it can retry if so desired. Bugfix: Exit the transfer loop if any read or write operation fails. Also, perform a stop operation on the bus if there was an error, otherwise the bus will remain hung forever. Consistantly use 'if (error != 0)' style in the function. Mostly rewrite the imx i2c driver. This started out as an attempt to fix one specific problem: the driver didn't check for ACK/NAK after writing a slave address byte to the bus, and some slaves signal that they are busy (such as when completing an internal write to flash memory) by sending a NAK in response to being addressed. Use IIC_EBUSBSY and IIC_BUSERR status values consistantly across all drivers. Make it clearer what each one means in the comments that define them. Add iic2errno(), a helper function to translate IIC_Exxxxx status values to errno values that are at least vaguely equivelent. Also add a new status value, IIC_ERESOURCE, to indicate a failure to acquire memory or other required resources to complete a transaction. Return only IIC_Exxxx status values from iicbus-layer functions. Most of these functions are thin wrappers around calling the hardware-layer driver, but some of them do sanity checks and return an error. Add a short name, IIC_INTRWAIT, for the common case (IIC_INTR | IIC_WAIT). Replace a local sx lock that allowed only one client at a time to access an eeprom device with iicbus_request/release_bus(), which achieves the same effect and also keeps other i2c slave drivers from clashing on the bus.
* Make ofw_bus_get_node() consistently return -1 when there is no associatednwhitehorn2012-03-151-1/+1
| | | | | | | OF node, instead of a random mixture of 0 and -1. Update all checks for 0 to check for -1 instead. MFC after: 4 weeks
* strict kobj signatures: fix iicbus_write impl in dev/pcfavg2009-06-112-2/+2
| | | | | | | input buf is const Reviewed by: imp, current@ Approved by: jhb (mentor)
* - Consolidate module version for the pcf module into just pcf.c insteadjhb2008-08-054-6/+6
| | | | | | | | | of having duplicate versions in each bus attachment. - Add a DRIVER_MODULE() instance so that the iicbus(4) driver will actually attach to pcf(4) driver instances. - Fix compile of envctrl.c. Pointy hat: jhb (3)
* Add locking to the various iicbus(4) bridge drivers:jhb2008-08-045-34/+82
| | | | | | | | | | | | | | | | | | | | | - Just grab Giant in the ixp425_iic(4) driver since this driver uses a shared address/data register window pair to access the actual I2C registers. None of the other ixp425 drivers lock access to these shared address/data registers yet and that would need to be done before this could use any meaningful locking. - Add locking to the interrupt handler and 'iicbus_reset' methods of the at91_twi(4) driver. - Add locking to the pcf(4) driver. Other pcf(4) fixes include: - Don't needlessly zero the softc. - Use bus_foo rather than bus_space_foo and remove bus space tag and handle from softc. - The lpbb(4) driver just grabs Giant for now. This will be refined later when ppbus(4) is locked. - As was done with smbus earlier, move the DRIVER_MODULE() lines to match the bus driver (either iicbus or iicbb) to the bridge driver into the bridge drivers. Tested by: sam (arm/ixp425)
* Don't call bus_deactivate_resource() explicitly before callingnyan2007-03-213-20/+0
| | | | | bus_release_resource(). This is needed for pc98 by upcoming nexus related change.
* o break newbus api: add a new argument of type driver_filter_t topiso2007-02-233-3/+3
| | | | | | | | | | | | | bus_setup_intr() o add an int return code to all fast handlers o retire INTR_FAST/IH_FAST For more info: http://docs.freebsd.org/cgi/getmsg.cgi?fetch=465712+0+current/freebsd-current Reviewed by: many Approved by: re@
* - Use bus_setup_intr() and bus_teardown_intr() to register device driverjhb2006-02-223-8/+6
| | | | | | | | | | interrupt handlers rather than BUS_SETUP_INTR() and BUS_TEARDOWN_INTR(). Uses of the BUS_*() versions in the implementation of foo_intr methods in bus drivers were not changed. Mostly this just means that some drivers might start printing diagnostic messages like [FAST] when appropriate as well as honoring mpsafenet=0. - Fix two more of the ppbus drivers' identify routines to function correctly in the mythical case of a machine with more than one ppbus.
* If the device has a PNPID, don't bother to attach. There were someimp2006-02-021-2/+5
| | | | instances where the probe that was here would falsely grab a device.
* Account for ebus(4) defaulting to SYS_RES_MEMORY for memory resourcesmarius2005-06-042-10/+10
| | | | since ebus.c rev. 1.22.
* - Introduce an ofw_bus kobj-interface for retrieving the OFW node and amarius2004-08-122-13/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | subset ("compatible", "device_type", "model" and "name") of the standard properties in drivers for devices on Open Firmware supported busses. The standard properties "reg", "interrupts" und "address" are not covered by this interface because they are only of interest in the respective bridge code. There's a remaining standard property "status" which is unclear how to support properly but which also isn't used in FreeBSD at present. This ofw_bus kobj-interface allows to replace the various (ebus_get_node(), ofw_pci_get_node(), etc.) and partially inconsistent (central_get_type() vs. sbus_get_device_type(), etc.) existing IVAR ones with a common one. This in turn allows to simplify and remove code-duplication in drivers for devices that can hang off of more than one OFW supported bus. - Convert the sparc64 Central, EBus, FHC, PCI and SBus bus drivers and the drivers for their children to use the ofw_bus kobj-interface. The IVAR- interfaces of the Central, EBus and FHC are entirely replaced by this. The PCI bus driver used its own kobj-interface and now also uses the ofw_bus one. The IVARs special to the SBus, e.g. for retrieving the burst size, remain. Beware: this causes an ABI-breakage for modules of drivers which used the IVAR-interfaces, i.e. esp(4), hme(4), isp(4) and uart(4), which need to be recompiled. The style-inconsistencies introduced in some of the bus drivers will be fixed by tmm@ in a generic clean-up of the respective drivers later (he requested to add the changes in the "new" style). - Convert the powerpc MacIO bus driver and the drivers for its children to use the ofw_bus kobj-interface. This invloves removing the IVARs related to the "reg" property which were unused and a leftover from the NetBSD origini of the code. There's no ABI-breakage caused by this because none of these driver are currently built as modules. There are other powerpc bus drivers which can be converted to the ofw_bus kobj-interface, e.g. the PCI bus driver, which should be done together with converting powerpc to use the OFW PCI code from sparc64. - Make the SBus and FHC front-end of zs(4) and the sparc64 eeprom(4) take advantage of the ofw_bus kobj-interface and simplify them a bit. Reviewed by: grehan, tmm Approved by: re (scottl) Discussed with: tmm Tested with: Sun AX1105, AXe, Ultra 2, Ultra 60; PPC cross-build on i386
* Unbreak after struct resource was hidden. Tested with EBus front-end onmarius2004-08-114-15/+19
| | | | Sun AXe board.
* Consistently use __inline instead of __inline__ as the former is an empty macrostefanf2004-07-041-4/+4
| | | | in <sys/cdefs.h> for compilers without support for inline.
* Add a first version of a pcf(4) front-end for the Sun i2c devices ("i2c"marius2004-06-101-0/+261
| | | | | | | | | | | | | | | | | | | is the actual name here) on EBus and which are PCF8584 (on systems having a boot-bus controller the i2c are said to not be a PCF8584). Similar to the SUNW,envctrl devices, onboard slaves for monitoring fans, temperatures and such hang off of these i2c devices. But there's also stuff like EEPROMs housing the hostid of the system and the boards usally have a connector to add custom slave devices (on CP1500 there's actually a second PCF8584 with its own I2C bus for these). This driver already works fine but I'm not yet sure if access to the slave devices on CP1400/CP1500 marked as "reserved for factory use" in the docs should be blocked (most likely these are the voltage controllers wich aren't meant to be controller by software and even not by the firmware). Once the issues with polled mode are fixed in the common pcf(4) part in pcf.c, this front-end should probably honour the poll-mode property of the i2c devices. Tested on Ultra AXe and CP1500 (Netra t1 100). OK'ed by: joerg, nsouch
* - Add missing <sys/module.h>.marius2004-06-101-3/+4
| | | | | | | | - Use "envctrl" as the name when registering this module rather than "pcf"; we can't have "pcf" as the name for all pcf(4) front-ends or we would get conflicts. OK'ed by: joerg
* - Add missing <sys/module.h>.marius2004-06-101-20/+20
| | | | | | | | | - s,pcf_,pcf_isa, to better reflect the purpose of this front-end and to avoid conflicts. - Don't use this front-end for attaching to EBus, declaring it as an EBus driver was a cut&paste accident according to joerg. OK'ed by: joerg, nsouch
* - #define\tFOO\tBARmarius2004-06-101-2/+2
| | | | | | - Remove two tabs from an otherwise empty line. OK'ed by: nsouch
* Necessary modifications do get pcf working again for ISA. Tested withnsouch2004-05-312-15/+55
| | | | | | | | | | my Elektor card. Note that the hints are necessary to specify the IO base of the pcf chip. This enables to check the IO base when the probe routine is called during ISA enumeration. The interrupt driven code is mixed with polled mode, which is wrong and produces supposed spurious interrupts at each access. I still have to work on it.
* Round #1 of improving pcf(4).joerg2004-05-254-320/+645
| | | | | | | | | | | | This splits the driver into a bus-independant backend, plus bus-specific frontends. The old pcf(4) (i386/ISA) frontend is now in pcf_isa.c, the frontend in envctrl.c is for sparc64/Ebus2 (Sun device name: SUNW,envctrl from Sun E450 machines). More frontends are expected to appear in future. This is not yet ready for public consumption, but it basically works. Nicolas will bring over his ISA-specific fixes soon. Reviewed by: nsouch
* Remove isa compat stuff.imp2004-03-141-2/+0
| | | | | | | Only cy, bs and wd in the tree still use it. I have a replacement for cy that I need to test on ISA and PCI cards. bs and wd are pc98 only drivers that appear to no longer be necessary. I'll be removing them when I hear back from the pc98 people.
* fix another LP64 problem. READ_IVAR takes a pointer to an uintptr_t, notjmg2003-06-201-1/+3
| | | | an int.
* Use __FBSDID().obrien2003-06-021-3/+4
|
* Correct typos, mostly s/ a / an / where appropriate. Some whitespace cleanup,schweikh2003-01-011-1/+1
| | | | especially in troff files.
* Fix bktr and pcf compilation with LINTnsouch2002-03-251-2/+2
|
* Update to C99, s/__FUNCTION__/__func__/,obrien2001-12-101-1/+1
| | | | also don't use ANSI string concatenation.
* Remove unneeded #include <machine/clock.h>phk2000-10-151-1/+0
|
* Remove ~25 unneeded #include <sys/conf.h>phk2000-04-191-1/+0
| | | | Remove ~60 unneeded #include <sys/malloc.h>
* Port of ppbus standalone framework to the newbus system.nsouch2000-01-141-76/+64
| | | | | | | | | | | | | | | | | | | | | Note1: the correct interrupt level is invoked correctly for each driver. For this purpose, drivers request the bus before being able to call BUS_SETUP_INTR and BUS_TEARDOWN_INTR call is forced by the ppbus core when drivers release it. Thus, when BUS_SETUP_INTR is called at ppbus driver level, ppbus checks that the caller owns the bus and stores the interrupt handler cookie (in order to unregister it later). Printing is impossible while plip link is up is still TRUE. vpo (ZIP driver) and lpt are make in such a way that using the ZIP and printing concurrently is permitted is also TRUE. Note2: specific chipset detection is not done by default. PPC_PROBE_CHIPSET is now needed to force chipset detection. If set, the flags 0x40 still avoid detection at boot. Port of the pcf(4) driver to the newbus system (was previously directly connected to the rootbus and attached by a bogus pcf_isa_probe function).
* Remove the 'ivars' arguement to device_add_child() andmdodd1999-12-031-1/+1
| | | | | | | | | | | | | | | | device_add_child_ordered(). 'ivars' may now be set using the device_set_ivars() function. This makes it easier for us to change how arbitrary data structures are associated with a device_t. Eventually we won't be modifying device_t to add additional pointers for ivars, softc data etc. Despite my best efforts I've probably forgotten something so let me know if this breaks anything. I've been running with this change for months and its been quite involved actually isolating all the changes from the rest of the local changes in my tree. Reviewed by: peter, dfr
* Trim some unused #includespeter1999-10-111-1/+0
| | | | Submitted by: phk
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* Alter the behavior of sys/kern/subr_bus.c:device_print_child()mdodd1999-07-291-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - device_print_child() either lets the BUS_PRINT_CHILD method produce the entire device announcement message or it prints "foo0: not found\n" Alter sys/kern/subr_bus.c:bus_generic_print_child() to take on the previous behavior of device_print_child() (printing the "foo0: <FooDevice 1.1>" bit of the announce message.) Provide bus_print_child_header() and bus_print_child_footer() to actually print the output for bus_generic_print_child(). These functions should be used whenever possible (unless you can just use bus_generic_print_child()) The BUS_PRINT_CHILD method now returns int instead of void. Modify everything else that defines or uses a BUS_PRINT_CHILD method to comply with the above changes. - Devices are 'on' a bus, not 'at' it. - If a custom BUS_PRINT_CHILD method does the same thing as bus_generic_print_child(), use bus_generic_print_child() - Use device_get_nameunit() instead of both device_get_name() and device_get_unit() - All BUS_PRINT_CHILD methods return the number of characters output. Reviewed by: dfr, peter
* Move the declaration of the interrupt type from the driver structuredfr1999-05-081-2/+1
| | | | to the BUS_SETUP_INTR call.
* Missing 'int' in declaration of variables.peter1999-05-061-2/+2
|
* Operator precedence bugpeter1999-05-021-2/+2
| | | | | PR: 11411 Submitted by: Christopher Peterson <cpeterso@cs.washington.edu>
* The "easy" fixes for compiling the kernel -Wunused: remove unreferenced staticarchie1998-12-071-3/+1
| | | | and local variables, goto labels, and functions declared but not defined.
* iicbus probe and attach deferred until root_bus_configure() call.nsouch1998-11-041-5/+1
|
* Fixup prototypes so that this beastie compiles.peter1998-10-311-4/+4
|
* pcf.c: timeout management addednsouch1998-10-311-47/+90
| | | | ppc.c: nsc code improved. Actually, a complete rewrite.
* Initialize isa_devtab entries for interrupt handlers in individualbde1998-10-221-2/+4
| | | | | | | device drivers, not in ioconf.c. Use a different hack in isa_device.h so that a new config(8) is not required yet. pc98 parts approved by: kato
* Reviewed by: Doug Rabsonnsouch1998-09-031-0/+607
Submitted by: nsouch Philips PCF8584 chipset support. Chipset controller for the I2C bus.
OpenPOWER on IntegriCloud