linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] mfd: tps65217: Improve the IRQ domain feature
@ 2016-11-15 13:02 Milo Kim
  2016-11-15 13:02 ` [PATCH 1/5] mfd: tps65217: Fix page fault on unloading modules Milo Kim
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Milo Kim @ 2016-11-15 13:02 UTC (permalink / raw)
  To: Lee Jones; +Cc: Tony Lindgren, linux-omap, linux-kernel, Milo Kim

TPS65217 can be built as a module, this patch-set includes the error fix 
and rework the interrupt handler.
Additionally, TPS65217 INT pin is registered as a system wakeup source.

Milo Kim (5):
  mfd: tps65217: Fix page fault on unloading modules
  mfd: tps65217: Specify the IRQ name
  mfd: tps65217: Update register interrupt mask bits instead of writing
    operation
  mfd: tps65217: Make an interrupt handler simpler
  mfd: tps65217: Support an interrupt pin as the system wakeup

 drivers/mfd/tps65217.c       | 71 ++++++++++++++++++++------------------------
 include/linux/mfd/tps65217.h |  4 ++-
 2 files changed, 36 insertions(+), 39 deletions(-)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/5] mfd: tps65217: Fix page fault on unloading modules
  2016-11-15 13:02 [PATCH 0/5] mfd: tps65217: Improve the IRQ domain feature Milo Kim
@ 2016-11-15 13:02 ` Milo Kim
  2016-11-22 15:39   ` Lee Jones
  2016-11-15 13:02 ` [PATCH 2/5] mfd: tps65217: Specify the IRQ name Milo Kim
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Milo Kim @ 2016-11-15 13:02 UTC (permalink / raw)
  To: Lee Jones; +Cc: Tony Lindgren, linux-omap, linux-kernel, Milo Kim

TPS65217 IRQ domain should be removed and initialised as NULL when the
module is unloaded for the next use. When tps65217.ko is loaded again,
it causes the page fault. This patch fixes the error below.

root@arm:~# lsmod | grep "tps"
tps65217_charger        3538  0
tps65218_pwrbutton      2974  0
tps65217                6710  1 tps65217_charger

root@arm:~# modprobe -r tps65217_charger

root@arm:~# modprobe tps65217.ko
[   71.990277] Unable to handle kernel paging request at virtual address bf055944
[   71.998063] pgd = dd3a4000
[   72.000904] [bf055944] *pgd=9e6f7811, *pte=00000000, *ppte=00000000
[   72.007567] Internal error: Oops: 7 [#1] SMP ARM
[   72.012404] Modules linked in: tps65217(+) evdev musb_dsps musb_hdrc udc_core tps65218_pwrbutton usbcore phy_am335]
[   72.055700] CPU: 0 PID: 243 Comm: modprobe Not tainted 4.9.0-rc5-next-20161114 #3
[   72.063531] Hardware name: Generic AM33XX (Flattened Device Tree)
[   72.069899] task: de714380 task.stack: de7e6000
[   72.074655] PC is at irq_find_matching_fwspec+0x88/0x100
[   72.080211] LR is at 0xde7e79d8
[   72.083496] pc : [<c01a5d88>]    lr : [<de7e79d8>]    psr: 200e0013
[   72.083496] sp : de7e7a78  ip : 00000000  fp : dd138a68
[   72.095506] r10: c0ca04f8  r9 : 00000018  r8 : de7e7ab8
[   72.100973] r7 : 00000001  r6 : c0c4517c  r5 : df963f68  r4 : de321980
[   72.107797] r3 : bf055940  r2 : de714380  r1 : 00000000  r0 : 00000000
[   72.114633] Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
[   72.122084] Control: 10c5387d  Table: 9d3a4019  DAC: 00000051
[   72.128097] Process modprobe (pid: 243, stack limit = 0xde7e6218)
[   72.134489] Stack: (0xde7e7a78 to 0xde7e8000)
[   72.139060] 7a60:                                                       df963f68 de7e7ab8
[   72.147643] 7a80: 00000000 dd0e1000 dd491e20 c01a6ea0 600e0013 c01a5dc0 dd138a68 c0c45138
[   72.156216] 7aa0: df963f68 00000000 df963f68 dd0e1010 00000000 c01a71a4 df963f68 00000001
[   72.164800] 7ac0: 00000002 de7e7ac0 c80048b8 dd0adf00 df963f68 c0c4517c 00000000 de7e7b50
[   72.173369] 7ae0: 00000018 c0ca04f8 dd138a68 c01a5dc0 df963f68 dd0e1010 00000000 dd0e1000
[   72.181942] 7b00: dd491e20 c0653a70 df963f58 00000001 00000002 00000000 00000000 00000000
[   72.190522] 7b20: 600e0093 c0cbf8f0 c0c0512c c0193674 00000001 00000080 00000000 c0554984
[   72.199096] 7b40: 00000000 00000000 800e0013 c0553858 df963f68 00000000 00000000 00000000
[   72.207674] 7b60: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[   72.216239] 7b80: 00000000 00000000 00000000 00000000 00000000 00000000 dd0e1000 c0544d24
[   72.224816] 7ba0: dd491e10 dd0e1010 dd16e800 bf1d517c bf1d5620 dd0e1010 c1497ed4 bf1d5620
[   72.233398] 7bc0: dd0e1010 fffffdfb bf1d5620 bf1d5620 00000000 c054537c c0545330 dd0e1010
[   72.241967] 7be0: c1497ed4 00000000 bf1d5620 c05433ac 00000000 00000000 de7e7c28 c0543570
[   72.250537] 7c00: 00000001 c1497e90 00000000 c0541884 de080cd4 dd44b7d4 dd0e1010 dd0e1010
[   72.259109] 7c20: dd0e1044 c05430c8 dd0e1010 00000001 dd0e1010 dd0e1018 dd0e1010 c0c9e328
[   72.267676] 7c40: de5d4020 c0542760 dd0e1018 dd0e1010 00000000 c0540ba8 dd138a40 c048dec4
[   72.276253] 7c60: 00000000 dd0e1000 00000001 dd0e1000 dd0e1010 dd0e1000 bf233de0 dd138a40
[   72.284829] 7c80: dd0e1010 c05450a0 000000bf 00000000 dd138a60 00000001 dd0e1000 c0571240
[   72.293398] 7ca0: 00000000 dd1ce9c0 00000040 dd1ce9cc bf233de0 00000003 de5d4020 ffffffff
[   72.301969] 7cc0: 00000004 dd0adf00 00000000 c0571408 00000000 00000000 dd0adf00 de5d4020
[   72.310543] 7ce0: c057146c dd1ce9c0 bf233d14 de5d4020 de7fb3d0 00000004 bf233d14 ffffffff
[   72.319120] 7d00: 00000018 dd49bf30 c01cedc0 c05714d0 00000000 00000000 dd0adf00 de322810
[   72.327692] 7d20: de322810 00000000 dd033000 000000f0 00000001 bf2333fc 00000000 00000000
[   72.336269] 7d40: dd0adf00 de5d4020 000000b6 bf233e40 de5d4020 bf233968 de5d4004 de5d4000
[   72.344848] 7d60: bf233314 c06148ac de5d4020 c1497ed4 00000000 bf233e40 00000000 c05433ac
[   72.353422] 7d80: 00000000 de5d4020 bf233e40 de5d4054 00000000 bf236000 00000000 c0543538
[   72.362002] 7da0: 00000000 bf233e40 c0543484 c05417e4 de1442a4 de5d04d0 bf233e40 de321300
[   72.370582] 7dc0: c0caa5a4 c05429fc bf233be0 bf233e40 c0cbfa44 bf233e40 c0cbfa44 dd2f7740
[   72.379148] 7de0: bf233f00 c05442f0 bf233e8c bf233e24 c0cbfa44 c0615ae0 00000000 bf233f00
[   72.387718] 7e00: c0cbfa44 c010186c 200f0013 c0191650 de714380 00000000 600f0013 00000040
[   72.396286] 7e20: dd2f7740 c018f1ac 00000001 c0c8356c 024000c0 c01a8854 c0c56e0e c028225c
[   72.404863] 7e40: dd2f7740 c0191984 de714380 dd2f7740 00000001 bf233f00 bf233f00 c0cbfa44
[   72.413440] 7e60: dd2f7740 bf233f00 00000001 dd49bf08 dd49bf30 c0230998 00000001 c0c8356c
[   72.421997] 7e80: c0c4c536 c0cbfa44 c0c0512c c01d2070 bf233f0c 00007fff bf233f00 c01cf5b8
[   72.430570] 7ea0: 00000000 c1475134 c01cee34 bf23411c bf233f48 bf234054 bf234150 00000000
[   72.439144] 7ec0: 024002c2 de7fbf40 0009bc20 c02776ac ff800000 00000000 00000000 bf233670
[   72.447723] 7ee0: 00000004 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[   72.456298] 7f00: 00000000 00000000 00000000 00000000 c01d2590 0000aa41 00000000 00000000
[   72.464862] 7f20: 000b2549 e12c3a41 00000051 de7e6000 0009bc20 c01d2630 00000530 e12b9000
[   72.473438] 7f40: 0000aa41 e12c1434 e12c1211 e12c336c 00001150 00001620 00000000 00000000
[   72.482003] 7f60: 00000000 000010fc 00000035 00000036 0000001d 0000001a 00000017 00000000
[   72.490564] 7f80: de7e6000 3ba39a00 0009b008 0009b718 00000080 c0107704 de7e6000 00000000
[   72.499141] 7fa0: 0009f609 c0107560 3ba39a00 0009b008 000a7b08 0000aa41 0009bc20 0000aa41
[   72.507717] 7fc0: 3ba39a00 0009b008 0009b718 00000080 00000001 00000008 0009ab14 0009f609
[   72.516290] 7fe0: bea31ab8 bea31aa8 0001e5eb b6e83b42 800f0030 000a7b08 0000ffff 0840ffff
[   72.524883] [<c01a5d88>] (irq_find_matching_fwspec) from [<c01a6ea0>] (irq_create_fwspec_mapping+0x28/0x2e0)
[   72.535174] [<c01a6ea0>] (irq_create_fwspec_mapping) from [<c01a71a4>] (irq_create_of_mapping+0x4c/0x54)
[   72.545115] [<c01a71a4>] (irq_create_of_mapping) from [<c0653a70>] (of_irq_get+0x58/0x68)
[   72.553699] [<c0653a70>] (of_irq_get) from [<c0544d24>] (platform_get_irq+0x1c/0xec)
[   72.561828] [<c0544d24>] (platform_get_irq) from [<bf1d517c>] (tps6521x_pb_probe+0xd0/0x1a8 [tps65218_pwrbutton])
[   72.572581] [<bf1d517c>] (tps6521x_pb_probe [tps65218_pwrbutton]) from [<c054537c>] (platform_drv_probe+0x4c/0xac)
[   72.583426] [<c054537c>] (platform_drv_probe) from [<c05433ac>] (driver_probe_device+0x204/0x2dc)
[   72.592729] [<c05433ac>] (driver_probe_device) from [<c0541884>] (bus_for_each_drv+0x58/0x8c)
[   72.601657] [<c0541884>] (bus_for_each_drv) from [<c05430c8>] (__device_attach+0xb0/0x114)
[   72.610324] [<c05430c8>] (__device_attach) from [<c0542760>] (bus_probe_device+0x88/0x90)
[   72.618898] [<c0542760>] (bus_probe_device) from [<c0540ba8>] (device_add+0x3b8/0x560)
[   72.627203] [<c0540ba8>] (device_add) from [<c05450a0>] (platform_device_add+0xa8/0x208)
[   72.635693] [<c05450a0>] (platform_device_add) from [<c0571240>] (mfd_add_device+0x240/0x338)
[   72.644634] [<c0571240>] (mfd_add_device) from [<c0571408>] (mfd_add_devices+0xa0/0x104)
[   72.653120] [<c0571408>] (mfd_add_devices) from [<c05714d0>] (devm_mfd_add_devices+0x60/0xa8)
[   72.662077] [<c05714d0>] (devm_mfd_add_devices) from [<bf2333fc>] (tps65217_probe+0xe8/0x2ec [tps65217])
[   72.672026] [<bf2333fc>] (tps65217_probe [tps65217]) from [<c06148ac>] (i2c_device_probe+0x168/0x1f4)
[   72.681695] [<c06148ac>] (i2c_device_probe) from [<c05433ac>] (driver_probe_device+0x204/0x2dc)
[   72.690816] [<c05433ac>] (driver_probe_device) from [<c0543538>] (__driver_attach+0xb4/0xb8)
[   72.699657] [<c0543538>] (__driver_attach) from [<c05417e4>] (bus_for_each_dev+0x60/0x94)
[   72.708224] [<c05417e4>] (bus_for_each_dev) from [<c05429fc>] (bus_add_driver+0x18c/0x214)
[   72.716892] [<c05429fc>] (bus_add_driver) from [<c05442f0>] (driver_register+0x78/0xf8)
[   72.725280] [<c05442f0>] (driver_register) from [<c0615ae0>] (i2c_register_driver+0x38/0x80)
[   72.734120] [<c0615ae0>] (i2c_register_driver) from [<c010186c>] (do_one_initcall+0x3c/0x178)
[   72.743055] [<c010186c>] (do_one_initcall) from [<c0230998>] (do_init_module+0x5c/0x1d0)
[   72.751537] [<c0230998>] (do_init_module) from [<c01d2070>] (load_module+0x1d10/0x21c0)
[   72.759933] [<c01d2070>] (load_module) from [<c01d2630>] (SyS_init_module+0x110/0x154)
[   72.768242] [<c01d2630>] (SyS_init_module) from [<c0107560>] (ret_fast_syscall+0x0/0x1c)
[   72.776725] Code: e5944000 e1540006 0a00001b e594300c (e593c004)
[   72.783181] ---[ end trace 0278ec325f4689b8 ]---

Fixes: 6556bdacf646 ("mfd: tps65217: Add support for IRQs")
Signed-off-by: Milo Kim <woogyom.kim@gmail.com>
---
 drivers/mfd/tps65217.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/mfd/tps65217.c b/drivers/mfd/tps65217.c
index 9a4d868..df2e775 100644
--- a/drivers/mfd/tps65217.c
+++ b/drivers/mfd/tps65217.c
@@ -424,6 +424,24 @@ static int tps65217_probe(struct i2c_client *client,
 	return 0;
 }
 
