Skip to contentSkip to conversation

clk: Add driver for MAX9485

PATCH Superseded Daniel Mack 2 participants 3 messages May 21, 2018 – May 23, 2018

Subsystems (2)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clk: Add driver for MAX9485

From: Daniel Mack <[email protected]>

This patch adds a driver for MAX9485, a programmable audio clock generator.

The device requires a 27.000 MHz clock input. It can provide a gated buffered output of its input clock and two gated outputs of a PLL that can generate one out of 16 discrete frequencies. There is only one PLL however, so the two gated outputs will always have the same frequency but they can be switched individually.

The driver for this device exposes 4 clocks in total:

- MAX9485_MCLKOUT: A gated, buffered output of the input clock
- MAX9485_CLKOUT: A PLL that can be configured to 16 different
discrete frequencies
- MAX9485_CLKOUT[1,2]: Two gated outputs for MAX9485_CLKOUT

Some PLL output frequencies can be achieved with different register settings. The driver will select the one with lowest jitter in such cases.

---
 .../devicetree/bindings/clock/maxim,max9485.txt    |  59 ++++
 drivers/clk/Kconfig                                |   8 +
 drivers/clk/Makefile                               |   1 +
 drivers/clk/clk-max9485.c                          | 379 +++++++++++++++++++++
 include/dt-bindings/clock/maxim,max9485.h          |  19 ++
 5 files changed, 466 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/maxim,max9485.txt
 create mode 100644 drivers/clk/clk-max9485.c
 create mode 100644 include/dt-bindings/clock/maxim,max9485.h
Documentation/devicetree/bindings/clock/maxim,max9485.txt new file +59 -0
new file mode 100644
index 000000000000..43713031be2c
@@ -0,0 +1,59 @@
+Devicetree bindings for Maxim MAX9485 Programmable Audio Clock Generator
+
+The driver for this device exposes 4 clocks in total:
+
+- MAX9485_MCLKOUT: 	A gated, buffered output of the input clock of 27 MHz
+- MAX9485_CLKOUT:	A PLL that can be configured to 16 different discrete
+			frequencies
+- MAX9485_CLKOUT[1,2]:	Two gated outputs for MAX9485_CLKOUT
+
+MAX9485_CLKOUT[1,2] are children of MAX9485_CLKOUT which upchain all rate set
+requests.
+
+Required properties:
+- compatible:	"maxim,max9485"
+- clocks:	Input clock, must provice 27.000 MHz
+- clock-names:	Must be set to "xclk"
+- #clock-cells: From common clock binding; shall be set to 1
+
+Optional properties:
+- reset-gpio:		GPIO descriptor connected to the #RESET input pin
+- vdd-supply:		A regulator node for Vdd
+- clock-output-names:	Name of output clocks, as defined in common clock
+			bindings
+
+If not explicitly set, the output names are "mclkout", "clkout", "clkout1"
+and "clkout2".
+
+Clocks are defined as preprocessor macros in the dt-binding header.
+
+Example:
+
+	#include <dt-bindings/clock/maxim,max9485.h>
+
+	xo_27mhz: xo_27mhz {
+		compatible = "fixed-clock";
+		#clock-cells = <0>;
+		clock-frequency = <27000000>;
+	};
+
+	&i2c0 {
+		max9485: max9485@63 {
+			compatible = "maxim,max9485";
+			clock-names = "xclk";
+			clocks = <&xo_27mhz>;
+			reg = <0x63>;
+			reset-gpios = <&gpio 1 GPIO_ACTIVE_HIGH>;
+			vdd-supply = <&3v3_reg>;
+			#clock-cells = <1>;
+		};
+	};
+
+	// Clock consumer node
+
+	foo@0 {
+		compatible = "bar,foo";
+		/* ... */
+		clock-names = "foo-intput-clk";
+		clocks = <&max9485 MAX9485_CLKOUT1>;
+	};
drivers/clk/Kconfig +8 -0
index 34968a381d0f..f8ab54c41d16 100644
@@ -45,6 +45,14 @@ config COMMON_CLK_MAX77686
 	  This driver supports Maxim 77620/77686/77802 crystal oscillator
 	  clock.
 
+config COMMON_CLK_MAX9485
+	tristate "Clock driver for Maxim 9485 Programmable Clock Generator"
+	depends on I2C
+	depends on OF
+	depends on GPIOLIB || COMPILE_TEST
+	---help---
+	  This driver supports Maxim 9485 Programmable Audio Clock Generator
+
 config COMMON_CLK_RK808
 	tristate "Clock driver for RK805/RK808/RK818"
 	depends on MFD_RK808
