- Some improvments for ci_hdrc_usb2.c
- Support imx7d USB charger - Add software sg support for UDC - Enable user trigger role switch -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEDaZUZmFxRG/wNThrSFkpgVDWcbsFAl7Mf1oACgkQSFkpgVDW cbskgggAvRbKPI2Zbw4tHa1JgwkADxg2Q3ewxFLiNIJ7GVLpZeiBn4Dziong6za9 1tB/f4qVyAlVT/zLYrxo9oCMwmGOLJjxigGLqJ2iMtDqcRG++jCdirTMXiI2Fdlh ZCup49W0IWKmQ7mSLK0TDVbEpYT8YOICiCJumMxhMYuP6bfgFihPjh8NTiz4X7Jr SUw5rCS7qTRAwDeywIbzWIeCmc4MKaohx4t/XD4Xxz0rPvJrkPgZAaiPh9vJzyMh 2XgFZovLin46QaVbSxxhTUJ7PitCQYzXF+W5vqsdtHkj2u3N3o0MPbSDCKT3oYUb 2zLS7SHzHuKmgFSnxOcLI56gF32uHg== =YwB9 -----END PGP SIGNATURE----- Merge tag 'usb-ci-v5.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/peter.chen/usb into usb-next Peter writes: - Some improvments for ci_hdrc_usb2.c - Support imx7d USB charger - Add software sg support for UDC - Enable user trigger role switch * tag 'usb-ci-v5.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/peter.chen/usb: usb: chipidea: Enable user-space triggered role-switching usb: chipidea: udc: add software sg list support usb: chipidea: usbmisc_imx: using different ops for imx7d and imx7ulp usb: chipidea: pull down dp for possible charger detection operation usb: chipidea: introduce imx7d USB charger detection usb: chipidea: introduce CI_HDRC_CONTROLLER_VBUS_EVENT glue layer use usb: chipidea: usb2: remove unneeded semicolon usb: chipidea: allow disabling glue drivers if EMBEDDED usb: chipidea: usb2: absorb zevio glue driver usb: chipidea: usb2: make clock optional usb: chipidea: usb2: fix formatting usb: chipidea: usb2: constify zynq_pdata usb: chipidea: core: show the real pointer value for register usb: chipidea: core: refine the description for this driver usb: chipidea: udc: fix the kernel doc for udc.h
This commit is contained in:
Коммит
37f6c193e6
|
@ -18,17 +18,6 @@ config USB_CHIPIDEA
|
|||
|
||||
if USB_CHIPIDEA
|
||||
|
||||
config USB_CHIPIDEA_OF
|
||||
tristate
|
||||
depends on OF
|
||||
default USB_CHIPIDEA
|
||||
|
||||
config USB_CHIPIDEA_PCI
|
||||
tristate
|
||||
depends on USB_PCI
|
||||
depends on NOP_USB_XCEIV
|
||||
default USB_CHIPIDEA
|
||||
|
||||
config USB_CHIPIDEA_UDC
|
||||
bool "ChipIdea device controller"
|
||||
depends on USB_GADGET
|
||||
|
@ -43,4 +32,30 @@ config USB_CHIPIDEA_HOST
|
|||
help
|
||||
Say Y here to enable host controller functionality of the
|
||||
ChipIdea driver.
|
||||
|
||||
config USB_CHIPIDEA_PCI
|
||||
tristate "Enable PCI glue driver" if EMBEDDED
|
||||
depends on USB_PCI
|
||||
depends on NOP_USB_XCEIV
|
||||
default USB_CHIPIDEA
|
||||
|
||||
config USB_CHIPIDEA_MSM
|
||||
tristate "Enable MSM hsusb glue driver" if EMBEDDED
|
||||
default USB_CHIPIDEA
|
||||
|
||||
config USB_CHIPIDEA_IMX
|
||||
tristate "Enable i.MX USB glue driver" if EMBEDDED
|
||||
depends on OF
|
||||
default USB_CHIPIDEA
|
||||
|
||||
config USB_CHIPIDEA_GENERIC
|
||||
tristate "Enable generic USB2 glue driver" if EMBEDDED
|
||||
default USB_CHIPIDEA
|
||||
|
||||
config USB_CHIPIDEA_TEGRA
|
||||
tristate "Enable Tegra UDC glue driver" if EMBEDDED
|
||||
depends on OF
|
||||
depends on USB_CHIPIDEA_UDC
|
||||
default USB_CHIPIDEA
|
||||
|
||||
endif
|
||||
|
|
|
@ -8,11 +8,8 @@ ci_hdrc-$(CONFIG_USB_OTG_FSM) += otg_fsm.o
|
|||
|
||||
# Glue/Bridge layers go here
|
||||
|
||||
obj-$(CONFIG_USB_CHIPIDEA) += ci_hdrc_usb2.o
|
||||
obj-$(CONFIG_USB_CHIPIDEA) += ci_hdrc_msm.o
|
||||
obj-$(CONFIG_USB_CHIPIDEA) += ci_hdrc_zevio.o
|
||||
|
||||
obj-$(CONFIG_USB_CHIPIDEA_PCI) += ci_hdrc_pci.o
|
||||
|
||||
obj-$(CONFIG_USB_CHIPIDEA_OF) += usbmisc_imx.o ci_hdrc_imx.o
|
||||
obj-$(CONFIG_USB_CHIPIDEA_OF) += ci_hdrc_tegra.o
|
||||
obj-$(CONFIG_USB_CHIPIDEA_GENERIC) += ci_hdrc_usb2.o
|
||||
obj-$(CONFIG_USB_CHIPIDEA_MSM) += ci_hdrc_msm.o
|
||||
obj-$(CONFIG_USB_CHIPIDEA_PCI) += ci_hdrc_pci.o
|
||||
obj-$(CONFIG_USB_CHIPIDEA_IMX) += ci_hdrc_imx.o usbmisc_imx.o
|
||||
obj-$(CONFIG_USB_CHIPIDEA_TEGRA) += ci_hdrc_tegra.o
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#define TD_PAGE_COUNT 5
|
||||
#define CI_HDRC_PAGE_SIZE 4096ul /* page size for TD's */
|
||||
#define ENDPT_MAX 32
|
||||
#define CI_MAX_BUF_SIZE (TD_PAGE_COUNT * CI_HDRC_PAGE_SIZE)
|
||||
|
||||
/******************************************************************************
|
||||
* REGISTERS
|
||||
|
|
|
@ -271,6 +271,7 @@ static int ci_hdrc_imx_notify_event(struct ci_hdrc *ci, unsigned int event)
|
|||
struct device *dev = ci->dev->parent;
|
||||
struct ci_hdrc_imx_data *data = dev_get_drvdata(dev);
|
||||
int ret = 0;
|
||||
struct imx_usbmisc_data *mdata = data->usbmisc_data;
|
||||
|
||||
switch (event) {
|
||||
case CI_HDRC_IMX_HSIC_ACTIVE_EVENT:
|
||||
|
@ -284,11 +285,19 @@ static int ci_hdrc_imx_notify_event(struct ci_hdrc *ci, unsigned int event)
|
|||
}
|
||||
break;
|
||||
case CI_HDRC_IMX_HSIC_SUSPEND_EVENT:
|
||||
ret = imx_usbmisc_hsic_set_connect(data->usbmisc_data);
|
||||
ret = imx_usbmisc_hsic_set_connect(mdata);
|
||||
if (ret)
|
||||
dev_err(dev,
|
||||
"hsic_set_connect failed, err=%d\n", ret);
|
||||
break;
|
||||
case CI_HDRC_CONTROLLER_VBUS_EVENT:
|
||||
if (ci->vbus_active)
|
||||
ret = imx_usbmisc_charger_detection(mdata, true);
|
||||
else
|
||||
ret = imx_usbmisc_charger_detection(mdata, false);
|
||||
if (ci->usb_phy)
|
||||
schedule_work(&ci->usb_phy->chg_work);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -414,6 +423,8 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
|
|||
}
|
||||
|
||||
pdata.usb_phy = data->phy;
|
||||
if (data->usbmisc_data)
|
||||
data->usbmisc_data->usb_phy = data->phy;
|
||||
|
||||
if ((of_device_is_compatible(np, "fsl,imx53-usb") ||
|
||||
of_device_is_compatible(np, "fsl,imx51-usb")) && pdata.usb_phy &&
|
||||
|
|
|
@ -24,6 +24,7 @@ struct imx_usbmisc_data {
|
|||
unsigned int hsic:1; /* HSIC controlller */
|
||||
unsigned int ext_id:1; /* ID from exteranl event */
|
||||
unsigned int ext_vbus:1; /* Vbus from exteranl event */
|
||||
struct usb_phy *usb_phy;
|
||||
};
|
||||
|
||||
int imx_usbmisc_init(struct imx_usbmisc_data *data);
|
||||
|
@ -31,5 +32,6 @@ int imx_usbmisc_init_post(struct imx_usbmisc_data *data);
|
|||
int imx_usbmisc_set_wakeup(struct imx_usbmisc_data *data, bool enabled);
|
||||
int imx_usbmisc_hsic_set_connect(struct imx_usbmisc_data *data);
|
||||
int imx_usbmisc_hsic_set_clk(struct imx_usbmisc_data *data, bool on);
|
||||
int imx_usbmisc_charger_detection(struct imx_usbmisc_data *data, bool connect);
|
||||
|
||||
#endif /* __DRIVER_USB_CHIPIDEA_CI_HDRC_IMX_H */
|
||||
|
|
|
@ -28,13 +28,19 @@ static const struct ci_hdrc_platform_data ci_default_pdata = {
|
|||
.flags = CI_HDRC_DISABLE_STREAMING,
|
||||
};
|
||||
|
||||
static struct ci_hdrc_platform_data ci_zynq_pdata = {
|
||||
static const struct ci_hdrc_platform_data ci_zynq_pdata = {
|
||||
.capoffset = DEF_CAPOFFSET,
|
||||
};
|
||||
|
||||
static const struct ci_hdrc_platform_data ci_zevio_pdata = {
|
||||
.capoffset = DEF_CAPOFFSET,
|
||||
.flags = CI_HDRC_REGS_SHARED | CI_HDRC_FORCE_FULLSPEED,
|
||||
};
|
||||
|
||||
static const struct of_device_id ci_hdrc_usb2_of_match[] = {
|
||||
{ .compatible = "chipidea,usb2"},
|
||||
{ .compatible = "xlnx,zynq-usb-2.20a", .data = &ci_zynq_pdata},
|
||||
{ .compatible = "chipidea,usb2" },
|
||||
{ .compatible = "xlnx,zynq-usb-2.20a", .data = &ci_zynq_pdata },
|
||||
{ .compatible = "lsi,zevio-usb", .data = &ci_zevio_pdata },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, ci_hdrc_usb2_of_match);
|
||||
|
@ -64,13 +70,14 @@ static int ci_hdrc_usb2_probe(struct platform_device *pdev)
|
|||
if (!priv)
|
||||
return -ENOMEM;
|
||||
|
||||
priv->clk = devm_clk_get(dev, NULL);
|
||||
if (!IS_ERR(priv->clk)) {
|
||||
ret = clk_prepare_enable(priv->clk);
|
||||
if (ret) {
|
||||
dev_err(dev, "failed to enable the clock: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
priv->clk = devm_clk_get_optional(dev, NULL);
|
||||
if (IS_ERR(priv->clk))
|
||||
return PTR_ERR(priv->clk);
|
||||
|
||||
ret = clk_prepare_enable(priv->clk);
|
||||
if (ret) {
|
||||
dev_err(dev, "failed to enable the clock: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ci_pdata->name = dev_name(dev);
|
||||
|
@ -94,8 +101,7 @@ static int ci_hdrc_usb2_probe(struct platform_device *pdev)
|
|||
return 0;
|
||||
|
||||
clk_err:
|
||||
if (!IS_ERR(priv->clk))
|
||||
clk_disable_unprepare(priv->clk);
|
||||
clk_disable_unprepare(priv->clk);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* Copyright (C) 2013 Daniel Tang <tangrs@tangrs.id.au>
|
||||
*
|
||||
* Based off drivers/usb/chipidea/ci_hdrc_msm.c
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/usb/gadget.h>
|
||||
#include <linux/usb/chipidea.h>
|
||||
|
||||
#include "ci.h"
|
||||
|
||||
static struct ci_hdrc_platform_data ci_hdrc_zevio_platdata = {
|
||||
.name = "ci_hdrc_zevio",
|
||||
.flags = CI_HDRC_REGS_SHARED | CI_HDRC_FORCE_FULLSPEED,
|
||||
.capoffset = DEF_CAPOFFSET,
|
||||
};
|
||||
|
||||
static int ci_hdrc_zevio_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct platform_device *ci_pdev;
|
||||
|
||||
dev_dbg(&pdev->dev, "ci_hdrc_zevio_probe\n");
|
||||
|
||||
ci_pdev = ci_hdrc_add_device(&pdev->dev,
|
||||
pdev->resource, pdev->num_resources,
|
||||
&ci_hdrc_zevio_platdata);
|
||||
|
||||
if (IS_ERR(ci_pdev)) {
|
||||
dev_err(&pdev->dev, "ci_hdrc_add_device failed!\n");
|
||||
return PTR_ERR(ci_pdev);
|
||||
}
|
||||
|
||||
platform_set_drvdata(pdev, ci_pdev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ci_hdrc_zevio_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct platform_device *ci_pdev = platform_get_drvdata(pdev);
|
||||
|
||||
ci_hdrc_remove_device(ci_pdev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct of_device_id ci_hdrc_zevio_dt_ids[] = {
|
||||
{ .compatible = "lsi,zevio-usb", },
|
||||
{ /* sentinel */ }
|
||||
};
|
||||
|
||||
static struct platform_driver ci_hdrc_zevio_driver = {
|
||||
.probe = ci_hdrc_zevio_probe,
|
||||
.remove = ci_hdrc_zevio_remove,
|
||||
.driver = {
|
||||
.name = "zevio_usb",
|
||||
.of_match_table = ci_hdrc_zevio_dt_ids,
|
||||
},
|
||||
};
|
||||
|
||||
MODULE_DEVICE_TABLE(of, ci_hdrc_zevio_dt_ids);
|
||||
module_platform_driver(ci_hdrc_zevio_driver);
|
||||
|
||||
MODULE_LICENSE("GPL v2");
|
|
@ -3,42 +3,16 @@
|
|||
* core.c - ChipIdea USB IP core family device controller
|
||||
*
|
||||
* Copyright (C) 2008 Chipidea - MIPS Technologies, Inc. All rights reserved.
|
||||
* Copyright (C) 2020 NXP
|
||||
*
|
||||
* Author: David Lopo
|
||||
*/
|
||||
|
||||
/*
|
||||
* Description: ChipIdea USB IP core family device controller
|
||||
* Peter Chen <peter.chen@nxp.com>
|
||||
*
|
||||
* This driver is composed of several blocks:
|
||||
* - HW: hardware interface
|
||||
* - DBG: debug facilities (optional)
|
||||
* - UTIL: utilities
|
||||
* - ISR: interrupts handling
|
||||
* - ENDPT: endpoint operations (Gadget API)
|
||||
* - GADGET: gadget operations (Gadget API)
|
||||
* - BUS: bus glue code, bus abstraction layer
|
||||
*
|
||||
* Compile Options
|
||||
* - STALL_IN: non-empty bulk-in pipes cannot be halted
|
||||
* if defined mass storage compliance succeeds but with warnings
|
||||
* => case 4: Hi > Dn
|
||||
* => case 5: Hi > Di
|
||||
* => case 8: Hi <> Do
|
||||
* if undefined usbtest 13 fails
|
||||
* - TRACE: enable function tracing (depends on DEBUG)
|
||||
*
|
||||
* Main Features
|
||||
* - Chapter 9 & Mass Storage Compliance with Gadget File Storage
|
||||
* - Chapter 9 Compliance with Gadget Zero (STALL_IN undefined)
|
||||
* - Normal & LPM support
|
||||
*
|
||||
* USBTEST Report
|
||||
* - OK: 0-12, 13 (STALL_IN defined) & 14
|
||||
* - Not Supported: 15 & 16 (ISO)
|
||||
*
|
||||
* TODO List
|
||||
* - Suspend & Remote Wakeup
|
||||
* Main Features:
|
||||
* - Four transfers are supported, usbtest is passed
|
||||
* - USB Certification for gadget: CH9 and Mass Storage are passed
|
||||
* - Low power mode
|
||||
* - USB wakeup
|
||||
*/
|
||||
#include <linux/delay.h>
|
||||
#include <linux/device.h>
|
||||
|
@ -272,7 +246,7 @@ static int hw_device_init(struct ci_hdrc *ci, void __iomem *base)
|
|||
ci->rev = ci_get_revision(ci);
|
||||
|
||||
dev_dbg(ci->dev,
|
||||
"ChipIdea HDRC found, revision: %d, lpm: %d; cap: %p op: %p\n",
|
||||
"revision: %d, lpm: %d; cap: %px op: %px\n",
|
||||
ci->rev, ci->hw_bank.lpm, ci->hw_bank.cap, ci->hw_bank.op);
|
||||
|
||||
/* setup lock mode ? */
|
||||
|
@ -666,6 +640,7 @@ static int ci_usb_role_switch_set(struct usb_role_switch *sw,
|
|||
static struct usb_role_switch_desc ci_role_switch = {
|
||||
.set = ci_usb_role_switch_set,
|
||||
.get = ci_usb_role_switch_get,
|
||||
.allow_userspace_control = true,
|
||||
};
|
||||
|
||||
static int ci_get_platdata(struct device *dev,
|
||||
|
@ -1149,8 +1124,11 @@ static int ci_hdrc_probe(struct platform_device *pdev)
|
|||
|
||||
if (!ci_otg_is_fsm_mode(ci)) {
|
||||
/* only update vbus status for peripheral */
|
||||
if (ci->role == CI_ROLE_GADGET)
|
||||
if (ci->role == CI_ROLE_GADGET) {
|
||||
/* Pull down DP for possible charger detection */
|
||||
hw_write(ci, OP_USBCMD, USBCMD_RS, 0);
|
||||
ci_handle_vbus_change(ci);
|
||||
}
|
||||
|
||||
ret = ci_role_start(ci, ci->role);
|
||||
if (ret) {
|
||||
|
|
|
@ -338,7 +338,7 @@ static int hw_usb_reset(struct ci_hdrc *ci)
|
|||
*****************************************************************************/
|
||||
|
||||
static int add_td_to_list(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq,
|
||||
unsigned length)
|
||||
unsigned int length, struct scatterlist *s)
|
||||
{
|
||||
int i;
|
||||
u32 temp;
|
||||
|
@ -366,7 +366,13 @@ static int add_td_to_list(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq,
|
|||
node->ptr->token |= cpu_to_le32(mul << __ffs(TD_MULTO));
|
||||
}
|
||||
|
||||
temp = (u32) (hwreq->req.dma + hwreq->req.actual);
|
||||
if (s) {
|
||||
temp = (u32) (sg_dma_address(s) + hwreq->req.actual);
|
||||
node->td_remaining_size = CI_MAX_BUF_SIZE - length;
|
||||
} else {
|
||||
temp = (u32) (hwreq->req.dma + hwreq->req.actual);
|
||||
}
|
||||
|
||||
if (length) {
|
||||
node->ptr->page[0] = cpu_to_le32(temp);
|
||||
for (i = 1; i < TD_PAGE_COUNT; i++) {
|
||||
|
@ -400,6 +406,122 @@ static inline u8 _usb_addr(struct ci_hw_ep *ep)
|
|||
return ((ep->dir == TX) ? USB_ENDPOINT_DIR_MASK : 0) | ep->num;
|
||||
}
|
||||
|
||||
static int prepare_td_for_non_sg(struct ci_hw_ep *hwep,
|
||||
struct ci_hw_req *hwreq)
|
||||
{
|
||||
unsigned int rest = hwreq->req.length;
|
||||
int pages = TD_PAGE_COUNT;
|
||||
int ret = 0;
|
||||
|
||||
if (rest == 0) {
|
||||
ret = add_td_to_list(hwep, hwreq, 0, NULL);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* The first buffer could be not page aligned.
|
||||
* In that case we have to span into one extra td.
|
||||
*/
|
||||
if (hwreq->req.dma % PAGE_SIZE)
|
||||
pages--;
|
||||
|
||||
while (rest > 0) {
|
||||
unsigned int count = min(hwreq->req.length - hwreq->req.actual,
|
||||
(unsigned int)(pages * CI_HDRC_PAGE_SIZE));
|
||||
|
||||
ret = add_td_to_list(hwep, hwreq, count, NULL);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
rest -= count;
|
||||
}
|
||||
|
||||
if (hwreq->req.zero && hwreq->req.length && hwep->dir == TX
|
||||
&& (hwreq->req.length % hwep->ep.maxpacket == 0)) {
|
||||
ret = add_td_to_list(hwep, hwreq, 0, NULL);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int prepare_td_per_sg(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq,
|
||||
struct scatterlist *s)
|
||||
{
|
||||
unsigned int rest = sg_dma_len(s);
|
||||
int ret = 0;
|
||||
|
||||
hwreq->req.actual = 0;
|
||||
while (rest > 0) {
|
||||
unsigned int count = min_t(unsigned int, rest,
|
||||
CI_MAX_BUF_SIZE);
|
||||
|
||||
ret = add_td_to_list(hwep, hwreq, count, s);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
rest -= count;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
node->ptr->token +=
|
||||
cpu_to_le32(sg_dma_len(s) << __ffs(TD_TOTAL_BYTES));
|
||||
|
||||
for (i = empty_td_slot_index; i < TD_PAGE_COUNT; i++) {
|
||||
u32 page = (u32) sg_dma_address(s) +
|
||||
(i - empty_td_slot_index) * CI_HDRC_PAGE_SIZE;
|
||||
|
||||
page &= ~TD_RESERVED_MASK;
|
||||
node->ptr->page[i] = cpu_to_le32(page);
|
||||
}
|
||||
}
|
||||
|
||||
static int prepare_td_for_sg(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq)
|
||||
{
|
||||
struct usb_request *req = &hwreq->req;
|
||||
struct scatterlist *s = req->sg;
|
||||
int ret = 0, i = 0;
|
||||
struct td_node *node = NULL;
|
||||
|
||||
if (!s || req->zero || req->length == 0) {
|
||||
dev_err(hwep->ci->dev, "not supported operation for sg\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
while (i++ < req->num_mapped_sgs) {
|
||||
if (sg_dma_address(s) % PAGE_SIZE) {
|
||||
dev_err(hwep->ci->dev, "not page aligned sg buffer\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (node && (node->td_remaining_size >= sg_dma_len(s))) {
|
||||
ci_add_buffer_entry(node, s);
|
||||
node->td_remaining_size -= sg_dma_len(s);
|
||||
} else {
|
||||
ret = prepare_td_per_sg(hwep, hwreq, s);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
node = list_entry(hwreq->tds.prev,
|
||||
struct td_node, td);
|
||||
}
|
||||
|
||||
s = sg_next(s);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* _hardware_enqueue: configures a request at hardware level
|
||||
* @hwep: endpoint
|
||||
|
@ -411,8 +533,6 @@ static int _hardware_enqueue(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq)
|
|||
{
|
||||
struct ci_hdrc *ci = hwep->ci;
|
||||
int ret = 0;
|
||||
unsigned rest = hwreq->req.length;
|
||||
int pages = TD_PAGE_COUNT;
|
||||
struct td_node *firstnode, *lastnode;
|
||||
|
||||
/* don't queue twice */
|
||||
|
@ -426,35 +546,13 @@ static int _hardware_enqueue(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq)
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
/*
|
||||
* The first buffer could be not page aligned.
|
||||
* In that case we have to span into one extra td.
|
||||
*/
|
||||
if (hwreq->req.dma % PAGE_SIZE)
|
||||
pages--;
|
||||
if (hwreq->req.num_mapped_sgs)
|
||||
ret = prepare_td_for_sg(hwep, hwreq);
|
||||
else
|
||||
ret = prepare_td_for_non_sg(hwep, hwreq);
|
||||
|
||||
if (rest == 0) {
|
||||
ret = add_td_to_list(hwep, hwreq, 0);
|
||||
if (ret < 0)
|
||||
goto done;
|
||||
}
|
||||
|
||||
while (rest > 0) {
|
||||
unsigned count = min(hwreq->req.length - hwreq->req.actual,
|
||||
(unsigned)(pages * CI_HDRC_PAGE_SIZE));
|
||||
ret = add_td_to_list(hwep, hwreq, count);
|
||||
if (ret < 0)
|
||||
goto done;
|
||||
|
||||
rest -= count;
|
||||
}
|
||||
|
||||
if (hwreq->req.zero && hwreq->req.length && hwep->dir == TX
|
||||
&& (hwreq->req.length % hwep->ep.maxpacket == 0)) {
|
||||
ret = add_td_to_list(hwep, hwreq, 0);
|
||||
if (ret < 0)
|
||||
goto done;
|
||||
}
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
firstnode = list_first_entry(&hwreq->tds, struct td_node, td);
|
||||
|
||||
|
@ -1561,6 +1659,7 @@ static int ci_udc_vbus_session(struct usb_gadget *_gadget, int is_active)
|
|||
{
|
||||
struct ci_hdrc *ci = container_of(_gadget, struct ci_hdrc, gadget);
|
||||
unsigned long flags;
|
||||
int ret = 0;
|
||||
|
||||
spin_lock_irqsave(&ci->lock, flags);
|
||||
ci->vbus_active = is_active;
|
||||
|
@ -1570,10 +1669,14 @@ static int ci_udc_vbus_session(struct usb_gadget *_gadget, int is_active)
|
|||
usb_phy_set_charger_state(ci->usb_phy, is_active ?
|
||||
USB_CHARGER_PRESENT : USB_CHARGER_ABSENT);
|
||||
|
||||
if (ci->platdata->notify_event)
|
||||
ret = ci->platdata->notify_event(ci,
|
||||
CI_HDRC_CONTROLLER_VBUS_EVENT);
|
||||
|
||||
if (ci->driver)
|
||||
ci_hdrc_gadget_connect(_gadget, is_active);
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ci_udc_wakeup(struct usb_gadget *_gadget)
|
||||
|
@ -1936,6 +2039,7 @@ static int udc_start(struct ci_hdrc *ci)
|
|||
ci->gadget.max_speed = USB_SPEED_HIGH;
|
||||
ci->gadget.name = ci->platdata->name;
|
||||
ci->gadget.otg_caps = otg_caps;
|
||||
ci->gadget.sg_supported = 1;
|
||||
|
||||
if (ci->platdata->flags & CI_HDRC_REQUIRES_ALIGNED_DMA)
|
||||
ci->gadget.quirk_avoids_skb_reserve = 1;
|
||||
|
|
|
@ -61,16 +61,14 @@ struct td_node {
|
|||
struct list_head td;
|
||||
dma_addr_t dma;
|
||||
struct ci_hw_td *ptr;
|
||||
int td_remaining_size;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct ci_hw_req - usb request representation
|
||||
* @req: request structure for gadget drivers
|
||||
* @queue: link to QH list
|
||||
* @ptr: transfer descriptor for this request
|
||||
* @dma: dma address for the transfer descriptor
|
||||
* @zptr: transfer descriptor for the zero packet
|
||||
* @zdma: dma address of the zero packet's transfer descriptor
|
||||
* @tds: link to TD list
|
||||
*/
|
||||
struct ci_hw_req {
|
||||
struct usb_request req;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <linux/err.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/usb/otg.h>
|
||||
|
||||
#include "ci_hdrc_imx.h"
|
||||
|
||||
|
@ -99,6 +100,33 @@
|
|||
#define MX7D_USB_VBUS_WAKEUP_SOURCE_AVALID MX7D_USB_VBUS_WAKEUP_SOURCE(1)
|
||||
#define MX7D_USB_VBUS_WAKEUP_SOURCE_BVALID MX7D_USB_VBUS_WAKEUP_SOURCE(2)
|
||||
#define MX7D_USB_VBUS_WAKEUP_SOURCE_SESS_END MX7D_USB_VBUS_WAKEUP_SOURCE(3)
|
||||
#define MX7D_USBNC_AUTO_RESUME BIT(2)
|
||||
/* The default DM/DP value is pull-down */
|
||||
#define MX7D_USBNC_USB_CTRL2_OPMODE(v) (v << 6)
|
||||
#define MX7D_USBNC_USB_CTRL2_OPMODE_NON_DRIVING MX7D_USBNC_USB_CTRL2_OPMODE(1)
|
||||
#define MX7D_USBNC_USB_CTRL2_OPMODE_OVERRIDE_MASK (BIT(7) | BIT(6))
|
||||
#define MX7D_USBNC_USB_CTRL2_OPMODE_OVERRIDE_EN BIT(8)
|
||||
#define MX7D_USBNC_USB_CTRL2_DP_OVERRIDE_VAL BIT(12)
|
||||
#define MX7D_USBNC_USB_CTRL2_DP_OVERRIDE_EN BIT(13)
|
||||
#define MX7D_USBNC_USB_CTRL2_DM_OVERRIDE_VAL BIT(14)
|
||||
#define MX7D_USBNC_USB_CTRL2_DM_OVERRIDE_EN BIT(15)
|
||||
#define MX7D_USBNC_USB_CTRL2_DP_DM_MASK (BIT(12) | BIT(13) | \
|
||||
BIT(14) | BIT(15))
|
||||
|
||||
#define MX7D_USB_OTG_PHY_CFG1 0x30
|
||||
#define MX7D_USB_OTG_PHY_CFG2_CHRG_CHRGSEL BIT(0)
|
||||
#define MX7D_USB_OTG_PHY_CFG2_CHRG_VDATDETENB0 BIT(1)
|
||||
#define MX7D_USB_OTG_PHY_CFG2_CHRG_VDATSRCENB0 BIT(2)
|
||||
#define MX7D_USB_OTG_PHY_CFG2_CHRG_DCDENB BIT(3)
|
||||
#define MX7D_USB_OTG_PHY_CFG2_DRVVBUS0 BIT(16)
|
||||
|
||||
#define MX7D_USB_OTG_PHY_CFG2 0x34
|
||||
|
||||
#define MX7D_USB_OTG_PHY_STATUS 0x3c
|
||||
#define MX7D_USB_OTG_PHY_STATUS_LINE_STATE0 BIT(0)
|
||||
#define MX7D_USB_OTG_PHY_STATUS_LINE_STATE1 BIT(1)
|
||||
#define MX7D_USB_OTG_PHY_STATUS_VBUS_VLD BIT(3)
|
||||
#define MX7D_USB_OTG_PHY_STATUS_CHRGDET BIT(29)
|
||||
|
||||
#define MX6_USB_OTG_WAKEUP_BITS (MX6_BM_WAKEUP_ENABLE | MX6_BM_VBUS_WAKEUP | \
|
||||
MX6_BM_ID_WAKEUP)
|
||||
|
@ -114,6 +142,8 @@ struct usbmisc_ops {
|
|||
int (*hsic_set_connect)(struct imx_usbmisc_data *data);
|
||||
/* It's called during suspend/resume */
|
||||
int (*hsic_set_clk)(struct imx_usbmisc_data *data, bool enabled);
|
||||
/* usb charger detection */
|
||||
int (*charger_detection)(struct imx_usbmisc_data *data);
|
||||
};
|
||||
|
||||
struct imx_usbmisc {
|
||||
|
@ -609,10 +639,263 @@ static int usbmisc_imx7d_init(struct imx_usbmisc_data *data)
|
|||
reg |= MX6_BM_PWR_POLARITY;
|
||||
writel(reg, usbmisc->base);
|
||||
|
||||
reg = readl(usbmisc->base + MX7D_USBNC_USB_CTRL2);
|
||||
reg &= ~MX7D_USB_VBUS_WAKEUP_SOURCE_MASK;
|
||||
writel(reg | MX7D_USB_VBUS_WAKEUP_SOURCE_BVALID,
|
||||
usbmisc->base + MX7D_USBNC_USB_CTRL2);
|
||||
/* SoC non-burst setting */
|
||||
reg = readl(usbmisc->base);
|
||||
writel(reg | MX6_BM_NON_BURST_SETTING, usbmisc->base);
|
||||
|
||||
if (!data->hsic) {
|
||||
reg = readl(usbmisc->base + MX7D_USBNC_USB_CTRL2);
|
||||
reg &= ~MX7D_USB_VBUS_WAKEUP_SOURCE_MASK;
|
||||
writel(reg | MX7D_USB_VBUS_WAKEUP_SOURCE_BVALID
|
||||
| MX7D_USBNC_AUTO_RESUME,
|
||||
usbmisc->base + MX7D_USBNC_USB_CTRL2);
|
||||
}
|
||||
|
||||
spin_unlock_irqrestore(&usbmisc->lock, flags);
|
||||
|
||||
usbmisc_imx7d_set_wakeup(data, false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int imx7d_charger_secondary_detection(struct imx_usbmisc_data *data)
|
||||
{
|
||||
struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
|
||||
struct usb_phy *usb_phy = data->usb_phy;
|
||||
int val;
|
||||
unsigned long flags;
|
||||
|
||||
/* VDM_SRC is connected to D- and IDP_SINK is connected to D+ */
|
||||
spin_lock_irqsave(&usbmisc->lock, flags);
|
||||
val = readl(usbmisc->base + MX7D_USB_OTG_PHY_CFG2);
|
||||
writel(val | MX7D_USB_OTG_PHY_CFG2_CHRG_VDATSRCENB0 |
|
||||
MX7D_USB_OTG_PHY_CFG2_CHRG_VDATDETENB0 |
|
||||
MX7D_USB_OTG_PHY_CFG2_CHRG_CHRGSEL,
|
||||
usbmisc->base + MX7D_USB_OTG_PHY_CFG2);
|
||||
spin_unlock_irqrestore(&usbmisc->lock, flags);
|
||||
|
||||
usleep_range(1000, 2000);
|
||||
|
||||
/*
|
||||
* Per BC 1.2, check voltage of D+:
|
||||
* DCP: if greater than VDAT_REF;
|
||||
* CDP: if less than VDAT_REF.
|
||||
*/
|
||||
val = readl(usbmisc->base + MX7D_USB_OTG_PHY_STATUS);
|
||||
if (val & MX7D_USB_OTG_PHY_STATUS_CHRGDET) {
|
||||
dev_dbg(data->dev, "It is a dedicate charging port\n");
|
||||
usb_phy->chg_type = DCP_TYPE;
|
||||
} else {
|
||||
dev_dbg(data->dev, "It is a charging downstream port\n");
|
||||
usb_phy->chg_type = CDP_TYPE;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void imx7_disable_charger_detector(struct imx_usbmisc_data *data)
|
||||
{
|
||||
struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
|
||||
unsigned long flags;
|
||||
u32 val;
|
||||
|
||||
spin_lock_irqsave(&usbmisc->lock, flags);
|
||||
val = readl(usbmisc->base + MX7D_USB_OTG_PHY_CFG2);
|
||||
val &= ~(MX7D_USB_OTG_PHY_CFG2_CHRG_DCDENB |
|
||||
MX7D_USB_OTG_PHY_CFG2_CHRG_VDATSRCENB0 |
|
||||
MX7D_USB_OTG_PHY_CFG2_CHRG_VDATDETENB0 |
|
||||
MX7D_USB_OTG_PHY_CFG2_CHRG_CHRGSEL);
|
||||
writel(val, usbmisc->base + MX7D_USB_OTG_PHY_CFG2);
|
||||
|
||||
/* Set OPMODE to be 2'b00 and disable its override */
|
||||
val = readl(usbmisc->base + MX7D_USBNC_USB_CTRL2);
|
||||
val &= ~MX7D_USBNC_USB_CTRL2_OPMODE_OVERRIDE_MASK;
|
||||
writel(val, usbmisc->base + MX7D_USBNC_USB_CTRL2);
|
||||
|
||||
val = readl(usbmisc->base + MX7D_USBNC_USB_CTRL2);
|
||||
writel(val & ~MX7D_USBNC_USB_CTRL2_OPMODE_OVERRIDE_EN,
|
||||
usbmisc->base + MX7D_USBNC_USB_CTRL2);
|
||||
spin_unlock_irqrestore(&usbmisc->lock, flags);
|
||||
}
|
||||
|
||||
static int imx7d_charger_data_contact_detect(struct imx_usbmisc_data *data)
|
||||
{
|
||||
struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
|
||||
unsigned long flags;
|
||||
u32 val;
|
||||
int i, data_pin_contact_count = 0;
|
||||
|
||||
/* Enable Data Contact Detect (DCD) per the USB BC 1.2 */
|
||||
spin_lock_irqsave(&usbmisc->lock, flags);
|
||||
val = readl(usbmisc->base + MX7D_USB_OTG_PHY_CFG2);
|
||||
writel(val | MX7D_USB_OTG_PHY_CFG2_CHRG_DCDENB,
|
||||
usbmisc->base + MX7D_USB_OTG_PHY_CFG2);
|
||||
spin_unlock_irqrestore(&usbmisc->lock, flags);
|
||||
|
||||
for (i = 0; i < 100; i = i + 1) {
|
||||
val = readl(usbmisc->base + MX7D_USB_OTG_PHY_STATUS);
|
||||
if (!(val & MX7D_USB_OTG_PHY_STATUS_LINE_STATE0)) {
|
||||
if (data_pin_contact_count++ > 5)
|
||||
/* Data pin makes contact */
|
||||
break;
|
||||
usleep_range(5000, 10000);
|
||||
} else {
|
||||
data_pin_contact_count = 0;
|
||||
usleep_range(5000, 6000);
|
||||
}
|
||||
}
|
||||
|
||||
/* Disable DCD after finished data contact check */
|
||||
spin_lock_irqsave(&usbmisc->lock, flags);
|
||||
val = readl(usbmisc->base + MX7D_USB_OTG_PHY_CFG2);
|
||||
writel(val & ~MX7D_USB_OTG_PHY_CFG2_CHRG_DCDENB,
|
||||
usbmisc->base + MX7D_USB_OTG_PHY_CFG2);
|
||||
spin_unlock_irqrestore(&usbmisc->lock, flags);
|
||||
|
||||
if (i == 100) {
|
||||
dev_err(data->dev,
|
||||
"VBUS is coming from a dedicated power supply.\n");
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int imx7d_charger_primary_detection(struct imx_usbmisc_data *data)
|
||||
{
|
||||
struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
|
||||
struct usb_phy *usb_phy = data->usb_phy;
|
||||
unsigned long flags;
|
||||
u32 val;
|
||||
|
||||
/* VDP_SRC is connected to D+ and IDM_SINK is connected to D- */
|
||||
spin_lock_irqsave(&usbmisc->lock, flags);
|
||||
val = readl(usbmisc->base + MX7D_USB_OTG_PHY_CFG2);
|
||||
val &= ~MX7D_USB_OTG_PHY_CFG2_CHRG_CHRGSEL;
|
||||
writel(val | MX7D_USB_OTG_PHY_CFG2_CHRG_VDATSRCENB0 |
|
||||
MX7D_USB_OTG_PHY_CFG2_CHRG_VDATDETENB0,
|
||||
usbmisc->base + MX7D_USB_OTG_PHY_CFG2);
|
||||
spin_unlock_irqrestore(&usbmisc->lock, flags);
|
||||
|
||||
usleep_range(1000, 2000);
|
||||
|
||||
/* Check if D- is less than VDAT_REF to determine an SDP per BC 1.2 */
|
||||
val = readl(usbmisc->base + MX7D_USB_OTG_PHY_STATUS);
|
||||
if (!(val & MX7D_USB_OTG_PHY_STATUS_CHRGDET)) {
|
||||
dev_dbg(data->dev, "It is a standard downstream port\n");
|
||||
usb_phy->chg_type = SDP_TYPE;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whole charger detection process:
|
||||
* 1. OPMODE override to be non-driving
|
||||
* 2. Data contact check
|
||||
* 3. Primary detection
|
||||
* 4. Secondary detection
|
||||
* 5. Disable charger detection
|
||||
*/
|
||||
static int imx7d_charger_detection(struct imx_usbmisc_data *data)
|
||||
{
|
||||
struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
|
||||
struct usb_phy *usb_phy = data->usb_phy;
|
||||
unsigned long flags;
|
||||
u32 val;
|
||||
int ret;
|
||||
|
||||
/* Check if vbus is valid */
|
||||
val = readl(usbmisc->base + MX7D_USB_OTG_PHY_STATUS);
|
||||
if (!(val & MX7D_USB_OTG_PHY_STATUS_VBUS_VLD)) {
|
||||
dev_err(data->dev, "vbus is error\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Keep OPMODE to be non-driving mode during the whole
|
||||
* charger detection process.
|
||||
*/
|
||||
spin_lock_irqsave(&usbmisc->lock, flags);
|
||||
val = readl(usbmisc->base + MX7D_USBNC_USB_CTRL2);
|
||||
val &= ~MX7D_USBNC_USB_CTRL2_OPMODE_OVERRIDE_MASK;
|
||||
val |= MX7D_USBNC_USB_CTRL2_OPMODE_NON_DRIVING;
|
||||
writel(val, usbmisc->base + MX7D_USBNC_USB_CTRL2);
|
||||
|
||||
val = readl(usbmisc->base + MX7D_USBNC_USB_CTRL2);
|
||||
writel(val | MX7D_USBNC_USB_CTRL2_OPMODE_OVERRIDE_EN,
|
||||
usbmisc->base + MX7D_USBNC_USB_CTRL2);
|
||||
spin_unlock_irqrestore(&usbmisc->lock, flags);
|
||||
|
||||
ret = imx7d_charger_data_contact_detect(data);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = imx7d_charger_primary_detection(data);
|
||||
if (!ret && usb_phy->chg_type != SDP_TYPE)
|
||||
ret = imx7d_charger_secondary_detection(data);
|
||||
|
||||
imx7_disable_charger_detector(data);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int usbmisc_imx7ulp_init(struct imx_usbmisc_data *data)
|
||||
{
|
||||
struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
|
||||
unsigned long flags;
|
||||
u32 reg;
|
||||
|
||||
if (data->index >= 1)
|
||||
return -EINVAL;
|
||||
|
||||
spin_lock_irqsave(&usbmisc->lock, flags);
|
||||
reg = readl(usbmisc->base);
|
||||
if (data->disable_oc) {
|
||||
reg |= MX6_BM_OVER_CUR_DIS;
|
||||
} else {
|
||||
reg &= ~MX6_BM_OVER_CUR_DIS;
|
||||
|
||||
/*
|
||||
* If the polarity is not configured keep it as setup by the
|
||||
* bootloader.
|
||||
*/
|
||||
if (data->oc_pol_configured && data->oc_pol_active_low)
|
||||
reg |= MX6_BM_OVER_CUR_POLARITY;
|
||||
else if (data->oc_pol_configured)
|
||||
reg &= ~MX6_BM_OVER_CUR_POLARITY;
|
||||
}
|
||||
/* If the polarity is not set keep it as setup by the bootlader */
|
||||
if (data->pwr_pol == 1)
|
||||
reg |= MX6_BM_PWR_POLARITY;
|
||||
|
||||
writel(reg, usbmisc->base);
|
||||
|
||||
/* SoC non-burst setting */
|
||||
reg = readl(usbmisc->base);
|
||||
writel(reg | MX6_BM_NON_BURST_SETTING, usbmisc->base);
|
||||
|
||||
if (data->hsic) {
|
||||
reg = readl(usbmisc->base);
|
||||
writel(reg | MX6_BM_UTMI_ON_CLOCK, usbmisc->base);
|
||||
|
||||
reg = readl(usbmisc->base + MX6_USB_HSIC_CTRL_OFFSET);
|
||||
reg |= MX6_BM_HSIC_EN | MX6_BM_HSIC_CLK_ON;
|
||||
writel(reg, usbmisc->base + MX6_USB_HSIC_CTRL_OFFSET);
|
||||
|
||||
/*
|
||||
* For non-HSIC controller, the autoresume is enabled
|
||||
* at MXS PHY driver (usbphy_ctrl bit18).
|
||||
*/
|
||||
reg = readl(usbmisc->base + MX7D_USBNC_USB_CTRL2);
|
||||
writel(reg | MX7D_USBNC_AUTO_RESUME,
|
||||
usbmisc->base + MX7D_USBNC_USB_CTRL2);
|
||||
} else {
|
||||
reg = readl(usbmisc->base + MX7D_USBNC_USB_CTRL2);
|
||||
reg &= ~MX7D_USB_VBUS_WAKEUP_SOURCE_MASK;
|
||||
writel(reg | MX7D_USB_VBUS_WAKEUP_SOURCE_BVALID,
|
||||
usbmisc->base + MX7D_USBNC_USB_CTRL2);
|
||||
}
|
||||
|
||||
spin_unlock_irqrestore(&usbmisc->lock, flags);
|
||||
|
||||
|
@ -659,6 +942,14 @@ static const struct usbmisc_ops imx6sx_usbmisc_ops = {
|
|||
static const struct usbmisc_ops imx7d_usbmisc_ops = {
|
||||
.init = usbmisc_imx7d_init,
|
||||
.set_wakeup = usbmisc_imx7d_set_wakeup,
|
||||
.charger_detection = imx7d_charger_detection,
|
||||
};
|
||||
|
||||
static const struct usbmisc_ops imx7ulp_usbmisc_ops = {
|
||||
.init = usbmisc_imx7ulp_init,
|
||||
.set_wakeup = usbmisc_imx7d_set_wakeup,
|
||||
.hsic_set_connect = usbmisc_imx6_hsic_set_connect,
|
||||
.hsic_set_clk = usbmisc_imx6_hsic_set_clk,
|
||||
};
|
||||
|
||||
static inline bool is_imx53_usbmisc(struct imx_usbmisc_data *data)
|
||||
|
@ -737,6 +1028,39 @@ int imx_usbmisc_hsic_set_clk(struct imx_usbmisc_data *data, bool on)
|
|||
return usbmisc->ops->hsic_set_clk(data, on);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(imx_usbmisc_hsic_set_clk);
|
||||
|
||||
int imx_usbmisc_charger_detection(struct imx_usbmisc_data *data, bool connect)
|
||||
{
|
||||
struct imx_usbmisc *usbmisc;
|
||||
struct usb_phy *usb_phy;
|
||||
int ret = 0;
|
||||
|
||||
if (!data)
|
||||
return -EINVAL;
|
||||
|
||||
usbmisc = dev_get_drvdata(data->dev);
|
||||
usb_phy = data->usb_phy;
|
||||
if (!usbmisc->ops->charger_detection)
|
||||
return -ENOTSUPP;
|
||||
|
||||
if (connect) {
|
||||
ret = usbmisc->ops->charger_detection(data);
|
||||
if (ret) {
|
||||
dev_err(data->dev,
|
||||
"Error occurs during detection: %d\n",
|
||||
ret);
|
||||
usb_phy->chg_state = USB_CHARGER_ABSENT;
|
||||
} else {
|
||||
usb_phy->chg_state = USB_CHARGER_PRESENT;
|
||||
}
|
||||
} else {
|
||||
usb_phy->chg_state = USB_CHARGER_ABSENT;
|
||||
usb_phy->chg_type = UNKNOWN_TYPE;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(imx_usbmisc_charger_detection);
|
||||
|
||||
static const struct of_device_id usbmisc_imx_dt_ids[] = {
|
||||
{
|
||||
.compatible = "fsl,imx25-usbmisc",
|
||||
|
@ -780,7 +1104,7 @@ static const struct of_device_id usbmisc_imx_dt_ids[] = {
|
|||
},
|
||||
{
|
||||
.compatible = "fsl,imx7ulp-usbmisc",
|
||||
.data = &imx7d_usbmisc_ops,
|
||||
.data = &imx7ulp_usbmisc_ops,
|
||||
},
|
||||
{ /* sentinel */ }
|
||||
};
|
||||
|
|
|
@ -67,6 +67,7 @@ struct ci_hdrc_platform_data {
|
|||
#define CI_HDRC_CONTROLLER_STOPPED_EVENT 1
|
||||
#define CI_HDRC_IMX_HSIC_ACTIVE_EVENT 2
|
||||
#define CI_HDRC_IMX_HSIC_SUSPEND_EVENT 3
|
||||
#define CI_HDRC_CONTROLLER_VBUS_EVENT 4
|
||||
int (*notify_event) (struct ci_hdrc *ci, unsigned event);
|
||||
struct regulator *reg_vbus;
|
||||
struct usb_otg_caps ci_otg_caps;
|
||||
|
|
Загрузка…
Ссылка в новой задаче