Skip to contentSkip to conversation

i2c: new bus driver for efm32

PATCH Superseded Uwe Kleine-König 1 participant 2 messages Mar 20, 2014 – Mar 21, 2014

Subsystems (2)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 i2c: new bus driver for efm32

This was tested on a EFM32GG-DK3750 devboard that has a temperature sensor and an eeprom on its i2c bus.

---
Notes:
Changes since (implicit) v1, sent with Message-Id: 1392027598-29015-1-git-send-email-u.kleine-koenig at pengutronix.de
- drop non-dt support
- drop locking
- don't only use -EIO on error
- drop many dev_dbg
- use reinit_completion instead of (repeated) init_completion
- fix .remove callback to also remove the i2c adapter
- use -EINVAL for clock problems
- use namespace for location property
- don't BUG but reset hardware on unexpected failure
- add dt binding doc

 .../devicetree/bindings/i2c/i2c-efm32.txt          |  34 ++
 drivers/i2c/busses/Kconfig                         |   7 +
 drivers/i2c/busses/Makefile                        |   1 +
 drivers/i2c/busses/i2c-efm32.c                     | 482 +++++++++++++++++++++
 4 files changed, 524 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-efm32.txt
 create mode 100644 drivers/i2c/busses/i2c-efm32.c
Documentation/devicetree/bindings/i2c/i2c-efm32.txt new file +33 -0
new file mode 100644
@@ -0,0 +1,33 @@
+* Energymicro efm32 i2c controller
+
+Required properties :
+
+ - reg : Offset and length of the register set for the device
+ - compatible : should be "efm32,i2c"
+ - interrupts : the interrupt number
+ - clocks : reference to the module clock
+
+Recommended properties :
+
+ - clock-frequency : maximal I2C bus clock frequency in Hz.
+ - efm32,location : Decides the location of the USART I/O pins.
+   Allowed range : [0 .. 6]
+
+Example:
+	i2c0: i2c at 4000a000 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		compatible = "efm32,i2c";
+		reg = <0x4000a000 0x400>;
+		interrupts = <9>;
+		clocks = <&cmu clk_HFPERCLKI2C0>;
+		clock-frequency = <100000>;
+		efm32,location = <3>;
+
+		eeprom at 50 {
+			compatible = "microchip,24c02";
+			reg = <0x50>;
+			pagesize = <16>;
+		};
+	};
+
drivers/i2c/busses/Kconfig +7 -0
index f5ed03164d86..7322ff0c4c60 100644
@@ -432,6 +432,13 @@ config I2C_DESIGNWARE_PCI
 	  This driver can also be built as a module.  If so, the module
 	  will be called i2c-designware-pci.
 
+config I2C_EFM32
+	tristate "EFM32 I2C controller"
+	depends on OF && (ARCH_EFM32 || COMPILE_TEST)
+	help
+	  This driver supports the i2c block found in Energy Micro's EFM32
+	  SoCs.
+
 config I2C_EG20T
 	tristate "Intel EG20T PCH/LAPIS Semicon IOH(ML7213/ML7223/ML7831) I2C"
 	depends on PCI
drivers/i2c/busses/Makefile +1 -0
index a08931fe73e1..2a56ab181851 100644
@@ -41,6 +41,7 @@ obj-$(CONFIG_I2C_DESIGNWARE_PLATFORM)	+= i2c-designware-platform.o
 i2c-designware-platform-objs := i2c-designware-platdrv.o
 obj-$(CONFIG_I2C_DESIGNWARE_PCI)	+= i2c-designware-pci.o
 i2c-designware-pci-objs := i2c-designware-pcidrv.o
+obj-$(CONFIG_I2C_EFM32)		+= i2c-efm32.o
 obj-$(CONFIG_I2C_EG20T)		+= i2c-eg20t.o
 obj-$(CONFIG_I2C_EXYNOS5)	+= i2c-exynos5.o
 obj-$(CONFIG_I2C_GPIO)		+= i2c-gpio.o
drivers/i2c/busses/i2c-efm32.c new file +482 -0

482 lines not on this page · raw message

Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 1/1 i2c: new bus driver for efm32

Hello,

Quoted 4 lines · Uwe Kleine-K?nig

This was tested on a EFM32GG-DK3750 devboard that has a temperature sensor and an eeprom on its i2c bus.

I screwed up testing and the driver doesn't even compile. Will send v3 in a moment.

Best regards and sorry,
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |