summaryrefslogtreecommitdiffstats
path: root/sys/dev/iicbus
Commit message (Collapse)AuthorAgeFilesLines
* MFC r313982, r314068:pfg2017-03-141-1/+1
| | | | | | sys: Replace zero with NULL for pointers. Found with: devel/coccinelle
* MFC r308530: iicsmb: SMB_MAXBLOCKSIZE can be used againavg2016-12-241-14/+4
|
* MFC r308104: add iic interface to ig4 driver, move isl and cyapa to iicbusavg2016-12-141-1/+3
|
* MFC r306589: Implement iicbus_write_ivar and impelemnt the NOSTOP ivaravg2016-12-141-0/+21
| | | | in both read and write.
* MFC r307195: convert iicsmb to use iicbus_transfer for all operationsavg2016-11-171-168/+142
|
* MFC r304459,r305527:mmel2016-11-051-2/+0
| | | | | | | | | | | | | | | | | | r304459: INTRNG: Rework handling with resources. Partially revert r301453. - Read interrupt properties at bus enumeration time and store it into global mapping table. - At bus_activate_resource() time, given mapping entry is resolved and connected to real interrupt source. A copy of mapping entry is attached to given resource. - At bus_setup_intr() time, mapping entry stored in resource is used for delivery of requested interrupt configuration. - For MSI/MSIX interrupts, mapping entry is created within pci_alloc_msi()/pci_alloc_msix() call. - For legacy PCI interrupts, mapping entry must be created within pcib_route_interrupt() by pcib driver itself. r305527: Fix MIPS INTRNG (both FDT and non-FDT) behaviour broken by r304459
* MFC r302523,r302528:mmel2016-11-051-2/+2
| | | | | | | | | | | r302523: Add clk_get_by_ofw_node_index, which is like clk_get_by_ofw_index but operates on a specific OF node instead of the pass in device's OF node. r302528: EXTRES: Add OF node as argument to all <foo>_get_by_ofw_<bar>() functions. In some cases, the driver must handle given properties located in specific OF subnode. Instead of creating duplicate set of function, add 'node' as argument to existing functions, defaulting it to device OF node.
* INTRNG - change the way how an interrupt mapping data are providedskra2016-06-051-0/+2
| | | | | | | | to the framework in OFW (FDT) case. This is a follow-up to r301451. Differential Revision: https://reviews.freebsd.org/D6634
* Add support for interrupts, sensors and GPIO for AXP209 PMIC.manu2016-05-261-2/+4
| | | | | | | | | | | | | | | | | Pressing the PEK (power enable key) will shutdown the board. Some events are reported to devd via system "PMU" and subsystem "Battery", "AC" and "USB" such as connected/disconnected. Some sensors values (power source voltage/current) are reported via sysctl (dev.axp209_pmu.X.) It also expose a gpioc node usable in kernel and userland. Only 3 of the 4 GPIO are exposed (The GPIO3 is different and mostly unused on boards). Most popular boards uses GPIO1 as a sense pin for OTG power. Add a dtsi file that adds gpio-controller capability to the device as upstream doesn't defined it and include it in our custom DTS. Reviewed by: jmcneill Approved by: cognet (mentor) Differential Revision: https://reviews.freebsd.org/D6135
* Move the OFW iicbus code to dev/iicbus to stop polluting dev/ofw withloos2016-05-241-0/+238
| | | | | | unrelated code. Discussed with: nwhitehorn (a long time ago)
* Fix the deciKelvin to Celsius conversion in kernel.loos2016-05-222-2/+2
| | | | | | | | | | | After r285994, sysctl(8) was fixed to use 273.15 instead of 273.20 as 0C reference and as result, the temperature read in sysctl(8) now exibits a +0.1C difference. This commit fix the kernel references to match the reference value used in sysctl(8) after r285994. Sponsored by: Rubicon Communications (Netgate)
* Remove a couple of extra blank lines.loos2016-05-222-2/+0
|
* iic_rdwr_data->nmsgs is uint32_t, so limit the allowable number of messages ↵jah2016-05-202-0/+11
| | | | | | | | | | | to prevent memory exhaustion and short allocations on 32-bit systems. Since iicrdwr is intended to be a workalike of a Linux i2c-dev call, use the same limit of 42 that Linux uses. Also check the return value of copyin(9) to prevent unnecessary allocation in the failure case. Submitted by: ngie Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D5155
* Use OF_prop_free instead of direct call to free(9)gonzo2016-05-141-4/+4
| | | | Reviewed by: jhibbits
* Add allwinner,sun8i-a83t-i2c to the list of compatible devices.jmcneill2016-05-141-0/+1
|
* sys/dev: minor spelling fixes.pfg2016-05-034-4/+4
| | | | Most affect comments, very few have user-visible effects.
* Convert Allwinner port to extres clk/hwreset/regulator APIs.jmcneill2016-04-061-27/+24
| | | | | | Reviewed by: andrew, gonzo, Emmanuel Vadot <manu@bidouilliste.com> Approved by: gonzo (mentor) Differential Revision: https://reviews.freebsd.org/D5752
* Add support for the Microchip mcp7941x.jhibbits2016-04-052-8/+34
| | | | | | | | This is compatible with the ds1307, but comparing the mcp7941x datasheet vs the ds1307 code, appears there is one bit placement difference, so that is now accounted for. Relnotes: yes
* Fix the resource_list_print_type() calls to use uintmax_t.jhibbits2016-03-221-1/+1
| | | | Missed a bunch from r297000.
* Migrate many bus_alloc_resource() calls to bus_alloc_resource_anywhere().jhibbits2016-02-271-2/+2
| | | | | | | | Most calls to bus_alloc_resource() use "anywhere" as the range, with a given count. Migrate these to use the new bus_alloc_resource_anywhere() API. Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D5370
* Add the start of support for the Allwinner A31 clocks. It only addsandrew2016-02-261-2/+31
| | | | | | | | | support for the i2c, mmc, and gmac clocks. Further clocks can be added as needed. Submitted by: Emmanuel Vadot <manu@bidouilliste.com> Reviewed by: jmcneill Differential Revision: https://reviews.freebsd.org/D5339
* Fix the spelling of OF_getencprop. It will fix the data correctly for theandrew2016-02-152-6/+4
| | | | | | endian of the CPU so there is no need to call fdt32_to_cpu. Sponsored by: ABT Systems Ltd
* Add support for the Allwinner i2c device. This is similar to the existingandrew2016-02-154-314/+602
| | | | | | | | | | Marvell twsi part, however uses different register locations, as such split the existing driver into Marvell and Allwinner attachments. While here clean a few style issues. Submitted by: Emmanuel Vadot <manu@bidouilliste.com> Differential Revision: https://reviews.freebsd.org/D4846
* Move the twsi driver source to be under iicbus. It is in a separateandrew2016-02-141-0/+644
| | | | | | | directory as it is expected multiple attachments will be added for the SoC families that use this hardware. Sponsored by: ABT Systems Ltd
* Use the correct type for i when iterating over `buf` to avoid unlikelyngie2016-01-301-1/+2
| | | | | | | | | | | negative array indexing in iicrdwr(..) Differential Revision: https://reviews.freebsd.org/D5132 Obtained from: HardenedBSD PR: 206754 Reported by: CTurt <cturt@hardenedbsd.org> Submitted by: Madhi Moktari <mokhi64@gmail.com> Sponsored by: EMC / Isilon Storage Division
* Add FDT compatibility to the icee driver.ian2015-10-221-37/+120
| | | | | | | | | | | | | | | | | | | | 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. Michal Meloun contributed some of the code for these changes.
* Add iicbus_transfer_excl(), a helper routine to do an i2c bus transactionian2015-10-222-0/+17
| | | | | | 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 removaldumbbell2015-10-204-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 MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D3926
* iicbus: Remove trailing whitespacesdumbbell2015-10-201-4/+4
| | | | MFC after: 1 week
* Replace a local sx lock that allowed only one client at a time to accessian2015-10-101-12/+11
| | | | | 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.
* Translate iic hardware layer status values to errno return values.ian2015-10-101-3/+9
|
* Add a short name, IIC_INTRWAIT, for the common case (IIC_INTR | IIC_WAIT).ian2015-10-101-0/+1
|
* Fix more cases of iicbus-layer functions that must return IIC_Exxxx values.ian2015-10-101-2/+2
|
* Return only IIC_Exxxx status values from iicbus-layer functions. Most ofian2015-10-092-7/+22
| | | | | | | | | | these functions are thin wrappers around calling the hardware-layer driver, but some of them do sanity checks and return an error. Since the hardware layer can only return IIC_Exxxxx status values, the iicbus helper functions must also adhere to that, so that drivers at higher layers can assume that any non-zero status value is an IIC_Exxxx value that provides details about what happened at the hardware layer (sometimes those details are important for certain slave drivers).
* Add iic2errno(), a helper function to translate IIC_Exxxxx status values toian2015-10-092-0/+24
| | | | | | | | | | | | | | | 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. The IIC_Exxxxxx values are supposed to communicate low-level details of the i2c transaction status between the lowest-layer hardware driver and higher-layer bus protocol and device drivers for slave devices on the bus. Most of those slave drivers just return all status values from the lower layers directly to their callers, resulting in crazy error reporting from a user's point of view (things like timeouts being reported as "no such process"). Now there's a helper function to make it easier to start cleaning up all those drivers.
* Use IIC_EBUSBSY and IIC_BUSERR status values consistantly across all drivers.ian2015-10-092-3/+3
| | | | | | | | | | | | Make it clearer what each one means in the comments that define them. IIC_BUSBSY was used in many places to mean two different things, either "someone else has reserved the bus so you have to wait until they're done" or "the signal level on the bus was not in the state I expected before/after issuing some command". Now IIC_BUSERR is used consistantly to refer to protocol/signaling errors, and IIC_BUSBSY refers to ownership/reservation of the bus.
* Bugfix: Exit the transfer loop if any read or write operation fails. Also,ian2015-10-091-2/+5
| | | | | | 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.
* Style and whitespace cleanups. The only functional change is removal ofian2015-10-091-12/+8
| | | | a printf that appears to be left over from development debugging.
* Remove unnecessary code and make use of generic implementations forloos2015-05-101-57/+4
| | | | | | | | | | | | bus_alloc_resource(), bus_release_resource() and bus_set_resource() (bus_generic_rl_alloc_resource(), bus_generic_rl_release_resource() and bus_generic_rl_set_resource() respectively). Do not print the resources for nomatch devices. Use the inherited method for bus_get_resource_list() on ofw_iicbus.c. Submitted by: jhb and Michal Meloun (D2033)
* Handle IRQ resources on iicbus and ofw_iicbus.loos2015-05-092-3/+83
| | | | Based on a patch submitted by Michal Meloun <meloun@miracle.cz>.
* Replace spaces with tabs, removes an extra blank line.loos2015-05-081-9/+8
| | | | No functional changes.
* Make the pcf8563 RTC work on FDT systems and on interrupt based i2cloos2015-04-251-15/+52
| | | | | | | | | | | | | controllers. Call iicbus_transfer() from the device context and not from the iicbus context. I am committing a slightly different patch, so if something break, it is probably my fault. PR: 199496 Submitted by: Juraj Lutter <otis@sk.FreeBSD.org>
* Fix numerous issues in iic(4) and iicbus(4):jah2015-04-214-204/+309
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | --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. Differential Revision: https://reviews.freebsd.org/D2140 Reviewed by: imp, jhb, loos Approved by: kib (mentor)
* Add a driver for the Dallas/Maxim DS1307, another common i2c RTC.loos2015-03-202-0/+470
| | | | | | | | Many thanks to ian who gently provided me the DS1307 breakout board. Tested on: Raspberry pi Differential Revision: https://reviews.freebsd.org/D2022 Reviewed by: rpaulo
* Fix off-by-one bugs.loos2015-03-102-8/+6
| | | | Spotted by: rpaulo (on another review)
* Add a driver for the Maxim DS3231 a low-cost, extremely accurate (+-2PPM)loos2015-02-282-0/+662
| | | | | | | | | | | | | | | | I2C real-time clock (RTC). The DS3231 has an integrated temperature-compensated crystal oscillator (TXCO) and crystal. DS3231 has a temperature sensor, an independent 32kHz output (which can be turned on and off by the driver) and another output that can be used as interrupt for alarms or as a second square-wave output, which frequency and operation mode can be set by driver sysctl(8) knobs. Differential Revision: https://reviews.freebsd.org/D1016 Reviewed by: ian, rpaulo Tested on: Raspberry pi model B
* Replace hardcoded sizes by sizeof() and nitems().loos2015-02-171-14/+13
| | | | Set all the sysctls as CTLFLAG_MPSAFE.
* Fix the display of negative temperatures.loos2015-02-171-7/+14
| | | | | Fix the setting of TOS (overtemperature shutdown) and THYST (hysteresis temperature).
* Use proper signed types. The ADT746x uses signed 8-bit numbers for thejhibbits2015-01-181-2/+3
| | | | | | temperature. MFC after: 2 weeks
* Allow i2c bus speed to be configured via hints, FDT data, and sysctl.ian2014-11-183-1/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
OpenPOWER on IntegriCloud