1 // Copyright (C) 2022 Beken Corporation
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include "icu_hw.h"
16 #include "icu_hal.h"
17 #include "icu_ll.h"
18 #include "hal_config.h"
19
20 //TODO finally we will automatically generate this code
21
22 #if CFG_HAL_DEBUG_ICU
23
icu_struct_dump(void)24 void icu_struct_dump(void)
25 {
26 icu_hw_t *hw = (icu_hw_t *)ICU_LL_REG_BASE();
27 SOC_LOGI("base=%x\n", (uint32_t)hw);
28
29 SOC_LOGI("peri_clk_mux=%x v=%x\n", &hw->peri_clk_mux, hw->peri_clk_mux.v);
30 SOC_LOGI(" uart1: %x\n", hw->peri_clk_mux.uart1);
31 SOC_LOGI(" uart2: %x\n", hw->peri_clk_mux.uart2);
32 SOC_LOGI(" i2c1: %x\n", hw->peri_clk_mux.i2c1);
33 SOC_LOGI(" irda: %x\n", hw->peri_clk_mux.irda);
34 SOC_LOGI(" i2c2: %x\n", hw->peri_clk_mux.i2c2);
35 SOC_LOGI(" spi: %x\n", hw->peri_clk_mux.spi);
36 SOC_LOGI(" saradc: %x\n", hw->peri_clk_mux.saradc);
37 SOC_LOGI(" pwms: %x\n", hw->peri_clk_mux.pwms);
38 SOC_LOGI(" sdio: %x\n", hw->peri_clk_mux.sdio);
39 SOC_LOGI(" reserved_1: %x\n", hw->peri_clk_mux.reserved_1);
40 #if CONFIG_SOC_BK7236A
41 SOC_LOGI(" jpeg=%x\n", hw->peri_clk_mux.jpeg);
42 #endif
43 SOC_LOGI(" dco_clk_div: %x\n", hw->peri_clk_mux.dco_clk_div);
44 SOC_LOGI(" reserved_2: %x\n", hw->peri_clk_mux.reserved_2);
45
46 SOC_LOGI("pwm_chan_clk_mux=%x v=%x\n", &hw->pwm_chan_clk_mux, hw->pwm_chan_clk_mux.v);
47 SOC_LOGI(" chan0=%x\n", hw->pwm_chan_clk_mux.chan0);
48 SOC_LOGI(" chan1=%x\n", hw->pwm_chan_clk_mux.chan1);
49 SOC_LOGI(" chan2=%x\n", hw->pwm_chan_clk_mux.chan2);
50 SOC_LOGI(" chan3=%x\n", hw->pwm_chan_clk_mux.chan3);
51 SOC_LOGI(" chan4=%x\n", hw->pwm_chan_clk_mux.chan4);
52 SOC_LOGI(" chan5=%x\n", hw->pwm_chan_clk_mux.chan5);
53 SOC_LOGI(" reserved=%x\n", hw->pwm_chan_clk_mux.reserved);
54
55 SOC_LOGI("clk_pwr_down=%x v=%x\n", &hw->clk_pwr_down, hw->clk_pwr_down.v);
56 SOC_LOGI(" uart1=%x\n", hw->clk_pwr_down.uart1);
57 SOC_LOGI(" uart2=%x\n", hw->clk_pwr_down.uart2);
58 SOC_LOGI(" i2c1=%x\n", hw->clk_pwr_down.i2c1);
59 SOC_LOGI(" irda=%x\n", hw->clk_pwr_down.irda);
60 SOC_LOGI(" reserved_1=%x\n", hw->clk_pwr_down.reserved_1);
61 SOC_LOGI(" i2c2=%x\n", hw->clk_pwr_down.i2c2);
62 SOC_LOGI(" spi=%x\n", hw->clk_pwr_down.spi);
63 SOC_LOGI(" saradc=%x\n", hw->clk_pwr_down.saradc);
64 SOC_LOGI(" arm_watchdog=%x\n", hw->clk_pwr_down.arm_watchdog);
65 SOC_LOGI(" pwm0=%x\n", hw->clk_pwr_down.pwm0);
66 SOC_LOGI(" pwm1=%x\n", hw->clk_pwr_down.pwm1);
67 SOC_LOGI(" pwm2=%x\n", hw->clk_pwr_down.pwm2);
68 SOC_LOGI(" pwm3=%x\n", hw->clk_pwr_down.pwm3);
69 SOC_LOGI(" pwm4=%x\n", hw->clk_pwr_down.pwm4);
70 SOC_LOGI(" pwm5=%x\n", hw->clk_pwr_down.pwm5);
71 SOC_LOGI(" security=%x\n", hw->clk_pwr_down.security);
72 SOC_LOGI(" reserved_2=%x\n", hw->clk_pwr_down.reserved_2);
73 SOC_LOGI(" sdio=%x\n", hw->clk_pwr_down.sdio);
74 SOC_LOGI(" timers=%x\n", hw->clk_pwr_down.timers);
75 #if CONFIG_SOC_BK7236A
76 SOC_LOGI(" jpeg=%x\n", hw->clk_pwr_down.jpeg);
77 #endif
78
79 SOC_LOGI("peri_clk_gate_disable=%x v=%x\n", &hw->peri_clk_gate_disable, hw->peri_clk_gate_disable.v);
80 SOC_LOGI(" icu=%x\n", hw->peri_clk_gate_disable.icu);
81 SOC_LOGI(" uart1=%x\n", hw->peri_clk_gate_disable.uart1);
82 SOC_LOGI(" uart2=%x\n", hw->peri_clk_gate_disable.uart2);
83 SOC_LOGI(" i2c1=%x\n", hw->peri_clk_gate_disable.i2c1);
84 SOC_LOGI(" irda=%x\n", hw->peri_clk_gate_disable.irda);
85 SOC_LOGI(" i2s_pcm=%x\n", hw->peri_clk_gate_disable.i2s_pcm);
86 SOC_LOGI(" i2c2=%x\n", hw->peri_clk_gate_disable.i2c2);
87 SOC_LOGI(" spi=%x\n", hw->peri_clk_gate_disable.spi);
88 SOC_LOGI(" gpio=%x\n", hw->peri_clk_gate_disable.gpio);
89 SOC_LOGI(" watchdog=%x\n", hw->peri_clk_gate_disable.watchdog);
90 SOC_LOGI(" timers=%x\n", hw->peri_clk_gate_disable.timers);
91 SOC_LOGI(" pwms=%x\n", hw->peri_clk_gate_disable.pwms);
92 SOC_LOGI(" saradc=%x\n", hw->peri_clk_gate_disable.saradc);
93 SOC_LOGI(" sdio=%x\n", hw->peri_clk_gate_disable.sdio);
94 SOC_LOGI(" reserved_1=%x\n", hw->peri_clk_gate_disable.reserved_1);
95 SOC_LOGI(" mac=%x\n", hw->peri_clk_gate_disable.mac);
96 SOC_LOGI(" reserved_2=%x\n", hw->peri_clk_gate_disable.reserved_2);
97
98 SOC_LOGI("clk_pwr_down_2=%x v=%x\n", &hw->clk_pwr_down_2, hw->clk_pwr_down_2.v);
99 SOC_LOGI(" reserved_1=%x\n", hw->clk_pwr_down_2.reserved_1);
100 SOC_LOGI(" ble=%x\n", hw->clk_pwr_down_2.ble);
101 SOC_LOGI(" reserved_2%x\n", hw->clk_pwr_down_2.reserved_2);
102
103 SOC_LOGI("clk26m_div_factor=%x v=%x\n", &hw->clk26m_div_factor, hw->clk26m_div_factor.v);
104 SOC_LOGI(" factor=%x\n", hw->clk26m_div_factor.factor);
105
106 SOC_LOGI("int_en(%x)=%x raw_status(%x)=%x status(%x)=%x\n", &hw->int_en, hw->int_en.v,
107 &hw->int_raw_status, hw->int_raw_status.v,
108 &hw->int_status, hw->int_status.v);
109 SOC_LOGI(" irq_uart1 en=%x raw=%x st=%x\n", hw->int_en.irq_uart1, hw->int_raw_status.irq_uart1, hw->int_status.irq_uart1);
110 SOC_LOGI(" irq_uqrt2 en=%x raw=%x st=%x\n", hw->int_en.irq_uart2, hw->int_raw_status.irq_uart2, hw->int_status.irq_uart2);
111 SOC_LOGI(" irq_i2c1 en=%x raw=%x st=%x\n", hw->int_en.irq_i2c1, hw->int_raw_status.irq_i2c1, hw->int_status.irq_i2c1);
112 SOC_LOGI(" irq_irda en=%x raw=%x st=%x\n", hw->int_en.irq_irda, hw->int_raw_status.irq_irda, hw->int_status.irq_irda);
113 SOC_LOGI(" reserved_1 en=%x raw=%x st=%x\n", hw->int_en.reserved_1, hw->int_raw_status.reserved_1, hw->int_status.reserved_1);
114 SOC_LOGI(" irq_i2c2 en=%x raw=%x st=%x\n", hw->int_en.irq_i2c2, hw->int_raw_status.irq_i2c2, hw->int_status.irq_i2c2);
115 SOC_LOGI(" irq_spi en=%x raw=%x st=%x\n", hw->int_en.irq_spi, hw->int_raw_status.irq_spi, hw->int_status.irq_spi);
116 SOC_LOGI(" irq_gpio en=%x raw=%x st=%x\n", hw->int_en.irq_gpio, hw->int_raw_status.irq_gpio, hw->int_status.irq_gpio);
117 SOC_LOGI(" irq_timer en=%x raw=%x st=%x\n", hw->int_en.irq_timer, hw->int_raw_status.irq_timer, hw->int_status.irq_timer);
118 SOC_LOGI(" irq_pwm en=%x raw=%x st=%x\n", hw->int_en.irq_pwm, hw->int_raw_status.irq_pwm, hw->int_status.irq_pwm);
119 #if CONFIG_SOC_BK7236A
120 SOC_LOGI(" jpeg en=%x raw=%x st=%x\n", hw->int_en.irq_jpeg, hw->int_raw_status.irq_jpeg, hw->int_status.irq_jpeg);
121 #endif
122 SOC_LOGI(" irq_saradc en=%x raw=%x st=%x\n", hw->int_en.irq_saradc, hw->int_raw_status.irq_saradc, hw->int_status.irq_saradc);
123 SOC_LOGI(" irq_sdio en=%x raw=%x st=%x\n", hw->int_en.irq_sdio, hw->int_raw_status.irq_sdio, hw->int_status.irq_sdio);
124 SOC_LOGI(" irq_security en=%x raw=%x st=%x\n", hw->int_en.irq_security, hw->int_raw_status.irq_security, hw->int_status.irq_security);
125 SOC_LOGI(" irq_la en=%x raw=%x st=%x\n", hw->int_en.irq_la, hw->int_raw_status.irq_la, hw->int_status.irq_la);
126 SOC_LOGI(" irq_general_dma en=%x raw=%x st=%x\n", hw->int_en.irq_general_dma, hw->int_raw_status.irq_general_dma, hw->int_status.irq_general_dma);
127
128 SOC_LOGI(" fiq_modem en=%x raw=%x st=%x\n", hw->int_en.fiq_modem, hw->int_raw_status.fiq_modem, hw->int_status.fiq_modem);
129 SOC_LOGI(" fiq_mac_txrx_timer en=%x raw=%x st=%x\n", hw->int_en.fiq_mac_txrx_timer, hw->int_raw_status.fiq_mac_txrx_timer, hw->int_status.fiq_mac_txrx_timer);
130 SOC_LOGI(" fiq_mac_txrx_misc en=%x raw=%x st=%x\n", hw->int_en.fiq_mac_txrx_misc, hw->int_raw_status.fiq_mac_txrx_misc, hw->int_status.fiq_mac_txrx_misc);
131 SOC_LOGI(" fiq_mac_rx_trigger en=%x raw=%x st=%x\n", hw->int_en.fiq_mac_rx_trigger, hw->int_raw_status.fiq_mac_rx_trigger, hw->int_status.fiq_mac_rx_trigger);
132 SOC_LOGI(" fiq_mac_tx_trigger en=%x raw=%x st=%x\n", hw->int_en.fiq_mac_tx_trigger, hw->int_raw_status.fiq_mac_tx_trigger, hw->int_status.fiq_mac_tx_trigger);
133 SOC_LOGI(" fiq_mac_prot_trigger en=%x raw=%x st=%x\n", hw->int_en.fiq_mac_prot_trigger, hw->int_raw_status.fiq_mac_prot_trigger, hw->int_status.fiq_mac_prot_trigger);
134 SOC_LOGI(" fiq_mac_general en=%x raw=%x st=%x\n", hw->int_en.fiq_mac_general, hw->int_raw_status.fiq_mac_general, hw->int_status.fiq_mac_general);
135 SOC_LOGI(" fiq_mac_wakeup en=%x raw=%x st=%x\n", hw->int_en.fiq_mac_wakeup, hw->int_raw_status.fiq_mac_wakeup, hw->int_status.fiq_mac_wakeup);
136 SOC_LOGI(" reserved_4 en=%x raw=%x st=%x\n", hw->int_en.reserved_4, hw->int_raw_status.reserved_4, hw->int_status.reserved_4);
137 SOC_LOGI(" fiq_pll_unlock en=%x raw=%x st=%x\n", hw->int_en.fiq_pll_unlock, hw->int_raw_status.fiq_pll_unlock, hw->int_status.fiq_pll_unlock);
138 SOC_LOGI(" fiq_btdm en=%x raw=%x st=%x\n", hw->int_en.fiq_btdm, hw->int_raw_status.fiq_btdm, hw->int_status.fiq_btdm);
139 SOC_LOGI(" fiq_ble en=%x raw=%x st=%x\n", hw->int_en.fiq_ble, hw->int_raw_status.fiq_ble, hw->int_status.fiq_ble);
140 SOC_LOGI(" fiq_bt en=%x raw=%x st=%x\n", hw->int_en.fiq_bt, hw->int_raw_status.fiq_bt, hw->int_status.fiq_bt);
141 #if CONFIG_SOC_BK7236A
142 SOC_LOGI(" fiq_modem_rc en=%x raw=%x st=%x\n", hw->int_en.fiq_modem_rc, hw->int_raw_status.fiq_modem_rc, hw->int_status.fiq_modem_rc);
143 SOC_LOGI(" fiq_mac_hsu en=%x raw=%x st=%x\n", hw->int_en.fiq_mac_hsu, hw->int_raw_status.fiq_mac_hsu, hw->int_status.fiq_mac_hsu);
144 #endif
145
146 SOC_LOGI(" fiq=%x \n", hw->int_global_en.fiq_en);
147 SOC_LOGI(" irq=%x \n", hw->int_global_en.irq_en);
148
149 SOC_LOGI("arm wakeup en(%x)=%x\n", &hw->arm_wakeup_en, hw->arm_wakeup_en.v);
150 SOC_LOGI(" uart1=%x\n", hw->arm_wakeup_en.uart1);
151 SOC_LOGI(" uart2=%x\n", hw->arm_wakeup_en.uart2);
152 SOC_LOGI(" i2c1=%x\n", hw->arm_wakeup_en.i2c1);
153 SOC_LOGI(" irda=%x\n", hw->arm_wakeup_en.irda);
154 SOC_LOGI(" reserved_1=%x\n", hw->arm_wakeup_en.reserved_1);
155 SOC_LOGI(" i2c2=%x\n", hw->arm_wakeup_en.i2c2);
156 SOC_LOGI(" spi=%x\n", hw->arm_wakeup_en.spi);
157 SOC_LOGI(" gpio=%x\n", hw->arm_wakeup_en.gpio);
158 SOC_LOGI(" timer=%x\n", hw->arm_wakeup_en.timer);
159 SOC_LOGI(" pwm=%x\n", hw->arm_wakeup_en.pwm);
160 SOC_LOGI(" reserved_2=%x\n", hw->arm_wakeup_en.reserved_2);
161 SOC_LOGI(" saradc=%x\n", hw->arm_wakeup_en.saradc);
162 SOC_LOGI(" sdio=%x\n", hw->arm_wakeup_en.sdio);
163 SOC_LOGI(" security=%x\n", hw->arm_wakeup_en.security);
164 SOC_LOGI(" la=%x\n", hw->arm_wakeup_en.la);
165 SOC_LOGI(" general_dma=%x\n", hw->arm_wakeup_en.general_dma);
166 SOC_LOGI(" modem=%x\n", hw->arm_wakeup_en.modem);
167 SOC_LOGI(" mac_tx_rx_timer=%x\n", hw->arm_wakeup_en.mac_tx_rx_timer);
168 SOC_LOGI(" mac_tx_rx_misc=%x\n", hw->arm_wakeup_en.mac_tx_rx_misc);
169 SOC_LOGI(" mac_rx_trigger=%x\n", hw->arm_wakeup_en.mac_rx_trigger);
170 SOC_LOGI(" mac_tx_trigger=%x\n", hw->arm_wakeup_en.mac_tx_trigger);
171 SOC_LOGI(" mac_prot_trigger=%x\n", hw->arm_wakeup_en.mac_prot_trigger);
172 SOC_LOGI(" mac_general=%x\n", hw->arm_wakeup_en.mac_general);
173 SOC_LOGI(" reserved_3=%x\n", hw->arm_wakeup_en.reserved_3);
174 SOC_LOGI(" mac=%x\n", hw->arm_wakeup_en.mac);
175 SOC_LOGI(" reserved_4=%x\n", hw->arm_wakeup_en.reserved_4);
176 SOC_LOGI(" pll_unlock=%x\n", hw->arm_wakeup_en.pll_unlock);
177 SOC_LOGI(" btdm=%x\n", hw->arm_wakeup_en.btdm);
178 SOC_LOGI(" ble=%x\n", hw->arm_wakeup_en.ble);
179 SOC_LOGI(" bt=%x\n", hw->arm_wakeup_en.bt);
180 }
181
182 #endif
183