From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Mark Brown <broonie@kernel.org>, Lee Jones <lee.jones@linaro.org>
Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
Mayulong <mayulong1@huawei.com>,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: [PATCH v8 08/14] staging: hikey9xx: hi6421-spmi-pmic: document registers
Date: Fri, 29 Jan 2021 20:51:54 +0100 [thread overview]
Message-ID: <10f52ec0a8346fb883245344886c44714c859cd1.1611949675.git.mchehab+huawei@kernel.org> (raw)
In-Reply-To: <cover.1611949675.git.mchehab+huawei@kernel.org>
Make it clearer about how the IRQ registers are filled by adding
a table with them, with two macros used to calculate the mask
register.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
drivers/staging/hikey9xx/hi6421-spmi-pmic.c | 39 +++++++++++++++++----
1 file changed, 32 insertions(+), 7 deletions(-)
diff --git a/drivers/staging/hikey9xx/hi6421-spmi-pmic.c b/drivers/staging/hikey9xx/hi6421-spmi-pmic.c
index f2af1760add9..9c10f7c4e7c9 100644
--- a/drivers/staging/hikey9xx/hi6421-spmi-pmic.c
+++ b/drivers/staging/hikey9xx/hi6421-spmi-pmic.c
@@ -38,10 +38,6 @@ enum hi6421_spmi_pmic_irq_list {
#define HISI_IRQ_ARRAY 2
#define HISI_IRQ_NUM (HISI_IRQ_ARRAY * 8)
-#define HISI_IRQ_MASK GENMASK(1, 0)
-
-#define SOC_PMIC_IRQ_MASK_0_ADDR 0x0202
-#define SOC_PMIC_IRQ0_ADDR 0x0212
#define HISI_IRQ_KEY_NUM 0
@@ -49,6 +45,36 @@ enum hi6421_spmi_pmic_irq_list {
#define HISI_IRQ_KEY_VALUE (BIT(POWERKEY_DOWN) | BIT(POWERKEY_UP))
#define HISI_MASK GENMASK(HISI_BITS - 1, 0)
+/*
+ * The IRQs are mapped as:
+ *
+ * ====================== ============= ============ =====
+ * IRQ MASK REGISTER IRQ REGISTER BIT
+ * ====================== ============= ============ =====
+ * OTMP 0x0202 0x212 bit 0
+ * VBUS_CONNECT 0x0202 0x212 bit 1
+ * VBUS_DISCONNECT 0x0202 0x212 bit 2
+ * ALARMON_R 0x0202 0x212 bit 3
+ * HOLD_6S 0x0202 0x212 bit 4
+ * HOLD_1S 0x0202 0x212 bit 5
+ * POWERKEY_UP 0x0202 0x212 bit 6
+ * POWERKEY_DOWN 0x0202 0x212 bit 7
+ *
+ * OCP_SCP_R 0x0203 0x213 bit 0
+ * COUL_R 0x0203 0x213 bit 1
+ * SIM0_HPD_R 0x0203 0x213 bit 2
+ * SIM0_HPD_F 0x0203 0x213 bit 3
+ * SIM1_HPD_R 0x0203 0x213 bit 4
+ * SIM1_HPD_F 0x0203 0x213 bit 5
+ * ====================== ============= ============ =====
+ */
+#define SOC_PMIC_IRQ_MASK_0_ADDR 0x0202
+#define SOC_PMIC_IRQ0_ADDR 0x0212
+
+#define IRQ_MASK_REGISTER(irq_data) (SOC_PMIC_IRQ_MASK_0_ADDR + \
+ (irqd_to_hwirq(irq_data) >> 3))
+#define IRQ_MASK_BIT(irq_data) BIT(irqd_to_hwirq(irq_data) & 0x07)
+
static const struct mfd_cell hi6421v600_devs[] = {
{ .name = "hi6421v600-regulator", },
};
@@ -89,13 +115,12 @@ static void hi6421_spmi_irq_mask(struct irq_data *d)
unsigned int data;
u32 offset;
- offset = (irqd_to_hwirq(d) >> HISI_IRQ_MASK);
- offset += SOC_PMIC_IRQ_MASK_0_ADDR;
+ offset = IRQ_MASK_REGISTER(d);
spin_lock_irqsave(&ddata->lock, flags);
regmap_read(ddata->regmap, offset, &data);
- data |= (1 << (irqd_to_hwirq(d) & 0x07));
+ data |= IRQ_MASK_BIT(d);
regmap_write(ddata->regmap, offset, data);
spin_unlock_irqrestore(&ddata->lock, flags);
--
2.29.2
next prev parent reply other threads:[~2021-01-29 19:55 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-29 19:51 [PATCH v8 00/14] Move Hisilicon 6421v600 SPMI and USB drivers out of staging Mauro Carvalho Chehab
2021-01-29 19:51 ` [PATCH v8 01/14] staging: hikey9xx: spmi driver: convert to regmap Mauro Carvalho Chehab
2021-01-29 19:51 ` [PATCH v8 02/14] staging: hikey9xx: hi6421v600-regulator: use some regmap helpers Mauro Carvalho Chehab
2021-01-29 19:51 ` [PATCH v8 03/14] staging: hikey9xx: hi6421-spmi-pmic: rename some vars Mauro Carvalho Chehab
2021-01-29 19:51 ` [PATCH v8 04/14] staging: hikey9xx: hi6421-spmi-pmic: cleanup probe code Mauro Carvalho Chehab
2021-01-29 19:51 ` [PATCH v8 05/14] staging: hikey9xx: hi6421-spmi-pmic: cleanup header file Mauro Carvalho Chehab
2021-01-29 19:51 ` [PATCH v8 06/14] staging: hikey9xx: hi6421-spmi-pmic: fix IRQ handler code Mauro Carvalho Chehab
2021-01-29 19:51 ` [PATCH v8 07/14] staging: hikey9xx: hi6421-spmi-pmic: cleanup IRQ handling code Mauro Carvalho Chehab
2021-01-29 19:51 ` Mauro Carvalho Chehab [this message]
2021-01-29 19:51 ` [PATCH v8 09/14] staging: hikey9xx: hi6421-spmi-pmic: update copyright notes Mauro Carvalho Chehab
2021-01-29 19:51 ` [PATCH v8 10/14] phy: phy-hi3670-usb3: move driver from staging into phy Mauro Carvalho Chehab
2021-01-29 19:51 ` [PATCH v8 11/14] spmi: hisi-spmi-controller: move driver from staging Mauro Carvalho Chehab
2021-02-08 22:12 ` Stephen Boyd
2021-01-29 19:51 ` [PATCH v8 12/14] mfd: hi6421-spmi-pmic: " Mauro Carvalho Chehab
2021-01-29 19:51 ` [PATCH v8 13/14] regulator: hi6421v600-regulator: move it " Mauro Carvalho Chehab
2021-01-29 19:52 ` [PATCH v8 14/14] dts: hisilicon: add support for the PMIC found on Hikey 970 Mauro Carvalho Chehab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=10f52ec0a8346fb883245344886c44714c859cd1.1611949675.git.mchehab+huawei@kernel.org \
--to=mchehab+huawei@kernel.org \
--cc=broonie@kernel.org \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=lee.jones@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mayulong1@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®