@@ -577,43 +577,6 @@ static const struct pinctrl_desc lptlp_pinctrl_desc = {
577
577
.owner = THIS_MODULE ,
578
578
};
579
579
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
-
617
580
static int lp_gpio_get (struct gpio_chip * chip , unsigned int offset )
618
581
{
619
582
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)
638
601
639
602
static int lp_gpio_direction_input (struct gpio_chip * chip , unsigned int offset )
640
603
{
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 );
650
605
}
651
606
652
607
static int lp_gpio_direction_output (struct gpio_chip * chip , unsigned int offset ,
653
608
int value )
654
609
{
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
-
659
610
lp_gpio_set (chip , offset , value );
660
611
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 );
666
613
}
667
614
668
615
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)
874
821
lg -> pctldesc .pins = lg -> soc -> pins ;
875
822
lg -> pctldesc .npins = lg -> soc -> npins ;
876
823
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
+
877
830
platform_set_drvdata (pdev , lg );
878
831
879
832
io_rc = platform_get_resource (pdev , IORESOURCE_IO , 0 );
@@ -902,8 +855,8 @@ static int lp_gpio_probe(struct platform_device *pdev)
902
855
gc = & lg -> chip ;
903
856
gc -> label = dev_name (dev );
904
857
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 ;
907
860
gc -> direction_input = lp_gpio_direction_input ;
908
861
gc -> direction_output = lp_gpio_direction_output ;
909
862
gc -> get = lp_gpio_get ;
0 commit comments