+static int tps65217_remove(struct i2c_client *client)
+{
+	struct tps65217 *tps = i2c_get_clientdata(client);
+	unsigned int virq;
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(tps65217_irqs); i++) {
+		virq = irq_find_mapping(tps->irq_domain, i);
+		if (virq)
+			irq_dispose_mapping(virq);
+	}
+
+	irq_domain_remove(tps->irq_domain);
+	tps->irq_domain = NULL;
+
+	return 0;
+}
+
 static const struct i2c_device_id tps65217_id_table[] = {
 	{"tps65217", TPS65217},
 	{ /* sentinel */ }
@@ -437,6 +455,7 @@ static struct i2c_driver tps65217_driver = {
 	},
 	.id_table	= tps65217_id_table,
 	.probe		= tps65217_probe,
+	.remove		= tps65217_remove,
 };
 
 static int __init tps65217_init(void)
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/5] mfd: tps65217: Specify the IRQ name
  2016-11-15 13:02 [PATCH 0/5] mfd: tps65217: Improve the IRQ domain feature Milo Kim
  2016-11-15 13:02 ` [PATCH 1/5] mfd: tps65217: Fix page fault on unloading modules Milo Kim
@ 2016-11-15 13:02 ` Milo Kim
  2016-11-22 15:45   ` Lee Jones
  2016-11-15 13:02 ` [PATCH 3/5] mfd: tps65217: Update register interrupt mask bits instead of writing operation Milo Kim
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Milo Kim @ 2016-11-15 13:02 UTC (permalink / raw)
  To: Lee Jones; +Cc: Tony Lindgren, linux-omap, linux-kernel, Milo Kim

TPS65217 MFD is an interrupt controller and MFD slave devices like
tps65217-charger and tps65217-pwrbutton request an interrupt to handle
each HW event.

Currently, TPS65217 IRQ name is not defined, so the result is as below.

root@arm:~# cat /proc/interrupts
...
182:          0      INTC   7 Level     tps65217-irq
183:          0         -   1 Edge      tps65217-charger
185:          0         -   2 Edge      tps65217_pwrbutton

This patch specifies the name of the interrupt controller.

182:          0      INTC   7 Level     tps65217-irq
183:          0  tps65217   1 Edge      tps65217-charger
185:          0  tps65217   2 Edge      tps65217_pwrbutton

Signed-off-by: Milo Kim <woogyom.kim@gmail.com>
---
 drivers/mfd/tps65217.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mfd/tps65217.c b/drivers/mfd/tps65217.c
index df2e775..77fb812 100644
--- a/drivers/mfd/tps65217.c
+++ b/drivers/mfd/tps65217.c
@@ -105,6 +105,7 @@ static void tps65217_irq_disable(struct irq_data *data)
 }
 
 static struct irq_chip tps65217_irq_chip = {
+	.name			= "tps65217",
 	.irq_bus_lock		= tps65217_irq_lock,
 	.irq_bus_sync_unlock	= tps65217_irq_sync_unlock,
 	.irq_enable		= tps65217_irq_enable,
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/5] mfd: tps65217: Update register interrupt mask bits instead of writing operation
  2016-11-15 13:02 [PATCH 0/5] mfd: tps65217: Improve the IRQ domain feature Milo Kim
  2016-11-15 13:02 ` [PATCH 1/5] mfd: tps65217: Fix page fault on unloading modules Milo Kim
  2016-11-15 13:02 ` [PATCH 2/5] mfd: tps65217: Specify the IRQ name Milo Kim
@ 2016-11-15 13:02 ` Milo Kim
  2016-11-22 15:46   ` Lee Jones
  2016-11-15 13:02 ` [PATCH 4/5] mfd: tps65217: Make an interrupt handler simpler Milo Kim
  2016-11-15 13:02 ` [PATCH 5/5] mfd: tps65217: Support an interrupt pin as the system wakeup Milo Kim
  4 siblings, 1 reply; 11+ messages in thread
From: Milo Kim @ 2016-11-15 13:02 UTC (permalink / raw)
  To: Lee Jones; +Cc: Tony Lindgren, linux-omap, linux-kernel, Milo Kim

TPS65217 interrupt register includes read/writeable mask bits with
read-only status bits. (bit 4, 5, 6 are R/W, bit 0, 1, 2 are RO)
And reserved bit is not required.

Register update operation is preferred for disabling all interrupts during
the device initialisation.

Signed-off-by: Milo Kim <woogyom.kim@gmail.com>
---
 drivers/mfd/tps65217.c       | 7 +++----
 include/linux/mfd/tps65217.h | 3 ++-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/mfd/tps65217.c b/drivers/mfd/tps65217.c
index 77fb812..9d76de9 100644
--- a/drivers/mfd/tps65217.c
+++ b/drivers/mfd/tps65217.c
@@ -189,10 +189,9 @@ static int tps65217_irq_init(struct tps65217 *tps, int irq)
 	tps->irq = irq;
 
 	/* Mask all interrupt sources */
-	tps->irq_mask = (TPS65217_INT_RESERVEDM | TPS65217_INT_PBM
-			| TPS65217_INT_ACM | TPS65217_INT_USBM);
-	tps65217_reg_write(tps, TPS65217_REG_INT, tps->irq_mask,
-			TPS65217_PROTECT_NONE);
+	tps->irq_mask = TPS65217_INT_MASK;
+	tps65217_set_bits(tps, TPS65217_REG_INT, TPS65217_INT_MASK,
+			  TPS65217_INT_MASK, TPS65217_PROTECT_NONE);
 
 	tps->irq_domain = irq_domain_add_linear(tps->dev->of_node,
 		TPS65217_NUM_IRQ, &tps65217_irq_domain_ops, tps);
diff --git a/include/linux/mfd/tps65217.h b/include/linux/mfd/tps65217.h
index 3cbec4b..35d8d64 100644
--- a/include/linux/mfd/tps65217.h
+++ b/include/linux/mfd/tps65217.h
@@ -73,13 +73,14 @@
 #define TPS65217_PPATH_AC_CURRENT_MASK	0x0C
 #define TPS65217_PPATH_USB_CURRENT_MASK	0x03
 
-#define TPS65217_INT_RESERVEDM		BIT(7)
 #define TPS65217_INT_PBM		BIT(6)
 #define TPS65217_INT_ACM		BIT(5)
 #define TPS65217_INT_USBM		BIT(4)
 #define TPS65217_INT_PBI		BIT(2)
 #define TPS65217_INT_ACI		BIT(1)
 #define TPS65217_INT_USBI		BIT(0)
+#define TPS65217_INT_MASK		(TPS65217_INT_PBM | TPS65217_INT_ACM | \
+					TPS65217_INT_USBM)
 
 #define TPS65217_CHGCONFIG0_TREG	BIT(7)
 #define TPS65217_CHGCONFIG0_DPPM	BIT(6)
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 4/5] mfd: tps65217: Make an interrupt handler simpler
  2016-11-15 13:02 [PATCH 0/5] mfd: tps65217: Improve the IRQ domain feature Milo Kim
                   ` (2 preceding siblings ...)
  2016-11-15 13:02 ` [PATCH 3/5] mfd: tps65217: Update register interrupt mask bits instead of writing operation Milo Kim
