All of lore.kernel.org
 help / color / mirror / Atom feed
* [RESEND PATCH v2 0/4] add mipi_csi_xx gate clocks for SC9863A
@ 2020-05-27  5:36 Chunyan Zhang
  2020-05-27  5:36 ` [RESEND PATCH v2 1/4] clk: sprd: check its parent status before reading gate clock Chunyan Zhang
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Chunyan Zhang @ 2020-05-27  5:36 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: linux-clk, linux-kernel, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Chunyan Zhang

From: Chunyan Zhang <chunyan.zhang@unisoc.com>

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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [RESEND PATCH v2 1/4] clk: sprd: check its parent status before reading gate clock
  2020-05-27  5:36 [RESEND PATCH v2 0/4] add mipi_csi_xx gate clocks for SC9863A Chunyan Zhang
@ 2020-05-27  5:36 ` Chunyan Zhang
  2020-05-27  6:41   ` Stephen Boyd
  2020-05-27  5:36 ` [RESEND PATCH v2 2/4] dt-bindings: clk: sprd: add mipi_csi_xx clocks for SC9863A Chunyan Zhang
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Chunyan Zhang @ 2020-05-27  5:36 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: linux-clk, linux-kernel, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Chunyan Zhang

From: Chunyan Zhang <chunyan.zhang@unisoc.com>

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 <chunyan.zhang@unisoc.com>
---
 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


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [RESEND PATCH v2 2/4] dt-bindings: clk: sprd: add mipi_csi_xx clocks for SC9863A
  2020-05-27  5:36 [RESEND PATCH v2 0/4] add mipi_csi_xx gate clocks for SC9863A Chunyan Zhang
  2020-05-27  5:36 ` [RESEND PATCH v2 1/4] clk: sprd: check its parent status before reading gate clock Chunyan Zhang
@ 2020-05-27  5:36 ` Chunyan Zhang
  2020-05-27  6:41   ` Stephen Boyd
  2020-05-27  5:36 ` [RESEND PATCH v2 3/4] clk: sprd: add dt-bindings include for mipi_csi_xx clocks Chunyan Zhang
  2020-05-27  5:36 ` [RESEND PATCH v2 4/4] clk: sprd: add mipi_csi_xx gate clocks Chunyan Zhang
  3 siblings, 1 reply; 9+ messages in thread
From: Chunyan Zhang @ 2020-05-27  5:36 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: linux-clk, linux-kernel, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Chunyan Zhang

From: Chunyan Zhang <chunyan.zhang@unisoc.com>

mipi_csi_xx clocks are used by camera sensors.

Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
Acked-by: Rob Herring <robh@kernel.org>
---
 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


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [RESEND PATCH v2 3/4] clk: sprd: add dt-bindings include for mipi_csi_xx clocks
  2020-05-27  5:36 [RESEND PATCH v2 0/4] add mipi_csi_xx gate clocks for SC9863A Chunyan Zhang
  2020-05-27  5:36 ` [RESEND PATCH v2 1/4] clk: sprd: check its parent status before reading gate clock Chunyan Zhang
  2020-05-27  5:36 ` [RESEND PATCH v2 2/4] dt-bindings: clk: sprd: add mipi_csi_xx clocks for SC9863A Chunyan Zhang
@ 2020-05-27  5:36 ` Chunyan Zhang
  2020-05-27  6:41   ` Stephen Boyd
  2020-05-27  5:36 ` [RESEND PATCH v2 4/4] clk: sprd: add mipi_csi_xx gate clocks Chunyan Zhang
  3 siblings, 1 reply; 9+ messages in thread
From: Chunyan Zhang @ 2020-05-27  5:36 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: linux-clk, linux-kernel, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Chunyan Zhang

From: Chunyan Zhang <chunyan.zhang@unisoc.com>

mipi_csi_xx clocks are used by camera sensors.

Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
Acked-by: Rob Herring <robh@kernel.org>
---
 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


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [RESEND PATCH v2 4/4] clk: sprd: add mipi_csi_xx gate clocks
  2020-05-27  5:36 [RESEND PATCH v2 0/4] add mipi_csi_xx gate clocks for SC9863A Chunyan Zhang
                   ` (2 preceding siblings ...)
  2020-05-27  5:36 ` [RESEND PATCH v2 3/4] clk: sprd: add dt-bindings include for mipi_csi_xx clocks Chunyan Zhang
@ 2020-05-27  5:36 ` Chunyan Zhang
  2020-05-27  6:41   ` Stephen Boyd
  3 siblings, 1 reply; 9+ messages in thread
From: Chunyan Zhang @ 2020-05-27  5:36 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: linux-clk, linux-kernel, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Chunyan Zhang

