1.1 --- a/pkg/devices/include/clocks.h Thu Nov 16 22:03:51 2023 +0100
1.2 +++ b/pkg/devices/include/clocks.h Thu Nov 16 23:58:13 2023 +0100
1.3 @@ -56,6 +56,7 @@
1.4 Clock_i2s1_rx,
1.5 Clock_i2s1_tx,
1.6 Clock_kbc,
1.7 + Clock_l2cache,
1.8 Clock_lcd, /* LCD peripheral clock */
1.9 Clock_lcd_pixel0,
1.10 Clock_lcd_pixel1,
2.1 --- a/pkg/devices/lib/cpm/src/jz4780.cc Thu Nov 16 22:03:51 2023 +0100
2.2 +++ b/pkg/devices/lib/cpm/src/jz4780.cc Thu Nov 16 23:58:13 2023 +0100
2.3 @@ -393,6 +393,10 @@
2.4 Control(Clock_gate_hdmi, Clock_change_enable_hdmi, Clock_busy_hdmi),
2.5 Divider(Clock_divider_hdmi)),
2.6
2.7 + clock_l2cache(Source(mux_core, Clock_source_cpu),
2.8 + Control(Field::undefined, Clock_change_enable_cpu, Clock_busy_cpu),
2.9 + Divider(Clock_divider_l2cache)),
2.10 +
2.11 clock_lcd_pixel0(Source(mux_lcd, Clock_source_lcd0),
2.12 Control(Clock_gate_lcd, Clock_change_enable_lcd0, Clock_busy_lcd0),
2.13 Divider(Clock_divider_lcd0)),
2.14 @@ -501,6 +505,7 @@
2.15 &clock_none, // Clock_i2s1_rx
2.16 &clock_none, // Clock_i2s1_tx
2.17 &clock_none, // Clock_kbc
2.18 + &clock_l2cache,
2.19 &clock_lcd,
2.20 &clock_lcd_pixel0,
2.21 &clock_lcd_pixel1,
3.1 --- a/pkg/devices/lib/cpm/src/x1600.cc Thu Nov 16 22:03:51 2023 +0100
3.2 +++ b/pkg/devices/lib/cpm/src/x1600.cc Thu Nov 16 23:58:13 2023 +0100
3.3 @@ -336,6 +336,10 @@
3.4
3.5 clock_hclock2((Source(mux_hclock2_pclock)), (Divider(Clock_divider_hclock2))),
3.6
3.7 + clock_l2cache(Source(mux_core, Clock_source_cpu),
3.8 + Control(Field::undefined, Clock_change_enable_cpu, Clock_busy_cpu),
3.9 + Divider(Clock_divider_l2cache)),
3.10 +
3.11 clock_lcd_pixel(Source(mux_dev, Clock_source_lcd),
3.12 Control(Clock_gate_lcd_pixel, Clock_change_enable_lcd, Clock_busy_lcd),
3.13 Divider(Clock_divider_lcd)),
3.14 @@ -440,6 +444,7 @@
3.15 &clock_none, // Clock_i2s1_rx
3.16 &clock_none, // Clock_i2s1_tx
3.17 &clock_none, // Clock_kbc
3.18 + &clock_l2cache,
3.19 &clock_none, // Clock_lcd
3.20 &clock_lcd_pixel,
3.21 &clock_none, // Clock_lcd_pixel1
4.1 --- a/pkg/devices/lib/rtc/include/rtc-x1600.h Thu Nov 16 22:03:51 2023 +0100
4.2 +++ b/pkg/devices/lib/rtc/include/rtc-x1600.h Thu Nov 16 23:58:13 2023 +0100
4.3 @@ -28,11 +28,15 @@
4.4
4.5 #ifdef __cplusplus
4.6
4.7 +#include <l4/devices/cpm-x1600.h>
4.8 #include <l4/devices/hw_register_block.h>
4.9
4.10 class Rtc_x1600_chip
4.11 {
4.12 protected:
4.13 + /* Only use the CPM for the X1600, not other chips. */
4.14 +
4.15 + Cpm_x1600_chip *_cpm;
4.16 Hw::Register_block<32> _regs;
4.17
4.18 /* Utility methods. */
4.19 @@ -42,7 +46,7 @@
4.20 void write_enable();
4.21
4.22 public:
4.23 - explicit Rtc_x1600_chip(l4_addr_t addr);
4.24 + explicit Rtc_x1600_chip(l4_addr_t addr, Cpm_x1600_chip *cpm = NULL);
4.25
4.26 void disable();
4.27
4.28 @@ -79,7 +83,7 @@
4.29
4.30 EXTERN_C_BEGIN
4.31
4.32 -void *x1600_rtc_init(l4_addr_t rtc_base);
4.33 +void *x1600_rtc_init(l4_addr_t rtc_base, void *cpm);
4.34
4.35 void x1600_rtc_disable(void *rtc);
4.36
5.1 --- a/pkg/devices/lib/rtc/src/x1600.cc Thu Nov 16 22:03:51 2023 +0100
5.2 +++ b/pkg/devices/lib/rtc/src/x1600.cc Thu Nov 16 23:58:13 2023 +0100
5.3 @@ -126,7 +126,8 @@
5.4
5.5 // Peripheral abstraction.
5.6
5.7 -Rtc_x1600_chip::Rtc_x1600_chip(l4_addr_t addr)
5.8 +Rtc_x1600_chip::Rtc_x1600_chip(l4_addr_t addr, Cpm_x1600_chip *cpm)
5.9 +: _cpm(cpm)
5.10 {
5.11 _regs = new Hw::Mmio_register_block<32>(addr);
5.12 }
5.13 @@ -264,6 +265,12 @@
5.14 void
5.15 Rtc_x1600_chip::power_down()
5.16 {
5.17 + /* Set CPU frequency to L2 cache frequency before powering down. This is
5.18 + apparently necessary according to the X1600 manual. */
5.19 +
5.20 + if (_cpm != NULL)
5.21 + _cpm->set_frequency(Clock_cpu, _cpm->get_frequency(Clock_l2cache));
5.22 +
5.23 write_enable();
5.24 _regs[Hibernate_control] = _regs[Hibernate_control] | Hibernate_power_down;
5.25 }
5.26 @@ -273,9 +280,9 @@
5.27 // C language interface functions.
5.28
5.29 void
5.30 -*x1600_rtc_init(l4_addr_t rtc_base)
5.31 +*x1600_rtc_init(l4_addr_t rtc_base, void *cpm)
5.32 {
5.33 - return (void *) new Rtc_x1600_chip(rtc_base);
5.34 + return (void *) new Rtc_x1600_chip(rtc_base, static_cast<Cpm_x1600_chip *>(cpm));
5.35 }
5.36
5.37 void x1600_rtc_disable(void *rtc)
6.1 --- a/pkg/landfall-examples/hw_info/common.h Thu Nov 16 22:03:51 2023 +0100
6.2 +++ b/pkg/landfall-examples/hw_info/common.h Thu Nov 16 23:58:13 2023 +0100
6.3 @@ -167,7 +167,7 @@
6.4
6.5 /* RTC adapter functions. */
6.6
6.7 -void *rtc_init(l4_addr_t start);
6.8 +void *rtc_init(l4_addr_t start, void *cpm);
6.9
6.10 void rtc_disable(void *rtc);
6.11
7.1 --- a/pkg/landfall-examples/hw_info/hw_info.c Thu Nov 16 22:03:51 2023 +0100
7.2 +++ b/pkg/landfall-examples/hw_info/hw_info.c Thu Nov 16 23:58:13 2023 +0100
7.3 @@ -1602,7 +1602,7 @@
7.4
7.5 printf("RTC at 0x%lx...0x%lx.\n", rtc_base, rtc_base_end);
7.6
7.7 - rtc = rtc_init(rtc_base);
7.8 + rtc = rtc_init(rtc_base, cpm);
7.9
7.10 printf("Access SSI...\n");
7.11
8.1 --- a/pkg/landfall-examples/hw_info/jz4780.c Thu Nov 16 22:03:51 2023 +0100
8.2 +++ b/pkg/landfall-examples/hw_info/jz4780.c Thu Nov 16 23:58:13 2023 +0100
8.3 @@ -337,9 +337,12 @@
8.4
8.5 /* RTC adapter functions. */
8.6
8.7 -void *rtc_init(l4_addr_t start)
8.8 +void *rtc_init(l4_addr_t start, void *cpm)
8.9 {
8.10 - return x1600_rtc_init(start);
8.11 + /* Ignore the CPM requirement for the JZ4780. */
8.12 +
8.13 + (void) cpm;
8.14 + return x1600_rtc_init(start, NULL);
8.15 }
8.16
8.17 void rtc_disable(void *rtc)
8.18 @@ -495,6 +498,7 @@
8.19 {"pllv", Clock_pll_V, "PLL V"},
8.20 {"main", Clock_main, "Main (SCLK_A)"},
8.21 {"cpu", Clock_cpu, "CPU"},
8.22 + {"l2c", Clock_l2cache, "L2 cache"},
8.23 {"h2p", Clock_hclock2_pclock, "AHB2/APB"},
8.24 {"ahb0", Clock_hclock0, "AHB0"},
8.25 {"ahb2", Clock_hclock2, "AHB2"},
9.1 --- a/pkg/landfall-examples/hw_info/x1600.c Thu Nov 16 22:03:51 2023 +0100
9.2 +++ b/pkg/landfall-examples/hw_info/x1600.c Thu Nov 16 23:58:13 2023 +0100
9.3 @@ -326,9 +326,9 @@
9.4
9.5 /* RTC adapter functions. */
9.6
9.7 -void *rtc_init(l4_addr_t start)
9.8 +void *rtc_init(l4_addr_t start, void *cpm)
9.9 {
9.10 - return x1600_rtc_init(start);
9.11 + return x1600_rtc_init(start, cpm);
9.12 }
9.13
9.14 void rtc_disable(void *rtc)
9.15 @@ -483,6 +483,7 @@
9.16 {"pllm", Clock_pll_M, "PLL M"},
9.17 {"main", Clock_main, "Main (SCLK_A)"},
9.18 {"cpu", Clock_cpu, "CPU"},
9.19 + {"l2c", Clock_l2cache, "L2 cache"},
9.20 {"ahb0", Clock_hclock0, "AHB0"},
9.21 {"ahb2", Clock_hclock2, "AHB2"},
9.22 {"apb", Clock_pclock, "APB"},