Re: [RFC PATCH 1/1] usb: phy: move usb_otg_state from struct usb_phy to struct usb_otg

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Fri, Aug 10, 2012 at 06:32:36AM +0000, Chen Peter-B29397 wrote:
> > > According to USB_OTG_and_EH_2-0-final_plus_errata_and_ecn_20110714 -
> > final.pdf
> > > Chapter7.1, 7,2. The states at enum usb_otg_state are all OTG state.
> > >
> > > If you think others (except for A_DEVICE and B_HOST) are not otg-
> > specific states,
> > > then what are they?
> > 
> > granted, they were defined on the OTG spec, but if you think about them,
> > every peripheral usb controller starts on B_IDLE state.
> > 
> > The OTG spec also says that any device can start SRP and any host can
> > reply to that, not only OTG-capable devices; which means that B_SRP_INIT
> > also applies to any device.
> > 
> > B_PERIPHERAL applies to any device which gets enumerated.
> > 
> > B_WAIT_ACON also applies to any device; it's that small timeframe where
> > your device is ready and just waits for host.
> > 
> > A_IDLE it's when your host is fully initialized but has no
> > devices attached to it.
> > 
> > A_WAIT_VRISE and A_WAIT_VFALL is applicable to any hosts which can
> > control their charge pumps.
> > 
> > A_WAIT_BCON is applicable to any host
> > 
> > A_HOST is the normal operation of a host when it enumerated a device
> > 
> > A_SUSPEND applies to any host. It's when it drives bus suspend
> > signalling on the bus
> > 
> > A_VBUS_ERR is that state when you just caught overcurrent.
> > 
> 
> So, the others are usb_state not usb_otg_state. Then, when we generalize
> otg driver, what kinds of **states** do you plan to use to stand for otg
> state machine? Besides, if we name something different with spec, does it
> will confuse the users?

We could have just a single enum usb_state defined something like:

enum usb_otg_state {
	USB_STATE_UNDEFINED = 0,

	/* single-role peripheral, and dual-role default-b */
	USB_STATE_B_IDLE,
	USB_STATE_B_SRP_INIT,
	USB_STATE_B_PERIPHERAL,

	/* single-role host, and dual-role default-a */
	USB_STATE_A_IDLE,
	USB_STATE_A_WAIT_VRISE,
	USB_STATE_A_WAIT_BCON,
	USB_STATE_A_HOST,
	USB_STATE_A_SUSPEND,
	USB_STATE_A_WAIT_VFALL,
	USB_STATE_A_VBUS_ERR,

#ifdef CONFIG_USB_OTG
	/* extra dual-role default-b states */
	USB_STATE_B_WAIT_ACON,
	USB_STATE_B_HOST,
	USB_STATE_A_PERIPHERAL,
#endif /* CONFIG_USB_OTG
};

or something similar. Then we shouldn't allow anyone to access
phy->state directly, so we would need:

static inline void usb_phy_set_state(struct usb_phy *phy,
	enum usb_state state)
{
	phy->state = state;
}

static inline enum usb_state usb_phy_get_state(struct usb_phy *phy)
{
	return phy->state;
}

-- 
balbi

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux