From e1038ac0cb71416829c05a22e2831ca70c9a7025 Mon Sep 17 00:00:00 2001 From: Eugen Hristev Date: Wed, 7 Apr 2021 11:39:28 +0300 Subject: gpio: atmel_pio4: add support for sama7g5 pio4 version with 5 banks Add support for sama7g5 pinctrl variant, with 5 banks with a degraded 8 line only 5th bank. Based on Linux Kernel implementation. Signed-off-by: Eugen Hristev --- drivers/gpio/atmel_pio4.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/gpio/atmel_pio4.c b/drivers/gpio/atmel_pio4.c index f615fce32e1..bea609db9df 100644 --- a/drivers/gpio/atmel_pio4.c +++ b/drivers/gpio/atmel_pio4.c @@ -173,8 +173,15 @@ int atmel_pio4_get_pio_input(u32 port, u32 pin) #if CONFIG_IS_ENABLED(DM_GPIO) +/** + * struct atmel_pioctrl_data - Atmel PIO controller (pinmux + gpio) data struct + * @nbanks: number of PIO banks + * @last_bank_count: number of lines in the last bank (can be less than + * the rest of the banks). + */ struct atmel_pioctrl_data { u32 nbanks; + u32 last_bank_count; }; struct atmel_pio4_plat { @@ -313,6 +320,12 @@ static int atmel_pio4_probe(struct udevice *dev) NULL); uc_priv->gpio_count = nbanks * ATMEL_PIO_NPINS_PER_BANK; + /* if last bank has limited number of pins, adjust accordingly */ + if (pioctrl_data->last_bank_count != ATMEL_PIO_NPINS_PER_BANK) { + uc_priv->gpio_count -= ATMEL_PIO_NPINS_PER_BANK; + uc_priv->gpio_count += pioctrl_data->last_bank_count; + } + return 0; } @@ -322,12 +335,21 @@ static int atmel_pio4_probe(struct udevice *dev) */ static const struct atmel_pioctrl_data atmel_sama5d2_pioctrl_data = { .nbanks = 4, + .last_bank_count = ATMEL_PIO_NPINS_PER_BANK, +}; + +static const struct atmel_pioctrl_data microchip_sama7g5_pioctrl_data = { + .nbanks = 5, + .last_bank_count = 8, /* 5th bank has only 8 lines on sama7g5 */ }; static const struct udevice_id atmel_pio4_ids[] = { { .compatible = "atmel,sama5d2-gpio", .data = (ulong)&atmel_sama5d2_pioctrl_data, + }, { + .compatible = "microchip,sama7g5-gpio", + .data = (ulong)µchip_sama7g5_pioctrl_data, }, {} }; -- cgit v1.2.3 From 53d76647112deb1a5f9b551a243560959c00f190 Mon Sep 17 00:00:00 2001 From: Eugen Hristev Date: Wed, 7 Apr 2021 11:39:29 +0300 Subject: ARM: dts: at91: sama7g5: change pinctrl compatible to sama7g5 Change the pinctrl compatible to sama7g5, the right one for this product. Signed-off-by: Eugen Hristev --- arch/arm/dts/sama7g5.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/dts/sama7g5.dtsi b/arch/arm/dts/sama7g5.dtsi index 0cb6eaf5d06..b951aff43e2 100644 --- a/arch/arm/dts/sama7g5.dtsi +++ b/arch/arm/dts/sama7g5.dtsi @@ -63,7 +63,7 @@ #size-cells = <1>; pioA: pinctrl@e0014000 { - compatible = "atmel,sama5d2-gpio"; + compatible = "microchip,sama7g5-gpio"; reg = <0xe0014000 0x800>; gpio-controller; #gpio-cells = <2>; -- cgit v1.2.3 From b0080ae1bbfe78caf9cc43cef2b8fdcc75cc4320 Mon Sep 17 00:00:00 2001 From: Manuel Reis Date: Tue, 6 Apr 2021 10:39:53 +0100 Subject: ARM: dts: at91: sama5d3: add u-boot properties to sama5d3 pit timer in the early SPL boot stage whenever there is a call to udelay, dm_timer_init fails to find the pit timer whenever it traverses the device tree, if this property is not present Signed-off-by: Manuel Reis CC: Eugen Hristev Tested-by: Derald D. Woods Reviewed-by: Eugen Hristev --- arch/arm/dts/sama5d3.dtsi | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/dts/sama5d3.dtsi b/arch/arm/dts/sama5d3.dtsi index 6ed218eaad3..42c30e9f307 100644 --- a/arch/arm/dts/sama5d3.dtsi +++ b/arch/arm/dts/sama5d3.dtsi @@ -1320,6 +1320,7 @@ reg = <0xfffffe30 0xf>; interrupts = <3 IRQ_TYPE_LEVEL_HIGH 5>; clocks = <&mck>; + u-boot,dm-pre-reloc; }; watchdog@fffffe40 { -- cgit v1.2.3