Skip to content

Commit cd3ebcf

Browse files
authored
Clk gp mnd (#657)
Clk gp mnd
2 parents 3f167fb + cd6b879 commit cd3ebcf

10 files changed

Lines changed: 539 additions & 3 deletions

File tree

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/clock/qcom,clk-gp-mnd.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Qualcomm Peripheral Web's PDM GP_MN Clock Divider
8+
9+
maintainers:
10+
- Taniya Das <taniya.das@oss.qualcomm.com>
11+
12+
description: |
13+
The Peripheral Web's PDM GP_MN clock divider receives an input clock
14+
(TCXO4) with frequency Fin and generates an output clock with
15+
frequency Fout = Fin * (M / N) and a duty cycle controlled by D
16+
and routed over a gpio pin.
17+
18+
The divider is configured using three registers:
19+
20+
- GP_MN_CLK_MDIV: holds the M value.
21+
- GP_MN_CLK_NDIV: holds the ones complement of (N - M).
22+
- GP_MN_CLK_DUTY: holds the D value.
23+
24+
For every N input clock cycles the GP_MN produces M output clock
25+
cycles. D is the number of native clock cycles in which the GP_MN
26+
output is low, counted over 2^13 native clock cycles.
27+
28+
Hardware constraints:
29+
30+
M <= 511
31+
N <= 8191
32+
N > 2 * M
33+
M < D < (N - M)
34+
M and N must be coprime (no common divisor)
35+
36+
properties:
37+
compatible:
38+
const: qcom,clk-gp-mnd
39+
40+
reg:
41+
maxItems: 1
42+
43+
clocks:
44+
items:
45+
- description: PDM XO4 source clock
46+
- description: PDM AHB bus clock for register access
47+
48+
clock-names:
49+
items:
50+
- const: pdm_clk
51+
- const: ahb_clk
52+
53+
'#clock-cells':
54+
const: 0
55+
56+
clock-output-names:
57+
maxItems: 1
58+
59+
pinctrl-0:
60+
description: Pin configuration for the GP_MN output in the active state.
61+
62+
pinctrl-names:
63+
items:
64+
- const: active
65+
66+
assigned-clocks:
67+
maxItems: 1
68+
description: Parent clock phandle used to set the input frequency.
69+
70+
assigned-clock-rates:
71+
maxItems: 1
72+
description: |
73+
Rate for the parent clock in Hz.
74+
Supported rates: 19200000, 9600000, 6400000, 4800000.
75+
76+
required:
77+
- compatible
78+
- reg
79+
- clocks
80+
- clock-names
81+
- '#clock-cells'
82+
- clock-output-names
83+
- pinctrl-0
84+
- pinctrl-names
85+
- assigned-clocks
86+
- assigned-clock-rates
87+
88+
additionalProperties: false
89+
90+
examples:
91+
- |
92+
#include <dt-bindings/clock/qcom,gcc-sdm845.h>
93+
gp_mn: clock-controller@88d3000 {
94+
compatible = "qcom,clk-gp-mnd";
95+
reg = <0x88d3000 0xc>;
96+
clocks = <&gcc GCC_PDM_XO4_CLK>,
97+
<&gcc GCC_PDM_AHB_CLK>;
98+
clock-names = "pdm_clk", "ahb_clk";
99+
clock-output-names = "gp_mn_clk";
100+
pinctrl-0 = <&gp_mn_pin_active>;
101+
pinctrl-names = "active";
102+
assigned-clocks = <&gcc GCC_PDM_XO4_CLK>;
103+
assigned-clock-rates = <4800000>;
104+
#clock-cells = <0>;
105+
};

arch/arm64/boot/dts/qcom/lemans.dtsi

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4045,6 +4045,20 @@
40454045
};
40464046
};
40474047

4048+
gp_mn: clock-controller@88d3000 {
4049+
compatible = "qcom,clk-gp-mnd";
4050+
reg = <0x0 0x088d3000 0x0 0xc>;
4051+
clocks = <&gcc GCC_PDM_XO4_CLK>,
4052+
<&gcc GCC_PDM_AHB_CLK>;
4053+
clock-names = "pdm_clk", "ahb_clk";
4054+
clock-output-names = "gp_mn_clk";
4055+
#clock-cells = <0>;
4056+
pinctrl-names = "active";
4057+
pinctrl-0 = <&gp_mn_active>;
4058+
assigned-clocks = <&gcc GCC_PDM_XO4_CLK>;
4059+
assigned-clock-rates = <4800000>;
4060+
};
4061+
40484062
usb_0_hsphy: phy@88e4000 {
40494063
compatible = "qcom,sa8775p-usb-hs-phy",
40504064
"qcom,usb-snps-hs-5nm-phy";
@@ -5646,6 +5660,13 @@
56465660
bias-disable;
56475661
};
56485662

5663+
gp_mn_active: gp_mn_active-state {
5664+
pins = "gpio35";
5665+
function = "gp_mn";
5666+
drive-strength = <2>;
5667+
bias-disable;
5668+
};
5669+
56495670
hs0_mi2s_active: hs0-mi2s-active-state {
56505671
pins = "gpio114", "gpio115", "gpio116", "gpio117";
56515672
function = "hs0_mi2s";

arch/arm64/boot/dts/qcom/monaco.dtsi

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4803,6 +4803,20 @@
48034803
};
48044804
};
48054805

