android13/u-boot/board/rockchip/evb_rk3528/evb_rk3528.c

86 lines
1.7 KiB
C

/*
* SPDX-License-Identifier: GPL-2.0+
*
* (C) Copyright 2020 Rockchip Electronics Co., Ltd
*/
#include <common.h>
#include <dwc3-uboot.h>
#include <usb.h>
#include <linux/usb/phy-rockchip-naneng-combphy.h>
#include <asm/io.h>
#include <rockusb.h>
DECLARE_GLOBAL_DATA_PTR;
#ifdef CONFIG_USB_DWC3
#define CRU_BASE 0xff4a0000
#define CRU_SOFTRST_CON33 0x0a84
static struct dwc3_device dwc3_device_data = {
.maximum_speed = USB_SPEED_SUPER,
.base = 0xfe500000,
.dr_mode = USB_DR_MODE_PERIPHERAL,
.index = 0,
.dis_u2_susphy_quirk = 1,
.dis_u1u2_quirk = 1,
.usb2_phyif_utmi_width = 16,
};
int usb_gadget_handle_interrupts(int index)
{
dwc3_uboot_handle_interrupt(0);
return 0;
}
bool rkusb_usb3_capable(void)
{
return true;
}
static void usb_reset_otg_controller(void)
{
writel(0x00020002, CRU_BASE + CRU_SOFTRST_CON33);
mdelay(1);
writel(0x00020000, CRU_BASE + CRU_SOFTRST_CON33);
mdelay(1);
}
int board_usb_init(int index, enum usb_init_type init)
{
u32 ret = 0;
usb_reset_otg_controller();
#if defined(CONFIG_SUPPORT_USBPLUG)
dwc3_device_data.maximum_speed = USB_SPEED_HIGH;
if (rkusb_switch_usb3_enabled()) {
dwc3_device_data.maximum_speed = USB_SPEED_SUPER;
ret = rockchip_combphy_usb3_uboot_init();
if (ret) {
rkusb_force_to_usb2(true);
dwc3_device_data.maximum_speed = USB_SPEED_HIGH;
}
}
#else
ret = rockchip_combphy_usb3_uboot_init();
if (ret) {
rkusb_force_to_usb2(true);
dwc3_device_data.maximum_speed = USB_SPEED_HIGH;
}
#endif
return dwc3_uboot_init(&dwc3_device_data);
}
#if defined(CONFIG_SUPPORT_USBPLUG)
int board_usb_cleanup(int index, enum usb_init_type init)
{
dwc3_uboot_exit(index);
return 0;
}
#endif
#endif