Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions drivers/clock_control/clock_control_renesas_ra_cgc.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,25 @@
#include <zephyr/dt-bindings/clock/ra_clock.h>
#include <zephyr/drivers/clock_control/renesas_ra_cgc.h>

#if DT_NODE_HAS_STATUS(DT_NODELABEL(pclkblock), okay)
#define MSTP_REGS_ELEM(node_id, prop, idx) \
[DT_STRING_TOKEN_BY_IDX(node_id, prop, idx)] = \
(volatile uint32_t *)DT_REG_ADDR_BY_IDX(node_id, idx),

static volatile uint32_t *mstp_regs[] = {
DT_FOREACH_PROP_ELEM(DT_NODELABEL(pclkblock), reg_names, MSTP_REGS_ELEM)};
#else
static volatile uint32_t *mstp_regs[] = {};
#endif

static int clock_control_renesas_ra_on(const struct device *dev, clock_control_subsys_t sys)
{
struct clock_control_ra_subsys_cfg *subsys_clk = (struct clock_control_ra_subsys_cfg *)sys;

if (!dev || !sys) {
return -EINVAL;
}
WRITE_BIT(*subsys_clk->mstp, subsys_clk->stop_bit, false);
WRITE_BIT(*mstp_regs[subsys_clk->mstp], subsys_clk->stop_bit, false);
return 0;
}

Expand All @@ -31,7 +42,7 @@ static int clock_control_renesas_ra_off(const struct device *dev, clock_control_
return -EINVAL;
}

WRITE_BIT(*subsys_clk->mstp, subsys_clk->stop_bit, true);
WRITE_BIT(*mstp_regs[subsys_clk->mstp], subsys_clk->stop_bit, true);
return 0;
}

