rt-thread/bsp/allwinner/libraries/sunxi-hal/hal/test/ccmu/test_ccmu.c

268 lines
15 KiB
C

#include <hal_log.h>
#include <hal_cmd.h>
#include <hal_clk.h>
struct st_test_clk
{
hal_clk_id_t id;
char *name;
};
struct st_test_clk ccmu_test_table[] =
{
{ HAL_CLK_SRC_ROOT, "HAL_CLK_SRC_ROOT"},
{ HAL_CLK_SRC_HOSC24M, "HAL_CLK_SRC_HOSC24M"},
{ HAL_CLK_SRC_HOSC24MD2, "HAL_CLK_SRC_HOSC24MD2"},
{ HAL_CLK_SRC_IOSC16M, "HAL_CLK_SRC_IOSC16M"},
{ HAL_CLK_SRC_OSC48M, "HAL_CLK_SRC_OSC48M"},
{ HAL_CLK_SRC_OSC48MD4, "HAL_CLK_SRC_OSC48MD4"},
{ HAL_CLK_SRC_LOSC, "HAL_CLK_SRC_LOSC"},
{ HAL_CLK_SRC_RC16M, "HAL_CLK_SRC_RC16M"},
{ HAL_CLK_PLL_PERI0DIV25M, "HAL_CLK_PLL_PERI0DIV25M"},
{ HAL_CLK_PLL_PERI0X2, "HAL_CLK_PLL_PERI0X2 "},
{ HAL_CLK_PLL_PERI1X2, "HAL_CLK_PLL_PERI1X2"},
{ HAL_CLK_PLL_AUDIOX2, "HAL_CLK_PLL_AUDIOX2"},
{ HAL_CLK_PLL_AUDIOX4, "HAL_CLK_PLL_AUDIOX4"},
{ HAL_CLK_PLL_VIDEOX4, "HAL_CLK_PLL_VIDEOX4"},
{ HAL_CLK_PLL_DDRDIV4, "HAL_CLK_PLL_DDRDIV4"},
{ HAL_CLK_PLL_CPUX_C0, "HAL_CLK_PLL_CPUX_C0 "},
{ HAL_CLK_PLL_CPUX_C1, "HAL_CLK_PLL_CPUX_C1"},
{ HAL_CLK_PLL_DDR0, "HAL_CLK_PLL_DDR0"},
{ HAL_CLK_PLL_DDR1, "HAL_CLK_PLL_DDR1"},
{ HAL_CLK_PLL_32K, "HAL_CLK_PLL_32K"},
{ HAL_CLK_PLL_PERI0, "H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MMC1_BUS, "HAL_CLK_PERIPH_SDMMC1_BUS"},
{ HAL_CLK_PERIPH_SMHC3, "HAL_CLK_PERIPH_SMHC3"},
{ HAL_CLK_PERIPH_SMHC4, "HAL_CLK_PERIPH_SMHC4"},
{ HAL_CLK_PERIPH_SMHC5, "HAL_CLK_PERIPH_SMHC5"},
{ HAL_CLK_PERIPH_UART0, "HAL_CLK_PERIPH_UART0"},
{ HAL_CLK_PERIPH_UART1, "HAL_CLK_PERIPH_UART1"},
{ HAL_CLK_PERIPH_UART2, "HAL_CLK_PERIPH_UART2"},
{ HAL_CLK_PERIPH_UART3, "HAL_CLK_PERIPH_UART3"},
{ HAL_CLK_PERIPH_UART4, "HAL_CLK_PERIPH_UART4"},
{ HAL_CLK_PERIPH_UART5, "HAL_CLK_PERIPH_UART5"},
{ HAL_CLK_PERIPH_UART6, "HAL_CLK_PERIPH_UART6"},
{ HAL_CLK_PERIPH_UART7, "HAL_CLK_PERIPH_UART7"},
{ HAL_CLK_PERIPH_TWI0, "HAL_CLK_PERIPH_TWI0"},
{ HAL_CLK_PERIPH_TWI1, "HAL_CLK_PERIPH_TWI1"},
{ HAL_CLK_PERIPH_TWI2, "HAL_CLK_PERIPH_TWI2"},
{ HAL_CLK_PERIPH_TWI3, "HAL_CLK_PERIPH_TWI3"},
{ HAL_CLK_PERIPH_TWI4, "HAL_CLK_PERIPH_TWI4"},
{ HAL_CLK_PERIPH_CAN0, "HAL_CLK_PERIPH_CAN0"},
{ HAL_CLK_PERIPH_CAN1, "HAL_CLK_PERIPH_CAN1"},
{ HAL_CLK_PERIPH_CAN2, "HAL_CLK_PERIPH_CAN2"},
{ HAL_CLK_PERIPH_SCR0, "HAL_CLK_PERIPH_SCR0"},
{ HAL_CLK_PERIPH_SCR1, "HAL_CLK_PERIPH_SCR1"},
{ HAL_CLK_PERIPH_SCR2, "HAL_CLK_PERIPH_SCR2"},
{ HAL_CLK_PERIPH_SCR3, "HAL_CLK_PERIPH_SCR3"},
{ HAL_CL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PERIPH_I2S1, "HAL_CLK_PERIPH_I2S1"},
{ HAL_CLK_PERIPH_I2S2, "HAL_CLK_PERIPH_I2S2"},
{ HAL_CLK_PERIPH_SPDIF, "HAL_CLK_PERIPH_SPDIF"},
{ HAL_CLK_PERIPH_DSD, "HAL_CLK_PERIPH_DSD"},
{ HAL_CLK_PERIPH_DMIC, "HAL_CLK_PERIPH_DMIC"},
{ HAL_CLK_PERIPH_AUDIOCODEC_1X, "HAL_CLK_PERIPH_AUDIOCODEC_1X"},
{ HAL_CLK_PERIPH_AUDIOCODEC_4X, "HAL_CLK_PERIPH_AUDIOCODEC_4X"},
{ HAL_CLK_PERIPH_WLAN, "HAL_CLK_PERIPH_WLAN"},
{ HAL_CLK_PERIPH_USB0, "HAL_CLK_PERIPH_USB0"},
{ HAL_CLK_PERIPH_USB1, "HAL_CLK_PERIPH_USB1"},
{ HAL_CLK_PERIPH_USB2, "HAL_CLK_PERIPH_USB2"},
{ HAL_CLK_PERIPH_USB3, "HAL_CLK_PERIPH_USB3"},
{ HAL_CLK_PERIPH_USBOHCI0, "HAL_CLK_PERIPH_USBOHCI0"},
{ HAL_CLK_PERIPH_USBOHCI0_12M, "HAL_CLK_PERIPH_USBOHCI0_12M"},
{ HAL_CLK_PERIPH_USBOHCI1, "HAL_CLK_PERIPH_USBOHCI1"},
{ HAL_CLK_PERIPH_USBOHCI1_12M, "HAL_CLK_PERIPH_USBOHCI1_12M"},
{ HAL_CLK_PERIPH_USBEHCI0, "HAL_CLK_PERIPH_USBEHCI0"},
{ HAL_CLK_PERIPH_USBEHCI1, "HAL_CLK_PERIPH_USBEHCI1"},
{ HAL_CLK_PERIPH_USBOTG, "HAL_CLK_PERIPH_USBOTG"},
{ HAL_CLK_PERIPH_HDMI0, "HAL_CLK_PERIPH_HDMI0"},
{ HAL_CLK_PERIPH_HDMI1, "HAL_CLK_PERIPH_HDMI1"},
{ HAL_CLK_PERIPH_HDMI2, "HAL_CLK_PERIPH_HDMI2"},
{ HAL_CLK_PERIPH_HDMI3, "HAL_CLK_PERIPH_HDMI3"},
{ HAL_CLK_PERIPH_MIPI_DSI0, "HAL_CLK_PERIPH_MIPI_DSI0"},
{ HAL_CLK_PERIPH_MIPI_DPHY0, "HAL_CLK_PERIPH_MIPI_DPHY0"},
{ HAL_CLK_PERIPH_MIPI_HOST0, "HAL_CLK_PERIPH_MIPI_HOST0"},
{ HAL_CLK_PERIPH_MIPI_DSI1, "HAL_CLK_PERIPH_MIPI_DSI1"},
{ HAL_CLK_PERIPH_MIPI_HOST1, "HAL_CLK_PERIPH_MIPI_HOST1"},
{ HAL_CLK_PERIPH_MIPI_DSI2, "HAL_CLK_PERIPH_MIPI_DSI2"},
{ HAL_CLK_PERIPH_MIPI_HOST2, "HAL_CLK_PERIPH_MIPI_HOST2"},
{ HAL_CLK_PERIPH_MIPI_DSI3, "HAL_CLK_PERIPH_MIPI_DSI3"},
{ HAL_CLK_PERIPH_MIPI_HOST3, "HAL_CLK_PERIPH_MIPI_HOST3"},
{ HAL_CLK_PERIPH_MIPI_DSC, "HAL_CLK_PERIPH_MIPI_DSC"},
{ HAL_CLK_PERIPH_DISPLAY_TOP, "HAL_CLK_PERIPH_DISPLAY_TOP"},
{ HAL_CLK_PERIPH_TCON_LCD0, "HAL_CLK_PERIPH_TCON_LCD0"},
{ HAL_CLK_PERIPH_TCON_LCD1, "HAL_CLK_PERIPH_TCON_LCD1"},
{ HAL_CLK_PERIPH_TCON_LCD2, "HAL_CLK_PERIPH_TCON_LCD2"},
{ HAL_CLK_PERIPH_TCON_LCD3, "HAL_CLK_PERIPH_TCON_LCD3"},
{ HAL_CLK_PERIPH_TCON_TV0, "HAL_CLK_PERIPH_TCON_TV0"},
{ HAL_CLK_PERIPH_TCON_TV1, "HAL_CLK_PERIPH_TCON_TV1"},
{ HAL_CLK_PERIPH_TCON_TV2, "HAL_CLK_PERIPH_TCON_TV2"},
{ HAL_CLK_PERIPH_TCON_TV3, "HAL_CLK_PERIPH_TCON_TV3"},
{ HAL_CLK_PERIPH_TVE0, "HAL_CLK_PERIPH_TVE0"},
{ HAL_CLK_PERIPH_TVE1, "HAL_CLK_PERIPH_TVE1"},
{ HAL_CLK_PERIPH_LVDS, "HAL_CLK_PERIPH_LVDS"},
{ HAL_CLK_PERIPH_TVD0, "HAL_CLK_PERIPH_TVD0"},
{ HAL_CLK_PERIPH_TVD1, "HAL_CLK_PERIPH_TVD1"},
{ HAL_CLK_PERIPH_TVD2, "HAL_CLK_PERIPH_TVD2"},
{ HAL_CLK_PERIPH_TVD3, "HAL_CLK_PERIPH_TVD3"},
{ HAL_CLK_PERIPH_TVD4, "HAL_CLK_PERIPH_TVD4"},
{ HAL_CLK_PERIPH_TVD5, "HAL_CLK_PERIPH_TVD5"},
{ HAL_CLK_PERIPH_EDP, "HAL_CLK_PERIPH_EDP"},
{ HAL_CLK_PERIPH_CSI0, "HAL_CLK_PERIPH_CSI0"},
{ HAL_CLK_PERIPH_CSI1, "HAL_CLK_PERIPH_CSI1"},
{ HAL_CLK_PERIPH_MIPI_CSI, "HAL_CLK_PERIPH_MIPI_CSI"},
{ HAL_CLK_PERIPH_SUB_LVDS, "HAL_CLK_PERIPH_SUB_LVDS"},
{ HAL_CLK_PERIPH_HISP, "HAL_CLK_PERIPH_HISP"},
{ HAL_CLK_PERIPH_CSI_TOP, "HAL_CLK_PERIPH_CSI_TOP"},
{ HAL_CLK_PERIPH_CSI_MASTER0, "HAL_CLK_PERIPH_CSI_MASTER0"},
{ HAL_CLK_PERIPH_CSI_MASTER1, "HAL_CLK_PERIPH_CSI_MASTER1"},
{ HAL_CLK_PERIPH_ISP, "HAL_CLK_PERIPH_ISP"},
{ HAL_CLK_PERIPH_DSPO, "HAL_CLK_PERIPH_DSPO"},
};
#define ccmuapi_test(_func, _id, _name, _result) \
do { \
_result = _func(_id); \
hal_log_info("Test(%04d): func is %s,result is %d\n", \
_id, #_func, _result); \
} while(0)
int cmd_test_ccmu(int argc, char **argv)
{
char *tname = NULL;
hal_clk_id_t tid = HAL_CLK_UNINITIALIZED;
unsigned int tsize = sizeof(ccmu_test_table) / sizeof(ccmu_test_table[0]);
hal_clk_id_t id = HAL_CLK_UNINITIALIZED;
unsigned int rate = 0;
hal_clk_status_t status = HAL_CLK_STATUS_INVALID_PARAMETER;
for (int i = 0; i < tsize; i++)
{
tid = ccmu_test_table[i].id;
tname = ccmu_test_table[i].name;
hal_log_info("------------------------------------\n" \
"CLK id: %d, \tname: %s\n", tid, tname);
/* testing get parent API */
ccmuapi_test(hal_clk_get_parent, tid, tname, id);
/* testing recalc rate API */
ccmuapi_test(hal_clk_recalc_rate, tid, tname, rate);
/* testing get rate API */
ccmuapi_test(hal_clk_get_rate, tid, tname, rate);
/* testing is enabled API */
ccmuapi_test(hal_clock_is_enabled, tid, tname, status);
}
/* TODO: add more APIs to test */
hal_log_info("===================================\n");
hal_log_info("Test Finished. total number: %d.\n", tsize);
return 0;
}
FINSH_FUNCTION_EXPORT_CMD(cmd_test_ccmu, hal_ccmu, ccmu hal APIs tests)