Skip to content

Commit 18d676a

Browse files
setotauLinus Walleij
authored andcommitted
pinctrl: qcom: lpass-lpi: Add ability to use custom pin offsets
By default pin_offset is calculated by formula: LPI_TLMM_REG_OFFSET * pin_id. However not all platforms are using this pin_offset formula (e.g. SDM660 LPASS LPI uses a predefined array of offsets [1]), so extend lpi_pingroup struct with pin_offset field, introduce extended LPI_PINGROUP_OFFSET macro with pin_offet field and introduce LPI_FLAG_USE_PREDEFINED_PIN_OFFSET flag. This adds an ability to use predefined offset for pin if it exists. [1] https://git.codelinaro.org/clo/la/kernel/msm-4.4/-/blob/LA.UM.7.2.c27-07400-sdm660.0/drivers/pinctrl/qcom/pinctrl-lpi.c#L107 Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> Signed-off-by: Nickolay Goppen <setotau@mainlining.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 87ebcd8 commit 18d676a

2 files changed

Lines changed: 34 additions & 2 deletions

File tree

drivers/pinctrl/qcom/pinctrl-lpass-lpi.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,27 @@ struct lpi_pinctrl {
4141
static int lpi_gpio_read(struct lpi_pinctrl *state, unsigned int pin,
4242
unsigned int addr)
4343
{
44-
return ioread32(state->tlmm_base + LPI_TLMM_REG_OFFSET * pin + addr);
44+
u32 pin_offset;
45+
46+
if (state->data->flags & LPI_FLAG_USE_PREDEFINED_PIN_OFFSET)
47+
pin_offset = state->data->groups[pin].pin_offset;
48+
else
49+
pin_offset = LPI_TLMM_REG_OFFSET * pin;
50+
51+
return ioread32(state->tlmm_base + pin_offset + addr);
4552
}
4653

4754
static int lpi_gpio_write(struct lpi_pinctrl *state, unsigned int pin,
4855
unsigned int addr, unsigned int val)
4956
{
50-
iowrite32(val, state->tlmm_base + LPI_TLMM_REG_OFFSET * pin + addr);
57+
u32 pin_offset;
58+
59+
if (state->data->flags & LPI_FLAG_USE_PREDEFINED_PIN_OFFSET)
60+
pin_offset = state->data->groups[pin].pin_offset;
61+
else
62+
pin_offset = LPI_TLMM_REG_OFFSET * pin;
63+
64+
iowrite32(val, state->tlmm_base + pin_offset + addr);
5165

5266
return 0;
5367
}

drivers/pinctrl/qcom/pinctrl-lpass-lpi.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,38 @@ struct pinctrl_pin_desc;
5555
LPI_MUX_##f4, \
5656
}, \
5757
.nfuncs = 5, \
58+
.pin_offset = 0, \
59+
}
60+
61+
#define LPI_PINGROUP_OFFSET(id, soff, f1, f2, f3, f4, poff) \
62+
{ \
63+
.pin = id, \
64+
.slew_offset = soff, \
65+
.funcs = (int[]){ \
66+
LPI_MUX_gpio, \
67+
LPI_MUX_##f1, \
68+
LPI_MUX_##f2, \
69+
LPI_MUX_##f3, \
70+
LPI_MUX_##f4, \
71+
}, \
72+
.nfuncs = 5, \
73+
.pin_offset = poff, \
5874
}
5975

6076
/*
6177
* Slew rate control is done in the same register as rest of the
6278
* pin configuration.
6379
*/
6480
#define LPI_FLAG_SLEW_RATE_SAME_REG BIT(0)
81+
#define LPI_FLAG_USE_PREDEFINED_PIN_OFFSET BIT(1)
6582

6683
struct lpi_pingroup {
6784
unsigned int pin;
6885
/* Bit offset in slew register for SoundWire pins only */
6986
int slew_offset;
7087
unsigned int *funcs;
7188
unsigned int nfuncs;
89+
unsigned int pin_offset;
7290
};
7391

7492
struct lpi_function {

0 commit comments

Comments
 (0)