From patchwork Sat May 9 10:35:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hui Song X-Patchwork-Id: 206938 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8CCB9C28CBC for ; Sat, 9 May 2020 10:40:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 68AC0214D8 for ; Sat, 9 May 2020 10:40:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726951AbgEIKkY (ORCPT ); Sat, 9 May 2020 06:40:24 -0400 Received: from inva021.nxp.com ([92.121.34.21]:44350 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726877AbgEIKkX (ORCPT ); Sat, 9 May 2020 06:40:23 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 1FEE42002EE; Sat, 9 May 2020 12:40:21 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 700A1200102; Sat, 9 May 2020 12:40:17 +0200 (CEST) Received: from localhost.localdomain (mega.ap.freescale.net [10.192.208.232]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id CFBE640285; Sat, 9 May 2020 18:40:12 +0800 (SGT) From: Hui Song To: jagdish.gediya@nxp.com, priyanka.jain@nxp.com, pramod.kumar_1@nxp.com Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, "hui.song" Subject: [PATCH v1 1/3] gpio: mpc8xxx: support fsl-layerscape platform. Date: Sat, 9 May 2020 18:35:35 +0800 Message-Id: <20200509103537.22865-1-hui.song_1@nxp.com> X-Mailer: git-send-email 2.17.1 X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: "hui.song" Make the MPC8XXX gpio driver to support the fsl-layerscape. Signed-off-by: hui.song --- drivers/gpio/mpc8xxx_gpio.c | 59 +++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/drivers/gpio/mpc8xxx_gpio.c b/drivers/gpio/mpc8xxx_gpio.c index 1dfd22522c..466f5f50cf 100644 --- a/drivers/gpio/mpc8xxx_gpio.c +++ b/drivers/gpio/mpc8xxx_gpio.c @@ -12,6 +12,8 @@ #include #include #include +#include +#include struct ccsr_gpio { u32 gpdir; @@ -20,6 +22,7 @@ struct ccsr_gpio { u32 gpier; u32 gpimr; u32 gpicr; + u32 gpibe; }; struct mpc8xxx_gpio_data { @@ -49,31 +52,51 @@ inline u32 gpio_mask(uint gpio) static inline u32 mpc8xxx_gpio_get_val(struct ccsr_gpio *base, u32 mask) { +#if CONFIG_ARM + return in_le32(&base->gpdat) & mask; +#else return in_be32(&base->gpdat) & mask; +#endif } static inline u32 mpc8xxx_gpio_get_dir(struct ccsr_gpio *base, u32 mask) { +#if CONFIG_ARM + return in_le32(&base->gpdir) & mask; +#else return in_be32(&base->gpdir) & mask; +#endif } static inline int mpc8xxx_gpio_open_drain_val(struct ccsr_gpio *base, u32 mask) { +#if CONFIG_ARM + return in_le32(&base->gpodr) & mask; +#else return in_be32(&base->gpodr) & mask; +#endif } static inline void mpc8xxx_gpio_open_drain_on(struct ccsr_gpio *base, u32 gpios) { +#if CONFIG_ARM + setbits_le32(&base->gpodr, gpios); +#else /* GPODR register 1 -> open drain on */ setbits_be32(&base->gpodr, gpios); +#endif } static inline void mpc8xxx_gpio_open_drain_off(struct ccsr_gpio *base, u32 gpios) { +#if CONFIG_ARM + clrbits_le32(&base->gpodr, gpios); +#else /* GPODR register 0 -> open drain off (actively driven) */ clrbits_be32(&base->gpodr, gpios); +#endif } static int mpc8xxx_gpio_direction_input(struct udevice *dev, uint gpio) @@ -81,9 +104,13 @@ static int mpc8xxx_gpio_direction_input(struct udevice *dev, uint gpio) struct mpc8xxx_gpio_data *data = dev_get_priv(dev); u32 mask = gpio_mask(gpio); +#if CONFIG_ARM + clrbits_le32(&data->base->gpdir, mask); +#else /* GPDIR register 0 -> input */ clrbits_be32(&data->base->gpdir, mask); +#endif return 0; } @@ -100,10 +127,19 @@ static int mpc8xxx_gpio_set_value(struct udevice *dev, uint gpio, int value) data->dat_shadow &= ~mask; } +#if CONFIG_ARM + gpdir = in_le32(&base->gpdir); +#else gpdir = in_be32(&base->gpdir); +#endif gpdir |= gpio_mask(gpio); +#if CONFIG_ARM + out_le32(&base->gpdat, gpdir & data->dat_shadow); + out_le32(&base->gpdir, gpdir); +#else out_be32(&base->gpdat, gpdir & data->dat_shadow); out_be32(&base->gpdir, gpdir); +#endif return 0; } @@ -147,13 +183,29 @@ static int mpc8xxx_gpio_ofdata_to_platdata(struct udevice *dev) { struct mpc8xxx_gpio_plat *plat = dev_get_platdata(dev); fdt_addr_t addr; + u32 i; +#if CONFIG_ARM + u32 reg[4]; + + dev_read_u32_array(dev, "reg", reg, 4); +#else u32 reg[2]; dev_read_u32_array(dev, "reg", reg, 2); +#endif + +#if CONFIG_ARM + for (i = 0; i < 2; i++) + reg[i] = be32_to_cpu(reg[i]); +#endif addr = dev_translate_address(dev, reg); plat->addr = addr; +#if CONFIG_ARM + plat->size = reg[3]; +#else plat->size = reg[1]; +#endif plat->ngpios = dev_read_u32_default(dev, "ngpios", 32); return 0; @@ -187,6 +239,7 @@ static int mpc8xxx_gpio_platdata_to_priv(struct udevice *dev) static int mpc8xxx_gpio_probe(struct udevice *dev) { struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); + struct device_node const *np = dev->node.np; struct mpc8xxx_gpio_data *data = dev_get_priv(dev); char name[32], *str; @@ -198,6 +251,12 @@ static int mpc8xxx_gpio_probe(struct udevice *dev) if (!str) return -ENOMEM; + if (of_device_is_compatible(np, "fsl,qoriq-gpio", NULL, NULL)) { + unsigned long gpibe = data->addr + sizeof(struct ccsr_gpio); + + out_be32(gpibe, 0xffffffff); + } + uc_priv->bank_name = str; uc_priv->gpio_count = data->gpio_count; From patchwork Sat May 9 10:35:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hui Song X-Patchwork-Id: 206937 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9236EC47254 for ; Sat, 9 May 2020 10:40:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6CDD021775 for ; Sat, 9 May 2020 10:40:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728190AbgEIKk0 (ORCPT ); Sat, 9 May 2020 06:40:26 -0400 Received: from inva021.nxp.com ([92.121.34.21]:44410 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726877AbgEIKkZ (ORCPT ); Sat, 9 May 2020 06:40:25 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 9201B200102; Sat, 9 May 2020 12:40:24 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 2638120032A; Sat, 9 May 2020 12:40:21 +0200 (CEST) Received: from localhost.localdomain (mega.ap.freescale.net [10.192.208.232]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 7DB0A40297; Sat, 9 May 2020 18:40:16 +0800 (SGT) From: Hui Song To: jagdish.gediya@nxp.com, priyanka.jain@nxp.com, pramod.kumar_1@nxp.com Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, "hui.song" Subject: [PATCH v1 2/3] armv8: gpio: add gpio feature Date: Sat, 9 May 2020 18:35:36 +0800 Message-Id: <20200509103537.22865-2-hui.song_1@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200509103537.22865-1-hui.song_1@nxp.com> References: <20200509103537.22865-1-hui.song_1@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: "hui.song" add one struct mpc8xxx_gpio_plat to enable gpio feature. Signed-off-by: hui.song --- .../include/asm/arch-fsl-layerscape/gpio.h | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 arch/arm/include/asm/arch-fsl-layerscape/gpio.h diff --git a/arch/arm/include/asm/arch-fsl-layerscape/gpio.h b/arch/arm/include/asm/arch-fsl-layerscape/gpio.h new file mode 100644 index 0000000000..d8dd750a72 --- /dev/null +++ b/arch/arm/include/asm/arch-fsl-layerscape/gpio.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2014 Freescale Semiconductor, Inc. + */ + +/* + * Dummy header file to enable CONFIG_OF_CONTROL. + * If CONFIG_OF_CONTROL is enabled, lib/fdtdec.c is compiled. + * It includes via , so those SoCs that enable + * OF_CONTROL must have arch/gpio.h. + */ + +#ifndef __ASM_ARCH_MX85XX_GPIO_H +#define __ASM_ARCH_MX85XX_GPIO_H + +struct mpc8xxx_gpio_plat { + ulong addr; + unsigned long size; + uint ngpios; +}; + +#endif From patchwork Sat May 9 10:39:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hui Song X-Patchwork-Id: 206936 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F3D3C47247 for ; Sat, 9 May 2020 10:44:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0EB7324954 for ; Sat, 9 May 2020 10:44:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727986AbgEIKom (ORCPT ); Sat, 9 May 2020 06:44:42 -0400 Received: from inva021.nxp.com ([92.121.34.21]:46222 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728130AbgEIKoj (ORCPT ); Sat, 9 May 2020 06:44:39 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id D9AF7200102; Sat, 9 May 2020 12:44:37 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id C3F772002EE; Sat, 9 May 2020 12:44:34 +0200 (CEST) Received: from localhost.localdomain (mega.ap.freescale.net [10.192.208.232]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 90B0540302; Sat, 9 May 2020 18:44:30 +0800 (SGT) From: Hui Song To: u-boot@linux.nxdi.nxp.com, jiafei.pan@nxp.com Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, "hui.song" Subject: [PATCH v1 3/3] dm: armv8: gpio: include for fsl-layerscape Date: Sat, 9 May 2020 18:39:56 +0800 Message-Id: <20200509103956.26038-3-hui.song_1@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200509103956.26038-1-hui.song_1@nxp.com> References: <20200509103956.26038-1-hui.song_1@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: "hui.song" Enable the gpio feature on fsl-layerscape platform. Signed-off-by: hui.song --- arch/arm/include/asm/gpio.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/arch/arm/include/asm/gpio.h b/arch/arm/include/asm/gpio.h index 333e407b66..7715a01706 100644 --- a/arch/arm/include/asm/gpio.h +++ b/arch/arm/include/asm/gpio.h @@ -1,12 +1,8 @@ #if !defined(CONFIG_ARCH_UNIPHIER) && !defined(CONFIG_ARCH_STI) && \ !defined(CONFIG_ARCH_K3) && !defined(CONFIG_ARCH_BCM68360) && \ !defined(CONFIG_ARCH_BCM6858) && !defined(CONFIG_ARCH_BCM63158) && \ - !defined(CONFIG_ARCH_ROCKCHIP) && !defined(CONFIG_ARCH_LX2160A) && \ - !defined(CONFIG_ARCH_LS1028A) && !defined(CONFIG_ARCH_LS2080A) && \ - !defined(CONFIG_ARCH_LS1088A) && !defined(CONFIG_ARCH_ASPEED) && \ - !defined(CONFIG_ARCH_LS1012A) && !defined(CONFIG_ARCH_LS1043A) && \ - !defined(CONFIG_ARCH_LS1046A) && !defined(CONFIG_ARCH_U8500) && \ - !defined(CONFIG_CORTINA_PLATFORM) + !defined(CONFIG_ARCH_ROCKCHIP) && !defined(CONFIG_ARCH_ASPEED) && \ + !defined(CONFIG_ARCH_U8500) && !defined(CONFIG_CORTINA_PLATFORM) #include #endif #include