Skip to content

Commit c581f8c

Browse files
committed
Merge tag 'pinctrl-v6.14-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl
Pull pin control fixes from Linus Walleij: - A series of IRQ and behaviour stabilization fixes for the CY8C95x0 pin control expander - A print format fix for the generic debugfs output * tag 'pinctrl-v6.14-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl: pinctrl: pinconf-generic: Print unsigned value if a format is registered pinctrl: cy8c95x0: Respect IRQ trigger settings from firmware pinctrl: cy8c95x0: Rename PWMSEL to SELPWM pinctrl: cy8c95x0: Enable regmap locking for debug pinctrl: cy8c95x0: Avoid accessing reserved registers pinctrl: cy8c95x0: Fix off-by-one in the regmap range settings
2 parents a64dcfb + 0af4c12 commit c581f8c

File tree

2 files changed

+29
-21
lines changed

2 files changed

+29
-21
lines changed

drivers/pinctrl/pinconf-generic.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ static void pinconf_generic_dump_one(struct pinctrl_dev *pctldev,
8989
seq_puts(s, items[i].display);
9090
/* Print unit if available */
9191
if (items[i].has_arg) {
92-
seq_printf(s, " (0x%x",
93-
pinconf_to_config_argument(config));
92+
u32 val = pinconf_to_config_argument(config);
93+
9494
if (items[i].format)
95-
seq_printf(s, " %s)", items[i].format);
95+
seq_printf(s, " (%u %s)", val, items[i].format);
9696
else
97-
seq_puts(s, ")");
97+
seq_printf(s, " (0x%x)", val);
9898
}
9999
}
100100
}

drivers/pinctrl/pinctrl-cy8c95x0.c

