From patchwork Thu Mar 2 12:52:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keguang Zhang X-Patchwork-Id: 13157260 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41E6FC678D4 for ; Thu, 2 Mar 2023 12:52:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229810AbjCBMw5 (ORCPT ); Thu, 2 Mar 2023 07:52:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229811AbjCBMw4 (ORCPT ); Thu, 2 Mar 2023 07:52:56 -0500 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 782EF4A1EA; Thu, 2 Mar 2023 04:52:45 -0800 (PST) Received: by mail-pf1-x436.google.com with SMTP id fa28so588333pfb.12; Thu, 02 Mar 2023 04:52:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9zyweGzdA9jS1fyEsOsHkcKiajwcBVlOAfPTENEP1t0=; b=TvwBcY9uVbl0p2l5Yxd74SXG0WA0SKa4wQOKSTf9WIfRoiRXc5LqQAaAQEnbRUq64e pOi6hAYoLcWAkKvD4nIRNWT6qnxxmOIsCk2w3NfjpGJDEmrI3rXqeoSqvhj80amgN3DB gs3pwd0zwlwGoTsWtutGfr7LmSYvWwxCTIgdnqfWws0wM0BjbdFEIJ6A+vv/8zpWifXH 94o+Lqt+GkhExg+PTovFYp60EiK4N39enher3M+MBFTLIOUTN11ak07QeHd0awpnfmYs IHNzEuF6+tinBZZzRPr57ybxkrNKp1DTPcn7eZhcBMCV5+xKAo1YzNsxT86fPD3iEAtz 2Mkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9zyweGzdA9jS1fyEsOsHkcKiajwcBVlOAfPTENEP1t0=; b=OTffPWGjpkU3H2Y5d+TGxzwYe4FBcqyz/fsMGIjx9NpNs6URpFQkGt3zLSmLaK5G16 pIApP0XzK3sV1CH7aS3ESKxQBWNWMxjGSIoOyhJU5MKEPG1vK+0DGjsZxQ3yLh5fVYr3 3AyKHlZ2N8HenCuV/ofC9+kwSGvTovoQ18g+0nLjNZKnFASqaIS222dwoPLPyDolFu8h zDVjkqA6/0jF+XYY7+swvyLbtmOKJxal92aRWzGX+blmjpmumC0Rz3yqYqhSUgjejzKL InScO0QOKailjlPZe1ZA3pB2f373qTUVL2AFxfRxwnioZrd48bWW82XNkHBYh37Ow0/J DwFg== X-Gm-Message-State: AO0yUKUg2RNQRIIIvE2azNKO0k3eCb3/GaRAL7ZElOKgqm5itnWc1ymK 6653tqs14Gh57k2+QsU2iOvhDy0w5Qs= X-Google-Smtp-Source: AK7set+SHWxvXTEjyB2cx85BN6na/7p9fbFI/+Z2RCGcFfbBp6lmnaWXTlThJIF+e6yXgqC3+WfZ2A== X-Received: by 2002:a62:62c6:0:b0:5a8:aa1d:30e9 with SMTP id w189-20020a6262c6000000b005a8aa1d30e9mr7493277pfb.18.1677761564572; Thu, 02 Mar 2023 04:52:44 -0800 (PST) Received: from kelvin-ThinkPad-L14-Gen-1.lan ([223.85.203.147]) by smtp.gmail.com with ESMTPSA id j7-20020a62e907000000b005aa60d8545esm9791955pfh.61.2023.03.02.04.52.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 04:52:44 -0800 (PST) From: Keguang Zhang To: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Linus Walleij , Bartosz Golaszewski , Rob Herring , Krzysztof Kozlowski , Keguang Zhang Subject: [PATCH v2 1/5] gpio: loongson1: Convert to SPDX identifier Date: Thu, 2 Mar 2023 20:52:11 +0800 Message-Id: <20230302125215.214014-2-keguang.zhang@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230302125215.214014-1-keguang.zhang@gmail.com> References: <20230302125215.214014-1-keguang.zhang@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org Use SPDX-License-Identifier instead of the license text and update the author information. Signed-off-by: Keguang Zhang --- V1 -> V2: Keep GPLv2, just convert to SPDX identifier --- drivers/gpio/gpio-loongson1.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/gpio-loongson1.c b/drivers/gpio/gpio-loongson1.c index 5d90b3bc5a25..8862c9ea0d41 100644 --- a/drivers/gpio/gpio-loongson1.c +++ b/drivers/gpio/gpio-loongson1.c @@ -1,11 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-only /* * GPIO Driver for Loongson 1 SoC * - * Copyright (C) 2015-2016 Zhang, Keguang - * - * This file is licensed under the terms of the GNU General Public - * License version 2. This program is licensed "as is" without any - * warranty of any kind, whether express or implied. + * Copyright (C) 2015-2023 Keguang Zhang */ #include @@ -90,6 +87,6 @@ static struct platform_driver ls1x_gpio_driver = { module_platform_driver(ls1x_gpio_driver); -MODULE_AUTHOR("Kelvin Cheung "); +MODULE_AUTHOR("Keguang Zhang "); MODULE_DESCRIPTION("Loongson1 GPIO driver"); MODULE_LICENSE("GPL"); From patchwork Thu Mar 2 12:52:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keguang Zhang X-Patchwork-Id: 13157261 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1979C7EE30 for ; Thu, 2 Mar 2023 12:53:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229881AbjCBMxD (ORCPT ); Thu, 2 Mar 2023 07:53:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229836AbjCBMw6 (ORCPT ); Thu, 2 Mar 2023 07:52:58 -0500 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D8FB185; Thu, 2 Mar 2023 04:52:51 -0800 (PST) Received: by mail-pf1-x433.google.com with SMTP id fa28so588506pfb.12; Thu, 02 Mar 2023 04:52:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ElZGWPSn9CP8auAvlpdoQ6n2hX46C9RTZsGwRvPpbgc=; b=j1ZnY7zsbC4LN55GLsFmwo37igkQ1Frh7YGwQbrxCBLETkPpVs4xLHP7jJElOoRF5Z W16lxLUwEv9CN3gbz+MqtUhpEJvmdz9Y+0Q9H1Bqnvxlplu+c2DHQn8H1PA/uFFs1LIs ch7vraMDdDwZmpyWTB4pcG0aW7bcwMAM9xubomrnYbC3ng0u7rPq0cT6HDGOm+PQ0Jrd VgATUy+zWvGvg8uUh7aRivZK6Vi/21ZlfRU5PsUGDr0uBwnM8zuIQD1hBD+QOMjE+atv 5/JLij+/uEPvdqGe/a5QwJ7byncaTfsjSdtJjx72ByOq31SsCRf2yik3mziwUH3re6Kc cyNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ElZGWPSn9CP8auAvlpdoQ6n2hX46C9RTZsGwRvPpbgc=; b=PQNSW4tXrf9V7itaZJRZLXhY5fhPNPevPAP1YGRGqo1QQf9vYtGUtK9K2eC8mVML2u YjqGI1vzPynpP2kpzp/eNOJbBeE5tcQF+/wbeLYErzYEjWtm4Nq24ZwPGL2yutbMBbpc +bMHnVSNU55OH6edkKpbueclGKpRLiduof9GLvWbj0yBXYcGU5qunNqBuYL8gOdsP4IN fZaCKHSP+7qr+aQSBAI7Z+aIgy7eySQaegHmTstMhRd2C6mmZj1wsEkNWCIRhnTlQ9IR oUEJblAEGunDhNPNQtVDggrfY2hxB4FJjFcSvBf932cSxeDqcZG6JathYQYv//PNeqcw 2Htg== X-Gm-Message-State: AO0yUKUe4PepHqFrWwur8yLmkxELHSJS37zX8lXBS3KZHuq3F7X358iC BjcOSujuEZ6tjZ60KSiK/r/htc/v9uIVtA== X-Google-Smtp-Source: AK7set9H4ghe7mKOm/BayKDrHgPnByE6BRDQmXGKFazoPyey/+FSuVhsPQFWesTAOAXH8axBN5kJgw== X-Received: by 2002:a62:1b51:0:b0:5a9:d0e6:6a85 with SMTP id b78-20020a621b51000000b005a9d0e66a85mr2266922pfb.7.1677761570646; Thu, 02 Mar 2023 04:52:50 -0800 (PST) Received: from kelvin-ThinkPad-L14-Gen-1.lan ([223.85.203.147]) by smtp.gmail.com with ESMTPSA id j7-20020a62e907000000b005aa60d8545esm9791955pfh.61.2023.03.02.04.52.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 04:52:50 -0800 (PST) From: Keguang Zhang To: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Linus Walleij , Bartosz Golaszewski , Rob Herring , Krzysztof Kozlowski , Keguang Zhang Subject: [PATCH v2 2/5] gpio: loongson1: Use readl() & writel() Date: Thu, 2 Mar 2023 20:52:12 +0800 Message-Id: <20230302125215.214014-3-keguang.zhang@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230302125215.214014-1-keguang.zhang@gmail.com> References: <20230302125215.214014-1-keguang.zhang@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org This patch replace __raw_readl() & __raw_writel() with readl() & writel(). Signed-off-by: Keguang Zhang --- V1 -> V2: Split this change to a separate patch --- drivers/gpio/gpio-loongson1.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpio-loongson1.c b/drivers/gpio/gpio-loongson1.c index 8862c9ea0d41..b6c11caa3ade 100644 --- a/drivers/gpio/gpio-loongson1.c +++ b/drivers/gpio/gpio-loongson1.c @@ -23,8 +23,8 @@ static int ls1x_gpio_request(struct gpio_chip *gc, unsigned int offset) unsigned long flags; raw_spin_lock_irqsave(&gc->bgpio_lock, flags); - __raw_writel(__raw_readl(gpio_reg_base + GPIO_CFG) | BIT(offset), - gpio_reg_base + GPIO_CFG); + writel(readl(gpio_reg_base + GPIO_CFG) | BIT(offset), + gpio_reg_base + GPIO_CFG); raw_spin_unlock_irqrestore(&gc->bgpio_lock, flags); return 0; @@ -35,8 +35,8 @@ static void ls1x_gpio_free(struct gpio_chip *gc, unsigned int offset) unsigned long flags; raw_spin_lock_irqsave(&gc->bgpio_lock, flags); - __raw_writel(__raw_readl(gpio_reg_base + GPIO_CFG) & ~BIT(offset), - gpio_reg_base + GPIO_CFG); + writel(readl(gpio_reg_base + GPIO_CFG) & ~BIT(offset), + gpio_reg_base + GPIO_CFG); raw_spin_unlock_irqrestore(&gc->bgpio_lock, flags); } From patchwork Thu Mar 2 12:52:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keguang Zhang X-Patchwork-Id: 13157262 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9D7DC7EE33 for ; Thu, 2 Mar 2023 12:53:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229864AbjCBMxO (ORCPT ); Thu, 2 Mar 2023 07:53:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229873AbjCBMxI (ORCPT ); Thu, 2 Mar 2023 07:53:08 -0500 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAC1083FD; Thu, 2 Mar 2023 04:52:57 -0800 (PST) Received: by mail-pf1-x42f.google.com with SMTP id n5so9990829pfv.11; Thu, 02 Mar 2023 04:52:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hRN/MkYkVyLNcqtB6OAlPlQu24Io/GUHW41CMMPteSg=; b=YKq3V2RU9yTIBU19bngkEao0jiqAfLDIcB93+oPJRXG1Xim38Q4tdkWd/AYq3Aizj+ 75CtomfDCEkNNueX3+MG0mxF/REpWKv34A1G3O57kURXvJ+foO5wuKAE5igTrUVuCNpx JLqnb7OL7kOTwZAqWDx0JNr0n3Mzs/f+wTbHXWmqIkbHzr/4FMmY4ZoXjuXbQcAyrtEE kc5kzpq9uH6USZ2l81Sri3I2KORXq17EYH72YW/T2eLRQJfuFJ/0Df3nyQQlmdI0SQy9 v5/cvVpknxwniqrVHNBUtIOMfYa1wMUwgmXCR5h7/aWA6Mf7Y95ruHIJBMmBnH+mQsob ip3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hRN/MkYkVyLNcqtB6OAlPlQu24Io/GUHW41CMMPteSg=; b=4yrmOseXcFytE2Hojzw7onWAkedVdpVHzc/fsbXYuBuTggLwK7y3qUuS8sjfBJ4vyB M5E/1aBGHUqMfo06in8YEmsAakdS8WkWbIelp+D1cySbi4VPXg6XJ8mKNhTAL+qja2Bd 80bZ9L2uj+3csvmRZkIxMrPX+hQcD59AIQQXL682j0J42c46xSYcxNTUJS0IDMl+muEc kfHJuxVy6xjtq+Uv+p4AyJJVYEdZsT6Qei2fXIVH66z5hBPDPTrz6S6GUWCypFqAqHv5 wYAbVS2VFkTAggCZ5PdagiVb7jkZbrUzrUG4p/OMsG8J3CRixN6iO/6Ra0usRjvAh3F7 Uxww== X-Gm-Message-State: AO0yUKUqUIR1um/m1uh+eNtm+S3166uaVPFOa5CBEl3ETzYxF2+cTrTc XfxRKn90Bo/mQhNcHbfu9DNObo5CdWQ= X-Google-Smtp-Source: AK7set/zR6q6un+xxh3TNQG3l99+9yGeiVRrVjHqia3hNZ0sjxfwNiY+Y9zundL6T2/RudydSq6hkg== X-Received: by 2002:aa7:947d:0:b0:5a8:adc8:6de1 with SMTP id t29-20020aa7947d000000b005a8adc86de1mr9897477pfq.29.1677761576729; Thu, 02 Mar 2023 04:52:56 -0800 (PST) Received: from kelvin-ThinkPad-L14-Gen-1.lan ([223.85.203.147]) by smtp.gmail.com with ESMTPSA id j7-20020a62e907000000b005aa60d8545esm9791955pfh.61.2023.03.02.04.52.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 04:52:56 -0800 (PST) From: Keguang Zhang To: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Linus Walleij , Bartosz Golaszewski , Rob Herring , Krzysztof Kozlowski , Keguang Zhang Subject: [PATCH v2 3/5] gpio: loongson1: Introduce ls1x_gpio_chip struct Date: Thu, 2 Mar 2023 20:52:13 +0800 Message-Id: <20230302125215.214014-4-keguang.zhang@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230302125215.214014-1-keguang.zhang@gmail.com> References: <20230302125215.214014-1-keguang.zhang@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org This patch introduces and allocates ls1x_gpio_chip struct containing gpio_chip and reg_base to avoid global gpio_reg_base. Signed-off-by: Keguang Zhang --- V1 -> V2: Split this change to a separate patch --- drivers/gpio/gpio-loongson1.c | 45 +++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/drivers/gpio/gpio-loongson1.c b/drivers/gpio/gpio-loongson1.c index b6c11caa3ade..3ac9e49e7efb 100644 --- a/drivers/gpio/gpio-loongson1.c +++ b/drivers/gpio/gpio-loongson1.c @@ -16,15 +16,19 @@ #define GPIO_DATA 0x20 #define GPIO_OUTPUT 0x30 -static void __iomem *gpio_reg_base; +struct ls1x_gpio_chip { + struct gpio_chip gc; + void __iomem *reg_base; +}; static int ls1x_gpio_request(struct gpio_chip *gc, unsigned int offset) { + struct ls1x_gpio_chip *ls1x_gc = gpiochip_get_data(gc); unsigned long flags; raw_spin_lock_irqsave(&gc->bgpio_lock, flags); - writel(readl(gpio_reg_base + GPIO_CFG) | BIT(offset), - gpio_reg_base + GPIO_CFG); + writel(readl(ls1x_gc->reg_base + GPIO_CFG) | BIT(offset), + ls1x_gc->reg_base + GPIO_CFG); raw_spin_unlock_irqrestore(&gc->bgpio_lock, flags); return 0; @@ -32,44 +36,45 @@ static int ls1x_gpio_request(struct gpio_chip *gc, unsigned int offset) static void ls1x_gpio_free(struct gpio_chip *gc, unsigned int offset) { + struct ls1x_gpio_chip *ls1x_gc = gpiochip_get_data(gc); unsigned long flags; raw_spin_lock_irqsave(&gc->bgpio_lock, flags); - writel(readl(gpio_reg_base + GPIO_CFG) & ~BIT(offset), - gpio_reg_base + GPIO_CFG); + writel(readl(ls1x_gc->reg_base + GPIO_CFG) & ~BIT(offset), + ls1x_gc->reg_base + GPIO_CFG); raw_spin_unlock_irqrestore(&gc->bgpio_lock, flags); } static int ls1x_gpio_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct gpio_chip *gc; + struct ls1x_gpio_chip *ls1x_gc; int ret; - gc = devm_kzalloc(dev, sizeof(*gc), GFP_KERNEL); - if (!gc) + ls1x_gc = devm_kzalloc(dev, sizeof(*ls1x_gc), GFP_KERNEL); + if (!ls1x_gc) return -ENOMEM; - gpio_reg_base = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(gpio_reg_base)) - return PTR_ERR(gpio_reg_base); + ls1x_gc->reg_base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(ls1x_gc->reg_base)) + return PTR_ERR(ls1x_gc->reg_base); - ret = bgpio_init(gc, dev, 4, gpio_reg_base + GPIO_DATA, - gpio_reg_base + GPIO_OUTPUT, NULL, - NULL, gpio_reg_base + GPIO_DIR, 0); + ret = bgpio_init(&ls1x_gc->gc, dev, 4, ls1x_gc->reg_base + GPIO_DATA, + ls1x_gc->reg_base + GPIO_OUTPUT, NULL, + NULL, ls1x_gc->reg_base + GPIO_DIR, 0); if (ret) goto err; - gc->owner = THIS_MODULE; - gc->request = ls1x_gpio_request; - gc->free = ls1x_gpio_free; - gc->base = pdev->id * 32; + ls1x_gc->gc.owner = THIS_MODULE; + ls1x_gc->gc.request = ls1x_gpio_request; + ls1x_gc->gc.free = ls1x_gpio_free; + ls1x_gc->gc.base = pdev->id * 32; - ret = devm_gpiochip_add_data(dev, gc, NULL); + ret = devm_gpiochip_add_data(dev, &ls1x_gc->gc, ls1x_gc); if (ret) goto err; - platform_set_drvdata(pdev, gc); + platform_set_drvdata(pdev, ls1x_gc); dev_info(dev, "Loongson1 GPIO driver registered\n"); return 0; From patchwork Thu Mar 2 12:52:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keguang Zhang X-Patchwork-Id: 13157263 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E50A2C678D4 for ; Thu, 2 Mar 2023 12:53:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229876AbjCBMxQ (ORCPT ); Thu, 2 Mar 2023 07:53:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229872AbjCBMxP (ORCPT ); Thu, 2 Mar 2023 07:53:15 -0500 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C9B921958; Thu, 2 Mar 2023 04:53:03 -0800 (PST) Received: by mail-pl1-x62a.google.com with SMTP id n6so16037125plf.5; Thu, 02 Mar 2023 04:53:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HTlG/HavU64jt/5bxFZVCvJJZA+o1I3CZfepDCCo+0s=; b=JzAhYLNxMLvZXlb9cW1eYkvy0Z+oYfKiK/HcOzu1x/4L3xIIq9/NPDoRXeF6AZ8bVG grQBSinQCoKZ5WdKilRNWSICo/juzj0gLFysU6vPORjtslv9oX+nQty3Uj5U8eZydM6t FqykxYDc1P4o5HOD17yh8rmjOoFKF2wRnRa+WSnXSYwTc2ewKMbselTSi8GvrcYIA8Rz qricXzRCyROjW7DL6TEp+plDQzwercRBXmXPPeZDtCa3nZOlSuBnUr0cJVNJ0u3W9tIe WeGsiWl/9I6tqSthPq9S+pKBrB7ltRNpXbticSZyBC36ZyVzkA9ySLdgUF3J1/IpmP08 zoQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HTlG/HavU64jt/5bxFZVCvJJZA+o1I3CZfepDCCo+0s=; b=r7r3eFZuc+EKtR6we4sZu3+2vB8viWf0HiTR+TOcnLvfuU7rLBKKWVJZJ4u5q1J5su MJbrAfKzjwsozM3mKWrxJRpNUBwi//fcjC7cnt1rRX5AC6ZU++OPq8bFW5mMx67j4tby mEbcAmL9qbAa6120AjMTZl5W2/3bb2KfjKfFvLslfimsLOWiiJ7RfPPaRnbVRj8SKEUX pc45FxXCNJJHBat8z990bWwlJqzJ4qWnFcG3ymOJSlXC/c84lJ/OOmCjLgSC29bwEju/ 6Bf12s+Bkr1zX9C9yzP8miCd9bJxHQkZa1x87Byf0KXmLW+ZGQ86llgLeVfw+mhNfFEA ER3g== X-Gm-Message-State: AO0yUKXTs6DNpwebsu4vZCmweIDgNqGAhgR0rhxGJhgv7fJPQgeQd6LW wb7TYh63i733QP2ZKQ9sH8q0oLdVpXP48Q== X-Google-Smtp-Source: AK7set8CvC//mEhCspT+FY5Y7s/4F36pQhRvOCU4ivGxfv87lnDgys0XFuWeFtK54Ea2QfCFS470kw== X-Received: by 2002:a05:6a21:99a5:b0:b6:99a4:66bd with SMTP id ve37-20020a056a2199a500b000b699a466bdmr12347441pzb.38.1677761582805; Thu, 02 Mar 2023 04:53:02 -0800 (PST) Received: from kelvin-ThinkPad-L14-Gen-1.lan ([223.85.203.147]) by smtp.gmail.com with ESMTPSA id j7-20020a62e907000000b005aa60d8545esm9791955pfh.61.2023.03.02.04.52.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 04:53:02 -0800 (PST) From: Keguang Zhang To: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Linus Walleij , Bartosz Golaszewski , Rob Herring , Krzysztof Kozlowski , Keguang Zhang Subject: [PATCH v2 4/5] gpio: loongson1: Add DT support Date: Thu, 2 Mar 2023 20:52:14 +0800 Message-Id: <20230302125215.214014-5-keguang.zhang@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230302125215.214014-1-keguang.zhang@gmail.com> References: <20230302125215.214014-1-keguang.zhang@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org This patch adds DT support for Loongson-1 GPIO driver. Signed-off-by: Keguang Zhang --- V1 -> V2: Let gpiolib parse ngpios property Remove unnecessary alias id parsing Remove superfluous initialization done by bgpio_init() Add MODULE_DEVICE_TABLE() Other minor fixes --- drivers/gpio/gpio-loongson1.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/gpio/gpio-loongson1.c b/drivers/gpio/gpio-loongson1.c index 3ac9e49e7efb..94ac0ccb450f 100644 --- a/drivers/gpio/gpio-loongson1.c +++ b/drivers/gpio/gpio-loongson1.c @@ -68,25 +68,38 @@ static int ls1x_gpio_probe(struct platform_device *pdev) ls1x_gc->gc.owner = THIS_MODULE; ls1x_gc->gc.request = ls1x_gpio_request; ls1x_gc->gc.free = ls1x_gpio_free; - ls1x_gc->gc.base = pdev->id * 32; + /* + * Clear ngpio to let gpiolib get the correct number + * by reading ngpios property + */ + ls1x_gc->gc.ngpio = 0; ret = devm_gpiochip_add_data(dev, &ls1x_gc->gc, ls1x_gc); if (ret) goto err; platform_set_drvdata(pdev, ls1x_gc); - dev_info(dev, "Loongson1 GPIO driver registered\n"); + + dev_info(dev, "GPIO controller registered with %d pins\n", + ls1x_gc->gc.ngpio); return 0; err: - dev_err(dev, "failed to register GPIO device\n"); + dev_err(dev, "failed to register GPIO controller\n"); return ret; } +static const struct of_device_id ls1x_gpio_dt_ids[] = { + { .compatible = "loongson,ls1x-gpio" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, ls1x_gpio_dt_ids); + static struct platform_driver ls1x_gpio_driver = { .probe = ls1x_gpio_probe, .driver = { .name = "ls1x-gpio", + .of_match_table = ls1x_gpio_dt_ids, }, }; From patchwork Thu Mar 2 12:52:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keguang Zhang X-Patchwork-Id: 13157264 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0BBE7C6FA8E for ; Thu, 2 Mar 2023 12:53:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229918AbjCBMx2 (ORCPT ); Thu, 2 Mar 2023 07:53:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229925AbjCBMxZ (ORCPT ); Thu, 2 Mar 2023 07:53:25 -0500 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B71E124486; Thu, 2 Mar 2023 04:53:09 -0800 (PST) Received: by mail-pg1-x532.google.com with SMTP id y19so9713648pgk.5; Thu, 02 Mar 2023 04:53:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jRnL8PP+Em3R8alqzrLZeyCQtoaYlrzX+Ww0tSnTWvw=; b=HRxqlQI8jw+d7AibX67FSXxvDalEP5+I4pP1ZMSjEq2DVqvror5lK7aAyFwwVqZHa+ UPpdpX75C/7U0nun4DU3bHMY5GxVUAYEoF3EM6ZCxTKyrV89xUwPL5n5mN+G+lAiTiBr JOqraCHOMcCZti2hJG/hL7Bp6NiliGLDeOHbiWlhDo7SpYUp4uWf4wjT7pobeyOHS4l4 MDESAWsb4r8/JuPg7Bl7+AZFrz0vTV66+TRcVUB746ZyYYC43mNzdM2CgRJFUBpwTLAd 8cwXSOL1Z6Q9nQ1P6T2O6aDTOKcXJT9MAREFmlgNtVOdCi3fflkCCHN4izR+2+Nr1cHd iC5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jRnL8PP+Em3R8alqzrLZeyCQtoaYlrzX+Ww0tSnTWvw=; b=qoIrntgEJGSXU0ZuHEpAbpdWxhleIU4BzZx08+5KzBoTMkeiYBb7RWefQOzcEXatIP 8eS8NqQlOSxY98EsFXU0B6PZSTmbCF6TZ9Se2ngd1P5MScCwS+YMywfxFtkOTG6glMD2 OMBev79/2LZpSKwrX5RyV/h+k34PVROtlwM4zmAnd1wy/Psf9dNVyfo1UC0yutzocefJ ui1bBtcNgvroLJ+fh0gtcOH30ocsQ8UyRcApM8bWQXmbZmnxbJ9VDHkjCRvjlFmogD6X dDCY9QhccMc+87e06cIGEiPgX1xzLrH03ilRXPUHo1b/k83aeQasseCuK04KqGgjLAMk MEcw== X-Gm-Message-State: AO0yUKVDSqE/J1U8dt7I0i8XhyBKiTESSYXlFTTGmlbEAT81+0LWAoJ0 FzrKoCShKRpiaelpFiIFekVN/1QUP36Zcw== X-Google-Smtp-Source: AK7set8MyVjJedvYNIycLjfa21tODlFFN4KW7G1+4wjFrLDCe0m/LuM8cdyZ4ZVbNE/AOPzM8YzKMA== X-Received: by 2002:aa7:9466:0:b0:5a8:5424:d138 with SMTP id t6-20020aa79466000000b005a85424d138mr7263122pfq.16.1677761588857; Thu, 02 Mar 2023 04:53:08 -0800 (PST) Received: from kelvin-ThinkPad-L14-Gen-1.lan ([223.85.203.147]) by smtp.gmail.com with ESMTPSA id j7-20020a62e907000000b005aa60d8545esm9791955pfh.61.2023.03.02.04.53.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 04:53:08 -0800 (PST) From: Keguang Zhang To: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Linus Walleij , Bartosz Golaszewski , Rob Herring , Krzysztof Kozlowski , Keguang Zhang Subject: [PATCH v2 5/5] dt-bindings: gpio: Add Loongson-1 GPIO Date: Thu, 2 Mar 2023 20:52:15 +0800 Message-Id: <20230302125215.214014-6-keguang.zhang@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230302125215.214014-1-keguang.zhang@gmail.com> References: <20230302125215.214014-1-keguang.zhang@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org Add devicetree binding document for Loongson-1 GPIO. Signed-off-by: Keguang Zhang Reviewed-by: Krzysztof Kozlowski --- V1 -> V2: Use the same consistent quotes Delete superfluous examples --- .../bindings/gpio/loongson,ls1x-gpio.yaml | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/loongson,ls1x-gpio.yaml diff --git a/Documentation/devicetree/bindings/gpio/loongson,ls1x-gpio.yaml b/Documentation/devicetree/bindings/gpio/loongson,ls1x-gpio.yaml new file mode 100644 index 000000000000..1a472c05697c --- /dev/null +++ b/Documentation/devicetree/bindings/gpio/loongson,ls1x-gpio.yaml @@ -0,0 +1,49 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/gpio/loongson,ls1x-gpio.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Loongson-1 GPIO controller + +maintainers: + - Keguang Zhang + +properties: + compatible: + const: loongson,ls1x-gpio + + reg: + maxItems: 1 + + gpio-controller: true + + "#gpio-cells": + const: 2 + + ngpios: + minimum: 1 + maximum: 32 + +required: + - compatible + - reg + - gpio-controller + - "#gpio-cells" + - ngpios + +additionalProperties: false + +examples: + - | + gpio0: gpio@1fd010c0 { + compatible = "loongson,ls1x-gpio"; + reg = <0x1fd010c0 0x4>; + + gpio-controller; + #gpio-cells = <2>; + + ngpios = <32>; + }; + +...