From: Fabio Estevam Date: Sun, 4 May 2014 01:24:39 +0000 (+0800) Subject: chipidea: usbmisc_imx: Allow USB OTG to work on mx51 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=33f92a8a926761bfe23d740851d218c0c4eb6463;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git chipidea: usbmisc_imx: Allow USB OTG to work on mx51 The field PLLDIVVALUE of register PHY_CTRL_1 selects the reference clock source for the PHY: 00 = sysclock uses 19.2 MHz 01 = sysclock uses 24 MHz 10 = sysclock uses 26 MHz 11 = sysclock uses 27 MHz The reset value for this field is 10 according to the reference manual, and even though this reset value works for mx53, it does not work for mx51. So instead of relying on the reset value for the PLLDIVVALUE field, explicitly set it to 01 so that a 24MHz clock can be selected for the PHY and allowing both mx51 and mx53 to have USB OTG port functional. Succesfully tested 'g_ether' on a imx51-babbage and on a imx53-qsb boards. Signed-off-by: Peter Chen Signed-off-by: Fabio Estevam Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c index 419b8959d150..85293b8b1df9 100644 --- a/drivers/usb/chipidea/usbmisc_imx.c +++ b/drivers/usb/chipidea/usbmisc_imx.c @@ -46,11 +46,14 @@ #define MX27_OTG_PM_BIT BIT(24) #define MX53_USB_OTG_PHY_CTRL_0_OFFSET 0x08 +#define MX53_USB_OTG_PHY_CTRL_1_OFFSET 0x0c #define MX53_USB_UH2_CTRL_OFFSET 0x14 #define MX53_USB_UH3_CTRL_OFFSET 0x18 #define MX53_BM_OVER_CUR_DIS_H1 BIT(5) #define MX53_BM_OVER_CUR_DIS_OTG BIT(8) #define MX53_BM_OVER_CUR_DIS_UHx BIT(30) +#define MX53_USB_PHYCTRL1_PLLDIV_MASK 0x3 +#define MX53_USB_PLL_DIV_24_MHZ 0x01 #define MX6_BM_OVER_CUR_DIS BIT(7) @@ -164,6 +167,13 @@ static int usbmisc_imx53_init(struct imx_usbmisc_data *data) if (data->index > 3) return -EINVAL; + /* Select a 24 MHz reference clock for the PHY */ + reg = usbmisc->base + MX53_USB_OTG_PHY_CTRL_1_OFFSET; + val = readl(reg); + val &= ~MX53_USB_PHYCTRL1_PLLDIV_MASK; + val |= MX53_USB_PLL_DIV_24_MHZ; + writel(val, usbmisc->base + MX53_USB_OTG_PHY_CTRL_1_OFFSET); + if (data->disable_oc) { spin_lock_irqsave(&usbmisc->lock, flags); switch (data->index) {