pinctrl: lynxpoint: reuse common functions from pinctrl-intel
authorRaag Jadav <raag.jadav@intel.com>
Mon, 14 Aug 2023 06:03:11 +0000 (11:33 +0530)
committerAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Tue, 15 Aug 2023 14:33:42 +0000 (17:33 +0300)
Reuse common functions from pinctrl-intel driver.
While at it, select pinctrl-intel for Intel Lynxpoint driver.

Signed-off-by: Raag Jadav <raag.jadav@intel.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Link: https://lore.kernel.org/r/20230814060311.15945-5-raag.jadav@intel.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
drivers/pinctrl/intel/Kconfig
drivers/pinctrl/intel/pinctrl-lynxpoint.c

index b3ec0062441659d7daad96f0952af56b47e4fe20..b42148c828efcc11c6b4a9bf50d823d5a9ac022f 100644 (file)
@@ -26,11 +26,7 @@ config PINCTRL_CHERRYVIEW
 config PINCTRL_LYNXPOINT
        tristate "Intel Lynxpoint pinctrl and GPIO driver"
        depends on ACPI
-       select PINMUX
-       select PINCONF
-       select GENERIC_PINCONF
-       select GPIOLIB
-       select GPIOLIB_IRQCHIP
+       select PINCTRL_INTEL
        help
          Lynxpoint is the PCH of Intel Haswell. This pinctrl driver
          provides an interface that allows configuring of PCH pins and
index cdace55aaeac8163cc3004b386c42f6469886c11..780c9ab79d85b38695f16923c65f16a8a83d2ad7 100644 (file)
@@ -206,21 +206,6 @@ static const struct intel_pinctrl_soc_data lptlp_soc_data = {
  * IOxAPIC redirection map applies only for gpio 8-10, 13-14, 45-55.
  */
 
-static struct intel_community *lp_get_community(struct intel_pinctrl *lg,
-                                               unsigned int pin)
-{
-       struct intel_community *comm;
-       int i;
-
-       for (i = 0; i < lg->ncommunities; i++) {
-               comm = &lg->communities[i];
-               if (pin < comm->pin_base + comm->npins && pin >= comm->pin_base)
-                       return comm;
-       }
-
-       return NULL;
-}
-
 static void __iomem *lp_gpio_reg(struct gpio_chip *chip, unsigned int offset,
                                 int reg)
 {
@@ -228,7 +213,7 @@ static void __iomem *lp_gpio_reg(struct gpio_chip *chip, unsigned int offset,
        struct intel_community *comm;
        int reg_offset;
 
-       comm = lp_get_community(lg, offset);
+       comm = intel_get_community(lg, offset);
        if (!comm)
                return NULL;
 
@@ -272,34 +257,6 @@ static bool lp_gpio_ioxapic_use(struct gpio_chip *chip, unsigned int offset)
        return false;
 }
 
-static int lp_get_groups_count(struct pinctrl_dev *pctldev)
-{
-       struct intel_pinctrl *lg = pinctrl_dev_get_drvdata(pctldev);
-
-       return lg->soc->ngroups;
-}
-
-static const char *lp_get_group_name(struct pinctrl_dev *pctldev,
-                                    unsigned int selector)
-{
-       struct intel_pinctrl *lg = pinctrl_dev_get_drvdata(pctldev);
-
-       return lg->soc->groups[selector].grp.name;
-}
-
-static int lp_get_group_pins(struct pinctrl_dev *pctldev,
-                            unsigned int selector,
-                            const unsigned int **pins,
-                            unsigned int *num_pins)
-{
-       struct intel_pinctrl *lg = pinctrl_dev_get_drvdata(pctldev);
-
-       *pins           = lg->soc->groups[selector].grp.pins;
-       *num_pins       = lg->soc->groups[selector].grp.npins;
-
-       return 0;
-}
-
 static void lp_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s,
                            unsigned int pin)
 {
@@ -323,40 +280,12 @@ static void lp_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s,
 }
 
 static const struct pinctrl_ops lptlp_pinctrl_ops = {
-       .get_groups_count       = lp_get_groups_count,
-       .get_group_name         = lp_get_group_name,
-       .get_group_pins         = lp_get_group_pins,
+       .get_groups_count       = intel_get_groups_count,
+       .get_group_name         = intel_get_group_name,
+       .get_group_pins         = intel_get_group_pins,
        .pin_dbg_show           = lp_pin_dbg_show,
 };
 
-static int lp_get_functions_count(struct pinctrl_dev *pctldev)
-{
-       struct intel_pinctrl *lg = pinctrl_dev_get_drvdata(pctldev);
-
-       return lg->soc->nfunctions;
-}
-
-static const char *lp_get_function_name(struct pinctrl_dev *pctldev,
-                                       unsigned int selector)
-{
-       struct intel_pinctrl *lg = pinctrl_dev_get_drvdata(pctldev);
-
-       return lg->soc->functions[selector].func.name;
-}
-
-static int lp_get_function_groups(struct pinctrl_dev *pctldev,
-                                 unsigned int selector,
-                                 const char * const **groups,
-                                 unsigned int *ngroups)
-{
-       struct intel_pinctrl *lg = pinctrl_dev_get_drvdata(pctldev);
-
-       *groups         = lg->soc->functions[selector].func.groups;
-       *ngroups        = lg->soc->functions[selector].func.ngroups;
-
-       return 0;
-}
-
 static int lp_pinmux_set_mux(struct pinctrl_dev *pctldev,
                             unsigned int function, unsigned int group)
 {
@@ -481,9 +410,9 @@ static int lp_gpio_set_direction(struct pinctrl_dev *pctldev,
 }
 
 static const struct pinmux_ops lptlp_pinmux_ops = {
-       .get_functions_count    = lp_get_functions_count,
-       .get_function_name      = lp_get_function_name,
-       .get_function_groups    = lp_get_function_groups,
+       .get_functions_count    = intel_get_functions_count,
+       .get_function_name      = intel_get_function_name,
+       .get_function_groups    = intel_get_function_groups,
        .set_mux                = lp_pinmux_set_mux,
        .gpio_request_enable    = lp_gpio_request_enable,
        .gpio_disable_free      = lp_gpio_disable_free,
@@ -987,3 +916,4 @@ MODULE_AUTHOR("Andy Shevchenko (Intel)");
 MODULE_DESCRIPTION("Intel Lynxpoint pinctrl driver");
 MODULE_LICENSE("GPL v2");
 MODULE_ALIAS("platform:lp_gpio");
+MODULE_IMPORT_NS(PINCTRL_INTEL);