linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] usb: ehci-sh: Add PHY init function with platform data
@ 2012-03-21  6:47 Nobuhiro Iwamatsu
  2012-03-21  6:58 ` Paul Mundt
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Nobuhiro Iwamatsu @ 2012-03-21  6:47 UTC (permalink / raw)
  To: linux-sh

In devices using ehci-sh, initialization of the PHY may be necessary.
This adds platform data to ehci-sh and provide function to initialize PHY.

Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
CC: Shimoda Yoshihiro <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/usb/host/ehci-sh.c  |    8 ++++++++
 include/linux/usb/ehci-sh.h |   28 ++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 0 deletions(-)
 create mode 100644 include/linux/usb/ehci-sh.h

diff --git a/drivers/usb/host/ehci-sh.c b/drivers/usb/host/ehci-sh.c
index 9d9cf47..98def36 100644
--- a/drivers/usb/host/ehci-sh.c
+++ b/drivers/usb/host/ehci-sh.c
@@ -11,6 +11,7 @@
  */
 #include <linux/platform_device.h>
 #include <linux/clk.h>
+#include <linux/usb/ehci-sh.h>
 
 struct ehci_sh_priv {
 	struct clk *iclk, *fclk;
@@ -100,6 +101,7 @@ static int ehci_hcd_sh_probe(struct platform_device *pdev)
 	const struct hc_driver *driver = &ehci_sh_hc_driver;
 	struct resource *res;
 	struct ehci_sh_priv *priv;
+	struct ehci_sh_platdata *pdata;
 	struct usb_hcd *hcd;
 	int irq, ret;
 
@@ -124,6 +126,9 @@ static int ehci_hcd_sh_probe(struct platform_device *pdev)
 		goto fail_create_hcd;
 	}
 
+	if (pdev->dev.platform_data != NULL)
+		pdata = pdev->dev.platform_data;
+
 	/* initialize hcd */
 	hcd = usb_create_hcd(&ehci_sh_hc_driver, &pdev->dev,
 			     dev_name(&pdev->dev));
@@ -168,6 +173,9 @@ static int ehci_hcd_sh_probe(struct platform_device *pdev)
 	clk_enable(priv->fclk);
 	clk_enable(priv->iclk);
 
+	if (pdata && pdata->phy_init)
+		pdata->phy_init();
+
 	ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
 	if (ret != 0) {
 		dev_err(&pdev->dev, "Failed to add hcd");
diff --git a/include/linux/usb/ehci-sh.h b/include/linux/usb/ehci-sh.h
new file mode 100644
index 0000000..817b206
--- /dev/null
+++ b/include/linux/usb/ehci-sh.h
@@ -0,0 +1,28 @@
+/*
+ * EHCI SuperH driver platform data
+ *
+ * Copyright (C) 2012  Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
+ * Copyright (C) 2012  Renesas Solutions Corp.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __LINUX_USB_EHCI_SH_H
+#define __LINUX_USB_EHCI_SH_H
+
+struct ehci_sh_platdata {
+	void (*phy_init)(void); /* Phy init function */
+};
+
+#endif /* __LINUX_USB_EHCI_SH_H */
-- 
1.7.9.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] usb: ehci-sh: Add PHY init function with platform data
  2012-03-21  6:47 [PATCH v2] usb: ehci-sh: Add PHY init function with platform data Nobuhiro Iwamatsu
@ 2012-03-21  6:58 ` Paul Mundt
  2012-03-23  4:38 ` Nobuhiro Iwamatsu
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Paul Mundt @ 2012-03-21  6:58 UTC (permalink / raw)
  To: linux-sh

On Wed, Mar 21, 2012 at 03:47:00PM +0900, Nobuhiro Iwamatsu wrote:
> In devices using ehci-sh, initialization of the PHY may be necessary.
> This adds platform data to ehci-sh and provide function to initialize PHY.
> 
> Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
> CC: Shimoda Yoshihiro <yoshihiro.shimoda.uh@renesas.com>

It's impossible to say whether this makes sense or not without first
seeing what you are trying to do in the callback.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] usb: ehci-sh: Add PHY init function with platform data
  2012-03-21  6:47 [PATCH v2] usb: ehci-sh: Add PHY init function with platform data Nobuhiro Iwamatsu
  2012-03-21  6:58 ` Paul Mundt