@ 2016-11-15 13:02 ` Milo Kim
  2016-11-22 15:48   ` Lee Jones
  2016-11-15 13:02 ` [PATCH 5/5] mfd: tps65217: Support an interrupt pin as the system wakeup Milo Kim
  4 siblings, 1 reply; 11+ messages in thread
From: Milo Kim @ 2016-11-15 13:02 UTC (permalink / raw)
  To: Lee Jones; +Cc: Tony Lindgren, linux-omap, linux-kernel, Milo Kim

Rework the IRQ handler by using HW IRQ number and status bit.

Each HW IRQ number is matched with TPS65217 register layout[*].
(USB IRQ number is 0, AC is 1, Push button is 2)

When an interrupt is enabled, mask bit should be cleared (unmasked).
If an interrupt is disabled, then mask bit should be set (masked).
This mask value is updated into the TPS65217 register in irq_sync_unlock().

Mask bit and interrupt status bit can be handled with HW IRQ number.
Eventually, additional IRQ data, 'tps65217_irqs[]' and the function,
'irq_to_tps65217_irq()' are not necessary.

[*] TPS65217 interrupt register layout

 Bit7  6     5     4     3    2     1     0
----------------------------------------------
| x | PBM | ACM | USBM | x | PBI | ACI | USBI

PBM:  Push button status change interrupt mask
ACM:  AC interrupt mask
USBM: USB power status change interrupt mask
PBI:  Push button status change interrupt
ACI:  AC power status change interrupt
USBI: USB power status change interrupt
x:    Not used

Signed-off-by: Milo Kim <woogyom.kim@gmail.com>
---
 drivers/mfd/tps65217.c       | 44 +++++++++-----------------------------------
 include/linux/mfd/tps65217.h |  1 +
 2 files changed, 10 insertions(+), 35 deletions(-)

diff --git a/drivers/mfd/tps65217.c b/drivers/mfd/tps65217.c
index 9d76de9..7376090 100644
--- a/drivers/mfd/tps65217.c
+++ b/drivers/mfd/tps65217.c
@@ -42,26 +42,6 @@ static struct resource pb_resources[] = {
 	DEFINE_RES_IRQ_NAMED(TPS65217_IRQ_PB, "PB"),
 };
 
-struct tps65217_irq {
-	int mask;
-	int interrupt;
-};
-
-static const struct tps65217_irq tps65217_irqs[] = {
-	[TPS65217_IRQ_PB] = {
-		.mask = TPS65217_INT_PBM,
-		.interrupt = TPS65217_INT_PBI,
-	},
-	[TPS65217_IRQ_AC] = {
-		.mask = TPS65217_INT_ACM,
-		.interrupt = TPS65217_INT_ACI,
-	},
-	[TPS65217_IRQ_USB] = {
-		.mask = TPS65217_INT_USBM,
-		.interrupt = TPS65217_INT_USBI,
-	},
-};
-
 static void tps65217_irq_lock(struct irq_data *data)
 {
 	struct tps65217 *tps = irq_data_get_irq_chip_data(data);
@@ -74,34 +54,28 @@ static void tps65217_irq_sync_unlock(struct irq_data *data)
 	struct tps65217 *tps = irq_data_get_irq_chip_data(data);
 	int ret;
 
-	ret = tps65217_reg_write(tps, TPS65217_REG_INT, tps->irq_mask,
-				TPS65217_PROTECT_NONE);
+	ret = tps65217_set_bits(tps, TPS65217_REG_INT, TPS65217_INT_MASK,
+				tps->irq_mask, TPS65217_PROTECT_NONE);
 	if (ret != 0)
 		dev_err(tps->dev, "Failed to sync IRQ masks\n");
 
 	mutex_unlock(&tps->irq_lock);
 }
 
-static inline const struct tps65217_irq *
-irq_to_tps65217_irq(struct tps65217 *tps, struct irq_data *data)
-{
-	return &tps65217_irqs[data->hwirq];
-}
-
 static void tps65217_irq_enable(struct irq_data *data)
 {
 	struct tps65217 *tps = irq_data_get_irq_chip_data(data);
-	const struct tps65217_irq *irq_data = irq_to_tps65217_irq(tps, data);
+	u8 mask = BIT(data->hwirq) << TPS65217_INT_SHIFT;
 
-	tps->irq_mask &= ~irq_data->mask;
+	tps->irq_mask &= ~mask;
 }
 
 static void tps65217_irq_disable(struct irq_data *data)
 {
 	struct tps65217 *tps = irq_data_get_irq_chip_data(data);
-	const struct tps65217_irq *irq_data = irq_to_tps65217_irq(tps, data);
+	u8 mask = BIT(data->hwirq) << TPS65217_INT_SHIFT;
 
-	tps->irq_mask |= irq_data->mask;
+	tps->irq_mask |= mask;
 }
 
 static struct irq_chip tps65217_irq_chip = {
@@ -150,8 +124,8 @@ static irqreturn_t tps65217_irq_thread(int irq, void *data)
 		return IRQ_NONE;
 	}
 
-	for (i = 0; i < ARRAY_SIZE(tps65217_irqs); i++) {
-		if (status & tps65217_irqs[i].interrupt) {
+	for (i = 0; i < TPS65217_NUM_IRQ; i++) {
+		if (status & BIT(i)) {
 			handle_nested_irq(irq_find_mapping(tps->irq_domain, i));
 			handled = true;
 		}
@@ -430,7 +404,7 @@ static int tps65217_remove(struct i2c_client *client)
 	unsigned int virq;
 	int i;
 
-	for (i = 0; i < ARRAY_SIZE(tps65217_irqs); i++) {
+	for (i = 0; i < TPS65217_NUM_IRQ; i++) {
 		virq = irq_find_mapping(tps->irq_domain, i);
 		if (virq)
 			irq_dispose_mapping(virq);
diff --git a/include/linux/mfd/tps65217.h b/include/linux/mfd/tps65217.h
index 35d8d64..eac2857 100644
--- a/include/linux/mfd/tps65217.h
+++ b/include/linux/mfd/tps65217.h
@@ -79,6 +79,7 @@
 #define TPS65217_INT_PBI		BIT(2)
 #define TPS65217_INT_ACI		BIT(1)
 #define TPS65217_INT_USBI		BIT(0)
+#define TPS65217_INT_SHIFT		4
 #define TPS65217_INT_MASK		(TPS65217_INT_PBM | TPS65217_INT_ACM | \
 					TPS65217_INT_USBM)
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 5/5] mfd: tps65217: Support an interrupt pin as the system wakeup
  2016-11-15 13:02 [PATCH 0/5] mfd: tps65217: Improve the IRQ domain feature Milo Kim
                   ` (3 preceding siblings ...)
  2016-11-15 13:02 ` [PATCH 4/5] mfd: tps65217: Make an interrupt handler simpler Milo Kim
@ 2016-11-15 13:02 ` Milo Kim
  2016-11-22 15:49   ` Lee Jones
  4 siblings, 1 reply; 11+ messages in thread
From: Milo Kim @ 2016-11-15 13:02 UTC (permalink / raw)
  To: Lee Jones; +Cc: Tony Lindgren, linux-omap, linux-kernel, Milo Kim

TPS65217 INT pin is used for the system wakeup from suspend mode.
This patch enables push button or charger input event as a wakeup source.

Signed-off-by: Milo Kim <woogyom.kim@gmail.com>
---
 drivers/mfd/tps65217.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/mfd/tps65217.c b/drivers/mfd/tps65217.c
index 7376090..f769c7d 100644
--- a/drivers/mfd/tps65217.c
+++ b/drivers/mfd/tps65217.c
@@ -183,6 +183,8 @@ static int tps65217_irq_init(struct tps65217 *tps, int irq)
 		return ret;
 	}
 
+	enable_irq_wake(irq);
+
 	return 0;
 }
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/5] mfd: tps65217: Fix page fault on unloading modules
  2016-11-15 13:02 ` [PATCH 1/5] mfd: tps65217: Fix page fault on unloading modules Milo Kim
