[PATCH v7 03/17] mfd: madera: Add common support for Cirrus Logic Madera codecs

2018-01-15 Thread Richard Fitzgerald
This adds the generic core support for Cirrus Logic "Madera" class codecs.
These are complex audio codec SoCs with a variety of digital and analogue
I/O, onboard audio processing and DSPs, and other features.

These codecs are all based off a common set of hardware IP so can be
supported by a core of common code (with a few minor device-to-device
variations).

Signed-off-by: Charles Keepax 
Signed-off-by: Nikesh Oswal 
Signed-off-by: Richard Fitzgerald 
Acked-for-MFD-by: Lee Jones 
---
 MAINTAINERS  |   3 +
 drivers/mfd/Kconfig  |  27 ++
 drivers/mfd/Makefile |   4 +
 drivers/mfd/madera-core.c| 599 +++
 drivers/mfd/madera-i2c.c | 140 +
 drivers/mfd/madera-spi.c | 139 +
 drivers/mfd/madera.h |  44 +++
 include/linux/mfd/madera/core.h  | 196 +
 include/linux/mfd/madera/pdata.h |  61 
 9 files changed, 1213 insertions(+)
 create mode 100644 drivers/mfd/madera-core.c
 create mode 100644 drivers/mfd/madera-i2c.c
 create mode 100644 drivers/mfd/madera-spi.c
 create mode 100644 drivers/mfd/madera.h
 create mode 100644 include/linux/mfd/madera/core.h
 create mode 100644 include/linux/mfd/madera/pdata.h

diff --git a/MAINTAINERS b/MAINTAINERS
index d150555c328a..aa7f3a9dfa77 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3495,7 +3495,10 @@ L:   patc...@opensource.wolfsonmicro.com
 T: git https://github.com/CirrusLogic/linux-drivers.git
 W: https://github.com/CirrusLogic/linux-drivers/wiki
 S: Supported
