Received: by 10.223.185.116 with SMTP id b49csp632948wrg; Fri, 23 Feb 2018 04:28:48 -0800 (PST) X-Google-Smtp-Source: AH8x22696FmMfZkXaloE/IxJzd3Mp8+LAQ9QRC4jBQLkgZe0D+7TpWn9RXEwQYOU6Zh/GjbFtKZP X-Received: by 10.98.34.75 with SMTP id i72mr1600682pfi.165.1519388928690; Fri, 23 Feb 2018 04:28:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519388928; cv=none; d=google.com; s=arc-20160816; b=ouDYoT/7h9eEFHMgI0TqJDC2rTNwjlKuKof238Q8PVwpsl0eFX+fQYPKLirinkzrPa Wx5vXLT5uYUiKDxYWmmDHZ+gk5Jr0W5yKognGnuhhnbFARA0UvlTUqwMLzLUD7TwoNJw yk9qwNpEtUpKfPMM8NfDyfXXN7yy1z6IlmlS1c7mMBSKxZ026OEKHy6tnYPE4MBqMSG6 zirAbk4TToRnjy+l/qV2tIrRBySsByG++fApSq3Y0Nkd8pnaBYvqabrN/pZ2eZ/4wo2w ETrs6nEpRMTjrolLxkl9xSVhL82CgU8EIwtiWpbA6NaU2RzRgOPGmgB99P7GgV3JDFHA LjeA== 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=/u2gXSDBmHjjd1vqNJz8RyWQdJEhSArabYRt3LXpBhc=; b=RRlS0DCKqZlrqXcZsLP3vKN5hGwFdy9LV3v5ZkElhh3+bEAB9+/OzUBJYPRJZGUKeH RjivwO2cGhBwiEAICr4PCeZS/lOcd5rH70UJe8D7t2vzDfCuEDE2jXKX4R2mbnN49bqM 3MXccokm3cGZ3OoRMiUhZ8YpxPIgQDIXdm23kqIBIDn+zm3k5QoDH158xysgj9oOLoiE zg2fuDJNk1SkJG5YFdlVbrW8D0+HFObAi3Pn0RqUuBEeVKQcQ0t7aWB9SW/sfiH2prcm N39+IHKHJXoRIeIGnYghTve5OFMVa7apYbCIhtyre5cOhMlYKeMP8aaj4dK4/PmbEx+c PcoA== 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 t5-v6si1500745plo.104.2018.02.23.04.28.33; Fri, 23 Feb 2018 04:28:48 -0800 (PST) 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 S1751480AbeBWM1I (ORCPT + 99 others); Fri, 23 Feb 2018 07:27:08 -0500 Received: from hermes.aosc.io ([199.195.250.187]:51065 "EHLO hermes.aosc.io" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750827AbeBWM1G (ORCPT ); Fri, 23 Feb 2018 07:27:06 -0500 Received: from localhost (localhost [127.0.0.1]) (Authenticated sender: icenowy@aosc.io) by hermes.aosc.io (Postfix) with ESMTPSA id 2CBA0571E2; Fri, 23 Feb 2018 12:27:01 +0000 (UTC) From: Icenowy Zheng To: 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 v3 1/7] pinctrl: sunxi: refactor irq related register function to have desc Date: Fri, 23 Feb 2018 20:25:46 +0800 Message-Id: <20180223122552.58049-2-icenowy@aosc.io> In-Reply-To: <20180223122552.58049-1-icenowy@aosc.io> References: <20180223122552.58049-1-icenowy@aosc.io> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As the new H6 SoC has holes in the IRQ registers, refactor the IRQ related register function for getting the full pinctrl desc structure. Signed-off-by: Icenowy Zheng --- New patch in v3. drivers/pinctrl/sunxi/pinctrl-sunxi.c | 18 ++++++++---------- drivers/pinctrl/sunxi/pinctrl-sunxi.h | 29 +++++++++++++++++++++-------- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c index 341312d66512..31bd99f7df50 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c @@ -835,7 +835,7 @@ static void sunxi_pinctrl_irq_release_resources(struct irq_data *d) static int sunxi_pinctrl_irq_set_type(struct irq_data *d, unsigned int type) { struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d); - u32 reg = sunxi_irq_cfg_reg(d->hwirq, pctl->desc->irq_bank_base); + u32 reg = sunxi_irq_cfg_reg(d->hwirq, pctl->desc); u8 index = sunxi_irq_cfg_offset(d->hwirq); unsigned long flags; u32 regval; @@ -882,8 +882,7 @@ static int sunxi_pinctrl_irq_set_type(struct irq_data *d, unsigned int type) static void sunxi_pinctrl_irq_ack(struct irq_data *d) { struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d); - u32 status_reg = sunxi_irq_status_reg(d->hwirq, - pctl->desc->irq_bank_base); + u32 status_reg = sunxi_irq_status_reg(d->hwirq, pctl->desc); u8 status_idx = sunxi_irq_status_offset(d->hwirq); /* Clear the IRQ */ @@ -893,7 +892,7 @@ static void sunxi_pinctrl_irq_ack(struct irq_data *d) static void sunxi_pinctrl_irq_mask(struct irq_data *d) { struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d); - u32 reg = sunxi_irq_ctrl_reg(d->hwirq, pctl->desc->irq_bank_base); + u32 reg = sunxi_irq_ctrl_reg(d->hwirq, pctl->desc); u8 idx = sunxi_irq_ctrl_offset(d->hwirq); unsigned long flags; u32 val; @@ -910,7 +909,7 @@ static void sunxi_pinctrl_irq_mask(struct irq_data *d) static void sunxi_pinctrl_irq_unmask(struct irq_data *d) { struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d); - u32 reg = sunxi_irq_ctrl_reg(d->hwirq, pctl->desc->irq_bank_base); + u32 reg = sunxi_irq_ctrl_reg(d->hwirq, pctl->desc); u8 idx = sunxi_irq_ctrl_offset(d->hwirq); unsigned long flags; u32 val; @@ -1002,7 +1001,7 @@ static void sunxi_pinctrl_irq_handler(struct irq_desc *desc) if (bank == pctl->desc->irq_banks) return; - reg = sunxi_irq_status_reg_from_bank(bank, pctl->desc->irq_bank_base); + reg = sunxi_irq_status_reg_from_bank(bank, pctl->desc); val = readl(pctl->membase + reg); if (val) { @@ -1234,8 +1233,7 @@ static int sunxi_pinctrl_setup_debounce(struct sunxi_pinctrl *pctl, writel(src | div << 4, pctl->membase + - sunxi_irq_debounce_reg_from_bank(i, - pctl->desc->irq_bank_base)); + sunxi_irq_debounce_reg_from_bank(i, pctl->desc)); } return 0; @@ -1411,10 +1409,10 @@ int sunxi_pinctrl_init_with_variant(struct platform_device *pdev, for (i = 0; i < pctl->desc->irq_banks; i++) { /* Mask and clear all IRQs before registering a handler */ writel(0, pctl->membase + sunxi_irq_ctrl_reg_from_bank(i, - pctl->desc->irq_bank_base)); + pctl->desc)); writel(0xffffffff, pctl->membase + sunxi_irq_status_reg_from_bank(i, - pctl->desc->irq_bank_base)); + pctl->desc)); irq_set_chained_handler_and_data(pctl->irq[i], sunxi_pinctrl_irq_handler, diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.h b/drivers/pinctrl/sunxi/pinctrl-sunxi.h index 11b128f54ed2..909ca1504b61 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.h +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.h @@ -263,8 +263,10 @@ static inline u32 sunxi_pull_offset(u16 pin) return pin_num * PULL_PINS_BITS; } -static inline u32 sunxi_irq_cfg_reg(u16 irq, unsigned bank_base) +static inline u32 sunxi_irq_cfg_reg(u16 irq, + const struct sunxi_pinctrl_desc *desc) { + 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; @@ -277,16 +279,20 @@ static inline u32 sunxi_irq_cfg_offset(u16 irq) return irq_num * IRQ_CFG_IRQ_BITS; } -static inline u32 sunxi_irq_ctrl_reg_from_bank(u8 bank, unsigned bank_base) +static inline u32 sunxi_irq_ctrl_reg_from_bank(u8 bank, + const struct sunxi_pinctrl_desc *desc) { + unsigned bank_base = desc->irq_bank_base; + return IRQ_CTRL_REG + (bank_base + bank) * IRQ_MEM_SIZE; } -static inline u32 sunxi_irq_ctrl_reg(u16 irq, unsigned bank_base) +static inline u32 sunxi_irq_ctrl_reg(u16 irq, + const struct sunxi_pinctrl_desc *desc) { u8 bank = irq / IRQ_PER_BANK; - return sunxi_irq_ctrl_reg_from_bank(bank, bank_base); + return sunxi_irq_ctrl_reg_from_bank(bank, desc); } static inline u32 sunxi_irq_ctrl_offset(u16 irq) @@ -295,21 +301,28 @@ static inline u32 sunxi_irq_ctrl_offset(u16 irq) return irq_num * IRQ_CTRL_IRQ_BITS; } -static inline u32 sunxi_irq_debounce_reg_from_bank(u8 bank, unsigned bank_base) +static inline u32 sunxi_irq_debounce_reg_from_bank(u8 bank, + const struct sunxi_pinctrl_desc *desc) { + unsigned bank_base = desc->irq_bank_base; + return IRQ_DEBOUNCE_REG + (bank_base + bank) * IRQ_MEM_SIZE; } -static inline u32 sunxi_irq_status_reg_from_bank(u8 bank, unsigned bank_base) +static inline u32 sunxi_irq_status_reg_from_bank(u8 bank, + const struct sunxi_pinctrl_desc *desc) { + unsigned bank_base = desc->irq_bank_base; + return IRQ_STATUS_REG + (bank_base + bank) * IRQ_MEM_SIZE; } -static inline u32 sunxi_irq_status_reg(u16 irq, unsigned bank_base) +static inline u32 sunxi_irq_status_reg(u16 irq, + const struct sunxi_pinctrl_desc *desc) { u8 bank = irq / IRQ_PER_BANK; - return sunxi_irq_status_reg_from_bank(bank, bank_base); + return sunxi_irq_status_reg_from_bank(bank, desc); } static inline u32 sunxi_irq_status_offset(u16 irq) -- 2.15.1