pinctrl: renesas: Factor out .pin_to_portcr() address handling
authorGeert Uytterhoeven <geert+renesas@glider.be>
Thu, 23 Dec 2021 14:56:18 +0000 (15:56 +0100)
committerGeert Uytterhoeven <geert+renesas@glider.be>
Tue, 22 Feb 2022 08:57:18 +0000 (09:57 +0100)
All implementations of the .pin_to_portcr() method implement the same
conversion from Port Control Register offset to virtual address.  Factor
it out into the two callers.
Remove the pfc parameter, as it is no longer used.

Note that the failure handling in r8a7740_pin_to_portcr() is pro forma,
as the function is never called with an invalid pin number.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/a485d4986a17259256988eb14e3a4c2b8d61c303.1640270559.git.geert+renesas@glider.be
drivers/pinctrl/renesas/pfc-r8a73a4.c
drivers/pinctrl/renesas/pfc-r8a7740.c
drivers/pinctrl/renesas/pfc-sh73a0.c
drivers/pinctrl/renesas/pinctrl.c
drivers/pinctrl/renesas/sh_pfc.h

index 1e569f6a03bf13e0d1f30608a27b68cdf47136b4..ba3a1857f80a08c4a36b540264d3c81adf765c11 100644 (file)
@@ -2606,9 +2606,9 @@ static const unsigned int r8a73a4_portcr_offsets[] = {
        0x00002000, 0x00003000, 0x00003000,
 };
 
-static void __iomem *r8a73a4_pin_to_portcr(struct sh_pfc *pfc, unsigned int pin)
+static int r8a73a4_pin_to_portcr(unsigned int pin)
 {
-       return pfc->windows->virt + r8a73a4_portcr_offsets[pin >> 5] + pin;
+       return r8a73a4_portcr_offsets[pin >> 5] + pin;
 }
 
 static const struct sh_pfc_soc_operations r8a73a4_pfc_ops = {
index 3214331ba4e243cbb53b7cce043417664f80fac8..e8b9fb74a802ac035bc26151b408ba632292ac10 100644 (file)
@@ -3495,7 +3495,7 @@ static const struct r8a7740_portcr_group r8a7740_portcr_offsets[] = {
        { 83, 0x0000 }, { 114, 0x1000 }, { 209, 0x2000 }, { 211, 0x3000 },
 };
 
-static void __iomem *r8a7740_pin_to_portcr(struct sh_pfc *pfc, unsigned int pin)
+static int r8a7740_pin_to_portcr(unsigned int pin)
 {
        unsigned int i;
 
@@ -3504,10 +3504,10 @@ static void __iomem *r8a7740_pin_to_portcr(struct sh_pfc *pfc, unsigned int pin)
                        &r8a7740_portcr_offsets[i];
 
                if (pin <= group->end_pin)
-                       return pfc->windows->virt + group->offset + pin;
+                       return group->offset + pin;
        }
 
-       return NULL;
+       return -1;
 }
 
 static const struct sh_pfc_soc_operations r8a7740_pfc_ops = {
index 44cf1adaff13b02ce6a94266cd217b3eb54c8553..5d8a0179fd60fee4762a48b757779414bd179c35 100644 (file)
@@ -4137,9 +4137,9 @@ static const unsigned int sh73a0_portcr_offsets[] = {
        0x00002000, 0x00002000, 0x00003000, 0x00003000, 0x00002000,
 };
 
-static void __iomem *sh73a0_pin_to_portcr(struct sh_pfc *pfc, unsigned int pin)
+static int sh73a0_pin_to_portcr(unsigned int pin)
 {
-       return pfc->windows->virt + sh73a0_portcr_offsets[pin >> 5] + pin;
+       return sh73a0_portcr_offsets[pin >> 5] + pin;
 }
 
 /* -----------------------------------------------------------------------------
index 0bdfc1ab3608829a26f8728428748353e8412836..3e4a67c67591b6c9f7e44ed4f79f51b1fd59cb3c 100644 (file)
@@ -919,7 +919,8 @@ void rcar_pinmux_set_bias(struct sh_pfc *pfc, unsigned int pin,
 
 unsigned int rmobile_pinmux_get_bias(struct sh_pfc *pfc, unsigned int pin)
 {
-       void __iomem *reg = pfc->info->ops->pin_to_portcr(pfc, pin);
+       void __iomem *reg = pfc->windows->virt +
+                           pfc->info->ops->pin_to_portcr(pin);
        u32 value = ioread8(reg) & PORTnCR_PULMD_MASK;
 
        switch (value) {
@@ -936,7 +937,8 @@ unsigned int rmobile_pinmux_get_bias(struct sh_pfc *pfc, unsigned int pin)
 void rmobile_pinmux_set_bias(struct sh_pfc *pfc, unsigned int pin,
                             unsigned int bias)
 {
-       void __iomem *reg = pfc->info->ops->pin_to_portcr(pfc, pin);
+       void __iomem *reg = pfc->windows->virt +
+                           pfc->info->ops->pin_to_portcr(pin);
        u32 value = ioread8(reg) & ~PORTnCR_PULMD_MASK;
 
        switch (bias) {
index d8a6bd0412e496d312a71e24387d97a2840b8944..7191c1c9ca9599547aaf823e3a5b8ee1c6e6acf2 100644 (file)
@@ -255,7 +255,7 @@ struct sh_pfc_soc_operations {
        void (*set_bias)(struct sh_pfc *pfc, unsigned int pin,
                         unsigned int bias);
        int (*pin_to_pocctrl)(unsigned int pin, u32 *pocctrl);
-       void __iomem * (*pin_to_portcr)(struct sh_pfc *pfc, unsigned int pin);
+       int (*pin_to_portcr)(unsigned int pin);
 };
 
 struct sh_pfc_soc_info {