On 10.05.2019 16:55, Chris Brandt wrote:
+ } else {
+ /* Not OTG, so dr_mode should be set in PHY node */
+ mode = usb_get_dr_mode(channel->dev);
+ if (mode == USB_DR_MODE_HOST)
+ writel(0x00000000, usb2_base + USB2_COMMCTRL);
+ else if (mode == USB_DR_MODE_PERIPHERAL)
+ writel(0x80000000, usb2_base + USB2_COMMCTRL);
Maybe a *switch* instead?
I like that idea because I can get rid of the dr_mode variable.
Yes. :-)
However...
I just tried it, but if I only have a case for HOST and PERIPHERAL, I
get this gcc warning:
warning: enumeration value ‘USB_DR_MODE_UNKNOWN’ not handled in switch [-Wswitch]
warning: enumeration value ‘USB_DR_MODE_OTG’ not handled in switch [-Wswitch]
So, my code would have to be:
} else {
/* Not OTG, so dr_mode should be set in PHY node */
switch (usb_get_dr_mode(channel->dev)) {
case USB_DR_MODE_HOST:
writel(0x00000000, usb2_base + USB2_COMMCTRL);
break;
case USB_DR_MODE_PERIPHERAL:
writel(0x80000000, usb2_base + USB2_COMMCTRL);
break;
case USB_DR_MODE_UNKNOWN:
case USB_DR_MODE_OTG:
Maybe default: instead?
break;
}
}
I guess that is still OK.
Yes. :-)
Chris
MBR, Sergei