bsp:cvitek: add pinmux for pwm

Board level pin available info is summarized and list here for memo:

Duo:

NAME    PWM         CV1800B/GPIO    <PINNAME>__<FUNCNAME>
----    ---         ------------    ---------------------
PWM-1
GP9     PWM4        PWR_GPIO[18]    SD1_D3__PWM_4
GP12    PWM4        XGPIOA[16]      UART0_TX__PWM_4

GP4     PWM5        PWR_GPIO[19]    SD1_D2__PWM_5
GP13    PWM5        XGPIOA[17]      UART0_RX__PWM_5

GP5     PWM6        PWR_GPIO[20]    SD1_D1__PWM_6

GP8     PMW7        PWR_GPIO[21]    SD1_D0__PWM_7

PWM-2
GP7     PWM8        PWR_GPIO[22]    SD1_CMD__PWM_8
GP6     PWM9        PWR_GPIO[23]    SD1_CLK__PWM_9
GP2     PWM10       PWR_GPIO[26]    SD1_GPIO1__PWM_10
GP3     PWM11       PWR_GPIO[25]    SD1_GPIO0__PWM_11

Duo256:

NAME    PWM         CV1800B/GPIO    <PINNAME>__<FUNCNAME>
----    ---         ------------    ---------------------
PWM-1
GP9     PWM4        PWR_GPIO[18]    SD1_D3__PWM_4
GP12    PWM4        XGPIOA[16]      UART0_TX__PWM_4

GP4     PWM5        PWR_GPIO[19]    SD1_D2__PWM_5
GP13    PWM5        XGPIOA[17]      UART0_RX__PWM_5

GP3     PWM6        XGPIOA[18]      JTAG_CPU_TCK__PWM_6
GP5     PWM6        PWR_GPIO[20]    SD1_D1__PWM_6

GP2     PWM7        XGPIOA[19]      JTAG_CPU_TMS__PWM_7
GP8     PMW7        PWR_GPIO[21]    SD1_D0__PWM_7

PWM-2
GP7     PWM8        PWR_GPIO[22]    SD1_CMD__PWM_8
GP6     PWM9        PWR_GPIO[23]    SD1_CLK__PWM_9
GP10    PWM10       XGPIOC[14]      PAD_MIPI_TXM1__PWM_10
GP11    PWM11       XGPIOC[15]      PAD_MIPI_TXP1__PWM_11

Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
This commit is contained in:
Chen Wang 2024-05-28 17:47:48 +08:00 committed by Rbb666
parent 114e143d56
commit 51825a5b5c
3 changed files with 321 additions and 16 deletions

View File

@ -190,20 +190,80 @@ menu "General Drivers Configuration"
if BSP_USING_PWM
config BSP_USING_PWM0
bool "Enable PWM 0"
default n
bool "Enable PWM 0"
default n
if BSP_USING_PWM0
config BSP_PWM0_0_PINNAME
string "pwm[0] pin name"
default ""
config BSP_PWM0_1_PINNAME
string "pwm[1] pin name"
default ""
config BSP_PWM0_2_PINNAME
string "pwm[2] pin name"
default ""
config BSP_PWM0_3_PINNAME
string "pwm[3] pin name"
default ""
endif
config BSP_USING_PWM1
bool "Enable PWM 1"
default n
bool "Enable PWM 1"
default n
if BSP_USING_PWM1
config BSP_PWM1_4_PINNAME
string "pwm[4] pin name"
default ""
config BSP_PWM1_5_PINNAME
string "pwm[5] pin name"
default ""
config BSP_PWM1_6_PINNAME
string "pwm[6] pin name"
default ""
config BSP_PWM1_7_PINNAME
string "pwm[7] pin name"
default ""
endif
config BSP_USING_PWM2
bool "Enable PWM 2"
default n
bool "Enable PWM 2"
default n
if BSP_USING_PWM2
config BSP_PWM2_8_PINNAME
string "pwm[8] pin name"
default ""
config BSP_PWM2_9_PINNAME
string "pwm[9] pin name"
default ""
config BSP_PWM2_10_PINNAME
string "pwm[10] pin name"
default ""
config BSP_PWM2_11_PINNAME
string "pwm[11] pin name"
default ""
endif
config BSP_USING_PWM3
bool "Enable PWM 3"
default n
bool "Enable PWM 3"
default n
if BSP_USING_PWM3
config BSP_PWM3_12_PINNAME
string "pwm[12] pin name"
default ""
config BSP_PWM3_13_PINNAME
string "pwm[13] pin name"
default ""
config BSP_PWM3_14_PINNAME
string "pwm[14] pin name"
default ""
config BSP_PWM3_15_PINNAME
string "pwm[15] pin name"
default ""
endif
endif
config BSP_USING_RTC

