Commit 37f6c193 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Merge tag 'usb-ci-v5.8-rc1' of...

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
parents e4befc12 6dbbbccd
...@@ -18,17 +18,6 @@ config USB_CHIPIDEA ...@@ -18,17 +18,6 @@ config USB_CHIPIDEA
if 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 config USB_CHIPIDEA_UDC
bool "ChipIdea device controller" bool "ChipIdea device controller"
depends on USB_GADGET depends on USB_GADGET
...@@ -43,4 +32,30 @@ config USB_CHIPIDEA_HOST ...@@ -43,4 +32,30 @@ config USB_CHIPIDEA_HOST
help help
Say Y here to enable host controller functionality of the Say Y here to enable host controller functionality of the
ChipIdea driver. 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 endif
...@@ -8,11 +8,8 @@ ci_hdrc-$(CONFIG_USB_OTG_FSM) += otg_fsm.o ...@@ -8,11 +8,8 @@ ci_hdrc-$(CONFIG_USB_OTG_FSM) += otg_fsm.o
# Glue/Bridge layers go here # Glue/Bridge layers go here
obj-$(CONFIG_USB_CHIPIDEA) += ci_hdrc_usb2.o obj-$(CONFIG_USB_CHIPIDEA_GENERIC) += ci_hdrc_usb2.o
obj-$(CONFIG_USB_CHIPIDEA) += ci_hdrc_msm.o obj-$(CONFIG_USB_CHIPIDEA_MSM) += 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_IMX) += ci_hdrc_imx.o usbmisc_imx.o
obj-$(CONFIG_USB_CHIPIDEA_PCI) += ci_hdrc_pci.o obj-$(CONFIG_USB_CHIPIDEA_TEGRA) += ci_hdrc_tegra.o
obj-$(CONFIG_USB_CHIPIDEA_OF) += usbmisc_imx.o ci_hdrc_imx.o
obj-$(CONFIG_USB_CHIPIDEA_OF) += ci_hdrc_tegra.o
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#define TD_PAGE_COUNT 5 #define TD_PAGE_COUNT 5
#define CI_HDRC_PAGE_SIZE 4096ul /* page size for TD's */ #define CI_HDRC_PAGE_SIZE 4096ul /* page size for TD's */
#define ENDPT_MAX 32 #define ENDPT_MAX 32
#define CI_MAX_BUF_SIZE (TD_PAGE_COUNT * CI_HDRC_PAGE_SIZE)
/****************************************************************************** /******************************************************************************
* REGISTERS * REGISTERS
......
...@@ -271,6 +271,7 @@ static int ci_hdrc_imx_notify_event(struct ci_hdrc *ci, unsigned int event) ...@@ -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 device *dev = ci->dev->parent;
struct ci_hdrc_imx_data *data = dev_get_drvdata(dev); struct ci_hdrc_imx_data *data = dev_get_drvdata(dev);
int ret = 0; int ret = 0;
struct imx_usbmisc_data *mdata = data->usbmisc_data;
switch (event) { switch (event) {
case CI_HDRC_IMX_HSIC_ACTIVE_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) ...@@ -284,11 +285,19 @@ static int ci_hdrc_imx_notify_event(struct ci_hdrc *ci, unsigned int event)
} }
break; break;
case CI_HDRC_IMX_HSIC_SUSPEND_EVENT: 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) if (ret)
dev_err(dev, dev_err(dev,
"hsic_set_connect failed, err=%d\n", ret); "hsic_set_connect failed, err=%d\n", ret);
break; 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: default:
break; break;
} }
...@@ -414,6 +423,8 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev) ...@@ -414,6 +423,8 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
} }
pdata.usb_phy = data->phy; 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") || if ((of_device_is_compatible(np, "fsl,imx53-usb") ||
of_device_is_compatible(np, "fsl,imx51-usb")) && pdata.usb_phy && of_device_is_compatible(np, "fsl,imx51-usb")) && pdata.usb_phy &&
......
...@@ -24,6 +24,7 @@ struct imx_usbmisc_data { ...@@ -24,6 +24,7 @@ struct imx_usbmisc_data {
unsigned int hsic:1; /* HSIC controlller */ unsigned int hsic:1; /* HSIC controlller */
unsigned int ext_id:1; /* ID from exteranl event */ unsigned int ext_id:1; /* ID from exteranl event */
unsigned int ext_vbus:1; /* Vbus 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); int imx_usbmisc_init(struct imx_usbmisc_data *data);
...@@ -31,5 +32,6 @@ int imx_usbmisc_init_post(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_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_connect(struct imx_usbmisc_data *data);
int imx_usbmisc_hsic_set_clk(struct imx_usbmisc_data *data, bool on); 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 */ #endif /* __DRIVER_USB_CHIPIDEA_CI_HDRC_IMX_H */
...@@ -28,13 +28,19 @@ static const struct ci_hdrc_platform_data ci_default_pdata = { ...@@ -28,13 +28,19 @@ static const struct ci_hdrc_platform_data ci_default_pdata = {
.flags = CI_HDRC_DISABLE_STREAMING, .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, .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[] = { static const struct of_device_id ci_hdrc_usb2_of_match[] = {
{ .compatible = "chipidea,usb2"}, { .compatible = "chipidea,usb2" },
{ .compatible = "xlnx,zynq-usb-2.20a", .data = &ci_zynq_pdata}, { .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); MODULE_DEVICE_TABLE(of, ci_hdrc_usb2_of_match);
...@@ -64,13 +70,14 @@ static int ci_hdrc_usb2_probe(struct platform_device *pdev) ...@@ -64,13 +70,14 @@ static int ci_hdrc_usb2_probe(struct platform_device *pdev)
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;
priv->clk = devm_clk_get(dev, NULL); priv->clk = devm_clk_get_optional(dev, NULL);
if (!IS_ERR(priv->clk)) { if (IS_ERR(priv->clk))
ret = clk_prepare_enable(priv->clk); return PTR_ERR(priv->clk);
if (ret) {
dev_err(dev, "failed to enable the clock: %d\n", ret); ret = clk_prepare_enable(priv->clk);
return ret; if (ret) {
} dev_err(dev, "failed to enable the clock: %d\n", ret);
return ret;
} }
ci_pdata->name = dev_name(dev); ci_pdata->name = dev_name(dev);
...@@ -94,8 +101,7 @@ static int ci_hdrc_usb2_probe(struct platform_device *pdev) ...@@ -94,8 +101,7 @@ static int ci_hdrc_usb2_probe(struct platform_device *pdev)
return 0; return 0;
clk_err: clk_err:
if (!IS_ERR(priv->clk)) clk_disable_unprepare(priv->clk);
clk_disable_unprepare(priv->clk);
return ret; return ret;
} }
......
// 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 @@ ...@@ -3,42 +3,16 @@
* core.c - ChipIdea USB IP core family device controller * core.c - ChipIdea USB IP core family device controller
* *
* Copyright (C) 2008 Chipidea - MIPS Technologies, Inc. All rights reserved. * Copyright (C) 2008 Chipidea - MIPS Technologies, Inc. All rights reserved.
* Copyright (C) 2020 NXP
* *
* Author: David Lopo * Author: David Lopo
*/ * Peter Chen <peter.chen@nxp.com>
/*
* Description: ChipIdea USB IP core family device controller
*
* 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 * Main Features:
* - STALL_IN: non-empty bulk-in pipes cannot be halted * - Four transfers are supported, usbtest is passed
* if defined mass storage compliance succeeds but with warnings * - USB Certification for gadget: CH9 and Mass Storage are passed
* => case 4: Hi > Dn * - Low power mode
* => case 5: Hi > Di * - USB wakeup
* => 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
*/ */
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/device.h> #include <linux/device.h>
...@@ -272,7 +246,7 @@ static int hw_device_init(struct ci_hdrc *ci, void __iomem *base) ...@@ -272,7 +246,7 @@ static int hw_device_init(struct ci_hdrc *ci, void __iomem *base)
ci->rev = ci_get_revision(ci); ci->rev = ci_get_revision(ci);
dev_dbg(ci->dev, 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); ci->rev, ci->hw_bank.lpm, ci->hw_bank.cap, ci->hw_bank.op);
/* setup lock mode ? */ /* setup lock mode ? */
...@@ -666,6 +640,7 @@ static int ci_usb_role_switch_set(struct usb_role_switch *sw, ...@@ -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 = { static struct usb_role_switch_desc ci_role_switch = {
.set = ci_usb_role_switch_set, .set = ci_usb_role_switch_set,
.get = ci_usb_role_switch_get, .get = ci_usb_role_switch_get,
.allow_userspace_control = true,
}; };
static int ci_get_platdata(struct device *dev, static int ci_get_platdata(struct device *dev,
...@@ -1149,8 +1124,11 @@ static int ci_hdrc_probe(struct platform_device *pdev) ...@@ -1149,8 +1124,11 @@ static int ci_hdrc_probe(struct platform_device *pdev)
if (!ci_otg_is_fsm_mode(ci)) { if (!ci_otg_is_fsm_mode(ci)) {
/* only update vbus status for peripheral */ /* 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); ci_handle_vbus_change(ci);
}
ret = ci_role_start(ci, ci->role); ret = ci_role_start(ci, ci->role);
if (ret) { if (ret) {
......
...@@ -338,7 +338,7 @@ static int hw_usb_reset(struct ci_hdrc *ci) ...@@ -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, 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; int i;
u32 temp; u32 temp;
...@@ -366,7 +366,13 @@ static int add_td_to_list(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq, ...@@ -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)); 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) { if (length) {
node->ptr->page[0] = cpu_to_le32(temp); node->ptr->page[0] = cpu_to_le32(temp);
for (i = 1; i < TD_PAGE_COUNT; i++) { for (i = 1; i < TD_PAGE_COUNT; i++) {
...@@ -400,6 +406,122 @@ static inline u8 _usb_addr(struct ci_hw_ep *ep) ...@@ -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; 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 * _hardware_enqueue: configures a request at hardware level
* @hwep: endpoint * @hwep: endpoint
...@@ -411,8 +533,6 @@ static int _hardware_enqueue(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq) ...@@ -411,8 +533,6 @@ static int _hardware_enqueue(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq)
{ {
struct ci_hdrc *ci = hwep->ci; struct ci_hdrc *ci = hwep->ci;
int ret = 0; int ret = 0;
unsigned rest = hwreq->req.length;
int pages = TD_PAGE_COUNT;
struct td_node *firstnode, *lastnode; struct td_node *firstnode, *lastnode;
/* don't queue twice */ /* don't queue twice */
...@@ -426,35 +546,13 @@ static int _hardware_enqueue(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq) ...@@ -426,35 +546,13 @@ static int _hardware_enqueue(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq)
if (ret) if (ret)
return ret; return ret;
/* if (hwreq->req.num_mapped_sgs)
* The first buffer could be not page aligned. ret = prepare_td_for_sg(hwep, hwreq);
* In that case we have to span into one extra td. else
*/ ret = prepare_td_for_non_sg(hwep, hwreq);
if (hwreq->req.dma % PAGE_SIZE)
pages--;
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 if (ret)
&& (hwreq->req.length % hwep->ep.maxpacket == 0)) { return ret;
ret = add_td_to_list(hwep, hwreq, 0);
if (ret < 0)
goto done;
}
firstnode = list_first_entry(&hwreq->tds, struct td_node, td); 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) ...@@ -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); struct ci_hdrc *ci = container_of(_gadget, struct ci_hdrc, gadget);
unsigned long flags; unsigned long flags;
int ret = 0;
spin_lock_irqsave(&ci->lock, flags); spin_lock_irqsave(&ci->lock, flags);
ci->vbus_active = is_active; ci->vbus_active = is_active;
...@@ -1570,10 +1669,14 @@ static int ci_udc_vbus_session(struct usb_gadget *_gadget, int 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_phy_set_charger_state(ci->usb_phy, is_active ?
USB_CHARGER_PRESENT : USB_CHARGER_ABSENT); 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) if (ci->driver)
ci_hdrc_gadget_connect(_gadget, is_active); ci_hdrc_gadget_connect(_gadget, is_active);
return 0; return ret;
} }
static int ci_udc_wakeup(struct usb_gadget *_gadget) static int ci_udc_wakeup(struct usb_gadget *_gadget)
...@@ -1936,6 +2039,7 @@ static int udc_start(struct ci_hdrc *ci) ...@@ -1936,6 +2039,7 @@ static int udc_start(struct ci_hdrc *ci)
ci->gadget.max_speed = USB_SPEED_HIGH; ci->gadget.max_speed = USB_SPEED_HIGH;
ci->gadget.name = ci->platdata->name; ci->gadget.name = ci->platdata->name;
ci->gadget.otg_caps = otg_caps; ci->gadget.otg_caps = otg_caps;
ci->gadget.sg_supported = 1;
if (ci->platdata->flags & CI_HDRC_REQUIRES_ALIGNED_DMA) if (ci->platdata->flags & CI_HDRC_REQUIRES_ALIGNED_DMA)
ci->gadget.quirk_avoids_skb_reserve = 1; ci->gadget.quirk_avoids_skb_reserve = 1;
......
...@@ -61,16 +61,14 @@ struct td_node { ...@@ -61,16 +61,14 @@ struct td_node {
struct list_head td; struct list_head td;
dma_addr_t dma; dma_addr_t dma;
struct ci_hw_td *ptr; struct ci_hw_td *ptr;
int td_remaining_size;
}; };
/** /**
* struct ci_hw_req - usb request representation * struct ci_hw_req - usb request representation
* @req: request structure for gadget drivers * @req: request structure for gadget drivers
* @queue: link to QH list * @queue: link to QH list
* @ptr: transfer descriptor for this request * @tds: link to TD list
* @dma: dma address for the transfer descriptor
* @zptr: transfer descriptor for the zero packet
* @zdma: dma address of the zero packet's transfer descriptor
*/ */
struct ci_hw_req { struct ci_hw_req {
struct usb_request req; struct usb_request req;
......
This diff is collapsed.
...@@ -67,6 +67,7 @@ struct ci_hdrc_platform_data { ...@@ -67,6 +67,7 @@ struct ci_hdrc_platform_data {
#define CI_HDRC_CONTROLLER_STOPPED_EVENT 1 #define CI_HDRC_CONTROLLER_STOPPED_EVENT 1
#define CI_HDRC_IMX_HSIC_ACTIVE_EVENT 2 #define CI_HDRC_IMX_HSIC_ACTIVE_EVENT 2
#define CI_HDRC_IMX_HSIC_SUSPEND_EVENT 3 #define CI_HDRC_IMX_HSIC_SUSPEND_EVENT 3
#define CI_HDRC_CONTROLLER_VBUS_EVENT 4
int (*notify_event) (struct ci_hdrc *ci, unsigned event); int (*notify_event) (struct ci_hdrc *ci, unsigned event);
struct regulator *reg_vbus; struct regulator *reg_vbus;
struct usb_otg_caps ci_otg_caps; struct usb_otg_caps ci_otg_caps;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment