Commit 563532b4 authored by Andy Shevchenko's avatar Andy Shevchenko
Browse files

Merge patch series "Reuse common functions from pinctrl-intel"

Raag Jadav <raag.jadav@intel.com> says:

This series exports common pinctrl functions that are used across
Intel specific platform drivers to PINCTRL_INTEL namespace and
reuses them into Baytrail, Cherryview and Lynxpoint drivers.
This helps reduce their code and memory footprint.

X86 kernels are fairly unikernels such that pinctrl-intel driver is
enabled by most Linux distributions and most Intel specific platform
drivers (inside drivers/pinctrl/intel) depend on it.

The only exception to this is Lynxpoint. But taking into account its
fairly old age, it wouldn't suffer much from pinctrl-intel dependency.

bloat-o-meter:
==============

Intel:
add/remove: 17/10 grow/shrink: 0/0 up/down: 375/-319 (56)
Total: Before=9598, After=9654, chg +0.58%

Baytrail:
add/remove: 1/6 grow/shrink: 0/2 up/down: 41/-441 (-400)
Total: Before=16538, After=16138, chg -2.42%

Cherryview:
add/remove: 1/6 grow/shrink: 2/0 up/down: 90/-272 (-182)
Total: Before=18133, After=17951, chg -1.00%

Lynxpoint:
add/remove: 1/6 grow/shrink: 0/1 up/down: 24/-354 (-330)
Total: Before=7836, After=7506, chg -4.21%

Link: https://lore.kernel.org/r/20230814060311.15945-1-raag.jadav@intel.com


Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
parents e4e17186 976cf4a6
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -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
+11 −79
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
@@ -551,25 +552,10 @@ static const struct intel_pinctrl_soc_data *byt_soc_data[] = {

static DEFINE_RAW_SPINLOCK(byt_lock);

static struct intel_community *byt_get_community(struct intel_pinctrl *vg,
						 unsigned int pin)
{
	struct intel_community *comm;
	int i;

	for (i = 0; i < vg->ncommunities; i++) {
		comm = vg->communities + i;
		if (pin < comm->pin_base + comm->npins && pin >= comm->pin_base)
			return comm;
	}

	return NULL;
}

static void __iomem *byt_gpio_reg(struct intel_pinctrl *vg, unsigned int offset,
				  int reg)
{
	struct intel_community *comm = byt_get_community(vg, offset);
	struct intel_community *comm = intel_get_community(vg, offset);
	u32 reg_offset;

	if (!comm)
@@ -591,68 +577,12 @@ static void __iomem *byt_gpio_reg(struct intel_pinctrl *vg, unsigned int offset,
	return comm->pad_regs + reg_offset + reg;
}

static int byt_get_groups_count(struct pinctrl_dev *pctldev)
{
	struct intel_pinctrl *vg = pinctrl_dev_get_drvdata(pctldev);

	return vg->soc->ngroups;
}

static const char *byt_get_group_name(struct pinctrl_dev *pctldev,
				      unsigned int selector)
{
	struct intel_pinctrl *vg = pinctrl_dev_get_drvdata(pctldev);

	return vg->soc->groups[selector].grp.name;
}

static int byt_get_group_pins(struct pinctrl_dev *pctldev,
			      unsigned int selector,
			      const unsigned int **pins,
			      unsigned int *num_pins)
{
	struct intel_pinctrl *vg = pinctrl_dev_get_drvdata(pctldev);

	*pins		= vg->soc->groups[selector].grp.pins;
	*num_pins	= vg->soc->groups[selector].grp.npins;

	return 0;
}

static const struct pinctrl_ops byt_pinctrl_ops = {
	.get_groups_count	= byt_get_groups_count,
	.get_group_name		= byt_get_group_name,
	.get_group_pins		= byt_get_group_pins,
	.get_groups_count	= intel_get_groups_count,
	.get_group_name		= intel_get_group_name,
	.get_group_pins		= intel_get_group_pins,
};

static int byt_get_functions_count(struct pinctrl_dev *pctldev)
{
	struct intel_pinctrl *vg = pinctrl_dev_get_drvdata(pctldev);

	return vg->soc->nfunctions;
}

static const char *byt_get_function_name(struct pinctrl_dev *pctldev,
					 unsigned int selector)
{
	struct intel_pinctrl *vg = pinctrl_dev_get_drvdata(pctldev);

	return vg->soc->functions[selector].func.name;
}

static int byt_get_function_groups(struct pinctrl_dev *pctldev,
				   unsigned int selector,
				   const char * const **groups,
				   unsigned int *ngroups)
{
	struct intel_pinctrl *vg = pinctrl_dev_get_drvdata(pctldev);

	*groups		= vg->soc->functions[selector].func.groups;
	*ngroups	= vg->soc->functions[selector].func.ngroups;

	return 0;
}

static void byt_set_group_simple_mux(struct intel_pinctrl *vg,
				     const struct intel_pingroup group,
				     unsigned int func)
@@ -851,9 +781,9 @@ static int byt_gpio_set_direction(struct pinctrl_dev *pctl_dev,
}

static const struct pinmux_ops byt_pinmux_ops = {
	.get_functions_count	= byt_get_functions_count,
	.get_function_name	= byt_get_function_name,
	.get_function_groups	= byt_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		= byt_set_mux,
	.gpio_request_enable	= byt_gpio_request_enable,
	.gpio_disable_free	= byt_gpio_disable_free,
@@ -1261,7 +1191,7 @@ static void byt_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
		val = readl(val_reg);
		raw_spin_unlock_irqrestore(&byt_lock, flags);

		comm = byt_get_community(vg, pin);
		comm = intel_get_community(vg, pin);
		if (!comm) {
			seq_printf(s, "Pin %i: can't retrieve community\n", pin);
			continue;
@@ -1848,3 +1778,5 @@ static int __init byt_gpio_init(void)
	return platform_driver_register(&byt_gpio_driver);
}
subsys_initcall(byt_gpio_init);

MODULE_IMPORT_NS(PINCTRL_INTEL);
+9 −60
Original line number Diff line number Diff line
@@ -617,31 +617,6 @@ static bool chv_pad_locked(struct intel_pinctrl *pctrl, unsigned int offset)
	return chv_readl(pctrl, offset, CHV_PADCTRL1) & CHV_PADCTRL1_CFGLOCK;
}

static int chv_get_groups_count(struct pinctrl_dev *pctldev)
{
	struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);

	return pctrl->soc->ngroups;
}

static const char *chv_get_group_name(struct pinctrl_dev *pctldev,
				      unsigned int group)
{
	struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);

	return pctrl->soc->groups[group].grp.name;
}

