[RFCv1 4/8] phy: amlogic: meson8b-usb2: Use phy set_mode callback function
Martin Blumenstingl
martin.blumenstingl at googlemail.com
Fri Jun 18 13:01:33 PDT 2021
Hi Anand,
On Fri, Jun 18, 2021 at 3:19 PM Anand Moon <linux.amoon at gmail.com> wrote:
[...]
> > I suggest dropping this patch until we know for sure if and which
> > registers need to be updated based on the DR mode.
>
> Yes, I have observed this, Can you give these small changes a try?
> With the below changes, I got the PHY_MODE_USB_DEVICE support working.
first of all: sorry that I have not linked my source of information previously:
- Meson8b: [0]
- Meson8 and Meson8m2: [1]
Unfortunately I don't have any datasheet or "better documentation" of
how the registers should be programmed.
This is why I am a bit defensive when I am asked to change something
there - as I simply have no way of knowing if the changes are good or
not. I can only tell whether they're "identical" or "different" from
what the vendor kernel does.
[...]
> + case PHY_MODE_USB_DEVICE:
> + case PHY_MODE_USB_OTG:
> + regmap_update_bits(priv->regmap, REG_ADP_BC,
> + REG_ADP_BC_DCD_ENABLE,
> + REG_ADP_BC_DCD_ENABLE);
> +
> + udelay(ACA_ENABLE_COMPLETE_TIME);
> +
> + regmap_read(priv->regmap, REG_ADP_BC, ®);
> + if (reg & REG_ADP_BC_ACA_PIN_FLOAT) {
> + dev_warn(&phy->dev, "USB ID detect failed!\n");
> + return -EINVAL;
> + }
> + regmap_update_bits(priv->regmap, REG_ADP_BC,
> + REG_ADP_BC_ID_PULLUP, REG_ADP_BC_ID_PULLUP);
> + break;
According to the vendor kernel this should only be applied to
"host-only" USB_PORT_IDX_B (which is usb1 in the mainline .dtsi).
Based on that I think it's not correct to apply this for DEVICE and OTG modes.
The vendor kernel does not configure REG_ADP_BC_ID_PULLUP anywhere.
Also DCD_ENABLE is only ever set to 0 (while you are enabling it now), see [2].
As mentioned before: all I can say about this patch is that it
programs the registers differently than the vendor kernel does.
>From your description I am not sure if you are now getting different
behavior on Odroid-C1 with this patch (compared to what we had
before).
Best regards,
Martin
[0] https://github.com/endlessm/linux-meson/blob/03393bb8e8478626e03ee93b0a2a225d6de242b5/arch/arm/mach-meson8b/usbclock.c#L120
[1] https://github.com/endlessm/linux-meson/blob/03393bb8e8478626e03ee93b0a2a225d6de242b5/arch/arm/mach-meson8/usbclock.c#L120
[2] https://github.com/endlessm/linux-meson/blob/d6e13c220931110fe676ede6da69fc61a7cb04b6/drivers/amlogic/usb/dwc_otg/310/dwc_otg_pcd.c#L71
More information about the linux-amlogic
mailing list