@ 2012-03-23  4:38 ` Nobuhiro Iwamatsu
  2012-03-23  7:18 ` Paul Mundt
  2012-04-12  1:54 ` Nobuhiro Iwamatsu
  3 siblings, 0 replies; 5+ messages in thread
From: Nobuhiro Iwamatsu @ 2012-03-23  4:38 UTC (permalink / raw)
  To: linux-sh

Paul Mundt さんは書きました:
> On Wed, Mar 21, 2012 at 03:47:00PM +0900, Nobuhiro Iwamatsu wrote:
>> In devices using ehci-sh, initialization of the PHY may be necessary.
>> This adds platform data to ehci-sh and provide function to initialize PHY.
>>
>> Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
>> CC: Shimoda Yoshihiro <yoshihiro.shimoda.uh@renesas.com>
> 
> It's impossible to say whether this makes sense or not without first
> seeing what you are trying to do in the callback.
> 

For example, it is necessary to initialize it after having
ebabled clock of ehci in sh7734.
I perform initialization CPU specific in callback.
For example, following.

/* USB */
#define USBPCTRL1		0xFFE70804
#define USBST			0xFFE70808
#define USBEH0			0xFFE7080C
#define USBOH0			0xFFE7081C
#define USBCTL0			0xFFE70858

#define USBPCTRL1_RST       (1 << 31)
#define USBPCTRL1_PHYENB    (1 << 0)
#define USBPCTRL1_PLLENB    (1 << 1)
#define USBPCTRL1_PHYRST    (1 << 2)
#define USBST_ACT           (1 << 31)
define USBST_PPL           (1 << 30)
#define USBCTL0_CLKSEL      (1 << 7)

static void usb_ehci_phy_init(void)
{
	/* Init check */
	if (__raw_readl(USBPCTRL1) & USBPCTRL1_PHYRST)
		return;

	__raw_writel(USBPCTRL1_RST, USBPCTRL1);
	__raw_writel(0, USBPCTRL1);

	__raw_writel(USBPCTRL1_PHYENB, USBPCTRL1);
	__raw_writel(__raw_readl(USBPCTRL1)|USBPCTRL1_PLLENB, USBPCTRL1);
	while (__raw_readl(USBST) != (USBST_ACT|USBST_PPL))
		cpu_relax();

	__raw_writel(__raw_readl(USBPCTRL1) | USBPCTRL1_PHYRST, USBPCTRL1);
}

Should I move this by initialization of board?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] usb: ehci-sh: Add PHY init function with platform data
  2012-03-21  6:47 [PATCH v2] usb: ehci-sh: Add PHY init function with platform data Nobuhiro Iwamatsu
  2012-03-21  6:58 ` Paul Mundt
  2012-03-23  4:38 ` Nobuhiro Iwamatsu
@ 2012-03-23  7:18 ` Paul Mundt
  2012-04-12  1:54 ` Nobuhiro Iwamatsu
  3 siblings, 0 replies; 5+ messages in thread
From: Paul Mundt @ 2012-03-23  7:18 UTC (permalink / raw)
  To: linux-sh

On Fri, Mar 23, 2012 at 01:38:38PM +0900, Nobuhiro Iwamatsu wrote:
> Paul Mundt ????????????????????????:
> >On Wed, Mar 21, 2012 at 03:47:00PM +0900, Nobuhiro Iwamatsu wrote:
> >>In devices using ehci-sh, initialization of the PHY may be necessary.
> >>This adds platform data to ehci-sh and provide function to initialize PHY.
> >>
> >>Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
> >>CC: Shimoda Yoshihiro <yoshihiro.shimoda.uh@renesas.com>
> >
> >It's impossible to say whether this makes sense or not without first
> >seeing what you are trying to do in the callback.
> >
> 
> For example, it is necessary to initialize it after having
> ebabled clock of ehci in sh7734.
> I perform initialization CPU specific in callback.
> For example, following.
> 
Ok, that seems fine. I'd prefer to see the header in
include/linux/platform_data/, however. Also, when can we expect an
upstream user for this? I don't mind adding support for it, but it
doesn't make much sense to have upstream if there aren't any in-tree
users.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] usb: ehci-sh: Add PHY init function with platform data
  2012-03-21  6:47 [PATCH v2] usb: ehci-sh: Add PHY init function with platform data Nobuhiro Iwamatsu
                   ` (2 preceding siblings ...)
  2012-03-23  7:18 ` Paul Mundt
@ 2012-04-12  1:54 ` Nobuhiro Iwamatsu
  3 siblings, 0 replies; 5+ messages in thread
From: Nobuhiro Iwamatsu @ 2012-04-12  1:54 UTC (permalink / raw)
  To: linux-sh

Paul Mundt さんは書きました:
> On Fri, Mar 23, 2012 at 01:38:38PM +0900, Nobuhiro Iwamatsu wrote:
>> Paul Mundt ????????????????????????:
>>> On Wed, Mar 21, 2012 at 03:47:00PM +0900, Nobuhiro Iwamatsu wrote:
>>>> In devices using ehci-sh, initialization of the PHY may be necessary.
>>>> This adds platform data to ehci-sh and provide function to initialize PHY.
>>>>
>>>> Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
>>>> CC: Shimoda Yoshihiro <yoshihiro.shimoda.uh@renesas.com>
>>> It's impossible to say whether this makes sense or not without first
>>> seeing what you are trying to do in the callback.
>>>
>> For example, it is necessary to initialize it after having
>> ebabled clock of ehci in sh7734.
>> I perform initialization CPU specific in callback.
>> For example, following.
>>
> Ok, that seems fine. I'd prefer to see the header in
> include/linux/platform_data/, however. Also, when can we expect an
> upstream user for this? I don't mind adding support for it, but it
> doesn't make much sense to have upstream if there aren't any in-tree
> users.
> 

OK, I will move to include/linux/platform_data/.
And Renesas sh7734 uses this now only.
Moreover, it can use for initialization of PHY by other SH CPUs.

Nobuhiro

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-04-12  1:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-21  6:47 [PATCH v2] usb: ehci-sh: Add PHY init function with platform data Nobuhiro Iwamatsu
2012-03-21  6:58 ` Paul Mundt
2012-03-23  4:38 ` Nobuhiro Iwamatsu
2012-03-23  7:18 ` Paul Mundt
2012-04-12  1:54 ` Nobuhiro Iwamatsu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).