@ 2016-11-22 15:39   ` Lee Jones
  0 siblings, 0 replies; 11+ messages in thread
From: Lee Jones @ 2016-11-22 15:39 UTC (permalink / raw)
  To: Milo Kim; +Cc: Tony Lindgren, linux-omap, linux-kernel

On Tue, 15 Nov 2016, Milo Kim wrote:

> TPS65217 IRQ domain should be removed and initialised as NULL when the
> module is unloaded for the next use. When tps65217.ko is loaded again,
> it causes the page fault. This patch fixes the error below.
> 
> root@arm:~# lsmod | grep "tps"
> tps65217_charger        3538  0
> tps65218_pwrbutton      2974  0
> tps65217                6710  1 tps65217_charger
> 
> root@arm:~# modprobe -r tps65217_charger
> 
> root@arm:~# modprobe tps65217.ko
> [   71.990277] Unable to handle kernel paging request at virtual address bf055944
> [   71.998063] pgd = dd3a4000
> [   72.000904] [bf055944] *pgd=9e6f7811, *pte=00000000, *ppte=00000000
> [   72.007567] Internal error: Oops: 7 [#1] SMP ARM
> [   72.012404] Modules linked in: tps65217(+) evdev musb_dsps musb_hdrc udc_core tps65218_pwrbutton usbcore phy_am335]
> [   72.055700] CPU: 0 PID: 243 Comm: modprobe Not tainted 4.9.0-rc5-next-20161114 #3
> [   72.063531] Hardware name: Generic AM33XX (Flattened Device Tree)
> [   72.069899] task: de714380 task.stack: de7e6000
> [   72.074655] PC is at irq_find_matching_fwspec+0x88/0x100
> [   72.080211] LR is at 0xde7e79d8
> [   72.083496] pc : [<c01a5d88>]    lr : [<de7e79d8>]    psr: 200e0013
> [   72.083496] sp : de7e7a78  ip : 00000000  fp : dd138a68
> [   72.095506] r10: c0ca04f8  r9 : 00000018  r8 : de7e7ab8
> [   72.100973] r7 : 00000001  r6 : c0c4517c  r5 : df963f68  r4 : de321980
> [   72.107797] r3 : bf055940  r2 : de714380  r1 : 00000000  r0 : 00000000
> [   72.114633] Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
> [   72.122084] Control: 10c5387d  Table: 9d3a4019  DAC: 00000051
> [   72.128097] Process modprobe (pid: 243, stack limit = 0xde7e6218)
> [   72.134489] Stack: (0xde7e7a78 to 0xde7e8000)
> [   72.139060] 7a60:                                                       df963f68 de7e7ab8
> [   72.147643] 7a80: 00000000 dd0e1000 dd491e20 c01a6ea0 600e0013 c01a5dc0 dd138a68 c0c45138
> [   72.156216] 7aa0: df963f68 00000000 df963f68 dd0e1010 00000000 c01a71a4 df963f68 00000001
> [   72.164800] 7ac0: 00000002 de7e7ac0 c80048b8 dd0adf00 df963f68 c0c4517c 00000000 de7e7b50
> [   72.173369] 7ae0: 00000018 c0ca04f8 dd138a68 c01a5dc0 df963f68 dd0e1010 00000000 dd0e1000
> [   72.181942] 7b00: dd491e20 c0653a70 df963f58 00000001 00000002 00000000 00000000 00000000
> [   72.190522] 7b20: 600e0093 c0cbf8f0 c0c0512c c0193674 00000001 00000080 00000000 c0554984
> [   72.199096] 7b40: 00000000 00000000 800e0013 c0553858 df963f68 00000000 00000000 00000000
> [   72.207674] 7b60: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
> [   72.216239] 7b80: 00000000 00000000 00000000 00000000 00000000 00000000 dd0e1000 c0544d24
> [   72.224816] 7ba0: dd491e10 dd0e1010 dd16e800 bf1d517c bf1d5620 dd0e1010 c1497ed4 bf1d5620
> [   72.233398] 7bc0: dd0e1010 fffffdfb bf1d5620 bf1d5620 00000000 c054537c c0545330 dd0e1010
> [   72.241967] 7be0: c1497ed4 00000000 bf1d5620 c05433ac 00000000 00000000 de7e7c28 c0543570
> [   72.250537] 7c00: 00000001 c1497e90 00000000 c0541884 de080cd4 dd44b7d4 dd0e1010 dd0e1010
> [   72.259109] 7c20: dd0e1044 c05430c8 dd0e1010 00000001 dd0e1010 dd0e1018 dd0e1010 c0c9e328
> [   72.267676] 7c40: de5d4020 c0542760 dd0e1018 dd0e1010 00000000 c0540ba8 dd138a40 c048dec4
> [   72.276253] 7c60: 00000000 dd0e1000 00000001 dd0e1000 dd0e1010 dd0e1000 bf233de0 dd138a40
> [   72.284829] 7c80: dd0e1010 c05450a0 000000bf 00000000 dd138a60 00000001 dd0e1000 c0571240
> [   72.293398] 7ca0: 00000000 dd1ce9c0 00000040 dd1ce9cc bf233de0 00000003 de5d4020 ffffffff
> [   72.301969] 7cc0: 00000004 dd0adf00 00000000 c0571408 00000000 00000000 dd0adf00 de5d4020
> [   72.310543] 7ce0: c057146c dd1ce9c0 bf233d14 de5d4020 de7fb3d0 00000004 bf233d14 ffffffff
> [   72.319120] 7d00: 00000018 dd49bf30 c01cedc0 c05714d0 00000000 00000000 dd0adf00 de322810
> [   72.327692] 7d20: de322810 00000000 dd033000 000000f0 00000001 bf2333fc 00000000 00000000
> [   72.336269] 7d40: dd0adf00 de5d4020 000000b6 bf233e40 de5d4020 bf233968 de5d4004 de5d4000
> [   72.344848] 7d60: bf233314 c06148ac de5d4020 c1497ed4 00000000 bf233e40 00000000 c05433ac
> [   72.353422] 7d80: 00000000 de5d4020 bf233e40 de5d4054 00000000 bf236000 00000000 c0543538
> [   72.362002] 7da0: 00000000 bf233e40 c0543484 c05417e4 de1442a4 de5d04d0 bf233e40 de321300
> [   72.370582] 7dc0: c0caa5a4 c05429fc bf233be0 bf233e40 c0cbfa44 bf233e40 c0cbfa44 dd2f7740
> [   72.379148] 7de0: bf233f00 c05442f0 bf233e8c bf233e24 c0cbfa44 c0615ae0 00000000 bf233f00
> [   72.387718] 7e00: c0cbfa44 c010186c 200f0013 c0191650 de714380 00000000 600f0013 00000040
> [   72.396286] 7e20: dd2f7740 c018f1ac 00000001 c0c8356c 024000c0 c01a8854 c0c56e0e c028225c
> [   72.404863] 7e40: dd2f7740 c0191984 de714380 dd2f7740 00000001 bf233f00 bf233f00 c0cbfa44
> [   72.413440] 7e60: dd2f7740 bf233f00 00000001 dd49bf08 dd49bf30 c0230998 00000001 c0c8356c
> [   72.421997] 7e80: c0c4c536 c0cbfa44 c0c0512c c01d2070 bf233f0c 00007fff bf233f00 c01cf5b8
> [   72.430570] 7ea0: 00000000 c1475134 c01cee34 bf23411c bf233f48 bf234054 bf234150 00000000
> [   72.439144] 7ec0: 024002c2 de7fbf40 0009bc20 c02776ac ff800000 00000000 00000000 bf233670
> [   72.447723] 7ee0: 00000004 00000000 00000000 00000000 00000000 00000000 00000000 00000000
> [   72.456298] 7f00: 00000000 00000000 00000000 00000000 c01d2590 0000aa41 00000000 00000000
> [   72.464862] 7f20: 000b2549 e12c3a41 00000051 de7e6000 0009bc20 c01d2630 00000530 e12b9000
> [   72.473438] 7f40: 0000aa41 e12c1434 e12c1211 e12c336c 00001150 00001620 00000000 00000000
> [   72.482003] 7f60: 00000000 000010fc 00000035 00000036 0000001d 0000001a 00000017 00000000
> [   72.490564] 7f80: de7e6000 3ba39a00 0009b008 0009b718 00000080 c0107704 de7e6000 00000000
> [   72.499141] 7fa0: 0009f609 c0107560 3ba39a00 0009b008 000a7b08 0000aa41 0009bc20 0000aa41
> [   72.507717] 7fc0: 3ba39a00 0009b008 0009b718 00000080 00000001 00000008 0009ab14 0009f609
> [   72.516290] 7fe0: bea31ab8 bea31aa8 0001e5eb b6e83b42 800f0030 000a7b08 0000ffff 0840ffff
> [   72.524883] [<c01a5d88>] (irq_find_matching_fwspec) from [<c01a6ea0>] (irq_create_fwspec_mapping+0x28/0x2e0)
> [   72.535174] [<c01a6ea0>] (irq_create_fwspec_mapping) from [<c01a71a4>] (irq_create_of_mapping+0x4c/0x54)
> [   72.545115] [<c01a71a4>] (irq_create_of_mapping) from [<c0653a70>] (of_irq_get+0x58/0x68)
> [   72.553699] [<c0653a70>] (of_irq_get) from [<c0544d24>] (platform_get_irq+0x1c/0xec)
> [   72.561828] [<c0544d24>] (platform_get_irq) from [<bf1d517c>] (tps6521x_pb_probe+0xd0/0x1a8 [tps65218_pwrbutton])
> [   72.572581] [<bf1d517c>] (tps6521x_pb_probe [tps65218_pwrbutton]) from [<c054537c>] (platform_drv_probe+0x4c/0xac)
> [   72.583426] [<c054537c>] (platform_drv_probe) from [<c05433ac>] (driver_probe_device+0x204/0x2dc)
> [   72.592729] [<c05433ac>] (driver_probe_device) from [<c0541884>] (bus_for_each_drv+0x58/0x8c)
> [   72.601657] [<c0541884>] (bus_for_each_drv) from [<c05430c8>] (__device_attach+0xb0/0x114)
> [   72.610324] [<c05430c8>] (__device_attach) from [<c0542760>] (bus_probe_device+0x88/0x90)
> [   72.618898] [<c0542760>] (bus_probe_device) from [<c0540ba8>] (device_add+0x3b8/0x560)
> [   72.627203] [<c0540ba8>] (device_add) from [<c05450a0>] (platform_device_add+0xa8/0x208)
> [   72.635693] [<c05450a0>] (platform_device_add) from [<c0571240>] (mfd_add_device+0x240/0x338)
> [   72.644634] [<c0571240>] (mfd_add_device) from [<c0571408>] (mfd_add_devices+0xa0/0x104)
> [   72.653120] [<c0571408>] (mfd_add_devices) from [<c05714d0>] (devm_mfd_add_devices+0x60/0xa8)
> [   72.662077] [<c05714d0>] (devm_mfd_add_devices) from [<bf2333fc>] (tps65217_probe+0xe8/0x2ec [tps65217])
> [   72.672026] [<bf2333fc>] (tps65217_probe [tps65217]) from [<c06148ac>] (i2c_device_probe+0x168/0x1f4)
> [   72.681695] [<c06148ac>] (i2c_device_probe) from [<c05433ac>] (driver_probe_device+0x204/0x2dc)
> [   72.690816] [<c05433ac>] (driver_probe_device) from [<c0543538>] (__driver_attach+0xb4/0xb8)
> [   72.699657] [<c0543538>] (__driver_attach) from [<c05417e4>] (bus_for_each_dev+0x60/0x94)
> [   72.708224] [<c05417e4>] (bus_for_each_dev) from [<c05429fc>] (bus_add_driver+0x18c/0x214)
> [   72.716892] [<c05429fc>] (bus_add_driver) from [<c05442f0>] (driver_register+0x78/0xf8)
> [   72.725280] [<c05442f0>] (driver_register) from [<c0615ae0>] (i2c_register_driver+0x38/0x80)
> [   72.734120] [<c0615ae0>] (i2c_register_driver) from [<c010186c>] (do_one_initcall+0x3c/0x178)
> [   72.743055] [<c010186c>] (do_one_initcall) from [<c0230998>] (do_init_module+0x5c/0x1d0)
> [   72.751537] [<c0230998>] (do_init_module) from [<c01d2070>] (load_module+0x1d10/0x21c0)
> [   72.759933] [<c01d2070>] (load_module) from [<c01d2630>] (SyS_init_module+0x110/0x154)
> [   72.768242] [<c01d2630>] (SyS_init_module) from [<c0107560>] (ret_fast_syscall+0x0/0x1c)
> [   72.776725] Code: e5944000 e1540006 0a00001b e594300c (e593c004)
> [   72.783181] ---[ end trace 0278ec325f4689b8 ]---
> 
> Fixes: 6556bdacf646 ("mfd: tps65217: Add support for IRQs")
> Signed-off-by: Milo Kim <woogyom.kim@gmail.com>
> ---
>  drivers/mfd/tps65217.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)

Applied, thanks.

> diff --git a/drivers/mfd/tps65217.c b/drivers/mfd/tps65217.c
> index 9a4d868..df2e775 100644
> --- a/drivers/mfd/tps65217.c
> +++ b/drivers/mfd/tps65217.c
> @@ -424,6 +424,24 @@ static int tps65217_probe(struct i2c_client *client,
>  	return 0;
>  }
>  
> +static int tps65217_remove(struct i2c_client *client)
> +{
> +	struct tps65217 *tps = i2c_get_clientdata(client);
> +	unsigned int virq;
> +	int i;
> +
> +	for (i = 0; i < ARRAY_SIZE(tps65217_irqs); i++) {
> +		virq = irq_find_mapping(tps->irq_domain, i);
> +		if (virq)
> +			irq_dispose_mapping(virq);
> +	}
> +
> +	irq_domain_remove(tps->irq_domain);
> +	tps->irq_domain = NULL;
> +
> +	return 0;
> +}
> +
>  static const struct i2c_device_id tps65217_id_table[] = {
>  	{"tps65217", TPS65217},
>  	{ /* sentinel */ }
> @@ -437,6 +455,7 @@ static struct i2c_driver tps65217_driver = {
>  	},
>  	.id_table	= tps65217_id_table,
>  	.probe		= tps65217_probe,
> +	.remove		= tps65217_remove,
>  };
>  
>  static int __init tps65217_init(void)

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/5] mfd: tps65217: Specify the IRQ name
  2016-11-15 13:02 ` [PATCH 2/5] mfd: tps65217: Specify the IRQ name Milo Kim
