Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

risc-v/bl808: Add I2C driver #15332

Merged
merged 1 commit into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Documentation/platforms/risc-v/bl808/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ DMA No
EMAC No
GPADC Yes
GPIO Yes
I2C No
I2C Yes
I2S No
PWM No
SPI Yes
Expand Down
4 changes: 4 additions & 0 deletions arch/risc-v/include/bl808/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
/* D0 IRQs ******************************************************************/

#define BL808_IRQ_UART3 (RISCV_IRQ_SEXT + BL808_IRQ_NUM_BASE + 4)
#define BL808_IRQ_I2C2 (RISCV_IRQ_SEXT + BL808_IRQ_NUM_BASE + 5)
#define BL808_IRQ_I2C3 (RISCV_IRQ_SEXT + BL808_IRQ_NUM_BASE + 6)
#define BL808_IRQ_SPI1 (RISCV_IRQ_SEXT + BL808_IRQ_NUM_BASE + 7)
#define BL808_IRQ_D0_IPC (RISCV_IRQ_SEXT + BL808_IRQ_NUM_BASE + 38)
#define BL808_IRQ_TIMER1_CH0 (RISCV_IRQ_SEXT + BL808_IRQ_NUM_BASE + 61)
Expand All @@ -68,8 +70,10 @@
#define BL808_IRQ_UART0 (RISCV_IRQ_SEXT + BL808_IRQ_NUM_BASE + BL808_M0_IRQ_OFFSET + 28)
#define BL808_IRQ_UART1 (RISCV_IRQ_SEXT + BL808_IRQ_NUM_BASE + BL808_M0_IRQ_OFFSET + 29)
#define BL808_IRQ_UART2 (RISCV_IRQ_SEXT + BL808_IRQ_NUM_BASE + BL808_M0_IRQ_OFFSET + 30)
#define BL808_IRQ_I2C0 (RISCV_IRQ_SEXT + BL808_IRQ_NUM_BASE + BL808_M0_IRQ_OFFSET + 32)
#define BL808_IRQ_TIMER0_CH0 (RISCV_IRQ_SEXT + BL808_IRQ_NUM_BASE + BL808_M0_IRQ_OFFSET + 36)
#define BL808_IRQ_TIMER0_CH1 (RISCV_IRQ_SEXT + BL808_IRQ_NUM_BASE + BL808_M0_IRQ_OFFSET + 37)
#define BL808_IRQ_WDT0 (RISCV_IRQ_SEXT + BL808_IRQ_NUM_BASE + BL808_M0_IRQ_OFFSET + 38)
#define BL808_IRQ_I2C1 (RISCV_IRQ_SEXT + BL808_IRQ_NUM_BASE + BL808_M0_IRQ_OFFSET + 39)

#endif /* __ARCH_RISCV_INCLUDE_BL808_IRQ_H */
92 changes: 92 additions & 0 deletions arch/risc-v/src/bl808/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,98 @@ config BL808_GPADC_SCAN_ORD11

endmenu

menuconfig BL808_I2C0
bool "I2C 0"
default n
select I2C
select I2C_DRIVER
select ARCH_HAVE_I2CRESET

if BL808_I2C0

comment "Refer to datasheet for valid pin assignments"

config BL808_I2C0_SCL
int "SCL Pin"
default 6
range 0 45

config BL808_I2C0_SDA
int "SDA Pin"
default 7
range 0 45

endif

menuconfig BL808_I2C1
bool "I2C 1"
default n
select I2C
select I2C_DRIVER
select ARCH_HAVE_I2CRESET

if BL808_I2C1

comment "Refer to datasheet for valid pin assignments"

config BL808_I2C1_SCL
int "SCL Pin"
default 6
range 0 45

config BL808_I2C1_SDA
int "SDA Pin"
default 7
range 0 45

endif

menuconfig BL808_I2C2
bool "I2C 2"
default n
select I2C
select I2C_DRIVER
select ARCH_HAVE_I2CRESET

if BL808_I2C2

comment "Refer to datasheet for valid pin assignments"

config BL808_I2C2_SCL
int "SCL Pin"
default 6
range 0 45

config BL808_I2C2_SDA
int "SDA Pin"
default 7
range 0 45

endif

menuconfig BL808_I2C3
bool "I2C 3"
default n
select I2C
select I2C_DRIVER
select ARCH_HAVE_I2CRESET

if BL808_I2C3

comment "Refer to datasheet for valid pin assignments"

config BL808_I2C3_SCL
int "SCL Pin"
default 6
range 0 45

config BL808_I2C3_SDA
int "SDA Pin"
default 7
range 0 45

endif

config BL808_UART0
bool "UART 0"
default n
Expand Down
1 change: 1 addition & 0 deletions arch/risc-v/src/bl808/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ CHIP_CSRCS = bl808_start.c bl808_irq_dispatch.c bl808_irq.c
CHIP_CSRCS += bl808_timerisr.c bl808_allocateheap.c
CHIP_CSRCS += bl808_gpio.c bl808_mm_init.c bl808_pgalloc.c bl808_serial.c
CHIP_CSRCS += bl808_gpadc.c bl808_spi.c bl808_timer.c bl808_wdt.c
CHIP_CSRCS += bl808_i2c.c
7 changes: 5 additions & 2 deletions arch/risc-v/src/bl808/bl808_gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@

#define GPIO_MODE_SHIFT (10) /* Bit 10: Port Mode */
#define GPIO_MODE_MASK (1 << GPIO_MODE_SHIFT)
# define GPIO_INPUT (1 << GPIO_MODE_SHIFT) /* Input Enable */
# define GPIO_OUTPUT (0 << GPIO_MODE_SHIFT) /* Output Enable */
#define GPIO_INPUT (1 << GPIO_MODE_SHIFT) /* Input Enable */
#define GPIO_OUTPUT (0 << GPIO_MODE_SHIFT) /* Output Enable */

/* Input/Output pull-ups/downs:
*
Expand Down Expand Up @@ -116,13 +116,16 @@
#define GPIO_FUNC_SDH (0 << GPIO_FUNC_SHIFT) /* SDH */
#define GPIO_FUNC_SPI0 (1 << GPIO_FUNC_SHIFT) /* SPI0 */
#define GPIO_FUNC_FLASH (2 << GPIO_FUNC_SHIFT) /* Flash */
#define GPIO_FUNC_I2C0 (5 << GPIO_FUNC_SHIFT) /* I2C0 */
#define GPIO_FUNC_I2C1 (6 << GPIO_FUNC_SHIFT) /* I2C1 */
#define GPIO_FUNC_UART (7 << GPIO_FUNC_SHIFT) /* UART */
#define GPIO_FUNC_CAM (9 << GPIO_FUNC_SHIFT) /* CSI */
#define GPIO_FUNC_ANA (10 << GPIO_FUNC_SHIFT) /* Analog */
#define GPIO_FUNC_SWGPIO (11 << GPIO_FUNC_SHIFT) /* Software GPIO */
#define GPIO_FUNC_PWM0 (16 << GPIO_FUNC_SHIFT) /* PWM0 */
#define GPIO_FUNC_SPI1 (18 << GPIO_FUNC_SHIFT) /* SPI1 */
#define GPIO_FUNC_I2C2 (19 << GPIO_FUNC_SHIFT) /* I2C2 */
#define GPIO_FUNC_I2C3 (20 << GPIO_FUNC_SHIFT) /* I2C3 */
#define GPIO_FUNC_JTAG_D0 (27 << GPIO_FUNC_SHIFT) /* JTAG */

/****************************************************************************
Expand Down
Loading
Loading