intel-pinctrl fixes for v5.4 part 2
A couple more fixes for Intel pinctrl drivers: - Try to avoid glitches when pin is in GPIO mode - Fix cherryview irq_valid_mask calculation - Allocate cherryview IRQ chip dynamically to avoid triggering warning from GPIO core -----BEGIN PGP SIGNATURE----- iQJUBAABCgA+FiEEVTdhRGBbNzLrSUBaAP2fSd+ZWKAFAl24fLkgHG1pa2Eud2Vz dGVyYmVyZ0BsaW51eC5pbnRlbC5jb20ACgkQAP2fSd+ZWKD0QxAAjyg4YGZ9kZD4 MztOOG/l8T+qPRvqg0vWg5yQCP8zcRA15kZ9ybMGHIl4nBPQ2sjfEd5Eu1iArUYt ieM/T4VJrnCAGJdwj522vLhEfAuaiymq8cAv1DcAk0bVTr/UF32KF5Pq9ZGAReHC MlkOXMOmihBZ7Oyc9ZMSP+yN122+TvLHmMREbigzyukwtCSNpIUjdu9g+qDRlM/e agxrN9sGPdLt/xQmPHrJwZ66Y1lHl4LkQIxRadr/3oLyg0u6fCkfB3IdXrL2qM+E QycJ1NjEgFQMJEJZGxL9jPVS4vzmH9B4oFAS8mAaqUyOi9LvTANKm/mdkYjtdfjC 9e4H+ReneSdtglH2m5fQ3I6zehuBGVbKHfdcLupYWLOyQ4uOepx8F8JgYDLXOSlS 1u0DGmxT4TS6+rbKlo05QVLS1xqRbkSgBUmxNTc84zEgnRDyyz4GFGM3ANWksX0a cATYOK2XViPGGFv733IRdy4rGGkYpV7T8nq/N0Pj12e+cPo27OiE93ouHrgi6Ovb 4OEbZPSTMwBQ46lZ9io3IEkMwSeN9AbO0u4+9zbN3sKZM89uzMnJeb4IPeUfGLVc d691Bb1TtSVqtZuXr0Y4d4ou3D3s1AwICHQ3+4dmX2992dJUZyAAJB67fqzb9gbF VWLyWdKCu/nl+BT5QYU5t7S0BzdpCQs= =3AVf -----END PGP SIGNATURE----- Merge tag 'intel-pinctrl-fixes-v5.4-2' of git://git.kernel.org/pub/scm/linux/kernel/git/pinctrl/intel into fixes intel-pinctrl fixes for v5.4 part 2 A couple more fixes for Intel pinctrl drivers: - Try to avoid glitches when pin is in GPIO mode - Fix cherryview irq_valid_mask calculation - Allocate cherryview IRQ chip dynamically to avoid triggering warning from GPIO core
This commit is contained in:
commit
451a59bd1f
|
@ -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);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue