Skip to contentSkip to conversation

Add support for Cirrus Logic CS47L35/L85/L90/L91 codecs

PATCH Superseded Richard Fitzgerald 4 participants 22 messages Feb 26, 2018 – Mar 21, 2018

Subsystems (5)

v8 of 10 Superseded Latest is v10 →

lore
Share & tools
lore

Richard Fitzgerald

author maintainer
#0 lore raw

v8 cover Add support for Cirrus Logic CS47L35/L85/L90/L91 codecs

NOTE: Compared to older versions of this chain I have removed patches at the end of the chain that were being ignored until the earlier patches had been merged - an impossible circular dependency. There were too many moving targets to keep the whole chain up-to-date and so patches that were already acked were getting stale. The subset of patches here are all acked or close-to-acked, and can be built and used as they are to produce a working pinctrl and gpio.

The Cirrus Logic CS47L35, CS47L85, CS47L90/91 codecs are complex audio SoC devices. In addition to the core audio capability they have onboard GPIO, regulators, DSPs and interrupt controller and a large register map space accessed over SPI or I2C. This family of codecs is based around common IP blocks and they are managed by a set of common drivers referred to as "Madera".

Richard Fitzgerald (9):
mfd: madera: Add register definitions for Cirrus Logic Madera codecs
mfd: madera: Add DT bindings for Cirrus Logic Madera codecs
mfd: madera: Add common support for Cirrus Logic Madera codecs
mfd: madera: Register map tables for Cirrus Logic CS47L35
mfd: madera: Register map tables for Cirrus Logic CS47L85
mfd: madera: Register map tables for Cirrus Logic CS47L90/91
pinctrl: madera: Add DT bindings for Cirrus Logic Madera codecs
pinctrl: madera: Add driver for Cirrus Logic Madera codecs
gpio: madera: Support Cirrus Logic Madera class codecs

 Documentation/devicetree/bindings/mfd/madera.txt   |  102 +
 .../bindings/pinctrl/cirrus,madera-pinctrl.txt     |   99 +
 MAINTAINERS                                        |   16 +
 drivers/gpio/Kconfig                               |    6 +
 drivers/gpio/Makefile                              |    1 +
 drivers/gpio/gpio-madera.c                         |  203 +
 drivers/mfd/Kconfig                                |   50 +
 drivers/mfd/Makefile                               |   14 +
 drivers/mfd/cs47l35-tables.c                       | 1609 ++++++++
 drivers/mfd/cs47l85-tables.c                       | 3009 +++++++++++++++
 drivers/mfd/cs47l90-tables.c                       | 2674 +++++++++++++
 drivers/mfd/madera-core.c                          |  602 +++
 drivers/mfd/madera-i2c.c                           |  141 +
 drivers/mfd/madera-spi.c                           |  140 +
 drivers/mfd/madera.h                               |   44 +
 drivers/pinctrl/Kconfig                            |    1 +
 drivers/pinctrl/Makefile                           |    1 +
 drivers/pinctrl/cirrus/Kconfig                     |   15 +
 drivers/pinctrl/cirrus/Makefile                    |   13 +
 drivers/pinctrl/cirrus/pinctrl-cs47l35.c           |   45 +
 drivers/pinctrl/cirrus/pinctrl-cs47l85.c           |   59 +
 drivers/pinctrl/cirrus/pinctrl-cs47l90.c           |   57 +
 drivers/pinctrl/cirrus/pinctrl-madera-core.c       | 1074 ++++++
 drivers/pinctrl/cirrus/pinctrl-madera.h            |   41 +
 include/linux/mfd/madera/core.h                    |  190 +
 include/linux/mfd/madera/pdata.h                   |   62 +
 include/linux/mfd/madera/registers.h               | 3917 ++++++++++++++++++++
 27 files changed, 14185 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/madera.txt
 create mode 100644 Documentation/devicetree/bindings/pinctrl/cirrus,madera-pinctrl.txt
 create mode 100644 drivers/gpio/gpio-madera.c
 create mode 100644 drivers/mfd/cs47l35-tables.c
 create mode 100644 drivers/mfd/cs47l85-tables.c
 create mode 100644 drivers/mfd/cs47l90-tables.c
 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 drivers/pinctrl/cirrus/Kconfig
 create mode 100644 drivers/pinctrl/cirrus/Makefile
 create mode 100644 drivers/pinctrl/cirrus/pinctrl-cs47l35.c
 create mode 100644 drivers/pinctrl/cirrus/pinctrl-cs47l85.c
 create mode 100644 drivers/pinctrl/cirrus/pinctrl-cs47l90.c
 create mode 100644 drivers/pinctrl/cirrus/pinctrl-madera-core.c
 create mode 100644 drivers/pinctrl/cirrus/pinctrl-madera.h
 create mode 100644 include/linux/mfd/madera/core.h
 create mode 100644 include/linux/mfd/madera/pdata.h
 create mode 100644 include/linux/mfd/madera/registers.h
Signature · 1 line
2.11.0
author maintainer
#1 lore raw

PATCH v8 1/9 mfd: madera: Add register definitions for Cirrus Logic Madera codecs

This patch adds a header file of register definitions for Cirrus Logic "Madera" class codecs. These codecs are all based off a common set of hardware IP so have a common register map (with a few minor device-to-device variations).

The registers.h file is tool-generated directly from the hardware design but has been manually stripped down to reduce size (full register map is >44000 lines). All names are kept the same as datasheet names so that they can be cross-referenced between source and datasheet without confusion.

The register map layout is kept fully-defined rather than factored into macros and/or block-indexing code. The major reasons for this are:

- #1 is that it makes the source highly greppable, which is important. "What does the driver do with register bits XYZ" or "Where does it use register bits XYZ" are commonly types of questions. These can be quickly answered by a grep. Squashing definitions into generator macros or block- indexing code is a way of defeating grep.

- most of the register definitions are used in tables, so a constant value is required. Using generator macros make the table definition clunky and obscure.

- the code is clearer when it's there in the source exactly what register and field it is using

- it is easier to diff the register map of a new (unsupported) codec against what is already supported and merge in differences

- it makes the register map available in source for maintenance/debugging instead of having to refer back to the datasheet for a register map

---
 MAINTAINERS                          |   10 +
 include/linux/mfd/madera/registers.h | 3917 ++++++++++++++++++++++++++++++++++
 2 files changed, 3927 insertions(+)
 create mode 100644 include/linux/mfd/madera/registers.h
MAINTAINERS +10 -0
index ac007ea02d54..4eeee67302e9 100644
@@ -3488,6 +3488,16 @@ M:	Dave Goodell <[email protected]>
 S:	Supported
 F:	drivers/infiniband/hw/usnic/
 
