add mipi_csi_xx gate clocks for SC9863A
Subsystems (3)
[email protected]
reviewerv2 cover 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(+)
Signature · 1 line
2.20.1
[email protected]
reviewerPATCH 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.
--- drivers/clk/sprd/gate.c | 7 +++++++ drivers/clk/sprd/gate.h | 9 +++++++++ 2 files changed, 16 insertions(+)
drivers/clk/sprd/gate.c +7 -0
@@ -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, ®);if (sg->flags &CLK_GATE_SET_TO_DISABLE )
drivers/clk/sprd/gate.h +9 -0
@@ -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) \
Signature · 1 line
2.20.1
[email protected]
reviewerPATCH v2 2/4 dt-bindings: clk: sprd: add mipi_csi_xx clocks for SC9863A
In reply to [email protected]From: Chunyan Zhang <[email protected]>
mipi_csi_xx clocks are used by camera sensors.
--- Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml +1 -0
@@ -28,6 +28,7 @@ properties: - sprd,sc9863a-rpll - sprd,sc9863a-dpll - sprd,sc9863a-mm-gate + - sprd,sc9863a-mm-clk - sprd,sc9863a-apapb-gate clocks:
Signature · 1 line
2.20.1
[email protected]
reviewerPATCH v2 3/4 clk: sprd: add dt-bindings include for mipi_csi_xx clocks
In reply to [email protected]From: Chunyan Zhang <[email protected]>
mipi_csi_xx clocks are used by camera sensors.
--- include/dt-bindings/clock/sprd,sc9863a-clk.h | 5 +++++ 1 file changed, 5 insertions(+)
include/dt-bindings/clock/sprd,sc9863a-clk.h +5 -0
@@ -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
Signature · 1 line
2.20.1
[email protected]
reviewerPATCH v2 4/4 clk: sprd: add mipi_csi_xx gate clocks
In reply to [email protected]From: Chunyan Zhang <[email protected]>
mipi_csi_xx clocks are used by camera sensors.
--- drivers/clk/sprd/sc9863a-clk.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
drivers/clk/sprd/sc9863a-clk.c +32 -0
@@ -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 }, { }
Signature · 1 line
2.20.1
Chunyan Zhang
reviewerHi Stephen,
Quoted 8 lines · On Tue, 14 Apr 2020 at 11:33, <[email protected]> wrote:
From: Chunyan Zhang <[email protected]>
mipi_csi_xxclocks 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).
Quoted 9 lines
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: addmipi_csi_xxclocks for SC9863A
clk: sprd: add dt-bindings include formipi_csi_xxclocks
clk: sprd: addmipi_csi_xxgate clocks
Do you have comments or could you please take this patchset to your tree?
Thanks,
Chunyan
Quoted 10 lines
.../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