1.1 --- a/pkg/devices/lib/cpm/include/cpm-jz4780.h Tue Sep 12 17:20:10 2023 +0200
1.2 +++ b/pkg/devices/lib/cpm/include/cpm-jz4780.h Thu Sep 14 00:11:14 2023 +0200
1.3 @@ -1,7 +1,7 @@
1.4 /*
1.5 * CPM (clock and power management) support for the JZ4780.
1.6 *
1.7 - * Copyright (C) 2017, 2018, 2020, 2021 Paul Boddie <paul@boddie.org.uk>
1.8 + * Copyright (C) 2017, 2018, 2020, 2021, 2023 Paul Boddie <paul@boddie.org.uk>
1.9 *
1.10 * This program is free software; you can redistribute it and/or
1.11 * modify it under the terms of the GNU General Public License as
1.12 @@ -48,11 +48,14 @@
1.13 void set_field(uint32_t reg, uint32_t mask, uint8_t shift, uint32_t value);
1.14 uint8_t _get_divider(uint32_t reg, uint32_t mask, uint8_t shift);
1.15
1.16 - // PLL control.
1.17 + // PLL status.
1.18
1.19 int have_pll(uint32_t pll_reg);
1.20 int pll_enabled(uint32_t pll_reg);
1.21 int pll_bypassed(uint32_t pll_reg);
1.22 +
1.23 + // PLL control.
1.24 +
1.25 void pll_disable(uint32_t pll_reg);
1.26 void pll_enable(uint32_t pll_reg);
1.27
1.28 @@ -89,10 +92,6 @@
1.29 void set_pclock_source(uint8_t source);
1.30 Cpm_jz4780_chip(l4_addr_t addr, uint32_t exclk_freq, uint32_t rtclk_freq);
1.31
1.32 - int have_clock(enum Clock_identifiers clock);
1.33 - void start_clock(enum Clock_identifiers clock);
1.34 - void stop_clock(enum Clock_identifiers clock);
1.35 -
1.36 // Clock divider values.
1.37
1.38 uint8_t get_cpu_divider();
1.39 @@ -103,13 +102,9 @@
1.40 uint8_t get_lcd_pixel_divider(uint8_t controller = 0);
1.41 uint8_t get_memory_divider();
1.42
1.43 - // Input frequencies.
1.44 + // Clock sources.
1.45
1.46 uint8_t get_main_source();
1.47 - uint32_t get_main_frequency();
1.48 -
1.49 - // Clock sources, providing the input frequency.
1.50 -
1.51 uint8_t get_cpu_source();
1.52 uint8_t get_hclock0_source();
1.53 uint8_t get_hclock2_source();
1.54 @@ -119,6 +114,14 @@
1.55 uint8_t get_memory_source();
1.56 uint8_t get_pclock_source();
1.57
1.58 + // PLL frequency status.
1.59 +
1.60 + uint32_t get_apll_frequency();
1.61 + uint32_t get_epll_frequency();
1.62 + uint32_t get_mpll_frequency();
1.63 + uint32_t get_vpll_frequency();
1.64 +
1.65 + uint32_t get_main_frequency();
1.66 uint32_t get_cpu_source_frequency();
1.67 uint32_t get_hclock0_source_frequency();
1.68 uint32_t get_hclock2_source_frequency();
1.69 @@ -128,7 +131,7 @@
1.70 uint32_t get_memory_source_frequency();
1.71 uint32_t get_pclock_source_frequency();
1.72
1.73 - // Final, calculated frequencies.
1.74 + // Clock frequency status.
1.75
1.76 uint32_t get_cpu_frequency();
1.77 uint32_t get_hclock0_frequency();
1.78 @@ -136,17 +139,16 @@
1.79 uint32_t get_memory_frequency();
1.80 uint32_t get_pclock_frequency();
1.81
1.82 - uint32_t get_apll_frequency();
1.83 - uint32_t get_epll_frequency();
1.84 - uint32_t get_mpll_frequency();
1.85 - uint32_t get_vpll_frequency();
1.86 -
1.87 void set_pll_parameters(uint32_t pll_reg, uint16_t multiplier, uint8_t in_divider, uint8_t out_divider);
1.88
1.89 - uint32_t get_frequency(enum Clock_frequency_identifiers clock);
1.90 - void set_frequency(enum Clock_frequency_identifiers clock, uint32_t frequency);
1.91 + // Clock frequency configuration.
1.92
1.93 - void update_output_frequency();
1.94 + uint32_t get_frequency(enum Clock_identifiers clock);
1.95 + void set_frequency(enum Clock_identifiers clock, uint32_t frequency);
1.96 +
1.97 + int have_clock(enum Clock_identifiers clock);
1.98 + void start_clock(enum Clock_identifiers clock);
1.99 + void stop_clock(enum Clock_identifiers clock);
1.100 };
1.101
1.102 #endif /* __cplusplus */
1.103 @@ -201,8 +203,8 @@
1.104 uint32_t jz4780_cpm_get_mpll_frequency(void *cpm);
1.105 uint32_t jz4780_cpm_get_vpll_frequency(void *cpm);
1.106
1.107 -uint32_t jz4780_cpm_get_frequency(void *cpm, enum Clock_frequency_identifiers clock);
1.108 -void jz4780_cpm_set_frequency(void *cpm, enum Clock_frequency_identifiers clock, uint32_t frequency);
1.109 +uint32_t jz4780_cpm_get_frequency(void *cpm, enum Clock_identifiers clock);
1.110 +void jz4780_cpm_set_frequency(void *cpm, enum Clock_identifiers clock, uint32_t frequency);
1.111
1.112 void jz4780_cpm_set_mpll_parameters(void *cpm, uint16_t multiplier, uint8_t in_divider, uint8_t out_divider);
1.113