Skip to content

Commit 3e5832e

Browse files
committed
Merge tag 'pinctrl-v5.17-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl
Pull pin control fixes from Linus Walleij: "Most interesting and urgent is the Intel stuff affecting Chromebooks and laptops. - Fix up group name building on the Intel Thunderbay - Fix interrupt problems on the Intel Cherryview - Fix some pin data on the Sunxi H616 - Fix up the CONFIG_PINCTRL_ST Kconfig sort order as noted during the merge window - Fix an unexpected interrupt problem on the Intel Sunrisepoint - Fix a glitch when updating IRQ flags on all Intel pin controllers - Revert a Zynqmp patch to unify the pin naming, let's find some better solution - Fix some error paths in the Broadcom BCM2835 driver - Fix a Kconfig problem pertaining to the BCM63XX drivers - Fix the regmap support in the Microchip SGPIO driver" * tag 'pinctrl-v5.17-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl: pinctrl: microchip-sgpio: Fix support for regmap pinctrl: bcm63xx: fix unmet dependency on REGMAP for GPIO_REGMAP pinctrl: bcm2835: Fix a few error paths pinctrl: zynqmp: Revert "Unify pin naming" pinctrl: intel: Fix a glitch when updating IRQ flags on a preconfigured line pinctrl: intel: fix unexpected interrupt pinctrl: Place correctly CONFIG_PINCTRL_ST in the Makefile pinctrl: sunxi: Fix H616 I2S3 pin data pinctrl: cherryview: Trigger hwirq0 for interrupt-lines without a mapping pinctrl: thunderbay: rework loops looking for groups names pinctrl: thunderbay: comment process of building functions a bit
2 parents 9f7fb8d + baf927a commit 3e5832e

9 files changed

Lines changed: 101 additions & 105 deletions

File tree

drivers/pinctrl/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ obj-$(CONFIG_PINCTRL_PISTACHIO) += pinctrl-pistachio.o
4242
obj-$(CONFIG_PINCTRL_RK805) += pinctrl-rk805.o
4343
obj-$(CONFIG_PINCTRL_ROCKCHIP) += pinctrl-rockchip.o
4444
obj-$(CONFIG_PINCTRL_SINGLE) += pinctrl-single.o
45+
obj-$(CONFIG_PINCTRL_ST) += pinctrl-st.o
4546
obj-$(CONFIG_PINCTRL_STARFIVE) += pinctrl-starfive.o
4647
obj-$(CONFIG_PINCTRL_STMFX) += pinctrl-stmfx.o
47-
obj-$(CONFIG_PINCTRL_ST) += pinctrl-st.o
4848
obj-$(CONFIG_PINCTRL_SX150X) += pinctrl-sx150x.o
4949
obj-$(CONFIG_PINCTRL_TB10X) += pinctrl-tb10x.o
5050
obj-$(CONFIG_PINCTRL_THUNDERBAY) += pinctrl-thunderbay.o

drivers/pinctrl/bcm/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ config PINCTRL_BCM63XX
3535
select PINCONF
3636
select GENERIC_PINCONF
3737
select GPIOLIB
38+
select REGMAP
3839
select GPIO_REGMAP
3940

4041
config PINCTRL_BCM6318

drivers/pinctrl/bcm/pinctrl-bcm2835.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,16 +1269,18 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)
12691269
sizeof(*girq->parents),
12701270
GFP_KERNEL);
12711271
if (!girq->parents) {
1272-
pinctrl_remove_gpio_range(pc->pctl_dev, &pc->gpio_range);
1273-
return -ENOMEM;
1272+
err = -ENOMEM;
1273+
goto out_remove;
12741274
}
12751275

12761276
if (is_7211) {
12771277
pc->wake_irq = devm_kcalloc(dev, BCM2835_NUM_IRQS,
12781278
sizeof(*pc->wake_irq),
12791279
GFP_KERNEL);
1280-
if (!pc->wake_irq)
1281-
return -ENOMEM;
1280+
if (!pc->wake_irq) {
1281+
err = -ENOMEM;
1282+
goto out_remove;
1283+
}
12821284
}
12831285

