Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e47d9254 authored by Antoine Tenart's avatar Antoine Tenart Committed by Felipe Balbi
Browse files

usb: move the OTG state from the USB PHY to the OTG structure



Before using the PHY framework instead of the USB PHY one, we need to
move the OTG state into another place, since it won't be available when
USB PHY isn't used. This patch moves the OTG state into the OTG
structure, and makes all the needed modifications in the drivers
using the OTG state.

[ balbi@ti.com : fix build regressions with phy-tahvo.c, musb_dsps.c,
		phy-isp1301-omap, and chipidea's debug.c ]

Acked-by: default avatarKishon Vijay Abraham I <kishon@ti.com>
Acked-by: default avatarPeter Chen <peter.chen@freescale.com>
Signed-off-by: default avatarAntoine Tenart <antoine.tenart@free-electrons.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent a2655e4a
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -80,11 +80,9 @@ static int omap_usb_start_srp(struct usb_otg *otg)

static int omap_usb_set_host(struct usb_otg *otg, struct usb_bus *host)
{
	struct usb_phy	*phy = otg->phy;

	otg->host = host;
	if (!host)
		phy->state = OTG_STATE_UNDEFINED;
		otg->state = OTG_STATE_UNDEFINED;

	return 0;
}
@@ -92,11 +90,9 @@ static int omap_usb_set_host(struct usb_otg *otg, struct usb_bus *host)
static int omap_usb_set_peripheral(struct usb_otg *otg,
		struct usb_gadget *gadget)
{
	struct usb_phy	*phy = otg->phy;

	otg->gadget = gadget;
	if (!gadget)
		phy->state = OTG_STATE_UNDEFINED;
		otg->state = OTG_STATE_UNDEFINED;

	return 0;
}
+1 −1
Original line number Diff line number Diff line
@@ -220,7 +220,7 @@ static int ci_otg_show(struct seq_file *s, void *unused)

	/* ------ State ----- */
	seq_printf(s, "OTG state: %s\n\n",
		usb_otg_state_string(ci->transceiver->state));
		usb_otg_state_string(ci->transceiver->otg->state));

	/* ------ State Machine Variables ----- */
	seq_printf(s, "a_bus_drop: %d\n", fsm->a_bus_drop);
+6 −6
Original line number Diff line number Diff line
@@ -328,7 +328,7 @@ static void b_ssend_srp_tmout_func(void *ptr, unsigned long indicator)
	set_tmout(ci, indicator);

	/* only vbus fall below B_sess_vld in b_idle state */
	if (ci->transceiver->state == OTG_STATE_B_IDLE)
	if (ci->fsm.otg->state == OTG_STATE_B_IDLE)
		ci_otg_queue_work(ci);
}

@@ -582,11 +582,11 @@ int ci_otg_fsm_work(struct ci_hdrc *ci)
	 * when there is no gadget class driver
	 */
	if (ci->fsm.id && !(ci->driver) &&
		ci->transceiver->state < OTG_STATE_A_IDLE)
		ci->fsm.otg->state < OTG_STATE_A_IDLE)
		return 0;

	if (otg_statemachine(&ci->fsm)) {
		if (ci->transceiver->state == OTG_STATE_A_IDLE) {
		if (ci->fsm.otg->state == OTG_STATE_A_IDLE) {
			/*
			 * Further state change for cases:
			 * a_idle to b_idle; or
@@ -600,7 +600,7 @@ int ci_otg_fsm_work(struct ci_hdrc *ci)
				ci_otg_queue_work(ci);
			if (ci->id_event)
				ci->id_event = false;
		} else if (ci->transceiver->state == OTG_STATE_B_IDLE) {
		} else if (ci->fsm.otg->state == OTG_STATE_B_IDLE) {
			if (ci->fsm.b_sess_vld) {
				ci->fsm.power_up = 0;
				/*
@@ -627,7 +627,7 @@ static void ci_otg_fsm_event(struct ci_hdrc *ci)
	otg_bsess_vld = hw_read_otgsc(ci, OTGSC_BSV);
	port_conn = hw_read(ci, OP_PORTSC, PORTSC_CCS);

	switch (ci->transceiver->state) {
	switch (ci->fsm.otg->state) {
	case OTG_STATE_A_WAIT_BCON:
		if (port_conn) {
			fsm->b_conn = 1;
@@ -794,7 +794,7 @@ int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci)
	ci->transceiver->otg = ci->fsm.otg;
	ci->fsm.power_up = 1;
	ci->fsm.id = hw_read_otgsc(ci, OTGSC_ID) ? 1 : 0;
	ci->transceiver->state = OTG_STATE_UNDEFINED;
	ci->fsm.otg->state = OTG_STATE_UNDEFINED;
	ci->fsm.ops = &ci_otg_ops;

	mutex_init(&ci->fsm.lock);
+4 −4
Original line number Diff line number Diff line
@@ -124,10 +124,10 @@ static void otg_leave_state(struct otg_fsm *fsm, enum usb_otg_state old_state)
static int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state)
{
	state_changed = 1;
	if (fsm->otg->phy->state == new_state)
	if (fsm->otg->state == new_state)
		return 0;
	VDBG("Set state: %s\n", usb_otg_state_string(new_state));
	otg_leave_state(fsm, fsm->otg->phy->state);
	otg_leave_state(fsm, fsm->otg->state);
	switch (new_state) {
	case OTG_STATE_B_IDLE:
		otg_drv_vbus(fsm, 0);
@@ -236,7 +236,7 @@ static int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state)
		break;
	}

	fsm->otg->phy->state = new_state;
	fsm->otg->state = new_state;
	return 0;
}

@@ -247,7 +247,7 @@ int otg_statemachine(struct otg_fsm *fsm)

	mutex_lock(&fsm->lock);

	state = fsm->otg->phy->state;
	state = fsm->otg->state;
	state_changed = 0;
	/* State machine state change judgement */

+1 −1
Original line number Diff line number Diff line
@@ -183,7 +183,7 @@ static void start_hnp(struct ohci_hcd *ohci)
	otg_start_hnp(hcd->usb_phy->otg);

	local_irq_save(flags);
	hcd->usb_phy->state = OTG_STATE_A_SUSPEND;
	hcd->usb_phy->otg.state = OTG_STATE_A_SUSPEND;
	writel (RH_PS_PSS, &ohci->regs->roothub.portstatus [port]);
	l = omap_readl(OTG_CTRL);
	l &= ~OTG_A_BUSREQ;
Loading