bsp:cvitek: add pinmux for i2c
Based on new pinmux framework, add configuration for uart. Board level pin available info is summarized and should be controlled by pin whitelist. Duo NAME I2C CV1800B/GPIO <PINNAME>__<FUNCNAME> ---- --- ------------ --------------------- GP0 I2C0_SCL XGPIOA[28] IIC0_SCL__IIC0_SCL GP1 I2C0_SDA XGPIOA[29] IIC0_SDA__IIC0_SDA GP4 I2C1_SCL PWR_GPIO[19] SD1_D2__IIC1_SCL GP9 I2C1_SCL PWR_GPIO[18] SD1_D3__IIC1_SCL GP11 I2C1_SCL XGPIOC[10] PAD_MIPIRX0N__IIC1_SCL GP5 I2C1_SDA PWR_GPIO[20] SD1_D1__IIC1_SDA GP8 I2C1_SDA PWR_GPIO[21] SD1_D0__IIC1_SDA GP10 I2C1_SDA XGPIOC[9] PAD_MIPIRX1P__IIC1_SDA GP7 I2C3_SCL PWR_GPIO[22] SD1_CMD__IIC3_SCL GP6 I2C3_SDA PWR_GPIO[23] SD1_CLK__IIC3_SDA Duo256m NAME I2C CV1800B/GPIO <PINNAME>__<FUNCNAME> ---- --- ------------ --------------------- GP4 I2C1_SCL PWR_GPIO[19] SD1_D2__IIC1_SCL GP9 I2C1_SCL PWR_GPIO[18] SD1_D3__IIC1_SCL GP5 I2C1_SDA PWR_GPIO[20] SD1_D1__IIC1_SDA GP8 I2C1_SDA PWR_GPIO[21] SD1_D0__IIC1_SDA GP11 I2C2_SCL XGPIOC[15] PAD_MIPI_TXP1__IIC2_SCL GP10 I2C2_SDA XGPIOC[14] PAD_MIPI_TXM1__IIC2_SDA GP7 I2C3_SCL PWR_GPIO[22] SD1_CMD__IIC3_SCL GP6 I2C3_SDA PWR_GPIO[23] SD1_CLK__IIC3_SDA Duo S(Note, we have not supported duo S, just list for memo) NAME I2C CV1800B/GPIO <PINNAME>__<FUNCNAME> ---- --- ------------ --------------------- J3-B18 I2C1_SCL XGPIOB[18] VIVO_D3__IIC1_SCL J3-B12 I2C1_SCL XGPIOB[12] VIVO_D9__IIC1_SCL J3-B11 I2C1_SDA XGPIOB[11] VIVO_D10__IIC1_SDA J3-B13 I2C2_SCL XGPIOB[13] VIVO_D8__IIC2_SCL J4-E1 I2C2_SCL PWR_GPIO[1] PWR_GPIO1__IIC2_SCL J3-B14 I2C2_SDA XGPIOB[14] VIVO_D7__IIC2_SDA J4-E2 I2C2_SDA PWR_GPIO[2] PWR_GPIO2__IIC2_SDA J3-B20 I2C4_SCL XGPIOB[20] VIVO_D1__IIC4_SCL J4-B1 I2C4_SCL XGPIOB[1] ADC3__IIC4_SCL J3-B21 I2C4_SDA XGPIOB[21] VIVO_D0__IIC4_SDA J4-B2 I2C4_SDA XGPIOB[2] ADC2__IIC4_SDA Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
This commit is contained in:
parent
23fc7bfa4d
commit
e1eb3d3217
|
@ -31,10 +31,67 @@ menu "General Drivers Configuration"
|
|||
bool "Enable I2C0"
|
||||
default n
|
||||
|
||||
if BSP_USING_I2C0
|
||||
config BSP_I2C0_SCL_PINNAME
|
||||
string "i2c0 scl pin name"
|
||||
default ""
|
||||
config BSP_I2C0_SDA_PINNAME
|
||||
string "i2c0 sda pin name"
|
||||
default ""
|
||||
endif
|
||||
|
||||
config BSP_USING_I2C1
|
||||
bool "Enable I2C1"
|
||||
default n
|
||||
|
||||
if BSP_USING_I2C1
|
||||
config BSP_I2C1_SCL_PINNAME
|
||||
string "i2c1 scl pin name"
|
||||
default ""
|
||||
config BSP_I2C1_SDA_PINNAME
|
||||
string "i2c1 sda pin name"
|
||||
default ""
|
||||
endif
|
||||
|
||||
config BSP_USING_I2C2
|
||||
bool "Enable I2C2"
|
||||
default n
|
||||
|
||||
if BSP_USING_I2C2
|
||||
config BSP_I2C2_SCL_PINNAME
|
||||
string "i2c2 scl pin name"
|
||||
default ""
|
||||
config BSP_I2C2_SDA_PINNAME
|
||||
string "i2c2 sda pin name"
|
||||
default ""
|
||||
endif
|
||||
|
||||
config BSP_USING_I2C3
|
||||
bool "Enable I2C3"
|
||||
default n
|
||||
|
||||
if BSP_USING_I2C3
|
||||
config BSP_I2C3_SCL_PINNAME
|
||||
string "i2c3 scl pin name"
|
||||
default ""
|
||||
config BSP_I2C3_SDA_PINNAME
|
||||
string "i2c3 sda pin name"
|
||||
default ""
|
||||
endif
|
||||
|
||||
config BSP_USING_I2C4
|
||||
bool "Enable I2C4"
|
||||
default n
|
||||
|
||||
if BSP_USING_I2C4
|
||||
config BSP_I2C4_SCL_PINNAME
|
||||
string "i2c4 scl pin name"
|
||||
default ""
|
||||
config BSP_I2C4_SDA_PINNAME
|
||||
string "i2c4 sda pin name"
|
||||
default ""
|
||||
endif
|
||||
|
||||
config I2C_IRQ_BASE
|
||||
int
|
||||
default 32
|
||||
|
|
|
@ -44,10 +44,67 @@ menu "General Drivers Configuration"
|
|||
bool "Enable I2C0"
|
||||
default n
|
||||
|
||||
if BSP_USING_I2C0
|
||||
config BSP_I2C0_SCL_PINNAME
|
||||
string "i2c0 scl pin name"
|
||||
default ""
|
||||
config BSP_I2C0_SDA_PINNAME
|
||||
string "i2c0 sda pin name"
|
||||
default ""
|
||||
endif
|
||||
|
||||
config BSP_USING_I2C1
|
||||
bool "Enable I2C1"
|
||||
default n
|
||||
|
||||
if BSP_USING_I2C1
|
||||
config BSP_I2C1_SCL_PINNAME
|
||||
string "i2c1 scl pin name"
|
||||
default ""
|
||||
config BSP_I2C1_SDA_PINNAME
|
||||
string "i2c1 sda pin name"
|
||||
default ""
|
||||
endif
|
||||
|
||||
config BSP_USING_I2C2
|
||||
bool "Enable I2C2"
|
||||
default n
|
||||
|
||||
if BSP_USING_I2C2
|
||||
config BSP_I2C2_SCL_PINNAME
|
||||
string "i2c2 scl pin name"
|
||||
default ""
|
||||
config BSP_I2C2_SDA_PINNAME
|
||||
string "i2c2 sda pin name"
|
||||
default ""
|
||||
endif
|
||||
|
||||
config BSP_USING_I2C3
|
||||
bool "Enable I2C3"
|
||||
default n
|
||||
|
||||
if BSP_USING_I2C3
|
||||
config BSP_I2C3_SCL_PINNAME
|
||||
string "i2c3 scl pin name"
|
||||
default ""
|
||||
config BSP_I2C3_SDA_PINNAME
|
||||
string "i2c3 sda pin name"
|
||||
default ""
|
||||
endif
|
||||
|
||||
config BSP_USING_I2C4
|
||||
bool "Enable I2C4"
|
||||
default n
|
||||
|
||||
if BSP_USING_I2C4
|
||||
config BSP_I2C4_SCL_PINNAME
|
||||
string "i2c4 scl pin name"
|
||||
default ""
|
||||
config BSP_I2C4_SDA_PINNAME
|
||||
string "i2c4 sda pin name"
|
||||
default ""
|
||||
endif
|
||||
|
||||
config I2C_IRQ_BASE
|
||||
int
|
||||
default 49
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "drv_hw_i2c.h"
|
||||
#include <rtdevice.h>
|
||||
#include <board.h>
|
||||
#include "drv_pinmux.h"
|
||||
|
||||
#define DBG_TAG "drv.i2c"
|
||||
#define DBG_LVL DBG_INFO
|
||||
|
@ -467,19 +468,160 @@ static const struct rt_i2c_bus_device_ops i2c_ops =
|
|||
.i2c_bus_control = RT_NULL
|
||||
};
|
||||
|
||||
|
||||
#if defined(BOARD_TYPE_MILKV_DUO) || defined(BOARD_TYPE_MILKV_DUO_SPINOR)
|
||||
|
||||
#ifdef BSP_USING_I2C0
|
||||
static const char *pinname_whitelist_i2c0_scl[] = {
|
||||
"IIC0_SCL",
|
||||
NULL,
|
||||
};
|
||||
static const char *pinname_whitelist_i2c0_sda[] = {
|
||||
"IIC0_SDA",
|
||||
NULL,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BSP_USING_I2C1
|
||||
static const char *pinname_whitelist_i2c1_scl[] = {
|
||||
"SD1_D2",
|
||||
"SD1_D3",
|
||||
"PAD_MIPIRX0N",
|
||||
NULL,
|
||||
};
|
||||
static const char *pinname_whitelist_i2c1_sda[] = {
|
||||
"SD1_D1",
|
||||
"SD1_D0",
|
||||
"PAD_MIPIRX1P",
|
||||
NULL,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BSP_USING_I2C2
|
||||
// I2C2 is not ALLOWED for Duo
|
||||
static const char *pinname_whitelist_i2c2_scl[] = {
|
||||
NULL,
|
||||
};
|
||||
static const char *pinname_whitelist_i2c2_sda[] = {
|
||||
NULL,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BSP_USING_I2C3
|
||||
static const char *pinname_whitelist_i2c3_scl[] = {
|
||||
"SD1_CMD",
|
||||
NULL,
|
||||
};
|
||||
static const char *pinname_whitelist_i2c3_sda[] = {
|
||||
"SD1_CLK",
|
||||
NULL,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BSP_USING_I2C4
|
||||
// I2C4 is not ALLOWED for Duo
|
||||
static const char *pinname_whitelist_i2c4_scl[] = {
|
||||
NULL,
|
||||
};
|
||||
static const char *pinname_whitelist_i2c4_sda[] = {
|
||||
NULL,
|
||||
};
|
||||
#endif
|
||||
|
||||
#elif defined(BOARD_TYPE_MILKV_DUO256M) || defined(BOARD_TYPE_MILKV_DUO256M_SPINOR)
|
||||
|
||||
#ifdef BSP_USING_I2C0
|
||||
// I2C0 is not ALLOWED for Duo
|
||||
static const char *pinname_whitelist_i2c0_scl[] = {
|
||||
NULL,
|
||||
};
|
||||
static const char *pinname_whitelist_i2c0_sda[] = {
|
||||
NULL,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BSP_USING_I2C1
|
||||
static const char *pinname_whitelist_i2c1_scl[] = {
|
||||
"SD1_D2",
|
||||
"SD1_D3",
|
||||
NULL,
|
||||
};
|
||||
static const char *pinname_whitelist_i2c1_sda[] = {
|
||||
"SD1_D1",
|
||||
"SD1_D0",
|
||||
NULL,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BSP_USING_I2C2
|
||||
static const char *pinname_whitelist_i2c2_scl[] = {
|
||||
"PAD_MIPI_TXP1",
|
||||
NULL,
|
||||
};
|
||||
static const char *pinname_whitelist_i2c2_sda[] = {
|
||||
"PAD_MIPI_TXM1",
|
||||
NULL,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BSP_USING_I2C3
|
||||
static const char *pinname_whitelist_i2c3_scl[] = {
|
||||
"SD1_CMD",
|
||||
NULL,
|
||||
};
|
||||
static const char *pinname_whitelist_i2c3_sda[] = {
|
||||
"SD1_CLK",
|
||||
NULL,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BSP_USING_I2C4
|
||||
// I2C4 is not ALLOWED for Duo
|
||||
static const char *pinname_whitelist_i2c4_scl[] = {
|
||||
NULL,
|
||||
};
|
||||
static const char *pinname_whitelist_i2c4_sda[] = {
|
||||
NULL,
|
||||
};
|
||||
#endif
|
||||
|
||||
#else
|
||||
#error "Unsupported board type!"
|
||||
#endif
|
||||
|
||||
static void rt_hw_i2c_pinmux_config()
|
||||
{
|
||||
#ifdef BSP_USING_I2C0
|
||||
pinmux_config(BSP_I2C0_SCL_PINNAME, IIC0_SCL, pinname_whitelist_i2c0_scl);
|
||||
pinmux_config(BSP_I2C0_SDA_PINNAME, IIC0_SDA, pinname_whitelist_i2c0_sda);
|
||||
#endif /* BSP_USING_I2C0 */
|
||||
|
||||
#ifdef BSP_USING_I2C1
|
||||
pinmux_config(BSP_I2C1_SCL_PINNAME, IIC1_SCL, pinname_whitelist_i2c1_scl);
|
||||
pinmux_config(BSP_I2C1_SDA_PINNAME, IIC1_SDA, pinname_whitelist_i2c1_sda);
|
||||
#endif /* BSP_USING_I2C1 */
|
||||
|
||||
#ifdef BSP_USING_I2C2
|
||||
pinmux_config(BSP_I2C2_SCL_PINNAME, IIC2_SCL, pinname_whitelist_i2c2_scl);
|
||||
pinmux_config(BSP_I2C2_SDA_PINNAME, IIC2_SDA, pinname_whitelist_i2c2_sda);
|
||||
#endif /* BSP_USING_I2C2 */
|
||||
|
||||
#ifdef BSP_USING_I2C3
|
||||
pinmux_config(BSP_I2C3_SCL_PINNAME, IIC3_SCL, pinname_whitelist_i2c3_scl);
|
||||
pinmux_config(BSP_I2C3_SDA_PINNAME, IIC3_SDA, pinname_whitelist_i2c3_sda);
|
||||
#endif /* BSP_USING_I2C3 */
|
||||
|
||||
#ifdef BSP_USING_I2C4
|
||||
pinmux_config(BSP_I2C4_SCL_PINNAME, IIC4_SCL, pinname_whitelist_i2c4_scl);
|
||||
pinmux_config(BSP_I2C4_SDA_PINNAME, IIC4_SDA, pinname_whitelist_i2c4_sda);
|
||||
#endif /* BSP_USING_I2C4 */
|
||||
}
|
||||
|
||||
int rt_hw_i2c_init(void)
|
||||
{
|
||||
int result = RT_EOK;
|
||||
|
||||
#ifdef BSP_USING_I2C0
|
||||
PINMUX_CONFIG(IIC0_SCL, IIC0_SCL);
|
||||
PINMUX_CONFIG(IIC0_SDA, IIC0_SDA);
|
||||
#endif /* BSP_USING_I2C0 */
|
||||
|
||||
#ifdef BSP_USING_I2C1
|
||||
PINMUX_CONFIG(PAD_MIPIRX1P, IIC1_SDA);
|
||||
PINMUX_CONFIG(PAD_MIPIRX0N, IIC1_SCL);
|
||||
#endif /* BSP_USING_I2C1 */
|
||||
rt_hw_i2c_pinmux_config();
|
||||
|
||||
for (rt_size_t i = 0; i < sizeof(_i2c_obj) / sizeof(struct _i2c_bus); i++)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue