From patchwork Wed Mar 15 11:06:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keguang Zhang X-Patchwork-Id: 13175635 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 6E6C8C61DA4 for ; Wed, 15 Mar 2023 11:09:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231937AbjCOLJc (ORCPT ); Wed, 15 Mar 2023 07:09:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231452AbjCOLJI (ORCPT ); Wed, 15 Mar 2023 07:09:08 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E785280E01; Wed, 15 Mar 2023 04:07:13 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id h12-20020a17090aea8c00b0023d1311fab3so1538005pjz.1; Wed, 15 Mar 2023 04:07:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678878427; 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=erfjIHSmGXfoAF8ObS8yp8f/sPlytQRqicin+mQofyE=; b=hdXigU3R6KAcjNj0bYviTN6QNoX9fU+TVX2vOj3PLR2GJBVAIuFCuCTVwx2oA4QiuO Mm38P96tRgZbxkx4D6J++L4g4Ejy5NuHk6HMrHEgBWfRAThZwPuZnLSfd8tJWRuIIKZZ BZjcMp1TIpLlT6DY0XChSrVO4FfxSJMbjI61qagzM7gGcwP81mHDAT5qWPfoHOcvl2E6 k0IYg9scNojB05W8sQy7PRlBenZ5Q+x70D79BTzoNfEg+OjjJymk5CXBYqLk8PEwz9O1 hQd/Gil2ynOyaYo+K3V887aS4PWZyd+YnCkKhKlcunJy7BIV8qB+iY+rUx4rOLlFEO7I +e1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678878427; 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=erfjIHSmGXfoAF8ObS8yp8f/sPlytQRqicin+mQofyE=; b=uDaVjTn9tnG5743ZMwoZBsaC4dT5rzvTeKs3qOOuRlOpwhBty9rd0dIPWPtdEsEMfW 1ZA/AeLsklO3R8QToVdrspDsCG5Xs4eZIpQfefDzbdbkq6CxC6gni+f19rs/xuCJ/t5r 6StUVSfyosFyUd1JWsMGeUaq0Ywu/NwkI72XYFe6vsPAX7RYCfj2oAfq2DTSAcQnBsWw ykwChIoDlrp/QYTj7GaZY38b6PwLLBmPRsJK62Vhnvm28+F9Q9wwYj/YluTEKzIzYPWL wpWQXjL2GySHF12ZxS4tUXVcIvcZ3M12sJS6BJ/+F6/RbraYEbW+nxQVNSKQwP/Vu2hd bJXw== X-Gm-Message-State: AO0yUKVFUh7GiITNiPYoSufxHUAGOy0DUtmiC/L6mST66L+78t7Y1Kpy nybeV9pryyKIA3hjIbU0acyvCktKYb7b0Q== X-Google-Smtp-Source: AK7set/2tKoo97CmIefQTlqsJEeNZfDRiU2LnEzZhC2h2SQBe52QyQnM/yx0WYLPaEN9a+zXJ0ZYmw== X-Received: by 2002:a05:6a20:160f:b0:d3:a13a:4c43 with SMTP id l15-20020a056a20160f00b000d3a13a4c43mr15223302pzj.0.1678878426702; Wed, 15 Mar 2023 04:07:06 -0700 (PDT) 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 v4-20020aa78084000000b005892ea4f092sm3337489pff.95.2023.03.15.04.07.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 04:07:06 -0700 (PDT) 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 v3 1/4] gpio: loongson1: Convert to SPDX identifier Date: Wed, 15 Mar 2023 19:06:47 +0800 Message-Id: <20230315110650.142577-2-keguang.zhang@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230315110650.142577-1-keguang.zhang@gmail.com> References: <20230315110650.142577-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. The current author name is unofficial, change it to my real name. Signed-off-by: Keguang Zhang --- V2 -> V3: Explain the reason for changing the author name in commit message 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 Wed Mar 15 11:06:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keguang Zhang X-Patchwork-Id: 13175637 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 14D03C6FD1D for ; Wed, 15 Mar 2023 11:09:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231775AbjCOLJg (ORCPT ); Wed, 15 Mar 2023 07:09:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231947AbjCOLJK (ORCPT ); Wed, 15 Mar 2023 07:09:10 -0400 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 BAD3780E21; Wed, 15 Mar 2023 04:07:15 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id j13so2652845pjd.1; Wed, 15 Mar 2023 04:07:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678878431; 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=lwZTvG1oeNKrq9Gr/GVv1X6yyECjAkdB1xOqZJhu/cU=; b=oW/IVbCLc/UQchYBi+eel5GnHE/DU+fgENzl2b3O5ct8SFP0PFOjL5aICJ35s5/RjT Lj0Z+blmtLuRc+I/22KpbW+U8dRZRquEVgfNKKR6W2P3u6uahHTDhxD9t9VmD6dn+hEz t5AXcz0CcKr26B7K7/7u++7YMugjxmgu/Z9j+m+iqx2z2iXCZ/f/fChKiaobBfqO7Xm0 DvXHmVbcYMmBI3k+H10QOnR1bGtbEsOX06Gku/3I4vJLM7w7d52doNkOCDPsrNgQLU2o nGbHCZvR8Wv1EDwkaM7grYJXfU/cYlViHF37FiY+VMmDFB/FNnZdYHOeKWhfAGZGxSsG 8s3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678878431; 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=lwZTvG1oeNKrq9Gr/GVv1X6yyECjAkdB1xOqZJhu/cU=; b=0GRHbeb3yXQavxpLvPCD4iWI76EXhnzk1tgcufaXs0bIoley9OPH+LoBx3sY4Z9J9q bVfiRo0I3ey7ZBqksrkkydUfyRwW6HldyPqJSKl6ybL0IQL0lpSRC+G+gIeQCEW3HeoR YcsToiHb9/PWXhMVmq0v6U/zekrW5IqS1gdzS99EW6wlNoGSK7nvZGG5gHVrcC1LjiMz I44/o/3NlNzRg+QFPyp7GoxKN8wXZlcZsUSNM6OT2gM9LvhgOoAPFTt7D5AOm0vmyyPM osSwBXItIqkCgLtDGq1zeBb+BPi7AwDYxA7/dLT8DQ+PriagrzSOUh6X/mIu2YgDoNWK 1uaw== X-Gm-Message-State: AO0yUKW8k2MPTgjLbzS+PkYElbxmg88DEagRrDNz6Cghym9/fnN8Gkq7 F7uOCMsZE6Y7oNrV8jwYW3wAQfngxi2vkw== X-Google-Smtp-Source: AK7set8B1yeRbAR/bxeclMZyxkvqmPWoOiUeI4detaa6Tb9v2lPXoAfkRJmqae79j+FcOBacUy2bwA== X-Received: by 2002:a05:6a21:33a2:b0:cd:97f3:25e1 with SMTP id yy34-20020a056a2133a200b000cd97f325e1mr53363631pzb.51.1678878430945; Wed, 15 Mar 2023 04:07:10 -0700 (PDT) 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 v4-20020aa78084000000b005892ea4f092sm3337489pff.95.2023.03.15.04.07.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 04:07:10 -0700 (PDT) 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 v3 2/4] gpio: loongson1: Introduce ls1x_gpio_chip struct Date: Wed, 15 Mar 2023 19:06:48 +0800 Message-Id: <20230315110650.142577-3-keguang.zhang@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230315110650.142577-1-keguang.zhang@gmail.com> References: <20230315110650.142577-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 --- V2 -> V3: Restore the calling of __raw_readl() & __raw_writel() 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 8862c9ea0d41..dddfc71f0e10 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); + __raw_writel(__raw_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); + __raw_writel(__raw_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 Mar 15 11:06:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keguang Zhang X-Patchwork-Id: 13175636 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 A76A9C7618A for ; Wed, 15 Mar 2023 11:09:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232035AbjCOLJf (ORCPT ); Wed, 15 Mar 2023 07:09:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231944AbjCOLJK (ORCPT ); Wed, 15 Mar 2023 07:09:10 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C60C8A381; Wed, 15 Mar 2023 04:07:16 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id h12so2555738pfh.5; Wed, 15 Mar 2023 04:07:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678878435; 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=ENZGfn0N5sbbl8jujN5yatFHQa0wMdAEr3milXh8ga4=; b=QwaQwQTpf1tFpCrehpL5Tyxx2PvivtwFRGQ+2g63q9DRPT0iJpuIEW8aL2Xm62Y9ys 3mDgW4bOoMoydaV8ves1yBEXZQC9O6S3QxDvd472spfwRsW9Os65vbWnEAg3Y7lgiQC2 Skzt974XUv96M8Mn6Uc3G//MVte5u7/u1yDzF3wQ/ezurk/HDxWNVT/VPozaUnnt5juC qcqBVsGjql+wlf4sMzKmllb4tRLVZg756g8e4fjG09jCCcp2/ql9FGJCAn1N4zO+7YgU eMDBagzau5d0kmX3wqUKf0HkrIebPdkowPFw1P+GvI/kl+DocrmqRrWb2Ba2aKEClyj3 cNcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678878435; 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=ENZGfn0N5sbbl8jujN5yatFHQa0wMdAEr3milXh8ga4=; b=w2jJk22c98MPjnGmytlYy2u+Q0fTjbP5DtmhCsaLcRSeDHAFnPc5U+G2rMdKHBQAxM 0dd+gEV/x+ZHkvDqLJV1djeV/hKuLaZLXUd4PseRW+IGOu3sad19mB24PEm2I/crabaE k1gmDHz1ns2F2KOfggCFD7oGCPsh0Ytmx4A3MWWPQSZm+cuyoDavCv/P4IEruOSOKblJ o3E5eB+dapJA5lthUm61yFmH098cUyx4RX8ma2rt8JyAkzpzEhUu2aewA/vjlh/ghgRw fmqcDz5UOSAeKQ2At4fRgNg6yszk/Rgz/xWWrobalg1YciaC4cKYxaXFVETgIqMzgOxf KdFw== X-Gm-Message-State: AO0yUKUnd+HNTxenVwAj1j1VoIjF/91FWzmDpMjvujHsMAcoGObSl1pb DJW0hwrDR1bpy2/t5+qdlzk/Lu0shji9Mg== X-Google-Smtp-Source: AK7set+PWLrf/DlRfDSG5f4bqHukXK6xMHNFVopCKXQWA1Mp8+HPh7WAzOCp+nPmzafpDyFr8mv3gw== X-Received: by 2002:a62:5285:0:b0:625:68f7:d552 with SMTP id g127-20020a625285000000b0062568f7d552mr4789285pfb.7.1678878434748; Wed, 15 Mar 2023 04:07:14 -0700 (PDT) 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 v4-20020aa78084000000b005892ea4f092sm3337489pff.95.2023.03.15.04.07.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 04:07:14 -0700 (PDT) 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 v3 3/4] gpio: loongson1: Add DT support Date: Wed, 15 Mar 2023 19:06:49 +0800 Message-Id: <20230315110650.142577-4-keguang.zhang@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230315110650.142577-1-keguang.zhang@gmail.com> References: <20230315110650.142577-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 --- V2 -> V3: None 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 dddfc71f0e10..6ca3b969db4d 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 Wed Mar 15 11:06:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keguang Zhang X-Patchwork-Id: 13175638 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 524ACC76196 for ; Wed, 15 Mar 2023 11:10:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231436AbjCOLKD (ORCPT ); Wed, 15 Mar 2023 07:10:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231998AbjCOLJR (ORCPT ); Wed, 15 Mar 2023 07:09:17 -0400 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF72D8B053; Wed, 15 Mar 2023 04:07:22 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id p13-20020a17090a284d00b0023d2e945aebso3226778pjf.0; Wed, 15 Mar 2023 04:07:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678878440; 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=y9Xe7G0mUprolJIwH6MJzsVRZJv7ADzG9ZALSt3qn7I=; b=bnlcAHsnJ4trii4aCzzIEel+4/5DQsER6/JTZL5KRxvcnFIvy+SHL0ICtnSnNvLA6G Qo6rtncYrZnNuagheheDLAbDFfQSrPW2CwEvkEcow494V0zxgnnYIAg5yx0JqFo8r0fu BjjNrAt0yyNOg0i+FrIRhcjUg7cQLV8n0E+PDHc9tHBsvQXQxmYocWj+iGduLVQzawnY Bd78sI5+psvQjm3jSilslwd1O6vkJ7R+qDYksjRyhcZC7xQbiNxiYyU6vMhIaAktGYg7 9EjktWCLeOov+70/Hftb/eoI9eshHpi1a/+6xmxJrj2vIxbmhndClulTsSywPbQvTJ4j KpxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678878440; 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=y9Xe7G0mUprolJIwH6MJzsVRZJv7ADzG9ZALSt3qn7I=; b=bzT8fRemRi4vtWxo0It+A0psyzYu9PyeaQXj6574Hd9GnzbBSH3eaRso6rqK4F+RMf OucQDZ5dGL5V/lKFpUE8TVKsvfrYsFda2cmczu7cGsGHatvjUW9iyyCYMt7egs4ZL4Sz fEgpnDqQC46cBpi2fBntgWavAKX81d224WiSML0cszURjy4VjJ4BlNDkIKOaXuvltvS/ wXJ2ayh9qavwL7qZPVMXI+zo90MLJtEqG2gaADsceN8V/LErOhs0YiC7qynszHOcele5 UCQrGu4jvY48oQ3fQ0bAcoW+YW+yDKAWbszluIJv3ygqaEYoivbk5qywsTZoV7he4D9B pNhQ== X-Gm-Message-State: AO0yUKUiYkPpv7FHJm76mpdixZPeVUSvGCMvUh9cw6Hie+JxHMfmnIM3 SqTRMFad6O/ITmxgBb2MtjGRwJyo15KJOQ== X-Google-Smtp-Source: AK7set9sqKEiYZykBR5KsaGrFDgczaih/so64Py9emYlckhNQJ57WA1xmCZS8OAdFvUMLn7DhqaBpA== X-Received: by 2002:a05:6a21:328a:b0:cd:5334:e240 with SMTP id yt10-20020a056a21328a00b000cd5334e240mr46959597pzb.5.1678878439968; Wed, 15 Mar 2023 04:07:19 -0700 (PDT) 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 v4-20020aa78084000000b005892ea4f092sm3337489pff.95.2023.03.15.04.07.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 04:07:19 -0700 (PDT) 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 , Krzysztof Kozlowski Subject: [PATCH v3 4/4] dt-bindings: gpio: Add Loongson-1 GPIO Date: Wed, 15 Mar 2023 19:06:50 +0800 Message-Id: <20230315110650.142577-5-keguang.zhang@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230315110650.142577-1-keguang.zhang@gmail.com> References: <20230315110650.142577-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 --- V2 -> V3: Add Reviewed-by tag from 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>; + }; + +...