Skip to contentSkip to conversation

Lochnagar Driver

PATCH In review Charles Keepax 4 participants 14 messages Nov 8, 2018 – Nov 15, 2018

Subsystems (8)
lore
Share & tools
lore

Charles Keepax

author maintainer
#0 lore raw

v4 cover Lochnagar Driver

Version 4 of this series the big change here is splitting up the device tree into having a node for each of the MFD child drivers. More detailed change logs are given on each patch.

Lee doesn't like the idea of having both mfd_add_devices and of_platform_populate in the MFD driver. Stephen had asked on a previous spin to move the fixed clocks out of the clock driver into device tree and there is a fixed regulator as well that is specified through device tree. Those require having the of_platform_populate there which left the only solution being to move the MFD children into device tree as well.

I have moved the relevant DT settings to be attached to their respective nodes in DT although I guess another option would be to leave all the config on the parent node and just use the child nodes for binding in the drivers, but I decided that was less consistent with other DT usage. But could switch over to it if people prefer.

Thanks,
Charles

Charles Keepax (6):
regulator: lochnagar: Explicitly include register headers
regulator: lochnagar: Move driver to binding from DT
mfd: lochnagar: Add initial binding documentation
mfd: lochnagar: Add support for the Cirrus Logic Lochnagar
clk: lochnagar: Add support for the Cirrus Logic Lochnagar
pinctrl: lochnagar: Add support for the Cirrus Logic Lochnagar

 .../devicetree/bindings/clock/cirrus,lochnagar.txt |   89 ++
 .../devicetree/bindings/mfd/cirrus,lochnagar.txt   |   70 ++
 .../bindings/pinctrl/cirrus,lochnagar.txt          |  141 +++
 .../bindings/regulator/cirrus,lochnagar.txt        |   80 ++
 MAINTAINERS                                        |   17 +
 drivers/clk/Kconfig                                |    7 +
 drivers/clk/Makefile                               |    1 +
 drivers/clk/clk-lochnagar.c                        |  360 ++++++
 drivers/mfd/Kconfig                                |    8 +
 drivers/mfd/Makefile                               |    2 +
 drivers/mfd/lochnagar-i2c.c                        |  394 +++++++
 drivers/pinctrl/cirrus/Kconfig                     |   10 +
 drivers/pinctrl/cirrus/Makefile                    |    2 +
 drivers/pinctrl/cirrus/pinctrl-lochnagar.c         | 1145 ++++++++++++++++++++
 drivers/pinctrl/cirrus/pinctrl-lochnagar.h         |  112 ++
 drivers/regulator/lochnagar-regulator.c            |   10 +-
 include/dt-bindings/clk/lochnagar.h                |   26 +
 include/dt-bindings/pinctrl/lochnagar.h            |  132 +++
 include/linux/mfd/lochnagar.h                      |   55 +
 include/linux/mfd/lochnagar1_regs.h                |  157 +++
 include/linux/mfd/lochnagar2_regs.h                |  253 +++++
 21 files changed, 3070 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/clock/cirrus,lochnagar.txt
 create mode 100644 Documentation/devicetree/bindings/mfd/cirrus,lochnagar.txt
 create mode 100644 Documentation/devicetree/bindings/pinctrl/cirrus,lochnagar.txt
 create mode 100644 Documentation/devicetree/bindings/regulator/cirrus,lochnagar.txt
 create mode 100644 drivers/clk/clk-lochnagar.c
 create mode 100644 drivers/mfd/lochnagar-i2c.c
 create mode 100644 drivers/pinctrl/cirrus/pinctrl-lochnagar.c
 create mode 100644 drivers/pinctrl/cirrus/pinctrl-lochnagar.h
 create mode 100644 include/dt-bindings/clk/lochnagar.h
 create mode 100644 include/dt-bindings/pinctrl/lochnagar.h
 create mode 100644 include/linux/mfd/lochnagar.h
 create mode 100644 include/linux/mfd/lochnagar1_regs.h
 create mode 100644 include/linux/mfd/lochnagar2_regs.h
Signature · 1 line
2.11.0
author maintainer
#1 lore raw

PATCH v4 1/6 regulator: lochnagar: Explicitly include register headers

Review of the MFD component has stated we should not include the register headers through lochnagar.h and thus removed them from that header. Explicitly include them in the end drivers manually.

---
 drivers/regulator/lochnagar-regulator.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/regulator/lochnagar-regulator.c +2 -0
index 2b5073b9ff868..182198246479f 100644
@@ -20,6 +20,8 @@
 #include <linux/regulator/of_regulator.h>
 
 #include <linux/mfd/lochnagar.h>
