[update] update flash and usb_v2 driver for bl616

This commit is contained in:
jzlv 2023-08-11 14:50:57 +08:00
parent 7a6e8b07bc
commit 58c1f0eab2
4 changed files with 72 additions and 16 deletions

View File

@ -691,4 +691,4 @@ void bflb_adc_vbat_disable(struct bflb_device_s *dev)
regval = getreg32(reg_base + AON_GPADC_REG_CONFIG2_OFFSET);
regval &= ~AON_GPADC_VBAT_EN;
putreg32(regval, reg_base + AON_GPADC_REG_CONFIG2_OFFSET);
}
}

View File

@ -506,8 +506,15 @@ int ATTR_TCM_SECTION bflb_flash_init(void)
if (ret == 0) {
g_jedec_id = jedec_id;
flash_get_clock_delay(&g_flash_cfg);
#if defined(BL616) || defined(BL628)
flash1_size = flash_get_size_from_jedecid(g_jedec_id);
#endif
#ifdef BFLB_SF_CTRL_SBUS2_ENABLE
flash2_init();
#else
#if defined(BL616) || defined(BL628)
flash2_size = 0;
#endif
#endif
return 0;
}
@ -529,6 +536,10 @@ int ATTR_TCM_SECTION bflb_flash_init(void)
#ifdef BFLB_SF_CTRL_SBUS2_ENABLE
flash2_init();
#else
#if defined(BL616) || defined(BL628)
flash2_size = 0;
#endif
#endif
return ret;

View File

