Skip to content

Commit 64e14e9

Browse files
committed
pinctrl: lynxpoint: Switch to pin control API
When all preparations are done, we may switch to pin control API. Reviewed-by: Linus Walleij <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]> Acked-by: Mika Westerberg <[email protected]>
1 parent 3683509 commit 64e14e9

File tree

2 files changed

+13
-57
lines changed

2 files changed

+13
-57
lines changed

drivers/pinctrl/intel/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ config PINCTRL_CHERRYVIEW
3434
config PINCTRL_LYNXPOINT
3535
tristate "Intel Lynxpoint pinctrl and GPIO driver"
3636
depends on ACPI
37+
select PINMUX
38+
select PINCONF
39+
select GENERIC_PINCONF
3740
select GPIOLIB
3841
select GPIOLIB_IRQCHIP
3942
help

drivers/pinctrl/intel/pinctrl-lynxpoint.c

Lines changed: 10 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -577,43 +577,6 @@ static const struct pinctrl_desc lptlp_pinctrl_desc = {
577577
.owner = THIS_MODULE,
578578
};
579579

580-
static int lp_gpio_request(struct gpio_chip *chip, unsigned int offset)
581-
{
582-
struct intel_pinctrl *lg = gpiochip_get_data(chip);
583-
void __iomem *reg = lp_gpio_reg(chip, offset, LP_CONFIG1);
584-
void __iomem *conf2 = lp_gpio_reg(chip, offset, LP_CONFIG2);
585-
u32 value;
586-
587-
pm_runtime_get(lg->dev); /* should we put if failed */
588-
589-
/*
590-
* Reconfigure pin to GPIO mode if needed and issue a warning,
591-
* since we expect firmware to configure it properly.
592-
*/
593-
value = ioread32(reg);
594-
if ((value & USE_SEL_MASK) != USE_SEL_GPIO) {
595-
iowrite32((value & USE_SEL_MASK) | USE_SEL_GPIO, reg);
596-
dev_warn(lg->dev, FW_BUG "pin %u forcibly reconfigured as GPIO\n", offset);
597-
}
598-
599-
/* enable input sensing */
600-
iowrite32(ioread32(conf2) & ~GPINDIS_BIT, conf2);
601-
602-
603-
return 0;
604-
}
605-
606-
static void lp_gpio_free(struct gpio_chip *chip, unsigned int offset)
607-
{
608-
struct intel_pinctrl *lg = gpiochip_get_data(chip);
609-
void __iomem *conf2 = lp_gpio_reg(chip, offset, LP_CONFIG2);
610-
611-
/* disable input sensing */
612-
iowrite32(ioread32(conf2) | GPINDIS_BIT, conf2);
613-
614-
pm_runtime_put(lg->dev);
615-
}
616-
617580
static int lp_gpio_get(struct gpio_chip *chip, unsigned int offset)
618581
{
619582
void __iomem *reg = lp_gpio_reg(chip, offset, LP_CONFIG1);
@@ -638,31 +601,15 @@ static void lp_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
638601

639602
static int lp_gpio_direction_input(struct gpio_chip *chip, unsigned int offset)
640603
{
641-
struct intel_pinctrl *lg = gpiochip_get_data(chip);
642-
void __iomem *reg = lp_gpio_reg(chip, offset, LP_CONFIG1);
643-
unsigned long flags;
644-
645-
raw_spin_lock_irqsave(&lg->lock, flags);
646-
iowrite32(ioread32(reg) | DIR_BIT, reg);
647-
raw_spin_unlock_irqrestore(&lg->lock, flags);
648-
649-
return 0;
604+
return pinctrl_gpio_direction_input(chip->base + offset);
650605
}
651606

652607
static int lp_gpio_direction_output(struct gpio_chip *chip, unsigned int offset,
653608
int value)
654609
{
655-
struct intel_pinctrl *lg = gpiochip_get_data(chip);
656-
void __iomem *reg = lp_gpio_reg(chip, offset, LP_CONFIG1);
657-
unsigned long flags;
658-
659610
lp_gpio_set(chip, offset, value);
660611

661-
raw_spin_lock_irqsave(&lg->lock, flags);
662-
iowrite32(ioread32(reg) & ~DIR_BIT, reg);
663-
raw_spin_unlock_irqrestore(&lg->lock, flags);
664-
665-
return 0;
612+
return pinctrl_gpio_direction_output(chip->base + offset);
666613
}
667614

668615
static int lp_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
@@ -874,6 +821,12 @@ static int lp_gpio_probe(struct platform_device *pdev)
874821
lg->pctldesc.pins = lg->soc->pins;
875822
lg->pctldesc.npins = lg->soc->npins;
876823

824+
lg->pctldev = devm_pinctrl_register(dev, &lg->pctldesc, lg);
825+
if (IS_ERR(lg->pctldev)) {
826+
dev_err(dev, "failed to register pinctrl driver\n");
827+
return PTR_ERR(lg->pctldev);
828+
}
829+
877830
platform_set_drvdata(pdev, lg);
878831

879832
io_rc = platform_get_resource(pdev, IORESOURCE_IO, 0);
@@ -902,8 +855,8 @@ static int lp_gpio_probe(struct platform_device *pdev)
902855
gc = &lg->chip;
903856
gc->label = dev_name(dev);
904857
gc->owner = THIS_MODULE;
905-
gc->request = lp_gpio_request;
906-
gc->free = lp_gpio_free;
858+
gc->request = gpiochip_generic_request;
859+
gc->free = gpiochip_generic_free;
907860
gc->direction_input = lp_gpio_direction_input;
908861
gc->direction_output = lp_gpio_direction_output;
909862
gc->get = lp_gpio_get;

0 commit comments

Comments
 (0)