[U-Boot] [PATCH v2 1/8] armv8: Add workaround for USB erratum A-009008
York Sun
york.sun at nxp.com
Fri Aug 11 16:36:15 UTC 2017
On 08/11/2017 12:26 AM, Ran Wang wrote:
> +static void erratum_a009008(void)
> +{
> +#ifdef CONFIG_SYS_FSL_ERRATUM_A009008
> + u32 __iomem *scfg = (u32 __iomem *)SCFG_BASE;
> +#if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A)
> + u32 val = scfg_in32(scfg + SCFG_USB3PRM1CR_USB1 / 4);
> +
> + val &= ~(0xF << 6);
> + scfg_out32(scfg + SCFG_USB3PRM1CR_USB1 / 4, val|(USB_TXVREFTUNE << 6));
> + val = scfg_in32(scfg + SCFG_USB3PRM1CR_USB2 / 4);
> + val &= ~(0xF << 6);
> + scfg_out32(scfg + SCFG_USB3PRM1CR_USB2 / 4, val|(USB_TXVREFTUNE << 6));
> + val = scfg_in32(scfg + SCFG_USB3PRM1CR_USB3 / 4);
> + val &= ~(0xF << 6);
> + scfg_out32(scfg + SCFG_USB3PRM1CR_USB3 / 4, val|(USB_TXVREFTUNE << 6));
> +#elif defined(CONFIG_ARCH_LS2080A)
> + u32 val = scfg_in32(scfg + SCFG_USB3PRM1CR / 4);
> +
> + val &= ~(0xF << 6);
> + scfg_out32(scfg + SCFG_USB3PRM1CR / 4, val|(USB_TXVREFTUNE << 6));
> +#endif
> +#endif /* CONFIG_SYS_FSL_ERRATUM_A009008 */
> +}
Ran,
Wouldn't it be cleaner to make an inline function like this
static inline void usb_errata_a009008(u32 __iomem *scfg, u32 offset)
{
u32 val;
val = scfg_in32(scfg + offset / 4) & ~(0xF << 6);
val |= USB_TXVREFTUNE << 6;
scfg_out32(scfg + offset / 4, val);
}
Then your function can be rewritten as
static void erratum_a009008(void)
{
#ifdef CONFIG_SYS_FSL_ERRATUM_A009008
u32 __iomem *scfg = (u32 __iomem *)SCFG_BASE;
#if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A)
usb_errata_a009008(scfg, SCFG_USB3PRM1CR_USB1);
usb_errata_a009008(scfg, SCFG_USB3PRM1CR_USB2);
usb_errata_a009008(scfg, SCFG_USB3PRM1CR_USB3);
usb_errata_a009008(scfg, SCFG_USB3PRM1CR_USB4);
#elif defined(CONFIG_ARCH_LS2080A)
usb_errata_a009008(scfg, SCFG_USB3PRM1CR);
#else
#error Platform not defined
#endif
#endif
}
York
More information about the U-Boot
mailing list