Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2557001pxj; Mon, 10 May 2021 05:53:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwC/g4pWUsGz0bA01wNjoqeckGOzzCeAnWai1SYVJLxMGZ7J6NefspQilaIxn0M5f7kobMt X-Received: by 2002:a17:906:d978:: with SMTP id rp24mr25774140ejb.333.1620651193210; Mon, 10 May 2021 05:53:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620651193; cv=none; d=google.com; s=arc-20160816; b=t09t5rHbfmiHzMDO1dLIxqfo4vdv5QjxZcY6BSqlQpKRru6jugvBvEfgR4i4opd8+q KAt7Q+hvxdNJ3aj8T91BTbimhRaeVo78tNXCI5BB8U9+mL/BAK/Ah7iz7eM8vWVBy0Kz PUNzhXw1APzjbHj1E0vE++Q4ZNUoL6wZrP63dCjFsYkZlhBDcSGCrRUIRsQyucrE62he ooAzwhK1RR+Z+iRKFzKB4GJsI38wske+nseiO9lNVHpsIVNk2EhG/ZyB1cPxmG0tprU4 7iHM3fzZFAErVqcj/tzKG319bx0ozclimpj93HKnVOnepSeubjU98o980JX4glAT7XEg 0oig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=OWxQUVVa2arybZmQXM7SJPd9NPBkh+SfXD/oW3ya9rI=; b=f1wW8ILyK5Myx6/633qOopVm2xBecxR7YpuhAmcfHeGxiVPA8TKWYtJIL7uKCHdJSb 8Iu0TWalVuQQc7trsczw2/hW54h2hVfVmbz7YFJbFWx33c5NKxdt3AKSa6qL3CENABVK /dqhBDYeyaMpufIyPprs3dVrpAk3HzboFJQ7DE6bgf9O2aAYoIPKv55oJU0W5LECtIxN dIEMWMohzjfMHbcozSYZWzJ+sK0lCySlEw/TYmMy9THwq0ix5/u9ZTywz8ZnNPOufSk7 Ydkl3WuyEzDFu+j/55IAD3Gt/Yt30hbaSDLG/DlWjA57DVuaqU/zVu9prdPzXiQnGoWg pKzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fuy1oSmI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id fi16si13637132ejb.693.2021.05.10.05.52.49; Mon, 10 May 2021 05:53:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fuy1oSmI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348580AbhEJMqK (ORCPT + 99 others); Mon, 10 May 2021 08:46:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:60380 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238348AbhEJLR1 (ORCPT ); Mon, 10 May 2021 07:17:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1289861879; Mon, 10 May 2021 11:13:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620645186; bh=B4WFBvw88JPDtmDWu3XSrE3Iy6cbRF0VbxZZ4UkYxjA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fuy1oSmI2wNusKy3D9FaXefrtvBKPVGgAah5lU+EWt9aTgsw1MWqO6kP994zPe4V9 GxaN05VEIQuW7aVInhOkWzHKUgINGJbWJobUcKBeB+QYOl3WXXUUOGUaW8R6FIEMl5 dn/BogD+4dDvMiH8t4vsceKndZX96vZue/YibYHw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?=E5=91=A8=E7=90=B0=E6=9D=B0=20 ?= , Andy Shevchenko , Paul Cercueil , Linus Walleij Subject: [PATCH 5.12 381/384] pinctrl: Ingenic: Add support for read the pin configuration of X1830. Date: Mon, 10 May 2021 12:22:50 +0200 Message-Id: <20210510102027.350308445@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102014.849075526@linuxfoundation.org> References: <20210510102014.849075526@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: 周琰杰 (Zhou Yanjie) commit 1d0bd580ef83b78a10c0b37f3313eaa59d8c80db upstream. Add X1830 support in "ingenic_pinconf_get()", so that it can read the configuration of X1830 SoC correctly. Fixes: d7da2a1e4e08 ("pinctrl: Ingenic: Add pinctrl driver for X1830.") Cc: Signed-off-by: 周琰杰 (Zhou Yanjie) Reviewed-by: Andy Shevchenko Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/1618757073-1724-3-git-send-email-zhouyanjie@wanyeetech.com Signed-off-by: Linus Walleij Signed-off-by: Greg Kroah-Hartman --- drivers/pinctrl/pinctrl-ingenic.c | 40 +++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) --- a/drivers/pinctrl/pinctrl-ingenic.c +++ b/drivers/pinctrl/pinctrl-ingenic.c @@ -2109,26 +2109,48 @@ static int ingenic_pinconf_get(struct pi enum pin_config_param param = pinconf_to_config_param(*config); unsigned int idx = pin % PINS_PER_GPIO_CHIP; unsigned int offt = pin / PINS_PER_GPIO_CHIP; - bool pull; + unsigned int bias; + bool pull, pullup, pulldown; - if (jzpc->info->version >= ID_JZ4770) - pull = !ingenic_get_pin_config(jzpc, pin, JZ4770_GPIO_PEN); - else - pull = !ingenic_get_pin_config(jzpc, pin, JZ4740_GPIO_PULL_DIS); + if (jzpc->info->version >= ID_X1830) { + unsigned int half = PINS_PER_GPIO_CHIP / 2; + unsigned int idxh = (pin % half) * 2; + + if (idx < half) + regmap_read(jzpc->map, offt * jzpc->info->reg_offset + + X1830_GPIO_PEL, &bias); + else + regmap_read(jzpc->map, offt * jzpc->info->reg_offset + + X1830_GPIO_PEH, &bias); + + bias = (bias >> idxh) & (GPIO_PULL_UP | GPIO_PULL_DOWN); + + pullup = (bias == GPIO_PULL_UP) && (jzpc->info->pull_ups[offt] & BIT(idx)); + pulldown = (bias == GPIO_PULL_DOWN) && (jzpc->info->pull_downs[offt] & BIT(idx)); + + } else { + if (jzpc->info->version >= ID_JZ4770) + pull = !ingenic_get_pin_config(jzpc, pin, JZ4770_GPIO_PEN); + else + pull = !ingenic_get_pin_config(jzpc, pin, JZ4740_GPIO_PULL_DIS); + + pullup = pull && (jzpc->info->pull_ups[offt] & BIT(idx)); + pulldown = pull && (jzpc->info->pull_downs[offt] & BIT(idx)); + } switch (param) { case PIN_CONFIG_BIAS_DISABLE: - if (pull) + if (pullup || pulldown) return -EINVAL; break; case PIN_CONFIG_BIAS_PULL_UP: - if (!pull || !(jzpc->info->pull_ups[offt] & BIT(idx))) + if (!pullup) return -EINVAL; break; case PIN_CONFIG_BIAS_PULL_DOWN: - if (!pull || !(jzpc->info->pull_downs[offt] & BIT(idx))) + if (!pulldown) return -EINVAL; break; @@ -2146,7 +2168,7 @@ static void ingenic_set_bias(struct inge if (jzpc->info->version >= ID_X1830) { unsigned int idx = pin % PINS_PER_GPIO_CHIP; unsigned int half = PINS_PER_GPIO_CHIP / 2; - unsigned int idxh = pin % half * 2; + unsigned int idxh = (pin % half) * 2; unsigned int offt = pin / PINS_PER_GPIO_CHIP; if (idx < half) {