Commit 7e062c0f authored by Heikki Krogerus's avatar Heikki Krogerus Committed by Felipe Balbi

usb: otg: fsl: Start using struct usb_otg

Use struct usb_otg members with OTG specific functions instead
of usb_phy members.
Signed-off-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
Acked-by: default avatarLi Yang <leoli@freescale.com>
Reviewed-by: default avatarMarek Vasut <marek.vasut@gmail.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 144713f3
...@@ -275,7 +275,7 @@ void b_srp_end(unsigned long foo) ...@@ -275,7 +275,7 @@ void b_srp_end(unsigned long foo)
fsl_otg_dischrg_vbus(0); fsl_otg_dischrg_vbus(0);
srp_wait_done = 1; srp_wait_done = 1;
if ((fsl_otg_dev->otg.state == OTG_STATE_B_SRP_INIT) && if ((fsl_otg_dev->phy.state == OTG_STATE_B_SRP_INIT) &&
fsl_otg_dev->fsm.b_sess_vld) fsl_otg_dev->fsm.b_sess_vld)
fsl_otg_dev->fsm.b_srp_done = 1; fsl_otg_dev->fsm.b_srp_done = 1;
} }
...@@ -288,7 +288,7 @@ void b_srp_end(unsigned long foo) ...@@ -288,7 +288,7 @@ void b_srp_end(unsigned long foo)
void a_wait_enum(unsigned long foo) void a_wait_enum(unsigned long foo)
{ {
VDBG("a_wait_enum timeout\n"); VDBG("a_wait_enum timeout\n");
if (!fsl_otg_dev->otg.host->b_hnp_enable) if (!fsl_otg_dev->phy.otg->host->b_hnp_enable)
fsl_otg_add_timer(a_wait_enum_tmr); fsl_otg_add_timer(a_wait_enum_tmr);
else else
otg_statemachine(&fsl_otg_dev->fsm); otg_statemachine(&fsl_otg_dev->fsm);
...@@ -452,14 +452,14 @@ void otg_reset_controller(void) ...@@ -452,14 +452,14 @@ void otg_reset_controller(void)
/* Call suspend/resume routines in host driver */ /* Call suspend/resume routines in host driver */
int fsl_otg_start_host(struct otg_fsm *fsm, int on) int fsl_otg_start_host(struct otg_fsm *fsm, int on)
{ {
struct usb_phy *xceiv = fsm->transceiver; struct usb_otg *otg = fsm->otg;
struct device *dev; struct device *dev;
struct fsl_otg *otg_dev = container_of(xceiv, struct fsl_otg, otg); struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy);
u32 retval = 0; u32 retval = 0;
if (!xceiv->host) if (!otg->host)
return -ENODEV; return -ENODEV;
dev = xceiv->host->controller; dev = otg->host->controller;
/* /*
* Update a_vbus_vld state as a_vbus_vld int is disabled * Update a_vbus_vld state as a_vbus_vld int is disabled
...@@ -518,14 +518,14 @@ int fsl_otg_start_host(struct otg_fsm *fsm, int on) ...@@ -518,14 +518,14 @@ int fsl_otg_start_host(struct otg_fsm *fsm, int on)
*/ */
int fsl_otg_start_gadget(struct otg_fsm *fsm, int on) int fsl_otg_start_gadget(struct otg_fsm *fsm, int on)
{ {
struct usb_phy *xceiv = fsm->transceiver; struct usb_otg *otg = fsm->otg;
struct device *dev; struct device *dev;
if (!xceiv->gadget || !xceiv->gadget->dev.parent) if (!otg->gadget || !otg->gadget->dev.parent)
return -ENODEV; return -ENODEV;
VDBG("gadget %s\n", on ? "on" : "off"); VDBG("gadget %s\n", on ? "on" : "off");
dev = xceiv->gadget->dev.parent; dev = otg->gadget->dev.parent;
if (on) { if (on) {
if (dev->driver->resume) if (dev->driver->resume)
...@@ -542,14 +542,14 @@ int fsl_otg_start_gadget(struct otg_fsm *fsm, int on) ...@@ -542,14 +542,14 @@ int fsl_otg_start_gadget(struct otg_fsm *fsm, int on)
* Called by initialization code of host driver. Register host controller * Called by initialization code of host driver. Register host controller
* to the OTG. Suspend host for OTG role detection. * to the OTG. Suspend host for OTG role detection.
*/ */
static int fsl_otg_set_host(struct usb_phy *otg_p, struct usb_bus *host) static int fsl_otg_set_host(struct usb_otg *otg, struct usb_bus *host)
{ {
struct fsl_otg *otg_dev = container_of(otg_p, struct fsl_otg, otg); struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy);
if (!otg_p || otg_dev != fsl_otg_dev) if (!otg || otg_dev != fsl_otg_dev)
return -ENODEV; return -ENODEV;
otg_p->host = host; otg->host = host;
otg_dev->fsm.a_bus_drop = 0; otg_dev->fsm.a_bus_drop = 0;
otg_dev->fsm.a_bus_req = 1; otg_dev->fsm.a_bus_req = 1;
...@@ -557,8 +557,8 @@ static int fsl_otg_set_host(struct usb_phy *otg_p, struct usb_bus *host) ...@@ -557,8 +557,8 @@ static int fsl_otg_set_host(struct usb_phy *otg_p, struct usb_bus *host)
if (host) { if (host) {
VDBG("host off......\n"); VDBG("host off......\n");
otg_p->host->otg_port = fsl_otg_initdata.otg_port; otg->host->otg_port = fsl_otg_initdata.otg_port;
otg_p->host->is_b_host = otg_dev->fsm.id; otg->host->is_b_host = otg_dev->fsm.id;
/* /*
* must leave time for khubd to finish its thing * must leave time for khubd to finish its thing
* before yanking the host driver out from under it, * before yanking the host driver out from under it,
...@@ -574,7 +574,7 @@ static int fsl_otg_set_host(struct usb_phy *otg_p, struct usb_bus *host) ...@@ -574,7 +574,7 @@ static int fsl_otg_set_host(struct usb_phy *otg_p, struct usb_bus *host)
/* Mini-A cable connected */ /* Mini-A cable connected */
struct otg_fsm *fsm = &otg_dev->fsm; struct otg_fsm *fsm = &otg_dev->fsm;
otg_p->state = OTG_STATE_UNDEFINED; otg->phy->state = OTG_STATE_UNDEFINED;
fsm->protocol = PROTO_UNDEF; fsm->protocol = PROTO_UNDEF;
} }
} }
...@@ -587,29 +587,29 @@ static int fsl_otg_set_host(struct usb_phy *otg_p, struct usb_bus *host) ...@@ -587,29 +587,29 @@ static int fsl_otg_set_host(struct usb_phy *otg_p, struct usb_bus *host)
} }
/* Called by initialization code of udc. Register udc to OTG. */ /* Called by initialization code of udc. Register udc to OTG. */
static int fsl_otg_set_peripheral(struct usb_phy *otg_p, static int fsl_otg_set_peripheral(struct usb_otg *otg,
struct usb_gadget *gadget) struct usb_gadget *gadget)
{ {
struct fsl_otg *otg_dev = container_of(otg_p, struct fsl_otg, otg); struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy);
VDBG("otg_dev 0x%x\n", (int)otg_dev); VDBG("otg_dev 0x%x\n", (int)otg_dev);
VDBG("fsl_otg_dev 0x%x\n", (int)fsl_otg_dev); VDBG("fsl_otg_dev 0x%x\n", (int)fsl_otg_dev);
if (!otg_p || otg_dev != fsl_otg_dev) if (!otg || otg_dev != fsl_otg_dev)
return -ENODEV; return -ENODEV;
if (!gadget) { if (!gadget) {
if (!otg_dev->otg.default_a) if (!otg->default_a)
otg_p->gadget->ops->vbus_draw(otg_p->gadget, 0); otg->gadget->ops->vbus_draw(otg->gadget, 0);
usb_gadget_vbus_disconnect(otg_dev->otg.gadget); usb_gadget_vbus_disconnect(otg->gadget);
otg_dev->otg.gadget = 0; otg->gadget = 0;
otg_dev->fsm.b_bus_req = 0; otg_dev->fsm.b_bus_req = 0;
otg_statemachine(&otg_dev->fsm); otg_statemachine(&otg_dev->fsm);
return 0; return 0;
} }
otg_p->gadget = gadget; otg->gadget = gadget;
otg_p->gadget->is_a_peripheral = !otg_dev->fsm.id; otg->gadget->is_a_peripheral = !otg_dev->fsm.id;
otg_dev->fsm.b_bus_req = 1; otg_dev->fsm.b_bus_req = 1;
...@@ -625,11 +625,11 @@ static int fsl_otg_set_peripheral(struct usb_phy *otg_p, ...@@ -625,11 +625,11 @@ static int fsl_otg_set_peripheral(struct usb_phy *otg_p,
} }
/* Set OTG port power, only for B-device */ /* Set OTG port power, only for B-device */
static int fsl_otg_set_power(struct usb_phy *otg_p, unsigned mA) static int fsl_otg_set_power(struct usb_phy *phy, unsigned mA)
{ {
if (!fsl_otg_dev) if (!fsl_otg_dev)
return -ENODEV; return -ENODEV;
if (otg_p->state == OTG_STATE_B_PERIPHERAL) if (phy->state == OTG_STATE_B_PERIPHERAL)
pr_info("FSL OTG: Draw %d mA\n", mA); pr_info("FSL OTG: Draw %d mA\n", mA);
return 0; return 0;
...@@ -658,12 +658,12 @@ static void fsl_otg_event(struct work_struct *work) ...@@ -658,12 +658,12 @@ static void fsl_otg_event(struct work_struct *work)
} }
/* B-device start SRP */ /* B-device start SRP */
static int fsl_otg_start_srp(struct usb_phy *otg_p) static int fsl_otg_start_srp(struct usb_otg *otg)
{ {
struct fsl_otg *otg_dev = container_of(otg_p, struct fsl_otg, otg); struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy);
if (!otg_p || otg_dev != fsl_otg_dev if (!otg || otg_dev != fsl_otg_dev
|| otg_p->state != OTG_STATE_B_IDLE) || otg->phy->state != OTG_STATE_B_IDLE)
return -ENODEV; return -ENODEV;
otg_dev->fsm.b_bus_req = 1; otg_dev->fsm.b_bus_req = 1;
...@@ -673,11 +673,11 @@ static int fsl_otg_start_srp(struct usb_phy *otg_p) ...@@ -673,11 +673,11 @@ static int fsl_otg_start_srp(struct usb_phy *otg_p)
} }
/* A_host suspend will call this function to start hnp */ /* A_host suspend will call this function to start hnp */
static int fsl_otg_start_hnp(struct usb_phy *otg_p) static int fsl_otg_start_hnp(struct usb_otg *otg)
{ {
struct fsl_otg *otg_dev = container_of(otg_p, struct fsl_otg, otg); struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy);
if (!otg_p || otg_dev != fsl_otg_dev) if (!otg || otg_dev != fsl_otg_dev)
return -ENODEV; return -ENODEV;
DBG("start_hnp...n"); DBG("start_hnp...n");
...@@ -698,7 +698,7 @@ static int fsl_otg_start_hnp(struct usb_phy *otg_p) ...@@ -698,7 +698,7 @@ static int fsl_otg_start_hnp(struct usb_phy *otg_p)
irqreturn_t fsl_otg_isr(int irq, void *dev_id) irqreturn_t fsl_otg_isr(int irq, void *dev_id)
{ {
struct otg_fsm *fsm = &((struct fsl_otg *)dev_id)->fsm; struct otg_fsm *fsm = &((struct fsl_otg *)dev_id)->fsm;
struct usb_phy *otg = &((struct fsl_otg *)dev_id)->otg; struct usb_otg *otg = ((struct fsl_otg *)dev_id)->phy.otg;
u32 otg_int_src, otg_sc; u32 otg_int_src, otg_sc;
otg_sc = fsl_readl(&usb_dr_regs->otgsc); otg_sc = fsl_readl(&usb_dr_regs->otgsc);
...@@ -774,6 +774,12 @@ static int fsl_otg_conf(struct platform_device *pdev) ...@@ -774,6 +774,12 @@ static int fsl_otg_conf(struct platform_device *pdev)
if (!fsl_otg_tc) if (!fsl_otg_tc)
return -ENOMEM; return -ENOMEM;
fsl_otg_tc->phy.otg = kzalloc(sizeof(struct usb_otg), GFP_KERNEL);
if (!fsl_otg_tc->phy.otg) {
kfree(fsl_otg_tc);
return -ENOMEM;
}
INIT_DELAYED_WORK(&fsl_otg_tc->otg_event, fsl_otg_event); INIT_DELAYED_WORK(&fsl_otg_tc->otg_event, fsl_otg_event);
INIT_LIST_HEAD(&active_timers); INIT_LIST_HEAD(&active_timers);
...@@ -788,17 +794,19 @@ static int fsl_otg_conf(struct platform_device *pdev) ...@@ -788,17 +794,19 @@ static int fsl_otg_conf(struct platform_device *pdev)
fsl_otg_tc->fsm.ops = &fsl_otg_ops; fsl_otg_tc->fsm.ops = &fsl_otg_ops;
/* initialize the otg structure */ /* initialize the otg structure */
fsl_otg_tc->otg.label = DRIVER_DESC; fsl_otg_tc->phy.label = DRIVER_DESC;
fsl_otg_tc->otg.set_host = fsl_otg_set_host; fsl_otg_tc->phy.set_power = fsl_otg_set_power;
fsl_otg_tc->otg.set_peripheral = fsl_otg_set_peripheral;
fsl_otg_tc->otg.set_power = fsl_otg_set_power; fsl_otg_tc->phy.otg->phy = &fsl_otg_tc->phy;
fsl_otg_tc->otg.start_hnp = fsl_otg_start_hnp; fsl_otg_tc->phy.otg->set_host = fsl_otg_set_host;
fsl_otg_tc->otg.start_srp = fsl_otg_start_srp; fsl_otg_tc->phy.otg->set_peripheral = fsl_otg_set_peripheral;
fsl_otg_tc->phy.otg->start_hnp = fsl_otg_start_hnp;
fsl_otg_tc->phy.otg->start_srp = fsl_otg_start_srp;
fsl_otg_dev = fsl_otg_tc; fsl_otg_dev = fsl_otg_tc;
/* Store the otg transceiver */ /* Store the otg transceiver */
status = otg_set_transceiver(&fsl_otg_tc->otg); status = usb_set_transceiver(&fsl_otg_tc->phy);
if (status) { if (status) {
pr_warn(FSL_OTG_NAME ": unable to register OTG transceiver.\n"); pr_warn(FSL_OTG_NAME ": unable to register OTG transceiver.\n");
goto err; goto err;
...@@ -807,6 +815,7 @@ static int fsl_otg_conf(struct platform_device *pdev) ...@@ -807,6 +815,7 @@ static int fsl_otg_conf(struct platform_device *pdev)
return 0; return 0;
err: err:
fsl_otg_uninit_timers(); fsl_otg_uninit_timers();
kfree(fsl_otg_tc->phy.otg);
kfree(fsl_otg_tc); kfree(fsl_otg_tc);
return status; return status;
} }
...@@ -815,19 +824,19 @@ static int fsl_otg_conf(struct platform_device *pdev) ...@@ -815,19 +824,19 @@ static int fsl_otg_conf(struct platform_device *pdev)
int usb_otg_start(struct platform_device *pdev) int usb_otg_start(struct platform_device *pdev)
{ {
struct fsl_otg *p_otg; struct fsl_otg *p_otg;
struct usb_phy *otg_trans = otg_get_transceiver(); struct usb_phy *otg_trans = usb_get_transceiver();
struct otg_fsm *fsm; struct otg_fsm *fsm;
int status; int status;
struct resource *res; struct resource *res;
u32 temp; u32 temp;
struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data; struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data;
p_otg = container_of(otg_trans, struct fsl_otg, otg); p_otg = container_of(otg_trans, struct fsl_otg, phy);
fsm = &p_otg->fsm; fsm = &p_otg->fsm;
/* Initialize the state machine structure with default values */ /* Initialize the state machine structure with default values */
SET_OTG_STATE(otg_trans, OTG_STATE_UNDEFINED); SET_OTG_STATE(otg_trans, OTG_STATE_UNDEFINED);
fsm->transceiver = &p_otg->otg; fsm->otg = p_otg->phy.otg;
/* We don't require predefined MEM/IRQ resource index */ /* We don't require predefined MEM/IRQ resource index */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
...@@ -857,9 +866,10 @@ int usb_otg_start(struct platform_device *pdev) ...@@ -857,9 +866,10 @@ int usb_otg_start(struct platform_device *pdev)
status = request_irq(p_otg->irq, fsl_otg_isr, status = request_irq(p_otg->irq, fsl_otg_isr,
IRQF_SHARED, driver_name, p_otg); IRQF_SHARED, driver_name, p_otg);
if (status) { if (status) {
dev_dbg(p_otg->otg.dev, "can't get IRQ %d, error %d\n", dev_dbg(p_otg->phy.dev, "can't get IRQ %d, error %d\n",
p_otg->irq, status); p_otg->irq, status);
iounmap(p_otg->dr_mem_map); iounmap(p_otg->dr_mem_map);
kfree(p_otg->phy.otg);
kfree(p_otg); kfree(p_otg);
return status; return status;
} }
...@@ -919,10 +929,10 @@ int usb_otg_start(struct platform_device *pdev) ...@@ -919,10 +929,10 @@ int usb_otg_start(struct platform_device *pdev)
* Also: record initial state of ID pin * Also: record initial state of ID pin
*/ */
if (fsl_readl(&p_otg->dr_mem_map->otgsc) & OTGSC_STS_USB_ID) { if (fsl_readl(&p_otg->dr_mem_map->otgsc) & OTGSC_STS_USB_ID) {
p_otg->otg.state = OTG_STATE_UNDEFINED; p_otg->phy.state = OTG_STATE_UNDEFINED;
p_otg->fsm.id = 1; p_otg->fsm.id = 1;
} else { } else {
p_otg->otg.state = OTG_STATE_A_IDLE; p_otg->phy.state = OTG_STATE_A_IDLE;
p_otg->fsm.id = 0; p_otg->fsm.id = 0;
} }
...@@ -978,7 +988,7 @@ static int show_fsl_usb2_otg_state(struct device *dev, ...@@ -978,7 +988,7 @@ static int show_fsl_usb2_otg_state(struct device *dev,
/* State */ /* State */
t = scnprintf(next, size, t = scnprintf(next, size,
"OTG state: %s\n\n", "OTG state: %s\n\n",
otg_state_string(fsl_otg_dev->otg.state)); otg_state_string(fsl_otg_dev->phy.state));
size -= t; size -= t;
next += t; next += t;
...@@ -1124,12 +1134,13 @@ static int __devexit fsl_otg_remove(struct platform_device *pdev) ...@@ -1124,12 +1134,13 @@ static int __devexit fsl_otg_remove(struct platform_device *pdev)
{ {
struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data; struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data;
otg_set_transceiver(NULL); usb_set_transceiver(NULL);
free_irq(fsl_otg_dev->irq, fsl_otg_dev); free_irq(fsl_otg_dev->irq, fsl_otg_dev);
iounmap((void *)usb_dr_regs); iounmap((void *)usb_dr_regs);
fsl_otg_uninit_timers(); fsl_otg_uninit_timers();
kfree(fsl_otg_dev->phy.otg);
kfree(fsl_otg_dev); kfree(fsl_otg_dev);
device_remove_file(&pdev->dev, &dev_attr_fsl_usb2_otg_state); device_remove_file(&pdev->dev, &dev_attr_fsl_usb2_otg_state);
......
...@@ -369,7 +369,7 @@ inline struct fsl_otg_timer *otg_timer_initializer ...@@ -369,7 +369,7 @@ inline struct fsl_otg_timer *otg_timer_initializer
} }
struct fsl_otg { struct fsl_otg {
struct usb_phy otg; struct usb_phy phy;
struct otg_fsm fsm; struct otg_fsm fsm;
struct usb_dr_mmap *dr_mem_map; struct usb_dr_mmap *dr_mem_map;
struct delayed_work otg_event; struct delayed_work otg_event;
......
...@@ -117,10 +117,10 @@ void otg_leave_state(struct otg_fsm *fsm, enum usb_otg_state old_state) ...@@ -117,10 +117,10 @@ void otg_leave_state(struct otg_fsm *fsm, enum usb_otg_state old_state)
int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state) int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state)
{ {
state_changed = 1; state_changed = 1;
if (fsm->transceiver->state == new_state) if (fsm->otg->phy->state == new_state)
return 0; return 0;
VDBG("Set state: %s\n", otg_state_string(new_state)); VDBG("Set state: %s\n", otg_state_string(new_state));
otg_leave_state(fsm, fsm->transceiver->state); otg_leave_state(fsm, fsm->otg->phy->state);
switch (new_state) { switch (new_state) {
case OTG_STATE_B_IDLE: case OTG_STATE_B_IDLE:
otg_drv_vbus(fsm, 0); otg_drv_vbus(fsm, 0);
...@@ -155,8 +155,8 @@ int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state) ...@@ -155,8 +155,8 @@ int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state)
otg_loc_conn(fsm, 0); otg_loc_conn(fsm, 0);
otg_loc_sof(fsm, 1); otg_loc_sof(fsm, 1);
otg_set_protocol(fsm, PROTO_HOST); otg_set_protocol(fsm, PROTO_HOST);
usb_bus_start_enum(fsm->transceiver->host, usb_bus_start_enum(fsm->otg->host,
fsm->transceiver->host->otg_port); fsm->otg->host->otg_port);
break; break;
case OTG_STATE_A_IDLE: case OTG_STATE_A_IDLE:
otg_drv_vbus(fsm, 0); otg_drv_vbus(fsm, 0);
...@@ -221,7 +221,7 @@ int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state) ...@@ -221,7 +221,7 @@ int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state)
break; break;
} }
fsm->transceiver->state = new_state; fsm->otg->phy->state = new_state;
return 0; return 0;
} }
...@@ -233,7 +233,7 @@ int otg_statemachine(struct otg_fsm *fsm) ...@@ -233,7 +233,7 @@ int otg_statemachine(struct otg_fsm *fsm)
spin_lock_irqsave(&fsm->lock, flags); spin_lock_irqsave(&fsm->lock, flags);
state = fsm->transceiver->state; state = fsm->otg->phy->state;
state_changed = 0; state_changed = 0;
/* State machine state change judgement */ /* State machine state change judgement */
...@@ -248,7 +248,7 @@ int otg_statemachine(struct otg_fsm *fsm) ...@@ -248,7 +248,7 @@ int otg_statemachine(struct otg_fsm *fsm)
case OTG_STATE_B_IDLE: case OTG_STATE_B_IDLE:
if (!fsm->id) if (!fsm->id)
otg_set_state(fsm, OTG_STATE_A_IDLE); otg_set_state(fsm, OTG_STATE_A_IDLE);
else if (fsm->b_sess_vld && fsm->transceiver->gadget) else if (fsm->b_sess_vld && fsm->otg->gadget)
otg_set_state(fsm, OTG_STATE_B_PERIPHERAL); otg_set_state(fsm, OTG_STATE_B_PERIPHERAL);
else if (fsm->b_bus_req && fsm->b_sess_end && fsm->b_se0_srp) else if (fsm->b_bus_req && fsm->b_sess_end && fsm->b_se0_srp)
otg_set_state(fsm, OTG_STATE_B_SRP_INIT); otg_set_state(fsm, OTG_STATE_B_SRP_INIT);
...@@ -260,7 +260,7 @@ int otg_statemachine(struct otg_fsm *fsm) ...@@ -260,7 +260,7 @@ int otg_statemachine(struct otg_fsm *fsm)
case OTG_STATE_B_PERIPHERAL: case OTG_STATE_B_PERIPHERAL:
if (!fsm->id || !fsm->b_sess_vld) if (!fsm->id || !fsm->b_sess_vld)
otg_set_state(fsm, OTG_STATE_B_IDLE); otg_set_state(fsm, OTG_STATE_B_IDLE);
else if (fsm->b_bus_req && fsm->transceiver-> else if (fsm->b_bus_req && fsm->otg->
gadget->b_hnp_enable && fsm->a_bus_suspend) gadget->b_hnp_enable && fsm->a_bus_suspend)
otg_set_state(fsm, OTG_STATE_B_WAIT_ACON); otg_set_state(fsm, OTG_STATE_B_WAIT_ACON);
break; break;
...@@ -302,7 +302,7 @@ int otg_statemachine(struct otg_fsm *fsm) ...@@ -302,7 +302,7 @@ int otg_statemachine(struct otg_fsm *fsm)
break; break;
case OTG_STATE_A_HOST: case OTG_STATE_A_HOST:
if ((!fsm->a_bus_req || fsm->a_suspend_req) && if ((!fsm->a_bus_req || fsm->a_suspend_req) &&
fsm->transceiver->host->b_hnp_enable) fsm->otg->host->b_hnp_enable)
otg_set_state(fsm, OTG_STATE_A_SUSPEND); otg_set_state(fsm, OTG_STATE_A_SUSPEND);
else if (fsm->id || !fsm->b_conn || fsm->a_bus_drop) else if (fsm->id || !fsm->b_conn || fsm->a_bus_drop)
otg_set_state(fsm, OTG_STATE_A_WAIT_BCON); otg_set_state(fsm, OTG_STATE_A_WAIT_BCON);
...@@ -310,9 +310,9 @@ int otg_statemachine(struct otg_fsm *fsm) ...@@ -310,9 +310,9 @@ int otg_statemachine(struct otg_fsm *fsm)
otg_set_state(fsm, OTG_STATE_A_VBUS_ERR); otg_set_state(fsm, OTG_STATE_A_VBUS_ERR);
break; break;
case OTG_STATE_A_SUSPEND: case OTG_STATE_A_SUSPEND:
if (!fsm->b_conn && fsm->transceiver->host->b_hnp_enable) if (!fsm->b_conn && fsm->otg->host->b_hnp_enable)
otg_set_state(fsm, OTG_STATE_A_PERIPHERAL); otg_set_state(fsm, OTG_STATE_A_PERIPHERAL);
else if (!fsm->b_conn && !fsm->transceiver->host->b_hnp_enable) else if (!fsm->b_conn && !fsm->otg->host->b_hnp_enable)
otg_set_state(fsm, OTG_STATE_A_WAIT_BCON); otg_set_state(fsm, OTG_STATE_A_WAIT_BCON);
else if (fsm->a_bus_req || fsm->b_bus_resume) else if (fsm->a_bus_req || fsm->b_bus_resume)
otg_set_state(fsm, OTG_STATE_A_HOST); otg_set_state(fsm, OTG_STATE_A_HOST);
......
...@@ -82,7 +82,7 @@ struct otg_fsm { ...@@ -82,7 +82,7 @@ struct otg_fsm {
int loc_sof; int loc_sof;
struct otg_fsm_ops *ops; struct otg_fsm_ops *ops;
struct usb_phy *transceiver; struct usb_otg *otg;
/* Current usb protocol used: 0:undefine; 1:host; 2:client */ /* Current usb protocol used: 0:undefine; 1:host; 2:client */
int protocol; int protocol;
......
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