+F: Documentation/devicetree/bindings/mfd/madera.txt
 F: include/linux/mfd/madera/*
+F: drivers/mfd/madera*
+F: drivers/mfd/cs47l*
 
 CLEANCACHE API
 M: Konrad Rzeszutek Wilk 
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index b860eb5aa194..8ea298bdcf58 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -232,6 +232,33 @@ config MFD_CROS_EC_CHARDEV
   If you have a supported Chromebook, choose Y or M here.
   The module will be called cros_ec_dev.
 
+config MFD_MADERA
+   bool
+   select MFD_CORE
+   select REGMAP
+   select REGMAP_IRQ
+   select MADERA_IRQ
+
+config MFD_MADERA_I2C
+   bool "Cirrus Logic Madera codecs with I2C"
+   select MFD_MADERA
+   select REGMAP_I2C
+   select PINCTRL
+   depends on I2C
+   help
+ Support for the Cirrus Logic Madera platform audio SoC
+ core functionality controlled via I2C.
+
+config MFD_MADERA_SPI
+   bool "Cirrus Logic Madera codecs with SPI"
+   select MFD_MADERA
+   select REGMAP_SPI
+   select PINCTRL
+   depends on SPI_MASTER
+   help
+ Support for the Cirrus Logic Madera platform audio SoC
+ core functionality controlled via SPI.
+
 config MFD_ASIC3
bool "Compaq ASIC3"
depends on GPIOLIB && ARM
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index d9d2cf0d32ef..1349e23e2be1 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -73,6 +73,10 @@ wm8994-objs  := wm8994-core.o wm8994-irq.o 
wm8994-regmap.o
 obj-$(CONFIG_MFD_WM8994)   += wm8994.o
 obj-$(CONFIG_MFD_WM97xx)   += wm97xx-core.o
 
+obj-$(CONFIG_MFD_MADERA)   += madera-core.o
+obj-$(CONFIG_MFD_MADERA_I2C)   += madera-i2c.o
+obj-$(CONFIG_MFD_MADERA_SPI)   += madera-spi.o
+
 obj-$(CONFIG_TPS6105X) += tps6105x.o
 obj-$(CONFIG_TPS65010) += tps65010.o
 obj-$(CONFIG_TPS6507X) += tps6507x.o
diff --git a/drivers/mfd/madera-core.c b/drivers/mfd/madera-core.c
new file mode 100644
index ..de1208b2f587
--- /dev/null
+++ b/drivers/mfd/madera-core.c
@@ -0,0 +1,599 @@
+/*
+ * Core MFD support for Cirrus Logic Madera codecs
+ *
+ * Copyright 2015-2017 Cirrus Logic
+ *
+ * Author: Richard Fitzgerald 
+ *
+ * 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "madera.h"
+
+#define CS47L35_SILICON_ID 0x6360
+#define CS47L85_SILICON_ID 0x6338
+#define CS47L90_SILICON_ID 0x6364
+
+#define MADERA_32KZ_MCLK2  1
+
+static const char * const madera_core_supplies[] = {
+   "AVDD",
+   "DBVDD1",
+};
+
+static const struct mfd_cell madera_ldo1_devs[] = {
+   { .name = "madera-ldo1" },
+};
+
+static const char * const cs47l35_supplies[] = {
+   "MICVDD",
+   "DBVDD2",
+   "CPVDD1",
+   "CPVDD2",
+   "SPKVDD",
+};
+
+static const struct mfd_cell cs47l35_devs[] = {
+   

[PATCH v7 03/17] mfd: madera: Add common support for Cirrus Logic Madera codecs

2018-01-15 Thread Richard Fitzgerald
This adds the generic core support for Cirrus Logic "Madera" class codecs.
These are complex audio codec SoCs with a variety of digital and analogue
I/O, onboard audio processing and DSPs, and other features.

These codecs are all based off a common set of hardware IP so can be
supported by a core of common code (with a few minor device-to-device
variations).

Signed-off-by: Charles Keepax 
Signed-off-by: Nikesh Oswal 
Signed-off-by: Richard Fitzgerald 
Acked-for-MFD-by: Lee Jones 
---
 MAINTAINERS  |   3 +
 drivers/mfd/Kconfig  |  27 ++
 drivers/mfd/Makefile |   4 +
 drivers/mfd/madera-core.c| 599 +++
 drivers/mfd/madera-i2c.c | 140 +
 drivers/mfd/madera-spi.c | 139 +
 drivers/mfd/madera.h |  44 +++
 include/linux/mfd/madera/core.h  | 196 +
 include/linux/mfd/madera/pdata.h |  61 
 9 files changed, 1213 insertions(+)
 create mode 100644 drivers/mfd/madera-core.c
 create mode 100644 drivers/mfd/madera-i2c.c
 create mode 100644 drivers/mfd/madera-spi.c
 create mode 100644 drivers/mfd/madera.h
 create mode 100644 include/linux/mfd/madera/core.h
 create mode 100644 include/linux/mfd/madera/pdata.h

diff --git a/MAINTAINERS b/MAINTAINERS
index d150555c328a..aa7f3a9dfa77 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3495,7 +3495,10 @@ L:   patc...@opensource.wolfsonmicro.com
 T: git https://github.com/CirrusLogic/linux-drivers.git
 W: https://github.com/CirrusLogic/linux-drivers/wiki
 S: Supported
+F: Documentation/devicetree/bindings/mfd/madera.txt
 F: include/linux/mfd/madera/*
+F: drivers/mfd/madera*
+F: drivers/mfd/cs47l*
 
 CLEANCACHE API
 M: Konrad Rzeszutek Wilk 
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index b860eb5aa194..8ea298bdcf58 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -232,6 +232,33 @@ config MFD_CROS_EC_CHARDEV
   If you have a supported Chromebook, choose Y or M here.
   The module will be called cros_ec_dev.
 
+config MFD_MADERA
+   bool
+   select MFD_CORE
+   select REGMAP
+   select REGMAP_IRQ
+   select MADERA_IRQ
+
+config MFD_MADERA_I2C
+   bool "Cirrus Logic Madera codecs with I2C"
+   select MFD_MADERA
+   select REGMAP_I2C
+   select PINCTRL
+   depends on I2C
+   help
+ Support for the Cirrus Logic Madera platform audio SoC
+ core functionality controlled via I2C.
+
+config MFD_MADERA_SPI
+   bool "Cirrus Logic Madera codecs with SPI"
+   select MFD_MADERA
+   select REGMAP_SPI
+   select PINCTRL
+   depends on SPI_MASTER
+   help
+ Support for the Cirrus Logic Madera platform audio SoC
+ core functionality controlled via SPI.
+
 config MFD_ASIC3
bool "Compaq ASIC3"
depends on GPIOLIB && ARM
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index d9d2cf0d32ef..1349e23e2be1 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -73,6 +73,10 @@ wm8994-objs  := wm8994-core.o wm8994-irq.o 
wm8994-regmap.o
 obj-$(CONFIG_MFD_WM8994)   += wm8994.o
 obj-$(CONFIG_MFD_WM97xx)   += wm97xx-core.o
 
+obj-$(CONFIG_MFD_MADERA)   += madera-core.o
+obj-$(CONFIG_MFD_MADERA_I2C)   += madera-i2c.o
+obj-$(CONFIG_MFD_MADERA_SPI)   += madera-spi.o
+
 obj-$(CONFIG_TPS6105X) += tps6105x.o
 obj-$(CONFIG_TPS65010) += tps65010.o
 obj-$(CONFIG_TPS6507X) += tps6507x.o
diff --git a/drivers/mfd/madera-core.c b/drivers/mfd/madera-core.c
new file mode 100644
index ..de1208b2f587
--- /dev/null
+++ b/drivers/mfd/madera-core.c
@@ -0,0 +1,599 @@
+/*
+ * Core MFD support for Cirrus Logic Madera codecs
+ *
+ * Copyright 2015-2017 Cirrus Logic
+ *
+ * Author: Richard Fitzgerald 
+ *
+ * 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "madera.h"
+
+#define CS47L35_SILICON_ID 0x6360
+#define CS47L85_SILICON_ID 0x6338
+#define CS47L90_SILICON_ID 0x6364
+
+#define MADERA_32KZ_MCLK2  1
+
+static const char * const madera_core_supplies[] = {
+   "AVDD",
+   "DBVDD1",
+};
+
+static const struct mfd_cell madera_ldo1_devs[] = {
+   { .name = "madera-ldo1" },
+};
+
+static const char * const cs47l35_supplies[] = {
+   "MICVDD",
+   "DBVDD2",
+   "CPVDD1",
+   "CPVDD2",
+   "SPKVDD",
+};
+
+static const struct mfd_cell cs47l35_devs[] = {
+   { .name = "madera-pinctrl", },
+   { .name = "madera-irq", },
+   { .name = "madera-micsupp", },
+   { .name = "madera-gpio", },
+   { .name = "madera-extcon", },
+