add TCB driver for sama5d2
v8 cover add TCB driver for sama5d2
When booting under OP-TEE, the SYSC is secured which means the PIT is also not accessible by non-secure world. The TCB 0 however is always available for non-secure world and thus can be used.
This series add a TCB driver and enables it in sama5d2 configs.
---
Changes in v8:
- Switch clock to use t0_clk, generated clk does not works if parent clock is slow_ck. Moreover, tcb0_clk needs to be enabled for the TCB to operate correctly
- Change driver to use TCB_CMR_TIMER_CLOCK2 (tcb0_clk / 8)
- Add potential missing clk_enable()
- Add u-boot,dm-pre-reloc properties to TCB nodes and to its dependencies in order to be used in SPL
Changes in v7:
- Keep the exact same Linux aic node definition
- Fixed a few constant definition to use (1 << x)
Changes in V6:
- Fix node ordering in device tree
- Disable CONFIG_PIT_TIMER in sama5d2 configuration file
- Fixed mach-at91/armv7/Makefile to allow building with TCB
Changes in v5:
- Fixed missing include in .dts file for IRQ defines
- Add aic interrupt controller node to avoid DTC warnings
Changes in v4:
- Add missing interrupts property to tcb node
Changes in v3:
- Remove useless defines
- Add printf in case of unsupported timers specified in device-tree
- Add "syscon" compatible to tcb node
Changes in v2:
- Reworked driver to use existing Linux bindings
Clément Léger (5):
timer: atmel_tcb_timer: add atmel_tcb driver
ARM: dts: at91: sama5d2: add AIC node
ARM: dts: at91: sama5d2: add TCB node
ARM: dts: at91: sama5d2: add u-boot,dm-pre-reloc property for TCB
configs: sama5d2: enable option CONFIG_ATMEL_TCB_TIMER
MAINTAINERS | 1 + arch/arm/dts/sama5d2.dtsi | 28 ++++ arch/arm/mach-at91/armv7/Makefile | 2 + configs/sama5d2_icp_mmc_defconfig | 2 +- configs/sama5d2_ptc_ek_mmc_defconfig | 2 +- configs/sama5d2_ptc_ek_nandflash_defconfig | 2 +- configs/sama5d2_xplained_emmc_defconfig | 2 +- configs/sama5d2_xplained_mmc_defconfig | 2 +- configs/sama5d2_xplained_qspiflash_defconfig | 2 +- configs/sama5d2_xplained_spiflash_defconfig | 2 +- drivers/timer/Kconfig | 8 + drivers/timer/Makefile | 1 + drivers/timer/atmel_tcb_timer.c | 161 +++++++++++++++++++ 13 files changed, 208 insertions(+), 7 deletions(-) create mode 100644 drivers/timer/atmel_tcb_timer.c
Signature · 1 line
2.34.1
PATCH v8 1/5 timer: atmel_tcb_timer: add atmel_tcb driver
Add a driver for the timer counter block that can be found on sama5d2. This driver will be used when booting under OP-TEE since the pit timer which is part of the SYSC is secured. Channel 1 & 2 are configured to be chained together which allows to have a 64bits counter.
--- MAINTAINERS | 1 + arch/arm/mach-at91/armv7/Makefile | 2 + drivers/timer/Kconfig | 8 ++ drivers/timer/Makefile | 1 + drivers/timer/atmel_tcb_timer.c | 161 ++++++++++++++++++++++++++++++ 5 files changed, 173 insertions(+) create mode 100644 drivers/timer/atmel_tcb_timer.c
MAINTAINERS +1 -0
@@ -352,6 +352,7 @@ F: arch/arm/mach-at91/ F: board/atmel/ F: drivers/cpu/at91_cpu.c F: drivers/misc/microchip_flexcom.c +F: drivers/timer/atmel_tcb_timer.c F: include/dt-bindings/mfd/atmel-flexcom.h F: drivers/timer/mchp-pit64b-timer.c
arch/arm/mach-at91/armv7/Makefile +2 -0
@@ -14,9 +14,11 @@ obj-y += cpu.o ifndef CONFIG_$(SPL_TPL_)SYSRESET obj-y += reset.o endif +ifneq ($(CONFIG_ATMEL_TCB_TIMER),y) ifneq ($(CONFIG_ATMEL_PIT_TIMER),y) ifneq ($(CONFIG_MCHP_PIT64B_TIMER),y) # old non-DM timer driver obj-y += timer.o endif endif +endif
drivers/timer/Kconfig +8 -0
@@ -96,6 +96,14 @@ config ATMEL_PIT_TIMER it is designed to offer maximum accuracy and efficient management, even for systems with long response time. +config ATMEL_TCB_TIMER + bool "Atmel timer counter support" + depends on TIMER + depends on ARCH_AT91 + help + Select this to enable the use of the timer counter as a monotonic + counter. + config CADENCE_TTC_TIMER bool "Cadence TTC (Triple Timer Counter)" depends on TIMER
drivers/timer/Makefile +1 -0
@@ -10,6 +10,7 @@ obj-$(CONFIG_ARC_TIMER) += arc_timer.o obj-$(CONFIG_AST_TIMER) += ast_timer.o obj-$(CONFIG_ATCPIT100_TIMER) += atcpit100_timer.o obj-$(CONFIG_ATMEL_PIT_TIMER) += atmel_pit_timer.o +obj-$(CONFIG_ATMEL_TCB_TIMER) += atmel_tcb_timer.o obj-$(CONFIG_CADENCE_TTC_TIMER) += cadence-ttc.o obj-$(CONFIG_DESIGNWARE_APB_TIMER) += dw-apb-timer.o obj-$(CONFIG_MPC83XX_TIMER) += mpc83xx_timer.o
drivers/timer/atmel_tcb_timer.c new file +161 -0
161 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v8 2/5 ARM: dts: at91: sama5d2: add AIC node
In reply to Clément LégerWhen using interrupts property, a global interrupt controller needs to be added to avoid warnings when compiling device-tree:
arch/arm/dts/at91-sama5d2_xplained.dtb: Warning (interrupts_property):
/ahb/apb/timer@f800c000: Missing interrupt-parent
Add AIC node as the sama5d2 global interrupt controller.
--- arch/arm/dts/sama5d2.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/arm/dts/sama5d2.dtsi +9 -0
@@ -3,6 +3,7 @@ / { model = "Atmel SAMA5D2 family SoC"; compatible = "atmel,sama5d2"; + interrupt-parent = <&aic>; aliases { spi0 = &spi0;
@@ -762,6 +763,14 @@ status = "disabled"; }; + aic: interrupt-controller@fc020000 { + #interrupt-cells = <3>; + compatible = "atmel,sama5d2-aic"; + interrupt-controller; + reg = <0xfc020000 0x200>; + atmel,external-irqs = <49>; + }; + i2c1: i2c@fc028000 { compatible = "atmel,sama5d2-i2c"; reg = <0xfc028000 0x100>;
Signature · 1 line
2.34.1
PATCH v8 3/5 ARM: dts: at91: sama5d2: add TCB node
In reply to Clément LégerAdd the device-tree node to describe the TCB timer.
--- arch/arm/dts/sama5d2.dtsi | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
arch/arm/dts/sama5d2.dtsi +16 -0
@@ -1,4 +1,5 @@ #include "skeleton.dtsi" +#include <dt-bindings/interrupt-controller/irq.h> / { model = "Atmel SAMA5D2 family SoC";
@@ -639,6 +640,21 @@ status = "disabled"; }; + tcb0: timer@f800c000 { + compatible = "atmel,sama5d2-tcb", "simple-mfd", "syscon"; + reg = <0xf800c000 0x100>; + interrupts = <35 IRQ_TYPE_LEVEL_HIGH 0>; + clocks = <&tcb0_clk>, <&tcb0_gclk>, <&clk32k>; + clock-names = "t0_clk", "gclk", "slow_clk"; + #address-cells = <1>; + #size-cells = <0>; + + timer0: timer@0 { + compatible = "atmel,tcb-timer"; + reg = <0>, <1>; + }; + }; + uart0: serial@f801c000 { compatible = "atmel,at91sam9260-usart"; reg = <0xf801c000 0x100>;
Signature · 1 line
2.34.1
PATCH v8 4/5 ARM: dts: at91: sama5d2: add u-boot, dm-pre-reloc property for TCB
In reply to Clément LégerIn order to use the TCB early in boot and in the SPL, add u-boot,dm-pre-reloc property for the TCB and the clock that is used by the driver (tcb0_clk).
--- arch/arm/dts/sama5d2.dtsi | 3 +++ 1 file changed, 3 insertions(+)
arch/arm/dts/sama5d2.dtsi +3 -0
@@ -363,6 +363,7 @@ #clock-cells = <0>; reg = <35>; atmel,clk-output-range = <0 83000000>; + u-boot,dm-pre-reloc; }; tcb1_clk: tcb1_clk@36 {
@@ -648,10 +649,12 @@ clock-names = "t0_clk", "gclk", "slow_clk"; #address-cells = <1>; #size-cells = <0>; + u-boot,dm-pre-reloc; timer0: timer@0 { compatible = "atmel,tcb-timer"; reg = <0>, <1>; + u-boot,dm-pre-reloc; }; };
Signature · 1 line
2.34.1
PATCH v8 5/5 configs: sama5d2: enable option CONFIG_ATMEL_TCB_TIMER
In reply to Clément LégerEnable CONFIG_ATMEL_TCB_TIMER and disable CONFIG_ATMEL_PIT_TIMER. This will allow using the TCB timer instead of the PIT one when running under OP-TEE.
--- configs/sama5d2_icp_mmc_defconfig | 2 +- configs/sama5d2_ptc_ek_mmc_defconfig | 2 +- configs/sama5d2_ptc_ek_nandflash_defconfig | 2 +- configs/sama5d2_xplained_emmc_defconfig | 2 +- configs/sama5d2_xplained_mmc_defconfig | 2 +- configs/sama5d2_xplained_qspiflash_defconfig | 2 +- configs/sama5d2_xplained_spiflash_defconfig | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-)
configs/sama5d2_icp_mmc_defconfig +1 -1
@@ -82,6 +82,6 @@ CONFIG_DEBUG_UART_ANNOUNCE=y CONFIG_ATMEL_USART=y CONFIG_TIMER=y CONFIG_SPL_TIMER=y -CONFIG_ATMEL_PIT_TIMER=y +CONFIG_ATMEL_TCB_TIMER=y CONFIG_OF_LIBFDT_OVERLAY=y # CONFIG_EFI_LOADER_HII is not set
configs/sama5d2_ptc_ek_mmc_defconfig +1 -1
@@ -71,7 +71,7 @@ CONFIG_DM_SERIAL=y CONFIG_DEBUG_UART_ANNOUNCE=y CONFIG_ATMEL_USART=y CONFIG_TIMER=y -CONFIG_ATMEL_PIT_TIMER=y +CONFIG_ATMEL_TCB_TIMER=y CONFIG_USB=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_STORAGE=y
configs/sama5d2_ptc_ek_nandflash_defconfig +1 -1
@@ -71,7 +71,7 @@ CONFIG_DM_SERIAL=y CONFIG_DEBUG_UART_ANNOUNCE=y CONFIG_ATMEL_USART=y CONFIG_TIMER=y -CONFIG_ATMEL_PIT_TIMER=y +CONFIG_ATMEL_TCB_TIMER=y CONFIG_USB=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_STORAGE=y
configs/sama5d2_xplained_emmc_defconfig +1 -1
@@ -90,7 +90,7 @@ CONFIG_DM_SPI=y CONFIG_ATMEL_QSPI=y CONFIG_TIMER=y CONFIG_SPL_TIMER=y -CONFIG_ATMEL_PIT_TIMER=y +CONFIG_ATMEL_TCB_TIMER=y CONFIG_USB=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_STORAGE=y
configs/sama5d2_xplained_mmc_defconfig +1 -1
@@ -92,7 +92,7 @@ CONFIG_DM_SPI=y CONFIG_ATMEL_QSPI=y CONFIG_TIMER=y CONFIG_SPL_TIMER=y -CONFIG_ATMEL_PIT_TIMER=y +CONFIG_ATMEL_TCB_TIMER=y CONFIG_USB=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_STORAGE=y
configs/sama5d2_xplained_qspiflash_defconfig +1 -1
@@ -91,7 +91,7 @@ CONFIG_DM_SPI=y CONFIG_ATMEL_QSPI=y CONFIG_TIMER=y CONFIG_SPL_TIMER=y -CONFIG_ATMEL_PIT_TIMER=y +CONFIG_ATMEL_TCB_TIMER=y CONFIG_USB=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_STORAGE=y
configs/sama5d2_xplained_spiflash_defconfig +1 -1
@@ -95,7 +95,7 @@ CONFIG_DM_SPI=y CONFIG_ATMEL_QSPI=y CONFIG_TIMER=y CONFIG_SPL_TIMER=y -CONFIG_ATMEL_PIT_TIMER=y +CONFIG_ATMEL_TCB_TIMER=y CONFIG_USB=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_STORAGE=y
Signature · 1 line
2.34.1
Quoted 6 lines · Clément Léger
When booting under OP-TEE, the SYSC is secured which means the PIT is also not accessible by non-secure world. The TCB 0 however is always available for non-secure world and thus can be used.
This series add a TCB driver and enables it in sama5d2 configs.---
Applied to u-boot-at91/next , thanks !