Skip to contentSkip to conversation

clk: at91: add new driver for Flexcom

PATCH In review Cyrille Pitchen 3 participants 5 messages Jun 2, 2015

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v2 cover clk: at91: add new driver for Flexcom

ChangeLog

v2:
- fix commit message

v1:
This series of patches introduces a new driver for the Atmel Flexcom.

Cyrille Pitchen (2):
clk: at91: add a new compatible string for Flexcom in the DT
documentation
clk: at91: add Flexcom clock

 .../devicetree/bindings/clock/at91-clock.txt       |  20 +++
 arch/arm/mach-at91/Kconfig                         |   3 +
 drivers/clk/at91/Makefile                          |   1 +
 drivers/clk/at91/clk-flexcom.c                     | 160 +++++++++++++++++++++
 4 files changed, 184 insertions(+)
 create mode 100644 drivers/clk/at91/clk-flexcom.c
Signature · 1 line
1.8.2.2
#1 lore raw

PATCH v2 1/2 clk: at91: add a new compatible string for Flexcom in the DT documentation

This patches documents the new bindings for the Flexcom clock, which will be introduced by Atmel sama5d2x chips.

---
 .../devicetree/bindings/clock/at91-clock.txt         | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
Documentation/devicetree/bindings/clock/at91-clock.txt +20 -0
index 7a4d492..df4f40b 100644
@@ -77,6 +77,9 @@ Required properties:
 	"atmel,sama5d4-clk-h32mx":
 		at91 h32mx clock
 
+	"atmel,sama5d2-flexcom":
+		at91 flexcom clock
+
 Required properties for SCKC node:
 - reg : defines the IO memory reserved for the SCKC.
 - #size-cells : shall be 0 (reg is used to encode clk id).
@@ -461,3 +464,20 @@ For example:
 		compatible = "atmel,sama5d4-clk-h32mx";
 		clocks = <&mck>;
 	};
+
+Required properties for flexcom clock:
+- #clock-cells : from common clock binding; shall be set to 0.
+- clocks : shall be the Flexcom peripheral clock from PMC.
+- reg : shall be the range for Flexcom dedicated I/O registers (without USART,
+  TWI or SPI registers).
+- atmel,flexcom-mode : shall be a string value among { "spi", "usart", "i2c",
+  "twi" }. "i2c" and "twi" are synonymous.
+
+For example:
+	flx0: flexcom at f8034000 {
+		compatible = "atmel,sama5d2-flexcom";
+		#clock-cells = <0>;
+		reg = <0xf8034000 0x200>;
+		clocks = <&flx0_clk>;
+		atmel,flexcom-mode = "spi";
+	};
Signature · 1 line
1.8.2.2
#2 lore raw

PATCH v2 2/2 clk: at91: add Flexcom clock

In reply to Cyrille Pitchen

This driver supports the new Atmel Flexcom. The Flexcom is a wrapper which integrates one SPI controller, one I2C controller and one USART. Only one function can be enabled at a time. This driver selects the function once for all, when the Flexcom is probed, according to the value of the new "atmel,flexcom-mode" device tree property.

This driver has chosen to present the Flexcom to the system as a clock so the implementation is seamless for the existing Atmel SPI, I2C and USART drivers.

Also the Flexcom embeds FIFOs: the latest patches of the SPI, I2C and USART drivers take advantage of this new feature.

---
 arch/arm/mach-at91/Kconfig     |   3 +
 drivers/clk/at91/Makefile      |   1 +
 drivers/clk/at91/clk-flexcom.c | 160 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 164 insertions(+)
 create mode 100644 drivers/clk/at91/clk-flexcom.c
arch/arm/mach-at91/Kconfig +3 -0
index fd95f34..8ce9b73 100644
@@ -90,6 +90,9 @@ config HAVE_AT91_SMD
 config HAVE_AT91_H32MX
 	bool
 
+config HAVE_AT91_FLEXCOM
+	bool
+
 config SOC_SAM_V4_V5
 	bool
 
drivers/clk/at91/Makefile +1 -0
index 89a48a7..74711b8 100644
@@ -10,3 +10,4 @@ obj-$(CONFIG_HAVE_AT91_UTMI)		+= clk-utmi.o
 obj-$(CONFIG_HAVE_AT91_USB_CLK)		+= clk-usb.o
 obj-$(CONFIG_HAVE_AT91_SMD)		+= clk-smd.o
 obj-$(CONFIG_HAVE_AT91_H32MX)		+= clk-h32mx.o
+obj-$(CONFIG_HAVE_AT91_FLEXCOM)		+= clk-flexcom.o
drivers/clk/at91/clk-flexcom.c new file +160 -0

160 lines not on this page · raw message

Signature · 1 line
1.8.2.2
#3 lore raw

Re: [PATCH v2 2/2] clk: at91: add Flexcom clock

Hi Cyrille,

Quoted 8 lines · On Tue, 2 Jun 2015 18:57:19 +0200 Cyrille Pitchen <[email protected]>…

This driver supports the new Atmel Flexcom. The Flexcom is a wrapper which integrates one SPI controller, one I2C controller and one USART. Only one function can be enabled at a time. This driver selects the function once for all, when the Flexcom is probed, according to the value of the new "atmel,flexcom-mode" device tree property.

This driver has chosen to present the Flexcom to the system as a clock so the implementation is seamless for the existing Atmel SPI, I2C and USART drivers.

Could detail a bit more why you chose to represent this flexcom IP as a clock device ?

I don't like to use this 'DT should represent real hardware' argument, but to me, it looks like you're trying to use a false hardware representation to avoid changing the peripheral drivers code, which is wrong since the DT is supposed to represent the hardware blocks.

How about representing the flexcom as an MFD instead ?

Best Regards,

Boris

Signature · 3 lines
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#4 lore raw

Re: [PATCH v2 2/2] clk: at91: add Flexcom clock

Quoted 17 lines · Boris Brezillon

Hi Cyrille,

Quoted 8 lines · On Tue, 2 Jun 2015 18:57:19 +0200 Cyrille Pitchen <[email protected]>…

This driver supports the new Atmel Flexcom. The Flexcom is a wrapper which integrates one SPI controller, one I2C controller and one USART. Only one function can be enabled at a time. This driver selects the function once for all, when the Flexcom is probed, according to the value of the new "atmel,flexcom-mode" device tree property.

This driver has chosen to present the Flexcom to the system as a clock so the implementation is seamless for the existing Atmel SPI, I2C and USART drivers.

Could detail a bit more why you chose to represent this flexcom IP as a clock device ?

Quoted 7 lines

I don't like to use this 'DT should represent real hardware' argument, but to me, it looks like you're trying to use a false hardware representation to avoid changing the peripheral drivers code, which is wrong since the DT is supposed to represent the hardware blocks.

How about representing the flexcom as an MFD instead ?

It should probably be represented as an MFD. The MFD driver will parse the chosen configuration and the probe the correct driver. You can have a look at the recent ST LPC driver from Lee.

Signature · 3 lines
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com