Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Nickolay Goppen and committed by
Linus Walleij
18d676ac 87ebcd8b

+34 -2
+16 -2
drivers/pinctrl/qcom/pinctrl-lpass-lpi.c
··· 41 41 static int lpi_gpio_read(struct lpi_pinctrl *state, unsigned int pin, 42 42 unsigned int addr) 43 43 { 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); 45 52 } 46 53 47 54 static int lpi_gpio_write(struct lpi_pinctrl *state, unsigned int pin, 48 55 unsigned int addr, unsigned int val) 49 56 { 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); 51 65 52 66 return 0; 53 67 }
+18
drivers/pinctrl/qcom/pinctrl-lpass-lpi.h
··· 55 55 LPI_MUX_##f4, \ 56 56 }, \ 57 57 .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, \ 58 74 } 59 75 60 76 /* ··· 78 62 * pin configuration. 79 63 */ 80 64 #define LPI_FLAG_SLEW_RATE_SAME_REG BIT(0) 65 + #define LPI_FLAG_USE_PREDEFINED_PIN_OFFSET BIT(1) 81 66 82 67 struct lpi_pingroup { 83 68 unsigned int pin; ··· 86 69 int slew_offset; 87 70 unsigned int *funcs; 88 71 unsigned int nfuncs; 72 + unsigned int pin_offset; 89 73 }; 90 74 91 75 struct lpi_function {