Skip to content

Commit 8081a03

Browse files
prabhakarladgeertu
authored andcommitted
pinctrl: renesas: rzg2l: Allow more bits for pin configuration
The pin configuration bits have been growing for every new SoCs being added for the pinctrl-rzg2l driver which would mean updating the macros every time for each new configuration. To avoid this allocate additional bits for pin configuration by relocating the known fixed bits to the very end of the configuration. Also update the size of 'cfg' to 'u64' to allow more configuration bits in the 'struct rzg2l_variable_pin_cfg'. Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Tested-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> # on RZ/G3S Link: https://lore.kernel.org/r/20240530173857.164073-4-prabhakar.mahadev-lad.rj@bp.renesas.com Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
1 parent f07a320 commit 8081a03

1 file changed

Lines changed: 17 additions & 13 deletions

File tree

drivers/pinctrl/renesas/pinctrl-rzg2l.c

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@
7878
PIN_CFG_FILNUM | \
7979
PIN_CFG_FILCLKSEL)
8080

81-
#define PIN_CFG_PIN_MAP_MASK GENMASK_ULL(35, 28)
82-
#define PIN_CFG_PIN_REG_MASK GENMASK(27, 20)
83-
#define PIN_CFG_MASK GENMASK(19, 0)
81+
#define PIN_CFG_PIN_MAP_MASK GENMASK_ULL(62, 55)
82+
#define PIN_CFG_PIN_REG_MASK GENMASK_ULL(54, 47)
83+
#define PIN_CFG_MASK GENMASK_ULL(46, 0)
8484

8585
/*
8686
* m indicates the bitmap of supported pins, a is the register index
@@ -102,8 +102,8 @@
102102
* (b * 8) and f is the pin configuration capabilities supported.
103103
*/
104104
#define RZG2L_SINGLE_PIN BIT_ULL(63)
105-
#define RZG2L_SINGLE_PIN_INDEX_MASK GENMASK(30, 24)
106-
#define RZG2L_SINGLE_PIN_BITS_MASK GENMASK(22, 20)
105+
#define RZG2L_SINGLE_PIN_INDEX_MASK GENMASK_ULL(62, 56)
106+
#define RZG2L_SINGLE_PIN_BITS_MASK GENMASK_ULL(55, 53)
107107

108108
#define RZG2L_SINGLE_PIN_PACK(p, b, f) (RZG2L_SINGLE_PIN | \
109109
FIELD_PREP_CONST(RZG2L_SINGLE_PIN_INDEX_MASK, (p)) | \
@@ -241,9 +241,9 @@ struct rzg2l_dedicated_configs {
241241
* @pin: port pin
242242
*/
243243
struct rzg2l_variable_pin_cfg {
244-
u32 cfg:20;
245-
u32 port:5;
246-
u32 pin:3;
244+
u64 cfg:47;
245+
u64 port:5;
246+
u64 pin:3;
247247
};
248248

249249
struct rzg2l_pinctrl_data {
@@ -1081,7 +1081,8 @@ static int rzg2l_pinctrl_pinconf_get(struct pinctrl_dev *pctldev,
10811081
const struct pinctrl_pin_desc *pin = &pctrl->desc.pins[_pin];
10821082
u64 *pin_data = pin->drv_data;
10831083
unsigned int arg = 0;
1084-
u32 off, cfg;
1084+
u32 off;
1085+
u64 cfg;
10851086
int ret;
10861087
u8 bit;
10871088

@@ -1185,7 +1186,8 @@ static int rzg2l_pinctrl_pinconf_set(struct pinctrl_dev *pctldev,
11851186
u64 *pin_data = pin->drv_data;
11861187
enum pin_config_param param;
11871188
unsigned int i, arg, index;
1188-
u32 cfg, off;
1189+
u32 off;
1190+
u64 cfg;
11891191
int ret;
11901192
u8 bit;
11911193

@@ -2413,9 +2415,9 @@ static void rzg2l_pinctrl_pm_setup_regs(struct rzg2l_pinctrl *pctrl, bool suspen
24132415

24142416
for (u32 port = 0; port < nports; port++) {
24152417
bool has_iolh, has_ien;
2416-
u32 off, caps;
2418+
u64 cfg, caps;
24172419
u8 pincnt;
2418-
u64 cfg;
2420+
u32 off;
24192421

24202422
cfg = pctrl->data->port_pin_configs[port];
24212423
off = RZG2L_PIN_CFG_TO_PORT_OFFSET(cfg);
@@ -2459,12 +2461,14 @@ static void rzg2l_pinctrl_pm_setup_regs(struct rzg2l_pinctrl *pctrl, bool suspen
24592461
static void rzg2l_pinctrl_pm_setup_dedicated_regs(struct rzg2l_pinctrl *pctrl, bool suspend)
24602462
{
24612463
struct rzg2l_pinctrl_reg_cache *cache = pctrl->dedicated_cache;
2464+
u64 caps;
2465+
u32 i;
24622466

24632467
/*
24642468
* Make sure entries in pctrl->data->n_dedicated_pins[] having the same
24652469
* port offset are close together.
24662470
*/
2467-
for (u32 i = 0, caps = 0; i < pctrl->data->n_dedicated_pins; i++) {
2471+
for (i = 0, caps = 0; i < pctrl->data->n_dedicated_pins; i++) {
24682472
bool has_iolh, has_ien;
24692473
u32 off, next_off = 0;
24702474
u64 cfg, next_cfg;

0 commit comments

Comments
 (0)