> > + } > > + > > + if (data->hsic_pad_regulator) { > > + ret = regulator_enable(data->hsic_pad_regulator); > > + if (ret) { > > + dev_err(dev, > > + "Fail to enable HSIC pad regulator\n"); > > s/Fail/Failed > Ok. > > struct imx_usbmisc { > > @@ -353,6 +369,18 @@ static int usbmisc_imx6q_init(struct imx_usbmisc_data > *data) > > writel(reg | MX6_BM_NON_BURST_SETTING, > > usbmisc->base + data->index * 4); > > > > + /* For HSIC controller */ > > + if (data->hsic) { > > + reg = readl(usbmisc->base + data->index * 4); > > + writel(reg | MX6_BM_UTMI_ON_CLOCK, > > + usbmisc->base + data->index * 4); > > + reg = readl(usbmisc->base + MX6_USB_HSIC_CTRL_OFFSET > > + + (data->index - 2) * 4); > > + reg |= MX6_BM_HSIC_EN | MX6_BM_HSIC_CLK_ON; > > + writel(reg, usbmisc->base + MX6_USB_HSIC_CTRL_OFFSET > > + + (data->index - 2) * 4); > > + } > > + > > spin_unlock_irqrestore(&usbmisc->lock, flags); > > > > usbmisc_imx6q_set_wakeup(data, false); @@ -360,6 +388,69 @@ static > > int usbmisc_imx6q_init(struct imx_usbmisc_data *data) > > return 0; > > } > > > > +static int usbmisc_imx6_hsic_set_connect(struct imx_usbmisc_data > > +*data) { > > + unsigned long flags; > > + u32 val, offset; > > + struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev); > > + int ret = 0; > > + > > + spin_lock_irqsave(&usbmisc->lock, flags); > > + if (data->index == 2 || data->index == 3) { > > + offset = (data->index - 2) * 4; > > + } else if (data->index == 0) { > > + /* > > + * For SoCs like i.MX7D and later, each USB controller has > > + * its own non-core register region. For SoCs before i.MX7D, > > + * the first USB controller is non-HSIC controller. > > + */ > > + offset = 0; > > + } else { > > + dev_err(data->dev, "index is error for usbmisc\n"); > > + offset = 0; > > + ret = -EINVAL; > > + } > > Maybe you could move the code above to a function > usbmisc_imx6_hsic_get_reg_offset(struct imx_usbmisc_data *data), that returns > the offset value... > Ok, and I will change the comment for SoCs before imx7D, since for these SoCs, the first two USB controllers are non-HSIC. > > + > > + val = readl(usbmisc->base + MX6_USB_HSIC_CTRL_OFFSET + offset); > > + if (!(val & MX6_BM_HSIC_DEV_CONN)) > > + writel(val | MX6_BM_HSIC_DEV_CONN, > > + usbmisc->base + MX6_USB_HSIC_CTRL_OFFSET + offset); > > + spin_unlock_irqrestore(&usbmisc->lock, flags); > > + > > + return ret; > > +} > > + > > +static int usbmisc_imx6_hsic_set_clk(struct imx_usbmisc_data *data, > > +bool on) { > > + unsigned long flags; > > + u32 val, offset; > > + struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev); > > + int ret = 0; > > + > > + spin_lock_irqsave(&usbmisc->lock, flags); > > + if (data->index == 2 || data->index == 3) { > > + offset = (data->index - 2) * 4; > > + } else if (data->index == 0) { > > + offset = 0; > > + } else { > > + dev_err(data->dev, "index is error for usbmisc\n"); > > + offset = 0; > > + ret = -EINVAL; > > + } > > ...and use the proposed function usbmisc_imx6_hsic_get_reg_offset() > here, too. > Ok. Thanks for all your comments. Peter