summaryrefslogtreecommitdiffstats
path: root/drivers/i2c
Commit message (Collapse)AuthorAgeFilesLines
* ARM: stm32mp: allow driver reuse for STM32 MCUsAhmad Fatoum2022-02-011-1/+1
| | | | | | | | | | | Most peripheral driver are usable for both STM32 MPUs and MCUs, but so far we they were only used for STM32MP1. In preparation for adding MCU support, introduce a new ARCH_STM32 selected by ARCH_STM32MP and migrate common drivers to it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220131075725.1873026-12-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c: add Rockchip i2c controller supportAhmad Fatoum2022-01-173-0/+467
| | | | | | | | | For addressing the PMIC on Rockchip platforms, add an i2c controller driver. Tested with rk3399 and rk808. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220114085425.315113-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: migrate "GPL-2.0" license identifiers to SPDX 2.0Roland Hieber2021-11-2218-18/+18
| | | | | | | | | | "GPL-2.0-only" was introduced in SPDX 2.0, and the old identifier "GPL-2.0" is now considered deprecated; see <https://spdx.org/licenses>. Fixes: 28f4a6a4df76f0f1581d (2021-10-30, "drivers: add missing SPDX-License-Identifier") Signed-off-by: Roland Hieber <rhi@pengutronix.de> Link: https://lore.barebox.org/20211117113851.2022669-2-rhi@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/spdx'Sascha Hauer2021-11-1522-92/+28
|\
| * drivers: add missing SPDX-License-IdentifierAhmad Fatoum2021-11-0121-73/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds the suitable SPDX-License-Identifier to all files in drivers/ that previously lacked one. To aid manual inspection, following heuristics can be used: * No changes outside of comments/whitespace: git show -U0 HEAD | rg -v '^(@@|diff|index)|[-+]([-+]|//|#|[\s/]\*)' * -or-later come in pairs: git show --inter-hunk-context=19 HEAD | \ perl -0777 -F'/^@/gm' -ne 'for (@F) { @m = /later/g; print if @m & 1 }' Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211030175632.2276077-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * i2c: algo-bit: switch to SPDX-License-IdentifierAhmad Fatoum2021-11-011-19/+5
| | | | | | | | | | | | | | | | Replace the boilerplate with a short equivalent identifier. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211030175632.2276077-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2021-11-152-4/+3
|\ \
| * | i2c-mux-pca954x: drop duplicate warning message on probeAhmad Fatoum2021-11-011-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Driver core will already print an error with the probe's return code, so no need to print a less useful message before that. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211030175812.2276705-10-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | ARM: i.MX: guf-santaro: fix passing around of uninitialized variableAhmad Fatoum2021-11-011-1/+2
| |/ | | | | | | | | | | | | | | | | | | i2c_device_present() does a zero byte read to probe for the i2c device. Make i2c_write_reg handle a NULL buf to silence the compiler warning. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211030175812.2276705-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / I2C: i.MX: early: replace zero-valued variable use with zero directlyAhmad Fatoum2021-11-011-1/+1
|/ | | | | | | | | There is a if (ret) return -EAGAIN a few lines above, so if we reach the final return, ret must be zero. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211030141954.2207820-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common: add initial barebox deep-probe supportMarco Felsch2021-06-251-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The barebox 'deep probe' or 'probe on demand' mechanism is the answer of unwanted -EPROBE_DEFER failures. The EPROBE_DEFER error code was introduced by commit ab3da15bc14c ("base: Introduce deferred probing") and since then it causes a few problems. The error is returned if either the device is not yet present or the driver is not yet registered. This makes sense on linux systems where modules and hot-plug devices are used very often but not for barebox. The module support is rarely used and devices aren't hot pluggable. The current barebox behaviour populates all devices before the drivers are registered so all devices are present during the driver registration. So the driver probe() function gets called immediately after the driver registration and causes the -EPROBE_DEFER error if this driver depends on an other not yet registered driver. To get rid of the EPROBE_DEFER error code we need to reorder the device population and the driver registration. All drivers must be registered first. In an ideal world all driver can be registered by the same initcall level. Then devices are getting populated which causes calling the driver probe() function but this time resources/devices are created on demand if not yet available. Dependencies between devices are normally expressed as references to other device nodes. With deep probe barebox provides helper functions which take a device node and probe the device behind that node if necessary. This means instead of returning -EPROBE_DEFER, we can now make the desired resources available once we need them. If the resource can't be created we are returning -ENODEV since we are not supporting hot-plugging. Dropping EPROBE_DEFER is the long-term goal, avoid initcall shifting is the short-term goal. Call it deep-probe since the on-demand device creation can create very deep stacks. This commit adds the initial support for: spi, i2c, reset, regulator, gpio and clk resource on-demand creation. The deep-probe mechanism must be enabled for each board to avoid breaking changes using deep_probe_enable(). This can be changed later after all boards are converted to the new mechanism. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.pengutronix.de/20201021115813.31645-8-m.felsch@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210625072540.32717-10-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c: designware: fix error message formattingAhmad Fatoum2021-06-091-5/+3
| | | | | | | | | Some error messages lack a trailing new line. One dev_dbg uses the i2c adapter's device_d as domain, before it was allocated. Fix this. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210531071304.32217-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* 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>