Skip to content

Commit 563532b

Browse files
committed
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: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2 parents e4e1718 + 976cf4a commit 563532b

File tree

6 files changed

+57
-236
lines changed

6 files changed

+57
-236
lines changed

drivers/pinctrl/intel/Kconfig

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@ config PINCTRL_CHERRYVIEW
2626
config PINCTRL_LYNXPOINT
2727
tristate "Intel Lynxpoint pinctrl and GPIO driver"
2828
depends on ACPI
29-
select PINMUX
30-
select PINCONF
31-
select GENERIC_PINCONF
32-
select GPIOLIB
33-
select GPIOLIB_IRQCHIP
29+
select PINCTRL_INTEL
3430
help
3531
Lynxpoint is the PCH of Intel Haswell. This pinctrl driver
3632
provides an interface that allows configuring of PCH pins and

drivers/pinctrl/intel/pinctrl-baytrail.c

Lines changed: 11 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/interrupt.h>
1414
#include <linux/io.h>
1515
#include <linux/kernel.h>
16+
#include <linux/module.h>
1617
#include <linux/types.h>
1718
#include <linux/platform_device.h>
1819
#include <linux/pm_runtime.h>
@@ -551,25 +552,10 @@ static const struct intel_pinctrl_soc_data *byt_soc_data[] = {
551552

552553
static DEFINE_RAW_SPINLOCK(byt_lock);
553554

554-
static struct intel_community *byt_get_community(struct intel_pinctrl *vg,
555-
unsigned int pin)
556-
{
557-
struct intel_community *comm;
558-
int i;
559-
560-
for (i = 0; i < vg->ncommunities; i++) {
561-
comm = vg->communities + i;
562-
if (pin < comm->pin_base + comm->npins && pin >= comm->pin_base)
563-
return comm;
564-
}
565-
566-
return NULL;
567-
}
568-
569555
static void __iomem *byt_gpio_reg(struct intel_pinctrl *vg, unsigned int offset,
570556
int reg)
571557
{
572-
struct intel_community *comm = byt_get_community(vg, offset);
558+
struct intel_community *comm = intel_get_community(vg, offset);
573559
u32 reg_offset;
574560

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

594-
static int byt_get_groups_count(struct pinctrl_dev *pctldev)
595-
{
596-
struct intel_pinctrl *vg = pinctrl_dev_get_drvdata(pctldev);
597-
598-
return vg->soc->ngroups;
599-
}
600-
601-
static const char *byt_get_group_name(struct pinctrl_dev *pctldev,
602-
unsigned int selector)
603-
{
604-
struct intel_pinctrl *vg = pinctrl_dev_get_drvdata(pctldev);
605-
606-
return vg->soc->groups[selector].grp.name;
607-
}
608-
609-
static int byt_get_group_pins(struct pinctrl_dev *pctldev,
610-
unsigned int selector,
611-
const unsigned int **pins,
612-
unsigned int *num_pins)
613-
{
614-
struct intel_pinctrl *vg = pinctrl_dev_get_drvdata(pctldev);
615-
616-
*pins = vg->soc->groups[selector].grp.pins;
617-
*num_pins = vg->soc->groups[selector].grp.npins;
618-
619-
return 0;
620-
}
621-
622580
static const struct pinctrl_ops byt_pinctrl_ops = {
623-
.get_groups_count = byt_get_groups_count,
624-
.get_group_name = byt_get_group_name,
625-
.get_group_pins = byt_get_group_pins,
581+
.get_groups_count = intel_get_groups_count,
582+
.get_group_name = intel_get_group_name,
583+
.get_group_pins = intel_get_group_pins,
626584
};
627585

628-
static int byt_get_functions_count(struct pinctrl_dev *pctldev)
629-
{
630-
struct intel_pinctrl *vg = pinctrl_dev_get_drvdata(pctldev);
631-
632-
return vg->soc->nfunctions;
633-
}
634-
635-
static const char *byt_get_function_name(struct pinctrl_dev *pctldev,
636-
unsigned int selector)
637-
{
638-
struct intel_pinctrl *vg = pinctrl_dev_get_drvdata(pctldev);
639-
640-
return vg->soc->functions[selector].func.name;
641-
}
642-
643-
static int byt_get_function_groups(struct pinctrl_dev *pctldev,
644-
unsigned int selector,
645-
const char * const **groups,
646-
unsigned int *ngroups)
647-
{
648-
struct intel_pinctrl *vg = pinctrl_dev_get_drvdata(pctldev);
649-
650-
*groups = vg->soc->functions[selector].func.groups;
651-
*ngroups = vg->soc->functions[selector].func.ngroups;
652-
653-
return 0;
654-
}
655-
656586
static void byt_set_group_simple_mux(struct intel_pinctrl *vg,
657587
const struct intel_pingroup group,
658588
unsigned int func)
@@ -851,9 +781,9 @@ static int byt_gpio_set_direction(struct pinctrl_dev *pctl_dev,
851781
}
852782

853783
static const struct pinmux_ops byt_pinmux_ops = {
854-
.get_functions_count = byt_get_functions_count,
855-
.get_function_name = byt_get_function_name,
856-
.get_function_groups = byt_get_function_groups,
784+
.get_functions_count = intel_get_functions_count,
785+
.get_function_name = intel_get_function_name,
786+
.get_function_groups = intel_get_function_groups,
857787
.set_mux = byt_set_mux,
858788
.gpio_request_enable = byt_gpio_request_enable,
859789
.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)
12611191
val = readl(val_reg);
12621192
raw_spin_unlock_irqrestore(&byt_lock, flags);
12631193

1264-
comm = byt_get_community(vg, pin);
1194+
comm = intel_get_community(vg, pin);
12651195
if (!comm) {
12661196
seq_printf(s, "Pin %i: can't retrieve community\n", pin);
12671197
continue;
@@ -1848,3 +1778,5 @@ static int __init byt_gpio_init(void)
18481778
return platform_driver_register(&byt_gpio_driver);
18491779
}
18501780
subsys_initcall(byt_gpio_init);
1781+
1782+
MODULE_IMPORT_NS(PINCTRL_INTEL);

drivers/pinctrl/intel/pinctrl-cherryview.c

Lines changed: 9 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -617,31 +617,6 @@ static bool chv_pad_locked(struct intel_pinctrl *pctrl, unsigned int offset)
617617
return chv_readl(pctrl, offset, CHV_PADCTRL1) & CHV_PADCTRL1_CFGLOCK;
618618
}
619619

620-
static int chv_get_groups_count(struct pinctrl_dev *pctldev)
621-
{
622-
struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
623-
624-
return pctrl->soc->ngroups;
625-
}
626-
627-
static const char *chv_get_group_name(struct pinctrl_dev *pctldev,
628-
unsigned int group)
629-
{
630-
struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
631-
632-
return pctrl->soc->groups[group].grp.name;
633-
}
634-
635-
static int chv_get_group_pins(struct pinctrl_dev *pctldev, unsigned int group,
636-
const unsigned int **pins, unsigned int *npins)
637-
{
638-
struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
639-
640-
*pins = pctrl->soc->groups[group].grp.pins;
641-
*npins = pctrl->soc->groups[group].grp.npins;
642-
return 0;
643-
}
644-
645620
static void chv_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s,
646621
unsigned int offset)
647622
{
@@ -676,39 +651,12 @@ static void chv_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s,
676651
}
677652