@ 2016-11-22 15:45   ` Lee Jones
  0 siblings, 0 replies; 11+ messages in thread
From: Lee Jones @ 2016-11-22 15:45 UTC (permalink / raw)
  To: Milo Kim; +Cc: Tony Lindgren, linux-omap, linux-kernel

On Tue, 15 Nov 2016, Milo Kim wrote:

> TPS65217 MFD is an interrupt controller and MFD slave devices like
> tps65217-charger and tps65217-pwrbutton request an interrupt to handle
> each HW event.
> 
> Currently, TPS65217 IRQ name is not defined, so the result is as below.
> 
> root@arm:~# cat /proc/interrupts
> ...
> 182:          0      INTC   7 Level     tps65217-irq
> 183:          0         -   1 Edge      tps65217-charger
> 185:          0         -   2 Edge      tps65217_pwrbutton
> 
> This patch specifies the name of the interrupt controller.
> 
> 182:          0      INTC   7 Level     tps65217-irq
> 183:          0  tps65217   1 Edge      tps65217-charger
> 185:          0  tps65217   2 Edge      tps65217_pwrbutton
> 
> Signed-off-by: Milo Kim <woogyom.kim@gmail.com>
> ---
>  drivers/mfd/tps65217.c | 1 +
>  1 file changed, 1 insertion(+)

Applied, thanks.

> diff --git a/drivers/mfd/tps65217.c b/drivers/mfd/tps65217.c
> index df2e775..77fb812 100644
> --- a/drivers/mfd/tps65217.c
> +++ b/drivers/mfd/tps65217.c
> @@ -105,6 +105,7 @@ static void tps65217_irq_disable(struct irq_data *data)
>  }
>  
>  static struct irq_chip tps65217_irq_chip = {
> +	.name			= "tps65217",
>  	.irq_bus_lock		= tps65217_irq_lock,
>  	.irq_bus_sync_unlock	= tps65217_irq_sync_unlock,
>  	.irq_enable		= tps65217_irq_enable,

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/5] mfd: tps65217: Update register interrupt mask bits instead of writing operation
  2016-11-15 13:02 ` [PATCH 3/5] mfd: tps65217: Update register interrupt mask bits instead of writing operation Milo Kim