@ -3,7 +3,9 @@
#include "usbh_core.h"
#include "hardware/usb_v2_reg.h"
/* select only one mode */
// #define CONFIG_USB_PINGPONG_ENABLE
// #define CONFIG_USB_TRIPLE_ENABLE
#define BLFB_USB_BASE ((uint32_t)0x20072000)
#define BFLB_PDS_BASE ((uint32_t)0x2000e000)
@ -456,14 +458,30 @@ static uint8_t usb_get_transfer_fifo(uint8_t ep_idx)
uint8_t target_fifo_id;
if ((g_bl_udc.out_ep[ep_idx].ep_mps > 512) || (g_bl_udc.in_ep[ep_idx].ep_mps > 512)) {
#ifdef CONFIG_USB_PINGPONG_ENABLE
target_fifo_id = 0;
#if defined(CONFIG_USB_PINGPONG_ENABLE)
target_fifo_id = USB_FIFO_F0;
#elif defined(CONFIG_USB_TRIPLE_ENABLE)
while (1) {}
#else
target_fifo_id = ((2 * ep_idx - 1) - 1);
if (ep_idx == 1) {
target_fifo_id = USB_FIFO_F0;
} else {
target_fifo_id = USB_FIFO_F2;
}
#endif
} else {
#ifdef CONFIG_USB_PINGPONG_ENABLE
target_fifo_id = ((2 * ep_idx - 1) - 1);
#if defined(CONFIG_USB_PINGPONG_ENABLE)
if (ep_idx == 1) {
target_fifo_id = USB_FIFO_F0;
} else {
target_fifo_id = USB_FIFO_F2;
}
#elif defined(CONFIG_USB_TRIPLE_ENABLE)
if (ep_idx == 1) {
target_fifo_id = USB_FIFO_F0;
} else {
target_fifo_id = USB_FIFO_F3;
}
#else
target_fifo_id = (ep_idx - 1);
#endif
@ -680,7 +698,7 @@ int usbd_ep_open(const struct usbd_endpoint_cfg *ep_cfg)
}
if (ep_idx != 0) {
#ifndef CONFIG_USB_PINGPONG_ENABLE
#if !defined(CONFIG_USB_PINGPONG_ENABLE) && !defined(CONFIG_USB_TRIPLE_ENABLE)
if (ep_cfg->ep_mps > 512) {
bflb_usb_set_ep_fifomap(1, USB_FIFO_F0);
bflb_usb_set_ep_fifomap(2, USB_FIFO_F2);
@ -722,7 +740,7 @@ int usbd_ep_open(const struct usbd_endpoint_cfg *ep_cfg)
return -1;
}
}
#else
#elif defined(CONFIG_USB_PINGPONG_ENABLE)
if (ep_cfg->ep_mps > 512) {
bflb_usb_set_ep_fifomap(1, USB_FIFO_F0);
@ -758,6 +776,28 @@ int usbd_ep_open(const struct usbd_endpoint_cfg *ep_cfg)
return -1;
}
}
#elif defined(CONFIG_USB_TRIPLE_ENABLE)
if (ep_cfg->ep_mps > 512) {
return -1;
} else {
bflb_usb_set_ep_fifomap(1, USB_FIFO_F0);
bflb_usb_set_ep_fifomap(2, USB_FIFO_F3);
bflb_usb_set_fifo_epmap(USB_FIFO_F0, 1, USB_FIFO_DIR_BID);
bflb_usb_set_fifo_epmap(USB_FIFO_F1, 1, USB_FIFO_DIR_BID);
bflb_usb_set_fifo_epmap(USB_FIFO_F2, 1, USB_FIFO_DIR_BID);
bflb_usb_set_fifo_epmap(USB_FIFO_F3, 2, USB_FIFO_DIR_BID);
if (ep_idx == 1) {
bflb_usb_fifo_config(USB_FIFO_F0, ep_cfg->ep_type, 512, 3, true);
bflb_usb_fifo_config(USB_FIFO_F1, ep_cfg->ep_type, 512, 3, false);
bflb_usb_fifo_config(USB_FIFO_F2, ep_cfg->ep_type, 512, 3, false);
} else if (ep_idx == 2) {
bflb_usb_fifo_config(USB_FIFO_F3, ep_cfg->ep_type, 512, 1, true);
} else {
return -1;
}
}
#endif
regval = getreg32(BLFB_USB_BASE + USB_DEV_ADR_OFFSET);
regval |= USB_AFT_CONF;
@ -927,7 +967,7 @@ void USBD_IRQHandler(int irq, void *arg)
if (subgroup_intstatus & USB_SUSP_INT) {
bflb_usb_source_group_int_clear(2, USB_SUSP_INT);
bflb_usb_reset_fifo(USB_FIFO_F0);
bflb_usb_reset_fifo(USB_FIFO_F1);
bflb_usb_reset_fifo(USB_FIFO_F2);
@ -1107,4 +1147,4 @@ void usbd_execute_test_mode(struct usb_setup_packet *setup)
break;
}
}
#endif
#endif

View File

@ -49,7 +49,7 @@ g_irq_sp:
.type default_interrupt_handler, %function
default_interrupt_handler:
/* ipush */
addi sp, sp, -76
addi sp, sp, -80
/* save x5 x6 then save mepc mcause */
sw x5, 4(sp)
@ -104,7 +104,7 @@ default_interrupt_handler:
csrs mstatus, 8
/* keep stack 16bytes aligned */
addi sp, sp, -88
addi sp, sp, -96
/* - 76: mstatus */
csrr t1, mstatus
@ -170,7 +170,7 @@ default_interrupt_handler:
flw ft11,76(sp)
.F_RegNotLoad:
addi sp, sp, 88
addi sp, sp, 96
/* mret included, and IRQ tail-chain may happen */
/* ipop */
@ -200,8 +200,8 @@ default_interrupt_handler:
lw x30, 56(sp)
lw x31, 60(sp)
addi sp, sp, 76
mret
addi sp, sp, 80
ret
.size default_interrupt_handler, . - default_interrupt_handler
@ -315,6 +315,11 @@ trap:
* Config MSOFT IRQ to non-vector mode
* tspend_handler is a weak alias to default_interrupt_handler
*/
j default_interrupt_handler
addi sp, sp, -16
sw ra, 0(sp)
call default_interrupt_handler
lw ra, 0(sp)
addi sp, sp, 16
mret
.size default_trap_handler, . - default_trap_handler