12841286
/*
@@ -1306,8 +1308,10 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)
13061308

13071309
len = strlen(dev_name(pc->dev)) + 16;
13081310
name = devm_kzalloc(pc->dev, len, GFP_KERNEL);
1309-
if (!name)
1310-
return -ENOMEM;
1311+
if (!name) {
1312+
err = -ENOMEM;
1313+
goto out_remove;
1314+
}
13111315

13121316
snprintf(name, len, "%s:bank%d", dev_name(pc->dev), i);
13131317

@@ -1326,11 +1330,14 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)
13261330
err = gpiochip_add_data(&pc->gpio_chip, pc);
13271331
if (err) {
13281332
dev_err(dev, "could not add GPIO chip\n");
1329-
pinctrl_remove_gpio_range(pc->pctl_dev, &pc->gpio_range);
1330-
return err;
1333+
goto out_remove;
13311334
}
13321335

13331336
return 0;
1337+
1338+
out_remove:
1339+
pinctrl_remove_gpio_range(pc->pctl_dev, &pc->gpio_range);
1340+
return err;
13341341
}
13351342

13361343
static struct platform_driver bcm2835_pinctrl_driver = {

drivers/pinctrl/intel/pinctrl-cherryview.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,8 +1471,9 @@ static void chv_gpio_irq_handler(struct irq_desc *desc)
14711471

14721472
offset = cctx->intr_lines[intr_line];
14731473
if (offset == CHV_INVALID_HWIRQ) {
1474-
dev_err(dev, "interrupt on unused interrupt line %u\n", intr_line);
1475-
continue;
1474+
dev_warn_once(dev, "interrupt on unmapped interrupt line %u\n", intr_line);
1475+
/* Some boards expect hwirq 0 to trigger in this case */
1476+
offset = 0;
14761477
}
14771478

14781479
generic_handle_domain_irq(gc->irq.domain, offset);

drivers/pinctrl/intel/pinctrl-intel.c

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,8 @@ static void intel_gpio_set_gpio_mode(void __iomem *padcfg0)
451451
value &= ~PADCFG0_PMODE_MASK;
452452
value |= PADCFG0_PMODE_GPIO;
453453

454-
/* Disable input and output buffers */
455-
value |= PADCFG0_GPIORXDIS;
454+
/* Disable TX buffer and enable RX (this will be input) */
455+
value &= ~PADCFG0_GPIORXDIS;
456456
value |= PADCFG0_GPIOTXDIS;
457457

458458
/* Disable SCI/SMI/NMI generation */
@@ -497,9 +497,6 @@ static int intel_gpio_request_enable(struct pinctrl_dev *pctldev,
497497

498498
intel_gpio_set_gpio_mode(padcfg0);
499499

500-
/* Disable TX buffer and enable RX (this will be input) */
501-
__intel_gpio_set_direction(padcfg0, true);
502-
503500
raw_spin_unlock_irqrestore(&pctrl->lock, flags);
504501

505502
return 0;
@@ -1115,9 +1112,6 @@ static int intel_gpio_irq_type(struct irq_data *d, unsigned int type)
11151112

11161113
intel_gpio_set_gpio_mode(reg);
11171114

1118-
/* Disable TX buffer and enable RX (this will be input) */
1119-
__intel_gpio_set_direction(reg, true);
1120-
11211115
value = readl(reg);
11221116

11231117
value &= ~(PADCFG0_RXEVCFG_MASK | PADCFG0_RXINV);
@@ -1216,6 +1210,39 @@ static irqreturn_t intel_gpio_irq(int irq, void *data)
12161210
return IRQ_RETVAL(ret);
12171211
}
12181212