From: Chunyan Zhang <chunyan.zhang@unisoc.com>

mipi_csi_xx clocks are used by camera sensors.

Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
---
 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


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [RESEND PATCH v2 1/4] clk: sprd: check its parent status before reading gate clock
  2020-05-27  5:36 ` [RESEND PATCH v2 1/4] clk: sprd: check its parent status before reading gate clock Chunyan Zhang
@ 2020-05-27  6:41   ` Stephen Boyd
  0 siblings, 0 replies; 9+ messages in thread
From: Stephen Boyd @ 2020-05-27  6:41 UTC (permalink / raw)
  To: Chunyan Zhang
  Cc: linux-clk, linux-kernel, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Chunyan Zhang

Quoting Chunyan Zhang (2020-05-26 22:36:35)
> From: Chunyan Zhang <chunyan.zhang@unisoc.com>
> 
> 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 <chunyan.zhang@unisoc.com>
> ---

Applied to clk-next

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RESEND PATCH v2 2/4] dt-bindings: clk: sprd: add mipi_csi_xx clocks for SC9863A
  2020-05-27  5:36 ` [RESEND PATCH v2 2/4] dt-bindings: clk: sprd: add mipi_csi_xx clocks for SC9863A Chunyan Zhang
@ 2020-05-27  6:41   ` Stephen Boyd
  0 siblings, 0 replies; 9+ messages in thread
From: Stephen Boyd @ 2020-05-27  6:41 UTC (permalink / raw)
  To: Chunyan Zhang
  Cc: linux-clk, linux-kernel, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Chunyan Zhang

Quoting Chunyan Zhang (2020-05-26 22:36:36)
> From: Chunyan Zhang <chunyan.zhang@unisoc.com>
> 
> mipi_csi_xx clocks are used by camera sensors.
> 
> Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
> Acked-by: Rob Herring <robh@kernel.org>
> ---

Applied to clk-next

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RESEND PATCH v2 3/4] clk: sprd: add dt-bindings include for mipi_csi_xx clocks
  2020-05-27  5:36 ` [RESEND PATCH v2 3/4] clk: sprd: add dt-bindings include for mipi_csi_xx clocks Chunyan Zhang
@ 2020-05-27  6:41   ` Stephen Boyd
  0 siblings, 0 replies; 9+ messages in thread
From: Stephen Boyd @ 2020-05-27  6:41 UTC (permalink / raw)
  To: Chunyan Zhang
  Cc: linux-clk, linux-kernel, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Chunyan Zhang

Quoting Chunyan Zhang (2020-05-26 22:36:37)
> From: Chunyan Zhang <chunyan.zhang@unisoc.com>
> 
> mipi_csi_xx clocks are used by camera sensors.
> 
> Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
> Acked-by: Rob Herring <robh@kernel.org>
> ---

Applied to clk-next

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RESEND PATCH v2 4/4] clk: sprd: add mipi_csi_xx gate clocks
  2020-05-27  5:36 ` [RESEND PATCH v2 4/4] clk: sprd: add mipi_csi_xx gate clocks Chunyan Zhang
@ 2020-05-27  6:41   ` Stephen Boyd
  0 siblings, 0 replies; 9+ messages in thread
From: Stephen Boyd @ 2020-05-27  6:41 UTC (permalink / raw)
  To: Chunyan Zhang
  Cc: linux-clk, linux-kernel, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Chunyan Zhang

Quoting Chunyan Zhang (2020-05-26 22:36:38)
> From: Chunyan Zhang <chunyan.zhang@unisoc.com>
> 
> mipi_csi_xx clocks are used by camera sensors.
> 
> Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
> ---

Applied to clk-next

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-05-27  6:41 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-27  5:36 [RESEND PATCH v2 0/4] add mipi_csi_xx gate clocks for SC9863A Chunyan Zhang
2020-05-27  5:36 ` [RESEND PATCH v2 1/4] clk: sprd: check its parent status before reading gate clock Chunyan Zhang
2020-05-27  6:41   ` Stephen Boyd
2020-05-27  5:36 ` [RESEND PATCH v2 2/4] dt-bindings: clk: sprd: add mipi_csi_xx clocks for SC9863A Chunyan Zhang
2020-05-27  6:41   ` Stephen Boyd
2020-05-27  5:36 ` [RESEND PATCH v2 3/4] clk: sprd: add dt-bindings include for mipi_csi_xx clocks Chunyan Zhang
2020-05-27  6:41   ` Stephen Boyd
2020-05-27  5:36 ` [RESEND PATCH v2 4/4] clk: sprd: add mipi_csi_xx gate clocks Chunyan Zhang
2020-05-27  6:41   ` Stephen Boyd

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.