Expand Down Expand Up @@ -79,7 +90,9 @@ static const struct clock_control_driver_api clock_control_reneas_ra_api = {
#define INIT_PCLK(node_id) \
IF_ENABLED(DT_NODE_HAS_COMPAT(node_id, renesas_ra_cgc_pclk), \
(static const struct clock_control_ra_pclk_cfg node_id##_cfg = \
{.clk_src = DT_PROP_OR(node_id, clk_src, RA_CLOCK_SOURCE_DISABLE), \
{.clk_src = DT_PROP_OR(node_id, clk_src, \
DT_PROP_OR(DT_PARENT(node_id), sysclock_src, \
RA_CLOCK_SOURCE_DISABLE)), \
.clk_div = DT_PROP_OR(node_id, clk_div, RA_SYS_CLOCK_DIV_1)}; \
DEVICE_DT_DEFINE(node_id, &clock_control_ra_init_pclk, NULL, NULL, \
&node_id##_cfg, PRE_KERNEL_1, \
Expand Down
9 changes: 8 additions & 1 deletion dts/arm/renesas/ra/ra2/r7fa2a1xh.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
};

clocks: clocks {
#address-cells = <1>;
#size-cells = <1>;

xtal: clock-xtal {
compatible = "renesas,ra-cgc-external-clock";
clock-frequency = <DT_FREQ_M(12)>;
Expand Down Expand Up @@ -54,8 +57,12 @@
status = "disabled";
};

pclkblock: pclkblock {
pclkblock: pclkblock@4001e01c {
compatible = "renesas,ra-cgc-pclk-block";
reg = <0x4001e01c 4>, <0x40047000 4>, <0x40047004 4>,
<0x40047008 4>;
reg-names = "MSTPA", "MSTPB","MSTPC",
"MSTPD";
#clock-cells = <0>;
sysclock-src = <RA_CLOCK_SOURCE_HOCO>;
status = "okay";
Expand Down
9 changes: 8 additions & 1 deletion dts/arm/renesas/ra/ra6/r7fa6e10x.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@
};

clocks: clocks {
#address-cells = <1>;
#size-cells = <1>;

xtal: clock-xtal {
compatible = "renesas,ra-cgc-external-clock";
clock-frequency = <DT_FREQ_M(20)>;
Expand Down Expand Up @@ -146,8 +149,12 @@
status = "disabled";
};

pclkblock: pclkblock {
pclkblock: pclkblock@40084000 {
compatible = "renesas,ra-cgc-pclk-block";
reg = <0x40084000 4>, <0x40084004 4>, <0x40084008 4>,
<0x4008400c 4>, <0x40084010 4>;
reg-names = "MSTPA", "MSTPB","MSTPC",
"MSTPD", "MSTPE";
#clock-cells = <0>;
sysclock-src = <RA_CLOCK_SOURCE_PLL>;
status = "okay";
Expand Down
9 changes: 8 additions & 1 deletion dts/arm/renesas/ra/ra6/r7fa6e2bx.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
};

clocks: clocks {
#address-cells = <1>;
#size-cells = <1>;

xtal: clock-xtal {
compatible = "renesas,ra-cgc-external-clock";
clock-frequency = <DT_FREQ_M(20)>;
Expand Down Expand Up @@ -76,8 +79,12 @@
status = "disabled";
};

pclkblock: pclkblock {
pclkblock: pclkblock@40084000 {
compatible = "renesas,ra-cgc-pclk-block";
reg = <0x40084000 4>, <0x40084004 4>, <0x40084008 4>,
<0x4008400c 4>, <0x40084010 4>;
reg-names = "MSTPA", "MSTPB","MSTPC",
"MSTPD", "MSTPE";
#clock-cells = <0>;
sysclock-src = <RA_CLOCK_SOURCE_PLL>;
status = "okay";
Expand Down
9 changes: 8 additions & 1 deletion dts/arm/renesas/ra/ra6/r7fa6m1ad3cfp.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
};

clocks: clocks {
#address-cells = <1>;
#size-cells = <1>;

xtal: clock-xtal {
compatible = "renesas,ra-cgc-external-clock";
clock-frequency = <DT_FREQ_M(12)>;
Expand Down Expand Up @@ -70,8 +73,12 @@
status = "disabled";
};

pclkblock: pclkblock {
pclkblock: pclkblock@4001e01c {
compatible = "renesas,ra-cgc-pclk-block";
reg = <0x4001e01c 4>, <0x40047000 4>, <0x40047004 4>,
<0x40047008 4>;
reg-names = "MSTPA", "MSTPB","MSTPC",
"MSTPD";
#clock-cells = <0>;
sysclock-src = <RA_CLOCK_SOURCE_PLL>;
status = "okay";
Expand Down
9 changes: 8 additions & 1 deletion dts/arm/renesas/ra/ra6/r7fa6m2ax.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
};

clocks: clocks {
#address-cells = <1>;
#size-cells = <1>;

xtal: clock-xtal {
compatible = "renesas,ra-cgc-external-clock";
clock-frequency = <DT_FREQ_M(12)>;
Expand Down Expand Up @@ -101,8 +104,12 @@
status = "disabled";
};

pclkblock: pclkblock {
pclkblock: pclkblock@4001e01c {
compatible = "renesas,ra-cgc-pclk-block";
reg = <0x4001e01c 4>, <0x40047000 4>, <0x40047004 4>,
<0x40047008 4>;
reg-names = "MSTPA", "MSTPB","MSTPC",
"MSTPD";
#clock-cells = <0>;
sysclock-src = <RA_CLOCK_SOURCE_PLL>;
status = "okay";
Expand Down
9 changes: 8 additions & 1 deletion dts/arm/renesas/ra/ra6/r7fa6m3ax.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@
};

clocks: clocks {
#address-cells = <1>;
#size-cells = <1>;

xtal: clock-xtal {
compatible = "renesas,ra-cgc-external-clock";
clock-frequency = <DT_FREQ_M(24)>;
Expand Down Expand Up @@ -141,8 +144,12 @@
status = "disabled";
};

pclkblock: pclkblock {
pclkblock: pclkblock@4001e01c {
compatible = "renesas,ra-cgc-pclk-block";
reg = <0x4001e01c 4>, <0x40047000 4>, <0x40047004 4>,
<0x40047008 4>;
reg-names = "MSTPA", "MSTPB","MSTPC",
"MSTPD";
#clock-cells = <0>;
sysclock-src = <RA_CLOCK_SOURCE_PLL>;
status = "okay";
Expand Down
9 changes: 8 additions & 1 deletion dts/arm/renesas/ra/ra6/r7fa6m4ax.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@
};

clocks: clocks {
#address-cells = <1>;
#size-cells = <1>;

xtal: clock-xtal {
compatible = "renesas,ra-cgc-external-clock";
clock-frequency = <DT_FREQ_M(24)>;
Expand Down Expand Up @@ -182,8 +185,12 @@
status = "disabled";
};

pclkblock: pclkblock {
pclkblock: pclkblock@40084000 {
compatible = "renesas,ra-cgc-pclk-block";
reg = <0x40084000 4>, <0x40084004 4>, <0x40084008 4>,
<0x4008400c 4>, <0x40084010 4>;
reg-names = "MSTPA", "MSTPB","MSTPC",
"MSTPD", "MSTPE";
#clock-cells = <0>;
sysclock-src = <RA_CLOCK_SOURCE_PLL>;
status = "okay";
Expand Down
9 changes: 8 additions & 1 deletion dts/arm/renesas/ra/ra6/r7fa6m5xh.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@
};

clocks: clocks {
#address-cells = <1>;
#size-cells = <1>;

xtal: clock-xtal {
compatible = "renesas,ra-cgc-external-clock";
clock-frequency = <DT_FREQ_M(24)>;
Expand Down Expand Up @@ -242,8 +245,12 @@
status = "disabled";
};

pclkblock: pclkblock {
pclkblock: pclkblock@40084000 {
compatible = "renesas,ra-cgc-pclk-block";
reg = <0x40084000 4>, <0x40084004 4>, <0x40084008 4>,
<0x4008400c 4>, <0x40084010 4>;
reg-names = "MSTPA", "MSTPB","MSTPC",
"MSTPD", "MSTPE";
#clock-cells = <0>;
sysclock-src = <RA_CLOCK_SOURCE_PLL>;
status = "okay";
Expand Down
9 changes: 8 additions & 1 deletion dts/arm/renesas/ra/ra8/r7fa8d1xh.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

/ {
clocks: clocks {
#address-cells = <1>;
#size-cells = <1>;

xtal: clock-xtal {
compatible = "renesas,ra-cgc-external-clock";
clock-frequency = <DT_FREQ_M(20)>;
Expand Down Expand Up @@ -75,8 +78,12 @@
status = "disabled";
};

pclkblock: pclkblock {
pclkblock: pclkblock@40203000 {
compatible = "renesas,ra-cgc-pclk-block";
reg = <0x40203000 4>, <0x40203004 4>, <0x40203008 4>,
<0x4020300c 4>, <0x40203010 4>;
reg-names = "MSTPA", "MSTPB","MSTPC",
"MSTPD", "MSTPE";
#clock-cells = <0>;
sysclock-src = <RA_CLOCK_SOURCE_PLL1P>;
status = "okay";
Expand Down
9 changes: 8 additions & 1 deletion dts/arm/renesas/ra/ra8/r7fa8m1xh.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

/ {
clocks: clocks {
#address-cells = <1>;
#size-cells = <1>;

xtal: clock-xtal {
compatible = "renesas,ra-cgc-external-clock";
clock-frequency = <DT_FREQ_M(20)>;
Expand Down Expand Up @@ -75,8 +78,12 @@
status = "disabled";
};

pclkblock: pclkblock {
pclkblock: pclkblock@40203000 {
compatible = "renesas,ra-cgc-pclk-block";
reg = <0x40203000 4>, <0x40203004 4>, <0x40203008 4>,
<0x4020300c 4>, <0x40203010 4>;
reg-names = "MSTPA", "MSTPB","MSTPC",
"MSTPD", "MSTPE";
#clock-cells = <0>;
sysclock-src = <RA_CLOCK_SOURCE_PLL1P>;
status = "okay";
Expand Down
9 changes: 8 additions & 1 deletion dts/arm/renesas/ra/ra8/r7fa8t1xh.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

/ {
clocks: clocks {
#address-cells = <1>;
#size-cells = <1>;

xtal: clock-xtal {
compatible = "renesas,ra-cgc-external-clock";
clock-frequency = <DT_FREQ_M(24)>;
Expand Down Expand Up @@ -75,8 +78,12 @@
status = "disabled";
};

pclkblock: pclkblock {
pclkblock: pclkblock@40203000 {
compatible = "renesas,ra-cgc-pclk-block";
reg = <0x40203000 4>, <0x40203004 4>, <0x40203008 4>,
<0x4020300c 4>, <0x40203010 4>;
reg-names = "MSTPA", "MSTPB","MSTPC",
"MSTPD", "MSTPE";
#clock-cells = <0>;
sysclock-src = <RA_CLOCK_SOURCE_PLL1P>;
status = "okay";
Expand Down
2 changes: 1 addition & 1 deletion include/zephyr/drivers/clock_control/renesas_ra_cgc.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct clock_control_ra_pclk_cfg {
};

struct clock_control_ra_subsys_cfg {
volatile uint32_t *mstp;
uint32_t mstp;
uint32_t stop_bit;
};

Expand Down
10 changes: 5 additions & 5 deletions include/zephyr/dt-bindings/clock/ra_clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@
#define RA_SDADC_CLOCK_DIV_12 7
#define RA_SDADC_CLOCK_DIV_16 8

#define MSTPA 0x40203000
#define MSTPB 0x40203004
#define MSTPC 0x40203008
#define MSTPD 0x4020300C
#define MSTPE 0x40203010
#define MSTPA 0
#define MSTPB 1
#define MSTPC 2
#define MSTPD 3
#define MSTPE 4

#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_RA_H_ */