4806+
gp_mn: clock-controller@88d3000 {
4807+
compatible = "qcom,clk-gp-mnd";
4808+
reg = <0x0 0x088d3000 0x0 0xc>;
4809+
clocks = <&gcc GCC_PDM_XO4_CLK>,
4810+
<&gcc GCC_PDM_AHB_CLK>;
4811+
clock-names = "pdm_clk", "ahb_clk";
4812+
clock-output-names = "gp_mn_clk";
4813+
#clock-cells = <0>;
4814+
pinctrl-names = "active";
4815+
pinctrl-0 = <&gp_mn_active>;
4816+
assigned-clocks = <&gcc GCC_PDM_XO4_CLK>;
4817+
assigned-clock-rates = <4800000>;
4818+
};
4819+
48064820
usb_1_hsphy: phy@8904000 {
48074821
compatible = "qcom,qcs8300-usb-hs-phy",
48084822
"qcom,usb-snps-hs-7nm-phy";
@@ -6269,6 +6283,13 @@
62696283
bias-disable;
62706284
};
62716285

6286+
gp_mn_active: gp_mn_active-state {
6287+
pins = "gpio32";
6288+
function = "gp_mn";
6289+
drive-strength = <2>;
6290+
bias-disable;
6291+
};
6292+
62726293
hs0_mi2s_active: hs0-mi2s-active-state {
62736294
pins = "gpio106", "gpio107", "gpio108", "gpio109";
62746295
function = "hs0_mi2s";

arch/arm64/boot/dts/qcom/sc7280.dtsi

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4347,6 +4347,20 @@
43474347
usb-role-switch;
43484348
};
43494349

4350+
gp_mn: clock-controller@88d3000 {
4351+
compatible = "qcom,clk-gp-mnd";
4352+
reg = <0x0 0x088d3000 0x0 0xc>;
4353+
clocks = <&gcc GCC_PDM_XO4_CLK>,
4354+
<&gcc GCC_PDM_AHB_CLK>;
4355+
clock-names = "pdm_clk", "ahb_clk";
4356+
clock-output-names = "gp_mn_clk";
4357+
#clock-cells = <0>;
4358+
pinctrl-names = "active";
4359+
pinctrl-0 = <&gp_mn_active>;
4360+
assigned-clocks = <&gcc GCC_PDM_XO4_CLK>;
4361+
assigned-clock-rates = <4800000>;
4362+
};
4363+
43504364
qspi: spi@88dc000 {
43514365
compatible = "qcom,sc7280-qspi", "qcom,qspi-v1";
43524366
reg = <0 0x088dc000 0 0x1000>;
@@ -5852,6 +5866,13 @@
58525866
function = "edp_hot";
58535867
};
58545868

5869+
gp_mn_active: gp_mn_active-state {
5870+
pins = "gpio35";
5871+
function = "gp_mn";
5872+
drive-strength = <2>;
5873+
bias-disable;
5874+
};
5875+
58555876
mi2s0_data0: mi2s0-data0-state {
58565877
pins = "gpio98";
58575878
function = "mi2s0_data0";

drivers/clk/qcom/Kconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1635,4 +1635,19 @@ config SM_VIDEOCC_8450
16351635
SM8450 or SM8475 devices.
16361636
Say Y if you want to support video devices and functionality such as
16371637
video encode/decode.
1638+
1639+
config QCOM_CLK_GP_MND
1640+
tristate "Qualcomm PDM GP_MN clock divider"
1641+
depends on ARM64 || COMPILE_TEST
1642+
help
1643+
Support for the Qualcomm PDM GP_MN clock divider found in PDM
1644+
(Pulse Density Modulation) hardware blocks.
1645+
Given an input clock of frequency Fin (TCXO4), the output
1646+
frequency is Fout = Fin * (M / N). For every N input cycles
1647+
the divider produces M output cycles. D controls the duty
1648+
cycle: it is the number of native clock cycles in which the
1649+
GP_MN output is low, counted over 8192 native clock cycles.
1650+
1651+
Say Y or M if you want to support GP_MN-based frequency and
1652+
duty-cycle configuration on Qualcomm SoCs.
16381653
endif

drivers/clk/qcom/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ obj-$(CONFIG_SM_VIDEOCC_8450) += videocc-sm8450.o
193193
obj-$(CONFIG_SM_VIDEOCC_8550) += videocc-sm8550.o
194194
obj-$(CONFIG_SM_VIDEOCC_MILOS) += videocc-milos.o
195195
obj-$(CONFIG_SPMI_PMIC_CLKDIV) += clk-spmi-pmic-div.o
196+
obj-$(CONFIG_QCOM_CLK_GP_MND) += clk-gp-mnd.o
196197
obj-$(CONFIG_KPSS_XCC) += kpss-xcc.o
197198
obj-$(CONFIG_QCOM_HFPLL) += hfpll.o
198199
obj-$(CONFIG_KRAITCC) += krait-cc.o

0 commit comments

Comments
 (0)