diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-07-29 13:57:09 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-07-29 13:57:09 +0200 |
commit | 107c89497545232acac83d71600d8030b7361ca2 (patch) | |
tree | 9dc8e1f46d35440fce42d3a1ba7320ec7b6bb429 /drivers | |
parent | fa56dd9152ef955bd21082c5330e4dff8621bca6 (diff) | |
parent | d6f93d21001e4388a25b0b922e02e64bc6004d2f (diff) |
Merge tag 'usb-ci-v5.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/peter.chen/usb into usb-next
Peter writes:
ENDIAN issue fix and one query controller role API is introduced.
* tag 'usb-ci-v5.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/peter.chen/usb:
usb: chipidea: imx: get available runtime dr mode for wakeup setting
usb: chipidea: add query_available_role interface
Documentation: ABI: usb: chipidea: Update Li Jun's e-mail
usb: chipidea: udc: fix the ENDIAN issue
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/chipidea/ci_hdrc_imx.c | 4 | ||||
-rw-r--r-- | drivers/usb/chipidea/ci_hdrc_imx.h | 1 | ||||
-rw-r--r-- | drivers/usb/chipidea/core.c | 27 | ||||
-rw-r--r-- | drivers/usb/chipidea/udc.c | 5 | ||||
-rw-r--r-- | drivers/usb/chipidea/usbmisc_imx.c | 4 |
5 files changed, 37 insertions, 4 deletions
diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c index 5ae16368a0c7..c39e2b615ac6 100644 --- a/drivers/usb/chipidea/ci_hdrc_imx.c +++ b/drivers/usb/chipidea/ci_hdrc_imx.c @@ -462,6 +462,10 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev) if (!IS_ERR(pdata.vbus_extcon.edev) || of_property_read_bool(np, "usb-role-switch")) data->usbmisc_data->ext_vbus = 1; + + /* usbmisc needs to know dr mode to choose wakeup setting */ + data->usbmisc_data->available_role = + ci_hdrc_query_available_role(data->ci_pdev); } ret = imx_usbmisc_init_post(data->usbmisc_data); diff --git a/drivers/usb/chipidea/ci_hdrc_imx.h b/drivers/usb/chipidea/ci_hdrc_imx.h index 727d02b6dbd3..99f846119c00 100644 --- a/drivers/usb/chipidea/ci_hdrc_imx.h +++ b/drivers/usb/chipidea/ci_hdrc_imx.h @@ -25,6 +25,7 @@ struct imx_usbmisc_data { unsigned int ext_id:1; /* ID from exteranl event */ unsigned int ext_vbus:1; /* Vbus from exteranl event */ struct usb_phy *usb_phy; + enum usb_dr_mode available_role; /* runtime usb dr mode */ }; int imx_usbmisc_init(struct imx_usbmisc_data *data); diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index 5c2de8185097..aa40e510b806 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -878,6 +878,33 @@ void ci_hdrc_remove_device(struct platform_device *pdev) } EXPORT_SYMBOL_GPL(ci_hdrc_remove_device); +/** + * ci_hdrc_query_available_role: get runtime available operation mode + * + * The glue layer can get current operation mode (host/peripheral/otg) + * This function should be called after ci core device has created. + * + * @pdev: the platform device of ci core. + * + * Return runtime usb_dr_mode. + */ +enum usb_dr_mode ci_hdrc_query_available_role(struct platform_device *pdev) +{ + struct ci_hdrc *ci = platform_get_drvdata(pdev); + + if (!ci) + return USB_DR_MODE_UNKNOWN; + if (ci->roles[CI_ROLE_HOST] && ci->roles[CI_ROLE_GADGET]) + return USB_DR_MODE_OTG; + else if (ci->roles[CI_ROLE_HOST]) + return USB_DR_MODE_HOST; + else if (ci->roles[CI_ROLE_GADGET]) + return USB_DR_MODE_PERIPHERAL; + else + return USB_DR_MODE_UNKNOWN; +} +EXPORT_SYMBOL_GPL(ci_hdrc_query_available_role); + static inline void ci_role_destroy(struct ci_hdrc *ci) { ci_hdrc_gadget_destroy(ci); diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index 6f173de1a5c1..60ea932afe2b 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c @@ -487,9 +487,10 @@ static void ci_add_buffer_entry(struct td_node *node, struct scatterlist *s) int empty_td_slot_index = (CI_MAX_BUF_SIZE - node->td_remaining_size) / CI_HDRC_PAGE_SIZE; int i; + u32 token; - node->ptr->token += - cpu_to_le32(sg_dma_len(s) << __ffs(TD_TOTAL_BYTES)); + token = le32_to_cpu(node->ptr->token) + (sg_dma_len(s) << __ffs(TD_TOTAL_BYTES)); + node->ptr->token = cpu_to_le32(token); for (i = empty_td_slot_index; i < TD_PAGE_COUNT; i++) { u32 page = (u32) sg_dma_address(s) + diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c index 8a8e7ad928a6..322e4de6b24a 100644 --- a/drivers/usb/chipidea/usbmisc_imx.c +++ b/drivers/usb/chipidea/usbmisc_imx.c @@ -367,10 +367,10 @@ static u32 usbmisc_wakeup_setting(struct imx_usbmisc_data *data) { u32 wakeup_setting = MX6_USB_OTG_WAKEUP_BITS; - if (data->ext_id) + if (data->ext_id || data->available_role != USB_DR_MODE_OTG) wakeup_setting &= ~MX6_BM_ID_WAKEUP; - if (data->ext_vbus) + if (data->ext_vbus || data->available_role == USB_DR_MODE_HOST) wakeup_setting &= ~MX6_BM_VBUS_WAKEUP; return wakeup_setting; |