public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Eugen Hristev <eugen.hristev@microchip.com>
To: u-boot@lists.denx.de
Subject: [PATCH 1/2] gpio: atmel_pio4: add support for sama7g5 pio4 version with 5 banks
Date: Wed, 7 Apr 2021 11:39:28 +0300	[thread overview]
Message-ID: <20210407083929.287218-1-eugen.hristev@microchip.com> (raw)

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 <eugen.hristev@microchip.com>
---
 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 f615fce32e..bea609db9d 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)&microchip_sama7g5_pioctrl_data,
 	},
 	{}
 };
-- 
2.25.1

             reply	other threads:[~2021-04-07  8:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-07  8:39 Eugen Hristev [this message]
2021-04-07  8:39 ` [PATCH 2/2] ARM: dts: at91: sama7g5: change pinctrl compatible to sama7g5 Eugen Hristev
2021-04-19  7:41 ` [PATCH 1/2] gpio: atmel_pio4: add support for sama7g5 pio4 version with 5 banks Eugen.Hristev at microchip.com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210407083929.287218-1-eugen.hristev@microchip.com \
    --to=eugen.hristev@microchip.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox