Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit e9d66bd

Browse files
committed
pinctrl: renesas: r8a77995: Add bias pinconf support
Implement support for pull-up (most pins, excl. DU_DOTCLKIN0) and pull-down (most pins, excl. JTAG) handling for the R-Car D3 SoC, using some parts from the common R-Car bias handling, which requires making rcar_pin_to_bias_reg() public. R-Car D3 needs special handling for the NFRE# (GP_3_0) and NFWE# (GP_3_1) pins. Unlike all other pins, they are controlled by different bits in the LSI pin pull-up/down control register (PUD2) than in the LSI pin pull-enable register (PUEN2). Signed-off-by: Geert Uytterhoeven <[email protected]> Reviewed-by: Niklas Söderlund <[email protected]> Link: https://lore.kernel.org/r/04aad2b0bf82a32fb08e5e21e4ac1fb03452724f.1625064076.git.geert+renesas@glider.be
1 parent 7ebaa41 commit e9d66bd

File tree

3 files changed

+316
-9
lines changed

3 files changed

+316
-9
lines changed

drivers/pinctrl/renesas/pfc-r8a77995.c

Lines changed: 312 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,27 @@
1414
#include <linux/errno.h>
1515
#include <linux/kernel.h>
1616

17+
#include "core.h"
1718
#include "sh_pfc.h"
1819

19-
#define CPU_ALL_GP(fn, sfx) \
20-
PORT_GP_9(0, fn, sfx), \
21-
PORT_GP_32(1, fn, sfx), \
22-
PORT_GP_32(2, fn, sfx), \
23-
PORT_GP_CFG_10(3, fn, sfx, SH_PFC_PIN_CFG_IO_VOLTAGE), \
24-
PORT_GP_32(4, fn, sfx), \
25-
PORT_GP_21(5, fn, sfx), \
26-
PORT_GP_14(6, fn, sfx)
20+
#define CPU_ALL_GP(fn, sfx) \
21+
PORT_GP_CFG_9(0, fn, sfx, SH_PFC_PIN_CFG_PULL_UP_DOWN), \
22+
PORT_GP_CFG_32(1, fn, sfx, SH_PFC_PIN_CFG_PULL_UP_DOWN), \
23+
PORT_GP_CFG_32(2, fn, sfx, SH_PFC_PIN_CFG_PULL_UP_DOWN), \
24+
PORT_GP_CFG_10(3, fn, sfx, SH_PFC_PIN_CFG_IO_VOLTAGE | SH_PFC_PIN_CFG_PULL_UP_DOWN), \
25+
PORT_GP_CFG_32(4, fn, sfx, SH_PFC_PIN_CFG_PULL_UP_DOWN), \
26+
PORT_GP_CFG_21(5, fn, sfx, SH_PFC_PIN_CFG_PULL_UP_DOWN), \
27+
PORT_GP_CFG_14(6, fn, sfx, SH_PFC_PIN_CFG_PULL_UP_DOWN)
28+
29+
#define CPU_ALL_NOGP(fn) \
30+
PIN_NOGP_CFG(DU_DOTCLKIN0, "DU_DOTCLKIN0", fn, SH_PFC_PIN_CFG_PULL_DOWN), \
31+
PIN_NOGP_CFG(FSCLKST_N, "FSCLKST#", fn, SH_PFC_PIN_CFG_PULL_UP_DOWN), \
32+
PIN_NOGP_CFG(MLB_REF, "MLB_REF", fn, SH_PFC_PIN_CFG_PULL_UP_DOWN), \
33+
PIN_NOGP_CFG(PRESETOUT_N, "PRESETOUT#", fn, SH_PFC_PIN_CFG_PULL_UP_DOWN), \
34+
PIN_NOGP_CFG(TCK, "TCK", fn, SH_PFC_PIN_CFG_PULL_UP), \
35+
PIN_NOGP_CFG(TDI, "TDI", fn, SH_PFC_PIN_CFG_PULL_UP), \
36+
PIN_NOGP_CFG(TMS, "TMS", fn, SH_PFC_PIN_CFG_PULL_UP), \
37+
PIN_NOGP_CFG(TRST_N, "TRST#", fn, SH_PFC_PIN_CFG_PULL_UP)
2738

2839
/*
2940
* F_() : just information
@@ -930,8 +941,17 @@ static const u16 pinmux_data[] = {
930941
PINMUX_IPSR_GPSR(IP13_7_4, TPU0TO3_A),
931942
};
932943

944+
/*
945+
* Pins not associated with a GPIO port.
946+
*/
947+
enum {
948+
GP_ASSIGN_LAST(),
949+
NOGP_ALL(),
950+
};
951+
933952
static const struct sh_pfc_pin pinmux_pins[] = {
934953
PINMUX_GPIO_GP_ALL(),
954+
PINMUX_NOGP_ALL(),
935955
};
936956

937957
/* - AUDIO CLOCK ------------------------------------------------------------- */
@@ -2834,6 +2854,214 @@ static int r8a77995_pin_to_pocctrl(struct sh_pfc *pfc, unsigned int pin, u32 *po
28342854
return bit;
28352855
}
28362856

2857+
static const struct pinmux_bias_reg pinmux_bias_regs[] = {
2858+
{ PINMUX_BIAS_REG("PUEN0", 0xe6060400, "PUD0", 0xe6060440) {
2859+
[ 0] = RCAR_GP_PIN(1, 9), /* DU_DG1 */
2860+
[ 1] = RCAR_GP_PIN(1, 8), /* DU_DG0 */
2861+
[ 2] = RCAR_GP_PIN(1, 7), /* DU_DB7 */
2862+
[ 3] = RCAR_GP_PIN(1, 6), /* DU_DB6 */
2863+
[ 4] = RCAR_GP_PIN(1, 5), /* DU_DB5 */
2864+
[ 5] = RCAR_GP_PIN(1, 4), /* DU_DB4 */
2865+
[ 6] = RCAR_GP_PIN(1, 3), /* DU_DB3 */
2866+
[ 7] = RCAR_GP_PIN(1, 2), /* DU_DB2 */
2867+
[ 8] = RCAR_GP_PIN(1, 1), /* DU_DB1 */
2868+
[ 9] = RCAR_GP_PIN(1, 0), /* DU_DB0 */
2869+
[10] = PIN_MLB_REF, /* MLB_REF */
2870+
[11] = RCAR_GP_PIN(0, 8), /* MLB_SIG */
2871+
[12] = RCAR_GP_PIN(0, 7), /* MLB_DAT */
2872+
[13] = RCAR_GP_PIN(0, 6), /* MLB_CLK */
2873+
[14] = RCAR_GP_PIN(0, 5), /* MSIOF2_RXD */
2874+
[15] = RCAR_GP_PIN(0, 4), /* MSIOF2_TXD */
2875+
[16] = RCAR_GP_PIN(0, 3), /* MSIOF2_SCK */
2876+
[17] = RCAR_GP_PIN(0, 2), /* IRQ0_A */
2877+
[18] = RCAR_GP_PIN(0, 1), /* USB0_OVC */
2878+
[19] = RCAR_GP_PIN(0, 0), /* USB0_PWEN */
2879+
[20] = PIN_PRESETOUT_N, /* PRESETOUT# */
2880+
[21] = PIN_DU_DOTCLKIN0, /* DU_DOTCLKIN0 */
2881+
[22] = PIN_FSCLKST_N, /* FSCLKST# */
2882+
[23] = SH_PFC_PIN_NONE,
2883+
[24] = SH_PFC_PIN_NONE,
2884+
[25] = SH_PFC_PIN_NONE,
2885+
[26] = SH_PFC_PIN_NONE,
2886+
[27] = SH_PFC_PIN_NONE,
2887+
[28] = PIN_TDI, /* TDI */
2888+
[29] = PIN_TMS, /* TMS */
2889+
[30] = PIN_TCK, /* TCK */
2890+
[31] = PIN_TRST_N, /* TRST# */
2891+
} },
2892+
{ PINMUX_BIAS_REG("PUEN1", 0xe6060404, "PUD1", 0xe6060444) {
2893+
[ 0] = RCAR_GP_PIN(2, 9), /* VI4_DATA8 */
2894+
[ 1] = RCAR_GP_PIN(2, 8), /* VI4_DATA7 */
2895+
[ 2] = RCAR_GP_PIN(2, 7), /* VI4_DATA6 */
2896+
[ 3] = RCAR_GP_PIN(2, 6), /* VI4_DATA5 */
2897+
[ 4] = RCAR_GP_PIN(2, 5), /* VI4_DATA4 */
2898+
[ 5] = RCAR_GP_PIN(2, 4), /* VI4_DATA3 */
2899+
[ 6] = RCAR_GP_PIN(2, 3), /* VI4_DATA2 */
2900+
[ 7] = RCAR_GP_PIN(2, 2), /* VI4_DATA1 */
2901+
[ 8] = RCAR_GP_PIN(2, 1), /* VI4_DATA0 */
2902+
[ 9] = RCAR_GP_PIN(2, 0), /* VI4_CLK */
2903+
[10] = RCAR_GP_PIN(1, 31), /* QPOLB */
2904+
[11] = RCAR_GP_PIN(1, 30), /* QPOLA */
2905+
[12] = RCAR_GP_PIN(1, 29), /* DU_CDE */
2906+
[13] = RCAR_GP_PIN(1, 28), /* DU_DISP/CDE */
2907+
[14] = RCAR_GP_PIN(1, 27), /* DU_DISP */
2908+
[15] = RCAR_GP_PIN(1, 26), /* DU_VSYNC */
2909+
[16] = RCAR_GP_PIN(1, 25), /* DU_HSYNC */
2910+
[17] = RCAR_GP_PIN(1, 24), /* DU_DOTCLKOUT0 */
2911+
[18] = RCAR_GP_PIN(1, 23), /* DU_DR7 */
2912+
[19] = RCAR_GP_PIN(1, 22), /* DU_DR6 */
2913+
[20] = RCAR_GP_PIN(1, 21), /* DU_DR5 */
2914+
[21] = RCAR_GP_PIN(1, 20), /* DU_DR4 */
2915+
[22] = RCAR_GP_PIN(1, 19), /* DU_DR3 */
2916+
[23] = RCAR_GP_PIN(1, 18), /* DU_DR2 */
2917+
[24] = RCAR_GP_PIN(1, 17), /* DU_DR1 */
2918+
[25] = RCAR_GP_PIN(1, 16), /* DU_DR0 */
2919+
[26] = RCAR_GP_PIN(1, 15), /* DU_DG7 */
2920+
[27] = RCAR_GP_PIN(1, 14), /* DU_DG6 */
2921+
[28] = RCAR_GP_PIN(1, 13), /* DU_DG5 */
2922+
[29] = RCAR_GP_PIN(1, 12), /* DU_DG4 */
2923+
[30] = RCAR_GP_PIN(1, 11), /* DU_DG3 */
2924+
[31] = RCAR_GP_PIN(1, 10), /* DU_DG2 */
2925+
} },
2926+
{ PINMUX_BIAS_REG("PUEN2", 0xe6060408, "PUD2", 0xe6060448) {
2927+
[ 0] = RCAR_GP_PIN(3, 8), /* NFDATA6 */
2928+
[ 1] = RCAR_GP_PIN(3, 7), /* NFDATA5 */
2929+
[ 2] = RCAR_GP_PIN(3, 6), /* NFDATA4 */
2930+
[ 3] = RCAR_GP_PIN(3, 5), /* NFDATA3 */
2931+
[ 4] = RCAR_GP_PIN(3, 4), /* NFDATA2 */
2932+
[ 5] = RCAR_GP_PIN(3, 3), /* NFDATA1 */
2933+
[ 6] = RCAR_GP_PIN(3, 2), /* NFDATA0 */
2934+
[ 7] = RCAR_GP_PIN(3, 1), /* NFWE# (PUEN) / NFRE# (PUD) */
2935+
[ 8] = RCAR_GP_PIN(3, 0), /* NFRE# (PUEN) / NFWE# (PUD) */
2936+
[ 9] = RCAR_GP_PIN(4, 0), /* NFRB# */
2937+
[10] = RCAR_GP_PIN(2, 31), /* NFCE# */
2938+
[11] = RCAR_GP_PIN(2, 30), /* NFCLE */
2939+
[12] = RCAR_GP_PIN(2, 29), /* NFALE */
2940+
[13] = RCAR_GP_PIN(2, 28), /* VI4_CLKENB */
2941+
[14] = RCAR_GP_PIN(2, 27), /* VI4_FIELD */
2942+
[15] = RCAR_GP_PIN(2, 26), /* VI4_HSYNC# */
2943+
[16] = RCAR_GP_PIN(2, 25), /* VI4_VSYNC# */
2944+
[17] = RCAR_GP_PIN(2, 24), /* VI4_DATA23 */
2945+
[18] = RCAR_GP_PIN(2, 23), /* VI4_DATA22 */
2946+
[19] = RCAR_GP_PIN(2, 22), /* VI4_DATA21 */
2947+
[20] = RCAR_GP_PIN(2, 21), /* VI4_DATA20 */
2948+
[21] = RCAR_GP_PIN(2, 20), /* VI4_DATA19 */
2949+
[22] = RCAR_GP_PIN(2, 19), /* VI4_DATA18 */
2950+
[23] = RCAR_GP_PIN(2, 18), /* VI4_DATA17 */
2951+
[24] = RCAR_GP_PIN(2, 17), /* VI4_DATA16 */
2952+
[25] = RCAR_GP_PIN(2, 16), /* VI4_DATA15 */
2953+
[26] = RCAR_GP_PIN(2, 15), /* VI4_DATA14 */
2954+
[27] = RCAR_GP_PIN(2, 14), /* VI4_DATA13 */
2955+
[28] = RCAR_GP_PIN(2, 13), /* VI4_DATA12 */
2956+
[29] = RCAR_GP_PIN(2, 12), /* VI4_DATA11 */
2957+
[30] = RCAR_GP_PIN(2, 11), /* VI4_DATA10 */
2958+
[31] = RCAR_GP_PIN(2, 10), /* VI4_DATA9 */
2959+
} },
2960+
{ PINMUX_BIAS_REG("PUEN3", 0xe606040c, "PUD3", 0xe606044c) {
2961+
[ 0] = RCAR_GP_PIN(4, 31), /* CAN0_RX_A */
2962+
[ 1] = RCAR_GP_PIN(5, 2), /* CAN_CLK */
2963+
[ 2] = RCAR_GP_PIN(5, 1), /* TPU0TO1_A */
2964+
[ 3] = RCAR_GP_PIN(5, 0), /* TPU0TO0_A */
2965+
[ 4] = RCAR_GP_PIN(4, 27), /* TX2 */
2966+
[ 5] = RCAR_GP_PIN(4, 26), /* RX2 */
2967+
[ 6] = RCAR_GP_PIN(4, 25), /* SCK2 */
2968+
[ 7] = RCAR_GP_PIN(4, 24), /* TX1_A */
2969+
[ 8] = RCAR_GP_PIN(4, 23), /* RX1_A */
2970+
[ 9] = RCAR_GP_PIN(4, 22), /* SCK1_A */
2971+
[10] = RCAR_GP_PIN(4, 21), /* TX0_A */
2972+
[11] = RCAR_GP_PIN(4, 20), /* RX0_A */
2973+
[12] = RCAR_GP_PIN(4, 19), /* SCK0_A */
2974+
[13] = RCAR_GP_PIN(4, 18), /* MSIOF1_RXD */
2975+
[14] = RCAR_GP_PIN(4, 17), /* MSIOF1_TXD */
2976+
[15] = RCAR_GP_PIN(4, 16), /* MSIOF1_SCK */
2977+
[16] = RCAR_GP_PIN(4, 15), /* MSIOF0_RXD */
2978+
[17] = RCAR_GP_PIN(4, 14), /* MSIOF0_TXD */
2979+
[18] = RCAR_GP_PIN(4, 13), /* MSIOF0_SYNC */
2980+
[19] = RCAR_GP_PIN(4, 12), /* MSIOF0_SCK */
2981+
[20] = RCAR_GP_PIN(4, 11), /* SDA1 */
2982+
[21] = RCAR_GP_PIN(4, 10), /* SCL1 */
2983+
[22] = RCAR_GP_PIN(4, 9), /* SDA0 */
2984+
[23] = RCAR_GP_PIN(4, 8), /* SCL0 */
2985+
[24] = RCAR_GP_PIN(4, 7), /* SSI_WS4_A */
2986+
[25] = RCAR_GP_PIN(4, 6), /* SSI_SDATA4_A */
2987+
[26] = RCAR_GP_PIN(4, 5), /* SSI_SCK4_A */
2988+
[27] = RCAR_GP_PIN(4, 4), /* SSI_WS34 */
2989+
[28] = RCAR_GP_PIN(4, 3), /* SSI_SDATA3 */
2990+
[29] = RCAR_GP_PIN(4, 2), /* SSI_SCK34 */
2991+
[30] = RCAR_GP_PIN(4, 1), /* AUDIO_CLKA */
2992+
[31] = RCAR_GP_PIN(3, 9), /* NFDATA7 */
2993+
} },
2994+
{ PINMUX_BIAS_REG("PUEN4", 0xe6060410, "PUD4", 0xe6060450) {
2995+
[ 0] = RCAR_GP_PIN(6, 10), /* QSPI1_IO3 */
2996+
[ 1] = RCAR_GP_PIN(6, 9), /* QSPI1_IO2 */
2997+
[ 2] = RCAR_GP_PIN(6, 8), /* QSPI1_MISO_IO1 */
2998+
[ 3] = RCAR_GP_PIN(6, 7), /* QSPI1_MOSI_IO0 */
2999+
[ 4] = RCAR_GP_PIN(6, 6), /* QSPI1_SPCLK */
3000+
[ 5] = RCAR_GP_PIN(6, 5), /* QSPI0_SSL */
3001+
[ 6] = RCAR_GP_PIN(6, 4), /* QSPI0_IO3 */
3002+
[ 7] = RCAR_GP_PIN(6, 3), /* QSPI0_IO2 */
3003+
[ 8] = RCAR_GP_PIN(6, 2), /* QSPI0_MISO_IO1 */
3004+
[ 9] = RCAR_GP_PIN(6, 1), /* QSPI0_MOSI_IO0 */
3005+
[10] = RCAR_GP_PIN(6, 0), /* QSPI0_SPCLK */
3006+
[11] = RCAR_GP_PIN(5, 20), /* AVB0_LINK */
3007+
[12] = RCAR_GP_PIN(5, 19), /* AVB0_PHY_INT */
3008+
[13] = RCAR_GP_PIN(5, 18), /* AVB0_MAGIC */
3009+
[14] = RCAR_GP_PIN(5, 17), /* AVB0_MDC */
3010+
[15] = RCAR_GP_PIN(5, 16), /* AVB0_MDIO */
3011+
[16] = RCAR_GP_PIN(5, 15), /* AVB0_TXCREFCLK */
3012+
[17] = RCAR_GP_PIN(5, 14), /* AVB0_TD3 */
3013+
[18] = RCAR_GP_PIN(5, 13), /* AVB0_TD2 */
3014+
[19] = RCAR_GP_PIN(5, 12), /* AVB0_TD1 */
3015+
[20] = RCAR_GP_PIN(5, 11), /* AVB0_TD0 */
3016+
[21] = RCAR_GP_PIN(5, 10), /* AVB0_TXC */
3017+
[22] = RCAR_GP_PIN(5, 9), /* AVB0_TX_CTL */
3018+
[23] = RCAR_GP_PIN(5, 8), /* AVB0_RD3 */
3019+
[24] = RCAR_GP_PIN(5, 7), /* AVB0_RD2 */
3020+
[25] = RCAR_GP_PIN(5, 6), /* AVB0_RD1 */
3021+
[26] = RCAR_GP_PIN(5, 5), /* AVB0_RD0 */
3022+
[27] = RCAR_GP_PIN(5, 4), /* AVB0_RXC */
3023+
[28] = RCAR_GP_PIN(5, 3), /* AVB0_RX_CTL */
3024+
[29] = RCAR_GP_PIN(4, 30), /* CAN1_TX_A */
3025+
[30] = RCAR_GP_PIN(4, 29), /* CAN1_RX_A */
3026+
[31] = RCAR_GP_PIN(4, 28), /* CAN0_TX_A */
3027+
} },
3028+
{ PINMUX_BIAS_REG("PUEN5", 0xe6060414, "PUD4", 0xe6060454) {
3029+
[ 0] = SH_PFC_PIN_NONE,
3030+
[ 1] = SH_PFC_PIN_NONE,
3031+
[ 2] = SH_PFC_PIN_NONE,
3032+
[ 3] = SH_PFC_PIN_NONE,
3033+
[ 4] = SH_PFC_PIN_NONE,
3034+
[ 5] = SH_PFC_PIN_NONE,
3035+
[ 6] = SH_PFC_PIN_NONE,
3036+
[ 7] = SH_PFC_PIN_NONE,
3037+
[ 8] = SH_PFC_PIN_NONE,
3038+
[ 9] = SH_PFC_PIN_NONE,
3039+
[10] = SH_PFC_PIN_NONE,
3040+
[11] = SH_PFC_PIN_NONE,
3041+
[12] = SH_PFC_PIN_NONE,
3042+
[13] = SH_PFC_PIN_NONE,
3043+
[14] = SH_PFC_PIN_NONE,
3044+
[15] = SH_PFC_PIN_NONE,
3045+
[16] = SH_PFC_PIN_NONE,
3046+
[17] = SH_PFC_PIN_NONE,
3047+
[18] = SH_PFC_PIN_NONE,
3048+
[19] = SH_PFC_PIN_NONE,
3049+
[20] = SH_PFC_PIN_NONE,
3050+
[21] = SH_PFC_PIN_NONE,
3051+
[22] = SH_PFC_PIN_NONE,
3052+
[23] = SH_PFC_PIN_NONE,
3053+
[24] = SH_PFC_PIN_NONE,
3054+
[25] = SH_PFC_PIN_NONE,
3055+
[26] = SH_PFC_PIN_NONE,
3056+
[27] = SH_PFC_PIN_NONE,
3057+
[28] = SH_PFC_PIN_NONE,
3058+
[29] = RCAR_GP_PIN(6, 13), /* RPC_INT# */
3059+
[30] = RCAR_GP_PIN(6, 12), /* RPC_RESET# */
3060+
[31] = RCAR_GP_PIN(6, 11), /* QSPI1_SSL */
3061+
} },
3062+
{ /* sentinel */ }
3063+
};
3064+
28373065
enum ioctrl_regs {
28383066
TDSELCTRL,
28393067
};
@@ -2843,8 +3071,83 @@ static const struct pinmux_ioctrl_reg pinmux_ioctrl_regs[] = {
28433071
{ /* sentinel */ },
28443072
};
28453073

