Skip to content

Commit c4a68b4

Browse files
stephan-ghgregkh
authored andcommitted
usb: phy: ab8500-usb: Keep PHY turned on in UART mode
AB8505 supports an "UART carkit mode" which makes UART accessible through the USB connector. Upon detection of the UART cable, this mode has to be manually enabled by: 1. Turning on the PHY in peripheral mode 2. Reconfiguring PHY/pins to route UART signals to USB pins At the moment, we do not handle the UART link statuses at all, which means that UART stops working as soon as phy-ab8500-usb is loaded (since we disable the PHY after initialization). Keeping UART working if the cable is inserted before turning on the device is quite simple: In this case, early boot firmware has already set up the necessary PHY/pin configuration. The presence of the UART cable is reported by a special value in the USB link status register. We can check for that value in ab8505_usb_link_status_update() and set the PHY back to peripheral mode to restore UART. (Note: This will result in some minor garbage since we still temporarily disable the PHY during initialization...) Fully implementing this feature is more complicated: For some reason, AB8505 does not update UART link status after bootup. Regular USB cables work fine, but the link status register does not change its state if an UART cable is inserted/removed. It seems likely that the hardware is not actually capable of detecting UART cables autonomously. In addition to the USB link status register, implementations in the vendor kernel also manually measure the ID resistance to detect additional cable types. For UART cables, the USB link status register might simply reflect the PHY configuration instead of the actual link status. Implementing that functionality requires significant additions, so for now just implement the simple case. This allows using UART when inserting the cable before turning on the device. Signed-off-by: Stephan Gerhold <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 8e1a200 commit c4a68b4

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

drivers/usb/phy/phy-ab8500-usb.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ enum ab8500_usb_mode {
108108
USB_IDLE = 0,
109109
USB_PERIPHERAL,
110110
USB_HOST,
111-
USB_DEDICATED_CHG
111+
USB_DEDICATED_CHG,
112+
USB_UART
112113
};
113114

114115
/* Register USB_LINK_STATUS interrupt */
@@ -393,6 +394,24 @@ static int ab8505_usb_link_status_update(struct ab8500_usb *ab,
393394
usb_phy_set_event(&ab->phy, USB_EVENT_CHARGER);
394395
break;
395396

397+
/*
398+
* FIXME: For now we rely on the boot firmware to set up the necessary
399+
* PHY/pin configuration for UART mode.
400+
*
401+
* AB8505 does not seem to report any status change for UART cables,
402+
* possibly because it cannot detect them autonomously.
403+
* We may need to measure the ID resistance manually to reliably
404+
* detect UART cables after bootup.
405+
*/
406+
case USB_LINK_SAMSUNG_UART_CBL_PHY_EN_8505:
407+
case USB_LINK_SAMSUNG_UART_CBL_PHY_DISB_8505:
408+
if (ab->mode == USB_IDLE) {
409+
ab->mode = USB_UART;
410+
ab8500_usb_peri_phy_en(ab);
411+
}
412+
413+
break;
414+
396415
default:
397416
break;
398417
}
@@ -566,6 +585,11 @@ static irqreturn_t ab8500_usb_disconnect_irq(int irq, void *data)
566585
ab->vbus_draw = 0;
567586
}
568587

588+
if (ab->mode == USB_UART) {
589+
ab8500_usb_peri_phy_dis(ab);
590+
ab->mode = USB_IDLE;
591+
}
592+
569593
if (is_ab8500_2p0(ab->ab8500)) {
570594
if (ab->mode == USB_DEDICATED_CHG) {
571595
ab8500_usb_wd_linkstatus(ab,

0 commit comments

Comments
 (0)