678653
static const struct pinctrl_ops chv_pinctrl_ops = {
679-
.get_groups_count = chv_get_groups_count,
680-
.get_group_name = chv_get_group_name,
681-
.get_group_pins = chv_get_group_pins,
654+
.get_groups_count = intel_get_groups_count,
655+
.get_group_name = intel_get_group_name,
656+
.get_group_pins = intel_get_group_pins,
682657
.pin_dbg_show = chv_pin_dbg_show,
683658
};
684659

685-
static int chv_get_functions_count(struct pinctrl_dev *pctldev)
686-
{
687-
struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
688-
689-
return pctrl->soc->nfunctions;
690-
}
691-
692-
static const char *chv_get_function_name(struct pinctrl_dev *pctldev,
693-
unsigned int function)
694-
{
695-
struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
696-
697-
return pctrl->soc->functions[function].func.name;
698-
}
699-
700-
static int chv_get_function_groups(struct pinctrl_dev *pctldev,
701-
unsigned int function,
702-
const char * const **groups,
703-
unsigned int * const ngroups)
704-
{
705-
struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
706-
707-
*groups = pctrl->soc->functions[function].func.groups;
708-
*ngroups = pctrl->soc->functions[function].func.ngroups;
709-
return 0;
710-
}
711-
712660
static int chv_pinmux_set_mux(struct pinctrl_dev *pctldev,
713661
unsigned int function, unsigned int group)
714662
{
@@ -884,9 +832,9 @@ static int chv_gpio_set_direction(struct pinctrl_dev *pctldev,
884832
}
885833

886834
static const struct pinmux_ops chv_pinmux_ops = {
887-
.get_functions_count = chv_get_functions_count,
888-
.get_function_name = chv_get_function_name,
889-
.get_function_groups = chv_get_function_groups,
835+
.get_functions_count = intel_get_functions_count,
836+
.get_function_name = intel_get_function_name,
837+
.get_function_groups = intel_get_function_groups,
890838
.set_mux = chv_pinmux_set_mux,
891839
.gpio_request_enable = chv_gpio_request_enable,
892840
.gpio_disable_free = chv_gpio_disable_free,
@@ -1118,7 +1066,7 @@ static int chv_config_group_get(struct pinctrl_dev *pctldev,
11181066
unsigned int npins;
11191067
int ret;
11201068

1121-
ret = chv_get_group_pins(pctldev, group, &pins, &npins);
1069+
ret = intel_get_group_pins(pctldev, group, &pins, &npins);
11221070
if (ret)
11231071
return ret;
11241072

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

1140-
ret = chv_get_group_pins(pctldev, group, &pins, &npins);
1088+
ret = intel_get_group_pins(pctldev, group, &pins, &npins);
11411089
if (ret)
11421090
return ret;
11431091

@@ -1915,3 +1863,4 @@ module_exit(chv_pinctrl_exit);
19151863
MODULE_AUTHOR("Mika Westerberg <mika.westerberg@linux.intel.com>");
19161864
MODULE_DESCRIPTION("Intel Cherryview/Braswell pinctrl driver");
19171865
MODULE_LICENSE("GPL v2");
1866+
MODULE_IMPORT_NS(PINCTRL_INTEL);

drivers/pinctrl/intel/pinctrl-intel.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ struct intel_community_context {
107107
#define pin_to_padno(c, p) ((p) - (c)->pin_base)
108108
#define padgroup_offset(g, p) ((p) - (g)->base)
109109

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

127127
static const struct intel_padgroup *
128128
intel_community_get_padgroup(const struct intel_community *community,
@@ -276,30 +276,32 @@ static bool intel_pad_usable(struct intel_pinctrl *pctrl, unsigned int pin)
276276
return intel_pad_owned_by_host(pctrl, pin) && intel_pad_is_unlocked(pctrl, pin);
277277
}
278278

279-
static int intel_get_groups_count(struct pinctrl_dev *pctldev)
279+
int intel_get_groups_count(struct pinctrl_dev *pctldev)
280280
{
281281
struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
282282

283283
return pctrl->soc->ngroups;
284284
}
285+
EXPORT_SYMBOL_NS_GPL(intel_get_groups_count, PINCTRL_INTEL);
285286

286-
static const char *intel_get_group_name(struct pinctrl_dev *pctldev,
287-
unsigned int group)
287+
const char *intel_get_group_name(struct pinctrl_dev *pctldev, unsigned int group)
288288
{
289289
struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
290290

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

294-
static int intel_get_group_pins(struct pinctrl_dev *pctldev, unsigned int group,
295-
const unsigned int **pins, unsigned int *npins)
295+
int intel_get_group_pins(struct pinctrl_dev *pctldev, unsigned int group,
296+
const unsigned int **pins, unsigned int *npins)
296297
{
297298
struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
298299

299300
*pins = pctrl->soc->groups[group].grp.pins;
300301
*npins = pctrl->soc->groups[group].grp.npins;
301302
return 0;
302303
}
304+
EXPORT_SYMBOL_NS_GPL(intel_get_group_pins, PINCTRL_INTEL);
303305

304306
static void intel_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s,
305307
unsigned int pin)
@@ -359,32 +361,32 @@ static const struct pinctrl_ops intel_pinctrl_ops = {
359361
.pin_dbg_show = intel_pin_dbg_show,
360362
};
361363

362-
static int intel_get_functions_count(struct pinctrl_dev *pctldev)
364+
int intel_get_functions_count(struct pinctrl_dev *pctldev)
363365
{
364366
struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
365367

366368
return pctrl->soc->nfunctions;
367369
}
370+
EXPORT_SYMBOL_NS_GPL(intel_get_functions_count, PINCTRL_INTEL);
368371

369-
static const char *intel_get_function_name(struct pinctrl_dev *pctldev,
370-
unsigned int function)
372+
const char *intel_get_function_name(struct pinctrl_dev *pctldev, unsigned int function)
371373
{
372374
struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
373375

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

377-
static int intel_get_function_groups(struct pinctrl_dev *pctldev,
378-
unsigned int function,
379-
const char * const **groups,
380-
unsigned int * const ngroups)
380+
int intel_get_function_groups(struct pinctrl_dev *pctldev, unsigned int function,
381+
const char * const **groups, unsigned int * const ngroups)
381382
{
382383
struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
383384

384385
*groups = pctrl->soc->functions[function].func.groups;
385386
*ngroups = pctrl->soc->functions[function].func.ngroups;
386387
return 0;
387388
}
389+
EXPORT_SYMBOL_NS_GPL(intel_get_function_groups, PINCTRL_INTEL);
388390

389391
static int intel_pinmux_set_mux(struct pinctrl_dev *pctldev,
390392
unsigned int function, unsigned int group)

drivers/pinctrl/intel/pinctrl-intel.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,4 +266,16 @@ const struct dev_pm_ops _name = { \
266266
intel_pinctrl_resume_noirq) \
267267
}
268268

269+
struct intel_community *intel_get_community(struct intel_pinctrl *pctrl, unsigned int pin);
270+
271+
int intel_get_groups_count(struct pinctrl_dev *pctldev);
272+
const char *intel_get_group_name(struct pinctrl_dev *pctldev, unsigned int group);
273+
int intel_get_group_pins(struct pinctrl_dev *pctldev, unsigned int group,
274+
const unsigned int **pins, unsigned int *npins);
275+
276+
int intel_get_functions_count(struct pinctrl_dev *pctldev);
277+
const char *intel_get_function_name(struct pinctrl_dev *pctldev, unsigned int function);
278+
int intel_get_function_groups(struct pinctrl_dev *pctldev, unsigned int function,
279+
const char * const **groups, unsigned int * const ngroups);
280+
269281
#endif /* PINCTRL_INTEL_H */

0 commit comments

Comments
 (0)