3074+
static const struct pinmux_bias_reg *
3075+
r8a77995_pin_to_bias_reg(const struct sh_pfc *pfc, unsigned int pin,
3076+
unsigned int *puen_bit, unsigned int *pud_bit)
3077+
{
3078+
const struct pinmux_bias_reg *reg;
3079+
unsigned int bit;
3080+
3081+
reg = rcar_pin_to_bias_reg(pfc, pin, &bit);
3082+
if (!reg)
3083+
return reg;
3084+
3085+
*puen_bit = bit;
3086+
3087+
/* NFWE# and NFRE# use different bit positions in PUD2 */
3088+
switch (pin) {
3089+
case RCAR_GP_PIN(3, 0): /* NFRE# */
3090+
*pud_bit = 7;
3091+
break;
3092+
3093+
case RCAR_GP_PIN(3, 1): /* NFWE# */
3094+
*pud_bit = 8;
3095+
break;
3096+
3097+
default:
3098+
*pud_bit = bit;
3099+
break;
3100+
}
3101+
3102+
return reg;
3103+
}
3104+
3105+
static unsigned int r8a77995_pinmux_get_bias(struct sh_pfc *pfc,
3106+
unsigned int pin)
3107+
{
3108+
const struct pinmux_bias_reg *reg;
3109+
unsigned int puen_bit, pud_bit;
3110+
3111+
reg = r8a77995_pin_to_bias_reg(pfc, pin, &puen_bit, &pud_bit);
3112+
if (!reg)
3113+
return PIN_CONFIG_BIAS_DISABLE;
3114+
3115+
if (!(sh_pfc_read(pfc, reg->puen) & BIT(puen_bit)))
3116+
return PIN_CONFIG_BIAS_DISABLE;
3117+
else if (sh_pfc_read(pfc, reg->pud) & BIT(pud_bit))
3118+
return PIN_CONFIG_BIAS_PULL_UP;
3119+
else
3120+
return PIN_CONFIG_BIAS_PULL_DOWN;
3121+
}
3122+
3123+
static void r8a77995_pinmux_set_bias(struct sh_pfc *pfc, unsigned int pin,
3124+
unsigned int bias)
3125+
{
3126+
const struct pinmux_bias_reg *reg;
3127+
unsigned int puen_bit, pud_bit;
3128+
u32 enable, updown;
3129+
3130+
reg = r8a77995_pin_to_bias_reg(pfc, pin, &puen_bit, &pud_bit);
3131+
if (!reg)
3132+
return;
3133+
3134+
enable = sh_pfc_read(pfc, reg->puen) & ~BIT(puen_bit);
3135+
if (bias != PIN_CONFIG_BIAS_DISABLE) {
3136+
enable |= BIT(puen_bit);
3137+
3138+
updown = sh_pfc_read(pfc, reg->pud) & ~BIT(pud_bit);
3139+
if (bias == PIN_CONFIG_BIAS_PULL_UP)
3140+
updown |= BIT(pud_bit);
3141+
3142+
sh_pfc_write(pfc, reg->pud, updown);
3143+
}
3144+
sh_pfc_write(pfc, reg->puen, enable);
3145+
}
3146+
28463147
static const struct sh_pfc_soc_operations r8a77995_pinmux_ops = {
28473148
.pin_to_pocctrl = r8a77995_pin_to_pocctrl,
3149+
.get_bias = r8a77995_pinmux_get_bias,
3150+
.set_bias = r8a77995_pinmux_set_bias,
28483151
};
28493152

28503153
const struct sh_pfc_soc_info r8a77995_pinmux_info = {
@@ -2862,6 +3165,7 @@ const struct sh_pfc_soc_info r8a77995_pinmux_info = {
28623165
.nr_functions = ARRAY_SIZE(pinmux_functions),
28633166

28643167
.cfg_regs = pinmux_config_regs,
3168+
.bias_regs = pinmux_bias_regs,
28653169
.ioctrl_regs = pinmux_ioctrl_regs,
28663170

28673171
.pinmux_data = pinmux_data,

drivers/pinctrl/renesas/pinctrl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ int sh_pfc_register_pinctrl(struct sh_pfc *pfc)
841841
return pinctrl_enable(pmx->pctl);
842842
}
843843

844-
static const struct pinmux_bias_reg *
844+
const struct pinmux_bias_reg *
845845
rcar_pin_to_bias_reg(const struct sh_pfc *pfc, unsigned int pin,
846846
unsigned int *bit)
847847
{

drivers/pinctrl/renesas/sh_pfc.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,9 @@ extern const struct sh_pfc_soc_info shx3_pinmux_info;
781781
/*
782782
* Bias helpers
783783
*/
784+
const struct pinmux_bias_reg *
785+
rcar_pin_to_bias_reg(const struct sh_pfc *pfc, unsigned int pin,
786+
unsigned int *bit);
784787
unsigned int rcar_pinmux_get_bias(struct sh_pfc *pfc, unsigned int pin);
785788
void rcar_pinmux_set_bias(struct sh_pfc *pfc, unsigned int pin,
786789
unsigned int bias);

0 commit comments

Comments
 (0)