summaryrefslogtreecommitdiffstats
path: root/sys/dev/iicbus
Commit message (Collapse)AuthorAgeFilesLines
* MFC r289727:ian2016-01-241-37/+120
| | | | | | | | | | | | | | | | | | | | Add FDT compatibility to the icee driver. The FDT bindings for eeprom parts don't include any metadata about the device other than the part name encoded in the compatible property. Instead, a driver is required to have a compiled-in table of information about the various parts (page size, device capacity, addressing scheme). So much for FDT being an abstract description of hardware characteristics, huh? In addition to the FDT-specific changes, this also switches to using the newer iicbus_transfer_excl() mechanism which holds bus ownership for the duration of the transfer. Previously this code held the bus across all the transfers needed to complete the user's IO request, which could be up to 128KB of data which might occupy the bus for 10-20 seconds. Now the bus will be released and re-aquired between every page-sized (8-256 byte) transfer, making this driver a much nicer citizen on the i2c bus. The hint-based configuration mechanism is still in place for non-FDT systems.
* MFC r289726:ian2016-01-242-0/+17
| | | | | | | Add iicbus_transfer_excl(), a helper routine to do an i2c bus transaction while holding exclusive ownership of the bus. This is the routine most slave drivers should use unless they have a need to acquire and hold the bus across a series of related operations that involves multiple transfers.
* iicbus: Use device_delete_children() instead of explicit child removaldumbbell2016-01-214-19/+6
| | | | | | | | | | | | | | | | | If the bus is detached and deleted by a call to device_delete_child() or device_delete_children() on a device higher in the tree, I²C children were already detached and deleted. So the device_t pointer stored in sc points to freed memory: we must not try to delete it again. By using device_delete_children(), we let subr_bus.c figure out if there are children to take care of. While here, make sure iicbus_detach() and iicoc_detach() call device_delete_children() too, to be safe. Reviewed by: jhb, imp Approved by: jhb, imp Differential Revision: https://reviews.freebsd.org/D3926
* iicbus: Remove trailing whitespacesdumbbell2016-01-211-4/+4
| | | | MFC of: r289656
* MFC r281828, r289083, r289084, r289091, r289093, r289095, r289097, r289098,ian2015-10-207-242/+391
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* MFC r274641, r274644, r274822, r276049:ian2014-12-273-1/+71
| | | | | | | | | | | Allow i2c bus speed to be configured via hints, FDT data, and sysctl. Implement bus speed setting for OMAP4, AM335x, and imx5/6. Fix the i2c bus speed divisors for TI OMAP4 and AM335x to give the advertised 100, 400, and 1000 KHz speeds. PR: 195009
* MFC r273728:kib2014-11-032-4/+10
| | | | | Add a method to iicbus to request IIC_M_NOSTOP behaviour for multibyte transfers to be default.
* MFC r266923:loos2014-08-201-0/+6
| | | | | | | | | | | | | | | | | | | | Ignore IIC_ENOADDR from iicbus_reset() as it only means we have a master-only controller. This fixes the iic bus scan with i2c(8) (on supported controllers). Tested with gpioiic(4). MFC r267009: Remove the unnecessary i2c slave address assignment. The ti_i2c controller only works in the master mode and the i2c address passed on iicbus_reset() is used to set the controller slave address when operating as an i2c slave (which isn't currently supported). When talking to a slave, the slave address is correctly provided to ti_i2c_tranfer().
* MFC r258046, r258047, r258050, r259035, r259036, r259037, r261842, r261843,loos2014-05-151-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r261844, r261845, r261846, r262194, r262522, r262559 r258046: Fix a typo on a comment in ofw_bus_if.m, the default method will return -1 when a node doesn't exist. r258047: Move the KASSERT() check to the point before the increase of number of pins. r258050: 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. r259035: Remove unnecessary includes and an unused softc variable. While here apply two minor style(9) fixes. r259036: 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. r259037: Fix the pin value reading on AM335x. Because of the inverted logic it was always returning '0' for all the reads, even for the outputs. It is now known to work with gpioiic(4) and gpioled(4). r261842: 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. r261843: 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. r261844: Allow the use of OFW I2C bus together with iicbb(4) on OFW-based systems. This change makes ofw_iicbus attach to iicbb(4) controllers in addition to the already supported i2c host bridges (iichb). On iicbb(4) allow the direct access of the OFW parent node by its children, so they can be directly attached to iicbb(4) node on the DTS without the need of describing the i2c bus. r261845: Allow the use of the OFW GPIO bus for ti_gpio and bcm2835_gpio. With this change the gpio children can be described as directly connected to the GPIO controller without the need of describing the OFW GPIO bus itself on the DTS file. With this commit the OFW GPIO bus is fully functional on BBB and RPi. GPIO controllers which want to use the OFW GPIO bus will need similar changes. r261846: Make the gpioled(4) work out of the box on BBB. Add gpioled(4) to BEAGLEBONE kernel and add the description of the four on-board leds of beaglebone-black to its DTS file. r262194: Remove an unnecessary header. r262522: Fix make depend for iicbus. r262559: Inspired by r262522, fix make depend. This fixes the build of gpio modules.
* MFC r261421jhibbits2014-03-151-0/+664
| | | | | Add driver for the ADT7460/ADT7467 fan controller found in later PowerBooks and iBooks. Original work by andreast.
* MFC r259082jhibbits2014-01-152-2/+2
| | | | | | Make some unsigned ints signed. Found by: clang (powerpc64)
* Clean up SIOCSIFDSTADDR usage from ifnet drivers. The ioctl itself isglebius2013-09-111-1/+0
| | | | | | | | extremely outdated, and I doubt that it was ever used for ifnet drivers. It was used for AF_INET sockets in pre-FreeBSD time. Approved by: re (hrs) Sponsored by: Nginx, Inc.
* Add const qualifier to the dst parameter of the ifnet if_output method.glebius2013-04-261-2/+2
|
* Use DEVMETHOD_END macro defined in sys/bus.h instead of {0, 0} sentinel on ↵sbz2013-01-304-4/+4
| | | | | | | device_method_t arrays Reviewed by: cognet Approved by: cognet
* Check the return value of uiomove(9).kevlo2012-11-131-1/+5
|
* It turns out that as documented, PCF8563_R_SECOND_VL (i.e. battery low)marius2012-10-181-3/+11
| | | | | | | | | | doesn't automatically clear when VDD rises above Vlow again and needs to be cleared manually. However, apparently this needs all of the time registers to be set, i.e. pcf8563_settime(), and not just PCF8563_R_SECOND in order for PCF8563_R_SECOND_VL to stick. Thus, we just issue a warning during pcf8563_attach() rather than failing with ENXIO in case it is set. MFC after: 3 days
* Remove unused variables.kevlo2012-09-291-4/+0
|
* Add s35390a_rtc(4) driver for Seiko Instruments S-35390A RTC.hrs2012-08-211-0/+333
| | | | Submitted by: Yusuke Tanaka
* Add a new temperature driver for certain PowerMacs. Found here on my Quad G5.andreast2012-08-191-0/+413
|
* Unify the sysctl description with the other PowerMac temperature drivers.andreast2012-08-191-7/+9
|
* Avoid using the degree symbol. Looks ugly on the console.andreast2012-08-191-3/+4
|
* Do the ADC init only at startup and not during every sensor read call.andreast2012-08-191-5/+12
| | | | This reduces the number of interrupts.
* Don't include MIPS machine headers. There's no need for it.marcel2012-05-191-6/+0
|
* Add a driver for the NXP (Philips) PCF8563 RTC.marius2012-04-132-0/+260
| | | | Obtained from: NetBSD (pcf8563reg.h)
* Driver for OpenCores I2C controller.jchandra2012-03-272-0/+468
| | | | | | | Add a Simple polled driver iicoc for the OpenCores I2C controller. This is used in Netlogic XLP processors. Submitted by: Sreekanth M. S. (kanthms at netlogicmicro com)
* Move driver for DS1374 RTC to sys/dev/iicbusjchandra2012-03-271-0/+143
| | | | | | The earlier version of the driver is sys/mips/rmi/dev/iic/ds1374u.c Convert all references to ds1374u to ds1374, and use DEVMETHOD_END. Also update the license header as Netlogic is now Broadcom.
* Fix typo.andreast2012-03-021-1/+1
|
* Provide pre/post transfer method callbacks for icbbbkan2012-03-012-2/+55
| | | | | | | | | | clients. These are helful when making certain drivers work on both Linux and FreeBSD without changing the code flow too much. Reviewed by: kib, wlosh MFC after: 1 month
* IIC bitbang changes - prepare to make the bit delay configurable; debug ↵adrian2011-12-201-31/+42
| | | | | | | | | | | print changes. * Right now the delay is hard coded at 10uS. This is a bit long when doing lots of periodic i2c transactions. So create a 'udelay' parameter and initialise it to 10. This can be tuned later. * Add a newline after a transaction finishes, so the debugging output isn't so horrible.
* Allow the i2c node requirements to be slightly relaxed.adrian2011-12-043-4/+12
| | | | | | | | | | | | | | | | | | | | | | | | 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-222-11/+6
| | | | | | | | | | 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.
* Mark MALLOC_DEFINEs static that have no corresponding MALLOC_DECLAREs.ed2011-11-072-2/+2
| | | | This means that their use is restricted to a single C file.
* Revert r226398 and instead move the allocation of usrbufs after the error check.brueffer2011-10-161-4/+2
| | | | | Suggested by: pjd MFC after: 1 week
* Properly free resources in an error case.brueffer2011-10-151-1/+3
| | | | | | CID: 4203 Found with: Coverity Prevent(tm) MFC after: 1 week
* Tag mbufs of all incoming frames or packets with the interface's FIBbz2011-07-031-0/+1
| | | | | | | | | setting (either default or if supported as set by SIOCSIFFIB, e.g. from ifconfig). Submitted by: Alexander V. Chernikov (melifaro ipfw.ru) Reviewed by: julian MFC after: 2 weeks
* Remove duplicate header includeskevlo2011-06-281-3/+0
|
* - Improve error handling.andreast2011-06-081-43/+127
| | | | | | | | - Add retry loops in the i2c read/write functions. - Combied the ADC channel selection and readout of the value into one iicbus_transfer to avoid possible races. Reviewed by: nwhitehorn
* - Improve error handling.andreast2011-06-041-23/+45
| | | | | | | | | - Add a retry loop for the i2c sensor reading. - Check on busy status of the chip and on invalid values. - Fix a typo in a comment. - Replace the constant 2732 with the ZERO_C_TO_K macro. Approved by: nwhitehorn (mentor)
* Replace the FCU_ZERO_C_TO_K with the ZERO_C_TO_K from powermac_thermal.h.andreast2011-06-041-7/+5
| | | | Approved by: nwhitehorn (mentor)
* - Improve error handling.andreast2011-06-031-11/+33
| | | | | | | | | - Add a retry loop for the i2c sensor reading. - Update the sensor handling for sensors which do not have a location entry. [1] Submitted by: [1] Justin Hibbits. Approved by: nwhitehorn (mentor)
* Move the celsius-to-kelvin conversion to a place that powermac_thermal cannwhitehorn2011-05-291-6/+3
| | | | see it as well.
* Update the I2C-based temperature/fan drivers to connect to the Powermacnwhitehorn2011-05-293-91/+186
| | | | | thermal control module. This provides automatic fan management on all G5 PowerMacs and Xserves.
* Add a new driver, the ad7417, to read temperatures and voltages on someandreast2011-05-291-0/+457
| | | | | | PowerMac's. Approved by: nwhitehorn (mentor)
* There are PowerMacs which do not have a hwsensor-location propertyandreast2011-01-181-7/+12
| | | | | | | | for this sensor. Instead of leaving this location empty we use here the default name 'sensor'. Submitted by: Justin Hibbits <chmeeedalf at gmail dot com> Approved by: nwhitehorn (mentor)
* Remove unused variable. Spotted by a cppcheckandreast2011-01-151-3/+0
| | | | | | (devel/cppcheck, http://sourceforge.net/projects/cppcheck) run. Approved by: nwhitehorn (mentor)
* On the Xserve G5 we find the LM75 instead of the DS1775. The coreandreast2010-12-101-2/+3
| | | | | | | | | | | | functionality is the same, a difference is that the DS1775 has a better precision than the LM75. But we do not use it in our setup. Make the LM75 work the same as the DS1775. Fix a typo in device_set_desc. Tested by: Paul Mather <paul at gromit dlib vt edu> Approved by: nwhitehorn (mentor)
* Provide support for IIC_M_NOSTOP/IIC_M_NOSTART for bit-banging andnwhitehorn2010-11-081-5/+29
| | | | | | otherwise low-level controllers. Reviewed by: thompsa
* Add three new drivers for fan control and temperature reading on theandreast2010-10-152-0/+590
| | | | | | | | | | | | | | | | PowerMac7,2. - The fcu driver lets us read and write the fan RPMs for all fans in the PowerMac7,2. This driver is PowerMac specific. - The ds1775 is a driver to read the temperature for the drive bay sensor. - The max6690 is another driver to read temperatures. Here it is used to read the inlet, the backside and the U3 heatsink temperature. An additional driver, the ad7417, will follow later. Thanks to nwhitehorn for guiding me through this driver development. Approved by: nwhitehorn (mentor)
* 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 typo in comment.joel2010-08-071-1/+1
|
OpenPOWER on IntegriCloud