clk: spacemit: add K1 reset support
Subsystems (4)
v4 cover clk: spacemit: add K1 reset support
This series adds reset controller support for the SpacemiT K1 SoC.
As before, this version is built upon the clock controller driver that Haylen Chu has out for review (currently at v7):
https://lore.kernel.org/lkml/[email protected]/
All of these patches are available here:
https://github.com/riscstar/linux/tree/outgoing/reset-v4
Between version 3 and version 4:
- Now based on Haylen Chu's v7 clock code, built on v6.15-rc2.
- Added Krzysztof's Reviewed-by on the first patch.
Here is version 2 of this series.
https://lore.kernel.org/lkml/[email protected]/
Between version 2 and version 3 there was no feedback, however:
- Haylen posted v6 of the clock series, and it included some changes that affected the logic in this reset code.
- I was informed that defining CCU nodes without any clocks led to warnings about "clocks" being a required property when running "make dtbs_check". For that reason, I made clock properties optional for reset-only CCU nodes.
- This code is now based on v6.15-rc1, which includes a few commits that were listed as dependencies previously.
Here is version 2 of this series.
https://lore.kernel.org/lkml/[email protected]/
Between version 1 and version 2:
- Added Rob's Reviewed-by tag on the first patch
- Renamed the of_match_data data type (and one or two other symbols) to use "spacemit" rather than "k1".
- Replaced the abbreviated "rst" or "RST" in names of newly-defined sympols with "reset" or "RESET" respectively.
- Eliminated rcdev_to_controller(), which was only used once.
- Changed a function that unsafely did a read/modify/write of a register to use regmap_update_bits() instead as suggested by Haylen.
- Eliminated a null check for a pointer known to be non-null.
- Reordered the assignment of reset controller device fields.
- Added a "sentinel" comment as requested by Yixun.
- Updated to be based on Linux v6.14 final.
Here is the first version of this series.
https://lore.kernel.org/lkml/[email protected]/
-Alex
Alex Elder (7):
dt-bindings: soc: spacemit: define spacemit,k1-ccu resets
clk: spacemit: rename spacemit_ccu_data fields
clk: spacemit: add reset controller support
clk: spacemit: define existing syscon resets
clk: spacemit: make clocks optional
clk: spacemit: define new syscons with only resets
riscv: dts: spacemit: add reset support for the K1 SoC
.../soc/spacemit/spacemit,k1-syscon.yaml | 29 +- arch/riscv/boot/dts/spacemit/k1.dtsi | 18 + drivers/clk/spacemit/ccu-k1.c | 330 +++++++++++++++++- .../dt-bindings/clock/spacemit,k1-syscon.h | 128 +++++++ 4 files changed, 482 insertions(+), 23 deletions(-)
base-commit: 846ce0a9d3e86830a3c6253c3b62104b369d6a95
Signature · 1 line
2.45.2
PATCH v4 1/7 dt-bindings: soc: spacemit: define spacemit,k1-ccu resets
There are additional SpacemiT syscon CCUs whose registers control both clocks and resets: RCPU, RCPU2, and APBC2. Unlike those defined previously, these will (initially) support only resets. They do not incorporate power domain functionality.
Previously the clock properties were required for all compatible nodes. Make that requirement only apply to the three existing CCUs (APBC, APMU, and MPMU), so that the new reset-only CCUs can go without specifying them.
Define the index values for resets associated with all SpacemiT K1 syscon nodes, including those with clocks already defined, as well as the new ones (without clocks).
--- .../soc/spacemit/spacemit,k1-syscon.yaml | 29 +++- .../dt-bindings/clock/spacemit,k1-syscon.h | 128 ++++++++++++++++++ 2 files changed, 150 insertions(+), 7 deletions(-)
Documentation/devicetree/bindings/soc/spacemit/spacemit,k1-syscon.yaml +22 -7
@@ -19,6 +19,9 @@ properties: - spacemit,k1-syscon-apbc - spacemit,k1-syscon-apmu - spacemit,k1-syscon-mpmu + - spacemit,k1-syscon-rcpu + - spacemit,k1-syscon-rcpu2 + - spacemit,k1-syscon-apbc2 reg: maxItems: 1
@@ -47,9 +50,6 @@ properties: required: - compatible - reg - - clocks - - clock-names - - "#clock-cells" - "#reset-cells" allOf:
@@ -57,13 +57,28 @@ allOf: properties: compatible: contains: - const: spacemit,k1-syscon-apbc + enum: + - spacemit,k1-syscon-apmu + - spacemit,k1-syscon-mpmu then: - properties: - "#power-domain-cells": false - else: required: - "#power-domain-cells" + else: + properties: + "#power-domain-cells": false + - if: + properties: + compatible: + contains: + enum: + - spacemit,k1-syscon-apbc + - spacemit,k1-syscon-apmu + - spacemit,k1-syscon-mpmu + then: + required: + - clocks + - clock-names + - "#clock-cells" additionalProperties: false
include/dt-bindings/clock/spacemit,k1-syscon.h +128 -0
144 lines not on this page · raw message
Signature · 1 line
2.45.2
PATCH v4 2/7 clk: spacemit: rename spacemit_ccu_data fields
In reply to Alex ElderAdd "clk_" to the names of the fields in the spacemit_ccu_data structure type. This prepares it for the addition of two similar fields dedicated to resets.
--- drivers/clk/spacemit/ccu-k1.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
drivers/clk/spacemit/ccu-k1.c +14 -14
@@ -130,8 +130,8 @@#define APMU_EMAC1_CLK_RES_CTRL 0x3ecstruct spacemit_ccu_data { -struct clk_hw **hws; -size_t num; +struct clk_hw **clk_hws; +size_t clk_num; };/* APBS clocks start, APBS region contains and only contains all PLL clocks */
@@ -819,8 +819,8 @@ static struct clk_hw *k1_ccu_pll_hws[] = { };static const struct spacemit_ccu_data k1_ccu_pll_data = { - .hws = k1_ccu_pll_hws, - .num =ARRAY_SIZE (k1_ccu_pll_hws), + .clk_hws = k1_ccu_pll_hws, + .clk_num =ARRAY_SIZE (k1_ccu_pll_hws), };static struct clk_hw *k1_ccu_mpmu_hws[] = {
@@ -860,8 +860,8 @@ static struct clk_hw *k1_ccu_mpmu_hws[] = { };static const struct spacemit_ccu_data k1_ccu_mpmu_data = { - .hws = k1_ccu_mpmu_hws, - .num =ARRAY_SIZE (k1_ccu_mpmu_hws), + .clk_hws = k1_ccu_mpmu_hws, + .clk_num =ARRAY_SIZE (k1_ccu_mpmu_hws), };static struct clk_hw *k1_ccu_apbc_hws[] = {
@@ -968,8 +968,8 @@ static struct clk_hw *k1_ccu_apbc_hws[] = { };static const struct spacemit_ccu_data k1_ccu_apbc_data = { - .hws = k1_ccu_apbc_hws, - .num =ARRAY_SIZE (k1_ccu_apbc_hws), + .clk_hws = k1_ccu_apbc_hws, + .clk_num =ARRAY_SIZE (k1_ccu_apbc_hws), };static struct clk_hw *k1_ccu_apmu_hws[] = {
@@ -1038,8 +1038,8 @@ static struct clk_hw *k1_ccu_apmu_hws[] = { };static const struct spacemit_ccu_data k1_ccu_apmu_data = { - .hws = k1_ccu_apmu_hws, - .num =ARRAY_SIZE (k1_ccu_apmu_hws), + .clk_hws = k1_ccu_apmu_hws, + .clk_num =ARRAY_SIZE (k1_ccu_apmu_hws), }; static int spacemit_ccu_register(struct device *dev,
@@ -1050,13 +1050,13 @@ static int spacemit_ccu_register(struct device *dev,struct clk_hw_onecell_data *clk_data;int i, ret; - clk_data =devm_kzalloc (dev,struct_size (clk_data, hws, data->num), + clk_data =devm_kzalloc (dev,struct_size (clk_data, hws, data->clk_num),GFP_KERNEL );if (!clk_data)return -ENOMEM ; -for (i =0 ; i < data->num; i++) { -struct clk_hw *hw = data->hws[i]; +for (i =0 ; i < data->clk_num; i++) { +struct clk_hw *hw = data->clk_hws[i];struct ccu_common *common;const char *name;
@@ -1081,7 +1081,7 @@ static int spacemit_ccu_register(struct device *dev, clk_data->hws[i] = hw; } - clk_data->num = data->num; + clk_data->num = data->clk_num; ret =devm_of_clk_add_hw_provider (dev, of_clk_hw_onecell_get, clk_data);if (ret)
Signature · 1 line
2.45.2
Re: [PATCH v4 2/7] clk: spacemit: rename spacemit_ccu_data fields
Quoted 5 lines · Alex Elder
Add "
clk_" to the names of the fields in thespacemit_ccu_datastructure type. This prepares it for the addition of two similar fields dedicated to resets.Signed-off-by Alex Elder <[email protected]>
Quoted 92 lines
--- drivers/clk/spacemit/ccu-k1.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)drivers/clk/spacemit/ccu-k1.c +14
-14@@ -130,8 +130,8 @@#define APMU_EMAC1_CLK_RES_CTRL 0x3ecstruct spacemit_ccu_data { -struct clk_hw **hws; -size_t num; +struct clk_hw **clk_hws; +size_t clk_num; };/* APBS clocks start, APBS region contains and only contains all PLL clocks */ @@ -819,8 +819,8 @@ static struct clk_hw *k1_ccu_pll_hws[] = { };static const struct spacemit_ccu_data k1_ccu_pll_data = { - .hws = k1_ccu_pll_hws, - .num =ARRAY_SIZE (k1_ccu_pll_hws), + .clk_hws = k1_ccu_pll_hws, + .clk_num =ARRAY_SIZE (k1_ccu_pll_hws), };static struct clk_hw *k1_ccu_mpmu_hws[] = {@@ -860,8 +860,8 @@ static struct clk_hw *k1_ccu_mpmu_hws[] = { };static const struct spacemit_ccu_data k1_ccu_mpmu_data = { - .hws = k1_ccu_mpmu_hws, - .num =ARRAY_SIZE (k1_ccu_mpmu_hws), + .clk_hws = k1_ccu_mpmu_hws, + .clk_num =ARRAY_SIZE (k1_ccu_mpmu_hws), };static struct clk_hw *k1_ccu_apbc_hws[] = {@@ -968,8 +968,8 @@ static struct clk_hw *k1_ccu_apbc_hws[] = { };static const struct spacemit_ccu_data k1_ccu_apbc_data = { - .hws = k1_ccu_apbc_hws, - .num =ARRAY_SIZE (k1_ccu_apbc_hws), + .clk_hws = k1_ccu_apbc_hws, + .clk_num =ARRAY_SIZE (k1_ccu_apbc_hws), };static struct clk_hw *k1_ccu_apmu_hws[] = {@@ -1038,8 +1038,8 @@ static struct clk_hw *k1_ccu_apmu_hws[] = { };static const struct spacemit_ccu_data k1_ccu_apmu_data = { - .hws = k1_ccu_apmu_hws, - .num =ARRAY_SIZE (k1_ccu_apmu_hws), + .clk_hws = k1_ccu_apmu_hws, + .clk_num =ARRAY_SIZE (k1_ccu_apmu_hws), }; static int spacemit_ccu_register(struct device *dev,@@ -1050,13 +1050,13 @@ static int spacemit_ccu_register(struct device *dev,struct clk_hw_onecell_data *clk_data;int i, ret; - clk_data =devm_kzalloc (dev,struct_size (clk_data, hws, data->num), + clk_data =devm_kzalloc (dev,struct_size (clk_data, hws, data->clk_num),GFP_KERNEL );if (!clk_data)return -ENOMEM ; -for (i =0 ; i < data->num; i++) { -struct clk_hw *hw = data->hws[i]; +for (i =0 ; i < data->clk_num; i++) { +struct clk_hw *hw = data->clk_hws[i];struct ccu_common *common;const char *name;@@ -1081,7 +1081,7 @@ static int spacemit_ccu_register(struct device *dev, clk_data->hws[i] = hw; } - clk_data->num = data->num; + clk_data->num = data->clk_num; ret =devm_of_clk_add_hw_provider (dev, of_clk_hw_onecell_get, clk_data);if (ret)Signature · 1 line
2.45.2
PATCH v4 3/7 clk: spacemit: add reset controller support
In reply to Alex ElderDefine ccu_reset_data as a structure that contains the constant register offset and bitmasks used to assert and deassert a reset control on a SpacemiT K1 CCU. Add a pointer to an array of those structures to the spacemit_ccu_data structure, along with a field indicating how many elements are in that array. Resets will be optional, and if none are defined the reset array pointer will be null.
Define a new ccu_reset_controller structure, which (for a CCU with resets) contains a pointer to the constant reset data, the regmap to be used for the controller, and an embedded a reset controller structure.
Each reset control is asserted or deasserted by updating bits in a register. The bits used are defined by an assert mask and a deassert mask. In some cases, one (non-zero) mask asserts reset and a different (non-zero) mask deasserts it. Otherwise one mask is nonzero, and the other is zero. Either way, the bits in both masks are cleared, then either the assert mask or the deassert mask is set in a register to affect the state of a reset control.
--- drivers/clk/spacemit/ccu-k1.c | 86 +++++++++++++++++++++++++++++++++-- 1 file changed, 83 insertions(+), 3 deletions(-)
drivers/clk/spacemit/ccu-k1.c +83 -3
@@ -11,6 +11,7 @@#include <linux/minmax.h> #include <linux/module.h> #include <linux/platform_device.h> +#include <linux/reset-controller.h> #include "ccu_common.h" #include "ccu_pll.h"
@@ -129,9 +130,23 @@#define APMU_EMAC0_CLK_RES_CTRL 0x3e4#define APMU_EMAC1_CLK_RES_CTRL 0x3ec +struct ccu_reset_data { +u32 offset; +u32 assert_mask; +u32 deassert_mask; +}; +struct spacemit_ccu_data { -struct clk_hw **clk_hws; +struct clk_hw **clk_hws;/* array */ size_t clk_num; +const struct ccu_reset_data *reset_data;/* array */ +size_t reset_num; +}; + +struct ccu_reset_controller { +struct regmap *regmap; +const struct spacemit_ccu_data *data; +struct reset_controller_dev rcdev; };/* APBS clocks start, APBS region contains and only contains all PLL clocks */
@@ -1042,6 +1057,39 @@ static const struct spacemit_ccu_data k1_ccu_apmu_data = { .clk_num = ARRAY_SIZE(k1_ccu_apmu_hws), }; +static int spacemit_reset_update (struct reset_controller_dev *rcdev, +unsigned long id,bool assert) +{ +struct ccu_reset_controller *controller; +const struct ccu_reset_data *data; +u32 mask; +u32 val; + + controller = container_of(rcdev, struct ccu_reset_controller, rcdev); + data = &controller->data->reset_data[id]; + mask = data->assert_mask | data->deassert_mask; + val = assert ? data->assert_mask : data->deassert_mask; + +return regmap_update_bits (controller->regmap, data->offset, mask, val); +} + +static int spacemit_reset_assert (struct reset_controller_dev *rcdev, +unsigned long id) +{ +return spacemit_reset_update (rcdev, id, true); +} + +static int spacemit_reset_deassert (struct reset_controller_dev *rcdev, +unsigned long id) +{ +return spacemit_reset_update (rcdev, id, false); +} + +static const struct reset_control_ops spacemit_reset_control_ops = { + .assert = spacemit_reset_assert, + .deassert = spacemit_reset_deassert, +}; + static int spacemit_ccu_register(struct device *dev, struct regmap *regmap, struct regmap *lock_regmap,
@@ -1090,9 +1138,37 @@ static int spacemit_ccu_register(struct device *dev,return ret; } +static int spacemit_reset_controller_register (struct device *dev, +struct regmap *regmap, +const struct spacemit_ccu_data *data) +{ +struct ccu_reset_controller *controller; +struct reset_controller_dev *rcdev; + +/* Resets are optional */ +if (!data->reset_data) +return 0 ; + + controller =devm_kzalloc (dev,sizeof (*controller),GFP_KERNEL ); +if (!controller) +return -ENOMEM ; + + controller->regmap = regmap; + controller->data = data; + + rcdev = &controller->rcdev; + rcdev->ops = &spacemit_reset_control_ops; + rcdev->owner =THIS_MODULE ; + rcdev->of_node = dev->of_node; + rcdev->nr_resets = data->reset_num; + +return devm_reset_controller_register (dev, rcdev); +} +static int k1_ccu_probe (struct platform_device *pdev) {struct regmap *base_regmap, *lock_regmap =NULL ; +const struct spacemit_ccu_data *data;struct device *dev = &pdev->dev;int ret;
@@ -1121,11 +1197,15 @@ static int k1_ccu_probe(struct platform_device *pdev) "failed to get lock regmap\n"); } - ret =spacemit_ccu_register (dev, base_regmap, lock_regmap, -of_device_get_match_data (dev)); + data =of_device_get_match_data (dev); + ret =spacemit_ccu_register (dev, base_regmap, lock_regmap, data);if (ret)return dev_err_probe (dev, ret,"failed to register clocks\n" ); + ret =spacemit_reset_controller_register (dev, base_regmap, data); +if (ret) +return dev_err_probe (dev, ret,"failed to register reset controller\n" ); +return 0 ; }
Signature · 1 line
2.45.2
Re: [PATCH v4 3/7] clk: spacemit: add reset controller support
Quoted 21 lines · Alex Elder
Define
ccu_reset_dataas a structure that contains the constant register offset and bitmasks used to assert and deassert a reset control on a SpacemiT K1 CCU. Add a pointer to an array of those structures to thespacemit_ccu_datastructure, along with a field indicating how many elements are in that array. Resets will be optional, and if none are defined the reset array pointer will be null.Define a new
ccu_reset_controllerstructure, which (for a CCU with resets) contains a pointer to the constant reset data, the regmap to be used for the controller, and an embedded a reset controller structure.Each reset control is asserted or deasserted by updating bits in a register. The bits used are defined by an assert mask and a deassert mask. In some cases, one (non-zero) mask asserts reset and a different (non-zero) mask deasserts it. Otherwise one mask is nonzero, and the other is zero. Either way, the bits in both masks are cleared, then either the assert mask or the deassert mask is set in a register to affect the state of a reset control.
Quoted 1 line
Signed-off-by Alex Elder <[email protected]>
regards
Philipp
PATCH v4 4/7 clk: spacemit: define existing syscon resets
In reply to Alex ElderDefine reset controls associated with the MPMU, APBC, and APMU SpacemiT K1 CCUs. These already have clocks associated with them.
--- drivers/clk/spacemit/ccu-k1.c | 120 ++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+)
drivers/clk/spacemit/ccu-k1.c +120 -0
@@ -136,6 +136,13 @@ struct ccu_reset_data {u32 deassert_mask; }; +#define RESET_DATA (_offset, _assert_mask, _deassert_mask) \ + { \ + .offset = (_offset), \ + .assert_mask = (_assert_mask), \ + .deassert_mask = (_deassert_mask), \ + } +struct spacemit_ccu_data {struct clk_hw **clk_hws;/* array */ size_t clk_num;
@@ -836,6 +843,7 @@ static struct clk_hw *k1_ccu_pll_hws[] = {static const struct spacemit_ccu_data k1_ccu_pll_data = { .clk_hws = k1_ccu_pll_hws, .clk_num =ARRAY_SIZE (k1_ccu_pll_hws), +/* No resets in the PLL CCU */ };static struct clk_hw *k1_ccu_mpmu_hws[] = {
@@ -874,9 +882,15 @@ static struct clk_hw *k1_ccu_mpmu_hws[] = { [CLK_WDT_BUS] = &wdt_bus_clk.common.hw, }; +static const struct ccu_reset_data mpmu_reset_data[] = { + [RESET_WDT ] =RESET_DATA (MPMU_WDTPCR ,BIT (2 ),0 ), +}; +static const struct spacemit_ccu_data k1_ccu_mpmu_data = { .clk_hws = k1_ccu_mpmu_hws, .clk_num =ARRAY_SIZE (k1_ccu_mpmu_hws), + .reset_data = mpmu_reset_data, + .reset_num =ARRAY_SIZE (mpmu_reset_data), };static struct clk_hw *k1_ccu_apbc_hws[] = {
@@ -982,9 +996,65 @@ static struct clk_hw *k1_ccu_apbc_hws[] = { [CLK_IPC_AP2AUD_BUS] = &ipc_ap2aud_bus_clk.common.hw, }; +static const struct ccu_reset_data apbc_reset_data[] = { + [RESET_UART0 ] =RESET_DATA (APBC_UART1_CLK_RST ,BIT (2 ),0 ), + [RESET_UART2 ] =RESET_DATA (APBC_UART2_CLK_RST ,BIT (2 ),0 ), + [RESET_GPIO ] =RESET_DATA (APBC_GPIO_CLK_RST ,BIT (2 ),0 ), + [RESET_PWM0 ] =RESET_DATA (APBC_PWM0_CLK_RST ,BIT (2 ),BIT (0 )), + [RESET_PWM1 ] =RESET_DATA (APBC_PWM1_CLK_RST ,BIT (2 ),BIT (0 )), + [RESET_PWM2 ] =RESET_DATA (APBC_PWM2_CLK_RST ,BIT (2 ),BIT (0 )), + [RESET_PWM3 ] =RESET_DATA (APBC_PWM3_CLK_RST ,BIT (2 ),BIT (0 )), + [RESET_PWM4 ] =RESET_DATA (APBC_PWM4_CLK_RST ,BIT (2 ),BIT (0 )), + [RESET_PWM5 ] =RESET_DATA (APBC_PWM5_CLK_RST ,BIT (2 ),BIT (0 )), + [RESET_PWM6 ] =RESET_DATA (APBC_PWM6_CLK_RST ,BIT (2 ),BIT (0 )), + [RESET_PWM7 ] =RESET_DATA (APBC_PWM7_CLK_RST ,BIT (2 ),BIT (0 )), + [RESET_PWM8 ] =RESET_DATA (APBC_PWM8_CLK_RST ,BIT (2 ),BIT (0 )), + [RESET_PWM9 ] =RESET_DATA (APBC_PWM9_CLK_RST ,BIT (2 ),BIT (0 )), + [RESET_PWM10 ] =RESET_DATA (APBC_PWM10_CLK_RST ,BIT (2 ),BIT (0 )), + [RESET_PWM11 ] =RESET_DATA (APBC_PWM11_CLK_RST ,BIT (2 ),BIT (0 )), + [RESET_PWM12 ] =RESET_DATA (APBC_PWM12_CLK_RST ,BIT (2 ),BIT (0 )), + [RESET_PWM13 ] =RESET_DATA (APBC_PWM13_CLK_RST ,BIT (2 ),BIT (0 )), + [RESET_PWM14 ] =RESET_DATA (APBC_PWM14_CLK_RST ,BIT (2 ),BIT (0 )), + [RESET_PWM15 ] =RESET_DATA (APBC_PWM15_CLK_RST ,BIT (2 ),BIT (0 )), + [RESET_PWM16 ] =RESET_DATA (APBC_PWM16_CLK_RST ,BIT (2 ),BIT (0 )), + [RESET_PWM17 ] =RESET_DATA (APBC_PWM17_CLK_RST ,BIT (2 ),BIT (0 )), + [RESET_PWM18 ] =RESET_DATA (APBC_PWM18_CLK_RST ,BIT (2 ),BIT (0 )), + [RESET_PWM19 ] =RESET_DATA (APBC_PWM19_CLK_RST ,BIT (2 ),BIT (0 )), + [RESET_SSP3 ] =RESET_DATA (APBC_SSP3_CLK_RST ,BIT (2 ),0 ), + [RESET_UART3 ] =RESET_DATA (APBC_UART3_CLK_RST ,BIT (2 ),0 ), + [RESET_RTC ] =RESET_DATA (APBC_RTC_CLK_RST ,BIT (2 ),0 ), + [RESET_TWSI0 ] =RESET_DATA (APBC_TWSI0_CLK_RST ,BIT (2 ),0 ), + [RESET_TIMERS1 ] =RESET_DATA (APBC_TIMERS1_CLK_RST ,BIT (2 ),0 ), + [RESET_AIB ] =RESET_DATA (APBC_AIB_CLK_RST ,BIT (2 ),0 ), + [RESET_TIMERS2 ] =RESET_DATA (APBC_TIMERS2_CLK_RST ,BIT (2 ),0 ), + [RESET_ONEWIRE ] =RESET_DATA (APBC_ONEWIRE_CLK_RST ,BIT (2 ),0 ), + [RESET_SSPA0 ] =RESET_DATA (APBC_SSPA0_CLK_RST ,BIT (2 ),0 ), + [RESET_SSPA1 ] =RESET_DATA (APBC_SSPA1_CLK_RST ,BIT (2 ),0 ), + [RESET_DRO ] =RESET_DATA (APBC_DRO_CLK_RST ,BIT (2 ),0 ), + [RESET_IR ] =RESET_DATA (APBC_IR_CLK_RST ,BIT (2 ),0 ), + [RESET_TWSI1 ] =RESET_DATA (APBC_TWSI1_CLK_RST ,BIT (2 ),0 ), + [RESET_TSEN ] =RESET_DATA (APBC_TSEN_CLK_RST ,BIT (2 ),0 ), + [RESET_TWSI2 ] =RESET_DATA (APBC_TWSI2_CLK_RST ,BIT (2 ),0 ), + [RESET_TWSI4 ] =RESET_DATA (APBC_TWSI4_CLK_RST ,BIT (2 ),0 ), + [RESET_TWSI5 ] =RESET_DATA (APBC_TWSI5_CLK_RST ,BIT (2 ),0 ), + [RESET_TWSI6 ] =RESET_DATA (APBC_TWSI6_CLK_RST ,BIT (2 ),0 ), + [RESET_TWSI7 ] =RESET_DATA (APBC_TWSI7_CLK_RST ,BIT (2 ),0 ), + [RESET_TWSI8 ] =RESET_DATA (APBC_TWSI8_CLK_RST ,BIT (2 ),0 ), + [RESET_IPC_AP2AUD ] =RESET_DATA (APBC_IPC_AP2AUD_CLK_RST ,BIT (2 ),0 ), + [RESET_UART4 ] =RESET_DATA (APBC_UART4_CLK_RST ,BIT (2 ),0 ), + [RESET_UART5 ] =RESET_DATA (APBC_UART5_CLK_RST ,BIT (2 ),0 ), + [RESET_UART6 ] =RESET_DATA (APBC_UART6_CLK_RST ,BIT (2 ),0 ), + [RESET_UART7 ] =RESET_DATA (APBC_UART7_CLK_RST ,BIT (2 ),0 ), + [RESET_UART8 ] =RESET_DATA (APBC_UART8_CLK_RST ,BIT (2 ),0 ), + [RESET_UART9 ] =RESET_DATA (APBC_UART9_CLK_RST ,BIT (2 ),0 ), + [RESET_CAN0 ] =RESET_DATA (APBC_CAN0_CLK_RST ,BIT (2 ),0 ), +}; +static const struct spacemit_ccu_data k1_ccu_apbc_data = { .clk_hws = k1_ccu_apbc_hws, .clk_num =ARRAY_SIZE (k1_ccu_apbc_hws), + .reset_data = apbc_reset_data, + .reset_num =ARRAY_SIZE (apbc_reset_data), };static struct clk_hw *k1_ccu_apmu_hws[] = {
@@ -1052,9 +1122,59 @@ static struct clk_hw *k1_ccu_apmu_hws[] = { [CLK_EMMC_BUS] = &emmc_bus_clk.common.hw, }; +static const struct ccu_reset_data apmu_reset_data[] = { + [RESET_CCIC_4X ] =RESET_DATA (APMU_CCIC_CLK_RES_CTRL ,0 ,BIT (1 )), + [RESET_CCIC1_PHY ] =RESET_DATA (APMU_CCIC_CLK_RES_CTRL ,0 ,BIT (2 )), + [RESET_SDH_AXI ] =RESET_DATA (APMU_SDH0_CLK_RES_CTRL ,0 ,BIT (0 )), + [RESET_SDH0 ] =RESET_DATA (APMU_SDH0_CLK_RES_CTRL ,0 ,BIT (1 )), + [RESET_SDH1 ] =RESET_DATA (APMU_SDH1_CLK_RES_CTRL ,0 ,BIT (1 )), + [RESET_SDH2 ] =RESET_DATA (APMU_SDH2_CLK_RES_CTRL ,0 ,BIT (1 )), + [RESET_USBP1_AXI ] =RESET_DATA (APMU_USB_CLK_RES_CTRL ,0 ,BIT (4 )), + [RESET_USB_AXI ] =RESET_DATA (APMU_USB_CLK_RES_CTRL ,0 ,BIT (0 )), + [RESET_USB3_0 ] =RESET_DATA (APMU_USB_CLK_RES_CTRL ,0 , +BIT (11 ) |BIT (10 ) |BIT (9 )), + [RESET_QSPI ] =RESET_DATA (APMU_QSPI_CLK_RES_CTRL ,0 ,BIT (1 )), + [RESET_QSPI_BUS ] =RESET_DATA (APMU_QSPI_CLK_RES_CTRL ,0 ,BIT (0 )), + [RESET_DMA ] =RESET_DATA (APMU_DMA_CLK_RES_CTRL ,0 ,BIT (0 )), + [RESET_AES ] =RESET_DATA (APMU_AES_CLK_RES_CTRL ,0 ,BIT (4 )), + [RESET_VPU ] =RESET_DATA (APMU_VPU_CLK_RES_CTRL ,0 ,BIT (0 )), + [RESET_GPU ] =RESET_DATA (APMU_GPU_CLK_RES_CTRL ,0 ,BIT (1 )), + [RESET_EMMC ] =RESET_DATA (APMU_PMUA_EM_CLK_RES_CTRL ,0 ,BIT (1 )), + [RESET_EMMC_X ] =RESET_DATA (APMU_PMUA_EM_CLK_RES_CTRL ,0 ,BIT (0 )), + [RESET_AUDIO ] =RESET_DATA (APMU_AUDIO_CLK_RES_CTRL ,0 , +BIT (3 ) |BIT (2 ) |BIT (0 )), + [RESET_HDMI ] =RESET_DATA (APMU_HDMI_CLK_RES_CTRL ,0 ,BIT (9 )), + [RESET_PCIE0 ] =RESET_DATA (APMU_PCIE_CLK_RES_CTRL_0 ,BIT (8 ), +BIT (5 ) |BIT (4 ) |BIT (3 )), + [RESET_PCIE1 ] =RESET_DATA (APMU_PCIE_CLK_RES_CTRL_1 ,BIT (8 ), +BIT (5 ) |BIT (4 ) |BIT (3 )), + [RESET_PCIE2 ] =RESET_DATA (APMU_PCIE_CLK_RES_CTRL_2 ,BIT (8 ), +BIT (5 ) |BIT (4 ) |BIT (3 )), + [RESET_EMAC0 ] =RESET_DATA (APMU_EMAC0_CLK_RES_CTRL ,0 ,BIT (1 )), + [RESET_EMAC1 ] =RESET_DATA (APMU_EMAC1_CLK_RES_CTRL ,0 ,BIT (1 )), + [RESET_JPG ] =RESET_DATA (APMU_JPG_CLK_RES_CTRL ,0 ,BIT (0 )), + [RESET_CCIC2PHY ] =RESET_DATA (APMU_CSI_CCIC2_CLK_RES_CTRL ,0 ,BIT (2 )), + [RESET_CCIC3PHY ] =RESET_DATA (APMU_CSI_CCIC2_CLK_RES_CTRL ,0 ,BIT (29 )), + [RESET_CSI ] =RESET_DATA (APMU_CSI_CCIC2_CLK_RES_CTRL ,0 ,BIT (1 )), + [RESET_ISP ] =RESET_DATA (APMU_ISP_CLK_RES_CTRL ,0 ,BIT (0 )), + [RESET_ISP_CPP ] =RESET_DATA (APMU_ISP_CLK_RES_CTRL ,0 ,BIT (27 )), + [RESET_ISP_BUS ] =RESET_DATA (APMU_ISP_CLK_RES_CTRL ,0 ,BIT (3 )), + [RESET_ISP_CI ] =RESET_DATA (APMU_ISP_CLK_RES_CTRL ,0 ,BIT (16 )), + [RESET_DPU_MCLK ] =RESET_DATA (APMU_LCD_CLK_RES_CTRL2 ,0 ,BIT (9 )), + [RESET_DPU_ESC ] =RESET_DATA (APMU_LCD_CLK_RES_CTRL1 ,0 ,BIT (3 )), + [RESET_DPU_HCLK ] =RESET_DATA (APMU_LCD_CLK_RES_CTRL1 ,0 ,BIT (4 )), + [RESET_DPU_SPIBUS ] =RESET_DATA (APMU_LCD_SPI_CLK_RES_CTRL ,0 ,BIT (4 )), + [RESET_DPU_SPI_HBUS ] =RESET_DATA (APMU_LCD_SPI_CLK_RES_CTRL ,0 ,BIT (2 )), + [RESET_V2D ] =RESET_DATA (APMU_LCD_CLK_RES_CTRL1 ,0 ,BIT (27 )), + [RESET_MIPI ] =RESET_DATA (APMU_LCD_CLK_RES_CTRL1 ,0 ,BIT (15 )), + [RESET_MC ] =RESET_DATA (APMU_PMUA_MC_CTRL ,0 ,BIT (0 )), +}; +static const struct spacemit_ccu_data k1_ccu_apmu_data = { .clk_hws = k1_ccu_apmu_hws, .clk_num =ARRAY_SIZE (k1_ccu_apmu_hws), + .reset_data = apmu_reset_data, + .reset_num =ARRAY_SIZE (apmu_reset_data), }; static int spacemit_reset_update(struct reset_controller_dev *rcdev,
Signature · 1 line
2.45.2
PATCH v4 5/7 clk: spacemit: make clocks optional
In reply to Alex ElderThere are some syscon devices that support both clocks and resets, but for now only their reset functionality is required. Make defining clocks optional for a SpacemiT CCU, though at least one clock or at least one reset controller must be defined.
--- drivers/clk/spacemit/ccu-k1.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/clk/spacemit/ccu-k1.c +5 -0
@@ -1218,6 +1218,10 @@ static int spacemit_ccu_register(struct device *dev,struct clk_hw_onecell_data *clk_data;int i, ret; +/* Clocks are optional */ +if (!data->clk_hws) +return 0 ; + clk_data =devm_kzalloc (dev,struct_size (clk_data, hws, data->clk_num),GFP_KERNEL );if (!clk_data)
@@ -1329,6 +1333,7 @@ static int k1_ccu_probe(struct platform_device *pdev)return 0 ; } +/* Match data is required; its clk_hws or reset_data field must be non-null */ static const struct of_device_id of_k1_ccu_match[] = { { .compatible ="spacemit,k1-pll" ,
Signature · 1 line
2.45.2
PATCH v4 6/7 clk: spacemit: define new syscons with only resets
In reply to Alex ElderEnable support for three additional syscon CCUs which support reset controls but no clocks: ARCPU, RCPU2, and APBC2.
--- drivers/clk/spacemit/ccu-k1.c | 93 +++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+)
drivers/clk/spacemit/ccu-k1.c +93 -0
@@ -130,6 +130,36 @@#define APMU_EMAC0_CLK_RES_CTRL 0x3e4#define APMU_EMAC1_CLK_RES_CTRL 0x3ec +/* RCPU register offsets */ +#define RCPU_SSP0_CLK_RST 0x0028 +#define RCPU_I2C0_CLK_RST 0x0030 +#define RCPU_UART1_CLK_RST 0x003c +#define RCPU_CAN_CLK_RST 0x0048 +#define RCPU_IR_CLK_RST 0x004c +#define RCPU_UART0_CLK_RST 0x00d8 +#define AUDIO_HDMI_CLK_CTRL 0x2044 + +/* RCPU2 register offsets */ +#define RCPU2_PWM0_CLK_RST 0x0000 +#define RCPU2_PWM1_CLK_RST 0x0004 +#define RCPU2_PWM2_CLK_RST 0x0008 +#define RCPU2_PWM3_CLK_RST 0x000c +#define RCPU2_PWM4_CLK_RST 0x0010 +#define RCPU2_PWM5_CLK_RST 0x0014 +#define RCPU2_PWM6_CLK_RST 0x0018 +#define RCPU2_PWM7_CLK_RST 0x001c +#define RCPU2_PWM8_CLK_RST 0x0020 +#define RCPU2_PWM9_CLK_RST 0x0024 + +/* APBC2 register offsets */ +#define APBC2_UART1_CLK_RST 0x0000 +#define APBC2_SSP2_CLK_RST 0x0004 +#define APBC2_TWSI3_CLK_RST 0x0008 +#define APBC2_RTC_CLK_RST 0x000c +#define APBC2_TIMERS0_CLK_RST 0x0010 +#define APBC2_KPC_CLK_RST 0x0014 +#define APBC2_GPIO_CLK_RST 0x001c +struct ccu_reset_data {u32 offset;u32 assert_mask;
@@ -1177,6 +1207,57 @@ static const struct spacemit_ccu_data k1_ccu_apmu_data = { .reset_num = ARRAY_SIZE(apmu_reset_data), }; +static const struct ccu_reset_data rcpu_reset_data[] = { + [RESET_RCPU_SSP0 ] =RESET_DATA (RCPU_SSP0_CLK_RST ,0 ,BIT (0 )), + [RESET_RCPU_I2C0 ] =RESET_DATA (RCPU_I2C0_CLK_RST ,0 ,BIT (0 )), + [RESET_RCPU_UART1 ] =RESET_DATA (RCPU_UART1_CLK_RST ,0 ,BIT (0 )), + [RESET_RCPU_IR ] =RESET_DATA (RCPU_CAN_CLK_RST ,0 ,BIT (0 )), + [RESET_RCPU_CAN ] =RESET_DATA (RCPU_IR_CLK_RST ,0 ,BIT (0 )), + [RESET_RCPU_UART0 ] =RESET_DATA (RCPU_UART0_CLK_RST ,0 ,BIT (0 )), + [RESET_RCPU_HDMI_AUDIO ] =RESET_DATA (AUDIO_HDMI_CLK_CTRL ,0 ,BIT (0 )), +}; + +static struct spacemit_ccu_data k1_ccu_rcpu_data = { +/* No clocks in the RCPU CCU */ + .reset_data = rcpu_reset_data, + .reset_num =ARRAY_SIZE (rcpu_reset_data), +}; + +static const struct ccu_reset_data rcpu2_reset_data[] = { + [RESET_RCPU2_PWM0 ] =RESET_DATA (RCPU2_PWM9_CLK_RST ,BIT (2 ),BIT (0 )), + [RESET_RCPU2_PWM1 ] =RESET_DATA (RCPU2_PWM9_CLK_RST ,BIT (2 ),BIT (0 )), + [RESET_RCPU2_PWM2 ] =RESET_DATA (RCPU2_PWM9_CLK_RST ,BIT (2 ),BIT (0 )), + [RESET_RCPU2_PWM3 ] =RESET_DATA (RCPU2_PWM9_CLK_RST ,BIT (2 ),BIT (0 )), + [RESET_RCPU2_PWM4 ] =RESET_DATA (RCPU2_PWM9_CLK_RST ,BIT (2 ),BIT (0 )), + [RESET_RCPU2_PWM5 ] =RESET_DATA (RCPU2_PWM9_CLK_RST ,BIT (2 ),BIT (0 )), + [RESET_RCPU2_PWM6 ] =RESET_DATA (RCPU2_PWM9_CLK_RST ,BIT (2 ),BIT (0 )), + [RESET_RCPU2_PWM7 ] =RESET_DATA (RCPU2_PWM9_CLK_RST ,BIT (2 ),BIT (0 )), + [RESET_RCPU2_PWM8 ] =RESET_DATA (RCPU2_PWM9_CLK_RST ,BIT (2 ),BIT (0 )), + [RESET_RCPU2_PWM9 ] =RESET_DATA (RCPU2_PWM9_CLK_RST ,BIT (2 ),BIT (0 )), +}; + +static struct spacemit_ccu_data k1_ccu_rcpu2_data = { +/* No clocks in the RCPU2 CCU */ + .reset_data = rcpu2_reset_data, + .reset_num =ARRAY_SIZE (rcpu2_reset_data), +}; + +static const struct ccu_reset_data apbc2_reset_data[] = { + [RESET_APBC2_UART1 ] =RESET_DATA (APBC2_UART1_CLK_RST ,BIT (2 ), (0 )), + [RESET_APBC2_SSP2 ] =RESET_DATA (APBC2_SSP2_CLK_RST ,BIT (2 ), (0 )), + [RESET_APBC2_TWSI3 ] =RESET_DATA (APBC2_TWSI3_CLK_RST ,BIT (2 ), (0 )), + [RESET_APBC2_RTC ] =RESET_DATA (APBC2_RTC_CLK_RST ,BIT (2 ), (0 )), + [RESET_APBC2_TIMERS0 ] =RESET_DATA (APBC2_TIMERS0_CLK_RST ,BIT (2 ), (0 )), + [RESET_APBC2_KPC ] =RESET_DATA (APBC2_KPC_CLK_RST ,BIT (2 ), (0 )), + [RESET_APBC2_GPIO ] =RESET_DATA (APBC2_GPIO_CLK_RST ,BIT (2 ), (0 )), +}; + +static struct spacemit_ccu_data k1_ccu_apbc2_data = { +/* No clocks in the APBC2 CCU */ + .reset_data = apbc2_reset_data, + .reset_num =ARRAY_SIZE (apbc2_reset_data), +}; +static int spacemit_reset_update (struct reset_controller_dev *rcdev,unsigned long id,bool assert) {
@@ -1351,6 +1432,18 @@ static const struct of_device_id of_k1_ccu_match[] = { .compatible = "spacemit,k1-syscon-apmu", .data = &k1_ccu_apmu_data, }, + { + .compatible = "spacemit,k1-syscon-rcpu", + .data = &k1_ccu_rcpu_data, + }, + { + .compatible = "spacemit,k1-syscon-rcpu2", + .data = &k1_ccu_rcpu2_data, + }, + { + .compatible = "spacemit,k1-syscon-apbc2", + .data = &k1_ccu_apbc2_data, + }, { } }; MODULE_DEVICE_TABLE(of, of_k1_ccu_match);
Signature · 1 line
2.45.2
Re: [PATCH v4 6/7] clk: spacemit: define new syscons with only resets
Quoted 54 lines · Alex Elder
Enable support for three additional syscon CCUs which support reset controls but no clocks: ARCPU, RCPU2, and APBC2.
Signed-off-by Alex Elder <[email protected]>--- drivers/clk/spacemit/ccu-k1.c | 93 +++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+)drivers/clk/spacemit/ccu-k1.c +31
-0@@ -130,6 +130,36 @@#define APMU_EMAC0_CLK_RES_CTRL 0x3e4#define APMU_EMAC1_CLK_RES_CTRL 0x3ec +/* RCPU register offsets */ +#define RCPU_SSP0_CLK_RST 0x0028 +#define RCPU_I2C0_CLK_RST 0x0030 +#define RCPU_UART1_CLK_RST 0x003c +#define RCPU_CAN_CLK_RST 0x0048 +#define RCPU_IR_CLK_RST 0x004c +#define RCPU_UART0_CLK_RST 0x00d8 +#define AUDIO_HDMI_CLK_CTRL 0x2044 + +/* RCPU2 register offsets */ +#define RCPU2_PWM0_CLK_RST 0x0000 +#define RCPU2_PWM1_CLK_RST 0x0004 +#define RCPU2_PWM2_CLK_RST 0x0008 +#define RCPU2_PWM3_CLK_RST 0x000c +#define RCPU2_PWM4_CLK_RST 0x0010 +#define RCPU2_PWM5_CLK_RST 0x0014 +#define RCPU2_PWM6_CLK_RST 0x0018 +#define RCPU2_PWM7_CLK_RST 0x001c +#define RCPU2_PWM8_CLK_RST 0x0020 +#define RCPU2_PWM9_CLK_RST 0x0024 + +/* APBC2 register offsets */ +#define APBC2_UART1_CLK_RST 0x0000 +#define APBC2_SSP2_CLK_RST 0x0004 +#define APBC2_TWSI3_CLK_RST 0x0008 +#define APBC2_RTC_CLK_RST 0x000c +#define APBC2_TIMERS0_CLK_RST 0x0010 +#define APBC2_KPC_CLK_RST 0x0014 +#define APBC2_GPIO_CLK_RST 0x001c +struct ccu_reset_data {u32 offset;u32 assert_mask;@@ -1177,6 +1207,57 @@ static const struct spacemit_ccu_data k1_ccu_apmu_data = { .reset_num = ARRAY_SIZE(apmu_reset_data), }; +static const struct ccu_reset_data rcpu_reset_data[] = {
drivers/clk/spacemit/ccu-k1.c static const struct spacemit_ccu_data k1_ccu_apmu_data = { · line 1220
Quoted 10 lines
drivers/clk/spacemit/ccu-k1.c +10
-0+ [RESET_RCPU_SSP0] = RESET_DATA(RCPU_SSP0_CLK_RST, 0, BIT(0)), + [RESET_RCPU_I2C0] = RESET_DATA(RCPU_I2C0_CLK_RST, 0, BIT(0)), + [RESET_RCPU_UART1] = RESET_DATA(RCPU_UART1_CLK_RST, 0, BIT(0)), + [RESET_RCPU_IR] = RESET_DATA(RCPU_CAN_CLK_RST, 0, BIT(0)), + [RESET_RCPU_CAN] = RESET_DATA(RCPU_IR_CLK_RST, 0, BIT(0)), + [RESET_RCPU_UART0] = RESET_DATA(RCPU_UART0_CLK_RST, 0, BIT(0)), + [RESET_RCPU_HDMI_AUDIO] = RESET_DATA(AUDIO_HDMI_CLK_CTRL, 0, BIT(0)), +}; + +static struct spacemit_ccu_data k1_ccu_rcpu_data = {
Could be const.
Quoted 9 lines
drivers/clk/spacemit/ccu-k1.c +9
-0+/* No clocks in the RCPU CCU */ + .reset_data = rcpu_reset_data, + .reset_num = ARRAY_SIZE(rcpu_reset_data), +}; + +static const struct ccu_reset_data rcpu2_reset_data[] = { + [RESET_RCPU2_PWM0 ] =RESET_DATA (RCPU2_PWM9_CLK_RST ,BIT (2 ),BIT (0 )), + [RESET_RCPU2_PWM1 ] =RESET_DATA (RCPU2_PWM9_CLK_RST ,BIT (2 ),BIT (0 )), + [RESET_RCPU2_PWM2 ] =RESET_DATA (RCPU2_PWM9_CLK_RST ,BIT (2 ),BIT (0 )),
drivers/clk/spacemit/ccu-k1.c static const struct spacemit_ccu_data k1_ccu_apmu_data = { · line 1239
Quoted 10 lines
drivers/clk/spacemit/ccu-k1.c +10
-0+ [RESET_RCPU2_PWM3] = RESET_DATA(RCPU2_PWM9_CLK_RST, BIT(2), BIT(0)), + [RESET_RCPU2_PWM4] = RESET_DATA(RCPU2_PWM9_CLK_RST, BIT(2), BIT(0)), + [RESET_RCPU2_PWM5] = RESET_DATA(RCPU2_PWM9_CLK_RST, BIT(2), BIT(0)), + [RESET_RCPU2_PWM6] = RESET_DATA(RCPU2_PWM9_CLK_RST, BIT(2), BIT(0)), + [RESET_RCPU2_PWM7] = RESET_DATA(RCPU2_PWM9_CLK_RST, BIT(2), BIT(0)), + [RESET_RCPU2_PWM8] = RESET_DATA(RCPU2_PWM9_CLK_RST, BIT(2), BIT(0)), + [RESET_RCPU2_PWM9] = RESET_DATA(RCPU2_PWM9_CLK_RST, BIT(2), BIT(0)), +}; + +static struct spacemit_ccu_data k1_ccu_rcpu2_data = {
const
drivers/clk/spacemit/ccu-k1.c static const struct spacemit_ccu_data k1_ccu_apmu_data = { · line 1252
Quoted 13 lines
drivers/clk/spacemit/ccu-k1.c +13
-0+/* No clocks in the RCPU2 CCU */ + .reset_data = rcpu2_reset_data, + .reset_num = ARRAY_SIZE(rcpu2_reset_data), +}; + +static const struct ccu_reset_data apbc2_reset_data[] = { + [RESET_APBC2_UART1 ] =RESET_DATA (APBC2_UART1_CLK_RST ,BIT (2 ), (0 )), + [RESET_APBC2_SSP2 ] =RESET_DATA (APBC2_SSP2_CLK_RST ,BIT (2 ), (0 )), + [RESET_APBC2_TWSI3 ] =RESET_DATA (APBC2_TWSI3_CLK_RST ,BIT (2 ), (0 )), + [RESET_APBC2_RTC ] =RESET_DATA (APBC2_RTC_CLK_RST ,BIT (2 ), (0 )), + [RESET_APBC2_TIMERS0 ] =RESET_DATA (APBC2_TIMERS0_CLK_RST ,BIT (2 ), (0 )), + [RESET_APBC2_KPC ] =RESET_DATA (APBC2_KPC_CLK_RST ,BIT (2 ), (0 )), + [RESET_APBC2_GPIO ] =RESET_DATA (APBC2_GPIO_CLK_RST ,BIT (2 ), (0 )),
Superfluous parentheses.
drivers/clk/spacemit/ccu-k1.c static const struct spacemit_ccu_data k1_ccu_apmu_data = { · line 1255
Quoted 3 lines
drivers/clk/spacemit/ccu-k1.c +3
-0+}; + +static struct spacemit_ccu_data k1_ccu_apbc2_data = {
const
Quoted 17 lines
drivers/clk/spacemit/ccu-k1.c +10
-0+/* No clocks in the APBC2 CCU */ + .reset_data = apbc2_reset_data, + .reset_num = ARRAY_SIZE(apbc2_reset_data), +}; +static int spacemit_reset_update (struct reset_controller_dev *rcdev,unsigned long id,bool assert) {@@ -1351,6 +1432,18 @@ static const struct of_device_id of_k1_ccu_match[] = { .compatible = "spacemit,k1-syscon-apmu", .data = &k1_ccu_apmu_data, }, + { + .compatible = "spacemit,k1-syscon-rcpu", + .data = &k1_ccu_rcpu_data, + }, + {
drivers/clk/spacemit/ccu-k1.c static const struct of_device_id of_k1_ccu_match[] = { · line 1449
Quoted 10 lines
drivers/clk/spacemit/ccu-k1.c +7
-0+ .compatible = "spacemit,k1-syscon-rcpu2", + .data = &k1_ccu_rcpu2_data, + }, + { + .compatible = "spacemit,k1-syscon-apbc2", + .data = &k1_ccu_apbc2_data, + }, { } };MODULE_DEVICE_TABLE (of, of_k1_ccu_match);
regards
Philipp
Re: [PATCH v4 6/7] clk: spacemit: define new syscons with only resets
Quoted 5 lines · Philipp Zabel
Quoted 4 lines · Alex Elder
Enable support for three additional syscon CCUs which support reset controls but no clocks: ARCPU, RCPU2, and APBC2.
Signed-off-by Alex Elder <[email protected]>
You are correct that those reset-only CCUs could have their spacemit_ccu_data be const.
I'm going to give this series a little more time for review but I'll gladly submit v5 with the added const qualifier in those places.
Thanks.
-Alex
Quoted 137 lines
Quoted 50 lines
--- drivers/clk/spacemit/ccu-k1.c | 93 +++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+)drivers/clk/spacemit/ccu-k1.c +31
-0@@ -130,6 +130,36 @@#define APMU_EMAC0_CLK_RES_CTRL 0x3e4#define APMU_EMAC1_CLK_RES_CTRL 0x3ec +/* RCPU register offsets */ +#define RCPU_SSP0_CLK_RST 0x0028 +#define RCPU_I2C0_CLK_RST 0x0030 +#define RCPU_UART1_CLK_RST 0x003c +#define RCPU_CAN_CLK_RST 0x0048 +#define RCPU_IR_CLK_RST 0x004c +#define RCPU_UART0_CLK_RST 0x00d8 +#define AUDIO_HDMI_CLK_CTRL 0x2044 + +/* RCPU2 register offsets */ +#define RCPU2_PWM0_CLK_RST 0x0000 +#define RCPU2_PWM1_CLK_RST 0x0004 +#define RCPU2_PWM2_CLK_RST 0x0008 +#define RCPU2_PWM3_CLK_RST 0x000c +#define RCPU2_PWM4_CLK_RST 0x0010 +#define RCPU2_PWM5_CLK_RST 0x0014 +#define RCPU2_PWM6_CLK_RST 0x0018 +#define RCPU2_PWM7_CLK_RST 0x001c +#define RCPU2_PWM8_CLK_RST 0x0020 +#define RCPU2_PWM9_CLK_RST 0x0024 + +/* APBC2 register offsets */ +#define APBC2_UART1_CLK_RST 0x0000 +#define APBC2_SSP2_CLK_RST 0x0004 +#define APBC2_TWSI3_CLK_RST 0x0008 +#define APBC2_RTC_CLK_RST 0x000c +#define APBC2_TIMERS0_CLK_RST 0x0010 +#define APBC2_KPC_CLK_RST 0x0014 +#define APBC2_GPIO_CLK_RST 0x001c +struct ccu_reset_data {u32 offset;u32 assert_mask;@@ -1177,6 +1207,57 @@ static const struct spacemit_ccu_data k1_ccu_apmu_data = { .reset_num = ARRAY_SIZE(apmu_reset_data), }; +static const struct ccu_reset_data rcpu_reset_data[] = {drivers/clk/spacemit/ccu-k1.c static const struct spacemit_ccu_data k1_ccu_apmu_data = { · line 1220
Quoted 10 lines
drivers/clk/spacemit/ccu-k1.c +10
-0+ [RESET_RCPU_SSP0] = RESET_DATA(RCPU_SSP0_CLK_RST, 0, BIT(0)), + [RESET_RCPU_I2C0] = RESET_DATA(RCPU_I2C0_CLK_RST, 0, BIT(0)), + [RESET_RCPU_UART1] = RESET_DATA(RCPU_UART1_CLK_RST, 0, BIT(0)), + [RESET_RCPU_IR] = RESET_DATA(RCPU_CAN_CLK_RST, 0, BIT(0)), + [RESET_RCPU_CAN] = RESET_DATA(RCPU_IR_CLK_RST, 0, BIT(0)), + [RESET_RCPU_UART0] = RESET_DATA(RCPU_UART0_CLK_RST, 0, BIT(0)), + [RESET_RCPU_HDMI_AUDIO] = RESET_DATA(AUDIO_HDMI_CLK_CTRL, 0, BIT(0)), +}; + +static struct spacemit_ccu_data k1_ccu_rcpu_data = {Could be const.
Quoted 9 lines
drivers/clk/spacemit/ccu-k1.c +9
-0+/* No clocks in the RCPU CCU */ + .reset_data = rcpu_reset_data, + .reset_num = ARRAY_SIZE(rcpu_reset_data), +}; + +static const struct ccu_reset_data rcpu2_reset_data[] = { + [RESET_RCPU2_PWM0 ] =RESET_DATA (RCPU2_PWM9_CLK_RST ,BIT (2 ),BIT (0 )), + [RESET_RCPU2_PWM1 ] =RESET_DATA (RCPU2_PWM9_CLK_RST ,BIT (2 ),BIT (0 )), + [RESET_RCPU2_PWM2 ] =RESET_DATA (RCPU2_PWM9_CLK_RST ,BIT (2 ),BIT (0 )),drivers/clk/spacemit/ccu-k1.c static const struct spacemit_ccu_data k1_ccu_apmu_data = { · line 1239
Quoted 10 lines
drivers/clk/spacemit/ccu-k1.c +10
-0+ [RESET_RCPU2_PWM3] = RESET_DATA(RCPU2_PWM9_CLK_RST, BIT(2), BIT(0)), + [RESET_RCPU2_PWM4] = RESET_DATA(RCPU2_PWM9_CLK_RST, BIT(2), BIT(0)), + [RESET_RCPU2_PWM5] = RESET_DATA(RCPU2_PWM9_CLK_RST, BIT(2), BIT(0)), + [RESET_RCPU2_PWM6] = RESET_DATA(RCPU2_PWM9_CLK_RST, BIT(2), BIT(0)), + [RESET_RCPU2_PWM7] = RESET_DATA(RCPU2_PWM9_CLK_RST, BIT(2), BIT(0)), + [RESET_RCPU2_PWM8] = RESET_DATA(RCPU2_PWM9_CLK_RST, BIT(2), BIT(0)), + [RESET_RCPU2_PWM9] = RESET_DATA(RCPU2_PWM9_CLK_RST, BIT(2), BIT(0)), +}; + +static struct spacemit_ccu_data k1_ccu_rcpu2_data = {const
drivers/clk/spacemit/ccu-k1.c static const struct spacemit_ccu_data k1_ccu_apmu_data = { · line 1252
Quoted 13 lines
drivers/clk/spacemit/ccu-k1.c +13
-0+/* No clocks in the RCPU2 CCU */ + .reset_data = rcpu2_reset_data, + .reset_num = ARRAY_SIZE(rcpu2_reset_data), +}; + +static const struct ccu_reset_data apbc2_reset_data[] = { + [RESET_APBC2_UART1 ] =RESET_DATA (APBC2_UART1_CLK_RST ,BIT (2 ), (0 )), + [RESET_APBC2_SSP2 ] =RESET_DATA (APBC2_SSP2_CLK_RST ,BIT (2 ), (0 )), + [RESET_APBC2_TWSI3 ] =RESET_DATA (APBC2_TWSI3_CLK_RST ,BIT (2 ), (0 )), + [RESET_APBC2_RTC ] =RESET_DATA (APBC2_RTC_CLK_RST ,BIT (2 ), (0 )), + [RESET_APBC2_TIMERS0 ] =RESET_DATA (APBC2_TIMERS0_CLK_RST ,BIT (2 ), (0 )), + [RESET_APBC2_KPC ] =RESET_DATA (APBC2_KPC_CLK_RST ,BIT (2 ), (0 )), + [RESET_APBC2_GPIO ] =RESET_DATA (APBC2_GPIO_CLK_RST ,BIT (2 ), (0 )),Superfluous parentheses.
drivers/clk/spacemit/ccu-k1.c static const struct spacemit_ccu_data k1_ccu_apmu_data = { · line 1255
Quoted 3 lines
drivers/clk/spacemit/ccu-k1.c +3
-0+}; + +static struct spacemit_ccu_data k1_ccu_apbc2_data = {const
Quoted 17 lines
drivers/clk/spacemit/ccu-k1.c +10
-0+/* No clocks in the APBC2 CCU */ + .reset_data = apbc2_reset_data, + .reset_num = ARRAY_SIZE(apbc2_reset_data), +}; +static int spacemit_reset_update (struct reset_controller_dev *rcdev,unsigned long id,bool assert) {@@ -1351,6 +1432,18 @@ static const struct of_device_id of_k1_ccu_match[] = { .compatible = "spacemit,k1-syscon-apmu", .data = &k1_ccu_apmu_data, }, + { + .compatible = "spacemit,k1-syscon-rcpu", + .data = &k1_ccu_rcpu_data, + }, + {drivers/clk/spacemit/ccu-k1.c static const struct of_device_id of_k1_ccu_match[] = { · line 1449
Quoted 10 lines
drivers/clk/spacemit/ccu-k1.c +7
-0+ .compatible = "spacemit,k1-syscon-rcpu2", + .data = &k1_ccu_rcpu2_data, + }, + { + .compatible = "spacemit,k1-syscon-apbc2", + .data = &k1_ccu_apbc2_data, + }, { } };MODULE_DEVICE_TABLE (of, of_k1_ccu_match);regards
Philipp
Re: [PATCH v4 6/7] clk: spacemit: define new syscons with only resets
In reply to Philipp ZabelQuoted 9 lines · Philipp Zabel
drivers/clk/spacemit/ccu-k1.c static const struct spacemit_ccu_data k1_ccu_apmu_data = { · line 1252
Quoted 8 lines
drivers/clk/spacemit/ccu-k1.c +8
-0+static const struct ccu_reset_data apbc2_reset_data[] = { + [RESET_APBC2_UART1 ] =RESET_DATA (APBC2_UART1_CLK_RST ,BIT (2 ), (0 )), + [RESET_APBC2_SSP2 ] =RESET_DATA (APBC2_SSP2_CLK_RST ,BIT (2 ), (0 )), + [RESET_APBC2_TWSI3 ] =RESET_DATA (APBC2_TWSI3_CLK_RST ,BIT (2 ), (0 )), + [RESET_APBC2_RTC ] =RESET_DATA (APBC2_RTC_CLK_RST ,BIT (2 ), (0 )), + [RESET_APBC2_TIMERS0 ] =RESET_DATA (APBC2_TIMERS0_CLK_RST ,BIT (2 ), (0 )), + [RESET_APBC2_KPC ] =RESET_DATA (APBC2_KPC_CLK_RST ,BIT (2 ), (0 )), + [RESET_APBC2_GPIO ] =RESET_DATA (APBC2_GPIO_CLK_RST ,BIT (2 ), (0 )),Superfluous parentheses.
Wow, this is something I don't normally do. I had to check to see if I managed to drop "BIT" or something (I did not). Anyway, I'll fix this in the next revision. Thanks.
-Alex
PATCH v4 7/7 riscv: dts: spacemit: add reset support for the K1 SoC
In reply to Alex ElderDefine syscon nodes for the RCPU, RCPU2, and APBC2 SpacemiT CCUS, which currently support resets but not clocks in the SpacemiT K1.
--- arch/riscv/boot/dts/spacemit/k1.dtsi | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
arch/riscv/boot/dts/spacemit/k1.dtsi +18 -0
@@ -346,6 +346,18 @@ soc { dma-noncoherent; ranges; + syscon_rcpu: system-controller@c0880000 { + compatible = "spacemit,k1-syscon-rcpu"; + reg = <0x0 0xc0880000 0x0 0x2048>; + #reset-cells = <1>; + }; + + syscon_rcpu2: system-controller@c0888000 { + compatible = "spacemit,k1-syscon-rcpu2"; + reg = <0x0 0xc0888000 0x0 0x28>; + #reset-cells = <1>; + }; + syscon_apbc: system-control@d4015000 { compatible = "spacemit,k1-syscon-apbc"; reg = <0x0 0xd4015000 0x0 0x1000>;
@@ -514,6 +526,12 @@ clint: timer@e4000000 { <&cpu7_intc 3>, <&cpu7_intc 7>; }; + syscon_apbc2: system-controller@f0610000 { + compatible = "spacemit,k1-syscon-apbc2"; + reg = <0x0 0xf0610000 0x0 0x20>; + #reset-cells = <1>; + }; + sec_uart1: serial@f0612000 { compatible = "spacemit,k1-uart", "intel,xscale-uart"; reg = <0x0 0xf0612000 0x0 0x100>;
Signature · 1 line
2.45.2
Stephen Boyd
maintainerQuoting Alex Elder (2025-04-14 12:17:07)
Quoted 1 line
This series adds reset controller support for the SpacemiT K1 SoC.
Please put the reset driver in drivers/reset so that it gets proper review from reset maintainers. To do that, use the auxiliary bus when the device is both a clk and reset controller.