From e7ce0b02cc72567f2a9acbc13c6af0622f0a0c5b Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Fri, 2 Mar 2018 11:19:44 +0000 Subject: [PATCH] pinctrl: madera: Add support for cs47l15 Change-Id: I75bfd5405cb5f9c3f2acdf8302ed933a067a74ff Signed-off-by: Charles Keepax --- drivers/pinctrl/cirrus/Kconfig | 3 ++ drivers/pinctrl/cirrus/Makefile | 3 ++ drivers/pinctrl/cirrus/pinctrl-cs47l15.c | 44 ++++++++++++++++++++++++ drivers/pinctrl/cirrus/pinctrl-madera.c | 4 +++ drivers/pinctrl/cirrus/pinctrl-madera.h | 1 + 5 files changed, 55 insertions(+) create mode 100644 drivers/pinctrl/cirrus/pinctrl-cs47l15.c diff --git a/drivers/pinctrl/cirrus/Kconfig b/drivers/pinctrl/cirrus/Kconfig index 20c437521f5c..5c5510a6ce00 100644 --- a/drivers/pinctrl/cirrus/Kconfig +++ b/drivers/pinctrl/cirrus/Kconfig @@ -4,6 +4,9 @@ config PINCTRL_MADERA select GENERIC_PINCONF default y if MFD_MADERA=y +config PINCTRL_CS47L15 + bool + config PINCTRL_CS47L35 bool diff --git a/drivers/pinctrl/cirrus/Makefile b/drivers/pinctrl/cirrus/Makefile index f5b973b77c8d..c1f9b0502bb0 100644 --- a/drivers/pinctrl/cirrus/Makefile +++ b/drivers/pinctrl/cirrus/Makefile @@ -1,5 +1,8 @@ # Cirrus Logic pinctrl drivers obj-$(CONFIG_PINCTRL_MADERA) += pinctrl-madera.o +ifeq ($(CONFIG_PINCTRL_CS47L15),y) +obj-$(CONFIG_PINCTRL_MADERA) += pinctrl-cs47l15.o +endif ifeq ($(CONFIG_PINCTRL_CS47L35),y) obj-$(CONFIG_PINCTRL_MADERA) += pinctrl-cs47l35.o endif diff --git a/drivers/pinctrl/cirrus/pinctrl-cs47l15.c b/drivers/pinctrl/cirrus/pinctrl-cs47l15.c new file mode 100644 index 000000000000..069b037b8c81 --- /dev/null +++ b/drivers/pinctrl/cirrus/pinctrl-cs47l15.c @@ -0,0 +1,44 @@ +/* + * Pinctrl for Cirrus Logic CS47L15 + * + * Copyright 2018 Cirrus Logic + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include + +#include + +#include "pinctrl-madera.h" + +/* + * The alt func groups are the most commonly used functions we place these at + * the lower function indexes for convenience, and the less commonly used gpio + * functions at higher indexes. + * + * To stay consistent with the datasheet the function names are the same as + * the group names for that function's pins + * + * Note - all 1 less than in datasheet because these are zero-indexed + */ +static const unsigned int cs47l15_aif1_pins[] = { 0, 1, 2, 3 }; +static const unsigned int cs47l15_aif2_pins[] = { 4, 5, 6, 7 }; +static const unsigned int cs47l15_aif3_pins[] = { 8, 9, 10, 11 }; +static const unsigned int cs47l15_spk1_pins[] = { 12, 13, 14 }; + +static const struct madera_pin_groups cs47l15_pin_groups[] = { + { "aif1", cs47l15_aif1_pins, ARRAY_SIZE(cs47l15_aif1_pins) }, + { "aif2", cs47l15_aif2_pins, ARRAY_SIZE(cs47l15_aif2_pins) }, + { "aif3", cs47l15_aif3_pins, ARRAY_SIZE(cs47l15_aif3_pins) }, + { "pdmspk1", cs47l15_spk1_pins, ARRAY_SIZE(cs47l15_spk1_pins) }, +}; + +const struct madera_pin_chip cs47l15_pin_chip = { + .n_pins = CS47L15_NUM_GPIOS, + .pin_groups = cs47l15_pin_groups, + .n_pin_groups = ARRAY_SIZE(cs47l15_pin_groups), +}; diff --git a/drivers/pinctrl/cirrus/pinctrl-madera.c b/drivers/pinctrl/cirrus/pinctrl-madera.c index 451d4df9d415..1869d58e130c 100644 --- a/drivers/pinctrl/cirrus/pinctrl-madera.c +++ b/drivers/pinctrl/cirrus/pinctrl-madera.c @@ -1014,6 +1014,10 @@ static int madera_pin_probe(struct platform_device *pdev) pdev->dev.of_node = madera->dev->of_node; switch (madera->type) { + case CS47L15: + if (IS_ENABLED(CONFIG_PINCTRL_CS47L15)) + priv->chip = &cs47l15_pin_chip; + break; case CS47L35: if (IS_ENABLED(CONFIG_PINCTRL_CS47L35)) priv->chip = &cs47l35_pin_chip; diff --git a/drivers/pinctrl/cirrus/pinctrl-madera.h b/drivers/pinctrl/cirrus/pinctrl-madera.h index 21aacd544e23..1d6c954f67dd 100644 --- a/drivers/pinctrl/cirrus/pinctrl-madera.h +++ b/drivers/pinctrl/cirrus/pinctrl-madera.h @@ -33,6 +33,7 @@ struct madera_pin_private { struct pinctrl_dev *pctl; }; +extern const struct madera_pin_chip cs47l15_pin_chip; extern const struct madera_pin_chip cs47l35_pin_chip; extern const struct madera_pin_chip cs47l85_pin_chip; extern const struct madera_pin_chip cs47l90_pin_chip; -- 2.20.1