+#include <linux/mfd/lochnagar1_regs.h>
+#include <linux/mfd/lochnagar2_regs.h>
 
 static const struct regulator_ops lochnagar_micvdd_ops = {
 	.enable = regulator_enable_regmap,
Signature · 1 line
2.11.0
author maintainer
#2 lore raw

PATCH v4 2/6 regulator: lochnagar: Move driver to binding from DT

In reply to Charles Keepax

Based on review comments on the MFD driver, move the child drivers for the Lochnagar MFD over to binding through device tree.

---

Mark, I would maybe hold on merging this one until discussions on this version of the patch chain are done, just incase we decide to go back to the single DT entry.

Thanks,
Charles

 drivers/regulator/lochnagar-regulator.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/regulator/lochnagar-regulator.c +7 -1
index 182198246479f..d08fe830b39c1 100644
@@ -222,7 +222,7 @@ static int lochnagar_regulator_probe(struct platform_device *pdev)
 	struct regulator_dev *rdev;
 	int ret, i;
 
-	config.dev = lochnagar->dev;
+	config.dev = dev;
 	config.regmap = lochnagar->regmap;
 	config.driver_data = lochnagar;
 
@@ -241,9 +241,15 @@ static int lochnagar_regulator_probe(struct platform_device *pdev)
 	return 0;
 }
 
