Skip to content

Commit 9f0648f

Browse files
committed
Merge tag 'intel-pinctrl-v6.5-1' of git://git.kernel.org/pub/scm/linux/kernel/git/pinctrl/intel into devel
intel-pinctrl for v6.5-1 * Fix of OPEN DRAIN pin mode setting in a few drivers * Reduce a scope of spin lock in the Bay Trail driver * Decrease a code footprint by refactoring in a few drivers * Expand string choices and reuse that in the Bay Trail driver The following is an automated git shortlog grouped by driver: baytrail: - invert if condition - add warning for BYT_VAL_REG retrieval failure - reduce scope of spinlock in ->dbg_show() hook - Use str_hi_lo() helper - Use BIT() in BYT_PULL_ASSIGN_* definitions - Unify style of error and debug messages cherryview: - Drop goto label - Return correct value if pin in push-pull mode - Don't use IRQ core constanst for invalid IRQ intel: - refine ->irq_set_type() hook - refine ->set_mux() hook - Add Intel Meteor Lake-S pin controller support lib/string_helpers: - Add str_high_low() helper - Split out string_choices.h - Add missing header files to MAINTAINERS database merrifield: - Use BUFCFG_PINMODE_GPIO in ->pin_dbg_show() - Fix open-drain pin mode configuration moorefield: - Use BUFCFG_PINMODE_GPIO in ->pin_dbg_show() - Fix open-drain pin mode configuration
2 parents d18b2a0 + 9314d05 commit 9f0648f

File tree

9 files changed

+371
-130
lines changed

9 files changed

+371
-130
lines changed

MAINTAINERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8670,6 +8670,9 @@ F: drivers/input/touchscreen/resistive-adc-touch.c
86708670
GENERIC STRING LIBRARY
86718671
R: Andy Shevchenko <andy@kernel.org>
86728672
S: Maintained
8673+
F: include/linux/string.h
8674+
F: include/linux/string_choices.h
8675+
F: include/linux/string_helpers.h
86738676
F: lib/string.c
86748677
F: lib/string_helpers.c
86758678
F: lib/test_string.c

drivers/pinctrl/intel/pinctrl-baytrail.c

Lines changed: 46 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/pm_runtime.h>
1919
#include <linux/property.h>
2020
#include <linux/seq_file.h>
21+
#include <linux/string_helpers.h>
2122

2223
#include <linux/pinctrl/pinctrl.h>
2324
#include <linux/pinctrl/pinmux.h>
@@ -52,10 +53,9 @@
5253
#define BYT_PULL_STR_10K (1 << BYT_PULL_STR_SHIFT)
5354
#define BYT_PULL_STR_20K (2 << BYT_PULL_STR_SHIFT)
5455
#define BYT_PULL_STR_40K (3 << BYT_PULL_STR_SHIFT)
55-
#define BYT_PULL_ASSIGN_SHIFT 7
5656
#define BYT_PULL_ASSIGN_MASK GENMASK(8, 7)
57-
#define BYT_PULL_ASSIGN_UP (1 << BYT_PULL_ASSIGN_SHIFT)
58-
#define BYT_PULL_ASSIGN_DOWN (2 << BYT_PULL_ASSIGN_SHIFT)
57+
#define BYT_PULL_ASSIGN_DOWN BIT(8)
58+
#define BYT_PULL_ASSIGN_UP BIT(7)
5959
#define BYT_PIN_MUX GENMASK(2, 0)
6060

