Skip to contentSkip to conversation

MPM pin mappings for MSM8226 and MSM8974

PATCH Superseded Matti Lehtimäki 3 participants 9 messages Sep 22, 2023 – Sep 23, 2023

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover MPM pin mappings for MSM8226 and MSM8974

This series adds the MPM wakeirq mappings for MSM8226 and MSM8974.

Matti Lehtimäki (2):
pinctrl: qcom: msm8226: Add MPM pin mappings
pinctrl: qcom: msm8974: Add MPM pin mappings

 drivers/pinctrl/qcom/pinctrl-msm8226.c | 12 ++++++++++++
 drivers/pinctrl/qcom/pinctrl-msm8x74.c | 12 ++++++++++++
 2 files changed, 24 insertions(+)
Signature · 1 line
2.39.2
#1 lore raw

PATCH 1/2 pinctrl: qcom: msm8226: Add MPM pin mappings

Add pin <-> wakeirq mappings to allow for waking up the AP from sleep through MPM-connected pins.

---
 drivers/pinctrl/qcom/pinctrl-msm8226.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/pinctrl/qcom/pinctrl-msm8226.c +12 -0
index 994619840a70..1e46a9ab382f 100644
@@ -612,6 +612,16 @@ static const struct msm_pingroup msm8226_groups[] = {
 
 #define NUM_GPIO_PINGROUPS 117
 
+static const struct msm_gpio_wakeirq_map msm8226_mpm_map[] = {
+	{ 1, 3 }, { 4, 4 }, { 5, 5 }, { 9, 6 }, { 13, 7 }, { 17, 8 },
+	{ 21, 9 }, { 27, 10 }, { 29, 11 }, { 31, 12 }, { 33, 13 }, { 35, 14 },
+	{ 37, 15 }, { 38, 16 }, { 39, 17 }, { 41, 18 }, { 46, 19 }, { 48, 20 },
+	{ 49, 21 }, { 50, 22 }, { 51, 23 }, { 52, 24 }, { 54, 25 }, { 62, 26 },
+	{ 63, 27 }, { 64, 28 }, { 65, 29 }, { 66, 30 }, { 67, 31 }, { 68, 32 },
+	{ 69, 33 }, { 71, 34 }, { 72, 35 }, { 106, 36 }, { 107, 37 },
+	{ 108, 38 }, { 109, 39 }, { 110, 40 }, { 111, 54 }, { 113, 55 },
+};
+
 static const struct msm_pinctrl_soc_data msm8226_pinctrl = {
 	.pins = msm8226_pins,
 	.npins = ARRAY_SIZE(msm8226_pins),
@@ -620,6 +630,8 @@ static const struct msm_pinctrl_soc_data msm8226_pinctrl = {
 	.groups = msm8226_groups,
 	.ngroups = ARRAY_SIZE(msm8226_groups),
 	.ngpios = NUM_GPIO_PINGROUPS,
+	.wakeirq_map = msm8226_mpm_map,
+	.nwakeirq_map = ARRAY_SIZE(msm8226_mpm_map),
 };
 
 static int msm8226_pinctrl_probe(struct platform_device *pdev)
Signature · 1 line
2.39.2
#2 lore raw

Re: [PATCH 1/2] pinctrl: qcom: msm8226: Add MPM pin mappings

Hi Matti,

Quoted 14 lines · On Samstag, 23. September 2023 00:40:26 CEST Matti Lehtimäki wrote:

Add pin <-> wakeirq mappings to allow for waking up the AP from sleep through MPM-connected pins.

---
 drivers/pinctrl/qcom/pinctrl-msm8226.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
(quoted diff) +0 -0

b/drivers/pinctrl/qcom/pinctrl-msm8226.c index 994619840a70..1e46a9ab382f 100644

drivers/pinctrl/qcom/pinctrl-msm8226.c static const struct msm_pingroup msm8226_groups[] = { · line 616

Quoted 5 lines
drivers/pinctrl/qcom/pinctrl-msm8226.c +2 -0
@@ -612,6 +612,16 @@ static const struct msm_pingroup msm8226_groups[] = {
 
 #define NUM_GPIO_PINGROUPS 117
 
+static const struct msm_gpio_wakeirq_map msm8226_mpm_map[] = {
+	{ 1, 3 }, { 4, 4 }, { 5, 5 }, { 9, 6 }, { 13, 7 }, { 17, 8 },

I'm not really convinced this is the correct order of values...

Let's look at downstream:

  qcom,gpio-map = <3  1>,
                  <4  4 >,
                  <5  5 >,
                  <6  9 >,
                  [...]

From Documentation/devicetree/bindings/arm/msm/mpm.txt downstream:

Each tuple represents a MPM pin and which GIC interrupt is routed to it.

So first is pin number, second is interrupt number.

And check mainline:

/**
* struct msm_gpio_wakeirq_map - Map of GPIOs and their wakeup pins
* @gpio: The GPIOs that are wakeup capable
* @wakeirq: The interrupt at the always-on interrupt controller
*/
struct msm_gpio_wakeirq_map {
unsigned int gpio;
unsigned int wakeirq;
};

So here we also have the order pin-interrupt, not the reverse order.

Therefore I believe the order in this patch is incorrect, and it should rather be:

{ 3, 1 }, { 4, 4 }, { 5, 5 }, { 6, 9 }, { 7, 13 }, { 8, 17 }, [...]

Or do you think I'm missing something?

Regards
Luca

drivers/pinctrl/qcom/pinctrl-msm8226.c static const struct msm_pingroup msm8226_groups[] = { · line 617

Quoted 1 line
drivers/pinctrl/qcom/pinctrl-msm8226.c +1 -0
+	{ 21, 9 }, { 27, 10 }, { 29, 11 }, { 31, 12 }, { 33, 13 }, { 35, 14 

},

drivers/pinctrl/qcom/pinctrl-msm8226.c static const struct msm_pingroup msm8226_groups[] = { · line 618

Quoted 1 line
drivers/pinctrl/qcom/pinctrl-msm8226.c +1 -0
+	{ 37, 15 }, { 38, 16 }, { 39, 17 }, { 41, 18 }, { 46, 19 }, { 48, 20 

},

drivers/pinctrl/qcom/pinctrl-msm8226.c static const struct msm_pingroup msm8226_groups[] = { · line 619

Quoted 1 line
drivers/pinctrl/qcom/pinctrl-msm8226.c +1 -0
+	{ 49, 21 }, { 50, 22 }, { 51, 23 }, { 52, 24 }, { 54, 25 }, { 62, 26 

},

drivers/pinctrl/qcom/pinctrl-msm8226.c static const struct msm_pingroup msm8226_groups[] = { · line 620

Quoted 1 line
drivers/pinctrl/qcom/pinctrl-msm8226.c +1 -0
+	{ 63, 27 }, { 64, 28 }, { 65, 29 }, { 66, 30 }, { 67, 31 }, { 68, 32 

},

Quoted 16 lines
drivers/pinctrl/qcom/pinctrl-msm8226.c +6 -0
+	{ 69, 33 }, { 71, 34 }, { 72, 35 }, { 106, 36 }, { 107, 37 },
+	{ 108, 38 }, { 109, 39 }, { 110, 40 }, { 111, 54 }, { 113, 55 },
+};
+
 static const struct msm_pinctrl_soc_data msm8226_pinctrl = {
 	.pins = msm8226_pins,
 	.npins = ARRAY_SIZE(msm8226_pins),
@@ -620,6 +630,8 @@ static const struct msm_pinctrl_soc_data msm8226_pinctrl
 = { .groups = msm8226_groups,
 	.ngroups = ARRAY_SIZE(msm8226_groups),
 	.ngpios = NUM_GPIO_PINGROUPS,
+	.wakeirq_map = msm8226_mpm_map,
+	.nwakeirq_map = ARRAY_SIZE(msm8226_mpm_map),
 };
 
 static int msm8226_pinctrl_probe(struct platform_device *pdev)
#3 lore raw

Re: [PATCH 1/2] pinctrl: qcom: msm8226: Add MPM pin mappings

Quoted 53 lines · Luca Weiss

Hi Matti,

Quoted 14 lines · On Samstag, 23. September 2023 00:40:26 CEST Matti Lehtimäki wrote:

Add pin <-> wakeirq mappings to allow for waking up the AP from sleep through MPM-connected pins.

---
 drivers/pinctrl/qcom/pinctrl-msm8226.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
(quoted diff) +0 -0

b/drivers/pinctrl/qcom/pinctrl-msm8226.c index 994619840a70..1e46a9ab382f 100644

drivers/pinctrl/qcom/pinctrl-msm8226.c static const struct msm_pingroup msm8226_groups[] = { · line 616

Quoted 5 lines
drivers/pinctrl/qcom/pinctrl-msm8226.c +2 -0
@@ -612,6 +612,16 @@ static const struct msm_pingroup msm8226_groups[] = {
 
 #define NUM_GPIO_PINGROUPS 117
 
+static const struct msm_gpio_wakeirq_map msm8226_mpm_map[] = {
+	{ 1, 3 }, { 4, 4 }, { 5, 5 }, { 9, 6 }, { 13, 7 }, { 17, 8 },

I'm not really convinced this is the correct order of values...

Let's look at downstream:

  qcom,gpio-map = <3  1>,
                  <4  4 >,
                  <5  5 >,
                  <6  9 >,
                  [...]

From Documentation/devicetree/bindings/arm/msm/mpm.txt downstream:

Each tuple represents a MPM pin and which GIC interrupt is routed to it.

So first is pin number, second is interrupt number.

And check mainline:

/**
* struct msm_gpio_wakeirq_map - Map of GPIOs and their wakeup pins
* @gpio: The GPIOs that are wakeup capable
* @wakeirq: The interrupt at the always-on interrupt controller
*/
struct msm_gpio_wakeirq_map {
unsigned int gpio;
unsigned int wakeirq;
};

So here we also have the order pin-interrupt, not the reverse order.

Quoted 8 lines

Therefore I believe the order in this patch is incorrect, and it should rather be:

{ 3, 1 }, { 4, 4 }, { 5, 5 }, { 6, 9 }, { 7, 13 }, { 8, 17 }, [...]

Or do you think I'm missing something?

Yes :)

Let's look at the later entries:

Quoted 4 lines

drivers/pinctrl/qcom/pinctrl-msm8226.c static const struct msm_pingroup msm8226_groups[] = { · line 617

Quoted 1 line
drivers/pinctrl/qcom/pinctrl-msm8226.c +1 -0
+	{ 21, 9 }, { 27, 10 }, { 29, 11 }, { 31, 12 }, { 33, 13 }, { 35, 14 

},

drivers/pinctrl/qcom/pinctrl-msm8226.c static const struct msm_pingroup msm8226_groups[] = { · line 618

Quoted 1 line
drivers/pinctrl/qcom/pinctrl-msm8226.c +1 -0
+	{ 37, 15 }, { 38, 16 }, { 39, 17 }, { 41, 18 }, { 46, 19 }, { 48, 20 

},

Quoted 8 lines

drivers/pinctrl/qcom/pinctrl-msm8226.c static const struct msm_pingroup msm8226_groups[] = { · line 619

Quoted 1 line
drivers/pinctrl/qcom/pinctrl-msm8226.c +1 -0
+	{ 49, 21 }, { 50, 22 }, { 51, 23 }, { 52, 24 }, { 54, 25 }, { 62, 26 

},

drivers/pinctrl/qcom/pinctrl-msm8226.c static const struct msm_pingroup msm8226_groups[] = { · line 620

Quoted 1 line
drivers/pinctrl/qcom/pinctrl-msm8226.c +1 -0
+	{ 63, 27 }, { 64, 28 }, { 65, 29 }, { 66, 30 }, { 67, 31 }, { 68, 32 

},

drivers/pinctrl/qcom/pinctrl-msm8226.c static const struct msm_pingroup msm8226_groups[] = { · line 624

Quoted 4 lines
drivers/pinctrl/qcom/pinctrl-msm8226.c +4 -0
+	{ 69, 33 }, { 71, 34 }, { 72, 35 }, { 106, 36 }, { 107, 37 },
+	{ 108, 38 }, { 109, 39 }, { 110, 40 }, { 111, 54 }, { 113, 55 },
+};
+

For example: { 113, 55 }, i.e. { .gpio = 113, .wakeirq = 55 }.

MSM8226 has GPIOs 0-116 and 64 MPM pins/interrupts. The order in this patch is the only one that can be correct because the definition would be invalid the other way around. 113 must be the GPIO number because it is larger than the 64 available MPM interrupt pins. :)

Thanks,
Stephan

#4 lore raw

Re: [PATCH 1/2] pinctrl: qcom: msm8226: Add MPM pin mappings

Quoted 93 lines · On Samstag, 23. September 2023 12:00:52 CEST Stephan Gerhold wrote:
Quoted 58 lines · Luca Weiss

Hi Matti,

Quoted 16 lines · On Samstag, 23. September 2023 00:40:26 CEST Matti Lehtimäki wrote:

Add pin <-> wakeirq mappings to allow for waking up the AP from sleep through MPM-connected pins.

---

 drivers/pinctrl/qcom/pinctrl-msm8226.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
(quoted diff) +0 -0

b/drivers/pinctrl/qcom/pinctrl-msm8226.c index
994619840a70..1e46a9ab382f
100644

drivers/pinctrl/qcom/pinctrl-msm8226.c static const struct msm_pingroup msm8226_groups[] = · line 617

Quoted 6 lines
drivers/pinctrl/qcom/pinctrl-msm8226.c +2 -0
@@ -612,6 +612,16 @@ static const struct msm_pingroup msm8226_groups[] =
 {
 
 #define NUM_GPIO_PINGROUPS 117
 
+static const struct msm_gpio_wakeirq_map msm8226_mpm_map[] = {
+	{ 1, 3 }, { 4, 4 }, { 5, 5 }, { 9, 6 }, { 13, 7 }, { 17, 8 },

I'm not really convinced this is the correct order of values...

Let's look at downstream:
qcom,gpio-map = <3 1>,

                  <4  4 >,
                  <5  5 >,
                  <6  9 >,
                  [...]

From Documentation/devicetree/bindings/arm/msm/mpm.txt downstream:
Each tuple represents a MPM pin and which GIC interrupt is routed to it.

So first is pin number, second is interrupt number.

And check mainline:
/**

* struct msm_gpio_wakeirq_map - Map of GPIOs and their wakeup pins
* @gpio: The GPIOs that are wakeup capable
* @wakeirq: The interrupt at the always-on interrupt controller
*/

  struct msm_gpio_wakeirq_map {

unsigned int gpio;
unsigned int wakeirq;

  };

So here we also have the order pin-interrupt, not the reverse order.

Quoted 7 lines

Therefore I believe the order in this patch is incorrect, and it should rather>
be:
{ 3, 1 }, { 4, 4 }, { 5, 5 }, { 6, 9 }, { 7, 13 }, { 8, 17 }, [...]

Or do you think I'm missing something?

Yes :)

Let's look at the later entries:

Quoted 12 lines

drivers/pinctrl/qcom/pinctrl-msm8226.c static const struct msm_pingroup msm8226_groups[] = · line 618

Quoted 1 line
drivers/pinctrl/qcom/pinctrl-msm8226.c +1 -0
+	{ 21, 9 }, { 27, 10 }, { 29, 11 }, { 31, 12 }, { 33, 13 }, { 35, 14

},

drivers/pinctrl/qcom/pinctrl-msm8226.c static const struct msm_pingroup msm8226_groups[] = · line 619

Quoted 1 line
drivers/pinctrl/qcom/pinctrl-msm8226.c +1 -0
+	{ 37, 15 }, { 38, 16 }, { 39, 17 }, { 41, 18 }, { 46, 19 }, { 48, 20

},

drivers/pinctrl/qcom/pinctrl-msm8226.c static const struct msm_pingroup msm8226_groups[] = · line 620

Quoted 1 line
drivers/pinctrl/qcom/pinctrl-msm8226.c +1 -0
+	{ 49, 21 }, { 50, 22 }, { 51, 23 }, { 52, 24 }, { 54, 25 }, { 62, 26

},

Quoted 8 lines

drivers/pinctrl/qcom/pinctrl-msm8226.c static const struct msm_pingroup msm8226_groups[] = · line 621

Quoted 1 line
drivers/pinctrl/qcom/pinctrl-msm8226.c +1 -0
+	{ 63, 27 }, { 64, 28 }, { 65, 29 }, { 66, 30 }, { 67, 31 }, { 68, 32

},

drivers/pinctrl/qcom/pinctrl-msm8226.c static const struct msm_pingroup msm8226_groups[] = { · line 624

Quoted 4 lines
drivers/pinctrl/qcom/pinctrl-msm8226.c +4 -0
+	{ 69, 33 }, { 71, 34 }, { 72, 35 }, { 106, 36 }, { 107, 37 },
+	{ 108, 38 }, { 109, 39 }, { 110, 40 }, { 111, 54 }, { 113, 55 },
+};
+

For example: { 113, 55 }, i.e. { .gpio = 113, .wakeirq = 55 }.

Quoted 4 lines

MSM8226 has GPIOs 0-116 and 64 MPM pins/interrupts. The order in this patch is the only one that can be correct because the definition would be invalid the other way around. 113 must be the GPIO number because it is larger than the 64 available MPM interrupt pins. :)

So basically you're saying downstream is wrong / buggy?

From qcom,gpio-map = [...], <55 113>; it's taking the properties like this (drivers/soc/qcom/mpm-of.c):

  unsigned long pin = be32_to_cpup(list++);
  irq_hw_number_t hwirq = be32_to_cpup(list++);

Your explanation does make sense I guess but somewhere the link downstream -> mainline must be broken, no?

Regards
Luca

Quoted 3 lines

Thanks,
Stephan

#5 lore raw

Re: [PATCH 1/2] pinctrl: qcom: msm8226: Add MPM pin mappings

Quoted 94 lines · Luca Weiss
Quoted 93 lines · On Samstag, 23. September 2023 12:00:52 CEST Stephan Gerhold wrote:
Quoted 58 lines · Luca Weiss

Hi Matti,

Quoted 16 lines · On Samstag, 23. September 2023 00:40:26 CEST Matti Lehtimäki wrote:

Add pin <-> wakeirq mappings to allow for waking up the AP from sleep through MPM-connected pins.

---

 drivers/pinctrl/qcom/pinctrl-msm8226.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
(quoted diff) +0 -0

b/drivers/pinctrl/qcom/pinctrl-msm8226.c index
994619840a70..1e46a9ab382f
100644

drivers/pinctrl/qcom/pinctrl-msm8226.c static const struct msm_pingroup msm8226_groups[] = · line 617

Quoted 6 lines
drivers/pinctrl/qcom/pinctrl-msm8226.c +2 -0
@@ -612,6 +612,16 @@ static const struct msm_pingroup msm8226_groups[] =
 {
 
 #define NUM_GPIO_PINGROUPS 117
 
+static const struct msm_gpio_wakeirq_map msm8226_mpm_map[] = {
+	{ 1, 3 }, { 4, 4 }, { 5, 5 }, { 9, 6 }, { 13, 7 }, { 17, 8 },

I'm not really convinced this is the correct order of values...

Let's look at downstream:
qcom,gpio-map = <3 1>,

                  <4  4 >,
                  <5  5 >,
                  <6  9 >,
                  [...]

From Documentation/devicetree/bindings/arm/msm/mpm.txt downstream:
Each tuple represents a MPM pin and which GIC interrupt is routed to it.

So first is pin number, second is interrupt number.

And check mainline:
/**

* struct msm_gpio_wakeirq_map - Map of GPIOs and their wakeup pins
* @gpio: The GPIOs that are wakeup capable
* @wakeirq: The interrupt at the always-on interrupt controller
*/

  struct msm_gpio_wakeirq_map {

unsigned int gpio;
unsigned int wakeirq;

  };

So here we also have the order pin-interrupt, not the reverse order.

Quoted 7 lines

Therefore I believe the order in this patch is incorrect, and it should rather>
be:
{ 3, 1 }, { 4, 4 }, { 5, 5 }, { 6, 9 }, { 7, 13 }, { 8, 17 }, [...]

Or do you think I'm missing something?

Yes :)

Let's look at the later entries:

Quoted 12 lines

drivers/pinctrl/qcom/pinctrl-msm8226.c static const struct msm_pingroup msm8226_groups[] = · line 618

Quoted 1 line
drivers/pinctrl/qcom/pinctrl-msm8226.c +1 -0
+	{ 21, 9 }, { 27, 10 }, { 29, 11 }, { 31, 12 }, { 33, 13 }, { 35, 14

},

drivers/pinctrl/qcom/pinctrl-msm8226.c static const struct msm_pingroup msm8226_groups[] = · line 619

Quoted 1 line
drivers/pinctrl/qcom/pinctrl-msm8226.c +1 -0
+	{ 37, 15 }, { 38, 16 }, { 39, 17 }, { 41, 18 }, { 46, 19 }, { 48, 20

},

drivers/pinctrl/qcom/pinctrl-msm8226.c static const struct msm_pingroup msm8226_groups[] = · line 620

Quoted 1 line
drivers/pinctrl/qcom/pinctrl-msm8226.c +1 -0
+	{ 49, 21 }, { 50, 22 }, { 51, 23 }, { 52, 24 }, { 54, 25 }, { 62, 26

},

Quoted 8 lines

drivers/pinctrl/qcom/pinctrl-msm8226.c static const struct msm_pingroup msm8226_groups[] = · line 621

Quoted 1 line
drivers/pinctrl/qcom/pinctrl-msm8226.c +1 -0
+	{ 63, 27 }, { 64, 28 }, { 65, 29 }, { 66, 30 }, { 67, 31 }, { 68, 32

},

drivers/pinctrl/qcom/pinctrl-msm8226.c static const struct msm_pingroup msm8226_groups[] = { · line 624

Quoted 4 lines
drivers/pinctrl/qcom/pinctrl-msm8226.c +4 -0
+	{ 69, 33 }, { 71, 34 }, { 72, 35 }, { 106, 36 }, { 107, 37 },
+	{ 108, 38 }, { 109, 39 }, { 110, 40 }, { 111, 54 }, { 113, 55 },
+};
+

For example: { 113, 55 }, i.e. { .gpio = 113, .wakeirq = 55 }.

Quoted 7 lines
Quoted 4 lines

MSM8226 has GPIOs 0-116 and 64 MPM pins/interrupts. The order in this patch is the only one that can be correct because the definition would be invalid the other way around. 113 must be the GPIO number because it is larger than the 64 available MPM interrupt pins. :)

So basically you're saying downstream is wrong / buggy?

"Misleading" or "confusing" would be the words I would use. :-)

Quoted 9 lines

From qcom,gpio-map = [...], <55 113>; it's taking the properties like this (drivers/soc/qcom/mpm-of.c):

  unsigned long pin = be32_to_cpup(list++);
  irq_hw_number_t hwirq = be32_to_cpup(list++);

Your explanation does make sense I guess but somewhere the link downstream -> mainline must be broken, no?

After staring at mpm-of.c for a while I would say that there:
- downstream "pin" = MPM pin = mainline "wakeirq"
- because this is used as index to msm_mpm_irqs_m2a, which has a size

     of MSM_MPM_NR_MPM_IRQS (64)

- downstream "hwirq" = GPIO / GIC IRQ = mainline "gpio"

This means for <55 113>: pin = wakeirq = 55 and hwirq = gpio = 113. Which matches the definition in this patch:
{ .gpio = 113, .wakeirq = 55 } = { 113, 55 }

Stephan

#6 lore raw

Re: [PATCH 1/2] pinctrl: qcom: msm8226: Add MPM pin mappings

Quoted 26 lines · On Samstag, 23. September 2023 13:35:25 CEST Stephan Gerhold wrote:
Quoted 25 lines · Luca Weiss
Quoted 24 lines · On Samstag, 23. September 2023 12:00:52 CEST Stephan Gerhold wrote:
Quoted 23 lines · Luca Weiss

Hi Matti,

Quoted 20 lines · On Samstag, 23. September 2023 00:40:26 CEST Matti Lehtimäki wrote:

Add pin <-> wakeirq mappings to allow for waking up the AP from sleep
through MPM-connected pins.

---

 drivers/pinctrl/qcom/pinctrl-msm8226.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
(quoted diff) +0 -0

b/drivers/pinctrl/qcom/pinctrl-msm8226.c index
994619840a70..1e46a9ab382f
100644

drivers/pinctrl/qcom/pinctrl-msm8226.c +0 -0
@@ -612,6 +612,16 @@ static const struct msm_pingroup

msm8226_groups[] =
{

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

drivers/pinctrl/qcom/pinctrl-msm8226.c

Quoted 4 lines

#define NUM_GPIO_PINGROUPS 117

drivers/pinctrl/qcom/pinctrl-msm8226.c +2 -0
+static const struct msm_gpio_wakeirq_map msm8226_mpm_map[] = {
+	{ 1, 3 }, { 4, 4 }, { 5, 5 }, { 9, 6 }, { 13, 7 }, { 17, 8 

},

Quoted 43 lines
Quoted 43 lines
Quoted 43 lines
Quoted 43 lines

I'm not really convinced this is the correct order of values...

Let's look at downstream:
qcom,gpio-map = <3 1>,

                  <4  4 >,
                  <5  5 >,
                  <6  9 >,
                  [...]

From Documentation/devicetree/bindings/arm/msm/mpm.txt downstream:
Each tuple represents a MPM pin and which GIC interrupt is routed to it.

So first is pin number, second is interrupt number.

And check mainline:
/**

* struct msm_gpio_wakeirq_map - Map of GPIOs and their wakeup pins
* @gpio: The GPIOs that are wakeup capable
* @wakeirq: The interrupt at the always-on interrupt
controller
*/

  struct msm_gpio_wakeirq_map {

unsigned int gpio;
unsigned int wakeirq;

  };

So here we also have the order pin-interrupt, not the reverse order.

Therefore I believe the order in this patch is incorrect, and it should
rather>

be:
{ 3, 1 }, { 4, 4 }, { 5, 5 }, { 6, 9 }, { 7, 13 }, { 8, 17 }, [...]

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line

Or do you think I'm missing something?

Yes :)

Let's look at the later entries:

Quoted 1 line

drivers/pinctrl/qcom/pinctrl-msm8226.c

Quoted 1 line
drivers/pinctrl/qcom/pinctrl-msm8226.c +1 -0
+	{ 21, 9 }, { 27, 10 }, { 29, 11 }, { 31, 12 }, { 33, 13 }, 

{ 35,

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

14

},

drivers/pinctrl/qcom/pinctrl-msm8226.c

Quoted 1 line
drivers/pinctrl/qcom/pinctrl-msm8226.c +1 -0
+	{ 37, 15 }, { 38, 16 }, { 39, 17 }, { 41, 18 }, { 46, 19 

}, { 48,

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

20

},

drivers/pinctrl/qcom/pinctrl-msm8226.c

Quoted 1 line
drivers/pinctrl/qcom/pinctrl-msm8226.c +1 -0
+	{ 49, 21 }, { 50, 22 }, { 51, 23 }, { 52, 24 }, { 54, 25 

}, { 62,

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

26

},

drivers/pinctrl/qcom/pinctrl-msm8226.c

Quoted 1 line
drivers/pinctrl/qcom/pinctrl-msm8226.c +1 -0
+	{ 63, 27 }, { 64, 28 }, { 65, 29 }, { 66, 30 }, { 67, 31 

}, { 68,

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

32

},

drivers/pinctrl/qcom/pinctrl-msm8226.c

Quoted 1 line
drivers/pinctrl/qcom/pinctrl-msm8226.c +1 -0
+	{ 69, 33 }, { 71, 34 }, { 72, 35 }, { 106, 36 }, { 107, 37 

},

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

drivers/pinctrl/qcom/pinctrl-msm8226.c

Quoted 1 line
drivers/pinctrl/qcom/pinctrl-msm8226.c +1 -0
+	{ 108, 38 }, { 109, 39 }, { 110, 40 }, { 111, 54 }, { 113, 

55 },

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

drivers/pinctrl/qcom/pinctrl-msm8226.c static const struct msm_pingroup msm8226_groups[] = { · line 624

Quoted 2 lines
drivers/pinctrl/qcom/pinctrl-msm8226.c +2 -0
+};
+

For example: { 113, 55 }, i.e. { .gpio = 113, .wakeirq = 55 }.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

MSM8226 has GPIOs 0-116 and 64 MPM pins/interrupts. The order in this patch is the only one that can be correct because the definition would be invalid the other way around. 113 must be the GPIO number because it is larger than the 64 available MPM interrupt pins. :)

So basically you're saying downstream is wrong / buggy?

"Misleading" or "confusing" would be the words I would use. :-)

;)

Quoted 13 lines
Quoted 9 lines

From qcom,gpio-map = [...], <55 113>; it's taking the properties like this

(drivers/soc/qcom/mpm-of.c):
unsigned long pin = be32_to_cpup(list++);
irq_hw_number_t hwirq = be32_to_cpup(list++);

Your explanation does make sense I guess but somewhere the link downstream -> mainline must be broken, no?

After staring at mpm-of.c for a while I would say that there:
- downstream "pin" = MPM pin = mainline "wakeirq"
- because this is used as index to msm_mpm_irqs_m2a, which has a size

Quoted 6 lines
     of MSM_MPM_NR_MPM_IRQS (64)

- downstream "hwirq" = GPIO / GIC IRQ = mainline "gpio"

This means for <55 113>: pin = wakeirq = 55 and hwirq = gpio = 113. Which matches the definition in this patch:
{ .gpio = 113, .wakeirq = 55 } = { 113, 55 }

Fun, thanks for digging into it!

@Matti: I think I see one missing entry here "<41 115>," on downstream, so { 115, 41 } appears to be missing in this patch? Or is there a reason you omitted that one? The rest looks correct :)

Regards
Luca

Quoted 2 lines

Stephan

#7 lore raw

PATCH 2/2 pinctrl: qcom: msm8974: Add MPM pin mappings

In reply to Matti Lehtimäki

Add pin <-> wakeirq mappings to allow for waking up the AP from sleep through MPM-connected pins.

---
 drivers/pinctrl/qcom/pinctrl-msm8x74.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/pinctrl/qcom/pinctrl-msm8x74.c +12 -0
index d5fe62992849..238c83f6ec4f 100644
@@ -1045,6 +1045,16 @@ static const struct msm_pingroup msm8x74_groups[] = {
 
 #define NUM_GPIO_PINGROUPS 146
 
+static const struct msm_gpio_wakeirq_map msm8x74_mpm_map[] = {
+	{ 1, 4 }, { 5, 5 }, { 9, 6 }, { 18, 7 }, { 20, 8 }, { 24, 9 },
+	{ 27, 10 }, { 28, 11 }, { 34, 12 }, { 35, 13 }, { 37, 14 }, { 42, 15 },
+	{ 44, 16 }, { 46, 17 }, { 50, 18 }, { 54, 19 }, { 59, 20 }, { 61, 21 },
+	{ 62, 22 }, { 64, 23 }, { 65, 24 }, { 66, 25 }, { 67, 26 }, { 68, 27 },
+	{ 71, 28 }, { 72, 29 }, { 73, 30 }, { 74, 31 }, { 75, 32 }, { 77, 33 },
+	{ 79, 34 }, { 80, 35 }, { 82, 36 }, { 86, 37 }, { 92, 38 }, { 93, 39 },
+	{ 95, 40 }, { 102, 3 }, { 144, 41 },
+};
+
 static const struct msm_pinctrl_soc_data msm8x74_pinctrl = {
 	.pins = msm8x74_pins,
 	.npins = ARRAY_SIZE(msm8x74_pins),
@@ -1053,6 +1063,8 @@ static const struct msm_pinctrl_soc_data msm8x74_pinctrl = {
 	.groups = msm8x74_groups,
 	.ngroups = ARRAY_SIZE(msm8x74_groups),
 	.ngpios = NUM_GPIO_PINGROUPS,
+	.wakeirq_map = msm8x74_mpm_map,
+	.nwakeirq_map = ARRAY_SIZE(msm8x74_mpm_map),
 };
 
 static int msm8x74_pinctrl_probe(struct platform_device *pdev)
Signature · 1 line
2.39.2
Reviewed-by on v1 2/2
#8 lore raw

Re: [PATCH 2/2] pinctrl: qcom: msm8974: Add MPM pin mappings

Quoted 4 lines · On Samstag, 23. September 2023 00:40:27 CEST Matti Lehtimäki wrote:

Add pin <-> wakeirq mappings to allow for waking up the AP from sleep through MPM-connected pins.

Based on the discussion in the 8226 patch, this looks correct, compared with downstream arch/arm/boot/dts/msm8974pro-pm.dtsi.

Quoted 10 lines
---
 drivers/pinctrl/qcom/pinctrl-msm8x74.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
(quoted diff) +0 -0

b/drivers/pinctrl/qcom/pinctrl-msm8x74.c index d5fe62992849..238c83f6ec4f 100644

drivers/pinctrl/qcom/pinctrl-msm8x74.c static const struct msm_pingroup msm8x74_groups[] = { · line 1050

Quoted 6 lines
drivers/pinctrl/qcom/pinctrl-msm8x74.c +3 -0
@@ -1045,6 +1045,16 @@ static const struct msm_pingroup msm8x74_groups[] = {
 
 #define NUM_GPIO_PINGROUPS 146
 
+static const struct msm_gpio_wakeirq_map msm8x74_mpm_map[] = {
+	{ 1, 4 }, { 5, 5 }, { 9, 6 }, { 18, 7 }, { 20, 8 }, { 24, 9 },
+	{ 27, 10 }, { 28, 11 }, { 34, 12 }, { 35, 13 }, { 37, 14 }, { 42, 15 

},

drivers/pinctrl/qcom/pinctrl-msm8x74.c static const struct msm_pingroup msm8x74_groups[] = { · line 1051

Quoted 1 line
drivers/pinctrl/qcom/pinctrl-msm8x74.c +1 -0
+	{ 44, 16 }, { 46, 17 }, { 50, 18 }, { 54, 19 }, { 59, 20 }, { 61, 21 

},

drivers/pinctrl/qcom/pinctrl-msm8x74.c static const struct msm_pingroup msm8x74_groups[] = { · line 1052

Quoted 1 line
drivers/pinctrl/qcom/pinctrl-msm8x74.c +1 -0
+	{ 62, 22 }, { 64, 23 }, { 65, 24 }, { 66, 25 }, { 67, 26 }, { 68, 27 

},

drivers/pinctrl/qcom/pinctrl-msm8x74.c static const struct msm_pingroup msm8x74_groups[] = { · line 1053

Quoted 1 line
drivers/pinctrl/qcom/pinctrl-msm8x74.c +1 -0
+	{ 71, 28 }, { 72, 29 }, { 73, 30 }, { 74, 31 }, { 75, 32 }, { 77, 33 

},

drivers/pinctrl/qcom/pinctrl-msm8x74.c static const struct msm_pingroup msm8x74_groups[] = { · line 1054

Quoted 1 line
drivers/pinctrl/qcom/pinctrl-msm8x74.c +1 -0
+	{ 79, 34 }, { 80, 35 }, { 82, 36 }, { 86, 37 }, { 92, 38 }, { 93, 39 

},

Quoted 15 lines
drivers/pinctrl/qcom/pinctrl-msm8x74.c +5 -0
+	{ 95, 40 }, { 102, 3 }, { 144, 41 },
+};
+
 static const struct msm_pinctrl_soc_data msm8x74_pinctrl = {
 	.pins = msm8x74_pins,
 	.npins = ARRAY_SIZE(msm8x74_pins),
@@ -1053,6 +1063,8 @@ static const struct msm_pinctrl_soc_data
 msm8x74_pinctrl = { .groups = msm8x74_groups,
 	.ngroups = ARRAY_SIZE(msm8x74_groups),
 	.ngpios = NUM_GPIO_PINGROUPS,
+	.wakeirq_map = msm8x74_mpm_map,
+	.nwakeirq_map = ARRAY_SIZE(msm8x74_mpm_map),
 };
 
 static int msm8x74_pinctrl_probe(struct platform_device *pdev)