Pin control fixes for v5.4:
- Fix glitch risks in the Intel GPIO - Fix the Intel Cherryview valid irq mask calculation. - Allocate the Intel Cherryview irqchip dynamically. - Fix the valid mask init sequency on the ST STMFX driver. -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEElDRnuGcz/wPCXQWMQRCzN7AZXXMFAl3HVugACgkQQRCzN7AZ XXNcOw//UAEO6DnTc4+fr46Al4hsgShxlHk0URPEkMWZI7t+R6bs9icGGDOoejWS n7/Fpd7ChpYqtsRQD4sc1/hJwXxoUJFX0xzP7dI/PmT+st0OULAHjokoqK3RtERe 1shwAQq1NosIlwmsy+ZOqQwXUfq6RAnnVPblt6+VeG7Sc9bNHnDcg7d58GVFl7C3 S6D2v59pPMAL9JU+hQDQ8DiODXLk2k9k7Vtoq8bYLei0PMKdt/7I1kJjELPfghiA PMLmtTztygB27fUiFVVGVcCtaivLXqtI83yi9uYnY2rQ4Oa+zxuuej5rUL+TwybK P+XKJDNUeg/l6+wdkQXN8rJXkEXcU+Sms0HZmaYkML4l/6Oh4JtjDhij1KPqNjhY ufO7mnf2zkfooLD8rv9YC50yYKX3vZT4b5SrPnvd4lG2/C3hiZozwmAXdYtLgoqS BU9c2kfzIKHiFgBCJCnkyDesaGCfbkw5rDh1R4tSpABbShS242EdAYL0ZCuzjEsc 9iR4Jbi03mhCINjkFDbx5PnAZk8cJUeSmKFeWxDuZoUh3gU0VoPHlH533k6FsnLG Kck2sBPhpPRl/b/64jF21UDI1g3W0gxQet+hGCSYzcA/QQ0fo5+VKpGyTSvxzDnl LcbccAELH3qdzMDajtyEXaIeOv8huG9iBzS0pUibLbAsPqqrMhk= =fkcG -----END PGP SIGNATURE----- Merge tag 'pinctrl-v5.4-3' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl Pull pin control fixes from Linus Walleij: - Fix glitch risks in the Intel GPIO - Fix the Intel Cherryview valid irq mask calculation. - Allocate the Intel Cherryview irqchip dynamically. - Fix the valid mask init sequency on the ST STMFX driver. * tag 'pinctrl-v5.4-3' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl: pinctrl: stmfx: fix valid_mask init sequence pinctrl: cherryview: Allocate IRQ chip dynamic pinctrl: cherryview: Fix irq_valid_mask calculation pinctrl: intel: Avoid potential glitches if pin is in GPIO modealistair/sunxi64-5.4-dsi
commit
4763c0894a
|
@ -147,6 +147,7 @@ struct chv_pin_context {
|
||||||
* @pctldesc: Pin controller description
|
* @pctldesc: Pin controller description
|
||||||
* @pctldev: Pointer to the pin controller device
|
* @pctldev: Pointer to the pin controller device
|
||||||
* @chip: GPIO chip in this pin controller
|
* @chip: GPIO chip in this pin controller
|
||||||
|
* @irqchip: IRQ chip in this pin controller
|
||||||
* @regs: MMIO registers
|
* @regs: MMIO registers
|
||||||
* @intr_lines: Stores mapping between 16 HW interrupt wires and GPIO
|
* @intr_lines: Stores mapping between 16 HW interrupt wires and GPIO
|
||||||
* offset (in GPIO number space)
|
* offset (in GPIO number space)
|
||||||
|
@ -162,6 +163,7 @@ struct chv_pinctrl {
|
||||||
struct pinctrl_desc pctldesc;
|
struct pinctrl_desc pctldesc;
|
||||||
struct pinctrl_dev *pctldev;
|
struct pinctrl_dev *pctldev;
|
||||||
struct gpio_chip chip;
|
struct gpio_chip chip;
|
||||||
|
struct irq_chip irqchip;
|
||||||
void __iomem *regs;
|
void __iomem *regs;
|
||||||
unsigned intr_lines[16];
|
unsigned intr_lines[16];
|
||||||
const struct chv_community *community;
|
const struct chv_community *community;
|
||||||
|
@ -1466,16 +1468,6 @@ static int chv_gpio_irq_type(struct irq_data *d, unsigned int type)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct irq_chip chv_gpio_irqchip = {
|
|
||||||
.name = "chv-gpio",
|
|
||||||
.irq_startup = chv_gpio_irq_startup,
|
|
||||||
.irq_ack = chv_gpio_irq_ack,
|
|
||||||
.irq_mask = chv_gpio_irq_mask,
|
|
||||||
.irq_unmask = chv_gpio_irq_unmask,
|
|
||||||
.irq_set_type = chv_gpio_irq_type,
|
|
||||||
.flags = IRQCHIP_SKIP_SET_WAKE,
|
|
||||||
};
|
|
||||||
|
|
||||||
static void chv_gpio_irq_handler(struct irq_desc *desc)
|
static void chv_gpio_irq_handler(struct irq_desc *desc)
|
||||||
{
|
{
|
||||||
struct gpio_chip *gc = irq_desc_get_handler_data(desc);
|
struct gpio_chip *gc = irq_desc_get_handler_data(desc);
|
||||||
|
@ -1559,7 +1551,7 @@ static void chv_init_irq_valid_mask(struct gpio_chip *chip,
|
||||||
intsel >>= CHV_PADCTRL0_INTSEL_SHIFT;
|
intsel >>= CHV_PADCTRL0_INTSEL_SHIFT;
|
||||||
|
|
||||||
if (intsel >= community->nirqs)
|
if (intsel >= community->nirqs)
|
||||||
clear_bit(i, valid_mask);
|
clear_bit(desc->number, valid_mask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1625,7 +1617,15 @@ static int chv_gpio_probe(struct chv_pinctrl *pctrl, int irq)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = gpiochip_irqchip_add(chip, &chv_gpio_irqchip, 0,
|
pctrl->irqchip.name = "chv-gpio";
|
||||||
|
pctrl->irqchip.irq_startup = chv_gpio_irq_startup;
|
||||||
|
pctrl->irqchip.irq_ack = chv_gpio_irq_ack;
|
||||||
|
pctrl->irqchip.irq_mask = chv_gpio_irq_mask;
|
||||||
|
pctrl->irqchip.irq_unmask = chv_gpio_irq_unmask;
|
||||||
|
pctrl->irqchip.irq_set_type = chv_gpio_irq_type;
|
||||||
|
pctrl->irqchip.flags = IRQCHIP_SKIP_SET_WAKE;
|
||||||
|
|
||||||
|
ret = gpiochip_irqchip_add(chip, &pctrl->irqchip, 0,
|
||||||
handle_bad_irq, IRQ_TYPE_NONE);
|
handle_bad_irq, IRQ_TYPE_NONE);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(pctrl->dev, "failed to add IRQ chip\n");
|
dev_err(pctrl->dev, "failed to add IRQ chip\n");
|
||||||
|
@ -1642,7 +1642,7 @@ static int chv_gpio_probe(struct chv_pinctrl *pctrl, int irq)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gpiochip_set_chained_irqchip(chip, &chv_gpio_irqchip, irq,
|
gpiochip_set_chained_irqchip(chip, &pctrl->irqchip, irq,
|
||||||
chv_gpio_irq_handler);
|
chv_gpio_irq_handler);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,7 @@
|
||||||
#define PADCFG0_GPIROUTNMI BIT(17)
|
#define PADCFG0_GPIROUTNMI BIT(17)
|
||||||
#define PADCFG0_PMODE_SHIFT 10
|
#define PADCFG0_PMODE_SHIFT 10
|
||||||
#define PADCFG0_PMODE_MASK GENMASK(13, 10)
|
#define PADCFG0_PMODE_MASK GENMASK(13, 10)
|
||||||
|
#define PADCFG0_PMODE_GPIO 0
|
||||||
#define PADCFG0_GPIORXDIS BIT(9)
|
#define PADCFG0_GPIORXDIS BIT(9)
|
||||||
#define PADCFG0_GPIOTXDIS BIT(8)
|
#define PADCFG0_GPIOTXDIS BIT(8)
|
||||||
#define PADCFG0_GPIORXSTATE BIT(1)
|
#define PADCFG0_GPIORXSTATE BIT(1)
|
||||||
|
@ -332,7 +333,7 @@ static void intel_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s,
|
||||||
cfg1 = readl(intel_get_padcfg(pctrl, pin, PADCFG1));
|
cfg1 = readl(intel_get_padcfg(pctrl, pin, PADCFG1));
|
||||||
|
|
||||||
mode = (cfg0 & PADCFG0_PMODE_MASK) >> PADCFG0_PMODE_SHIFT;
|
mode = (cfg0 & PADCFG0_PMODE_MASK) >> PADCFG0_PMODE_SHIFT;
|
||||||
if (!mode)
|
if (mode == PADCFG0_PMODE_GPIO)
|
||||||
seq_puts(s, "GPIO ");
|
seq_puts(s, "GPIO ");
|
||||||
else
|
else
|
||||||
seq_printf(s, "mode %d ", mode);
|
seq_printf(s, "mode %d ", mode);
|
||||||
|
@ -458,6 +459,11 @@ static void __intel_gpio_set_direction(void __iomem *padcfg0, bool input)
|
||||||
writel(value, padcfg0);
|
writel(value, padcfg0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int intel_gpio_get_gpio_mode(void __iomem *padcfg0)
|
||||||
|
{
|
||||||
|
return (readl(padcfg0) & PADCFG0_PMODE_MASK) >> PADCFG0_PMODE_SHIFT;
|
||||||
|
}
|
||||||
|
|
||||||
static void intel_gpio_set_gpio_mode(void __iomem *padcfg0)
|
static void intel_gpio_set_gpio_mode(void __iomem *padcfg0)
|
||||||
{
|
{
|
||||||
u32 value;
|
u32 value;
|
||||||
|
@ -491,7 +497,20 @@ static int intel_gpio_request_enable(struct pinctrl_dev *pctldev,
|
||||||
}
|
}
|
||||||
|
|
||||||
padcfg0 = intel_get_padcfg(pctrl, pin, PADCFG0);
|
padcfg0 = intel_get_padcfg(pctrl, pin, PADCFG0);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If pin is already configured in GPIO mode, we assume that
|
||||||
|
* firmware provides correct settings. In such case we avoid
|
||||||
|
* potential glitches on the pin. Otherwise, for the pin in
|
||||||
|
* alternative mode, consumer has to supply respective flags.
|
||||||
|
*/
|
||||||
|
if (intel_gpio_get_gpio_mode(padcfg0) == PADCFG0_PMODE_GPIO) {
|
||||||
|
raw_spin_unlock_irqrestore(&pctrl->lock, flags);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
intel_gpio_set_gpio_mode(padcfg0);
|
intel_gpio_set_gpio_mode(padcfg0);
|
||||||
|
|
||||||
/* Disable TX buffer and enable RX (this will be input) */
|
/* Disable TX buffer and enable RX (this will be input) */
|
||||||
__intel_gpio_set_direction(padcfg0, true);
|
__intel_gpio_set_direction(padcfg0, true);
|
||||||
|
|
||||||
|
|
|
@ -585,19 +585,6 @@ static int stmfx_pinctrl_gpio_function_enable(struct stmfx_pinctrl *pctl)
|
||||||
return stmfx_function_enable(pctl->stmfx, func);
|
return stmfx_function_enable(pctl->stmfx, func);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int stmfx_pinctrl_gpio_init_valid_mask(struct gpio_chip *gc,
|
|
||||||
unsigned long *valid_mask,
|
|
||||||
unsigned int ngpios)
|
|
||||||
{
|
|
||||||
struct stmfx_pinctrl *pctl = gpiochip_get_data(gc);
|
|
||||||
u32 n;
|
|
||||||
|
|
||||||
for_each_clear_bit(n, &pctl->gpio_valid_mask, ngpios)
|
|
||||||
clear_bit(n, valid_mask);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int stmfx_pinctrl_probe(struct platform_device *pdev)
|
static int stmfx_pinctrl_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct stmfx *stmfx = dev_get_drvdata(pdev->dev.parent);
|
struct stmfx *stmfx = dev_get_drvdata(pdev->dev.parent);
|
||||||
|
@ -660,7 +647,6 @@ static int stmfx_pinctrl_probe(struct platform_device *pdev)
|
||||||
pctl->gpio_chip.ngpio = pctl->pctl_desc.npins;
|
pctl->gpio_chip.ngpio = pctl->pctl_desc.npins;
|
||||||
pctl->gpio_chip.can_sleep = true;
|
pctl->gpio_chip.can_sleep = true;
|
||||||
pctl->gpio_chip.of_node = np;
|
pctl->gpio_chip.of_node = np;
|
||||||
pctl->gpio_chip.init_valid_mask = stmfx_pinctrl_gpio_init_valid_mask;
|
|
||||||
|
|
||||||
ret = devm_gpiochip_add_data(pctl->dev, &pctl->gpio_chip, pctl);
|
ret = devm_gpiochip_add_data(pctl->dev, &pctl->gpio_chip, pctl);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
|
Loading…
Reference in New Issue