i2c: add i2c driver for stm32
PATCH v2 1/1 i2c: add i2c driver for stm32
From: Patrice Chotard <[email protected]>
Add i2c driver which can be used on both STM32F7 and STM32H7. This I2C block supports the following features:
_ Slave and master modes
_ Multimaster capability
_ Standard-mode (up to 100 kHz)
_ Fast-mode (up to 400 kHz)
_ Fast-mode Plus (up to 1 MHz)
_ 7-bit and 10-bit addressing mode
_ Multiple 7-bit slave addresses (2 addresses, 1 with configurable mask) _ All 7-bit addresses acknowledge mode
_ General call
_ Programmable setup and hold times
_ Easy to use event management
_ Optional clock stretching
_ Software reset
---
v2: _ add I2C controller description in Kconfig
_ rename stm32_i2c_dev struct to stm32_i2c_priv
_ add comment for stm32_i2c_handle_reload()
_ split stm32_i2c_compute_timing() code and add :
_ stm32_i2c_compute_solutions() which computes list of possible timings candidate _ stm32_i2c_choose_solution() which selects the best timing
_ use #defines instead of hard coded vlaue for speed in
stm32_i2c_set_bus_speed() and in i2c_specs[] array
_ move part of code of stm32_i2c_probe() inside stm32_ofdata_to_platdata()
doc/device-tree-bindings/i2c/i2c-stm32.txt | 30 + drivers/i2c/Kconfig | 20 + drivers/i2c/Makefile | 1 + drivers/i2c/stm32f7_i2c.c | 882 +++++++++++++++++++++++++++++ 4 files changed, 933 insertions(+) create mode 100644 doc/device-tree-bindings/i2c/i2c-stm32.txt create mode 100644 drivers/i2c/stm32f7_i2c.c
doc/device-tree-bindings/i2c/i2c-stm32.txt new file +30 -0
@@ -0,0 +1,30 @@ +* I2C controller embedded in STMicroelectronis STM32 platforms + +Required properties : +- compatible : Must be "st,stm32f7-i2c" +- reg : Offset and length of the register set for the device +- resets: Must contain the phandle to the reset controller +- clocks: Must contain the input clock of the I2C instance +- A pinctrl state named "default" must be defined to set pins in mode of + operation for I2C transfer +- #address-cells = <1>; +- #size-cells = <0>; + +Optional properties : +- clock-frequency : Desired I2C bus clock frequency in Hz. If not specified, + the default 100 kHz frequency will be used. As only Normal, Fast and Fast+ + modes are implemented, possible values are 100000, 400000 and 1000000. + +Example : + + i2c1: i2c at 40005400 { + compatible = "st,stm32f7-i2c"; + reg = <0x40005400 0x400>; + resets = <&rcc 181>; + clocks = <&clk_pclk1>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_i2c1>; + clock-frequency = <400000>; + #address-cells = <1>; + #size-cells = <0>; + };
drivers/i2c/Kconfig +20 -0
@@ -168,6 +168,26 @@ config SYS_I2C_S3C24X0 help Support for Samsung I2C controller as Samsung SoCs. +config SYS_I2C_STM32F7 + bool "STMicroelectronics STM32F7 I2C support" + depends on (STM32F7 || STM32H7) && DM_I2C + help + Enable this option to add support for STM32 I2C controller + introduced with STM32F7/H7 SoCs. This I2C controller supports : + _ Slave and master modes + _ Multimaster capability + _ Standard-mode (up to 100 kHz) + _ Fast-mode (up to 400 kHz) + _ Fast-mode Plus (up to 1 MHz) + _ 7-bit and 10-bit addressing mode + _ Multiple 7-bit slave addresses (2 addresses, 1 with configurable mask) + _ All 7-bit addresses acknowledge mode + _ General call + _ Programmable setup and hold times + _ Easy to use event management + _ Optional clock stretching + _ Software reset + config SYS_I2C_UNIPHIER bool "UniPhier I2C driver" depends on ARCH_UNIPHIER && DM_I2C
drivers/i2c/Makefile +1 -0
@@ -38,6 +38,7 @@ obj-$(CONFIG_SYS_I2C_S3C24X0) += s3c24x0_i2c.o exynos_hs_i2c.o obj-$(CONFIG_SYS_I2C_SANDBOX) += sandbox_i2c.o i2c-emul-uclass.o obj-$(CONFIG_SYS_I2C_SH) += sh_i2c.o obj-$(CONFIG_SYS_I2C_SOFT) += soft_i2c.o +obj-$(CONFIG_SYS_I2C_STM32F7) += stm32f7_i2c.o obj-$(CONFIG_SYS_I2C_TEGRA) += tegra_i2c.o obj-$(CONFIG_SYS_I2C_UNIPHIER) += i2c-uniphier.o obj-$(CONFIG_SYS_I2C_UNIPHIER_F) += i2c-uniphier-f.o
drivers/i2c/stm32f7_i2c.c new file +882 -0
882 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 1/1 i2c: add i2c driver for stm32
Quoted 32 lines · On 9 August 2017 at 06:45, <[email protected]> wrote:
From: Patrice Chotard <[email protected]>
Add i2c driver which can be used on both STM32F7 and STM32H7. This I2C block supports the following features:
_ Slave and master modes
_ Multimaster capability
_ Standard-mode (up to 100 kHz)
_ Fast-mode (up to 400 kHz)
_ Fast-mode Plus (up to 1 MHz)
_ 7-bit and 10-bit addressing mode
_ Multiple 7-bit slave addresses (2 addresses, 1 with configurable mask) _ All 7-bit addresses acknowledge mode
_ General call
_ Programmable setup and hold times
_ Easy to use event management
_ Optional clock stretching
_ Software resetSigned-off-by Christophe Kerello <[email protected]>Signed-off-by Patrice Chotard <[email protected]>---
v2: _ add I2C controller description in
Kconfig
_ renamestm32_i2c_devstruct tostm32_i2c_priv
_ add comment forstm32_i2c_handle_reload()
_ splitstm32_i2c_compute_timing()code and add :
_stm32_i2c_compute_solutions()which computes list of possible timings candidate _stm32_i2c_choose_solution()which selects the best timing
_ use #defines instead of hard coded vlaue for speed in
stm32_i2c_set_bus_speed()and in i2c_specs[] array
_ move part of code ofstm32_i2c_probe()insidestm32_ofdata_to_platdata()
Quoted 7 lines
doc/device-tree-bindings/i2c/i2c-stm32.txt | 30 + drivers/i2c/Kconfig | 20 + drivers/i2c/Makefile | 1 + drivers/i2c/stm32f7_i2c.c | 882 +++++++++++++++++++++++++++++ 4 files changed, 933 insertions(+) create mode 100644 doc/device-tree-bindings/i2c/i2c-stm32.txt create mode 100644 drivers/i2c/stm32f7_i2c.c
PATCH v2 1/1 i2c: add i2c driver for stm32
In reply to patrice.chotard at st.comHello Partrice,
Am 09.08.2017 um 14:45 schrieb patrice.chotard at st.com:
Quoted 32 lines
From: Patrice Chotard <[email protected]>
Add i2c driver which can be used on both STM32F7 and STM32H7. This I2C block supports the following features:
_ Slave and master modes
_ Multimaster capability
_ Standard-mode (up to 100 kHz)
_ Fast-mode (up to 400 kHz)
_ Fast-mode Plus (up to 1 MHz)
_ 7-bit and 10-bit addressing mode
_ Multiple 7-bit slave addresses (2 addresses, 1 with configurable mask) _ All 7-bit addresses acknowledge mode
_ General call
_ Programmable setup and hold times
_ Easy to use event management
_ Optional clock stretching
_ Software resetSigned-off-by Christophe Kerello <[email protected]>Signed-off-by Patrice Chotard <[email protected]>---
v2: _ add I2C controller description in
Kconfig
_ renamestm32_i2c_devstruct tostm32_i2c_priv
_ add comment forstm32_i2c_handle_reload()
_ splitstm32_i2c_compute_timing()code and add :
_stm32_i2c_compute_solutions()which computes list of possible timings candidate _stm32_i2c_choose_solution()which selects the best timing
_ use #defines instead of hard coded vlaue for speed in
stm32_i2c_set_bus_speed()and in i2c_specs[] array
_ move part of code ofstm32_i2c_probe()insidestm32_ofdata_to_platdata()
Quoted 7 lines
doc/device-tree-bindings/i2c/i2c-stm32.txt | 30 + drivers/i2c/Kconfig | 20 + drivers/i2c/Makefile | 1 + drivers/i2c/stm32f7_i2c.c | 882 +++++++++++++++++++++++++++++ 4 files changed, 933 insertions(+)create mode 100644
doc/device-tree-bindings/i2c/i2c-stm32.txtcreate mode 100644drivers/i2c/stm32f7_i2c.c
Applied to u-boot-i2c.git master
Thanks!
bye,
Heiko
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany