summaryrefslogtreecommitdiffstats
path: root/drivers/i2c
Commit message (Collapse)AuthorAgeFilesLines
* i2c: at91: extend for sama5d2 supportAhmad Fatoum2020-08-031-19/+116
| | | | | | | | Port over the Linux v5.8-rc4 bits to support i2c on the sama5d2. This has been tested by reading the i2c EEPROM on the sama5d27-som1-ek. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c: sync i2c_parse_fw_timings() with upstreamAhmad Fatoum2020-08-031-39/+34
| | | | | | | | | | Upstream now has support for i2c-digital-filter-width-ns and i2c-analog-filter-cutoff-frequency device tree properties, that are used in an upcoming patch. Prepare for it by syncing with Linux v5.8-rc4. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c: stm32: support new st,stm32mp15-i2c compatibleAhmad Fatoum2020-08-031-0/+1
| | | | | | | | | | | | | | Linux v5.8-rc1 has gained support for the FastMode+ registers on the stm32mp15, but those are incompatible between the stm32mp15 and the stm32f7, so a new compatible was introduced. The old compatible was replaced for the MP15 SoC, breaking I2C in barebox. Add the new compatible to fix this. Unlike Linux, we just use the same setup parameters as for the stm32f7. This is ok as long we don't want to support FastMode+. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: Convert files covered by ARM copyright to SPDXUwe Kleine-König2020-07-141-7/+6
| | | | | | | | | | According to Marc Zyngier, former employee at ARM, the company owns the copyright for code created by its employees. Convert accordingly to SPDX with the usual rearrangements. Also dropped Marc's email address which doesn't work any more. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c: designware: use proper type for writel argumentAhmad Fatoum2020-07-141-2/+5
| | | | | | | | | We need to write DW_IC_ENABLE_ENABLE (1 << 0) to the register to enable, but instead we were writing true. This happens to work, but is quite unusual. Make the code more readable. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: stm32mp: depend on ARCH_STM32MP for SoC driversAhmad Fatoum2020-07-141-0/+1
| | | | | | | | | The i2c, MCI and reset controller peripherals are STM32-specific. There is no reason to ask uses on oldconfig about it, thus make them depend on ARCH_STM32MP || COMPILE_TEST. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: replace commas with semicolons where appropriateAhmad Fatoum2020-05-203-3/+3
| | | | | | | | | | | | Found by searching drivers/ arch/ common/ and lib/ for /^\s+[^."/\*\[\s\{\(A-Z][^\[\{\(]*=[^\{\(]+,$/ Because the comma has the lowest precedence in C, this shouldn't result in any functional change. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c: Port of_find_i2c_device_by_node() from LinuxAndrey Smirnov2020-04-011-0/+13
| | | | | | | | | | Port of_find_i2c_device_by_node() from Linux in order to allow looking i2c_client up by corresponding DT node. Useful for interacting with identical raw/driverless I2C devices that are not found on the same bus between board variants. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* I2C: i.MX: Add early i2c support for i.MX8MSascha Hauer2020-02-191-0/+12
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c: tegra: correct error messageAhmad Fatoum2020-02-121-1/+1
| | | | | | | | | | reset_control_get returns NULL when the controller reset is missing. The error pointer is used for malformed reset controller specification. Correct the message accordingly. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/stm32'Sascha Hauer2019-12-101-8/+3
|\
| * i2c: stm32: use device_reset_us helper instead of open-codingAhmad Fatoum2019-11-131-8/+3
| | | | | | | | | | | | | | | | The exact sequence is already available in form of device_reset_us. Make use of it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/randfixes'Sascha Hauer2019-12-101-1/+2
|\ \
| * | i2c: always walk down into i2c/busses MakefileLucas Stach2019-12-021-1/+2
| |/ | | | | | | | | | | | | | | Otherwise CONFIG_I2C_IMX_EARLY won't be built if !CONFIG_I2C even though it has no direct dependency on the i2c core. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / i2c: gpio: use of_get_named_gpio() instead of of_get_named_gpio_flags()Antony Pavlov2019-11-251-2/+2
|/ | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c-mux-pca954x: Add support for "i2c-mux-idle-disconnect"Andrey Smirnov2019-10-141-1/+18
| | | | | | | | | | | Add support for "i2c-mux-idle-disconnect" binding to match the behavior, already present in upstream kernel driver. This feature is a must have for I2C bus topologies with multiple muxes connected to child segments containing slaves with identical addresses (e.g. ZII's SCU4) Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/stm32'Sascha Hauer2019-09-124-0/+929
|\
| * i2c: add stm32f7 I2C adapter driverAhmad Fatoum2019-09-093-0/+869
| | | | | | | | | | | | | | | | This patch adds initial support for the STM32F7 I2C controller. It was tested to work with the STM32MP157C. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * i2c: port Linux i2c_parse_fw_timingsAhmad Fatoum2019-09-091-0/+60
| | | | | | | | | | | | | | | | | | Linux has a generic function for extracting i2c timings parameters from device-associated firmware nodes. Port this function to barebox, but have it only work on device tree nodes for now. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | i2c/pca954x: Initialize the mux to disconnected stateAndrey Smirnov2019-09-091-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Port of a Linux kernel commit cd823db8b1161ef0d756514d280715a576d65cc3 pca954x power-on default is channel 0 connected. If multiple pca954x muxes are connected to the same physical I2C bus, the parent bus will see channel 0 devices behind both muxes by default. This is bad. Scenario: -- pca954x @ 0x70 -- ch 0 (I2C-bus-101) -- EEPROM @ 0x50 | I2C-bus-1 --- | -- pca954x @ 0x71 -- ch 0 (I2C-bus-111) -- EEPROM @ 0x50 1. Load I2C bus driver: creates I2C-bus-1 2. Load pca954x driver: creates virtual I2C-bus-101 and I2C-bus-111 3. Load eeprom driver 4. Try to read EEPROM @ 0x50 on I2C-bus-101. The transaction will also bleed onto I2C-bus-111 because pca954x @ 0x71 channel 0 is connected by default. Fix: Initialize pca954x to disconnected state in pca954x_probe() Signed-off-by: Petri Gynther <pgynther@google.com> Signed-off-by: Jean Delvare <khali@linux-fr.org> Cc: stable@kernel.org Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | i2c-mux-pca954x: remove use of uninitialized variableAhmad Fatoum2019-08-301-3/+3
|/ | | | | | | | force isn't used except to print its uninitialized value in an error path. Drop it. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: scb9328: refurbish board suportSascha Hauer2019-08-151-1/+1
| | | | | | | | | - switch the i.MX1 based scb9328 board to device tree - Remove scb9328_defconfig and enable scb9328 board support in imx_defconfig - Remove old environment and switch to new default environment Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c: gpio: add sda/scl-gpios property supportMarco Felsch2019-06-261-10/+17
| | | | | | | | | The gpios property is marked as deprecated since kernel 4.15 so we should support the "new" mechanism too. The new mechanism has a higher priority than the deprecated one. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: remove stale mentions of CONFIG_OF in commentsAhmad Fatoum2019-06-131-1/+1
| | | | | | | | | | | | barebox doesn't define a CONFIG_OF kconfig option, but CONFIG_OFTREE for the device tree handling and CONFIG_OFDEVICE for probing devices out of the device tree. Replace comment mentions of CONFIG_OF with mentions of either as appropriate. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2019-04-091-3/+3
|\
| * treewide: surround Kconfig file paths with double quotesMasahiro Yamada2019-03-211-3/+3
| | | | | | | | | | | | | | | | | | Based on Linux commit 8636a1f9677db4f883f29a072f401303acfc2edd This will be needed when you sync Kconfig with Linux 5.0 or later. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | i2c: i.MX: Add layerscape supportSascha Hauer2019-03-132-2/+4
|/ | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c: i.MX: Add early driver for use in PBLSascha Hauer2019-03-043-0/+314
| | | | | | | i2c is used in SPD EEPROMs and thus needed very early before barebox is up. This patch adds a i.MX i2c driver variant for use in PBL. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c: i.MX: Create header file for register definesSascha Hauer2019-02-272-46/+53
| | | | | | | We'll add a stripped down driver variant for use in PBL. To share the register defines add a header file for them. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c: i.MX: Read clock-frequency from device treeSascha Hauer2019-02-271-6/+6
| | | | | | | We speed up the clock frequency only if probed via platform_data. Additionally honour the "clock-frequency" property. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c: i.MX: remove unused defineSascha Hauer2019-02-271-3/+0
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c: i.MX: stop after read only in last transfer of a messageSascha Hauer2019-02-271-3/+4
| | | | | | | | | Following the Linux driver the controller should be stopped in the read transfer path only after the last transfer of a message, but not when other transfers of the same message are following. Implement this behaviour for the barebox driver aswell. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c: i.MX: Consolidate status polling loopsSascha Hauer2019-02-271-42/+31
| | | | | | | | We poll for different bits in the status register in different functions. Instead of repeating the polling loops each time create a helper function for it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c: i.MX: remove unnecessary ifdefSascha Hauer2019-02-271-8/+0
| | | | | | dev_dbg is a no-op when debugging is disabled, so no need for extra ifdefs. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c: i.MX: Fix FSL_I2C_DFSRR register offsetSascha Hauer2019-02-271-1/+1
| | | | | | | | 4ed5b77 ("i.MX: i2c: Add Vybrid support") introduced regshifts for the register offsets, but missed to adjust the register offset for the FSL_I2C_DFSRR register (which exists only on PowerPC). Fix this. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c: i.MX: remove unnecessary ifdefSascha Hauer2019-02-271-2/+0
| | | | | | No need to put the of_compatible field into ifdefs, remove them. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c: i.MX: remove unnecesary defineSascha Hauer2019-02-271-4/+1
| | | | | | No need for a define which is used only once. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c: i.MX: fix variable nameSascha Hauer2019-02-271-14/+14
| | | | | | | i2c_fsl_write() and i2c_fsl_read() take exactly one i2c message, not multiple ones, hence rename the variable from "msgs" to "msg". Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c: i.MX: consolidate codeSascha Hauer2019-02-271-33/+21
| | | | | | | | We have to write to FSL_I2C_I2DR and wait for completion/ack three times in the code. Instead of open coding it each time create a helper function for it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c: i.MX: Track stopped status in I2CR_MSTA bitSascha Hauer2019-02-271-28/+15
| | | | | | | | We can track the stopped status in the I2CR_MSTA bit, no need for an extra variable. Also we can call i2c_fsl_stop() instead of open coding it in i2c_fsl_read(). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c: i.MX: move disabling of controller out of i2c_fsl_stopSascha Hauer2019-02-271-4/+4
| | | | | | | Move disabling of the controller out of i2c_fsl_stop(). This makes the function reusable in other places in the next patch. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c: i.MX: Do not call i2c_fsl_bus_busy twiceSascha Hauer2019-02-271-4/+0
| | | | | | | | In i2c_fsl_stop() we call i2c_fsl_bus_busy() a second time when it fails. If it fails once it won't succeed the second time, so drop the second call. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/net-switch-mv88e6xxx'Sascha Hauer2018-11-091-2/+2
|\
| * drivers: Introduce dev_set_name()Andrey Smirnov2018-10-181-2/+2
| | | | | | | | | | | | | | | | Introduce dev_set_name() in order to hide implementation details of setting device's name so it'd be easier to change it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | i2c: introduce device_i2c_driver() macroMarco Felsch2018-10-191-7/+1
|/ | | | | | | | | Add macro and dependency to avoid boilerplate code. Since now simple i2c drivers only have to include the i2c.h header and call the device_i2c_driver() macro to register a i2c device driver. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i.MX: i2c: Fix build error in debug output codeAndrey Smirnov2018-08-131-2/+2
| | | | | | | | | Looks like that particular chunk of the code have not been built in a while and bitrotted. Change function parameters appropriately to avoid breaking the build. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c-mux-pca954x: fix out-of-bounds write for 64 bit systemsPeter Mamonov2018-05-241-1/+3
| | | | | | | | get_drv_data(..., &data->type) overwrites memory beyond data->type member due to mismatch of sizeof(enum pca_type) and sizeof(void *) on 64 bit systems. Signed-off-by: Peter Mamonov <pmamonov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c: i2c_master_send(): don't leave flags uninitializedAntony Pavlov2018-02-091-0/+1
| | | | | | | | Leaving the flags field unitialized can lead to performing read operation instead of write operation. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c: read/write_reg: don't assume client->dev to be validUwe Kleine-König2018-01-251-2/+2
| | | | | | | | | | | | | | When using the barebox commands i2c_read or i2c_write the client pointer passed to the respective function isn't completely initialized. This makes dev_dbg(&client->dev, ...); choke as it dereferences client->dev.driver->name with client->dev.driver being a random value. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c: designware: evaluate i2c-sda-hold-time propertySteffen Trumtrar2018-01-111-0/+40
| | | | | | | | | | Newer designware i2c controllers allow setting the SDA hold time. Evaluate the devicetree property "i2c-sda-hold-time" and set the value accordingly. The code is an adaption of the Linux v4.12 driver. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>