+#ifdef CONFIG_ARM64
#include "usbdev_rk.h"
-#include "usbdev_grf_regs.h"
#include "dwc_otg_regs.h"
+
static struct dwc_otg_control_usb *control_usb;
static u32 uoc_read(u32 reg)
/* Turn off differential receiver in suspend mode */
uoc_write(UOC_HIWORD_UPDATE(0, 1, 2), 0x798);
+ /* Set disconnect detection trigger point to 625mv */
+ uoc_write(UOC_HIWORD_UPDATE(0x9, 0xf, 11), 0x79c);
+
/* other haredware init,include:
* DRV_VBUS GPIO init */
if (gpio_is_valid(control_usb->otg_gpios->gpio))
static void usb20otg_phy_suspend(void *pdata, int suspend)
{
struct dwc_otg_platform_data *usbpdata = pdata;
-
if (suspend) {
/* enable soft control */
- uoc_write(UOC_HIWORD_UPDATE(0x55, 0x7f, 0), 0x700);
+ uoc_write(UOC_HIWORD_UPDATE(0x1d5, 0x1ff, 0), 0x700);
usbpdata->phy_status = 1;
} else {
/* exit suspend */
reset_control_deassert(rst_otg_c);
reset_control_deassert(rst_otg_h);
break;
-
+ case RST_CHN_HALT:
+ /* PHY reset */
+ uoc_write(UOC_HIWORD_UPDATE(0x1, 0x3, 0), 0x700);
+ reset_control_assert(rst_otg_p);
+ udelay(15);
+ uoc_write(UOC_HIWORD_UPDATE(0x2, 0x3, 0), 0x700);
+ udelay(1500);
+ reset_control_deassert(rst_otg_p);
+ udelay(2);
+ break;
default:
break;
}
static void usb20otg_power_enable(int enable)
{
if (0 == enable) {
+ rk_battery_charger_detect_cb(USB_OTG_POWER_OFF);
/* disable otg_drv power */
if (gpio_is_valid(control_usb->otg_gpios->gpio))
gpio_set_value(control_usb->otg_gpios->gpio, 0);
} else if (1 == enable) {
+ rk_battery_charger_detect_cb(USB_OTG_POWER_ON);
/* enable otg_drv power */
if (gpio_is_valid(control_usb->otg_gpios->gpio))
gpio_set_value(control_usb->otg_gpios->gpio, 1);
.get_status = usb20otg_get_status,
.power_enable = usb20otg_power_enable,
.dwc_otg_uart_mode = dwc_otg_uart_mode,
- /* .bc_detect_cb = rk_battery_charger_detect_cb, */
+ .bc_detect_cb = rk_battery_charger_detect_cb,
};
#endif
{
/* Turn off differential receiver in suspend mode */
uoc_write(UOC_HIWORD_UPDATE(0, 1, 2), 0x7b8);
- /* Set disconnect detection trigger point to 600mv */
- uoc_write(UOC_HIWORD_UPDATE(1, 0xf, 11), 0x7bc);
+ /* Set disconnect detection trigger point to 625mv */
+ uoc_write(UOC_HIWORD_UPDATE(0x9, 0xf, 11), 0x7bc);
/* other haredware init,include:
* DRV_VBUS GPIO init */
static void usb_battery_charger_detect_work(struct work_struct *work)
{
- /* rk_battery_charger_detect_cb(usb_battery_charger_detect(1)); */
+ rk_battery_charger_detect_cb(usb_battery_charger_detect(1));
}
/********** handler for bvalid irq **********/
static irqreturn_t bvalid_irq_handler(int irq, void *dev_id)
{
/* clear irq */
- uoc_write(UOC_HIWORD_UPDATE(0x1, 0x1, 3), 0x690);
+ uoc_write(UOC_HIWORD_UPDATE(0x1, 0x1, 3), 0x6a0);
#ifdef CONFIG_RK_USB_UART
/* usb otg dp/dm switch to usb phy */
dwc_otg_uart_mode(NULL, PHY_USB_MODE);
wake_lock_init(&control_usb->usb_wakelock, WAKE_LOCK_SUSPEND,
"usb_detect");
INIT_DELAYED_WORK(&control_usb->usb_det_wakeup_work, do_wakeup);
-#if 0
+
/*register otg_bvalid irq */
irq = platform_get_irq_byname(pdev, "otg_bvalid");
if ((irq > 0) && control_usb->usb_irq_wakeup) {
uoc_write(UOC_HIWORD_UPDATE(0x1, 0x1, 3), 0x680);
}
}
-#endif
+
return 0;
}
MODULE_AUTHOR("RockChip Inc.");
MODULE_DESCRIPTION("RockChip Control Module USB Driver");
MODULE_LICENSE("GPL v2");
+#endif