+CIRRUS LOGIC MADERA CODEC DRIVERS
+M:	Charles Keepax <[email protected]>
+M:	Richard Fitzgerald <[email protected]>
+L:	[email protected] (moderated for non-subscribers)
+L:	[email protected]
+T:	git https://github.com/CirrusLogic/linux-drivers.git
+W:	https://github.com/CirrusLogic/linux-drivers/wiki
+S:	Supported
+F:	include/linux/mfd/madera/*
+
 CLEANCACHE API
 M:	Konrad Rzeszutek Wilk <[email protected]>
 L:	[email protected]
include/linux/mfd/madera/registers.h new file +3917 -0

2,984 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.11.0

Part of the diff is not shown here. View the raw message.

#2 lore raw

Re: [PATCH v8 1/9] mfd: madera: Add register definitions for Cirrus Logic Madera codecs

Quoted 32 lines · Richard Fitzgerald

This patch adds a header file of register definitions for Cirrus Logic "Madera" class codecs. These codecs are all based off a common set of hardware IP so have a common register map (with a few minor device-to-device variations).

The registers.h file is tool-generated directly from the hardware design but has been manually stripped down to reduce size (full register map is >44000 lines). All names are kept the same as datasheet names so that they can be cross-referenced between source and datasheet without confusion.

The register map layout is kept fully-defined rather than factored into macros and/or block-indexing code. The major reasons for this are:

- #1 is that it makes the source highly greppable, which is important. "What does the driver do with register bits XYZ" or "Where does it use register bits XYZ" are commonly types of questions. These can be quickly answered by a grep. Squashing definitions into generator macros or block- indexing code is a way of defeating grep.

- most of the register definitions are used in tables, so a constant value is required. Using generator macros make the table definition clunky and obscure.

- the code is clearer when it's there in the source exactly what register and field it is using

- it is easier to diff the register map of a new (unsupported) codec against what is already supported and merge in differences

- it makes the register map available in source for maintenance/debugging instead of having to refer back to the datasheet for a register map

...

include/linux/mfd/madera/registers.h line 3913

Quoted 3 lines
include/linux/mfd/madera/registers.h new file +2 -0
+#define MADERA_OTP_HPDET_GRADIENT_1X_MASK          0x0000FF00
 
+#define MADERA_OTP_HPDET_GRADIENT_0X_MASK          0x000000FF

GENMASK() for all masks?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#3 lore raw

Re: [PATCH v8 1/9] mfd: madera: Add register definitions for Cirrus Logic Madera codecs

Quoted 35 lines · Andy Shevchenko
Quoted 24 lines · Richard Fitzgerald

This patch adds a header file of register definitions for Cirrus Logic "Madera" class codecs. These codecs are all based off a common set of hardware IP so have a common register map (with a few minor device-to-device variations).

The registers.h file is tool-generated directly from the hardware design but has been manually stripped down to reduce size (full register map is >44000 lines). All names are kept the same as datasheet names so that they can be cross-referenced between source and datasheet without confusion.

The register map layout is kept fully-defined rather than factored into macros and/or block-indexing code. The major reasons for this are:

- #1 is that it makes the source highly greppable, which is important. "What does the driver do with register bits XYZ" or "Where does it use register bits XYZ" are commonly types of questions. These can be quickly answered by a grep. Squashing definitions into generator macros or block- indexing code is a way of defeating grep.

- most of the register definitions are used in tables, so a constant value is required. Using generator macros make the table definition clunky and obscure.

Quoted 8 lines

- the code is clearer when it's there in the source exactly what register and field it is using

- it is easier to diff the register map of a new (unsupported) codec against what is already supported and merge in differences

- it makes the register map available in source for maintenance/debugging instead of having to refer back to the datasheet for a register map

Quoted 8 lines

...

include/linux/mfd/madera/registers.h line 3913

Quoted 3 lines
include/linux/mfd/madera/registers.h new file +2 -0
+#define MADERA_OTP_HPDET_GRADIENT_1X_MASK          0x0000FF00
 
+#define MADERA_OTP_HPDET_GRADIENT_0X_MASK          0x000000FF

GENMASK() for all masks?

I'm an un-fan of GENMASK(). It seems to me to make it less readable. Unless it's important I'd rather leave the masks as they are because this is all auto-generated from the hardware design. Also keeping it in plain form like this makes it easier for people converting settings from the output of codec tuning tools.

author maintainer
#4 lore raw

PATCH v8 2/9 mfd: madera: Add DT bindings for Cirrus Logic Madera codecs

In reply to Richard Fitzgerald

Specification of the bindings for the parent MFD driver component of the Cirrus Logic Madera codec drivers.

Note that although the interrupt controller and GPIO are child drivers their required bindings are trivial, mandatory, and exist within the parent MFD node so are documented here.

---
 Documentation/devicetree/bindings/mfd/madera.txt | 102 +++++++++++++++++++++++
 1 file changed, 102 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/madera.txt
Documentation/devicetree/bindings/mfd/madera.txt new file +102 -0
new file mode 100644
index 000000000000..db3266088386
@@ -0,0 +1,102 @@
+Cirrus Logic Madera class audio codecs Multi-Functional Device
+
+These devices are audio SoCs with extensive digital capabilities and a range
+of analogue I/O.
+
+See also the child driver bindings in:
+bindings/pinctrl/cirrus,madera-pinctrl.txt
+bindings/regulator/arizona-regulator.txt
+bindings/sound/madera.txt
+
+Required properties:
+
+  - compatible : One of the following chip-specific strings:
+        "cirrus,cs47l35"
+        "cirrus,cs47l85"
+        "cirrus,cs47l90"
+        "cirrus,cs47l91"
+        "cirrus,wm1840"
+
+  - reg : I2C slave address when connected using I2C, chip select number when
+    using SPI.
+
+  - DCVDD-supply : Power supply for the device as defined in
+    bindings/regulator/regulator.txt
+    Mandatory on CS47L35, CS47L90, CS47L91
+    Optional on CS47L85, WM1840
+
+  - AVDD-supply, DBVDD1-supply, DBVDD2-supply, CPVDD1-supply, CPVDD2-supply :
+    Power supplies for the device
+
+  - DBVDD3-supply, DBVDD4-supply : Power supplies for the device
+    (CS47L85, CS47L90, CS47L91, WM1840)
+
+  - SPKVDDL-supply, SPKVDDR-supply : Power supplies for the device
+    (CS47L85, WM1840)
+
+  - SPKVDD-supply : Power supply for the device
+    (CS47L35)
+
+  - interrupt-controller : Indicates that this device is an interrupt controller
+
+  - #interrupt-cells: the number of cells to describe an IRQ, must be 2.
+    The first cell is the IRQ number.
+    The second cell is the flags, encoded as the trigger masks from
+    bindings/interrupt-controller/interrupts.txt
+
+  - gpio-controller : Indicates this device is a GPIO controller.
+
+  - #gpio-cells : Must be 2. The first cell is the pin number. The second cell
+    is reserved for future use and must be zero
+
+  - interrupt-parent : The parent interrupt controller.
+
+  - interrupts : The interrupt line the /IRQ signal for the device is
+    connected to.
+
+Optional properties:
+
+  - MICVDD-supply : Power supply, only need to be specified if
+    powered externally
+
+  - reset-gpios : One entry specifying the GPIO controlling /RESET.
+    As defined in bindings/gpio.txt.
+    Although optional, it is strongly recommended to use a hardware reset
+
+  - MICBIASx : Initial data for the MICBIAS regulators, as covered in
+    Documentation/devicetree/bindings/regulator/regulator.txt.
+    One for each MICBIAS generator (MICBIAS1, MICBIAS2, ...)
+    (all codecs)
+
+    One for each output pin (MICBIAS1A, MIBCIAS1B, MICBIAS2A, ...)
+    (all except CS47L85, WM1840)
+
+    The following following additional property is supported for the generator
+    nodes:
+      - cirrus,ext-cap : Set to 1 if the MICBIAS has external decoupling
+        capacitors attached.
+
+Optional child nodes:
+    micvdd : Node containing initialization data for the micvdd regulator
+    See bindings/regulator/arizona-regulator.txt
+
+    ldo1 : Node containing initialization data for the LDO1 regulator
+    See bindings/regulator/arizona-regulator.txt
+    (cs47l85, wm1840)
+
+Example:
+
+cs47l85@0 {
+	compatible = "cirrus,cs47l85";
+	reg = <0>;
+
+	reset-gpios = <&gpio 0>;
+
+	interrupt-controller;
+	#interrupt-cells = <2>;
+	interrupts = <&host_irq1>;
+	interrupt-parent = <&gic>;
+
+	gpio-controller;
+	#gpio-cells = <2>;
+};
Signature · 1 line
2.11.0
author maintainer
#5 lore raw

PATCH v8 3/9 mfd: madera: Add common support for Cirrus Logic Madera codecs

In reply to 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).

---
There are some small changes since Lee acked this patch but as they are all trivial I have carried forward Lee's ack:
- SPDX license headers
- the core driver can now be built as a module
- minor Kconfig change to make the SPI/I2C submodules depend on the core module as this gives a more user-friendly menuconfig
- changed the irqchip and codec pdata to be a pointer to remove the build dependency so we can submit this patch without the irqchip and codec driver patches

---
 MAINTAINERS                      |   3 +
 drivers/mfd/Kconfig              |  29 ++
 drivers/mfd/Makefile             |   5 +
 drivers/mfd/madera-core.c        | 602 +++++++++++++++++++++++++++++++++++++++
 drivers/mfd/madera-i2c.c         | 141 +++++++++
 drivers/mfd/madera-spi.c         | 140 +++++++++
 drivers/mfd/madera.h             |  44 +++
 include/linux/mfd/madera/core.h  | 190 ++++++++++++
 include/linux/mfd/madera/pdata.h |  62 ++++
 9 files changed, 1216 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
MAINTAINERS +3 -0
index 4eeee67302e9..865d3a3c9e5f 100644
@@ -3496,7 +3496,10 @@ L:	[email protected]
 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 <[email protected]>
drivers/mfd/Kconfig +29 -0
index b860eb5aa194..f5ca392f8bc2 100644
@@ -232,6 +232,35 @@ 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
+	tristate "Cirrus Logic Madera codecs"
+	select MFD_CORE
+	select REGMAP
+	select REGMAP_IRQ
+	select MADERA_IRQ
+	select PINCTRL
+	select PINCTRL_MADERA
+	help
+	  Support for the Cirrus Logic Madera platform audio codecs
+
+config MFD_MADERA_I2C
+	tristate "Cirrus Logic Madera codecs with I2C"
+	depends on MFD_MADERA
+	depends on I2C
+	select REGMAP_I2C
+	help
+	  Support for the Cirrus Logic Madera platform audio SoC
+	  core functionality controlled via I2C.
+
+config MFD_MADERA_SPI
+	tristate "Cirrus Logic Madera codecs with SPI"
+	depends on MFD_MADERA
+	depends on SPI_MASTER
+	select REGMAP_SPI
+	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
drivers/mfd/Makefile +5 -0
index d9d2cf0d32ef..0a89a6a6d793 100644
@@ -73,6 +73,11 @@ wm8994-objs			:= wm8994-core.o wm8994-irq.o wm8994-regmap.o
 obj-$(CONFIG_MFD_WM8994)	+= wm8994.o
 obj-$(CONFIG_MFD_WM97xx)	+= wm97xx-core.o
 
+madera-objs			:= madera-core.o
+obj-$(CONFIG_MFD_MADERA)	+= madera.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
drivers/mfd/madera-core.c new file +602 -0

602 lines not on this page · raw message

drivers/mfd/madera-i2c.c new file +141 -0

141 lines not on this page · raw message

drivers/mfd/madera-spi.c new file +140 -0

140 lines not on this page · raw message

drivers/mfd/madera.h new file +44 -0

44 lines not on this page · raw message

include/linux/mfd/madera/core.h new file +190 -0

190 lines not on this page · raw message

include/linux/mfd/madera/pdata.h new file +62 -0

62 lines not on this page · raw message

Signature · 1 line
2.11.0
#6 lore raw

Re: [PATCH v8 3/9] mfd: madera: Add common support for Cirrus Logic Madera codecs

drivers/mfd/madera-core.c line 1

Quoted 4 lines · Richard Fitzgerald
drivers/mfd/madera-core.c new file +1 -0
@@ -0,0 +1,602 @@
+// SPDX-License-Identifier: GPL-2.0

As you use SPDX line here....

drivers/mfd/madera-core.c line 9

Quoted 8 lines
drivers/mfd/madera-core.c new file +8 -0
+/*
+ * Core MFD support for Cirrus Logic Madera codecs
+ *
+ * Copyright (C) 2015-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 as published by the
+ * Free Software Foundation; version 2.

You can remove this paragraph.

Same applies to the other places of this series.

author maintainer
#7 lore raw

Re: [PATCH v8 3/9] mfd: madera: Add common support for Cirrus Logic Madera codecs

Quoted 19 lines · Fabio Estevam

drivers/mfd/madera-core.c line 1

Quoted 4 lines · Richard Fitzgerald
drivers/mfd/madera-core.c new file +1 -0
@@ -0,0 +1,602 @@
+// SPDX-License-Identifier: GPL-2.0

As you use SPDX line here....

drivers/mfd/madera-core.c line 9

Quoted 8 lines
drivers/mfd/madera-core.c new file +8 -0
+/*
+ * Core MFD support for Cirrus Logic Madera codecs
+ *
+ * Copyright (C) 2015-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 as published by the
+ * Free Software Foundation; version 2.
Quoted 4 lines

You can remove this paragraph.

Same applies to the other places of this series.

Our legal team says no, these lines should stay.

#8 lore raw

Re: [PATCH v8 3/9] mfd: madera: Add common support for Cirrus Logic Madera codecs

In reply to Richard Fitzgerald
Quoted 9 lines · 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).

Quoted 4 lines

+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; version 2.

This is redundant.

drivers/mfd/madera-core.c line 188

Quoted 3 lines
drivers/mfd/madera-core.c new file +3 -0
+static void madera_enable_hard_reset(struct madera *madera)
+{
+       if (madera->reset_gpio)

if (!...)
return

drivers/mfd/madera-core.c line 194

Quoted 6 lines
drivers/mfd/madera-core.c new file +6 -0
+               gpiod_set_value_cansleep(madera->reset_gpio, 0);
+}
+
+static void madera_disable_hard_reset(struct madera *madera)
+{
+       if (madera->reset_gpio) {

Ditto.

drivers/mfd/madera-core.c line 200

Quoted 7 lines
drivers/mfd/madera-core.c new file +6 -0
+               gpiod_set_value_cansleep(madera->reset_gpio, 1);
+               usleep_range(1000, 2000);
+       }
+}
+
 
+#ifdef CONFIG_PM

__maybe_unused

drivers/mfd/madera-core.c line 264

Quoted 5 lines
drivers/mfd/madera-core.c new file +5 -0
+const struct dev_pm_ops madera_pm_ops = {
+       SET_RUNTIME_PM_OPS(madera_runtime_suspend,
+                          madera_runtime_resume,
+                          NULL)
+};

There is a macro helper for this I believe.

drivers/mfd/madera-core.c line 273

Quoted 8 lines
drivers/mfd/madera-core.c new file +7 -0
+const struct of_device_id madera_of_match[] = {
+       { .compatible = "cirrus,cs47l35", .data = (void *)CS47L35 },
+       { .compatible = "cirrus,cs47l85", .data = (void *)CS47L85 },
+       { .compatible = "cirrus,cs47l90", .data = (void *)CS47L90 },
+       { .compatible = "cirrus,cs47l91", .data = (void *)CS47L91 },
+       { .compatible = "cirrus,wm1840", .data = (void *)WM1840 },
 
+       {},

No comma.

drivers/mfd/madera-core.c line 289

Quoted 9 lines
drivers/mfd/madera-core.c new file +7 -0
+};
 
 
+               ret = devm_gpio_request_one(madera->dev,
+                                           madera->pdata.reset,
+                                           GPIOF_DIR_OUT | GPIOF_INIT_LOW,
+                                           "madera reset");
+               if (!ret)
+                       madera->reset_gpio = gpio_to_desc(madera->pdata.reset);

Why? What's wrong with descriptors?

Quoted 1 line

+ dev_set_drvdata(madera->dev, madera);

...

Quoted 1 line

+ if (dev_get_platdata(madera->dev))

What this dance for?

drivers/mfd/madera-core.c line 552

Quoted 3 lines
drivers/mfd/madera-core.c new file +3 -0
+       ret = mfd_add_devices(madera->dev, PLATFORM_DEVID_NONE,
+                             mfd_devs, n_devs,
+                             NULL, 0, NULL);

devm_?

drivers/mfd/madera-i2c.c

Quoted 12 lines
drivers/mfd/madera-i2c.c new file +11 -0
+       if (i2c->dev.of_node) {
+               of_id = of_match_device(madera_of_match, &i2c->dev);
+               if (of_id)
+                       type = (unsigned long)of_id->data;
+       } else {
+               type = id->driver_data;
+       }
 
+       if (spi->dev.of_node) {
+               of_id = of_match_device(madera_of_match, &spi->dev);
+               if (of_id)
+                       type = (unsigned long)of_id->data;

There is a helper to get match data.

drivers/mfd/madera-i2c.c

Quoted 6 lines
drivers/mfd/madera-i2c.c new file +5 -0
+       } else {
+               type = id->driver_data;
+       }
 
+struct madera_irqchip_pdata;
+struct madera_codec_pdata;

Why do you need platform data in new code?

Quoted 1 line

+ * @reset: GPIO controlling /RESET (0 = none)

Shouldn't be descriptor?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#9 lore raw

Re: [PATCH v8 3/9] mfd: madera: Add common support for Cirrus Logic Madera codecs

Quoted 11 lines · Andy Shevchenko
Quoted 7 lines · 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).

Quoted 7 lines
Quoted 4 lines

+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; version 2.

This is redundant.

Ditto my other reply. Our legal team want these lines.

Quoted 7 lines

drivers/mfd/madera-core.c line 188

Quoted 3 lines
drivers/mfd/madera-core.c new file +3 -0
+static void madera_enable_hard_reset(struct madera *madera)
+{
+       if (madera->reset_gpio)

if (!...)
return

Could do but why bother? For such a trivial function, in my opinion

static void madera_enable_hard_reset(struct madera *madera)

{
	if (madera->reset_gpio)
		gpiod_set_value_cansleep(madera->reset_gpio, 0);
}

is simpler and more readable than

static void madera_enable_hard_reset(struct madera *madera)

{
	if (!madera->reset_gpio)
		return;

	gpiod_set_value_cansleep(madera->reset_gpio, 0);
}
Quoted 9 lines

drivers/mfd/madera-core.c line 194

Quoted 6 lines
drivers/mfd/madera-core.c new file +6 -0
+               gpiod_set_value_cansleep(madera->reset_gpio, 0);
+}
+
+static void madera_disable_hard_reset(struct madera *madera)
+{
+       if (madera->reset_gpio) {

Ditto.

As above, yes it would work the other way but I think for such a simple implementation the way I have written it is more readable.

Quoted 11 lines

drivers/mfd/madera-core.c line 200

Quoted 7 lines
drivers/mfd/madera-core.c new file +6 -0
+               gpiod_set_value_cansleep(madera->reset_gpio, 1);
+               usleep_range(1000, 2000);
+       }
+}
+
 
+#ifdef CONFIG_PM

__maybe_unused

Quoted 7 lines

drivers/mfd/madera-core.c line 264

Quoted 5 lines
drivers/mfd/madera-core.c new file +5 -0
+const struct dev_pm_ops madera_pm_ops = {
+       SET_RUNTIME_PM_OPS(madera_runtime_suspend,
+                          madera_runtime_resume,
+                          NULL)
+};

There is a macro helper for this I believe.

Not for a dev_pm_ops that only has runtime pm.
If you're thinking of UNIVERSAL_DEV_PM_OPS that would set the same functions as handlers for system suspend, which we don't want to do for the reasons given in the comment describing UNIVERSAL_DEV_PM_OPS.

Quoted 8 lines
Quoted 7 lines
drivers/mfd/madera-core.c new file +6 -0
+const struct of_device_id madera_of_match[] = {
+       { .compatible = "cirrus,cs47l35", .data = (void *)CS47L35 },
+       { .compatible = "cirrus,cs47l85", .data = (void *)CS47L85 },
+       { .compatible = "cirrus,cs47l90", .data = (void *)CS47L90 },
+       { .compatible = "cirrus,cs47l91", .data = (void *)CS47L91 },
+       { .compatible = "cirrus,wm1840", .data = (void *)WM1840 },
Quoted 4 lines
Quoted 1 line

+ {},

No comma.

Seems to be personal preference. Both ways are used in the kernel and we've always used this style so I'll leave it to Lee to decide.

Quoted 12 lines

drivers/mfd/madera-core.c line 289

Quoted 9 lines
drivers/mfd/madera-core.c new file +7 -0
+};
 
 
+               ret = devm_gpio_request_one(madera->dev,
+                                           madera->pdata.reset,
+                                           GPIOF_DIR_OUT | GPIOF_INIT_LOW,
+                                           "madera reset");
+               if (!ret)
+                       madera->reset_gpio = gpio_to_desc(madera->pdata.reset);

Why? What's wrong with descriptors?

This is what I mean by code going stale when it's acked but then never gets merged. Some time ago there was a reason (which I forget).

Quoted 6 lines
Quoted 1 line

+ dev_set_drvdata(madera->dev, madera);

...

Quoted 1 line

+ if (dev_get_platdata(madera->dev))

What this dance for?

Are you perhaps thinking the second line is dev_get_drvdata()? dev_get_platdata() gets a pointer to any pdata, so not related to dev_set_drvdata().

Quoted 6 lines

drivers/mfd/madera-core.c line 552

Quoted 3 lines
drivers/mfd/madera-core.c new file +3 -0
+       ret = mfd_add_devices(madera->dev, PLATFORM_DEVID_NONE,
+                             mfd_devs, n_devs,
+                             NULL, 0, NULL);

devm_?

I can try it and see. It's scary because we can depend on our children but maybe devm_mfd_add_devices() is safe.

Quoted 19 lines

drivers/mfd/madera-i2c.c

Quoted 12 lines
drivers/mfd/madera-i2c.c new file +11 -0
+       if (i2c->dev.of_node) {
+               of_id = of_match_device(madera_of_match, &i2c->dev);
+               if (of_id)
+                       type = (unsigned long)of_id->data;
+       } else {
+               type = id->driver_data;
+       }
 
+       if (spi->dev.of_node) {
+               of_id = of_match_device(madera_of_match, &spi->dev);
+               if (of_id)
+                       type = (unsigned long)of_id->data;

There is a helper to get match data.

Quoted 3 lines
drivers/mfd/madera-i2c.c new file +3 -0
+       } else {
+               type = id->driver_data;
+       }
Quoted 6 lines

include/linux/mfd/madera/pdata.h line 27

Quoted 2 lines
include/linux/mfd/madera/pdata.h new file +2 -0
+struct madera_irqchip_pdata;
+struct madera_codec_pdata;

Why do you need platform data in new code?

Answered in a comment in another patch. We care about allowing people to use our chips with systems that don't use devicetree/acpi. There are also many out-of-tree systems.

Quoted 4 lines
Quoted 1 line

+ * @reset: GPIO controlling /RESET (0 = none)

Shouldn't be descriptor?

#10 lore raw

Re: [PATCH v8 3/9] mfd: madera: Add common support for Cirrus Logic Madera codecs

Quoted 23 lines · Richard Fitzgerald
Quoted 11 lines · Andy Shevchenko

drivers/mfd/madera-core.c line 188

Quoted 3 lines · Richard Fitzgerald
drivers/mfd/madera-core.c new file +3 -0
+static void madera_enable_hard_reset(struct madera *madera)
+{
+       if (madera->reset_gpio)

if (!...)
return

Could do but why bother? For such a trivial function, in my opinion

static void madera_enable_hard_reset(struct madera *madera)

{
        if (madera->reset_gpio)
                gpiod_set_value_cansleep(madera->reset_gpio, 0);
}

is simpler and more readable than

Quoted 7 lines

static void madera_enable_hard_reset(struct madera *madera)

{
        if (!madera->reset_gpio)
                return;

        gpiod_set_value_cansleep(madera->reset_gpio, 0);
}

The rationale is that if someone wants to add more code you will not need to take care of deeper indentation and potentially split lines.

Quoted 12 lines
Quoted 11 lines

drivers/mfd/madera-core.c line 194

Quoted 7 lines
drivers/mfd/madera-core.c new file +6 -0
+               gpiod_set_value_cansleep(madera->reset_gpio, 0);
+}
+
+static void madera_disable_hard_reset(struct madera *madera)
+{
+       if (madera->reset_gpio) {

Ditto.

Quoted 2 lines

As above, yes it would work the other way but I think for such a simple implementation the way I have written it is more readable.

I have different opinion, but yes. It's more matter of taste with rationale above (perhaps never happen to this code).

Quoted 13 lines
Quoted 13 lines
Quoted 11 lines
drivers/mfd/madera-core.c new file +10 -0
+               gpiod_set_value_cansleep(madera->reset_gpio, 1);
+               usleep_range(1000, 2000);
+       }
+}
 
+const struct of_device_id madera_of_match[] = {
+       { .compatible = "cirrus,cs47l35", .data = (void *)CS47L35 },
+       { .compatible = "cirrus,cs47l85", .data = (void *)CS47L85 },
+       { .compatible = "cirrus,cs47l90", .data = (void *)CS47L90 },
+       { .compatible = "cirrus,cs47l91", .data = (void *)CS47L91 },
+       { .compatible = "cirrus,wm1840", .data = (void *)WM1840 },
Quoted 8 lines
Quoted 5 lines
Quoted 1 line

+ {},

No comma.

Seems to be personal preference. Both ways are used in the kernel and we've always used this style so I'll leave it to Lee to decide.

This is not.
The rationale is pretty obvious, terminator must terminate. With cheap price (no comma), we just prevent some potential weird cases (bad patch application for example, or not very careful contributor) where entry goes after. Compiler will fail.

Quoted 13 lines
Quoted 13 lines
Quoted 11 lines
drivers/mfd/madera-core.c new file +4 -0
+};
 
+               ret = devm_gpio_request_one(madera->dev,
+                                           madera->pdata.reset,
+                                           GPIOF_DIR_OUT |

GPIOF_INIT_LOW,

drivers/mfd/madera-core.c new file +3 -0
+                                           "madera reset");
+               if (!ret)
+                       madera->reset_gpio =

gpio_to_desc(madera->pdata.reset);

Quoted 4 lines
Quoted 1 line

Why? What's wrong with descriptors?

This is what I mean by code going stale when it's acked but then never gets merged. Some time ago there was a reason (which I forget).

So, can we switch to descriptors?

Quoted 10 lines
Quoted 6 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+       dev_set_drvdata(madera->dev, madera);
+       if (dev_get_platdata(madera->dev))

What this dance for?

Are you perhaps thinking the second line is dev_get_drvdata()? dev_get_platdata() gets a pointer to any pdata, so not related to dev_set_drvdata().

Indeed.

Quoted 10 lines
Quoted 7 lines

drivers/mfd/madera-core.c line 552

Quoted 3 lines
drivers/mfd/madera-core.c new file +3 -0
+       ret = mfd_add_devices(madera->dev, PLATFORM_DEVID_NONE,
+                             mfd_devs, n_devs,
+                             NULL, 0, NULL);

devm_?

I can try it and see. It's scary because we can depend on our children but maybe devm_mfd_add_devices() is safe.

It will fail in the same way. It does nothing more, than keeping a pointer to release function and its data.

Quoted 8 lines
Quoted 4 lines

include/linux/mfd/madera/pdata.h line 27

Quoted 2 lines
include/linux/mfd/madera/pdata.h new file +2 -0
+struct madera_irqchip_pdata;
+struct madera_codec_pdata;

Why do you need platform data in new code?

Answered in a comment in another patch. We care about allowing people to use our chips with systems that don't use devicetree/acpi. There are also many out-of-tree systems.

a) we don't care about out of tree much;
b) there are other means to provide date w/o using platform data:
- unified device property API (including built-in device properties)
- bunch of lookup tables GPIO, regulator, PWM, etc
- fwnode graph for more complex cases with device dependencies

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#11 lore raw

Re: [PATCH v8 3/9] mfd: madera: Add common support for Cirrus Logic Madera codecs

Quoted 30 lines · Andy Shevchenko
Quoted 28 lines · Richard Fitzgerald
Quoted 11 lines · Andy Shevchenko

drivers/mfd/madera-core.c line 188

Quoted 3 lines · Richard Fitzgerald
drivers/mfd/madera-core.c new file +3 -0
+static void madera_enable_hard_reset(struct madera *madera)
+{
+       if (madera->reset_gpio)

if (!...)
return

Could do but why bother? For such a trivial function, in my opinion

static void madera_enable_hard_reset(struct madera *madera)

{
         if (madera->reset_gpio)
                 gpiod_set_value_cansleep(madera->reset_gpio, 0);
}

is simpler and more readable than

static void madera_enable_hard_reset(struct madera *madera)

{
         if (!madera->reset_gpio)
                 return;
Quoted 6 lines
Quoted 2 lines
         gpiod_set_value_cansleep(madera->reset_gpio, 0);
}

The rationale is that if someone wants to add more code you will not need to take care of deeper indentation and potentially split lines.

Yes, true. It's probably unlikely here and I'm inclined to leave it as it is because Lee already acked it.

Quoted 37 lines
Quoted 12 lines
Quoted 11 lines

drivers/mfd/madera-core.c line 194

Quoted 7 lines
drivers/mfd/madera-core.c new file +6 -0
+               gpiod_set_value_cansleep(madera->reset_gpio, 0);
+}
+
+static void madera_disable_hard_reset(struct madera *madera)
+{
+       if (madera->reset_gpio) {

Ditto.

Quoted 2 lines

As above, yes it would work the other way but I think for such a simple implementation the way I have written it is more readable.

I have different opinion, but yes. It's more matter of taste with rationale above (perhaps never happen to this code).

Quoted 19 lines
Quoted 18 lines
Quoted 4 lines
drivers/mfd/madera-core.c new file +4 -0
+               gpiod_set_value_cansleep(madera->reset_gpio, 1);
+               usleep_range(1000, 2000);
+       }
+}

drivers/mfd/madera-core.c line 273

Quoted 10 lines
drivers/mfd/madera-core.c new file +7 -0
 
+const struct of_device_id madera_of_match[] = {
+       { .compatible = "cirrus,cs47l35", .data = (void *)CS47L35 },
+       { .compatible = "cirrus,cs47l85", .data = (void *)CS47L85 },
+       { .compatible = "cirrus,cs47l90", .data = (void *)CS47L90 },
+       { .compatible = "cirrus,cs47l91", .data = (void *)CS47L91 },
+       { .compatible = "cirrus,wm1840", .data = (void *)WM1840 },
 
 
+       {},

No comma.

Quoted 9 lines
Quoted 2 lines

Seems to be personal preference. Both ways are used in the kernel and we've always used this style so I'll leave it to Lee to decide.

This is not.
The rationale is pretty obvious, terminator must terminate. With cheap price (no comma), we just prevent some potential weird cases (bad patch application for example, or not very careful contributor) where entry goes after. Compiler will fail.

Yes, ok. I see a lot of people don't do that (I searched). But if I do a new version of this patch I'll change it.

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 11 lines
drivers/mfd/madera-core.c new file +4 -0
+};
 
+               ret = devm_gpio_request_one(madera->dev,
+                                           madera->pdata.reset,
+                                           GPIOF_DIR_OUT |

GPIOF_INIT_LOW,

drivers/mfd/madera-core.c new file +3 -0
+                                           "madera reset");
+               if (!ret)
+                       madera->reset_gpio =

gpio_to_desc(madera->pdata.reset);

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Why? What's wrong with descriptors?

This is what I mean by code going stale when it's acked but then never gets merged. Some time ago there was a reason (which I forget).

So, can we switch to descriptors?

Yes, however as this patch has been in review for nearly 1 year now, and acked for several months, I'd really hoped we could get it merged now and update it later.

Quoted 32 lines
Quoted 10 lines
Quoted 6 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+       dev_set_drvdata(madera->dev, madera);
+       if (dev_get_platdata(madera->dev))

What this dance for?

Are you perhaps thinking the second line is dev_get_drvdata()? dev_get_platdata() gets a pointer to any pdata, so not related to dev_set_drvdata().

Indeed.

Quoted 10 lines
Quoted 7 lines

drivers/mfd/madera-core.c line 552

Quoted 3 lines
drivers/mfd/madera-core.c new file +3 -0
+       ret = mfd_add_devices(madera->dev, PLATFORM_DEVID_NONE,
+                             mfd_devs, n_devs,
+                             NULL, 0, NULL);

devm_?

I can try it and see. It's scary because we can depend on our children but maybe devm_mfd_add_devices() is safe.

It will fail in the same way. It does nothing more, than keeping a pointer to release function and its data.

Quoted 4 lines
Quoted 4 lines

include/linux/mfd/madera/pdata.h line 27

Quoted 2 lines
include/linux/mfd/madera/pdata.h new file +2 -0
+struct madera_irqchip_pdata;
+struct madera_codec_pdata;

Why do you need platform data in new code?

Quoted 5 lines
Quoted 3 lines

Answered in a comment in another patch. We care about allowing people to use our chips with systems that don't use devicetree/acpi. There are also many out-of-tree systems.

a) we don't care about out of tree much;

You might not, but as a commercial company we have to.

Quoted 5 lines

b) there are other means to provide date w/o using platform data:
- unified device property API (including built-in device properties)
- bunch of lookup tables GPIO, regulator, PWM, etc
- fwnode graph for more complex cases with device dependencies

Basically same answer as (a)

author maintainer
#12 lore raw

PATCH v8 4/9 mfd: madera: Register map tables for Cirrus Logic CS47L35

In reply to Richard Fitzgerald

Regmap configuration tables for Cirrus Logic CS47L35 codecs.

---
 drivers/mfd/Kconfig          |    7 +
 drivers/mfd/Makefile         |    3 +
 drivers/mfd/cs47l35-tables.c | 1609 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1619 insertions(+)
 create mode 100644 drivers/mfd/cs47l35-tables.c
drivers/mfd/Kconfig +7 -0
index f5ca392f8bc2..da595d71671d 100644
@@ -261,6 +261,13 @@ config MFD_MADERA_SPI
 	  Support for the Cirrus Logic Madera platform audio SoC
 	  core functionality controlled via SPI.
 
+config MFD_CS47L35
+	bool "Cirrus Logic CS47L35"
+	select PINCTRL_CS47L35
+	depends on MFD_MADERA
+	help
+	  Support for Cirrus Logic CS47L35 Smart Codec
+
 config MFD_ASIC3
 	bool "Compaq ASIC3"
 	depends on GPIOLIB && ARM
drivers/mfd/Makefile +3 -0
index 0a89a6a6d793..fd33ea301b3c 100644
@@ -74,6 +74,9 @@ obj-$(CONFIG_MFD_WM8994)	+= wm8994.o
 obj-$(CONFIG_MFD_WM97xx)	+= wm97xx-core.o
 
 madera-objs			:= madera-core.o
+ifeq ($(CONFIG_MFD_CS47L35),y)
+madera-objs			+= cs47l35-tables.o
+endif
 obj-$(CONFIG_MFD_MADERA)	+= madera.o
 obj-$(CONFIG_MFD_MADERA_I2C)	+= madera-i2c.o
 obj-$(CONFIG_MFD_MADERA_SPI)	+= madera-spi.o
drivers/mfd/cs47l35-tables.c new file +1609 -0

1,609 lines not on this page · raw message

Signature · 1 line
2.11.0
author maintainer
#13 lore raw

PATCH v8 5/9 mfd: madera: Register map tables for Cirrus Logic CS47L85

In reply to Richard Fitzgerald

Regmap configuration tables for Cirrus Logic CS47L85 codecs.

---
 drivers/mfd/Kconfig          |    7 +
 drivers/mfd/Makefile         |    3 +
 drivers/mfd/cs47l85-tables.c | 3009 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 3019 insertions(+)
 create mode 100644 drivers/mfd/cs47l85-tables.c
drivers/mfd/Kconfig +7 -0
index da595d71671d..92d555ca21e2 100644
@@ -268,6 +268,13 @@ config MFD_CS47L35
 	help
 	  Support for Cirrus Logic CS47L35 Smart Codec
 
+config MFD_CS47L85
+	bool "Cirrus Logic CS47L85"
+	select PINCTRL_CS47L85
+	depends on MFD_MADERA
+	help
+	  Support for Cirrus Logic CS47L85 Smart Codec
+
 config MFD_ASIC3
 	bool "Compaq ASIC3"
 	depends on GPIOLIB && ARM
drivers/mfd/Makefile +3 -0
index fd33ea301b3c..8c0328c47ab5 100644
@@ -77,6 +77,9 @@ madera-objs			:= madera-core.o
 ifeq ($(CONFIG_MFD_CS47L35),y)
 madera-objs			+= cs47l35-tables.o
 endif
+ifeq ($(CONFIG_MFD_CS47L85),y)
+madera-objs			+= cs47l85-tables.o
+endif
 obj-$(CONFIG_MFD_MADERA)	+= madera.o
 obj-$(CONFIG_MFD_MADERA_I2C)	+= madera-i2c.o
 obj-$(CONFIG_MFD_MADERA_SPI)	+= madera-spi.o
drivers/mfd/cs47l85-tables.c new file +3009 -0

2,978 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.11.0

Part of the diff is not shown here. View the raw message.

author maintainer
#14 lore raw

PATCH v8 6/9 mfd: madera: Register map tables for Cirrus Logic CS47L90/91

In reply to Richard Fitzgerald

Regmap configuration tables for Cirrus Logic CS47L90 and CS47L91 codecs.

---
 drivers/mfd/Kconfig          |    7 +
 drivers/mfd/Makefile         |    3 +
 drivers/mfd/cs47l90-tables.c | 2674 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 2684 insertions(+)
 create mode 100644 drivers/mfd/cs47l90-tables.c
drivers/mfd/Kconfig +7 -0
index 92d555ca21e2..2db1c1c48700 100644
@@ -275,6 +275,13 @@ config MFD_CS47L85
 	help
 	  Support for Cirrus Logic CS47L85 Smart Codec
 
+config MFD_CS47L90
+	bool "Cirrus Logic CS47L90/91"
+	select PINCTRL_CS47L90
+	depends on MFD_MADERA
+	help
+	  Support for Cirrus Logic CS47L90 and CS47L91 Smart Codecs
+
 config MFD_ASIC3
 	bool "Compaq ASIC3"
 	depends on GPIOLIB && ARM
drivers/mfd/Makefile +3 -0
index 8c0328c47ab5..4d0dfd065706 100644
@@ -80,6 +80,9 @@ endif
 ifeq ($(CONFIG_MFD_CS47L85),y)
 madera-objs			+= cs47l85-tables.o
 endif
+ifeq ($(CONFIG_MFD_CS47L90),y)
+madera-objs			+= cs47l90-tables.o
+endif
 obj-$(CONFIG_MFD_MADERA)	+= madera.o
 obj-$(CONFIG_MFD_MADERA_I2C)	+= madera-i2c.o
 obj-$(CONFIG_MFD_MADERA_SPI)	+= madera-spi.o
drivers/mfd/cs47l90-tables.c new file +2674 -0

2,674 lines not on this page · raw message

Signature · 1 line
2.11.0
author maintainer
#15 lore raw

PATCH v8 7/9 pinctrl: madera: Add DT bindings for Cirrus Logic Madera codecs

In reply to Richard Fitzgerald

This is the binding description of the pinctrl driver for Cirrus Logic Madera codecs. The binding uses the generic pinctrl binding so the main purpose here is to describe the device-specific names for groups and functions.

---
 .../bindings/pinctrl/cirrus,madera-pinctrl.txt     | 99 ++++++++++++++++++++++
 1 file changed, 99 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/cirrus,madera-pinctrl.txt
Documentation/devicetree/bindings/pinctrl/cirrus,madera-pinctrl.txt new file +99 -0
new file mode 100644
index 000000000000..b0e36cf0d289
@@ -0,0 +1,99 @@
+Cirrus Logic Madera class audio codecs pinctrl driver
+
+The Cirrus Logic Madera codecs provide a number of GPIO functions for
+interfacing to external hardware and to provide logic outputs to other devices.
+Certain groups of GPIO pins also have an alternate function, normally as an
+audio interface.
+
+The set of available GPIOs, functions and alternate function groups differs
+between codecs so refer to the datasheet for the codec for further information
+on what is supported on that device.
+
+The properties for this driver exist within the parent MFD driver node.
+
+See also
+  the core bindings for the parent MFD driver:
+    Documentation/devicetree/bindings/mfd/madera.txt
+
+  the generic pinmix bindings:
+    Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
+
+Required properties of parent mfd node:
+  - pinctrl-names : must be "default"
+  - pinctrl-0 : a phandle to the node containing the subnodes containing default
+      configurations
+
+Required subnodes:
+  One subnode is required to contain the default settings. It contains an
+  arbitrary number of configuration subnodes, one for each group or pin
+  configuration you want to apply as a default.
+
+Required properties of configuration subnodes:
+  - groups : name of one pin group to configure. One of:
+	aif1, aif2, aif3, aif4, mif1, mif2, mif3, pdmspk1, pdmspk2,
+	dmic4, dmic5, dmic6,
+	gpio1, gpio2, ..., gpio40
+    The gpioN groups select the single pin of this name for configuration
+
+Optional properties of configuration subnodes:
+  Any configuration option not explicitly listed in the dts will be left at
+  chip default setting.
+
+  - function : name of function to assign to this group. One of:
+	aif1, aif2, aif3, aif4, mif1, mif2, mif3, pdmspk1, pdmspk2,
+	dmic3, dmic4, dmic5, dmic6,
+	io, dsp-gpio, irq1, irq2,
+	fll1-clk, fll1-lock, fll2-clk, fll2-lock, fll3-clk, fll3-lock,
+	fllao-clk, fllao-lock,
+	opclk, opclk-async, pwm1, pwm2, spdif,
+	asrc1-in1-lock, asrc1-in2-lock, asrc2-in1-lock, asrc2-in2-lock,
+	spkl-short-circuit, spkr-short-circuit, spk-shutdown,
+	spk-overheat-shutdown, spk-overheat-warn,
+	timer1-sts, timer2-sts, timer3-sts, timer4-sts, timer5-sts, timer6-sts,
+	timer7-sts, timer8-sts,
+	log1-fifo-ne, log2-fifo-ne, log3-fifo-ne, log4-fifo-ne, log5-fifo-ne,
+	log6-fifo-ne, log7-fifo-ne, log8-fifo-ne,
+
+  - bias-disable : disable pull-up and pull-down
+  - bias-bus-hold : enable buskeeper
+  - bias-pull-up : output is pulled-up
+  - bias-pull-down : output is pulled-down
+  - drive-push-pull : CMOS output
+  - drive-open-drain : open-drain output
+  - drive-strength : drive strength in mA. Valid values are 4 or 8
+  - input-schmitt-enable : enable schmitt-trigger mode
+  - input-schmitt-disable : disable schmitt-trigger mode
+  - input-debounce : A value of 0 disables debounce, a value !=0 enables
+	debounce
+  - output-low : set the pin to output mode with low level
+  - output-high : set the pin to output mode with high level
+
+Example:
+
+cs47l85@0 {
+	compatible = "cirrus,cs47l85";
+
+	pinctrl-names = "default";
+	pinctrl-0 = <&cs47l85_defaults>;
+
+	cs47l85_defaults: cs47l85-gpio-defaults {
+		aif1 {
+			groups = "aif1";
+			function = "aif1";
+			bias-bus-hold;
+		};
+
+		aif2 {
+			groups = "aif2";
+			function = "aif2";
+			bias-bus-hold;
+		};
+
+		opclk {
+			groups = "gpio1";
+			function = "opclk";
+			bias-pull-up;
+			drive-strength = <8>;
+		};
+	};
+};
Signature · 1 line
2.11.0
Reviewed-by on v8 7/9
#16 lore raw

Re: [PATCH v8 7/9] pinctrl: madera: Add DT bindings for Cirrus Logic Madera codecs

Quoted 7 lines · Richard Fitzgerald

This is the binding description of the pinctrl driver for Cirrus Logic Madera codecs. The binding uses the generic pinctrl binding so the main purpose here is to describe the device-specific names for groups and functions.

Tell me if you want me to just merge this patch to get your patch stack smaller.

Yours,
Linus Walleij

author maintainer
#17 lore raw

PATCH v8 8/9 pinctrl: madera: Add driver for Cirrus Logic Madera codecs

In reply to Richard Fitzgerald

These codecs have a variable number of I/O lines each of which is individually selectable to a wide range of possible functions.

The functionality is slightly different from the traditional muxed GPIO since most of the functions can be mapped to any pin (and even the same function to multiple pins). Most pins have a dedicated "alternate" function that is only available on that pin. The alternate functions are usually a group of signals, though it is not always necessary to enable the full group, depending on the alternate function and how it is to be used. The mapping between alternate functions and GPIO pins varies between codecs depending on the number of alternate functions and available pins.

---
There are some minor changes since LinusW last reviewed this patch but as they are trivial I have carried forward Linus's Reviewed-by:
- SPDX license headers
- can now build it as a module
- avoided a minor checkpatch warning about an unnecessary else {} in madera_get_group_name()

---
 MAINTAINERS                                  |    2 +
 drivers/pinctrl/Kconfig                      |    1 +
 drivers/pinctrl/Makefile                     |    1 +
 drivers/pinctrl/cirrus/Kconfig               |   15 +
 drivers/pinctrl/cirrus/Makefile              |   13 +
 drivers/pinctrl/cirrus/pinctrl-cs47l35.c     |   45 ++
 drivers/pinctrl/cirrus/pinctrl-cs47l85.c     |   59 ++
 drivers/pinctrl/cirrus/pinctrl-cs47l90.c     |   57 ++
 drivers/pinctrl/cirrus/pinctrl-madera-core.c | 1074 ++++++++++++++++++++++++++
 drivers/pinctrl/cirrus/pinctrl-madera.h      |   41 +
 10 files changed, 1308 insertions(+)
 create mode 100644 drivers/pinctrl/cirrus/Kconfig
 create mode 100644 drivers/pinctrl/cirrus/Makefile
 create mode 100644 drivers/pinctrl/cirrus/pinctrl-cs47l35.c
 create mode 100644 drivers/pinctrl/cirrus/pinctrl-cs47l85.c
 create mode 100644 drivers/pinctrl/cirrus/pinctrl-cs47l90.c
 create mode 100644 drivers/pinctrl/cirrus/pinctrl-madera-core.c
 create mode 100644 drivers/pinctrl/cirrus/pinctrl-madera.h
MAINTAINERS +2 -0
index 865d3a3c9e5f..7a93fee8b637 100644
@@ -3497,9 +3497,11 @@ 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:	Documentation/devicetree/bindings/pinctrl/cirrus,madera-pinctrl.txt
 F:	include/linux/mfd/madera/*
 F:	drivers/mfd/madera*
 F:	drivers/mfd/cs47l*
+F:	drivers/pinctrl/cirrus/*
 
 CLEANCACHE API
 M:	Konrad Rzeszutek Wilk <[email protected]>
drivers/pinctrl/Kconfig +1 -0
index 0f254b35c378..e7cb602127d7 100644
@@ -390,6 +390,7 @@ source "drivers/pinctrl/vt8500/Kconfig"
 source "drivers/pinctrl/mediatek/Kconfig"
 source "drivers/pinctrl/zte/Kconfig"
 source "drivers/pinctrl/meson/Kconfig"
+source "drivers/pinctrl/cirrus/Kconfig"
 
 config PINCTRL_XWAY
 	bool
drivers/pinctrl/Makefile +1 -0
index d3692633e9ed..100a6dae3edc 100644
@@ -68,3 +68,4 @@ obj-$(CONFIG_PINCTRL_UNIPHIER)	+= uniphier/
 obj-$(CONFIG_ARCH_VT8500)	+= vt8500/
 obj-y				+= mediatek/
 obj-$(CONFIG_PINCTRL_ZX)	+= zte/
+obj-y				+= cirrus/
drivers/pinctrl/cirrus/Kconfig new file +15 -0
new file mode 100644
index 000000000000..a86e354bb62a
@@ -0,0 +1,15 @@
+# This is all selected by the Madera MFD driver Kconfig options
+config PINCTRL_MADERA
+	tristate
+	select PINMUX
+	select GENERIC_PINCONF
+
+config PINCTRL_CS47L35
+	bool
+
+config PINCTRL_CS47L85
+	bool
+
+config PINCTRL_CS47L90
+	bool
+
drivers/pinctrl/cirrus/Makefile new file +13 -0
new file mode 100644
index 000000000000..6e4938cde9e3
@@ -0,0 +1,13 @@
+# Cirrus Logic pinctrl drivers
+pinctrl-madera-objs		:= pinctrl-madera-core.o
+ifeq ($(CONFIG_PINCTRL_CS47L35),y)
+pinctrl-madera-objs		+= pinctrl-cs47l35.o
+endif
+ifeq ($(CONFIG_PINCTRL_CS47L85),y)
+pinctrl-madera-objs		+= pinctrl-cs47l85.o
+endif
+ifeq ($(CONFIG_PINCTRL_CS47L90),y)
+pinctrl-madera-objs		+= pinctrl-cs47l90.o
+endif
+
+obj-$(CONFIG_PINCTRL_MADERA)	+= pinctrl-madera.o
drivers/pinctrl/cirrus/pinctrl-cs47l35.c new file +45 -0

45 lines not on this page · raw message

drivers/pinctrl/cirrus/pinctrl-cs47l85.c new file +59 -0

59 lines not on this page · raw message

drivers/pinctrl/cirrus/pinctrl-cs47l90.c new file +57 -0

57 lines not on this page · raw message

drivers/pinctrl/cirrus/pinctrl-madera-core.c new file +1074 -0

1,074 lines not on this page · raw message

drivers/pinctrl/cirrus/pinctrl-madera.h new file +41 -0

41 lines not on this page · raw message

Signature · 1 line
2.11.0
#18 lore raw

Re: [PATCH v8 8/9] pinctrl: madera: Add driver for Cirrus Logic Madera codecs

Quoted 15 lines · Richard Fitzgerald

These codecs have a variable number of I/O lines each of which is individually selectable to a wide range of possible functions.

The functionality is slightly different from the traditional muxed GPIO since most of the functions can be mapped to any pin (and even the same function to multiple pins). Most pins have a dedicated "alternate" function that is only available on that pin. The alternate functions are usually a group of signals, though it is not always necessary to enable the full group, depending on the alternate function and how it is to be used. The mapping between alternate functions and GPIO pins varies between codecs depending on the number of alternate functions and available pins.

Quoted 7 lines

---
There are some minor changes since LinusW last reviewed this patch but as they are trivial I have carried forward Linus's Reviewed-by:
- SPDX license headers
- can now build it as a module
- avoided a minor checkpatch warning about an unnecessary else {} in madera_get_group_name()

It's fine. Keep my Review tag.

Yours,
Linus Walleij

author maintainer
#19 lore raw

PATCH v8 9/9 gpio: madera: Support Cirrus Logic Madera class codecs

In reply to Richard Fitzgerald

This adds support for the GPIOs on Cirrus Logic Madera class codecs. Any pins not used for special functions (see the pinctrl driver) can be used as general single-bit input or output lines. The number of available GPIOs varies between codecs.

Note that this is part of a composite MFD for these codecs and can only be used with the corresponding MFD and other child drivers on those silicon. The GPIO block on these codecs does not exist indepedently of the rest of the MFD.

---
Changes since V7:
As the changes are all small and mostly coding style, I've carried forward Linus's previous ack.

- SPDX license headers
- can now build as a module
- fixed some coding style issues raised by Andy Shevchenko and Linus Walleij
- commented why we are calling gpiochip_add_pin_range()

---
 MAINTAINERS                |   1 +
 drivers/gpio/Kconfig       |   6 ++
 drivers/gpio/Makefile      |   1 +
 drivers/gpio/gpio-madera.c | 203 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 211 insertions(+)
 create mode 100644 drivers/gpio/gpio-madera.c
MAINTAINERS +1 -0
index 7a93fee8b637..ea1a9d8d57d3 100644
@@ -3499,6 +3499,7 @@ S:	Supported
 F:	Documentation/devicetree/bindings/mfd/madera.txt
 F:	Documentation/devicetree/bindings/pinctrl/cirrus,madera-pinctrl.txt
 F:	include/linux/mfd/madera/*
+F:	drivers/gpio/gpio-madera*
 F:	drivers/mfd/madera*
 F:	drivers/mfd/cs47l*
 F:	drivers/pinctrl/cirrus/*
drivers/gpio/Kconfig +6 -0
index dff99871bca8..6683af4205e9 100644
@@ -1025,6 +1025,12 @@ config GPIO_LP87565
 	  This driver can also be built as a module. If so, the module will be
 	  called gpio-lp87565.
 
+config GPIO_MADERA
+	tristate "Cirrus Logic Madera class codecs"
+	depends on PINCTRL_MADERA
+	help
+	  Support for GPIOs on Cirrus Logic Madera class codecs.
+
 config GPIO_MAX77620
 	tristate "GPIO support for PMIC MAX77620 and MAX20024"
 	depends on MFD_MAX77620
drivers/gpio/Makefile +1 -0
index 77f88bc086c4..576235b7e2c0 100644
@@ -71,6 +71,7 @@ obj-$(CONFIG_ARCH_LPC32XX)	+= gpio-lpc32xx.o
 obj-$(CONFIG_GPIO_LP873X)	+= gpio-lp873x.o
 obj-$(CONFIG_GPIO_LP87565)	+= gpio-lp87565.o
 obj-$(CONFIG_GPIO_LYNXPOINT)	+= gpio-lynxpoint.o
+obj-$(CONFIG_GPIO_MADERA)	+= gpio-madera.o
 obj-$(CONFIG_GPIO_MAX3191X)	+= gpio-max3191x.o
 obj-$(CONFIG_GPIO_MAX730X)	+= gpio-max730x.o
 obj-$(CONFIG_GPIO_MAX7300)	+= gpio-max7300.o
drivers/gpio/gpio-madera.c new file +203 -0

203 lines not on this page · raw message

Signature · 1 line
2.11.0
#20 lore raw

Re: [PATCH v8 9/9] gpio: madera: Support Cirrus Logic Madera class codecs

Quoted 10 lines · Richard Fitzgerald

This adds support for the GPIOs on Cirrus Logic Madera class codecs. Any pins not used for special functions (see the pinctrl driver) can be used as general single-bit input or output lines. The number of available GPIOs varies between codecs.

Note that this is part of a composite MFD for these codecs and can only be used with the corresponding MFD and other child drivers on those silicon. The GPIO block on these codecs does not exist indepedently of the rest of the MFD.

drivers/gpio/gpio-madera.c line 24

Quoted 4 lines
drivers/gpio/gpio-madera.c new file +4 -0
+struct madera_gpio {
+       struct madera *madera;
+       struct gpio_chip gpio_chip;
+};

Why do you need this? I suppose one embeds or refers to the other.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#21 lore raw

Re: [PATCH v8 9/9] gpio: madera: Support Cirrus Logic Madera class codecs

Quoted 12 lines · Andy Shevchenko
Quoted 9 lines · Richard Fitzgerald

This adds support for the GPIOs on Cirrus Logic Madera class codecs. Any pins not used for special functions (see the pinctrl driver) can be used as general single-bit input or output lines. The number of available GPIOs varies between codecs.

Note that this is part of a composite MFD for these codecs and can only be used with the corresponding MFD and other child drivers on those silicon. The GPIO block on these codecs does not exist indepedently of the rest of the MFD.

Quoted 7 lines

drivers/gpio/gpio-madera.c line 24

Quoted 4 lines
drivers/gpio/gpio-madera.c new file +4 -0
+struct madera_gpio {
+       struct madera *madera;
+       struct gpio_chip gpio_chip;
+};

Why do you need this? I suppose one embeds or refers to the other.

The gpio_chip is storage for the struct gpio_chip that we're using. It allow us to create dynamically constructed struct gpio_chip based on the template in madera_gpio_chip. See the code in madera_gpio_probe.

There are slight differences between the codecs (currently what we care about is that they have different numbers of gpios.) and as we still want to support pdata we also might have to change .base at runtime.

It's possible to have multiple codecs of different type in one system so patching the static madera_gpio_chip is not viable, we would need different content for each codec.

As almost all members are the same, what we do is use madera_gpio_chip as a template and copy it into the gpio_chip member of struct madera_gpio for this codec. That becomes the struct gpio_chip that we're actually using for this instance of this codec.