View File

@ -190,20 +190,80 @@ menu "General Drivers Configuration"
if BSP_USING_PWM
config BSP_USING_PWM0
bool "Enable PWM 0"
default n
bool "Enable PWM 0"
default n
if BSP_USING_PWM0
config BSP_PWM0_0_PINNAME
string "pwm[0] pin name"
default ""
config BSP_PWM0_1_PINNAME
string "pwm[1] pin name"
default ""
config BSP_PWM0_2_PINNAME
string "pwm[2] pin name"
default ""
config BSP_PWM0_3_PINNAME
string "pwm[3] pin name"
default ""
endif
config BSP_USING_PWM1
bool "Enable PWM 1"
default n
bool "Enable PWM 1"
default n
if BSP_USING_PWM1
config BSP_PWM1_4_PINNAME
string "pwm[4] pin name"
default ""
config BSP_PWM1_5_PINNAME
string "pwm[5] pin name"
default ""
config BSP_PWM1_6_PINNAME
string "pwm[6] pin name"
default ""
config BSP_PWM1_7_PINNAME
string "pwm[7] pin name"
default ""
endif
config BSP_USING_PWM2
bool "Enable PWM 2"
default n
bool "Enable PWM 2"
default n
if BSP_USING_PWM2
config BSP_PWM2_8_PINNAME
string "pwm[8] pin name"
default ""
config BSP_PWM2_9_PINNAME
string "pwm[9] pin name"
default ""
config BSP_PWM2_10_PINNAME
string "pwm[10] pin name"
default ""
config BSP_PWM2_11_PINNAME
string "pwm[11] pin name"
default ""
endif
config BSP_USING_PWM3
bool "Enable PWM 3"
default n
bool "Enable PWM 3"
default n
if BSP_USING_PWM3
config BSP_PWM3_12_PINNAME
string "pwm[12] pin name"
default ""
config BSP_PWM3_13_PINNAME
string "pwm[13] pin name"
default ""
config BSP_PWM3_14_PINNAME
string "pwm[14] pin name"
default ""
config BSP_PWM3_15_PINNAME
string "pwm[15] pin name"
default ""
endif
endif
config BSP_USING_RTC

View File

