summaryrefslogtreecommitdiffstats
path: root/sys/dev/iicbus/iicbus.c
Commit message (Collapse)AuthorAgeFilesLines
* Allow i2c bus speed to be configured via hints, FDT data, and sysctl.ian2014-11-181-0/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current support for controlling i2c bus speed is an inconsistant mess. There are 4 symbolic speed values defined, UNKNOWN, SLOW, FAST, FASTEST. It seems to be universally assumed that SLOW means the standard 100KHz rate from the original spec. Nothing ever calls iicbus_reset() with a speed of FAST, although some drivers would treat it as the 400KHz standard speed. Mostly iicbus_reset() is called with the speed set to UNKNOWN or FASTEST, and there's really no telling what any individual driver will do with those. The speed of an i2c bus is limited by the speed of the slowest device on the bus. This means that generally the bus speed needs to be configured based on the board/system and the components within it. Historically for i2c we've configured with device hints. Newer systems use FDT data and it documents a clock-frequency property for i2c busses. Hobbyists and developers are likely to want on the fly changes. These changes provide all 3 methods, but do not require any existing drivers to change to use the new facilities. This adds an iicbus method, iicbus_get_frequency(dev, speed) that gets the frequency for the requested symbolic speed. If the symbolic speed is SLOW or if there is no speed configured for the bus, the returned value is 100KHz, always. Otherwise, if bus speed is configured by hints, fdt, tunable, or sysctl, that speed is returned. It also adds a helper function, iicbus_init_frequency() that any bus driver subclassed from iicbus can initialize the frequency from some other source of info. Initial driver implementations are provided for Freescale and TI. Differential Revision: https://reviews.freebsd.org/D1174 PR: 195009
* Allow the i2c node requirements to be slightly relaxed.adrian2011-12-041-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | These realtek switch PHYs speak a variant of i2c with some slightly modified handling. From the submitter, slightly modified now that some further digging has been done: The I2C framework makes a assumption that the read/not-write bit of the first byte (the address) indicates whether reads or writes are to follow. The RTL8366 family uses the bus: after sending the address+read/not-write byte, two register address bytes are sent, then the 16-bit register value is sent or received. While the register write access can be performed as a 4-byte write, the read access requires the read bit to be set, but the first two bytes for the register address then need to be transmitted. This patch maintains the i2c protocol behaviour but allows it to be relaxed (for these kinds of switch PHYs, and whatever else Realtek may do with this almost-but-not-quite i2c bus) - by setting the "strict" hint to 0. The "strict" hint defaults to 1. Submitted by: Stefan Bethke <stb@lassitu.de>
* - There's no need to overwrite the default device method with the defaultmarius2011-11-221-2/+1
| | | | | | | | | | 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.
* bus_add_child: change type of order parameter to u_intavg2010-09-101-1/+1
| | | | | | | | | | This reflects actual type used to store and compare child device orders. Change is mostly done via a Coccinelle (soon to be devel/coccinelle) semantic patch. Verified by LINT+modules kernel builds. Followup to: r212213 MFC after: 10 days
* Fix iicbus_get_addr() on 64-bit big-endian systems. The bus accessornwhitehorn2010-07-081-1/+1
| | | | passes a uintptr_t, not a uint32_t.
* Fix iicbus_intr, iicbus_write and device_read_ivar prototypes...imp2009-02-101-1/+1
|
* Change the probe priority for PCI and I2C generic bus modules fromnwhitehorn2009-01-201-1/+1
| | | | | | numerical constants to BUS_PROBE_GENERIC. Suggested by: jhb
* Import an Open Firmware I2C bus module. This attaches firmware device treenwhitehorn2009-01-151-0/+2
| | | | | | | | indicated I2C devices, and provides an ofw_bus interface for driver probing. This should be MI, but is currently provided only on PowerPC due to lack of sparc64 hardware with an I2C controller. Discussed on: freebsd-arch
* Change the way I2C bus attachment works to allow firmware-assisted busnwhitehorn2009-01-061-1/+3
| | | | | | | | | subclasses as are available with PCI. Changes I2C device drivers without real probe logic to return BUS_PROBE_NOWILDWARD to avoid interference with firmware bus enumeration, and reduces the probe priority of the iicbus base driver to allow subclass attachment at higher priority. Discussed on: freebsd-arch
* Add locking to the core iicbus(4) drivers:jhb2008-08-041-8/+6
| | | | | | | | | | | | | | | | | | - Add an sx lock to the iic(4) driver to serialize open(), close(), read(), and write and to protect sc_addr and sc_count in the softc. - Use cdev->si_drv1 instead of using the minor number of the cdev to lookup the softc via newbus in iic(4). - Store the device_t in the softc to avoid a similar detour via minor numbers in iic(4). - Only add at most one instance of iic(4) and iicsmb(4) to each iicbus(4) instance, and do it in the child driver. - Add a mutex to the iicbus(4) softc to synchronize the request/release bus stuff. - Use __BUS_ACCESSOR() for IICBUS_ACCESSOR() instead of rolling our own. - Add a mutex to the iicsmb(4) softc to protect softc state updated in the interrupt handler. - Remove Giant from all the smbus methods in iicsmb(4) now that all the iicbus(4) backend is locked.
* MFp4: Make the iicbus fully hinted. We no longer automatically addimp2007-03-231-46/+119
| | | | | | | | | | | some devices (and not others). To get instances onto the iicbus, one now needs hints or an identify routine. We also do not probe the bus for devices because many iic devices cannot be safely probed (and when they can, the probe order turns out to be somewhat difficult to get right). # I'm not 100% sure that the iicsmb removal is right. Please contact me if # this causes difficulty.
* o define transfer methodsam2006-11-191-0/+4
| | | | | | o attach ds1672 and ad7418, to be cleaned up MFC after: 1 month
* Allow iic bridges to support a generalized transfer, rather thanimp2006-07-141-11/+12
| | | | | | | | | forcing all transfers to do the start read/write stop by hand. Some smart bridges prefer this sort of operation, and this allows us to support their features more easily. When bridges don't support it, we fall back to using the old-style opertaions. Expand the ioctl interface to expose this function. Unlike the old-style interface, this interface is thread safe, even on old bridges.
* remove DRIVER_MODULE lines that are useless... pcf doesn't exist (onlyjmg2006-04-171-2/+0
| | | | | | | as pcf_ebus and pcf_isa, they should probably be fixed back to pcf), and bti2c doesn't exist, bktr has smbus or iicbb as children.. Brought to you by: http://people.FreeBSD.org/~jmg/driver.pdf
* Make "envctrl" a known master driver for iicbus.joerg2004-05-271-0/+1
|
* After successfully attaching an iicbus instance, instead of using ajoerg2004-05-161-1/+3
| | | | | | | | | NULL name in device_add_child(), explicitly name all of our known child drivers in order to give them a chance to attach to us. Otherwise, only the first one present would be probed and attached. Reviewed by: nsouch MFC after: 1 month
* Convert the #if 0 magic to #if SCAN_IICBUS, and make it actually compilejoerg2004-05-121-3/+10
| | | | | again. While it's not generally recommended anymore, it might still prove useful for debugging purposes.
* Use __FBSDID().obrien2003-08-241-3/+3
| | | | Also some minor style cleanups.
* Major rework of the iicbus/smbus framework:nsouch2002-03-231-135/+31
| | | | | | | | - VIA chipset SMBus controllers added - alpm driver updated - Support for dynamic modules added - bktr FreeBSD smbus updated but not tested - cleanup
* Update to C99, s/__FUNCTION__/__func__/,obrien2001-12-101-2/+2
| | | | also don't use ANSI string concatenation.
* Remove unneeded #include <machine/clock.h>phk2000-10-151-1/+0
|
* Remove the 'ivars' arguement to device_add_child() andmdodd1999-12-031-2/+2
| | | | | | | | | | | | | | | | 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
* Sync with RELENG_3.nsouch1999-11-011-1/+1
|
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* Alter the behavior of sys/kern/subr_bus.c:device_print_child()mdodd1999-07-291-9/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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.
* Staticize.eivind1999-04-111-2/+2
|
* Change /dev/smb and /dev/iic interface to allow user programs to interact withnsouch1999-01-091-11/+24
| | | | | | | | | | devices dynamically. That means, + only one /dev/iic or /dev/smb device for each smb/iic bus to access + I2C/SMB device address must be given to any ioctl + new devices may be plugged and accessed after boot, which was impossible previously (device addresses were hardcoded into the kernel)
* The "easy" fixes for compiling the kernel -Wunused: remove unreferenced staticarchie1998-12-071-8/+2
| | | | and local variables, goto labels, and functions declared but not defined.
* Remove broken and useless intr interface.nsouch1998-11-221-3/+1
| | | | | | | Submitted by: Doug Rabson <dfr@nlsystems.com> Amancio Hasty <hasty@rah.star-gate.com> Avoid compile warnings.
* Check if devclass exists for probed devices beforensouch1998-11-081-2/+4
| | | | declaring the device 'alive'.
* Add iic driver iff the corresponding devclass exists.nsouch1998-11-071-7/+8
|
* iicbb is generic support for I2C bit-banging.nsouch1998-10-311-31/+96
| | | | Other files: timeout management added to the I2C framework.
* Submitted by: nsouchnsouch1998-09-031-0/+215
Philips I2C bus generic support other new bus architecture.
OpenPOWER on IntegriCloud