From: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Cc: l.majewski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org,
kgene.kim-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org,
boyko.lee-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
yulgon.kim-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org,
joshi-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org,
kyungmin.park-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org,
linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Vivek Gautam
<gautam.vivek-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>,
olofj-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org,
a.kesavan-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org,
av.tikhomirov-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org,
prashanth.g-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org,
ajaykumar.rs-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org,
m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org
Subject: Re: [PATCH 5/8 v2] ARM: EXYNOS5: Add PHY initialization code for usb 2.0
Date: Thu, 26 Jul 2012 12:08:13 +0000 [thread overview]
Message-ID: <201207261208.13874.arnd@arndb.de> (raw)
In-Reply-To: <1342866729-30460-6-git-send-email-gautam.vivek-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
On Saturday 21 July 2012, Vivek Gautam wrote:
> This patch adds PHY setup functions usb 2.0 support on exynos5
>
> Signed-off-by: Yulgon Kim <yulgon.kim-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
> Signed-off-by: Vivek Gautam <gautam.vivek-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
> ---
> arch/arm/mach-exynos/Kconfig | 1 +
> arch/arm/mach-exynos/include/mach/regs-usb-phy.h | 86 ++++++++
> arch/arm/mach-exynos/setup-usb-phy.c | 232 +++++++++++++++++++++-
> 3 files changed, 311 insertions(+), 8 deletions(-)
This looks very much like a new device driver, not some code you can just stick
into platform code. We're trying hard to move driver code out of the platform
directories, so please don't add any new stuff for a driver and soc that doesn't
have to deal with legacy code.
>
> static int exynos4_usb_host_phy_is_on(void)
> {
> - return (readl(EXYNOS4_PHYPWR) & PHY1_STD_ANALOG_POWERDOWN) ? 0 : 1;
> + if (soc_is_exynos5250()) {
> + return (readl(EXYNOS5_PHY_HOST_CTRL0) &
> + HOST_CTRL0_PHYSWRSTALL) ? 0 : 1;
> + } else {
> + return (readl(EXYNOS4_PHYPWR) &
> + PHY1_STD_ANALOG_POWERDOWN) ? 0 : 1;
> + }
> +}
Never hardcode register locations like this.
Also you clearly have two SoC that do different things here, so putting them
into the same function is a bit strange.
>
> static struct clk *exynos_usb_clock_enable(struct platform_device *pdev)
> @@ -31,7 +56,10 @@ static struct clk *exynos_usb_clock_enable(struct platform_device *pdev)
> struct clk *usb_clk = NULL;
> int err = 0;
>
> - usb_clk = clk_get(&pdev->dev, "otg");
> + if (soc_is_exynos5250())
> + usb_clk = clk_get(&pdev->dev, "usbhost");
> + else
> + usb_clk = clk_get(&pdev->dev, "otg");
> if (IS_ERR(usb_clk)) {
> dev_err(&pdev->dev, "Failed to get otg clock\n");
> return NULL;
Why do you have different names for the same clock on different SoCs?
If the clock has the same purpose, just give it the same name.
> @@ -50,7 +78,11 @@ static int exynos4210_usb_phy_clkset(struct platform_device *pdev)
> struct clk *xusbxti_clk;
> u32 phyclk = 0;
>
> - xusbxti_clk = clk_get(&pdev->dev, "xusbxti");
> + if (soc_is_exynos5250())
> + xusbxti_clk = clk_get(&pdev->dev, "ext_xtal");
> + else
> + xusbxti_clk = clk_get(&pdev->dev, "xusbxti");
> +
> if (xusbxti_clk && !IS_ERR(xusbxti_clk)) {
> if (soc_is_exynos4210()) {
> /* set clock frequency for PLL */
same here.
> @@ -218,8 +431,11 @@ int s5p_usb_phy_exit(struct platform_device *pdev, int type)
> {
> if (type == S5P_USB_PHY_DEVICE)
> return exynos4210_usb_phy0_exit(pdev);
> - else if (type == S5P_USB_PHY_HOST)
> - return exynos4210_usb_phy1_exit(pdev);
> -
> + else if (type == S5P_USB_PHY_HOST) {
> + if (soc_is_exynos5250())
> + return exynos5_usb_phy20_exit(pdev);
> + else
> + return exynos4210_usb_phy1_exit(pdev);
> + }
> return -EINVAL;
> }
You are doing completely different things here. None of these are actually
s5p, so better make these different functions for each soc.
If you have a driver that has some common code and some hardware specific
code, we generally structure the code so that the entry points are different
for the each kind of hardware and they call into common code from there.
This code is done in the opposite way and should be changed over time,
so please don't add to the mess.
Arnd
WARNING: multiple messages have this Message-ID (diff)
From: arnd@arndb.de (Arnd Bergmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 5/8 v2] ARM: EXYNOS5: Add PHY initialization code for usb 2.0
Date: Thu, 26 Jul 2012 12:08:13 +0000 [thread overview]
Message-ID: <201207261208.13874.arnd@arndb.de> (raw)
In-Reply-To: <1342866729-30460-6-git-send-email-gautam.vivek@samsung.com>
On Saturday 21 July 2012, Vivek Gautam wrote:
> This patch adds PHY setup functions usb 2.0 support on exynos5
>
> Signed-off-by: Yulgon Kim <yulgon.kim@samsung.com>
> Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
> ---
> arch/arm/mach-exynos/Kconfig | 1 +
> arch/arm/mach-exynos/include/mach/regs-usb-phy.h | 86 ++++++++
> arch/arm/mach-exynos/setup-usb-phy.c | 232 +++++++++++++++++++++-
> 3 files changed, 311 insertions(+), 8 deletions(-)
This looks very much like a new device driver, not some code you can just stick
into platform code. We're trying hard to move driver code out of the platform
directories, so please don't add any new stuff for a driver and soc that doesn't
have to deal with legacy code.
>
> static int exynos4_usb_host_phy_is_on(void)
> {
> - return (readl(EXYNOS4_PHYPWR) & PHY1_STD_ANALOG_POWERDOWN) ? 0 : 1;
> + if (soc_is_exynos5250()) {
> + return (readl(EXYNOS5_PHY_HOST_CTRL0) &
> + HOST_CTRL0_PHYSWRSTALL) ? 0 : 1;
> + } else {
> + return (readl(EXYNOS4_PHYPWR) &
> + PHY1_STD_ANALOG_POWERDOWN) ? 0 : 1;
> + }
> +}
Never hardcode register locations like this.
Also you clearly have two SoC that do different things here, so putting them
into the same function is a bit strange.
>
> static struct clk *exynos_usb_clock_enable(struct platform_device *pdev)
> @@ -31,7 +56,10 @@ static struct clk *exynos_usb_clock_enable(struct platform_device *pdev)
> struct clk *usb_clk = NULL;
> int err = 0;
>
> - usb_clk = clk_get(&pdev->dev, "otg");
> + if (soc_is_exynos5250())
> + usb_clk = clk_get(&pdev->dev, "usbhost");
> + else
> + usb_clk = clk_get(&pdev->dev, "otg");
> if (IS_ERR(usb_clk)) {
> dev_err(&pdev->dev, "Failed to get otg clock\n");
> return NULL;
Why do you have different names for the same clock on different SoCs?
If the clock has the same purpose, just give it the same name.
> @@ -50,7 +78,11 @@ static int exynos4210_usb_phy_clkset(struct platform_device *pdev)
> struct clk *xusbxti_clk;
> u32 phyclk = 0;
>
> - xusbxti_clk = clk_get(&pdev->dev, "xusbxti");
> + if (soc_is_exynos5250())
> + xusbxti_clk = clk_get(&pdev->dev, "ext_xtal");
> + else
> + xusbxti_clk = clk_get(&pdev->dev, "xusbxti");
> +
> if (xusbxti_clk && !IS_ERR(xusbxti_clk)) {
> if (soc_is_exynos4210()) {
> /* set clock frequency for PLL */
same here.
> @@ -218,8 +431,11 @@ int s5p_usb_phy_exit(struct platform_device *pdev, int type)
> {
> if (type == S5P_USB_PHY_DEVICE)
> return exynos4210_usb_phy0_exit(pdev);
> - else if (type == S5P_USB_PHY_HOST)
> - return exynos4210_usb_phy1_exit(pdev);
> -
> + else if (type == S5P_USB_PHY_HOST) {
> + if (soc_is_exynos5250())
> + return exynos5_usb_phy20_exit(pdev);
> + else
> + return exynos4210_usb_phy1_exit(pdev);
> + }
> return -EINVAL;
> }
You are doing completely different things here. None of these are actually
s5p, so better make these different functions for each soc.
If you have a driver that has some common code and some hardware specific
code, we generally structure the code so that the entry points are different
for the each kind of hardware and they call into common code from there.
This code is done in the opposite way and should be changed over time,
so please don't add to the mess.
Arnd
next prev parent reply other threads:[~2012-07-26 12:08 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-21 10:32 [PATCH 0/8 v2] EXYNOS5: USB: Add USB 2.0 and USB 3.0 support for exynos5 Vivek Gautam
2012-07-21 10:32 ` Vivek Gautam
2012-07-21 10:32 ` [PATCH 1/8 v2] EXYNOS4: USB: Generalising setup-usb-phy driver for exynos Vivek Gautam
2012-07-21 10:32 ` Vivek Gautam
2012-07-21 10:32 ` [PATCH 2/8 v2] ARM: EXYNOS5: Add machine data for USB 2.0 Vivek Gautam
2012-07-21 10:32 ` Vivek Gautam
2012-07-26 11:24 ` Arnd Bergmann
2012-07-26 11:24 ` Arnd Bergmann
2012-07-28 16:05 ` Vivek Gautam
2012-07-28 16:05 ` Vivek Gautam
2012-07-29 13:11 ` Arnd Bergmann
2012-07-29 13:11 ` Arnd Bergmann
2012-08-01 3:02 ` Joonyoung Shim
2012-08-01 3:02 ` Joonyoung Shim
2012-07-21 10:32 ` [PATCH 3/8 v2] ARM: EXYNOS5: Add OHCI device from device tree Vivek Gautam
2012-07-21 10:32 ` Vivek Gautam
2012-07-21 10:32 ` [PATCH 4/8 v2] ARM: EXYNOS5: Add EHCI " Vivek Gautam
2012-07-21 10:32 ` Vivek Gautam
2012-07-26 11:57 ` Arnd Bergmann
2012-07-26 11:57 ` Arnd Bergmann
2012-07-28 16:41 ` Vivek Gautam
2012-07-28 16:42 ` Vivek Gautam
2012-07-21 10:32 ` [PATCH 5/8 v2] ARM: EXYNOS5: Add PHY initialization code for usb 2.0 Vivek Gautam
2012-07-21 10:32 ` Vivek Gautam
[not found] ` <1342866729-30460-6-git-send-email-gautam.vivek-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2012-07-26 12:08 ` Arnd Bergmann [this message]
2012-07-26 12:08 ` Arnd Bergmann
2012-07-21 10:32 ` [PATCH 6/8 v2] ARM: EXYNOS5: Add machine data for USB3.0 Vivek Gautam
2012-07-21 10:32 ` Vivek Gautam
2012-07-21 10:32 ` [PATCH 7/8 v2] ARM: EXYNOS5: Add XHCI device from device tree Vivek Gautam
2012-07-21 10:32 ` Vivek Gautam
2012-07-21 10:32 ` [PATCH 8/8 v2] ARM: EXYNOS5: Add PHY initialization code for usb 3.0 Vivek Gautam
2012-07-21 10:32 ` Vivek Gautam
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201207261208.13874.arnd@arndb.de \
--to=arnd-r2ngtmty4d4@public.gmane.org \
--cc=a.kesavan-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
--cc=ajaykumar.rs-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
--cc=av.tikhomirov-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
--cc=boyko.lee-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
--cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
--cc=gautam.vivek-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
--cc=joshi-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
--cc=kgene.kim-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
--cc=kyungmin.park-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
--cc=l.majewski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
--cc=olofj-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
--cc=prashanth.g-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
--cc=yulgon.kim-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.