drivers/clk/Makefile +1 -0
index de6d06ac790b..27417ba3c1df 100644
@@ -31,6 +31,7 @@ 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_MAX77686)	+= clk-max77686.o
+obj-$(CONFIG_COMMON_CLK_MAX9485)	+= clk-max9485.o
 obj-$(CONFIG_ARCH_MOXART)		+= clk-moxart.o
 obj-$(CONFIG_ARCH_NOMADIK)		+= clk-nomadik.o
 obj-$(CONFIG_ARCH_NSPIRE)		+= clk-nspire.o
drivers/clk/clk-max9485.c new file +379 -0

379 lines not on this page · raw message

include/dt-bindings/clock/maxim,max9485.h new file +19 -0
new file mode 100644
index 000000000000..23add67f32a7
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2018 Daniel Mack
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#ifndef __DT_BINDINGS_MAX9485_CLK_H
+#define __DT_BINDINGS_MAX9485_CLK_H
+
+#define MAX9485_MCLKOUT	0
+#define MAX9485_CLKOUT	1
+#define MAX9485_CLKOUT1	2
+#define MAX9485_CLKOUT2	3
+
+#endif /* __DT_BINDINGS_MAX9485_CLK_H */
Signature · 1 line
2.14.3
maintainer
#1 lore raw
Quoted 20 lines · Daniel Mack

From: Daniel Mack <[email protected]>

This patch adds a driver for MAX9485, a programmable audio clock generator.

The device requires a 27.000 MHz clock input. It can provide a gated buffered output of its input clock and two gated outputs of a PLL that can generate one out of 16 discrete frequencies. There is only one PLL however, so the two gated outputs will always have the same frequency but they can be switched individually.

The driver for this device exposes 4 clocks in total:

- MAX9485_MCLKOUT: A gated, buffered output of the input clock
- MAX9485_CLKOUT: A PLL that can be configured to 16 different
discrete frequencies
- MAX9485_CLKOUT[1,2]: Two gated outputs for MAX9485_CLKOUT

Some PLL output frequencies can be achieved with different register settings. The driver will select the one with lowest jitter in such cases.

Quoted 7 lines
---
 .../devicetree/bindings/clock/maxim,max9485.txt    |  59 ++++
 drivers/clk/Kconfig                                |   8 +
 drivers/clk/Makefile                               |   1 +
 drivers/clk/clk-max9485.c                          | 379 +++++++++++++++++++++
 include/dt-bindings/clock/maxim,max9485.h          |  19 ++

The 2 DT files should be a separate patch.

Quoted 11 lines
 5 files changed, 466 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/maxim,max9485.txt
 create mode 100644 drivers/clk/clk-max9485.c
 create mode 100644 include/dt-bindings/clock/maxim,max9485.h
Documentation/devicetree/bindings/clock/maxim,max9485.txt new file +0 -0
new file mode 100644
index 000000000000..43713031be2c

Documentation/devicetree/bindings/clock/maxim,max9485.txt line 3

Quoted 3 lines
Documentation/devicetree/bindings/clock/maxim,max9485.txt new file +3 -0
@@ -0,0 +1,59 @@
+Devicetree bindings for Maxim MAX9485 Programmable Audio Clock Generator
+
+The driver for this device exposes 4 clocks in total:

Bindings describe h/w, not drivers.

Quoted 6 lines
Documentation/devicetree/bindings/clock/maxim,max9485.txt new file +6 -0
+- MAX9485_MCLKOUT: 	A gated, buffered output of the input clock of 27 MHz
+- MAX9485_CLKOUT:	A PLL that can be configured to 16 different discrete
+			frequencies
+- MAX9485_CLKOUT[1,2]:	Two gated outputs for MAX9485_CLKOUT
+
+MAX9485_CLKOUT[1,2] are children of MAX9485_CLKOUT which upchain all rate set

Documentation/devicetree/bindings/clock/maxim,max9485.txt line 20

Quoted 10 lines
Documentation/devicetree/bindings/clock/maxim,max9485.txt new file +10 -0
+requests.
+
+Required properties:
+- compatible:	"maxim,max9485"
+- clocks:	Input clock, must provice 27.000 MHz
+- clock-names:	Must be set to "xclk"
+- #clock-cells: From common clock binding; shall be set to 1
+
+Optional properties:
+- reset-gpio:		GPIO descriptor connected to the #RESET input pin