+static const struct of_device_id lochnagar_of_match[] = {
+	{ .compatible = "cirrus,lochnagar-regulator" },
+	{},
+};
+
 static struct platform_driver lochnagar_regulator_driver = {
 	.driver = {
 		.name = "lochnagar-regulator",
+		.of_match_table = of_match_ptr(lochnagar_of_match),
 	},
 
 	.probe = lochnagar_regulator_probe,
Signature · 1 line
2.11.0
maintainer
#3 lore raw

Re: [PATCH 2/6] regulator: lochnagar: Move driver to binding from DT

drivers/regulator/lochnagar-regulator.c static int lochnagar_regulator_probe(struct platform_device *pdev) · line 247

Quoted 4 lines · Charles Keepax
drivers/regulator/lochnagar-regulator.c +4 -0
+static const struct of_device_id lochnagar_of_match[] = {
+	{ .compatible = "cirrus,lochnagar-regulator" },
+	{},
+};

This is obviously just dumping the Linux driver model into the DT, the regulators are clearly different. If you want to explicitly list the regulators in DT it'd be better to reflect the hardware and enumerate the regulators individually - you can use one driver for all the MICVDDs and a separate one for VDDCORE for example.

author maintainer
#4 lore raw

Re: [PATCH 2/6] regulator: lochnagar: Move driver to binding from DT

Quoted 12 lines · Mark Brown

drivers/regulator/lochnagar-regulator.c static int lochnagar_regulator_probe(struct platform_device *pdev) · line 247

Quoted 4 lines · Charles Keepax
drivers/regulator/lochnagar-regulator.c +4 -0
+static const struct of_device_id lochnagar_of_match[] = {
+	{ .compatible = "cirrus,lochnagar-regulator" },
+	{},
+};

This is obviously just dumping the Linux driver model into the DT, the regulators are clearly different. If you want to explicitly list the regulators in DT it'd be better to reflect the hardware and enumerate the regulators individually - you can use one driver for all the MICVDDs and a separate one for VDDCORE for example.

Agreed, would be relatively doable for regulators, might be a bit verbose for the clock, but I really don't see how to handle pinctrl.

I guess I will wait and see what the other maintainers think but personally I would really be inclined to keep the binding the same as the last version if we can.

Thanks,
Charles

author maintainer
#5 lore raw

PATCH v4 3/6 mfd: lochnagar: Add initial binding documentation

In reply to Charles Keepax

Lochnagar is an evaluation and development board for Cirrus Logic Smart CODEC and Amp devices. It allows the connection of most Cirrus Logic devices on mini-cards, as well as allowing connection of various application processor systems to provide a full evaluation platform. This driver supports the board controller chip on the Lochnagar board.

---

I have dropped Rob and Stephen's Acks from this patch on account of the scale of the changes since v3.

Changes since v3:
- Split the binding up into separate parts for the individual subsystems
- Added documentation for the fixed clocks that are done through DT

Thanks,
Charles

 .../devicetree/bindings/clock/cirrus,lochnagar.txt |  89 +++++++++++++
 .../devicetree/bindings/mfd/cirrus,lochnagar.txt   |  70 ++++++++++
 .../bindings/pinctrl/cirrus,lochnagar.txt          | 141 +++++++++++++++++++++
 .../bindings/regulator/cirrus,lochnagar.txt        |  80 ++++++++++++
 include/dt-bindings/clk/lochnagar.h                |  26 ++++
 include/dt-bindings/pinctrl/lochnagar.h            | 132 +++++++++++++++++++
 6 files changed, 538 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/cirrus,lochnagar.txt
 create mode 100644 Documentation/devicetree/bindings/mfd/cirrus,lochnagar.txt
 create mode 100644 Documentation/devicetree/bindings/pinctrl/cirrus,lochnagar.txt
 create mode 100644 Documentation/devicetree/bindings/regulator/cirrus,lochnagar.txt
 create mode 100644 include/dt-bindings/clk/lochnagar.h
 create mode 100644 include/dt-bindings/pinctrl/lochnagar.h
Documentation/devicetree/bindings/clock/cirrus,lochnagar.txt new file +89 -0
new file mode 100644
index 0000000000000..035525da32c8e
@@ -0,0 +1,89 @@
+Cirrus Logic Lochnagar Audio Development Board
+
+Lochnagar is an evaluation and development board for Cirrus Logic
+Smart CODEC and Amp devices. It allows the connection of most Cirrus
+Logic devices on mini-cards, as well as allowing connection of
+various application processor systems to provide a full evaluation
+platform.  Audio system topology, clocking and power can all be
+controlled through the Lochnagar, allowing the device under test
+to be used in a variety of possible use cases.
+
+This binding document describes the binding for the clock portion of
+the driver.
+
+Also see these documents for generic binding information:
+  [1] Clock : ../clock/clock-bindings.txt
+
+And these for relevant defines:
+  [2] include/dt-bindings/clock/lochnagar.h
+
+This binding must be part of the Lochnagar MFD binding:
+  [3] ../mfd/cirrus,lochnagar.txt
+
+Required properties:
+
+  - compatible : One of the following strings:
+                 "cirrus,lochnagar1-clk"
+                 "cirrus,lochnagar2-clk"
+
+  - #clock-cells : Must be 1. The first cell indicates the clock
+    number, see [2] for available clocks and [1].
+
+Optional properties:
+
+  - clocks : Must contain an entry for each clock in clock-names.
+  - clock-names : May contain entries for each of the following
+    clocks:
+     - ln-cdc-clkout : Output clock from CODEC card.
+     - ln-dsp-clkout : Output clock from DSP card.
+     - ln-gf-mclk1,ln-gf-mclk2,ln-gf-mclk3,ln-gf-mclk4 : Optional
+       input audio clocks from host system.
+     - ln-psia1-mclk, ln-psia2-mclk : Optional input audio clocks from
+       external connector.
+     - ln-spdif-clkout : Optional input audio clock from SPDIF.
+     - ln-adat-clkout : Optional input audio clock from ADAT.
+     - ln-pmic-32k : On board fixed regulator.
+     - ln-clk-12m : On board fixed regulator.
+     - ln-clk-11m : On board fixed regulator.
+     - ln-clk-24m : On board fixed regulator.
+     - ln-clk-22m : On board fixed regulator.
+     - ln-usb-clk-24m : On board fixed regulator.
+     - ln-usb-clk-12m : On board fixed regulator.
+
+  - assigned-clocks : A list of Lochnagar clocks to be reparented, see
+    [2] for available clocks.
+  - assigned-clock-parents : Parents to be assigned to the clocks
+    listed in "assigned-clocks".
+
+Optional sub-nodes:
+
+  - fixed-clock nodes may be registered for the following on board clocks:
+     - ln-pmic-32k : 32768 kHz
+     - ln-clk-12m : 12288000 kHz
+     - ln-clk-11m : 11298600 kHz
+     - ln-clk-24m : 24576000 kHz
+     - ln-clk-22m : 22579200 kHz
+     - ln-usb-clk-24m : 24000000 kHz
+     - ln-usb-clk-12m : 12000000 kHz
+
+Example:
+
+lochnagar-clk {
+	compatible = "cirrus,lochnagar2-clk";
+
+	#clock-cells = <1>;
+
+	clocks = <&clk-audio>, <&clk_pmic>;
+	clock-names = "ln-gf-mclk2", "ln-pmic-32k";
+
+	assigned-clocks = <&lochnagar-clk LOCHNAGAR_CDC_MCLK1>,
+			  <&lochnagar-clk LOCHNAGAR_CDC_MCLK2>;
+	assigned-clock-parents = <&clk-audio>,
+				 <&clk-pmic>;
+
+	clk-pmic: clk-pmic {
+		compatible = "fixed-clock";
+		clock-cells = <0>;
+		clock-frequency = <32768>;
+	};
+};
Documentation/devicetree/bindings/mfd/cirrus,lochnagar.txt new file +70 -0

70 lines not on this page · raw message

Documentation/devicetree/bindings/pinctrl/cirrus,lochnagar.txt new file +141 -0

141 lines not on this page · raw message

Documentation/devicetree/bindings/regulator/cirrus,lochnagar.txt new file +80 -0

80 lines not on this page · raw message

include/dt-bindings/clk/lochnagar.h new file +26 -0
new file mode 100644
index 0000000000000..8fa20551ff171
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Device Tree defines for Lochnagar clocking
+ *
+ * Copyright (c) 2017-2018 Cirrus Logic, Inc. and
+ *                         Cirrus Logic International Semiconductor Ltd.
+ *
+ * Author: Charles Keepax <[email protected]>
+ */
+
+#ifndef DT_BINDINGS_CLK_LOCHNAGAR_H
+#define DT_BINDINGS_CLK_LOCHNAGAR_H
+
+#define LOCHNAGAR_CDC_MCLK1		0
+#define LOCHNAGAR_CDC_MCLK2		1
+#define LOCHNAGAR_DSP_CLKIN		2
+#define LOCHNAGAR_GF_CLKOUT1		3
+#define LOCHNAGAR_GF_CLKOUT2		4
+#define LOCHNAGAR_PSIA1_MCLK		5
+#define LOCHNAGAR_PSIA2_MCLK		6
+#define LOCHNAGAR_SPDIF_MCLK		7
+#define LOCHNAGAR_ADAT_MCLK		8
+#define LOCHNAGAR_SOUNDCARD_MCLK	9
+#define LOCHNAGAR_SPDIF_CLKOUT		10
+
+#endif
include/dt-bindings/pinctrl/lochnagar.h new file +132 -0

132 lines not on this page · raw message

Signature · 1 line
2.11.0
#6 lore raw

Re: [PATCH v4 3/6] mfd: lochnagar: Add initial binding documentation

Quoted 17 lines · Charles Keepax

Lochnagar is an evaluation and development board for Cirrus Logic Smart CODEC and Amp devices. It allows the connection of most Cirrus Logic devices on mini-cards, as well as allowing connection of various application processor systems to provide a full evaluation platform. This driver supports the board controller chip on the Lochnagar board.

---

I have dropped Rob and Stephen's Acks from this patch on account of the scale of the changes since v3.

Changes since v3:
- Split the binding up into separate parts for the individual subsystems
- Added documentation for the fixed clocks that are done through DT

Quoted 5 lines

Thanks,
Charles

 .../devicetree/bindings/clock/cirrus,lochnagar.txt |  89 +++++++++++++
 .../devicetree/bindings/mfd/cirrus,lochnagar.txt   |  70 ++++++++++

I think these should all be seperate patches.

Code looks okay to me though.

For my own reference:

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
author maintainer
#7 lore raw

Re: [PATCH v4 3/6] mfd: lochnagar: Add initial binding documentation

Quoted 19 lines · Lee Jones
Quoted 17 lines · Charles Keepax

Lochnagar is an evaluation and development board for Cirrus Logic Smart CODEC and Amp devices. It allows the connection of most Cirrus Logic devices on mini-cards, as well as allowing connection of various application processor systems to provide a full evaluation platform. This driver supports the board controller chip on the Lochnagar board.

---

I have dropped Rob and Stephen's Acks from this patch on account of the scale of the changes since v3.

Changes since v3:
- Split the binding up into separate parts for the individual subsystems
- Added documentation for the fixed clocks that are done through DT

Quoted 8 lines
Quoted 5 lines

Thanks,
Charles

 .../devicetree/bindings/clock/cirrus,lochnagar.txt |  89 +++++++++++++
 .../devicetree/bindings/mfd/cirrus,lochnagar.txt   |  70 ++++++++++

I think these should all be seperate patches.

I will need to do a respin for the regulator changes anyway so can split them up then.

Thanks,
Charles

author maintainer
#8 lore raw

PATCH v4 4/6 mfd: lochnagar: Add support for the Cirrus Logic Lochnagar

In reply to Charles Keepax

Lochnagar is an evaluation and development board for Cirrus Logic Smart CODEC and Amp devices. It allows the connection of most Cirrus Logic devices on mini-cards, as well as allowing connection of various application processor systems to provide a full evaluation platform. This driver supports the board controller chip on the Lochnagar board. Audio system topology, clocking and power can all be controlled through the Lochnagar controller chip, allowing the device under test to be used in a variety of possible use cases.

As the Lochnagar is a fairly complex device this MFD driver allows the drivers for the various features to be bound in. Initially clocking, regulator and pinctrl will be added as these are necessary to configure the system. But in time at least audio and voltage/current monitoring will also be added.

---

Changes since v3:
- Bind in child drivers through device tree rather than using mfd_add_devices
- Remove defaults arrays for regmap
- Use a lot of ... in the regmap readable/volatile callbacks
- Explicitly include register headers, rather than relying on lochnagar.h
- Add some kernel doc
- Some minor cosmetic fixups
- Add a lockdep_assert in lochnagar_update_config

Thanks,
Charles

 MAINTAINERS                         |  17 ++
 drivers/mfd/Kconfig                 |   8 +
 drivers/mfd/Makefile                |   2 +
 drivers/mfd/lochnagar-i2c.c         | 394 ++++++++++++++++++++++++++++++++++++
 include/linux/mfd/lochnagar.h       |  55 +++++
 include/linux/mfd/lochnagar1_regs.h | 157 ++++++++++++++
 include/linux/mfd/lochnagar2_regs.h | 253 +++++++++++++++++++++++
 7 files changed, 886 insertions(+)
 create mode 100644 drivers/mfd/lochnagar-i2c.c
 create mode 100644 include/linux/mfd/lochnagar.h
 create mode 100644 include/linux/mfd/lochnagar1_regs.h
 create mode 100644 include/linux/mfd/lochnagar2_regs.h
MAINTAINERS +17 -0
index f4855974f3250..0398c8752e610 100644
@@ -3567,6 +3567,23 @@ L:	[email protected]
 S:	Maintained
 F:	drivers/net/ethernet/cirrus/ep93xx_eth.c
 
+CIRRUS LOGIC LOCHNAGAR DRIVER
+M:	Charles Keepax <[email protected]>
+M:	Richard Fitzgerald <[email protected]>
+L:	[email protected]
+S:	Supported
+F:	drivers/clk/clk-lochnagar.c
+F:	drivers/mfd/lochnagar-i2c.c
+F:	drivers/pinctrl/cirrus/pinctrl-lochnagar*
+F:	drivers/regulator/lochnagar-regulator.c
+F:	include/dt-bindings/clk/lochnagar.h
+F:	include/dt-bindings/pinctrl/lochnagar.h
+F:	include/linux/mfd/lochnagar*
+F:	Documentation/devicetree/bindings/mfd/cirrus,lochnagar.txt
+F:	Documentation/devicetree/bindings/clock/cirrus,lochnagar.txt
+F:	Documentation/devicetree/bindings/pinctrl/cirrus,lochnagar.txt
+F:	Documentation/devicetree/bindings/regulator/cirrus,lochnagar.txt
+
 CISCO FCOE HBA DRIVER
 M:	Satish Kharat <[email protected]>
 M:	Sesidhar Baddela <[email protected]>
drivers/mfd/Kconfig +8 -0
index 8c5dfdce4326c..51de2db3f6537 100644
@@ -1685,6 +1685,14 @@ config MFD_VX855
 	  VIA VX855/VX875 south bridge. You will need to enable the vx855_spi
 	  and/or vx855_gpio drivers for this to do anything useful.
 
+config MFD_LOCHNAGAR
+	bool "Cirrus Logic Lochnagar Audio Development Board"
+	select MFD_CORE
+	select REGMAP_I2C
+	depends on I2C=y && OF
+	help
+	  Support for Cirrus Logic Lochnagar audio development board.
+
 config MFD_ARIZONA
 	select REGMAP
 	select REGMAP_IRQ
drivers/mfd/Makefile +2 -0
index 12980a4ad4608..93284316d5307 100644
@@ -37,6 +37,8 @@ obj-$(CONFIG_MFD_T7L66XB)	+= t7l66xb.o tmio_core.o
 obj-$(CONFIG_MFD_TC6387XB)	+= tc6387xb.o tmio_core.o
 obj-$(CONFIG_MFD_TC6393XB)	+= tc6393xb.o tmio_core.o
 
+obj-$(CONFIG_MFD_LOCHNAGAR)	+= lochnagar-i2c.o
+
 obj-$(CONFIG_MFD_ARIZONA)	+= arizona-core.o
 obj-$(CONFIG_MFD_ARIZONA)	+= arizona-irq.o
 obj-$(CONFIG_MFD_ARIZONA_I2C)	+= arizona-i2c.o
drivers/mfd/lochnagar-i2c.c new file +394 -0

394 lines not on this page · raw message

include/linux/mfd/lochnagar.h new file +55 -0

55 lines not on this page · raw message

include/linux/mfd/lochnagar1_regs.h new file +157 -0

157 lines not on this page · raw message

include/linux/mfd/lochnagar2_regs.h new file +253 -0

253 lines not on this page · raw message

Signature · 1 line
2.11.0
#9 lore raw

Re: [PATCH v4 4/6] mfd: lochnagar: Add support for the Cirrus Logic Lochnagar

Quoted 159 lines · Charles Keepax

Lochnagar is an evaluation and development board for Cirrus Logic Smart CODEC and Amp devices. It allows the connection of most Cirrus Logic devices on mini-cards, as well as allowing connection of various application processor systems to provide a full evaluation platform. This driver supports the board controller chip on the Lochnagar board. Audio system topology, clocking and power can all be controlled through the Lochnagar controller chip, allowing the device under test to be used in a variety of possible use cases.

As the Lochnagar is a fairly complex device this MFD driver allows the drivers for the various features to be bound in. Initially clocking, regulator and pinctrl will be added as these are necessary to configure the system. But in time at least audio and voltage/current monitoring will also be added.

---

Changes since v3:
- Bind in child drivers through device tree rather than using mfd_add_devices
- Remove defaults arrays for regmap
- Use a lot of ... in the regmap readable/volatile callbacks
- Explicitly include register headers, rather than relying on lochnagar.h
- Add some kernel doc
- Some minor cosmetic fixups
- Add a lockdep_assert in lochnagar_update_config

Thanks,
Charles

 MAINTAINERS                         |  17 ++
 drivers/mfd/Kconfig                 |   8 +
 drivers/mfd/Makefile                |   2 +
 drivers/mfd/lochnagar-i2c.c         | 394 ++++++++++++++++++++++++++++++++++++
 include/linux/mfd/lochnagar.h       |  55 +++++
 include/linux/mfd/lochnagar1_regs.h | 157 ++++++++++++++
 include/linux/mfd/lochnagar2_regs.h | 253 +++++++++++++++++++++++
 7 files changed, 886 insertions(+)
 create mode 100644 drivers/mfd/lochnagar-i2c.c
 create mode 100644 include/linux/mfd/lochnagar.h
 create mode 100644 include/linux/mfd/lochnagar1_regs.h
 create mode 100644 include/linux/mfd/lochnagar2_regs.h
MAINTAINERS +17 -0
index f4855974f3250..0398c8752e610 100644
@@ -3567,6 +3567,23 @@ L:	[email protected]
 S:	Maintained
 F:	drivers/net/ethernet/cirrus/ep93xx_eth.c
 
+CIRRUS LOGIC LOCHNAGAR DRIVER
+M:	Charles Keepax <[email protected]>
+M:	Richard Fitzgerald <[email protected]>
+L:	[email protected]
+S:	Supported
+F:	drivers/clk/clk-lochnagar.c
+F:	drivers/mfd/lochnagar-i2c.c
+F:	drivers/pinctrl/cirrus/pinctrl-lochnagar*
+F:	drivers/regulator/lochnagar-regulator.c
+F:	include/dt-bindings/clk/lochnagar.h
+F:	include/dt-bindings/pinctrl/lochnagar.h
+F:	include/linux/mfd/lochnagar*
+F:	Documentation/devicetree/bindings/mfd/cirrus,lochnagar.txt
+F:	Documentation/devicetree/bindings/clock/cirrus,lochnagar.txt
+F:	Documentation/devicetree/bindings/pinctrl/cirrus,lochnagar.txt
+F:	Documentation/devicetree/bindings/regulator/cirrus,lochnagar.txt
+
 CISCO FCOE HBA DRIVER
 M:	Satish Kharat <[email protected]>
 M:	Sesidhar Baddela <[email protected]>
drivers/mfd/Kconfig +8 -0
index 8c5dfdce4326c..51de2db3f6537 100644
@@ -1685,6 +1685,14 @@ config MFD_VX855
 	  VIA VX855/VX875 south bridge. You will need to enable the vx855_spi
 	  and/or vx855_gpio drivers for this to do anything useful.
 
+config MFD_LOCHNAGAR
+	bool "Cirrus Logic Lochnagar Audio Development Board"
+	select MFD_CORE
+	select REGMAP_I2C
+	depends on I2C=y && OF
+	help
+	  Support for Cirrus Logic Lochnagar audio development board.
+
 config MFD_ARIZONA
 	select REGMAP
 	select REGMAP_IRQ
drivers/mfd/Makefile +2 -0
index 12980a4ad4608..93284316d5307 100644
@@ -37,6 +37,8 @@ obj-$(CONFIG_MFD_T7L66XB)	+= t7l66xb.o tmio_core.o
 obj-$(CONFIG_MFD_TC6387XB)	+= tc6387xb.o tmio_core.o
 obj-$(CONFIG_MFD_TC6393XB)	+= tc6393xb.o tmio_core.o
 
+obj-$(CONFIG_MFD_LOCHNAGAR)	+= lochnagar-i2c.o
+
 obj-$(CONFIG_MFD_ARIZONA)	+= arizona-core.o
 obj-$(CONFIG_MFD_ARIZONA)	+= arizona-irq.o
 obj-$(CONFIG_MFD_ARIZONA_I2C)	+= arizona-i2c.o
drivers/mfd/lochnagar-i2c.c new file +49 -0
new file mode 100644
index 0000000000000..133159d7646ed
@@ -0,0 +1,394 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Lochnagar I2C bus interface
+ *
+ * Copyright (c) 2012-2018 Cirrus Logic, Inc. and
+ *                         Cirrus Logic International Semiconductor Ltd.
+ *
+ * Author: Charles Keepax <[email protected]>
+ */
+
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/gpio/consumer.h>
+#include <linux/i2c.h>
+#include <linux/lockdep.h>
+#include <linux/mfd/core.h>
+#include <linux/mutex.h>
+#include <linux/of.h>
+#include <linux/of_platform.h>
+#include <linux/regmap.h>
+
+#include <linux/mfd/lochnagar.h>
+#include <linux/mfd/lochnagar1_regs.h>
+#include <linux/mfd/lochnagar2_regs.h>
+
+#define LOCHNAGAR_BOOT_RETRIES		10
+#define LOCHNAGAR_BOOT_DELAY_MS		350
+
+#define LOCHNAGAR_CONFIG_POLL_US	10000
+
+static bool lochnagar1_readable_register(struct device *dev, unsigned int reg)
+{
+	switch (reg) {
+	case LOCHNAGAR_SOFTWARE_RESET:
+	case LOCHNAGAR_FIRMWARE_ID1...LOCHNAGAR_FIRMWARE_ID2:
+	case LOCHNAGAR1_CDC_AIF1_SEL...LOCHNAGAR1_CDC_AIF3_SEL:
+	case LOCHNAGAR1_CDC_MCLK1_SEL...LOCHNAGAR1_CDC_MCLK2_SEL:
+	case LOCHNAGAR1_CDC_AIF_CTRL1...LOCHNAGAR1_CDC_AIF_CTRL2:
+	case LOCHNAGAR1_EXT_AIF_CTRL:
+	case LOCHNAGAR1_DSP_AIF1_SEL...LOCHNAGAR1_DSP_AIF2_SEL:
+	case LOCHNAGAR1_DSP_CLKIN_SEL:
+	case LOCHNAGAR1_DSP_AIF:
+	case LOCHNAGAR1_GF_AIF1...LOCHNAGAR1_GF_AIF2:
+	case LOCHNAGAR1_PSIA_AIF:
+	case LOCHNAGAR1_PSIA1_SEL...LOCHNAGAR1_PSIA2_SEL:
+	case LOCHNAGAR1_SPDIF_AIF_SEL:
+	case LOCHNAGAR1_GF_AIF3_SEL...LOCHNAGAR1_GF_AIF4_SEL:
+	case LOCHNAGAR1_GF_CLKOUT1_SEL:

drivers/mfd/lochnagar-i2c.c line 59

Quoted 10 lines
drivers/mfd/lochnagar-i2c.c new file +10 -0
+	case LOCHNAGAR1_GF_AIF1_SEL...LOCHNAGAR1_GF_AIF2_SEL:
+	case LOCHNAGAR1_GF_GPIO2...LOCHNAGAR1_GF_GPIO7:
+	case LOCHNAGAR1_RST:
+	case LOCHNAGAR1_LED1...LOCHNAGAR1_LED2:
+	case LOCHNAGAR1_I2C_CTRL:
+		return true;
+	default:
+		return false;
+	}
+}

Niiiiiice!

Driver is much better for me to swallow like this.

For my own reference:

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
author maintainer
#10 lore raw

PATCH v4 5/6 clk: lochnagar: Add support for the Cirrus Logic Lochnagar

In reply to Charles Keepax

Lochnagar is an evaluation and development board for Cirrus Logic Smart CODEC and Amp devices. It allows the connection of most Cirrus Logic devices on mini-cards, as well as allowing connection of various application processor systems to provide a full evaluation platform. This driver supports the board controller chip on the Lochnagar board.

The Lochnagar can take several input clocks from the host system, provides several of its own clock sources, and provides extensive routing options for those clocks to be supplied to the attached CODEC/Amp device.

---

Changes since v3:
- Driver is bound through device tree rather than using mfd_add_devices
- Explicitly include register headers, rather than relying on lochnagar.h

Thanks,
Charles

 drivers/clk/Kconfig         |   7 +
 drivers/clk/Makefile        |   1 +
 drivers/clk/clk-lochnagar.c | 360 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 368 insertions(+)
 create mode 100644 drivers/clk/clk-lochnagar.c
drivers/clk/Kconfig +7 -0
index 81cdb4eaca07f..2c63c431879f5 100644
@@ -219,6 +219,13 @@ config COMMON_CLK_XGENE
 	---help---
 	  Sypport for the APM X-Gene SoC reference, PLL, and device clocks.
 
+config COMMON_CLK_LOCHNAGAR
+	tristate "Cirrus Logic Lochnagar clock driver"
+	depends on MFD_LOCHNAGAR
+	help
+	  This driver supports the clocking features of the Cirrus Logic
+	  Lochnagar audio development board.
+
 config COMMON_CLK_NXP
 	def_bool COMMON_CLK && (ARCH_LPC18XX || ARCH_LPC32XX)
 	select REGMAP_MMIO if ARCH_LPC32XX
drivers/clk/Makefile +1 -0
index 72be7a38cff1e..2354f0c8c8f17 100644
@@ -30,6 +30,7 @@ obj-$(CONFIG_COMMON_CLK_GEMINI)		+= clk-gemini.o
 obj-$(CONFIG_COMMON_CLK_ASPEED)		+= clk-aspeed.o
 obj-$(CONFIG_ARCH_HIGHBANK)		+= clk-highbank.o
 obj-$(CONFIG_CLK_HSDK)			+= clk-hsdk-pll.o
+obj-$(CONFIG_COMMON_CLK_LOCHNAGAR)	+= clk-lochnagar.o
 obj-$(CONFIG_COMMON_CLK_MAX77686)	+= clk-max77686.o
 obj-$(CONFIG_COMMON_CLK_MAX9485)	+= clk-max9485.o
 obj-$(CONFIG_ARCH_MOXART)		+= clk-moxart.o
drivers/clk/clk-lochnagar.c new file +360 -0

360 lines not on this page · raw message

Signature · 1 line
2.11.0
author maintainer
#11 lore raw

PATCH v4 6/6 pinctrl: lochnagar: Add support for the Cirrus Logic Lochnagar

In reply to Charles Keepax

Lochnagar is an evaluation and development board for Cirrus Logic Smart CODEC and Amp devices. It allows the connection of most Cirrus Logic devices on mini-cards, as well as allowing connection of various application processor systems to provide a full evaluation platform. This driver supports the board controller chip on the Lochnagar board.

Lochnagar provides many pins which can generally be used for an audio function such as an AIF or a PDM interface, but also as GPIOs.

---

Changes since v3:
- Driver is bound through device tree rather than using mfd_add_devices
- Explicitly include register headers, rather than relying on lochnagar.h
- Used unsigned in more places
- Use u16 for register values
- Switch from custom configs of aif-master/slave to input-enable/output-enable
- Use BIT macro

Thanks,
Charles

 drivers/pinctrl/cirrus/Kconfig             |   10 +
 drivers/pinctrl/cirrus/Makefile            |    2 +
 drivers/pinctrl/cirrus/pinctrl-lochnagar.c | 1145 ++++++++++++++++++++++++++++
 drivers/pinctrl/cirrus/pinctrl-lochnagar.h |  112 +++
 4 files changed, 1269 insertions(+)
 create mode 100644 drivers/pinctrl/cirrus/pinctrl-lochnagar.c
 create mode 100644 drivers/pinctrl/cirrus/pinctrl-lochnagar.h
drivers/pinctrl/cirrus/Kconfig +10 -0
index 27013e5949bc1..74af07e251741 100644
@@ -1,3 +1,13 @@
+config PINCTRL_LOCHNAGAR
+	tristate "Cirrus Logic Lochnagar pinctrl driver"
+	depends on MFD_LOCHNAGAR
+	select PINMUX
+	select PINCONF
+	select GENERIC_PINCONF
+	help
+	  This driver supports configuring the GPIO and other pin configuration
+	  of the Cirrus Logic Lochnagar audio development board.
+
 # This is all selected by the Madera MFD driver Kconfig options
 config PINCTRL_MADERA
 	tristate
drivers/pinctrl/cirrus/Makefile +2 -0
index 6e4938cde9e30..20baebf438f62 100644
@@ -1,4 +1,6 @@
 # Cirrus Logic pinctrl drivers
+obj-$(CONFIG_PINCTRL_LOCHNAGAR)	+= pinctrl-lochnagar.o
+
 pinctrl-madera-objs		:= pinctrl-madera-core.o
 ifeq ($(CONFIG_PINCTRL_CS47L35),y)
 pinctrl-madera-objs		+= pinctrl-cs47l35.o
drivers/pinctrl/cirrus/pinctrl-lochnagar.c new file +1145 -0

1,145 lines not on this page · raw message

drivers/pinctrl/cirrus/pinctrl-lochnagar.h new file +112 -0

112 lines not on this page · raw message

Signature · 1 line
2.11.0
Reviewed-by on v4 6/6
#12 lore raw

Re: [PATCH v4 6/6] pinctrl: lochnagar: Add support for the Cirrus Logic Lochnagar

Quoted 7 lines · Charles Keepax

Lochnagar is an evaluation and development board for Cirrus Logic Smart CODEC and Amp devices. It allows the connection of most Cirrus Logic devices on mini-cards, as well as allowing connection of various application processor systems to provide a full evaluation platform. This driver supports the board controller chip on the Lochnagar board.

Quoted 5 lines

Lochnagar provides many pins which can generally be used for an audio function such as an AIF or a PDM interface, but also as GPIOs.

This v4 version looks very good to me!

Nitpicks (fix or not, my review tag stands):

Quoted 2 lines
 drivers/pinctrl/cirrus/pinctrl-lochnagar.c | 1145 ++++++++++++++++++++++++++++
 drivers/pinctrl/cirrus/pinctrl-lochnagar.h |  112 +++

Why don't you just include that header file in the C file. 112 lines +/- on a 1145 line file doesn't matter.

Quoted 1 line

+ priv->gpio_chip = template_chip;

I would just skip the template and just assign struct members directly.

Bonus if you set ->label to something instance-unique as well.

Yours,
Linus Walleij

author maintainer
#13 lore raw

Re: [PATCH v4 6/6] pinctrl: lochnagar: Add support for the Cirrus Logic Lochnagar

Quoted 27 lines · Linus Walleij
Quoted 7 lines · Charles Keepax

Lochnagar is an evaluation and development board for Cirrus Logic Smart CODEC and Amp devices. It allows the connection of most Cirrus Logic devices on mini-cards, as well as allowing connection of various application processor systems to provide a full evaluation platform. This driver supports the board controller chip on the Lochnagar board.

Quoted 5 lines

Lochnagar provides many pins which can generally be used for an audio function such as an AIF or a PDM interface, but also as GPIOs.

This v4 version looks very good to me!

Nitpicks (fix or not, my review tag stands):

Quoted 2 lines
 drivers/pinctrl/cirrus/pinctrl-lochnagar.c | 1145 ++++++++++++++++++++++++++++
 drivers/pinctrl/cirrus/pinctrl-lochnagar.h |  112 +++

Why don't you just include that header file in the C file. 112 lines +/- on a 1145 line file doesn't matter.

Quoted 7 lines
Quoted 1 line

+ priv->gpio_chip = template_chip;

I would just skip the template and just assign struct members directly.

Bonus if you set ->label to something instance-unique as well.

No objection to any of those need to respin for Mark's comments on the regulators anyway, so will wrap these in and add your reviewed by.

Thanks,
Charles