From patchwork Wed Feb 22 11:12:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keguang Zhang X-Patchwork-Id: 13149031 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 A0577C677F1 for ; Wed, 22 Feb 2023 11:12:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231545AbjBVLMd (ORCPT ); Wed, 22 Feb 2023 06:12:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231305AbjBVLMa (ORCPT ); Wed, 22 Feb 2023 06:12:30 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 264351EBC6; Wed, 22 Feb 2023 03:12:29 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id pt11so9099709pjb.1; Wed, 22 Feb 2023 03:12:29 -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=Bu2paKVrVIoD9107RPYWka25sQcplKWr4Bown4/f63Y=; b=dJ5ZevpxvZ7Q46EC37jjEBMbS6QFAtcmqi4mrXN+WD6XdIDrNepOqlZ9mu5IIM2xsn taSY19aizrOjW+rDHzYi6yY+rujfP47rBjW+XG3pXPczjSIJdbYBRc3EdUEJgEZtT6Fa uo4gjnp2HNYQx91iZ7hVoYUH4Xqe6ZcKjgWCQ+JbjFs4gYhDbeXuUIWK8GItbjZ7fN5j j8lai8Jp1SjG6+YyyPnmgL+BLVybr5/QXwI8cOMrGswLX3oEcpZil2db879oepuKM7Fh wvQJTIocj/HeKcLBgo301oAivXlZYboAMfX5etaTBI9iNnbMXxlCi4gfTii/FDO1BQTU 6gMQ== 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=Bu2paKVrVIoD9107RPYWka25sQcplKWr4Bown4/f63Y=; b=47idL44LXxvv1XnQfJ/D96y5L7nUEeJ5KKAF+0q48zZPUTtFxMtpoYKiolFdL/BCXT iIwSYcVKVP2wESYtPkQI4a18Pm4bOlODVRex17VCeosoDHCnpJgfq45dnzIl/VJk5MJH 1y+AoUYtIlp4tTvl4aKDEIueHWgrav35eBSTVOIRQSGtNdp7DFc39VCFiCWE953U3kF4 2K6TC+FFzhgJEkcIAoRWgDlZlDu4KGjAjDOZHA8tJY3Y2fg3gR6Ij2WvM85qgOCHUwqv VqM1POh8ZAvhKTKiK/lfpVFiCOxToiKxlv4G7b+2HRFJGoOELcgkNFK9DvgzXRtYIeNp lAnA== X-Gm-Message-State: AO0yUKXHeWLACKvzvxDntSxpWTEiHoRcsZdL7x8gag1jdY8CYAU05rCn WI9QyI5iU/HDGde62waIUxOObAvc8rWPFg== X-Google-Smtp-Source: AK7set8CW9Ao3dsPSM68IxsiRJ2aesJAXkri5+EVCi0lTv55Bs/Vs7YcseHjHPbAnfN5CyAge+Koiw== X-Received: by 2002:a17:90b:1647:b0:237:44c3:df0b with SMTP id il7-20020a17090b164700b0023744c3df0bmr1192934pjb.32.1677064348304; Wed, 22 Feb 2023 03:12:28 -0800 (PST) Received: from kelvin-ThinkPad-L14-Gen-1.. (94.130.220.35.bc.googleusercontent.com. [35.220.130.94]) by smtp.gmail.com with ESMTPSA id x7-20020a17090a294700b00234899c65e7sm4763228pjf.28.2023.02.22.03.12.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 03:12:27 -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 1/4] gpio: loongson1: Update copyright Date: Wed, 22 Feb 2023 19:12:10 +0800 Message-Id: <20230222111213.2241633-2-keguang.zhang@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230222111213.2241633-1-keguang.zhang@gmail.com> References: <20230222111213.2241633-1-keguang.zhang@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org This patch updates copyright and author information. Signed-off-by: Keguang Zhang --- 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..7ecbc43f8b38 100644 --- a/drivers/gpio/gpio-loongson1.c +++ b/drivers/gpio/gpio-loongson1.c @@ -1,11 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * 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 Wed Feb 22 11:12: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: 13149032 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 CC776C636D6 for ; Wed, 22 Feb 2023 11:12:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231712AbjBVLMf (ORCPT ); Wed, 22 Feb 2023 06:12:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231230AbjBVLMf (ORCPT ); Wed, 22 Feb 2023 06:12:35 -0500 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBC01211D6; Wed, 22 Feb 2023 03:12:33 -0800 (PST) Received: by mail-pj1-x1031.google.com with SMTP id q31-20020a17090a17a200b0023750b69614so193052pja.5; Wed, 22 Feb 2023 03:12:33 -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=azrsxJplJ+DgLt389DwS68lqZLzLGhDWxaz1QQlD5Js=; b=jlrCfPyouseNbDppeJ5IFeloNRVnhiC8a3VC41uf0HyVPqwLDfe2QHIDNGPjKmgXof BuvKIAtVb5Qt4xHLLdO1zK970/o2Ejs01C5pe9qcZE7Z2l7fHOXsiIOHjzebK27g109U cZ3DWSwUHL27o1DBCTJAI2eYYYgSIkGWa2Ot/squXRn3amq1u8ZI8gzIIGOsq5Q1iQ6v gOg6ppDLhJR+EV38vXS9mtznCRX6GTQz2jbsf2jx6dh86mx3f/D9q0wGbm9vd37FNP6O Riz3FqtmuShyNZqgp2cQ1n0IS1lNqNVgN7j0xSAFAtLtdqTg7SS5q7nwCdfmMv0KSTsQ gXqQ== 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=azrsxJplJ+DgLt389DwS68lqZLzLGhDWxaz1QQlD5Js=; b=yIHD3AlV2Yrjq5aQIduMzVtPh3/nbvgbxS0aL0UmBV4rlRyucfKAY7VEqnJM4MacOO QhmJuDAnNSk2D65q3+nP98bqYXggHYSWVVrcu7/SoBO/ZEUiYpVpf4DzICLcF1sSndtp dMmK6nXWW/Ij+iaydb3AZdmdCVAZPH2G5R0L1OX36xSDz/UCKcrOIgj/U3vORgXhJgi/ ejNn+ak8cjgweQs0pE2tZWjXSTlSmollLzGJ07XC/Dv9KGiCw1CjcK4SAw6S2mnFlr0A Nl3FdeJrZBuFSY7DMq19dk0UESU4VYwjZXMq8s+haUAvuNF4XU5fVLnvlqiLCUL8Ovk8 eF6Q== X-Gm-Message-State: AO0yUKVQIvQvveJEf8X8TzPezjjqgjJCUg/bY3Oc0sVQgB6ihgVbnIJ2 X8hIxHprptOSDjZES6V9WGCM2TFjo8Q= X-Google-Smtp-Source: AK7set8gMx4PNKWM2ER+1oMD8et/3evsiduBobQ1yJDBpcbF1j5RyVXJolmLWHSzgPbF7+KJP476xA== X-Received: by 2002:a17:90a:4d88:b0:234:17b:ae2b with SMTP id m8-20020a17090a4d8800b00234017bae2bmr9789396pjh.13.1677064352955; Wed, 22 Feb 2023 03:12:32 -0800 (PST) Received: from kelvin-ThinkPad-L14-Gen-1.. (94.130.220.35.bc.googleusercontent.com. [35.220.130.94]) by smtp.gmail.com with ESMTPSA id x7-20020a17090a294700b00234899c65e7sm4763228pjf.28.2023.02.22.03.12.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 03:12:32 -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 2/4] gpio: loongson1: Introduce ls1x_gpio_chip struct Date: Wed, 22 Feb 2023 19:12:11 +0800 Message-Id: <20230222111213.2241633-3-keguang.zhang@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230222111213.2241633-1-keguang.zhang@gmail.com> References: <20230222111213.2241633-1-keguang.zhang@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org Introduce and allocate ls1x_gpio_chip struct containing gpio_chip and reg_base to avoid global gpio_reg_base. Use readl() & writel() instead of __raw_readl() & __raw_writel(). Signed-off-by: Keguang Zhang --- 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 7ecbc43f8b38..b950bcfd78ce 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); - __raw_writel(__raw_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); - __raw_writel(__raw_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 Wed Feb 22 11:12: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: 13149033 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 D2A74C636D6 for ; Wed, 22 Feb 2023 11:12:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231774AbjBVLMp (ORCPT ); Wed, 22 Feb 2023 06:12:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231785AbjBVLMn (ORCPT ); Wed, 22 Feb 2023 06:12:43 -0500 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37B0B392B2; Wed, 22 Feb 2023 03:12:38 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id e9so3333642plh.2; Wed, 22 Feb 2023 03:12:38 -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=/59u0aFLCj7mAVvWdqbe9uXAbJQVQlHSWO1sFeKEmaM=; b=Io6QEstP+tREfhiRZY4Ocgan+qroAozZmpSWtKekTone0wj/kjzebFvLtX8jDgdvQP y4k8UjqMUKVJtfFZDCMTtR/W5dZmODnlOOaXJTpLkH1+0ILNl2CEMiGdxoj67Nl+UuwN aVWLfQ3DnP5vF+oy+CHXsJZ0Dyb+CLubY6+761P3UgK4sf+BhBgP6GV9/X9rzb3dFLTG 1I2A44jclwYgEBKA4mu2JyUSnvwYpHtrsv4m9N89ESr6jVjS6w2V5Wy9pSYUG263GtDe GnHLpJnQYaJHJPez5mSGk5+BwhLaOOfJ6+FVlv2sSncv7Hkq8DGMR6dVCbYmZHFrhgN+ 3B4g== 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=/59u0aFLCj7mAVvWdqbe9uXAbJQVQlHSWO1sFeKEmaM=; b=V7GU8kgt3+I3pMhwea1pZ+dGdUfHXLWDf2czXOmrIfM153EwlrNPXURdb1kkMlcVNs DsSNW0cKjfVp36XUbD/af159dIIibZXiIedppLj0KZtYoptRM784fyeNufpxE1N0D+t3 MFbLthynD2kfRm+igE19dlPksMAbbUJChfgUG2zgX8uaCUN7/+zympmv4L80rbLPKjtw LDXLiQqE6XJN0Wk/EZRykFAqJPXB54eqUZg37JpIJjgdzxNnGPEXSnqcZUEBWeM7R4Iv IsUZxHzpSlRtwD4LLMYUIpMUrdq5XRsiaIl67gcxAZ8Cr2oqPiyM2eaKW3reU9qUtGtQ Qn7g== X-Gm-Message-State: AO0yUKXn5sQwm3GB79vpUfvqQjsb+SShgUNPV88FkLDY9n24gpzI9kuS 9j2Q9woSriMixd0RYUIUIHBch64tMb7RDA== X-Google-Smtp-Source: AK7set8ODvsg9PGkSOZ5l1lt3bU1KfULzoQsu2vqX7fW3MHOKZxbH7yrgsY3CAtZcFphuOyhFF/jew== X-Received: by 2002:a17:90b:388a:b0:235:82d0:3a36 with SMTP id mu10-20020a17090b388a00b0023582d03a36mr10664926pjb.41.1677064357358; Wed, 22 Feb 2023 03:12:37 -0800 (PST) Received: from kelvin-ThinkPad-L14-Gen-1.. (94.130.220.35.bc.googleusercontent.com. [35.220.130.94]) by smtp.gmail.com with ESMTPSA id x7-20020a17090a294700b00234899c65e7sm4763228pjf.28.2023.02.22.03.12.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 03:12:36 -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 3/4] gpio: loongson1: Add DT support Date: Wed, 22 Feb 2023 19:12:12 +0800 Message-Id: <20230222111213.2241633-4-keguang.zhang@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230222111213.2241633-1-keguang.zhang@gmail.com> References: <20230222111213.2241633-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, including the following changes. - Add the of_match_table - Parse the ngpios property - Parse the alias id Signed-off-by: Keguang Zhang --- drivers/gpio/gpio-loongson1.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/drivers/gpio/gpio-loongson1.c b/drivers/gpio/gpio-loongson1.c index b950bcfd78ce..92ad31f61bf0 100644 --- a/drivers/gpio/gpio-loongson1.c +++ b/drivers/gpio/gpio-loongson1.c @@ -48,7 +48,10 @@ static void ls1x_gpio_free(struct gpio_chip *gc, unsigned int offset) static int ls1x_gpio_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; + struct device_node *dn = pdev->dev.of_node; struct ls1x_gpio_chip *ls1x_gc; + unsigned int ngpios; + int id; int ret; ls1x_gc = devm_kzalloc(dev, sizeof(*ls1x_gc), GFP_KERNEL); @@ -59,34 +62,56 @@ static int ls1x_gpio_probe(struct platform_device *pdev) if (IS_ERR(ls1x_gc->reg_base)) return PTR_ERR(ls1x_gc->reg_base); + if (of_property_read_u32(dn, "ngpios", &ngpios)) { + dev_err(dev, "Missing ngpios OF property\n"); + return -ENODEV; + } + + id = of_alias_get_id(dn, "gpio"); + if (id < 0) { + dev_err(dev, "Couldn't get OF id\n"); + return id; + } + 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; + ls1x_gc->gc.label = dev_name(&pdev->dev); + ls1x_gc->gc.ngpio = ngpios; ls1x_gc->gc.owner = THIS_MODULE; + ls1x_gc->gc.parent = dev; + ls1x_gc->gc.base = pdev->id * BITS_PER_LONG; 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, &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 %d registered with %d pins\n", id, + ngpios); 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 */ } +}; + static struct platform_driver ls1x_gpio_driver = { .probe = ls1x_gpio_probe, .driver = { .name = "ls1x-gpio", + .of_match_table = ls1x_gpio_dt_ids, }, }; From patchwork Wed Feb 22 11:12: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: 13149034 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 31D2AC61DA4 for ; Wed, 22 Feb 2023 11:12:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231801AbjBVLMy (ORCPT ); Wed, 22 Feb 2023 06:12:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231788AbjBVLMv (ORCPT ); Wed, 22 Feb 2023 06:12:51 -0500 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCB2C392B5; Wed, 22 Feb 2023 03:12:42 -0800 (PST) Received: by mail-pj1-x102d.google.com with SMTP id nt5-20020a17090b248500b00237161e33f4so6024541pjb.4; Wed, 22 Feb 2023 03:12:42 -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=AJ9DYSbNtBd9DPjLU4U4sH7nNCDVV4pFgLMTLw3Ypkc=; b=mCP2sIrzT0l72A0togvSIYGMucC8MVq21zmCLnPzmT0A3CydfV9EU+ChGgxhF4AM4g WGJ+XJOcH4685GuPjhgv4ZyKxYicsKzKACf5vwstBKUxVouCkGqE/064BB/LlCkw58+g 4pf8A5QhPnypsJqYbLTSb9NBPzvwF6x+xuDWeQxF5wFXdM3Nb1QeoNAQnDYdXiksQKlF roPfCPG3gid9SyCxxf3hbgeilVz/xCGCFKGqP9f1aWaNOURFTibs9uo5GxOR8VWmFcFv joqqbydp4PPAvLHWsspL1AQejxNOFMF/DkPsAqbzCDO9rqWYaxQQn6AnP11ivEO2o2j1 PnZA== 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=AJ9DYSbNtBd9DPjLU4U4sH7nNCDVV4pFgLMTLw3Ypkc=; b=DKLlJrAa8ZASyIzYcstoosY/51SqEA6+RaU4Jl5xWO86XGVTBxTDELkStuTJS8YIFB lmhZa5jvUTpS64398AA9HWG5bjDZ6SAR27xRo6Dv/jbsECKCqcgogrsYWgIIXm+mX29K OLb0y/Y9RqvUlZT26C5b2frh+CLd9+aO6SQHuAVri19xkxKyNb1XD0RRDS75Wp5oI8Yw n7UhRX0MOeIGZNhqHSxa/YCaDOlE2TZ821k1+hzWG6oINPlSyEngWjefc30Ov/TRl/O7 Jw+bF4NG6OphFcI0E+j7kdMR5ckD2htN5IDWGGCI2AZsPfau9yo5sMnEVnGCIwdlmsBG leHQ== X-Gm-Message-State: AO0yUKUHu6VHpf9dobniuepzhOCQU+qEVORvq477oFgnjD2iptve4WV0 atGMpUwMh1Ne41J+bSchBb/XNWgw+7SR4A== X-Google-Smtp-Source: AK7set8VK32EeAr175TT+eNn4od7p3eCIq1FJnE1yFuE/RAwOLqsg2DwJ4Cy5TGJTXMCYXVA7HhVlw== X-Received: by 2002:a17:90a:1d5:b0:233:ab9b:f86a with SMTP id 21-20020a17090a01d500b00233ab9bf86amr7497976pjd.8.1677064361780; Wed, 22 Feb 2023 03:12:41 -0800 (PST) Received: from kelvin-ThinkPad-L14-Gen-1.. (94.130.220.35.bc.googleusercontent.com. [35.220.130.94]) by smtp.gmail.com with ESMTPSA id x7-20020a17090a294700b00234899c65e7sm4763228pjf.28.2023.02.22.03.12.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 03:12:41 -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 4/4] dt-bindings: gpio: Add Loongson-1 GPIO Date: Wed, 22 Feb 2023 19:12:13 +0800 Message-Id: <20230222111213.2241633-5-keguang.zhang@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230222111213.2241633-1-keguang.zhang@gmail.com> References: <20230222111213.2241633-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 --- .../bindings/gpio/loongson,ls1x-gpio.yaml | 60 +++++++++++++++++++ 1 file changed, 60 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..e4ab49d48fae --- /dev/null +++ b/Documentation/devicetree/bindings/gpio/loongson,ls1x-gpio.yaml @@ -0,0 +1,60 @@ +# 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>; + }; + + - | + gpio1: gpio@1fd010c4 { + compatible = "loongson,ls1x-gpio"; + reg = <0x1fd010c4 0x4>; + + gpio-controller; + #gpio-cells = <2>; + + ngpios = <32>; + }; + +...