clk: at91: audio PLL clock
Subsystems (5)
cover clk: at91: audio PLL clock
This series covers the addition of the Audio PLL clock found on AT91 SoCs like the SAMA5D2.
I also added the use of these clocks by the ClassD audi amplifier in both SoC and board DT.
The Audio PLL is described in the sama5d2 datasheet chapter "29.8 Audio PLL".
Even if "it works" (!), note that I'm not satisfied with the current code and would need some advice from people more accustomed with the CCF and particularly composite audio PLL/clocks like these. For example, I do not take into account the limits of these clocks (as described in the datasheet) and the dependency between the PAD and the PMC child clocks.
Thanks in advance for your inputs.
Best regards,
Nicolas
Cyrille Pitchen (2):
ARM: dts: at91: sama5d2: add classd nodes
ARM: dts: at91: sama5d2_xplained: add pin muxing and enable classd
Nicolas Ferre (1):
clk: at91: add audio pll clock driver
.../devicetree/bindings/clock/at91-clock.txt | 10 + arch/arm/boot/dts/at91-sama5d2_xplained.dts | 16 ++ arch/arm/boot/dts/sama5d2.dtsi | 39 +++- arch/arm/mach-at91/Kconfig | 4 + drivers/clk/at91/Makefile | 2 + drivers/clk/at91/clk-audio-pll-pad.c | 238 +++++++++++++++++++ drivers/clk/at91/clk-audio-pll-pmc.c | 184 +++++++++++++++ drivers/clk/at91/clk-audio-pll.c | 253 +++++++++++++++++++++ include/linux/clk/at91_pmc.h | 25 ++ 9 files changed, 770 insertions(+), 1 deletion(-) create mode 100644 drivers/clk/at91/clk-audio-pll-pad.c create mode 100644 drivers/clk/at91/clk-audio-pll-pmc.c create mode 100644 drivers/clk/at91/clk-audio-pll.c
Signature · 1 line
2.9.0
RFC PATCH 1/3 clk: at91: add audio pll clock driver
This new clock driver set allows to have a fractional divided clock that would generate a precise clock particularly suitable for audio applications.
The main audio pll clock has two children clocks: one that is connected to the PMC, the other that can directly drive a pad. As these two routes have different enable bits and different dividers and divider formula, they are handled by two different drivers. Each of them would modify the rate of the main audio pll parent.
--- .../devicetree/bindings/clock/at91-clock.txt | 10 + arch/arm/mach-at91/Kconfig | 4 + drivers/clk/at91/Makefile | 2 + drivers/clk/at91/clk-audio-pll-pad.c | 238 +++++++++++++++++++ drivers/clk/at91/clk-audio-pll-pmc.c | 184 +++++++++++++++ drivers/clk/at91/clk-audio-pll.c | 253 +++++++++++++++++++++ include/linux/clk/at91_pmc.h | 25 ++ 7 files changed, 716 insertions(+) create mode 100644 drivers/clk/at91/clk-audio-pll-pad.c create mode 100644 drivers/clk/at91/clk-audio-pll-pmc.c create mode 100644 drivers/clk/at91/clk-audio-pll.c
Documentation/devicetree/bindings/clock/at91-clock.txt +10 -0
@@ -81,6 +81,16 @@ Required properties: "atmel,sama5d2-clk-generated": at91 generated clock + "atmel,sama5d2-clk-audio-pll-frac": + at91 audio fractional pll + + "atmel,sama5d2-clk-audio-pll-pad": + at91 audio pll CLK_AUDIO output pin + + "atmel,sama5d2-clk-audio-pll-pmc" + at91 audio pll ouput on AUDIOPLLCLK that feeds the PMC + and can be used by peripheral clock or generic clock + Required properties for SCKC node: - reg : defines the IO memory reserved for the SCKC. - #size-cells : shall be 0 (reg is used to encode clk id).
arch/arm/mach-at91/Kconfig +4 -0
@@ -17,6 +17,7 @@ config SOC_SAMA5D2 select HAVE_AT91_USB_CLK select HAVE_AT91_H32MX select HAVE_AT91_GENERATED_CLK + select HAVE_AT91_AUDIO_PLL select PINCTRL_AT91PIO4 help Select this if ou are using one of Atmel's SAMA5D2 family SoC.
@@ -114,6 +115,9 @@ config HAVE_AT91_H32MX config HAVE_AT91_GENERATED_CLK bool +config HAVE_AT91_AUDIO_PLL + bool + config SOC_SAM_V4_V5 bool
drivers/clk/at91/Makefile +2 -0
@@ -6,6 +6,8 @@ obj-y += pmc.o sckc.o obj-y += clk-slow.o clk-main.o clk-pll.o clk-plldiv.o clk-master.o obj-y += clk-system.o clk-peripheral.o clk-programmable.o +obj-$(CONFIG_HAVE_AT91_AUDIO_PLL) += clk-audio-pll.o +obj-$(CONFIG_HAVE_AT91_AUDIO_PLL) += clk-audio-pll-pmc.o clk-audio-pll-pad.o obj-$(CONFIG_HAVE_AT91_UTMI) += clk-utmi.o obj-$(CONFIG_HAVE_AT91_USB_CLK) += clk-usb.o obj-$(CONFIG_HAVE_AT91_SMD) += clk-smd.o
drivers/clk/at91/clk-audio-pll-pad.c new file +238 -0
238 lines not on this page · raw message
drivers/clk/at91/clk-audio-pll-pmc.c new file +184 -0
184 lines not on this page · raw message
drivers/clk/at91/clk-audio-pll.c new file +253 -0
253 lines not on this page · raw message
include/linux/clk/at91_pmc.h +25 -0
@@ -185,4 +185,29 @@#define AT91_PMC_PCR_EN (0x1 << 28)/* Enable */ #define AT91_PMC_PCR_GCKEN (0x1 << 29)/* GCK Enable */ +#define AT91_PMC_AUDIO_PLL0 0x14c +#define AT91_PMC_AUDIO_PLL_PLLEN (1 << 0) +#define AT91_PMC_AUDIO_PLL_PADEN (1 << 1) +#define AT91_PMC_AUDIO_PLL_PMCEN (1 << 2) +#define AT91_PMC_AUDIO_PLL_RESETN (1 << 3) +#define AT91_PMC_AUDIO_PLL_ND_OFFSET 8 +#define AT91_PMC_AUDIO_PLL_ND_MASK (0x7f << AT91_PMC_AUDIO_PLL_ND_OFFSET) +#define AT91_PMC_AUDIO_PLL_ND (n) ((n) << AT91_PMC_AUDIO_PLL_ND_OFFSET) +#define AT91_PMC_AUDIO_PLL_QDPMC_OFFSET 16 +#define AT91_PMC_AUDIO_PLL_QDPMC_MASK (0x7f << AT91_PMC_AUDIO_PLL_QDPMC_OFFSET) +#define AT91_PMC_AUDIO_PLL_QDPMC (n) ((n) << AT91_PMC_AUDIO_PLL_QDPMC_OFFSET) + +#define AT91_PMC_AUDIO_PLL1 0x150 +#define AT91_PMC_AUDIO_PLL_FRACR_MASK 0x3fffff +#define AT91_PMC_AUDIO_PLL_QDPAD_OFFSET 24 +#define AT91_PMC_AUDIO_PLL_QDPAD_MASK (0x7f << AT91_PMC_AUDIO_PLL_QDPAD_OFFSET) +#define AT91_PMC_AUDIO_PLL_QDPAD (n) ((n) << AT91_PMC_AUDIO_PLL_QDPAD_OFFSET) +#define AT91_PMC_AUDIO_PLL_QDPAD_DIV_OFFSET AT91_PMC_AUDIO_PLL_QDPAD_OFFSET +#define AT91_PMC_AUDIO_PLL_QDPAD_DIV_MASK (0x3 << AT91_PMC_AUDIO_PLL_QDPAD_DIV_OFFSET) +#define AT91_PMC_AUDIO_PLL_QDPAD_DIV (n) ((n) << AT91_PMC_AUDIO_PLL_QDPAD_DIV_OFFSET) +#define AT91_PMC_AUDIO_PLL_QDPAD_EXTDIV_OFFSET 26 +#define AT91_PMC_AUDIO_PLL_QDPAD_EXTDIV_MAX 0x1f +#define AT91_PMC_AUDIO_PLL_QDPAD_EXTDIV_MASK (AT91_PMC_AUDIO_PLL_QDPAD_EXTDIV_MAX << AT91_PMC_AUDIO_PLL_QDPAD_EXTDIV_OFFSET) +#define AT91_PMC_AUDIO_PLL_QDPAD_EXTDIV (n) ((n) << AT91_PMC_AUDIO_PLL_QDPAD_EXTDIV_OFFSET) +#endif
Signature · 1 line
2.9.0
RFC PATCH 2/3 ARM: dts: at91: sama5d2: add classd nodes
In reply to Nicolas FerreFrom: Cyrille Pitchen <[email protected]>
This patch adds nodes for the classd device and its generated clock.
--- arch/arm/boot/dts/sama5d2.dtsi | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-)
arch/arm/boot/dts/sama5d2.dtsi +38 -1
@@ -447,6 +447,24 @@ clocks = <&plla>; }; + audio_pll_frac: audiopll_fracck { + compatible = "atmel,sama5d2-clk-audio-pll-frac"; + #clock-cells = <0>; + clocks = <&main>; + }; + + audio_pll_pad: audiopll_padck { + compatible = "atmel,sama5d2-clk-audio-pll-pad"; + #clock-cells = <0>; + clocks = <&audio_pll_frac>; + }; + + audio_pll_pmc: audiopll_pmcck { + compatible = "atmel,sama5d2-clk-audio-pll-pmc"; + #clock-cells = <0>; + clocks = <&audio_pll_frac>; + }; + utmi: utmick { compatible = "atmel,at91sam9x5-clk-utmi"; #clock-cells = <0>;
@@ -836,7 +854,7 @@ #address-cells = <1>; #size-cells = <0>; interrupt-parent = <&pmc>; - clocks = <&clk32k>, <&main>, <&plladiv>, <&utmi>, <&mck>; + clocks = <&clk32k>, <&main>, <&plladiv>, <&utmi>, <&mck>, <&audio_pll_pmc>; sdmmc0_gclk: sdmmc0_gclk { #clock-cells = <0>;
@@ -880,6 +898,12 @@ #clock-cells = <0>; reg = <55>; }; + + classd_gclk: classd_gclk { + #clock-cells = <0>; + reg = <59>; + atmel,clk-output-range = <0 100000000>; + }; }; };
@@ -1279,6 +1303,19 @@ status = "okay"; }; + classd: classd at fc048000 { + compatible = "atmel,sama5d2-classd"; + reg = <0xfc048000 0x100>; + interrupts = <59 IRQ_TYPE_LEVEL_HIGH 7>; + dmas = <&dma0 + (AT91_XDMAC_DT_MEM_IF(0) | AT91_XDMAC_DT_PER_IF(1) | + AT91_XDMAC_DT_PERID(47))>; + dma-names = "tx"; + clocks = <&classd_clk>, <&classd_gclk>, <&audio_pll_pmc>; + clock-names = "pclk", "gclk", "aclk"; + status = "disabled"; + }; + chipid at fc069000 { compatible = "atmel,sama5d2-chipid"; reg = <0xfc069000 0x8>;
Signature · 1 line
2.9.0
RFC PATCH 3/3 ARM: dts: at91: sama5d2_xplained: add pin muxing and enable classd
In reply to Nicolas FerreFrom: Cyrille Pitchen <[email protected]>
This patch adds the pin muxing for classd and enables it.
--- arch/arm/boot/dts/at91-sama5d2_xplained.dts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
arch/arm/boot/dts/at91-sama5d2_xplained.dts +16 -0
@@ -332,6 +332,14 @@ bias-pull-up; }; + pinctrl_classd_default: classd_default { + pinmux = <PIN_PB1__CLASSD_R0>, + <PIN_PB2__CLASSD_R1>, + <PIN_PB3__CLASSD_R2>, + <PIN_PB4__CLASSD_R3>; + bias-pull-up; + }; + pinctrl_flx0_default: flx0_default { pinmux = <PIN_PB28__FLEXCOM0_IO0>, <PIN_PB29__FLEXCOM0_IO1>;
@@ -464,6 +472,14 @@ }; }; + + classd: classd at fc048000 { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_classd_default>; + atmel,pwm-type = "diff"; + atmel,non-overlap-time = <10>; + status = "okay"; + }; }; };
Signature · 1 line
2.9.0
Le 06/12/2016 ? 11:55, Nicolas Ferre a ?crit :
Quoted 7 lines
This series covers the addition of the Audio PLL clock found on AT91 SoCs like the SAMA5D2.
I also added the use of these clocks by the ClassD audi amplifier in both SoC and board DT.The Audio PLL is described in the sama5d2 datasheet chapter "29.8 Audio PLL".
Quoted 7 lines
Even if "it works" (!), note that I'm not satisfied with the current code and would need some advice from people more accustomed with the CCF and particularly composite audio PLL/clocks like these. For example, I do not take into account the limits of these clocks (as described in the datasheet) and the dependency between the PAD and the PMC child clocks.
Thanks in advance for your inputs.
Note as well that Boris already sent me a review of the first posting of this patch ("[PATCH] clk: at91: add audio pll clock driver" on 31 Jul. 2015) and most of his comments are still relevant.
https://patchwork.kernel.org/patch/6910111/
https://www.spinics.net/lists/arm-kernel/msg436120.html
But I would like some comments about the whole architecture of these clocks and how I could rearrange them and maybe use some of the common facilities of the CCF (composite with gate + fractionnal? + divider?, etc.)
Regards,
Quoted 21 lines
Cyrille Pitchen (2):
ARM: dts: at91: sama5d2: add classd nodes
ARM: dts: at91:sama5d2_xplained: add pin muxing and enable classdNicolas Ferre (1):
clk: at91: add audio pll clock driver.../devicetree/bindings/clock/at91-clock.txt | 10 + arch/arm/boot/dts/at91-sama5d2_xplained.dts | 16 ++ arch/arm/boot/dts/sama5d2.dtsi | 39 +++- arch/arm/mach-at91/Kconfig | 4 + drivers/clk/at91/Makefile | 2 + drivers/clk/at91/clk-audio-pll-pad.c | 238 +++++++++++++++++++ drivers/clk/at91/clk-audio-pll-pmc.c | 184 +++++++++++++++ drivers/clk/at91/clk-audio-pll.c | 253 +++++++++++++++++++++ include/linux/clk/at91_pmc.h | 25 ++ 9 files changed, 770 insertions(+), 1 deletion(-) create mode 100644 drivers/clk/at91/clk-audio-pll-pad.c create mode 100644 drivers/clk/at91/clk-audio-pll-pmc.c create mode 100644 drivers/clk/at91/clk-audio-pll.c
Signature · 1 line
Nicolas Ferre