6161
/* BYT_VAL_REG register bits */
@@ -668,8 +668,7 @@ static void byt_set_group_simple_mux(struct intel_pinctrl *vg,
668668

669669
padcfg0 = byt_gpio_reg(vg, group.grp.pins[i], BYT_CONF0_REG);
670670
if (!padcfg0) {
671-
dev_warn(vg->dev,
672-
"Group %s, pin %i not muxed (no padcfg0)\n",
671+
dev_warn(vg->dev, "Group %s, pin %i not muxed (can't retrieve CONF0)\n",
673672
group.grp.name, i);
674673
continue;
675674
}
@@ -698,8 +697,7 @@ static void byt_set_group_mixed_mux(struct intel_pinctrl *vg,
698697

699698
padcfg0 = byt_gpio_reg(vg, group.grp.pins[i], BYT_CONF0_REG);
700699
if (!padcfg0) {
701-
dev_warn(vg->dev,
702-
"Group %s, pin %i not muxed (no padcfg0)\n",
700+
dev_warn(vg->dev, "Group %s, pin %i not muxed (can't retrieve CONF0)\n",
703701
group.grp.name, i);
704702
continue;
705703
}
@@ -755,9 +753,7 @@ static void byt_gpio_clear_triggering(struct intel_pinctrl *vg, unsigned int off
755753
value = readl(reg);
756754

757755
/* Do not clear direct-irq enabled IRQs (from gpio_disable_free) */
758-
if (value & BYT_DIRECT_IRQ_EN)
759-
/* nothing to do */ ;
760-
else
756+
if (!(value & BYT_DIRECT_IRQ_EN))
761757
value &= ~(BYT_TRIG_POS | BYT_TRIG_NEG | BYT_TRIG_LVL);
762758

763759
writel(value, reg);
@@ -791,7 +787,7 @@ static int byt_gpio_request_enable(struct pinctrl_dev *pctl_dev,
791787
value |= gpio_mux;
792788
writel(value, reg);
793789

794-
dev_warn(vg->dev, FW_BUG "pin %u forcibly re-configured as GPIO\n", offset);
790+
dev_warn(vg->dev, FW_BUG "Pin %i: forcibly re-configured as GPIO\n", offset);
795791
}
796792

797793
raw_spin_unlock_irqrestore(&byt_lock, flags);
@@ -823,7 +819,9 @@ static void byt_gpio_direct_irq_check(struct intel_pinctrl *vg,
823819
* themselves in the foot.
824820
*/
825821
if (readl(conf_reg) & BYT_DIRECT_IRQ_EN)
826-
dev_info_once(vg->dev, "Potential Error: Setting GPIO with direct_irq_en to output");
822+
dev_info_once(vg->dev,
823+
"Potential Error: Pin %i: forcibly set GPIO with DIRECT_IRQ_EN to output\n",
824+
offset);
827825
}
828826

829827
static int byt_gpio_set_direction(struct pinctrl_dev *pctl_dev,
@@ -1026,9 +1024,7 @@ static int byt_pin_config_set(struct pinctrl_dev *pctl_dev,
10261024
if (val & BYT_INPUT_EN) {
10271025
val &= ~BYT_INPUT_EN;
10281026
writel(val, val_reg);
1029-
dev_warn(vg->dev,
1030-
"pin %u forcibly set to input mode\n",
1031-
offset);
1027+
dev_warn(vg->dev, "Pin %i: forcibly set to input mode\n", offset);
10321028
}
10331029

10341030
conf &= ~BYT_PULL_ASSIGN_MASK;
@@ -1048,9 +1044,7 @@ static int byt_pin_config_set(struct pinctrl_dev *pctl_dev,
10481044
if (val & BYT_INPUT_EN) {
10491045
val &= ~BYT_INPUT_EN;
10501046
writel(val, val_reg);
1051-
dev_warn(vg->dev,
1052-
"pin %u forcibly set to input mode\n",
1053-
offset);
1047+
dev_warn(vg->dev, "Pin %i: forcibly set to input mode\n", offset);
10541048
}
10551049

10561050
conf &= ~BYT_PULL_ASSIGN_MASK;
@@ -1245,39 +1239,35 @@ static void byt_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
12451239

12461240
for (i = 0; i < vg->soc->npins; i++) {
12471241
const struct intel_community *comm;
1242+
void __iomem *conf_reg, *val_reg;
12481243
const char *pull_str = NULL;
12491244
const char *pull = NULL;
1250-
void __iomem *reg;
12511245
unsigned long flags;
12521246
const char *label;
12531247
unsigned int pin;
12541248

1255-
raw_spin_lock_irqsave(&byt_lock, flags);
12561249
pin = vg->soc->pins[i].number;
1257-
reg = byt_gpio_reg(vg, pin, BYT_CONF0_REG);
1258-
if (!reg) {
1259-
seq_printf(s,
1260-
"Could not retrieve pin %i conf0 reg\n",
1261-
pin);
1262-
raw_spin_unlock_irqrestore(&byt_lock, flags);
1250+
1251+
conf_reg = byt_gpio_reg(vg, pin, BYT_CONF0_REG);
1252+
if (!conf_reg) {
1253+
seq_printf(s, "Pin %i: can't retrieve CONF0\n", pin);
12631254
continue;
12641255
}
1265-
conf0 = readl(reg);
12661256

1267-
reg = byt_gpio_reg(vg, pin, BYT_VAL_REG);
1268-
if (!reg) {
1269-
seq_printf(s,
1270-
"Could not retrieve pin %i val reg\n", pin);
1271-
raw_spin_unlock_irqrestore(&byt_lock, flags);
1257+
val_reg = byt_gpio_reg(vg, pin, BYT_VAL_REG);
1258+
if (!val_reg) {
1259+
seq_printf(s, "Pin %i: can't retrieve VAL\n", pin);
12721260
continue;
12731261
}
1274-
val = readl(reg);
1262+
1263+
raw_spin_lock_irqsave(&byt_lock, flags);
1264+
conf0 = readl(conf_reg);
1265+
val = readl(val_reg);
12751266
raw_spin_unlock_irqrestore(&byt_lock, flags);
12761267

12771268
comm = byt_get_community(vg, pin);
12781269
if (!comm) {
1279-
seq_printf(s,
1280-
"Could not get community for pin %i\n", pin);
1270+
seq_printf(s, "Pin %i: can't retrieve community\n", pin);
12811271
continue;
12821272
}
12831273
label = gpiochip_is_requested(chip, i);
@@ -1314,7 +1304,7 @@ static void byt_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
13141304
label,
13151305
val & BYT_INPUT_EN ? " " : "in",
13161306
val & BYT_OUTPUT_EN ? " " : "out",
1317-
val & BYT_LEVEL ? "hi" : "lo",
1307+
str_hi_lo(val & BYT_LEVEL),
13181308
comm->pad_map[i], comm->pad_map[i] * 16,
13191309
conf0 & 0x7,
13201310
conf0 & BYT_TRIG_NEG ? " fall" : " ",
@@ -1429,7 +1419,7 @@ static int byt_irq_type(struct irq_data *d, unsigned int type)
14291419
value = readl(reg);
14301420

14311421
WARN(value & BYT_DIRECT_IRQ_EN,
1432-
"Bad pad config for io mode, force direct_irq_en bit clearing");
1422+
"Bad pad config for IO mode, force DIRECT_IRQ_EN bit clearing");
14331423

14341424
/* For level trigges the BYT_TRIG_POS and BYT_TRIG_NEG bits
14351425
* are used to indicate high and low level triggering
@@ -1476,9 +1466,7 @@ static void byt_gpio_irq_handler(struct irq_desc *desc)
14761466
reg = byt_gpio_reg(vg, base, BYT_INT_STAT_REG);
14771467

14781468
if (!reg) {
1479-
dev_warn(vg->dev,
1480-
"Pin %i: could not retrieve interrupt status register\n",
1481-
base);
1469+
dev_warn(vg->dev, "Pin %i: can't retrieve INT_STAT%u\n", base / 32, base);
14821470
continue;
14831471
}
14841472

@@ -1501,7 +1489,7 @@ static bool byt_direct_irq_sanity_check(struct intel_pinctrl *vg, int pin, u32 c
15011489
sizeof(direct_irq_mux));
15021490
match = memchr(direct_irq_mux, pin, sizeof(direct_irq_mux));
15031491
if (!match) {
1504-
dev_warn(vg->dev, FW_BUG "pin %i: direct_irq_en set but no IRQ assigned, clearing\n", pin);
1492+
dev_warn(vg->dev, FW_BUG "Pin %i: DIRECT_IRQ_EN set but no IRQ assigned, clearing\n", pin);
15051493
return false;
15061494
}
15071495

@@ -1528,7 +1516,8 @@ static bool byt_direct_irq_sanity_check(struct intel_pinctrl *vg, int pin, u32 c
15281516
trig = conf0 & BYT_TRIG_MASK;
15291517
if (trig != (BYT_TRIG_POS | BYT_TRIG_LVL) &&
15301518
trig != (BYT_TRIG_NEG | BYT_TRIG_LVL)) {
1531-
dev_warn(vg->dev, FW_BUG "pin %i: direct_irq_en set without trigger (conf0: %xh), clearing\n",
1519+
dev_warn(vg->dev,
1520+
FW_BUG "Pin %i: DIRECT_IRQ_EN set without trigger (CONF0: %#08x), clearing\n",
15321521
pin, conf0);
15331522
return false;
15341523
}
@@ -1555,9 +1544,7 @@ static void byt_init_irq_valid_mask(struct gpio_chip *chip,
15551544

15561545
reg = byt_gpio_reg(vg, pin, BYT_CONF0_REG);
15571546
if (!reg) {
1558-
dev_warn(vg->dev,
1559-
"Pin %i: could not retrieve conf0 register\n",
1560-
i);
1547+
dev_warn(vg->dev, "Pin %i: could not retrieve CONF0\n", i);
15611548
continue;
15621549
}
15631550

@@ -1588,9 +1575,7 @@ static int byt_gpio_irq_init_hw(struct gpio_chip *chip)
15881575
reg = byt_gpio_reg(vg, base, BYT_INT_STAT_REG);
15891576

15901577
if (!reg) {
1591-
dev_warn(vg->dev,
1592-
"Pin %i: could not retrieve irq status reg\n",
1593-
base);
1578+
dev_warn(vg->dev, "Pin %i: can't retrieve INT_STAT%u\n", base / 32, base);
15941579
continue;
15951580
}
15961581

@@ -1600,7 +1585,7 @@ static int byt_gpio_irq_init_hw(struct gpio_chip *chip)
16001585
value = readl(reg);
16011586
if (value)
16021587
dev_err(vg->dev,
1603-
"GPIO interrupt error, pins misconfigured. INT_STAT%u: 0x%08x\n",
1588+
"GPIO interrupt error, pins misconfigured. INT_STAT%u: %#08x\n",
16041589
base / 32, value);
16051590
}
16061591

@@ -1764,15 +1749,17 @@ static int byt_gpio_suspend(struct device *dev)
17641749

17651750
reg = byt_gpio_reg(vg, pin, BYT_CONF0_REG);
17661751
if (!reg) {
1767-
dev_warn(vg->dev,
1768-
"Pin %i: could not retrieve conf0 register\n",
1769-
i);
1752+
dev_warn(vg->dev, "Pin %i: can't retrieve CONF0\n", i);
17701753
continue;
17711754
}
17721755
value = readl(reg) & BYT_CONF0_RESTORE_MASK;
17731756
vg->context.pads[i].conf0 = value;
17741757

17751758
reg = byt_gpio_reg(vg, pin, BYT_VAL_REG);
1759+
if (!reg) {
1760+
dev_warn(vg->dev, "Pin %i: can't retrieve VAL\n", i);
1761+
continue;
1762+
}
17761763
value = readl(reg) & BYT_VAL_RESTORE_MASK;
17771764
vg->context.pads[i].val = value;
17781765
}
@@ -1796,9 +1783,7 @@ static int byt_gpio_resume(struct device *dev)
17961783

17971784
reg = byt_gpio_reg(vg, pin, BYT_CONF0_REG);
17981785
if (!reg) {
1799-
dev_warn(vg->dev,
1800-
"Pin %i: could not retrieve conf0 register\n",
1801-
i);
1786+
dev_warn(vg->dev, "Pin %i: can't retrieve CONF0\n", i);
18021787
continue;
18031788
}
18041789
value = readl(reg);
@@ -1807,10 +1792,14 @@ static int byt_gpio_resume(struct device *dev)
18071792
value &= ~BYT_CONF0_RESTORE_MASK;
18081793
value |= vg->context.pads[i].conf0;
18091794
writel(value, reg);
1810-
dev_info(dev, "restored pin %d conf0 %#08x", i, value);
1795+
dev_info(dev, "restored pin %d CONF0 %#08x", i, value);
18111796
}
18121797

18131798
reg = byt_gpio_reg(vg, pin, BYT_VAL_REG);
1799+
if (!reg) {
1800+
dev_warn(vg->dev, "Pin %i: can't retrieve VAL\n", i);
1801+
continue;
1802+
}
18141803
value = readl(reg);
18151804
if ((value & BYT_VAL_RESTORE_MASK) !=
18161805
vg->context.pads[i].val) {
@@ -1820,8 +1809,7 @@ static int byt_gpio_resume(struct device *dev)
18201809
v |= vg->context.pads[i].val;
18211810
if (v != value) {
18221811
writel(v, reg);
1823-
dev_dbg(dev, "restored pin %d val %#08x\n",
1824-
i, v);
1812+
dev_dbg(dev, "restored pin %d VAL %#08x\n", i, v);
18251813
}
18261814
}
18271815
}

drivers/pinctrl/intel/pinctrl-cherryview.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ struct intel_pad_context {
7575
u32 padctrl1;
7676
};
7777

78-
#define CHV_INVALID_HWIRQ ((unsigned int)INVALID_HWIRQ)
78+
#define CHV_INVALID_HWIRQ (~0U)
7979

8080
/**
8181
* struct intel_community_context - community context for Cherryview
@@ -949,11 +949,6 @@ static int chv_config_get(struct pinctrl_dev *pctldev, unsigned int pin,
949949

950950
break;
951951

952-
case PIN_CONFIG_DRIVE_OPEN_DRAIN:
953-
if (!(ctrl1 & CHV_PADCTRL1_ODEN))
954-
return -EINVAL;
955-
break;
956-
957952
case PIN_CONFIG_BIAS_HIGH_IMPEDANCE: {
958953
u32 cfg;
959954

@@ -963,6 +958,16 @@ static int chv_config_get(struct pinctrl_dev *pctldev, unsigned int pin,
963958
return -EINVAL;
964959

965960
break;
961+
962+
case PIN_CONFIG_DRIVE_PUSH_PULL:
963+
if (ctrl1 & CHV_PADCTRL1_ODEN)
964+
return -EINVAL;
965+
break;
966+
967+
case PIN_CONFIG_DRIVE_OPEN_DRAIN:
968+
if (!(ctrl1 & CHV_PADCTRL1_ODEN))
969+
return -EINVAL;
970+
break;
966971
}
967972

968973
default:
@@ -1408,8 +1413,10 @@ static int chv_gpio_irq_type(struct irq_data *d, unsigned int type)
14081413
raw_spin_lock_irqsave(&chv_lock, flags);
14091414

14101415
ret = chv_gpio_set_intr_line(pctrl, hwirq);
1411-
if (ret)
1412-
goto out_unlock;
1416+
if (ret) {
1417+
raw_spin_unlock_irqrestore(&chv_lock, flags);
1418+
return ret;
1419+
}
14131420

14141421
/*
14151422
* Pins which can be used as shared interrupt are configured in
@@ -1450,10 +1457,9 @@ static int chv_gpio_irq_type(struct irq_data *d, unsigned int type)
14501457
else if (type & IRQ_TYPE_LEVEL_MASK)
14511458
irq_set_handler_locked(d, handle_level_irq);
14521459

1453-
out_unlock:
14541460
raw_spin_unlock_irqrestore(&chv_lock, flags);
14551461

1456-
return ret;
1462+
return 0;
14571463
}
14581464

14591465
static const struct irq_chip chv_gpio_irq_chip = {

0 commit comments

Comments
 (0)