@ 2016-11-22 15:46   ` Lee Jones
  0 siblings, 0 replies; 11+ messages in thread
From: Lee Jones @ 2016-11-22 15:46 UTC (permalink / raw)
  To: Milo Kim; +Cc: Tony Lindgren, linux-omap, linux-kernel

On Tue, 15 Nov 2016, Milo Kim wrote:

> TPS65217 interrupt register includes read/writeable mask bits with
> read-only status bits. (bit 4, 5, 6 are R/W, bit 0, 1, 2 are RO)
> And reserved bit is not required.
> 
> Register update operation is preferred for disabling all interrupts during
> the device initialisation.
> 
> Signed-off-by: Milo Kim <woogyom.kim@gmail.com>
> ---
>  drivers/mfd/tps65217.c       | 7 +++----
>  include/linux/mfd/tps65217.h | 3 ++-
>  2 files changed, 5 insertions(+), 5 deletions(-)

Applied, thanks.

> diff --git a/drivers/mfd/tps65217.c b/drivers/mfd/tps65217.c
> index 77fb812..9d76de9 100644
> --- a/drivers/mfd/tps65217.c
> +++ b/drivers/mfd/tps65217.c
> @@ -189,10 +189,9 @@ static int tps65217_irq_init(struct tps65217 *tps, int irq)
>  	tps->irq = irq;
>  
>  	/* Mask all interrupt sources */
> -	tps->irq_mask = (TPS65217_INT_RESERVEDM | TPS65217_INT_PBM
> -			| TPS65217_INT_ACM | TPS65217_INT_USBM);
> -	tps65217_reg_write(tps, TPS65217_REG_INT, tps->irq_mask,
> -			TPS65217_PROTECT_NONE);
> +	tps->irq_mask = TPS65217_INT_MASK;
> +	tps65217_set_bits(tps, TPS65217_REG_INT, TPS65217_INT_MASK,
> +			  TPS65217_INT_MASK, TPS65217_PROTECT_NONE);
>  
>  	tps->irq_domain = irq_domain_add_linear(tps->dev->of_node,
>  		TPS65217_NUM_IRQ, &tps65217_irq_domain_ops, tps);
> diff --git a/include/linux/mfd/tps65217.h b/include/linux/mfd/tps65217.h
> index 3cbec4b..35d8d64 100644
> --- a/include/linux/mfd/tps65217.h
> +++ b/include/linux/mfd/tps65217.h
> @@ -73,13 +73,14 @@
>  #define TPS65217_PPATH_AC_CURRENT_MASK	0x0C
>  #define TPS65217_PPATH_USB_CURRENT_MASK	0x03
>  
> -#define TPS65217_INT_RESERVEDM		BIT(7)
>  #define TPS65217_INT_PBM		BIT(6)
>  #define TPS65217_INT_ACM		BIT(5)
>  #define TPS65217_INT_USBM		BIT(4)
>  #define TPS65217_INT_PBI		BIT(2)
>  #define TPS65217_INT_ACI		BIT(1)
>  #define TPS65217_INT_USBI		BIT(0)
> +#define TPS65217_INT_MASK		(TPS65217_INT_PBM | TPS65217_INT_ACM | \
> +					TPS65217_INT_USBM)
>  
>  #define TPS65217_CHGCONFIG0_TREG	BIT(7)
>  #define TPS65217_CHGCONFIG0_DPPM	BIT(6)

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 4/5] mfd: tps65217: Make an interrupt handler simpler
  2016-11-15 13:02 ` [PATCH 4/5] mfd: tps65217: Make an interrupt handler simpler Milo Kim