@ -10,6 +10,7 @@
#include <rtthread.h>
#include <rtdevice.h>
#include "drv_pwm.h"
#include "drv_pinmux.h"
#define DBG_LEVEL DBG_LOG
#include <rtdbg.h>
@ -134,11 +135,195 @@ static struct cvi_pwm_dev cvi_pwm[] =
#endif
};
#if defined(BOARD_TYPE_MILKV_DUO) || defined(BOARD_TYPE_MILKV_DUO_SPINOR)
#ifdef BSP_USING_PWM0
static const char *pinname_whitelist_pwm0[] = {
NULL,
};
static const char *pinname_whitelist_pwm1[] = {
NULL,
};
static const char *pinname_whitelist_pwm2[] = {
NULL,
};
static const char *pinname_whitelist_pwm3[] = {
NULL,
};
#endif
#ifdef BSP_USING_PWM1
static const char *pinname_whitelist_pwm4[] = {
"SD1_D3",
"UART0_TX",
NULL,
};
static const char *pinname_whitelist_pwm5[] = {
"SD1_D2",
"UART0_RX",
NULL,
};
static const char *pinname_whitelist_pwm6[] = {
"SD1_D1",
NULL,
};
static const char *pinname_whitelist_pwm7[] = {
"SD1_D0",
NULL,
};
#endif
#ifdef BSP_USING_PWM2
static const char *pinname_whitelist_pwm8[] = {
"SD1_CMD",
NULL,
};
static const char *pinname_whitelist_pwm9[] = {
"SD1_CLK",
NULL,
};
static const char *pinname_whitelist_pwm10[] = {
"SD1_GPIO1",
NULL,
};
static const char *pinname_whitelist_pwm11[] = {
"SD1_GPIO0",
NULL,
};
#endif
#ifdef BSP_USING_PWM3
static const char *pinname_whitelist_pwm12[] = {
NULL,
};
static const char *pinname_whitelist_pwm13[] = {
NULL,
};
static const char *pinname_whitelist_pwm14[] = {
NULL,
};
static const char *pinname_whitelist_pwm15[] = {
NULL,
};
#endif
#elif defined(BOARD_TYPE_MILKV_DUO256M) || defined(BOARD_TYPE_MILKV_DUO256M_SPINOR)
#ifdef BSP_USING_PWM0
static const char *pinname_whitelist_pwm0[] = {
NULL,
};
static const char *pinname_whitelist_pwm1[] = {
NULL,
};
static const char *pinname_whitelist_pwm2[] = {
NULL,
};
static const char *pinname_whitelist_pwm3[] = {
NULL,
};
#endif
#ifdef BSP_USING_PWM1
static const char *pinname_whitelist_pwm4[] = {
"SD1_D3",
"UART0_TX",
NULL,
};
static const char *pinname_whitelist_pwm5[] = {
"SD1_D2",
"UART0_RX",
NULL,
};
static const char *pinname_whitelist_pwm6[] = {
"JTAG_CPU_TCK",
"SD1_D1",
NULL,
};
static const char *pinname_whitelist_pwm7[] = {
"JTAG_CPU_TMS",
"SD1_D0",
NULL,
};
#endif
#ifdef BSP_USING_PWM2
static const char *pinname_whitelist_pwm8[] = {
"SD1_CMD",
NULL,
};
static const char *pinname_whitelist_pwm9[] = {
"SD1_CLK",
NULL,
};
static const char *pinname_whitelist_pwm10[] = {
"PAD_MIPI_TXM1",
NULL,
};
static const char *pinname_whitelist_pwm11[] = {
"PAD_MIPI_TXP1",
NULL,
};
#endif
#ifdef BSP_USING_PWM3
static const char *pinname_whitelist_pwm12[] = {
NULL,
};
static const char *pinname_whitelist_pwm13[] = {
NULL,
};
static const char *pinname_whitelist_pwm14[] = {
NULL,
};
static const char *pinname_whitelist_pwm15[] = {
NULL,
};
#endif
#else
#error "Unsupported board type!"
#endif
static void rt_hw_pwm_pinmux_config()
{
#ifdef BSP_USING_PWM0
pinmux_config(BSP_PWM0_0_PINNAME, PWM_0, pinname_whitelist_pwm0);
pinmux_config(BSP_PWM0_1_PINNAME, PWM_1, pinname_whitelist_pwm1);
pinmux_config(BSP_PWM0_2_PINNAME, PWM_2, pinname_whitelist_pwm2);
pinmux_config(BSP_PWM0_3_PINNAME, PWM_3, pinname_whitelist_pwm3);
#endif /* BSP_USING_PWM0 */
#ifdef BSP_USING_PWM1
pinmux_config(BSP_PWM1_4_PINNAME, PWM_4, pinname_whitelist_pwm4);
pinmux_config(BSP_PWM1_5_PINNAME, PWM_5, pinname_whitelist_pwm5);
pinmux_config(BSP_PWM1_6_PINNAME, PWM_6, pinname_whitelist_pwm6);
pinmux_config(BSP_PWM1_7_PINNAME, PWM_7, pinname_whitelist_pwm7);
#endif /* BSP_USING_PWM1 */
#ifdef BSP_USING_PWM2
pinmux_config(BSP_PWM2_8_PINNAME, PWM_8, pinname_whitelist_pwm8);
pinmux_config(BSP_PWM2_9_PINNAME, PWM_9, pinname_whitelist_pwm9);
pinmux_config(BSP_PWM2_10_PINNAME, PWM_10, pinname_whitelist_pwm10);
pinmux_config(BSP_PWM2_11_PINNAME, PWM_11, pinname_whitelist_pwm11);
#endif /* BSP_USING_PWM2 */
#ifdef BSP_USING_PWM3
pinmux_config(BSP_PWM3_12_PINNAME, PWM_12, pinname_whitelist_pwm12);
pinmux_config(BSP_PWM3_13_PINNAME, PWM_13, pinname_whitelist_pwm13);
pinmux_config(BSP_PWM3_14_PINNAME, PWM_14, pinname_whitelist_pwm14);
pinmux_config(BSP_PWM3_15_PINNAME, PWM_15, pinname_whitelist_pwm15);
#endif /* BSP_USING_PWM3 */
}
int rt_hw_pwm_init(void)
{
int result = RT_EOK;
uint8_t i;
rt_hw_pwm_pinmux_config();
for (i = 0; i < sizeof(cvi_pwm) / sizeof(cvi_pwm[0]); i++)
{
result = rt_device_pwm_register(&cvi_pwm[i].device, cvi_pwm[i].name, &cvi_pwm_ops, &cvi_pwm[i]);