Message ID | 1484719707-12107-2-git-send-email-chunfeng.yun@mediatek.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 18/01/17 07:08, Chunfeng Yun wrote: > usually, the reference clock comes from 26M oscillator directly, > but some SoCs are not, add it for compatibility. > > Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> > --- > drivers/usb/mtu3/mtu3.h | 1 + > drivers/usb/mtu3/mtu3_plat.c | 21 +++++++++++++++++++-- > 2 files changed, 20 insertions(+), 2 deletions(-) > > diff --git a/drivers/usb/mtu3/mtu3.h b/drivers/usb/mtu3/mtu3.h > index ba9df71..aa6fd6a 100644 > --- a/drivers/usb/mtu3/mtu3.h > +++ b/drivers/usb/mtu3/mtu3.h > @@ -225,6 +225,7 @@ struct ssusb_mtk { > /* common power & clock */ > struct regulator *vusb33; > struct clk *sys_clk; > + struct clk *ref_clk; > /* otg */ > struct otg_switch_mtk otg_switch; > enum usb_dr_mode dr_mode; > diff --git a/drivers/usb/mtu3/mtu3_plat.c b/drivers/usb/mtu3/mtu3_plat.c > index 6344859..19a345d 100644 > --- a/drivers/usb/mtu3/mtu3_plat.c > +++ b/drivers/usb/mtu3/mtu3_plat.c > @@ -123,7 +123,13 @@ static int ssusb_rscs_init(struct ssusb_mtk *ssusb) > ret = clk_prepare_enable(ssusb->sys_clk); > if (ret) { > dev_err(ssusb->dev, "failed to enable sys_clk\n"); > - goto clk_err; > + goto sys_clk_err; > + } > + > + ret = clk_prepare_enable(ssusb->ref_clk); > + if (ret) { > + dev_err(ssusb->dev, "failed to enable ref_clk\n"); > + goto ref_clk_err; > } > > ret = ssusb_phy_init(ssusb); > @@ -143,8 +149,10 @@ static int ssusb_rscs_init(struct ssusb_mtk *ssusb) > phy_err: > ssusb_phy_exit(ssusb); > phy_init_err: > + clk_disable_unprepare(ssusb->ref_clk); > +ref_clk_err: > clk_disable_unprepare(ssusb->sys_clk); > -clk_err: > +sys_clk_err: > regulator_disable(ssusb->vusb33); > vusb33_err: > > @@ -154,6 +162,7 @@ static int ssusb_rscs_init(struct ssusb_mtk *ssusb) > static void ssusb_rscs_exit(struct ssusb_mtk *ssusb) > { > clk_disable_unprepare(ssusb->sys_clk); > + clk_disable_unprepare(ssusb->ref_clk); > regulator_disable(ssusb->vusb33); > ssusb_phy_power_off(ssusb); > ssusb_phy_exit(ssusb); > @@ -216,6 +225,12 @@ static int get_ssusb_rscs(struct platform_device *pdev, struct ssusb_mtk *ssusb) > return PTR_ERR(ssusb->sys_clk); > } > > + ssusb->ref_clk = devm_clk_get(dev, "ref_ck"); > + if (IS_ERR(ssusb->ref_clk)) { > + dev_err(dev, "failed to get ref clock\n"); > + return PTR_ERR(ssusb->ref_clk); > + } > + That would break older dts bindings, right? ref_ck must be optional for the code. Regards, Matthias
On Thu, 2017-01-19 at 13:22 +0100, Matthias Brugger wrote: > > On 18/01/17 07:08, Chunfeng Yun wrote: > > usually, the reference clock comes from 26M oscillator directly, > > but some SoCs are not, add it for compatibility. > > > > Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> > > --- > > drivers/usb/mtu3/mtu3.h | 1 + > > drivers/usb/mtu3/mtu3_plat.c | 21 +++++++++++++++++++-- > > 2 files changed, 20 insertions(+), 2 deletions(-) [...] > > @@ -154,6 +162,7 @@ static int ssusb_rscs_init(struct ssusb_mtk *ssusb) > > static void ssusb_rscs_exit(struct ssusb_mtk *ssusb) > > { > > clk_disable_unprepare(ssusb->sys_clk); > > + clk_disable_unprepare(ssusb->ref_clk); > > regulator_disable(ssusb->vusb33); > > ssusb_phy_power_off(ssusb); > > ssusb_phy_exit(ssusb); > > @@ -216,6 +225,12 @@ static int get_ssusb_rscs(struct platform_device *pdev, struct ssusb_mtk *ssusb) > > return PTR_ERR(ssusb->sys_clk); > > } > > > > + ssusb->ref_clk = devm_clk_get(dev, "ref_ck"); > > + if (IS_ERR(ssusb->ref_clk)) { > > + dev_err(dev, "failed to get ref clock\n"); > > + return PTR_ERR(ssusb->ref_clk); > > + } > > + > > That would break older dts bindings, right? Yes, So I send a new patch for the related dts. Maybe it's not a problem, only one dts file need be updated currently. > ref_ck must be optional for the code. I tend to make it be optional for the dts, but not for the code. There are some "fixed-clock" which can be treated as dummy ones, and if a clock is really optional, we can use one fixed-clock in dts, and keep the code simple. In fact, the reference clock is essential for usb controller. > > Regards, > Matthias
On 01/20/2017 03:20 AM, Chunfeng Yun wrote: > On Thu, 2017-01-19 at 13:22 +0100, Matthias Brugger wrote: >> >> On 18/01/17 07:08, Chunfeng Yun wrote: >>> usually, the reference clock comes from 26M oscillator directly, >>> but some SoCs are not, add it for compatibility. >>> >>> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> >>> --- >>> drivers/usb/mtu3/mtu3.h | 1 + >>> drivers/usb/mtu3/mtu3_plat.c | 21 +++++++++++++++++++-- >>> 2 files changed, 20 insertions(+), 2 deletions(-) > [...] >>> @@ -154,6 +162,7 @@ static int ssusb_rscs_init(struct ssusb_mtk *ssusb) >>> static void ssusb_rscs_exit(struct ssusb_mtk *ssusb) >>> { >>> clk_disable_unprepare(ssusb->sys_clk); >>> + clk_disable_unprepare(ssusb->ref_clk); >>> regulator_disable(ssusb->vusb33); >>> ssusb_phy_power_off(ssusb); >>> ssusb_phy_exit(ssusb); >>> @@ -216,6 +225,12 @@ static int get_ssusb_rscs(struct platform_device *pdev, struct ssusb_mtk *ssusb) >>> return PTR_ERR(ssusb->sys_clk); >>> } >>> >>> + ssusb->ref_clk = devm_clk_get(dev, "ref_ck"); >>> + if (IS_ERR(ssusb->ref_clk)) { >>> + dev_err(dev, "failed to get ref clock\n"); >>> + return PTR_ERR(ssusb->ref_clk); >>> + } >>> + >> >> That would break older dts bindings, right? > Yes, So I send a new patch for the related dts. Maybe it's not a > problem, only one dts file need be updated currently. > >> ref_ck must be optional for the code. > I tend to make it be optional for the dts, but not for the code. > There are some "fixed-clock" which can be treated as dummy ones, and if > a clock is really optional, we can use one fixed-clock in dts, and keep > the code simple. > In fact, the reference clock is essential for usb controller. Well the thing is that there are devices in the field with an older dtb which would break on a newer kernel. That's why we need to make it work with the old dtb in the code as well. Regards, Matthias >> >> Regards, >> Matthias > >
On Wed, 2017-01-25 at 00:23 +0100, Matthias Brugger wrote: > > On 01/20/2017 03:20 AM, Chunfeng Yun wrote: > > On Thu, 2017-01-19 at 13:22 +0100, Matthias Brugger wrote: > >> > >> On 18/01/17 07:08, Chunfeng Yun wrote: > >>> usually, the reference clock comes from 26M oscillator directly, > >>> but some SoCs are not, add it for compatibility. > >>> > >>> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> > >>> --- > >>> drivers/usb/mtu3/mtu3.h | 1 + > >>> drivers/usb/mtu3/mtu3_plat.c | 21 +++++++++++++++++++-- > >>> 2 files changed, 20 insertions(+), 2 deletions(-) > > [...] > >>> @@ -154,6 +162,7 @@ static int ssusb_rscs_init(struct ssusb_mtk *ssusb) > >>> static void ssusb_rscs_exit(struct ssusb_mtk *ssusb) > >>> { > >>> clk_disable_unprepare(ssusb->sys_clk); > >>> + clk_disable_unprepare(ssusb->ref_clk); > >>> regulator_disable(ssusb->vusb33); > >>> ssusb_phy_power_off(ssusb); > >>> ssusb_phy_exit(ssusb); > >>> @@ -216,6 +225,12 @@ static int get_ssusb_rscs(struct platform_device *pdev, struct ssusb_mtk *ssusb) > >>> return PTR_ERR(ssusb->sys_clk); > >>> } > >>> > >>> + ssusb->ref_clk = devm_clk_get(dev, "ref_ck"); > >>> + if (IS_ERR(ssusb->ref_clk)) { > >>> + dev_err(dev, "failed to get ref clock\n"); > >>> + return PTR_ERR(ssusb->ref_clk); > >>> + } > >>> + > >> > >> That would break older dts bindings, right? > > Yes, So I send a new patch for the related dts. Maybe it's not a > > problem, only one dts file need be updated currently. > > > >> ref_ck must be optional for the code. > > I tend to make it be optional for the dts, but not for the code. > > There are some "fixed-clock" which can be treated as dummy ones, and if > > a clock is really optional, we can use one fixed-clock in dts, and keep > > the code simple. > > In fact, the reference clock is essential for usb controller. > > Well the thing is that there are devices in the field with an older dtb > which would break on a newer kernel. That's why we need to make it work > with the old dtb in the code as well. > Happy Chinese New Year! Ok, I will make it optional. Thanks and sorry for later reply. > Regards, > Matthias > > >> > >> Regards, > >> Matthias > > > >
diff --git a/drivers/usb/mtu3/mtu3.h b/drivers/usb/mtu3/mtu3.h index ba9df71..aa6fd6a 100644 --- a/drivers/usb/mtu3/mtu3.h +++ b/drivers/usb/mtu3/mtu3.h @@ -225,6 +225,7 @@ struct ssusb_mtk { /* common power & clock */ struct regulator *vusb33; struct clk *sys_clk; + struct clk *ref_clk; /* otg */ struct otg_switch_mtk otg_switch; enum usb_dr_mode dr_mode; diff --git a/drivers/usb/mtu3/mtu3_plat.c b/drivers/usb/mtu3/mtu3_plat.c index 6344859..19a345d 100644 --- a/drivers/usb/mtu3/mtu3_plat.c +++ b/drivers/usb/mtu3/mtu3_plat.c @@ -123,7 +123,13 @@ static int ssusb_rscs_init(struct ssusb_mtk *ssusb) ret = clk_prepare_enable(ssusb->sys_clk); if (ret) { dev_err(ssusb->dev, "failed to enable sys_clk\n"); - goto clk_err; + goto sys_clk_err; + } + + ret = clk_prepare_enable(ssusb->ref_clk); + if (ret) { + dev_err(ssusb->dev, "failed to enable ref_clk\n"); + goto ref_clk_err; } ret = ssusb_phy_init(ssusb); @@ -143,8 +149,10 @@ static int ssusb_rscs_init(struct ssusb_mtk *ssusb) phy_err: ssusb_phy_exit(ssusb); phy_init_err: + clk_disable_unprepare(ssusb->ref_clk); +ref_clk_err: clk_disable_unprepare(ssusb->sys_clk); -clk_err: +sys_clk_err: regulator_disable(ssusb->vusb33); vusb33_err: @@ -154,6 +162,7 @@ static int ssusb_rscs_init(struct ssusb_mtk *ssusb) static void ssusb_rscs_exit(struct ssusb_mtk *ssusb) { clk_disable_unprepare(ssusb->sys_clk); + clk_disable_unprepare(ssusb->ref_clk); regulator_disable(ssusb->vusb33); ssusb_phy_power_off(ssusb); ssusb_phy_exit(ssusb); @@ -216,6 +225,12 @@ static int get_ssusb_rscs(struct platform_device *pdev, struct ssusb_mtk *ssusb) return PTR_ERR(ssusb->sys_clk); } + ssusb->ref_clk = devm_clk_get(dev, "ref_ck"); + if (IS_ERR(ssusb->ref_clk)) { + dev_err(dev, "failed to get ref clock\n"); + return PTR_ERR(ssusb->ref_clk); + } + ssusb->num_phys = of_count_phandle_with_args(node, "phys", "#phy-cells"); if (ssusb->num_phys > 0) { @@ -428,6 +443,7 @@ static int __maybe_unused mtu3_suspend(struct device *dev) ssusb_host_disable(ssusb, true); ssusb_phy_power_off(ssusb); clk_disable_unprepare(ssusb->sys_clk); + clk_disable_unprepare(ssusb->ref_clk); ssusb_wakeup_enable(ssusb); return 0; @@ -445,6 +461,7 @@ static int __maybe_unused mtu3_resume(struct device *dev) ssusb_wakeup_disable(ssusb); clk_prepare_enable(ssusb->sys_clk); + clk_prepare_enable(ssusb->ref_clk); ssusb_phy_power_on(ssusb); ssusb_host_enable(ssusb);
usually, the reference clock comes from 26M oscillator directly, but some SoCs are not, add it for compatibility. Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> --- drivers/usb/mtu3/mtu3.h | 1 + drivers/usb/mtu3/mtu3_plat.c | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-)