1213+
static void intel_gpio_irq_init(struct intel_pinctrl *pctrl)
1214+
{
1215+
int i;
1216+
1217+
for (i = 0; i < pctrl->ncommunities; i++) {
1218+
const struct intel_community *community;
1219+
void __iomem *base;
1220+
unsigned int gpp;
1221+
1222+
community = &pctrl->communities[i];
1223+
base = community->regs;
1224+
1225+
for (gpp = 0; gpp < community->ngpps; gpp++) {
1226+
/* Mask and clear all interrupts */
1227+
writel(0, base + community->ie_offset + gpp * 4);
1228+
writel(0xffff, base + community->is_offset + gpp * 4);
1229+
}
1230+
}
1231+
}
1232+
1233+
static int intel_gpio_irq_init_hw(struct gpio_chip *gc)
1234+
{
1235+
struct intel_pinctrl *pctrl = gpiochip_get_data(gc);
1236+
1237+
/*
1238+
* Make sure the interrupt lines are in a proper state before
1239+
* further configuration.
1240+
*/
1241+
intel_gpio_irq_init(pctrl);
1242+
1243+
return 0;
1244+
}
1245+
12191246
static int intel_gpio_add_community_ranges(struct intel_pinctrl *pctrl,
12201247
const struct intel_community *community)
12211248
{
@@ -1320,6 +1347,7 @@ static int intel_gpio_probe(struct intel_pinctrl *pctrl, int irq)
13201347
girq->num_parents = 0;
13211348
girq->default_type = IRQ_TYPE_NONE;
13221349
girq->handler = handle_bad_irq;
1350+
girq->init_hw = intel_gpio_irq_init_hw;
13231351

13241352
ret = devm_gpiochip_add_data(pctrl->dev, &pctrl->chip, pctrl);
13251353
if (ret) {
@@ -1695,26 +1723,6 @@ int intel_pinctrl_suspend_noirq(struct device *dev)
16951723
}
16961724
EXPORT_SYMBOL_GPL(intel_pinctrl_suspend_noirq);
16971725

1698-
static void intel_gpio_irq_init(struct intel_pinctrl *pctrl)
1699-
{
1700-
size_t i;
1701-
1702-
for (i = 0; i < pctrl->ncommunities; i++) {
1703-
const struct intel_community *community;
1704-
void __iomem *base;
1705-
unsigned int gpp;
1706-
1707-
community = &pctrl->communities[i];
1708-
base = community->regs;
1709-
1710-
for (gpp = 0; gpp < community->ngpps; gpp++) {
1711-
/* Mask and clear all interrupts */
1712-
writel(0, base + community->ie_offset + gpp * 4);
1713-
writel(0xffff, base + community->is_offset + gpp * 4);
1714-
}
1715-
}
1716-
}
1717-
17181726
static bool intel_gpio_update_reg(void __iomem *reg, u32 mask, u32 value)
17191727
{
17201728
u32 curr, updated;

drivers/pinctrl/pinctrl-microchip-sgpio.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ static inline int sgpio_addr_to_pin(struct sgpio_priv *priv, int port, int bit)
137137

138138
static inline u32 sgpio_get_addr(struct sgpio_priv *priv, u32 rno, u32 off)
139139
{
140-
return priv->properties->regoff[rno] + off;
140+
return (priv->properties->regoff[rno] + off) *
141+
regmap_get_reg_stride(priv->regs);
141142
}
142143

143144
static u32 sgpio_readl(struct sgpio_priv *priv, u32 rno, u32 off)

drivers/pinctrl/pinctrl-thunderbay.c

Lines changed: 35 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -773,63 +773,42 @@ static int thunderbay_build_groups(struct thunderbay_pinctrl *tpc)
773773

774774
static int thunderbay_add_functions(struct thunderbay_pinctrl *tpc, struct function_desc *funcs)
775775
{
776-
struct function_desc *function = funcs;
777776
int i;
778777

779778
/* Assign the groups for each function */
780-
for (i = 0; i < tpc->soc->npins; i++) {
781-
const struct pinctrl_pin_desc *pin_info = thunderbay_pins + i;
782-
struct thunderbay_mux_desc *pin_mux = pin_info->drv_data;
783-
784-
while (pin_mux->name) {
785-
const char **grp;
786-
int j, grp_num, match = 0;
787-
size_t grp_size;
788-
struct function_desc *func;
789-
790-
for (j = 0; j < tpc->nfuncs; j++) {
791-
if (!strcmp(pin_mux->name, function[j].name)) {
792-
match = 1;
793-
break;
794-
}
795-
}
796-
797-
if (!match)
798-
return -EINVAL;
799-
800-
func = function + j;
801-
grp_num = func->num_group_names;
802-
grp_size = sizeof(*func->group_names);
803-
804-
if (!func->group_names) {
805-
func->group_names = devm_kcalloc(tpc->dev,
806-
grp_num,
807-
grp_size,
808-
GFP_KERNEL);
809-
if (!func->group_names) {
810-
kfree(func);
811-
return -ENOMEM;
812-
}
779+
for (i = 0; i < tpc->nfuncs; i++) {
780+
struct function_desc *func = &funcs[i];
781+
const char **group_names;
782+
unsigned int grp_idx = 0;
783+
int j;
784+
785+
group_names = devm_kcalloc(tpc->dev, func->num_group_names,
786+
sizeof(*group_names), GFP_KERNEL);
787+
if (!group_names)
788+
return -ENOMEM;
789+
790+
for (j = 0; j < tpc->soc->npins; j++) {
791+
const struct pinctrl_pin_desc *pin_info = &thunderbay_pins[j];
792+
struct thunderbay_mux_desc *pin_mux;
793+
794+
for (pin_mux = pin_info->drv_data; pin_mux->name; pin_mux++) {
795+
if (!strcmp(pin_mux->name, func->name))
796+
group_names[grp_idx++] = pin_info->name;
813797
}
814-
815-
grp = func->group_names;
816-
while (*grp)
817-
grp++;
818-
819-
*grp = pin_info->name;
820-
pin_mux++;
821798
}
799+
800+
func->group_names = group_names;
822801
}
823802

824803
/* Add all functions */
825804
for (i = 0; i < tpc->nfuncs; i++) {
826805
pinmux_generic_add_function(tpc->pctrl,
827-
function[i].name,
828-
function[i].group_names,
829-
function[i].num_group_names,
830-
function[i].data);
806+
funcs[i].name,
807+
funcs[i].group_names,
808+
funcs[i].num_group_names,
809+
funcs[i].data);
831810
}
832-
kfree(function);
811+
kfree(funcs);
833812
return 0;
834813
}
835814

@@ -839,27 +818,30 @@ static int thunderbay_build_functions(struct thunderbay_pinctrl *tpc)
839818
void *ptr;
840819
int pin;
841820

842-
/* Total number of functions is unknown at this point. Allocate first. */
821+
/*
822+
* Allocate maximum possible number of functions. Assume every pin
823+
* being part of 8 (hw maximum) globally unique muxes.
824+
*/
843825
tpc->nfuncs = 0;
844826
thunderbay_funcs = kcalloc(tpc->soc->npins * 8,
845827
sizeof(*thunderbay_funcs), GFP_KERNEL);
846828
if (!thunderbay_funcs)
847829
return -ENOMEM;
848830

849-
/* Find total number of functions and each's properties */
831+
/* Setup 1 function for each unique mux */
850832
for (pin = 0; pin < tpc->soc->npins; pin++) {
851833
const struct pinctrl_pin_desc *pin_info = thunderbay_pins + pin;
852-
struct thunderbay_mux_desc *pin_mux = pin_info->drv_data;
834+
struct thunderbay_mux_desc *pin_mux;
853835

854-
while (pin_mux->name) {
855-
struct function_desc *func = thunderbay_funcs;
836+
for (pin_mux = pin_info->drv_data; pin_mux->name; pin_mux++) {
837+
struct function_desc *func;
856838

857-
while (func->name) {
839+
/* Check if we already have function for this mux */
840+
for (func = thunderbay_funcs; func->name; func++) {
858841
if (!strcmp(pin_mux->name, func->name)) {
859842
func->num_group_names++;
860843
break;
861844
}
862-
func++;
863845
}
864846

865847
if (!func->name) {
@@ -868,8 +850,6 @@ static int thunderbay_build_functions(struct thunderbay_pinctrl *tpc)
868850
func->data = (int *)&pin_mux->mode;
869851
tpc->nfuncs++;
870852
}
871-
872-
pin_mux++;
873853
}
874854
}
875855

drivers/pinctrl/pinctrl-zynqmp.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,6 @@ static int zynqmp_pinctrl_prepare_pin_desc(struct device *dev,
809809
unsigned int *npins)
810810
{
811811
struct pinctrl_pin_desc *pins, *pin;
812-
char **pin_names;
813812
int ret;
814813
int i;
815814

@@ -821,14 +820,13 @@ static int zynqmp_pinctrl_prepare_pin_desc(struct device *dev,
821820
if (!pins)
822821
return -ENOMEM;
823822

824-
pin_names = devm_kasprintf_strarray(dev, ZYNQMP_PIN_PREFIX, *npins);
825-
if (IS_ERR(pin_names))
826-
return PTR_ERR(pin_names);
827-
828823
for (i = 0; i < *npins; i++) {
829824
pin = &pins[i];
830825
pin->number = i;
831-
pin->name = pin_names[i];
826+
pin->name = devm_kasprintf(dev, GFP_KERNEL, "%s%d",
827+
ZYNQMP_PIN_PREFIX, i);
828+
if (!pin->name)
829+
return -ENOMEM;
832830
}
833831

834832
*zynqmp_pins = pins;

drivers/pinctrl/sunxi/pinctrl-sun50i-h616.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,16 +363,16 @@ static const struct sunxi_desc_pin h616_pins[] = {
363363
SUNXI_FUNCTION(0x0, "gpio_in"),
364364
SUNXI_FUNCTION(0x1, "gpio_out"),
365365
SUNXI_FUNCTION(0x2, "uart2"), /* CTS */
366-
SUNXI_FUNCTION(0x3, "i2s3"), /* DO0 */
366+
SUNXI_FUNCTION(0x3, "i2s3_dout0"), /* DO0 */
367367
SUNXI_FUNCTION(0x4, "spi1"), /* MISO */
368-
SUNXI_FUNCTION(0x5, "i2s3"), /* DI1 */
368+
SUNXI_FUNCTION(0x5, "i2s3_din1"), /* DI1 */
369369
SUNXI_FUNCTION_IRQ_BANK(0x6, 6, 8)), /* PH_EINT8 */
370370
SUNXI_PIN(SUNXI_PINCTRL_PIN(H, 9),
371371
SUNXI_FUNCTION(0x0, "gpio_in"),
372372
SUNXI_FUNCTION(0x1, "gpio_out"),
373-
SUNXI_FUNCTION(0x3, "i2s3"), /* DI0 */
373+
SUNXI_FUNCTION(0x3, "i2s3_din0"), /* DI0 */
374374
SUNXI_FUNCTION(0x4, "spi1"), /* CS1 */
375-
SUNXI_FUNCTION(0x3, "i2s3"), /* DO1 */
375+
SUNXI_FUNCTION(0x5, "i2s3_dout1"), /* DO1 */
376376
SUNXI_FUNCTION_IRQ_BANK(0x6, 6, 9)), /* PH_EINT9 */
377377
SUNXI_PIN(SUNXI_PINCTRL_PIN(H, 10),
378378
SUNXI_FUNCTION(0x0, "gpio_in"),

0 commit comments

Comments
 (0)