static int chv_get_group_pins(struct pinctrl_dev *pctldev, unsigned int group,
			      const unsigned int **pins, unsigned int *npins)
{
	struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);

	*pins = pctrl->soc->groups[group].grp.pins;
	*npins = pctrl->soc->groups[group].grp.npins;
	return 0;
}

static void chv_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s,
			     unsigned int offset)
{
@@ -676,39 +651,12 @@ static void chv_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s,
}

static const struct pinctrl_ops chv_pinctrl_ops = {
	.get_groups_count = chv_get_groups_count,
	.get_group_name = chv_get_group_name,
	.get_group_pins = chv_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 = chv_pin_dbg_show,
};

static int chv_get_functions_count(struct pinctrl_dev *pctldev)
{
	struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);

	return pctrl->soc->nfunctions;
}

static const char *chv_get_function_name(struct pinctrl_dev *pctldev,
					 unsigned int function)
{
	struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);

	return pctrl->soc->functions[function].func.name;
}

static int chv_get_function_groups(struct pinctrl_dev *pctldev,
				   unsigned int function,
				   const char * const **groups,
				   unsigned int * const ngroups)
{
	struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);

	*groups = pctrl->soc->functions[function].func.groups;
	*ngroups = pctrl->soc->functions[function].func.ngroups;
	return 0;
}