reset-gpios

Quoted 4 lines
Documentation/devicetree/bindings/clock/maxim,max9485.txt new file +4 -0
+- vdd-supply:		A regulator node for Vdd
+- clock-output-names:	Name of output clocks, as defined in common clock
+			bindings
+

Documentation/devicetree/bindings/clock/maxim,max9485.txt line 34

Quoted 10 lines
Documentation/devicetree/bindings/clock/maxim,max9485.txt new file +10 -0
+If not explicitly set, the output names are "mclkout", "clkout", "clkout1"
+and "clkout2".
+
+Clocks are defined as preprocessor macros in the dt-binding header.
+
+Example:
+
+	#include <dt-bindings/clock/maxim,max9485.h>
+
+	xo_27mhz: xo_27mhz {

Don't use '_' in node names.

Documentation/devicetree/bindings/clock/maxim,max9485.txt line 41

Quoted 7 lines
Documentation/devicetree/bindings/clock/maxim,max9485.txt new file +7 -0
+		compatible = "fixed-clock";
+		#clock-cells = <0>;
+		clock-frequency = <27000000>;
+	};
+
+	&i2c0 {
+		max9485: max9485@63 {

clock-controller@63

Quoted 26 lines
Documentation/devicetree/bindings/clock/maxim,max9485.txt new file +18 -0
+			compatible = "maxim,max9485";
+			clock-names = "xclk";
+			clocks = <&xo_27mhz>;
+			reg = <0x63>;
+			reset-gpios = <&gpio 1 GPIO_ACTIVE_HIGH>;
+			vdd-supply = <&3v3_reg>;
+			#clock-cells = <1>;
+		};
+	};
+
+	// Clock consumer node
+
+	foo@0 {
+		compatible = "bar,foo";
+		/* ... */
+		clock-names = "foo-intput-clk";
+		clocks = <&max9485 MAX9485_CLKOUT1>;
+	};
include/dt-bindings/clock/maxim,max9485.h new file +0 -0
new file mode 100644
index 000000000000..23add67f32a7

include/dt-bindings/clock/maxim,max9485.h line 7

Quoted 7 lines
include/dt-bindings/clock/maxim,max9485.h new file +7 -0
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2018 Daniel Mack
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.

Don't need this with the SPDX tag.

Quoted 19 lines
include/dt-bindings/clock/maxim,max9485.h new file +12 -0
+ *
+ */
+
+#ifndef __DT_BINDINGS_MAX9485_CLK_H
+#define __DT_BINDINGS_MAX9485_CLK_H
+
+#define MAX9485_MCLKOUT	0
+#define MAX9485_CLKOUT	1
+#define MAX9485_CLKOUT1	2
+#define MAX9485_CLKOUT2	3
+
+#endif /* __DT_BINDINGS_MAX9485_CLK_H */
Signature · 6 lines
2.14.3

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw

Hi Rob,

Thanks for the review!

Quoted 29 lines · Rob Herring
Quoted 20 lines · Daniel Mack

From: Daniel Mack <[email protected]>

This patch adds a driver for MAX9485, a programmable audio clock generator.

The device requires a 27.000 MHz clock input. It can provide a gated buffered output of its input clock and two gated outputs of a PLL that can generate one out of 16 discrete frequencies. There is only one PLL however, so the two gated outputs will always have the same frequency but they can be switched individually.

The driver for this device exposes 4 clocks in total:

- MAX9485_MCLKOUT: A gated, buffered output of the input clock
- MAX9485_CLKOUT: A PLL that can be configured to 16 different
discrete frequencies
- MAX9485_CLKOUT[1,2]: Two gated outputs for MAX9485_CLKOUT

Some PLL output frequencies can be achieved with different register settings. The driver will select the one with lowest jitter in such cases.

Quoted 7 lines
---
  .../devicetree/bindings/clock/maxim,max9485.txt    |  59 ++++
  drivers/clk/Kconfig                                |   8 +
  drivers/clk/Makefile                               |   1 +
  drivers/clk/clk-max9485.c                          | 379 +++++++++++++++++++++
  include/dt-bindings/clock/maxim,max9485.h          |  19 ++
Quoted 1 line

The 2 DT files should be a separate patch.

Sure, I can do that. In order to keep the series bisectable however, that would mean that the bindings come in first, and then the actual implementation because that also depends on maxim,max9485.h. Is that okay?

I agree with the rest of your comments.

Thanks,
Daniel