+25-17
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
#define CY8C95X0_PORTSEL 0x18
4343
/* Port settings, write PORTSEL first */
4444
#define CY8C95X0_INTMASK 0x19
45-
#define CY8C95X0_PWMSEL 0x1A
45+
#define CY8C95X0_SELPWM 0x1A
4646
#define CY8C95X0_INVERT 0x1B
4747
#define CY8C95X0_DIRECTION 0x1C
4848
/* Drive mode register change state on writing '1' */
@@ -328,14 +328,14 @@ static int cypress_get_pin_mask(struct cy8c95x0_pinctrl *chip, unsigned int pin)
328328
static bool cy8c95x0_readable_register(struct device *dev, unsigned int reg)
329329
{
330330
/*
331-
* Only 12 registers are present per port (see Table 6 in the
332-
* datasheet).
331+
* Only 12 registers are present per port (see Table 6 in the datasheet).
333332
*/
334-
if (reg >= CY8C95X0_VIRTUAL && (reg % MUXED_STRIDE) < 12)
335-
return true;
333+
if (reg >= CY8C95X0_VIRTUAL && (reg % MUXED_STRIDE) >= 12)
334+
return false;
336335

337336
switch (reg) {
338337
case 0x24 ... 0x27:
338+
case 0x31 ... 0x3f:
339339
return false;
340340
default:
341341
return true;
@@ -344,15 +344,19 @@ static bool cy8c95x0_readable_register(struct device *dev, unsigned int reg)
344344

345345
static bool cy8c95x0_writeable_register(struct device *dev, unsigned int reg)
346346
{
347-
if (reg >= CY8C95X0_VIRTUAL)
348-
return true;
347+
/*
348+
* Only 12 registers are present per port (see Table 6 in the datasheet).
349+
*/
350+
if (reg >= CY8C95X0_VIRTUAL && (reg % MUXED_STRIDE) >= 12)
351+
return false;
349352

350353
switch (reg) {
351354
case CY8C95X0_INPUT_(0) ... CY8C95X0_INPUT_(7):
352355
return false;
353356
case CY8C95X0_DEVID:
354357
return false;
355358
case 0x24 ... 0x27:
359+
case 0x31 ... 0x3f:
356360
return false;
357361
default:
358362
return true;
@@ -365,8 +369,8 @@ static bool cy8c95x0_volatile_register(struct device *dev, unsigned int reg)
365369
case CY8C95X0_INPUT_(0) ... CY8C95X0_INPUT_(7):
366370
case CY8C95X0_INTSTATUS_(0) ... CY8C95X0_INTSTATUS_(7):
367371
case CY8C95X0_INTMASK:
372+
case CY8C95X0_SELPWM:
368373
case CY8C95X0_INVERT:
369-
case CY8C95X0_PWMSEL:
370374
case CY8C95X0_DIRECTION:
371375
case CY8C95X0_DRV_PU:
372376
case CY8C95X0_DRV_PD:
@@ -395,7 +399,7 @@ static bool cy8c95x0_muxed_register(unsigned int reg)
395399
{
396400
switch (reg) {
397401
case CY8C95X0_INTMASK:
398-
case CY8C95X0_PWMSEL:
402+
case CY8C95X0_SELPWM:
399403
case CY8C95X0_INVERT:
400404
case CY8C95X0_DIRECTION:
401405
case CY8C95X0_DRV_PU:
@@ -466,7 +470,11 @@ static const struct regmap_config cy8c9520_i2c_regmap = {
466470
.max_register = 0, /* Updated at runtime */
467471
.num_reg_defaults_raw = 0, /* Updated at runtime */
468472
.use_single_read = true, /* Workaround for regcache bug */
473+
#if IS_ENABLED(CONFIG_DEBUG_PINCTRL)
474+
.disable_locking = false,
475+
#else
469476
.disable_locking = true,
477+
#endif
470478
};
471479

472480
static inline int cy8c95x0_regmap_update_bits_base(struct cy8c95x0_pinctrl *chip,
@@ -789,7 +797,7 @@ static int cy8c95x0_gpio_get_pincfg(struct cy8c95x0_pinctrl *chip,
789797
reg = CY8C95X0_DIRECTION;
790798
break;
791799
case PIN_CONFIG_MODE_PWM:
792-
reg = CY8C95X0_PWMSEL;
800+
reg = CY8C95X0_SELPWM;
793801
break;
794802
case PIN_CONFIG_OUTPUT:
795803
reg = CY8C95X0_OUTPUT;
@@ -868,7 +876,7 @@ static int cy8c95x0_gpio_set_pincfg(struct cy8c95x0_pinctrl *chip,
868876
reg = CY8C95X0_DRV_PP_FAST;
869877
break;
870878
case PIN_CONFIG_MODE_PWM:
871-
reg = CY8C95X0_PWMSEL;
879+
reg = CY8C95X0_SELPWM;
872880
break;
873881
case PIN_CONFIG_OUTPUT_ENABLE:
874882
return cy8c95x0_pinmux_direction(chip, off, !arg);
@@ -1153,7 +1161,7 @@ static void cy8c95x0_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *
11531161
bitmap_zero(mask, MAX_LINE);
11541162
__set_bit(pin, mask);
11551163

1156-
if (cy8c95x0_read_regs_mask(chip, CY8C95X0_PWMSEL, pwm, mask)) {
1164+
if (cy8c95x0_read_regs_mask(chip, CY8C95X0_SELPWM, pwm, mask)) {
11571165
seq_puts(s, "not available");
11581166
return;
11591167
}
@@ -1198,7 +1206,7 @@ static int cy8c95x0_set_mode(struct cy8c95x0_pinctrl *chip, unsigned int off, bo
11981206
u8 port = cypress_get_port(chip, off);
11991207
u8 bit = cypress_get_pin_mask(chip, off);
12001208

1201-
return cy8c95x0_regmap_write_bits(chip, CY8C95X0_PWMSEL, port, bit, mode ? bit : 0);
1209+
return cy8c95x0_regmap_write_bits(chip, CY8C95X0_SELPWM, port, bit, mode ? bit : 0);
12021210
}
12031211

12041212
static int cy8c95x0_pinmux_mode(struct cy8c95x0_pinctrl *chip,
@@ -1347,7 +1355,7 @@ static int cy8c95x0_irq_setup(struct cy8c95x0_pinctrl *chip, int irq)
13471355

13481356
ret = devm_request_threaded_irq(chip->dev, irq,
13491357
NULL, cy8c95x0_irq_handler,
1350-
IRQF_ONESHOT | IRQF_SHARED | IRQF_TRIGGER_HIGH,
1358+
IRQF_ONESHOT | IRQF_SHARED,
13511359
dev_name(chip->dev), chip);
13521360
if (ret) {
13531361
dev_err(chip->dev, "failed to request irq %d\n", irq);
@@ -1438,15 +1446,15 @@ static int cy8c95x0_probe(struct i2c_client *client)
14381446
switch (chip->tpin) {
14391447
case 20:
14401448
strscpy(chip->name, cy8c95x0_id[0].name);
1441-
regmap_range_conf.range_max = CY8C95X0_VIRTUAL + 3 * MUXED_STRIDE;
1449+
regmap_range_conf.range_max = CY8C95X0_VIRTUAL + 3 * MUXED_STRIDE - 1;
14421450
break;
14431451
case 40:
14441452
strscpy(chip->name, cy8c95x0_id[1].name);
1445-
regmap_range_conf.range_max = CY8C95X0_VIRTUAL + 6 * MUXED_STRIDE;
1453+
regmap_range_conf.range_max = CY8C95X0_VIRTUAL + 6 * MUXED_STRIDE - 1;
14461454
break;
14471455
case 60:
14481456
strscpy(chip->name, cy8c95x0_id[2].name);
1449-
regmap_range_conf.range_max = CY8C95X0_VIRTUAL + 8 * MUXED_STRIDE;
1457+
regmap_range_conf.range_max = CY8C95X0_VIRTUAL + 8 * MUXED_STRIDE - 1;
14501458
break;
14511459
default:
14521460
return -ENODEV;

0 commit comments

Comments
 (0)