static int chv_pinmux_set_mux(struct pinctrl_dev *pctldev,
			      unsigned int function, unsigned int group)
{
@@ -884,9 +832,9 @@ static int chv_gpio_set_direction(struct pinctrl_dev *pctldev,
}

static const struct pinmux_ops chv_pinmux_ops = {
	.get_functions_count = chv_get_functions_count,
	.get_function_name = chv_get_function_name,
	.get_function_groups = chv_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 = chv_pinmux_set_mux,
	.gpio_request_enable = chv_gpio_request_enable,
	.gpio_disable_free = chv_gpio_disable_free,
@@ -1118,7 +1066,7 @@ static int chv_config_group_get(struct pinctrl_dev *pctldev,
	unsigned int npins;
	int ret;

	ret = chv_get_group_pins(pctldev, group, &pins, &npins);
	ret = intel_get_group_pins(pctldev, group, &pins, &npins);
	if (ret)
		return ret;

@@ -1137,7 +1085,7 @@ static int chv_config_group_set(struct pinctrl_dev *pctldev,
	unsigned int npins;
	int i, ret;

	ret = chv_get_group_pins(pctldev, group, &pins, &npins);
	ret = intel_get_group_pins(pctldev, group, &pins, &npins);
	if (ret)
		return ret;

@@ -1915,3 +1863,4 @@ module_exit(chv_pinctrl_exit);
MODULE_AUTHOR("Mika Westerberg <mika.westerberg@linux.intel.com>");
MODULE_DESCRIPTION("Intel Cherryview/Braswell pinctrl driver");
MODULE_LICENSE("GPL v2");
MODULE_IMPORT_NS(PINCTRL_INTEL);
+16 −14
Original line number Diff line number Diff line
@@ -107,8 +107,7 @@ struct intel_community_context {
#define pin_to_padno(c, p)	((p) - (c)->pin_base)
#define padgroup_offset(g, p)	((p) - (g)->base)

static struct intel_community *intel_get_community(struct intel_pinctrl *pctrl,
						   unsigned int pin)
struct intel_community *intel_get_community(struct intel_pinctrl *pctrl, unsigned int pin)
{
	struct intel_community *community;
	int i;
@@ -123,6 +122,7 @@ static struct intel_community *intel_get_community(struct intel_pinctrl *pctrl,
	dev_warn(pctrl->dev, "failed to find community for pin %u\n", pin);
	return NULL;
}
EXPORT_SYMBOL_NS_GPL(intel_get_community, PINCTRL_INTEL);

static const struct intel_padgroup *
intel_community_get_padgroup(const struct intel_community *community,
@@ -276,22 +276,23 @@ static bool intel_pad_usable(struct intel_pinctrl *pctrl, unsigned int pin)
	return intel_pad_owned_by_host(pctrl, pin) && intel_pad_is_unlocked(pctrl, pin);
}

static int intel_get_groups_count(struct pinctrl_dev *pctldev)
int intel_get_groups_count(struct pinctrl_dev *pctldev)
{
	struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);

	return pctrl->soc->ngroups;
}
EXPORT_SYMBOL_NS_GPL(intel_get_groups_count, PINCTRL_INTEL);

static const char *intel_get_group_name(struct pinctrl_dev *pctldev,
				      unsigned int group)
const char *intel_get_group_name(struct pinctrl_dev *pctldev, unsigned int group)
{
	struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);

	return pctrl->soc->groups[group].grp.name;
}
EXPORT_SYMBOL_NS_GPL(intel_get_group_name, PINCTRL_INTEL);

static int intel_get_group_pins(struct pinctrl_dev *pctldev, unsigned int group,
int intel_get_group_pins(struct pinctrl_dev *pctldev, unsigned int group,
			 const unsigned int **pins, unsigned int *npins)
{
	struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
@@ -300,6 +301,7 @@ static int intel_get_group_pins(struct pinctrl_dev *pctldev, unsigned int group,
	*npins = pctrl->soc->groups[group].grp.npins;
	return 0;
}
EXPORT_SYMBOL_NS_GPL(intel_get_group_pins, PINCTRL_INTEL);

static void intel_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s,
			       unsigned int pin)
@@ -359,25 +361,24 @@ static const struct pinctrl_ops intel_pinctrl_ops = {
	.pin_dbg_show = intel_pin_dbg_show,
};

static int intel_get_functions_count(struct pinctrl_dev *pctldev)
int intel_get_functions_count(struct pinctrl_dev *pctldev)
{
	struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);

	return pctrl->soc->nfunctions;
}
EXPORT_SYMBOL_NS_GPL(intel_get_functions_count, PINCTRL_INTEL);

static const char *intel_get_function_name(struct pinctrl_dev *pctldev,
					   unsigned int function)
const char *intel_get_function_name(struct pinctrl_dev *pctldev, unsigned int function)
{
	struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);

	return pctrl->soc->functions[function].func.name;
}
EXPORT_SYMBOL_NS_GPL(intel_get_function_name, PINCTRL_INTEL);

static int intel_get_function_groups(struct pinctrl_dev *pctldev,
				     unsigned int function,
				     const char * const **groups,
				     unsigned int * const ngroups)
int intel_get_function_groups(struct pinctrl_dev *pctldev, unsigned int function,
			      const char * const **groups, unsigned int * const ngroups)
{
	struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);

@@ -385,6 +386,7 @@ static int intel_get_function_groups(struct pinctrl_dev *pctldev,
	*ngroups = pctrl->soc->functions[function].func.ngroups;
	return 0;
}
EXPORT_SYMBOL_NS_GPL(intel_get_function_groups, PINCTRL_INTEL);

static int intel_pinmux_set_mux(struct pinctrl_dev *pctldev,
				unsigned int function, unsigned int group)
+12 −0
Original line number Diff line number Diff line
@@ -266,4 +266,16 @@ const struct dev_pm_ops _name = { \
				      intel_pinctrl_resume_noirq)	\
}

struct intel_community *intel_get_community(struct intel_pinctrl *pctrl, unsigned int pin);

int intel_get_groups_count(struct pinctrl_dev *pctldev);
const char *intel_get_group_name(struct pinctrl_dev *pctldev, unsigned int group);
int intel_get_group_pins(struct pinctrl_dev *pctldev, unsigned int group,
			 const unsigned int **pins, unsigned int *npins);

int intel_get_functions_count(struct pinctrl_dev *pctldev);
const char *intel_get_function_name(struct pinctrl_dev *pctldev, unsigned int function);
int intel_get_function_groups(struct pinctrl_dev *pctldev, unsigned int function,
			      const char * const **groups, unsigned int * const ngroups);

#endif /* PINCTRL_INTEL_H */
Loading