Received: by 10.213.65.68 with SMTP id h4csp414162imn; Fri, 16 Mar 2018 07:06:17 -0700 (PDT) X-Google-Smtp-Source: AG47ELuR+8ZnaMIHmp3FUFNmxqcNHZ7Cpauu6cBGB+jEmaTUgqPz74ynU8LS4PCeiKzA3JOZv7Lo X-Received: by 10.98.161.10 with SMTP id b10mr1693804pff.240.1521209177258; Fri, 16 Mar 2018 07:06:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521209177; cv=none; d=google.com; s=arc-20160816; b=dzUUmkfNkauftvt66SJ8MtKe6N7fZZT1/zkAzzwkGAODHTpQ+Yvt9ztwWDy6Y5MJVY KKn2p8PtAh2nneEFkGUP5SSFYhmSoEhK8sNTnJBtP5h47l9nGsCoYWv4S1bDonR+x6cx j7EWTQxO+ELoaTKObVS7SmBS0tBSG6d32MzGSeiEj9xEFjVxzKzevZibWiA2ymLAC5Ls DRVC2l+TLYlIf2ahovqAKw3bRHHnae9+YbffBALiEhbAota9ZXdtJNt/DSBHAZiRz1YM hqGQBan2yWW5WlbPGb733+/njhsz7mHqQl2TNtG9V7InPNsf97IzkGVITUSlI4KC5QxD Ifzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=CB8eyefNcb7l2o6JunXpzxmjsVjutTtBSMfF27eJ+f0=; b=lPZrM7VPmR+aHdLBiHxnLzaJQIyJeesegmuhQZPc+3fqNirygNw/ACSQ0RfLHxGZ70 0XlIIVP2Q25O2XRRu+EVLudUhlmuLpNkUBOdAQZAqZAsxqwYOVFtBbLasxiIxUiw1UMk z6vOGBkU+CisvilrsPbZkbum1d7G64PtYjoYrmmunogb9+cU7IlC8MxTIXhnXLlq8fqT GlSjMqFORdmWRtm1qdYsec25ZEUAHFc9o0ZOtQ0j6jhx+gRlY/ZlV75x377BIkHiRcq4 LKKlLXF/2nZ74YO5ViT+veITKbQMPuE2Ld1v0zulHUOuWJPpUazZhRtu3mcJ//4+/izX jemw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q23si4073762pfg.18.2018.03.16.07.05.53; Fri, 16 Mar 2018 07:06:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752854AbeCPOD7 (ORCPT + 99 others); Fri, 16 Mar 2018 10:03:59 -0400 Received: from hermes.aosc.io ([199.195.250.187]:44023 "EHLO hermes.aosc.io" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750982AbeCPOD5 (ORCPT ); Fri, 16 Mar 2018 10:03:57 -0400 Received: from localhost (localhost [127.0.0.1]) (Authenticated sender: icenowy@aosc.io) by hermes.aosc.io (Postfix) with ESMTPSA id 77D9159788; Fri, 16 Mar 2018 14:03:53 +0000 (UTC) From: Icenowy Zheng To: Rob Herring , Maxime Ripard , Chen-Yu Tsai , Linus Walleij Cc: linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, linux-sunxi@googlegroups.com, Icenowy Zheng Subject: [PATCH v4 2/9] pinctrl: sunxi: introduce IRQ bank conversion function Date: Fri, 16 Mar 2018 22:02:08 +0800 Message-Id: <20180316140215.28663-3-icenowy@aosc.io> In-Reply-To: <20180316140215.28663-1-icenowy@aosc.io> References: <20180316140215.28663-1-icenowy@aosc.io> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The Allwinner H6 SoC have its pin controllers with the first IRQ-capable GPIO bank at IRQ bank 1 and the second bank at IRQ bank 5. Some refactors in the sunxi pinctrl framework are needed. This commit introduces a IRQ bank conversion function, which replaces the "(bank_base + bank)" code in IRQ register access. Signed-off-by: Icenowy Zheng --- Extracted in v4. drivers/pinctrl/sunxi/pinctrl-sunxi.h | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.h b/drivers/pinctrl/sunxi/pinctrl-sunxi.h index a13bd57d880d..466840d886f6 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.h +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.h @@ -263,14 +263,19 @@ static inline u32 sunxi_pull_offset(u16 pin) return pin_num * PULL_PINS_BITS; } +static inline u32 sunxi_irq_hw_bank_num(const struct sunxi_pinctrl_desc *desc, u8 bank) +{ + return desc->irq_bank_base + bank; +} + static inline u32 sunxi_irq_cfg_reg(const struct sunxi_pinctrl_desc *desc, u16 irq) { - unsigned bank_base = desc->irq_bank_base; u8 bank = irq / IRQ_PER_BANK; u8 reg = (irq % IRQ_PER_BANK) / IRQ_CFG_IRQ_PER_REG * 0x04; - return IRQ_CFG_REG + (bank_base + bank) * IRQ_MEM_SIZE + reg; + return IRQ_CFG_REG + + sunxi_irq_hw_bank_num(desc, bank) * IRQ_MEM_SIZE + reg; } static inline u32 sunxi_irq_cfg_offset(u16 irq) @@ -281,9 +286,7 @@ static inline u32 sunxi_irq_cfg_offset(u16 irq) static inline u32 sunxi_irq_ctrl_reg_from_bank(const struct sunxi_pinctrl_desc *desc, u8 bank) { - unsigned bank_base = desc->irq_bank_base; - - return IRQ_CTRL_REG + (bank_base + bank) * IRQ_MEM_SIZE; + return IRQ_CTRL_REG + sunxi_irq_hw_bank_num(desc, bank) * IRQ_MEM_SIZE; } static inline u32 sunxi_irq_ctrl_reg(const struct sunxi_pinctrl_desc *desc, @@ -302,16 +305,14 @@ static inline u32 sunxi_irq_ctrl_offset(u16 irq) static inline u32 sunxi_irq_debounce_reg_from_bank(const struct sunxi_pinctrl_desc *desc, u8 bank) { - unsigned bank_base = desc->irq_bank_base; - - return IRQ_DEBOUNCE_REG + (bank_base + bank) * IRQ_MEM_SIZE; + return IRQ_DEBOUNCE_REG + + sunxi_irq_hw_bank_num(desc, bank) * IRQ_MEM_SIZE; } static inline u32 sunxi_irq_status_reg_from_bank(const struct sunxi_pinctrl_desc *desc, u8 bank) { - unsigned bank_base = desc->irq_bank_base; - - return IRQ_STATUS_REG + (bank_base + bank) * IRQ_MEM_SIZE; + return IRQ_STATUS_REG + + sunxi_irq_hw_bank_num(desc, bank) * IRQ_MEM_SIZE; } static inline u32 sunxi_irq_status_reg(const struct sunxi_pinctrl_desc *desc, -- 2.15.1