@ 2016-11-22 15:48   ` Lee Jones
  0 siblings, 0 replies; 11+ messages in thread
From: Lee Jones @ 2016-11-22 15:48 UTC (permalink / raw)
  To: Milo Kim; +Cc: Tony Lindgren, linux-omap, linux-kernel

On Tue, 15 Nov 2016, Milo Kim wrote:

> Rework the IRQ handler by using HW IRQ number and status bit.
> 
> Each HW IRQ number is matched with TPS65217 register layout[*].
> (USB IRQ number is 0, AC is 1, Push button is 2)
> 
> When an interrupt is enabled, mask bit should be cleared (unmasked).
> If an interrupt is disabled, then mask bit should be set (masked).
> This mask value is updated into the TPS65217 register in irq_sync_unlock().
> 
> Mask bit and interrupt status bit can be handled with HW IRQ number.
> Eventually, additional IRQ data, 'tps65217_irqs[]' and the function,
> 'irq_to_tps65217_irq()' are not necessary.
> 
> [*] TPS65217 interrupt register layout
> 
>  Bit7  6     5     4     3    2     1     0
> ----------------------------------------------
> | x | PBM | ACM | USBM | x | PBI | ACI | USBI
> 
> PBM:  Push button status change interrupt mask
> ACM:  AC interrupt mask
> USBM: USB power status change interrupt mask
> PBI:  Push button status change interrupt
> ACI:  AC power status change interrupt
> USBI: USB power status change interrupt
> x:    Not used
> 
> Signed-off-by: Milo Kim <woogyom.kim@gmail.com>
> ---
>  drivers/mfd/tps65217.c       | 44 +++++++++-----------------------------------
>  include/linux/mfd/tps65217.h |  1 +
>  2 files changed, 10 insertions(+), 35 deletions(-)

Applied, thanks.

> diff --git a/drivers/mfd/tps65217.c b/drivers/mfd/tps65217.c
> index 9d76de9..7376090 100644
> --- a/drivers/mfd/tps65217.c
> +++ b/drivers/mfd/tps65217.c
> @@ -42,26 +42,6 @@ static struct resource pb_resources[] = {
>  	DEFINE_RES_IRQ_NAMED(TPS65217_IRQ_PB, "PB"),
>  };
>  
> -struct tps65217_irq {
> -	int mask;
> -	int interrupt;
> -};
> -
> -static const struct tps65217_irq tps65217_irqs[] = {
> -	[TPS65217_IRQ_PB] = {
> -		.mask = TPS65217_INT_PBM,
> -		.interrupt = TPS65217_INT_PBI,
> -	},
> -	[TPS65217_IRQ_AC] = {
> -		.mask = TPS65217_INT_ACM,
> -		.interrupt = TPS65217_INT_ACI,
> -	},
> -	[TPS65217_IRQ_USB] = {
> -		.mask = TPS65217_INT_USBM,
> -		.interrupt = TPS65217_INT_USBI,
> -	},
> -};
> -
>  static void tps65217_irq_lock(struct irq_data *data)
>  {
>  	struct tps65217 *tps = irq_data_get_irq_chip_data(data);
> @@ -74,34 +54,28 @@ static void tps65217_irq_sync_unlock(struct irq_data *data)
>  	struct tps65217 *tps = irq_data_get_irq_chip_data(data);
>  	int ret;
>  
> -	ret = tps65217_reg_write(tps, TPS65217_REG_INT, tps->irq_mask,
> -				TPS65217_PROTECT_NONE);
> +	ret = tps65217_set_bits(tps, TPS65217_REG_INT, TPS65217_INT_MASK,
> +				tps->irq_mask, TPS65217_PROTECT_NONE);
>  	if (ret != 0)
>  		dev_err(tps->dev, "Failed to sync IRQ masks\n");
>  
>  	mutex_unlock(&tps->irq_lock);
>  }
>  
> -static inline const struct tps65217_irq *
> -irq_to_tps65217_irq(struct tps65217 *tps, struct irq_data *data)
> -{
> -	return &tps65217_irqs[data->hwirq];
> -}
> -
>  static void tps65217_irq_enable(struct irq_data *data)
>  {
>  	struct tps65217 *tps = irq_data_get_irq_chip_data(data);
> -	const struct tps65217_irq *irq_data = irq_to_tps65217_irq(tps, data);
> +	u8 mask = BIT(data->hwirq) << TPS65217_INT_SHIFT;
>  
> -	tps->irq_mask &= ~irq_data->mask;
> +	tps->irq_mask &= ~mask;
>  }
>  
>  static void tps65217_irq_disable(struct irq_data *data)
>  {
>  	struct tps65217 *tps = irq_data_get_irq_chip_data(data);
> -	const struct tps65217_irq *irq_data = irq_to_tps65217_irq(tps, data);
> +	u8 mask = BIT(data->hwirq) << TPS65217_INT_SHIFT;
>  
> -	tps->irq_mask |= irq_data->mask;
> +	tps->irq_mask |= mask;
>  }
>  
>  static struct irq_chip tps65217_irq_chip = {
> @@ -150,8 +124,8 @@ static irqreturn_t tps65217_irq_thread(int irq, void *data)
>  		return IRQ_NONE;
>  	}
>  
> -	for (i = 0; i < ARRAY_SIZE(tps65217_irqs); i++) {
> -		if (status & tps65217_irqs[i].interrupt) {
> +	for (i = 0; i < TPS65217_NUM_IRQ; i++) {
> +		if (status & BIT(i)) {
>  			handle_nested_irq(irq_find_mapping(tps->irq_domain, i));
>  			handled = true;
>  		}
> @@ -430,7 +404,7 @@ static int tps65217_remove(struct i2c_client *client)
>  	unsigned int virq;
>  	int i;
>  
> -	for (i = 0; i < ARRAY_SIZE(tps65217_irqs); i++) {
> +	for (i = 0; i < TPS65217_NUM_IRQ; i++) {
>  		virq = irq_find_mapping(tps->irq_domain, i);
>  		if (virq)
>  			irq_dispose_mapping(virq);
> diff --git a/include/linux/mfd/tps65217.h b/include/linux/mfd/tps65217.h
> index 35d8d64..eac2857 100644
> --- a/include/linux/mfd/tps65217.h
> +++ b/include/linux/mfd/tps65217.h
> @@ -79,6 +79,7 @@
>  #define TPS65217_INT_PBI		BIT(2)
>  #define TPS65217_INT_ACI		BIT(1)
>  #define TPS65217_INT_USBI		BIT(0)
> +#define TPS65217_INT_SHIFT		4
>  #define TPS65217_INT_MASK		(TPS65217_INT_PBM | TPS65217_INT_ACM | \
>  					TPS65217_INT_USBM)
>  

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 5/5] mfd: tps65217: Support an interrupt pin as the system wakeup
  2016-11-15 13:02 ` [PATCH 5/5] mfd: tps65217: Support an interrupt pin as the system wakeup Milo Kim
@ 2016-11-22 15:49   ` Lee Jones
  0 siblings, 0 replies; 11+ messages in thread
From: Lee Jones @ 2016-11-22 15:49 UTC (permalink / raw)
  To: Milo Kim; +Cc: Tony Lindgren, linux-omap, linux-kernel

On Tue, 15 Nov 2016, Milo Kim wrote:

> TPS65217 INT pin is used for the system wakeup from suspend mode.
> This patch enables push button or charger input event as a wakeup source.
> 
> Signed-off-by: Milo Kim <woogyom.kim@gmail.com>
> ---
>  drivers/mfd/tps65217.c | 2 ++
>  1 file changed, 2 insertions(+)

Applied, thanks.

> diff --git a/drivers/mfd/tps65217.c b/drivers/mfd/tps65217.c
> index 7376090..f769c7d 100644
> --- a/drivers/mfd/tps65217.c
> +++ b/drivers/mfd/tps65217.c
> @@ -183,6 +183,8 @@ static int tps65217_irq_init(struct tps65217 *tps, int irq)
>  		return ret;
>  	}
>  
> +	enable_irq_wake(irq);
> +
>  	return 0;
>  }
>  

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-11-22 15:46 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-15 13:02 [PATCH 0/5] mfd: tps65217: Improve the IRQ domain feature Milo Kim
2016-11-15 13:02 ` [PATCH 1/5] mfd: tps65217: Fix page fault on unloading modules Milo Kim
2016-11-22 15:39   ` Lee Jones
2016-11-15 13:02 ` [PATCH 2/5] mfd: tps65217: Specify the IRQ name Milo Kim
2016-11-22 15:45   ` Lee Jones
2016-11-15 13:02 ` [PATCH 3/5] mfd: tps65217: Update register interrupt mask bits instead of writing operation Milo Kim
2016-11-22 15:46   ` Lee Jones
2016-11-15 13:02 ` [PATCH 4/5] mfd: tps65217: Make an interrupt handler simpler Milo Kim
2016-11-22 15:48   ` Lee Jones
2016-11-15 13:02 ` [PATCH 5/5] mfd: tps65217: Support an interrupt pin as the system wakeup Milo Kim
2016-11-22 15:49   ` Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).