summaryrefslogtreecommitdiff
path: root/drivers/i2c/i2c-gpio.c
AgeCommit message (Collapse)AuthorFilesLines
2021-08-22i2c: i2c-gpio: Support the named GPIO bindingSamuel Holland1-0/+9
To avoid confusion about the order of the GPIOs, the i2c-gpio binding was updated to use a separate property for each GPIO instead of an array. However, the driver only supports the old binding. Add support for the new binding as well, so the driver continues to work as device trees are updated. Signed-off-by: Samuel Holland <samuel@sholland.org> Reviewed-by: Heiko Schocher <hs@denx.de>
2021-04-13gpio: i2c-gpio: Drop use of dm_gpio_set_dir()Simon Glass1-10/+9
This is the only driver that uses this function. Update it to use the alternative which is dm_gpio_clrset_flags(). Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Harm Berntsen <harm.berntsen@nedap.com>
2021-02-21i2c: i2c-gpio: Fix GPIO outputHarm Berntsen1-7/+10
The dm_gpio_set_dir_flags function cannot be used to update the configuration of a GPIO pin because it does a bitwise OR with the existing flags. Looks like commit 788ea834124b ("gpio: add function _dm_gpio_set_dir_flags") has introduced this behaviour and the i2c-gpio driver has been broken since. Signed-off-by: Harm Berntsen <harm.berntsen@nedap.com> CC: Heiko Schocher <hs@denx.de> CC: Patrick Delaunay <patrick.delaunay@st.com>
2020-12-19dm: Avoid accessing seq directlySimon Glass1-1/+1
At present various drivers etc. access the device's 'seq' member directly. This makes it harder to change the meaning of that member. Change access to go through a function instead. The drivers/i2c/lpc32xx_i2c.c file is left unchanged for now. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-12-14dm: treewide: Rename ofdata_to_platdata() to of_to_plat()Simon Glass1-2/+2
This name is far too long. Rename it to remove the 'data' bits. This makes it consistent with the platdata->plat rename. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-12-13dm: treewide: Rename auto_alloc_size members to be shorterSimon Glass1-1/+1
This construct is quite long-winded. In earlier days it made some sense since auto-allocation was a strange concept. But with driver model now used pretty universally, we can shorten this to 'auto'. This reduces verbosity and makes it easier to read. Coincidentally it also ensures that every declaration is on one line, thus making dtoc's job easier. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-23i2c: i2c-gpio: Convert to use APIs which support live DTPatrick Delaunay1-7/+3
Use ofnode_ or dev_ APIs instead of fdt_ and fdtdec_ APIs so that the driver can support live DT. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Heiko Schocher <hs@denx.de>
2020-05-19common: Drop linux/delay.h from common headerSimon Glass1-0/+1
Move this uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-19common: Drop log.h from common headerSimon Glass1-0/+1
Move this header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-03-16dm: i2c-gpio: add support for clock stretchingHeiko Schocher1-1/+22
This adds support for clock stretching to the i2c-gpio driver. This is accomplished by switching the GPIO used for the SCL line to an input when it should be driven high, and polling on the SCL line value until it goes high (indicating that the I2C slave is no longer pulling it low). This is enabled by default; for gpios which cannot be configured as inputs, the i2c-gpio,scl-output-only property can be used to fall back to the previous behavior. Signed-off-by: Michael Auchter <michael.auchter@ni.com> Cc: Heiko Schocher <hs@denx.de> Reviewed-by: Heiko Schocher <hs@denx.de>
2020-03-16dm: i2c-gpio: rework gpio get/set functionsMichael Auchter1-69/+64
This patch reworks i2c-gpio to make it easier to switch out the implementation of the sda/scl get/set functions. This is in preparation for a patch to conditionally implement clock stretching support. Signed-off-by: Michael Auchter <michael.auchter@ni.com> Cc: Heiko Schocher <hs@denx.de> Reviewed-by: Heiko Schocher <hs@denx.de>
2020-03-16i2c: gpio: Run deblock sequence on probeMarek Vasut1-0/+16
Add deblock dequence for the I2C bus, needed on some devices. This sequence is issued once, when probing the driver, and is controlled by DT property, "i2c-gpio,deblock". Signed-off-by: Marek Vasut <marex@denx.de> Reviewed-by: Heiko Schocher <hs@denx.de>
2017-10-04treewide: replace with error() with pr_err()Masahiro Yamada1-1/+1
U-Boot widely uses error() as a bit noisier variant of printf(). This macro causes name conflict with the following line in include/linux/compiler-gcc.h: # define __compiletime_error(message) __attribute__((error(message))) This prevents us from using __compiletime_error(), and makes it difficult to fully sync BUILD_BUG macros with Linux. (Notice Linux's BUILD_BUG_ON_MSG is implemented by using compiletime_assert().) Let's convert error() into now treewide-available pr_err(). Done with the help of Coccinelle, excluing tools/ directory. The semantic patch I used is as follows: // <smpl> @@@@ -error +pr_err (...) // </smpl> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Simon Glass <sjg@chromium.org> [trini: Re-run Coccinelle] Signed-off-by: Tom Rini <trini@konsulko.com>
2017-02-08dm: core: Replace of_offset with accessorSimon Glass1-1/+1
At present devices use a simple integer offset to record the device tree node associated with the device. In preparation for supporting a live device tree, which uses a node pointer instead, refactor existing code to access this field through an inline function. Signed-off-by: Simon Glass <sjg@chromium.org>
2015-05-06dm: i2c-gpio: Remove redundant dm_gpio_set_value() callAxel Lin1-6/+7
dm_gpio_set_dir_flags() will also set gpio output value when switching to gpio output. So it's not necessary to call dm_gpio_set_value() after dm_gpio_set_dir_flags() call. Signed-off-by: Axel Lin <axel.lin@ingics.com> Acked-by: Simon Glass <sjg@chromium.org>
2015-04-18dm: i2c: add i2c-gpio driverPrzemyslaw Marczak1-0/+346
This commit adds driver model support to software emulated i2c bus driver. This driver supports kernel-style device tree bindings. Fdt properties in use: - compatible - "i2c-gpio" - gpios - data and clock GPIO pin phandles - delay-us - micro seconds delay between GPIOs toggle operations, which is 1/4 of I2C speed clock period. Added: - Config: CONFIG_DM_I2C_GPIO - File: drivers/i2c/i2c-gpio.c - File: doc/device-tree-bindings/i2c/i2c-gpio.txt Driver base code is taken from: drivers/i2c/soft-i2c.c, changes: - use "i2c-gpio" naming - update comments style - move preprocesor macros into functions - add device tree support - add driver model i2c support - code cleanup, - add Kconfig entry Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com> Acked-by: Simon Glass <sjg@chromium.org> Added braces in i2c_gpio_xfer() to fix style nit: Signed-off-by: Simon Glass <sjg@chromium.org>