2020-04-14 14:13:08

by Chunyan Zhang

[permalink] [raw]
Subject: [PATCH v2 0/4] add mipi_csi_xx gate clocks for SC9863A

From: Chunyan Zhang <[email protected]>

mipi_csi_xx clocks are used by camera sensors. These clocks cannot be
accessed (even read) if their parent gate clock is disabled. So this
patchset also add a check to parent clocks when reading these gate
clocks which marked with the specific flag (SPRD_GATE_NON_AON).

changes from v1:
* added Rob's acked-by;

Chunyan Zhang (4):
clk: sprd: check its parent status before reading gate clock
dt-bindings: clk: sprd: add mipi_csi_xx clocks for SC9863A
clk: sprd: add dt-bindings include for mipi_csi_xx clocks
clk: sprd: add mipi_csi_xx gate clocks

.../bindings/clock/sprd,sc9863a-clk.yaml | 1 +
drivers/clk/sprd/gate.c | 7 ++++
drivers/clk/sprd/gate.h | 9 ++++++
drivers/clk/sprd/sc9863a-clk.c | 32 +++++++++++++++++++
include/dt-bindings/clock/sprd,sc9863a-clk.h | 5 +++
5 files changed, 54 insertions(+)

--
2.20.1


2020-04-14 14:14:37

by Chunyan Zhang

[permalink] [raw]
Subject: [PATCH v2 2/4] dt-bindings: clk: sprd: add mipi_csi_xx clocks for SC9863A

From: Chunyan Zhang <[email protected]>

mipi_csi_xx clocks are used by camera sensors.

Signed-off-by: Chunyan Zhang <[email protected]>
Acked-by: Rob Herring <[email protected]>
---
Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml | 1 +
1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml b/Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml
index bb3a78d8105e..87e8349a539a 100644
--- a/Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml
+++ b/Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml
@@ -28,6 +28,7 @@ properties:
- sprd,sc9863a-rpll
- sprd,sc9863a-dpll
- sprd,sc9863a-mm-gate
+ - sprd,sc9863a-mm-clk
- sprd,sc9863a-apapb-gate

clocks:
--
2.20.1

2020-04-14 14:14:39

by Chunyan Zhang

[permalink] [raw]
Subject: [PATCH v2 1/4] clk: sprd: check its parent status before reading gate clock

From: Chunyan Zhang <[email protected]>

Some clocks only can be accessed if their parent is enabled. mipi_csi_xx
clocks on SC9863A are an examples. We have to ensure the parent clock is
enabled when reading those clocks.

Signed-off-by: Chunyan Zhang <[email protected]>
---
drivers/clk/sprd/gate.c | 7 +++++++
drivers/clk/sprd/gate.h | 9 +++++++++
2 files changed, 16 insertions(+)

diff --git a/drivers/clk/sprd/gate.c b/drivers/clk/sprd/gate.c
index 574cfc116bbc..56e1714b541e 100644
--- a/drivers/clk/sprd/gate.c
+++ b/drivers/clk/sprd/gate.c
@@ -94,8 +94,15 @@ static int sprd_gate_is_enabled(struct clk_hw *hw)
{
struct sprd_gate *sg = hw_to_sprd_gate(hw);
struct sprd_clk_common *common = &sg->common;
+ struct clk_hw *parent;
unsigned int reg;

+ if (sg->flags & SPRD_GATE_NON_AON) {
+ parent = clk_hw_get_parent(hw);
+ if (!parent || !clk_hw_is_enabled(parent))
+ return 0;
+ }
+
regmap_read(common->regmap, common->reg, &reg);

if (sg->flags & CLK_GATE_SET_TO_DISABLE)
diff --git a/drivers/clk/sprd/gate.h b/drivers/clk/sprd/gate.h
index b55817869367..e738dafa4fe9 100644
--- a/drivers/clk/sprd/gate.h
+++ b/drivers/clk/sprd/gate.h
@@ -19,6 +19,15 @@ struct sprd_gate {
struct sprd_clk_common common;
};

+/*
+ * sprd_gate->flags is used for:
+ * CLK_GATE_SET_TO_DISABLE BIT(0)
+ * CLK_GATE_HIWORD_MASK BIT(1)
+ * CLK_GATE_BIG_ENDIAN BIT(2)
+ * so we define new flags from BIT(3)
+ */
+#define SPRD_GATE_NON_AON BIT(3) /* not alway powered on, check before read */
+
#define SPRD_SC_GATE_CLK_HW_INIT_FN(_struct, _name, _parent, _reg, \
_sc_offset, _enable_mask, _flags, \
_gate_flags, _udelay, _ops, _fn) \
--
2.20.1

2020-04-14 14:15:11

by Chunyan Zhang

[permalink] [raw]
Subject: [PATCH v2 4/4] clk: sprd: add mipi_csi_xx gate clocks

From: Chunyan Zhang <[email protected]>

mipi_csi_xx clocks are used by camera sensors.

Signed-off-by: Chunyan Zhang <[email protected]>
---
drivers/clk/sprd/sc9863a-clk.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)

diff --git a/drivers/clk/sprd/sc9863a-clk.c b/drivers/clk/sprd/sc9863a-clk.c
index a0631f7756cf..f67bd08f225c 100644
--- a/drivers/clk/sprd/sc9863a-clk.c
+++ b/drivers/clk/sprd/sc9863a-clk.c
@@ -1615,6 +1615,36 @@ static const struct sprd_clk_desc sc9863a_mm_gate_desc = {
.hw_clks = &sc9863a_mm_gate_hws,
};

+/* camera sensor clocks */
+static SPRD_GATE_CLK_HW(mipi_csi_clk, "mipi-csi-clk", &mahb_ckg_eb.common.hw,
+ 0x20, BIT(16), 0, SPRD_GATE_NON_AON);
+static SPRD_GATE_CLK_HW(mipi_csi_s_clk, "mipi-csi-s-clk", &mahb_ckg_eb.common.hw,
+ 0x24, BIT(16), 0, SPRD_GATE_NON_AON);
+static SPRD_GATE_CLK_HW(mipi_csi_m_clk, "mipi-csi-m-clk", &mahb_ckg_eb.common.hw,
+ 0x28, BIT(16), 0, SPRD_GATE_NON_AON);
+
+static struct sprd_clk_common *sc9863a_mm_clk_clks[] = {
+ /* address base is 0x60900000 */
+ &mipi_csi_clk.common,
+ &mipi_csi_s_clk.common,
+ &mipi_csi_m_clk.common,
+};
+
+static struct clk_hw_onecell_data sc9863a_mm_clk_hws = {
+ .hws = {
+ [CLK_MIPI_CSI] = &mipi_csi_clk.common.hw,
+ [CLK_MIPI_CSI_S] = &mipi_csi_s_clk.common.hw,
+ [CLK_MIPI_CSI_M] = &mipi_csi_m_clk.common.hw,
+ },
+ .num = CLK_MM_CLK_NUM,
+};
+
+static const struct sprd_clk_desc sc9863a_mm_clk_desc = {
+ .clk_clks = sc9863a_mm_clk_clks,
+ .num_clk_clks = ARRAY_SIZE(sc9863a_mm_clk_clks),
+ .hw_clks = &sc9863a_mm_clk_hws,
+};
+
static SPRD_SC_GATE_CLK_FW_NAME(sim0_eb, "sim0-eb", "ext-26m", 0x0,
0x1000, BIT(0), 0, 0);
static SPRD_SC_GATE_CLK_FW_NAME(iis0_eb, "iis0-eb", "ext-26m", 0x0,
@@ -1737,6 +1767,8 @@ static const struct of_device_id sprd_sc9863a_clk_ids[] = {
.data = &sc9863a_aonapb_gate_desc },
{ .compatible = "sprd,sc9863a-mm-gate", /* 0x60800000 */
.data = &sc9863a_mm_gate_desc },
+ { .compatible = "sprd,sc9863a-mm-clk", /* 0x60900000 */
+ .data = &sc9863a_mm_clk_desc },
{ .compatible = "sprd,sc9863a-apapb-gate", /* 0x71300000 */
.data = &sc9863a_apapb_gate_desc },
{ }
--
2.20.1

2020-04-14 14:17:23

by Chunyan Zhang

[permalink] [raw]
Subject: [PATCH v2 3/4] clk: sprd: add dt-bindings include for mipi_csi_xx clocks

From: Chunyan Zhang <[email protected]>

mipi_csi_xx clocks are used by camera sensors.

Signed-off-by: Chunyan Zhang <[email protected]>
Acked-by: Rob Herring <[email protected]>
---
include/dt-bindings/clock/sprd,sc9863a-clk.h | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/include/dt-bindings/clock/sprd,sc9863a-clk.h b/include/dt-bindings/clock/sprd,sc9863a-clk.h
index 901ba59676c2..4e030421641f 100644
--- a/include/dt-bindings/clock/sprd,sc9863a-clk.h
+++ b/include/dt-bindings/clock/sprd,sc9863a-clk.h
@@ -308,6 +308,11 @@
#define CLK_MCPHY_CFG_EB 14
#define CLK_MM_GATE_NUM (CLK_MCPHY_CFG_EB + 1)

+#define CLK_MIPI_CSI 0
+#define CLK_MIPI_CSI_S 1
+#define CLK_MIPI_CSI_M 2
+#define CLK_MM_CLK_NUM (CLK_MIPI_CSI_M + 1)
+
#define CLK_SIM0_EB 0
#define CLK_IIS0_EB 1
#define CLK_IIS1_EB 2
--
2.20.1

2020-04-27 02:39:43

by Chunyan Zhang

[permalink] [raw]
Subject: Re: [PATCH v2 0/4] add mipi_csi_xx gate clocks for SC9863A

Hi Stephen,

On Tue, 14 Apr 2020 at 11:33, <[email protected]> wrote:
>
> From: Chunyan Zhang <[email protected]>
>
> mipi_csi_xx clocks are used by camera sensors. These clocks cannot be
> accessed (even read) if their parent gate clock is disabled. So this
> patchset also add a check to parent clocks when reading these gate
> clocks which marked with the specific flag (SPRD_GATE_NON_AON).
>
> changes from v1:
> * added Rob's acked-by;
>
> Chunyan Zhang (4):
> clk: sprd: check its parent status before reading gate clock
> dt-bindings: clk: sprd: add mipi_csi_xx clocks for SC9863A
> clk: sprd: add dt-bindings include for mipi_csi_xx clocks
> clk: sprd: add mipi_csi_xx gate clocks
>

Do you have comments or could you please take this patchset to your tree?

Thanks,
Chunyan

> .../bindings/clock/sprd,sc9863a-clk.yaml | 1 +
> drivers/clk/sprd/gate.c | 7 ++++
> drivers/clk/sprd/gate.h | 9 ++++++
> drivers/clk/sprd/sc9863a-clk.c | 32 +++++++++++++++++++
> include/dt-bindings/clock/sprd,sc9863a-clk.h | 5 +++
> 5 files changed, 54 insertions(+)
>
> --
> 2.20.1
>