From patchwork Wed Apr 7 08:39:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugen Hristev X-Patchwork-Id: 1463248 X-Patchwork-Delegate: eugen.hristev@microchip.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=microchip.com header.i=@microchip.com header.a=rsa-sha256 header.s=mchp header.b=NRGMLbPk; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FFdBJ5F4hz9sRR for ; Wed, 7 Apr 2021 18:40:08 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 50FC880433; Wed, 7 Apr 2021 10:39:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=quarantine dis=none) header.from=microchip.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=microchip.com header.i=@microchip.com header.b="NRGMLbPk"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5F43680C67; Wed, 7 Apr 2021 10:39:54 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E6C1F80023 for ; Wed, 7 Apr 2021 10:39:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=microchip.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=Eugen.Hristev@microchip.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1617784790; x=1649320790; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=hycWFSzOFfm8xSB7QZE1/NgawUvHn0JLkjfwijxyNwQ=; b=NRGMLbPkIJhWJQ4BLjFSvX1Ve7+Li6MjFoe+uqD/e56oL9farGkO1+nF 2Ct9NAYf3Oj17nArhwIRyIkAf5nUn2QucGskPW3D0PPnVqln3IUyAh9Yk Hl8esvrr5qN+e/4dPfTWoTi2ffQT19z0nuiD3r1PtKwzZFoNmBKhuRFE3 Z0kw0FhLf+oDGb+fQuybdddeB8ozEopqXnN6mpne7tMkepbUjLH2GhXy2 sZF2oAB2I/OkvW2vEivvzdmTXQXoOQqZiedItjrx/tOW904N+hp8F3hr+ bhln/w/Sr49B1qZwaz4ENzAS75YBaDShMhsXcpkG1sw9IrWZ5qHJRbFGo Q==; IronPort-SDR: nHsyz0EIJzLY5/H+bKUKsXsgY1dE6CqTcpKz7bXQs+seZ/ugv/mbgYrajLKToU4zuQLosEXlVb pF6NowhRFgMOi03X8jNh3EMZFFDn1DKgc+L1yGrevGonXGOxLbCh0ZjGPxy4+y0EHz4w6jrwDe Wy9viZSHWzgbdAIgZdBI93GVa5/PWmK5IAenMfSxC3/1vl8LKHxKUD6AqkUtsDM2kMCy43byIa /QN1682dBGOYmsLrGAbBwBD3jMTONfxGo9823g/YaIxeNKzwdvgB2FHLolo2N9skoxGWR2UU5N Jb0= X-IronPort-AV: E=Sophos;i="5.82,203,1613458800"; d="scan'208";a="109942660" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 07 Apr 2021 01:39:43 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 7 Apr 2021 01:39:43 -0700 Received: from ROB-ULT-M18282.microchip.com (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2176.2 via Frontend Transport; Wed, 7 Apr 2021 01:39:40 -0700 From: Eugen Hristev To: CC: Eugen Hristev 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 Message-ID: <20210407083929.287218-1-eugen.hristev@microchip.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.4 at phobos.denx.de X-Virus-Status: Clean 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 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)µchip_sama7g5_pioctrl_data, }, {} };