Skip to contentSkip to conversation

usb: musb: add new phy driver

RFC PATCH In review Kishon Vijay Abraham I 4 participants 9 messages May 30, 2012 – Jun 20, 2012

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

cover usb: musb: add new phy driver

This series adds a new usb2 phy driver. The device for which is created by the ocp2scp driver. This also uses control module driver.

This series converts twl6030 as a comparator driver (previously it was also the phy driver) and makes use of omap-usb2 as the phy driver.

Instead of notification mechanism by power chip to omap glue to pass detection of any events, an export API has been added in omap glue. Both twl4030 and twl6030 will call to this API to pass any event. (twl6030 is used in omap4 and twl4030 is used in omap3).

This series depends on:
*[RFC PATCH 00/11] OMAP System Control Module* patch series However System Control Module driver has only dt support, so wouldn't be able to test this patch series. However I'll adapt omap usb2 phy driver and musb driver for dt and send it asap to the list.

This series also depends on:
*[PATCH v3 0/3] usb: multi-phy support* patch series *[RFC PATCH 0/5] omap: add ocp2scp as a misc driver* patch series

Compile tested only.

Kishon Vijay Abraham I (3):
drivers: usb: otg: add a new driver for omap usb2 phy
usb: musb: omap glue: use omap-usb2 as the phy driver
arm: omap: phy: remove unused functions from omap-phy-internal.c

 arch/arm/mach-omap2/omap_phy_internal.c |  138 ------------------
 arch/arm/mach-omap2/twl-common.c        |    5 -
 arch/arm/mach-omap2/usb-musb.c          |    3 -
 drivers/usb/musb/musb_core.h            |    1 -
 drivers/usb/musb/omap2430.c             |  150 ++++++++++++++------
 drivers/usb/otg/Kconfig                 |   17 ++-
 drivers/usb/otg/Makefile                |    1 +
 drivers/usb/otg/omap-usb2.c             |  232 +++++++++++++++++++++++++++++++
 drivers/usb/otg/twl4030-usb.c           |   40 ++----
 drivers/usb/otg/twl6030-usb.c           |  172 +++++------------------
 include/linux/usb/musb-omap.h           |   31 ++++
 include/linux/usb/omap_usb.h            |   47 ++++++
 include/linux/usb/phy_companion.h       |   34 +++++
 13 files changed, 514 insertions(+), 357 deletions(-)
 create mode 100644 drivers/usb/otg/omap-usb2.c
 create mode 100644 include/linux/usb/musb-omap.h
 create mode 100644 include/linux/usb/omap_usb.h
 create mode 100644 include/linux/usb/phy_companion.h
Signature · 1 line
1.7.5.4
#1 lore raw

RFC PATCH 1/3 drivers: usb: otg: add a new driver for omap usb2 phy

All phy related programming like enabling/disabling the clocks, powering on/off the phy is taken care of by this driver. It is also used for OTG related functionality like srp.

---
 drivers/usb/otg/Kconfig           |   17 ++-
 drivers/usb/otg/Makefile          |    1 +
 drivers/usb/otg/omap-usb2.c       |  232 +++++++++++++++++++++++++++++++++++++
 include/linux/usb/omap_usb.h      |   47 ++++++++
 include/linux/usb/phy_companion.h |   34 ++++++
 5 files changed, 327 insertions(+), 4 deletions(-)
 create mode 100644 drivers/usb/otg/omap-usb2.c
 create mode 100644 include/linux/usb/omap_usb.h
 create mode 100644 include/linux/usb/phy_companion.h
drivers/usb/otg/Kconfig +13 -4
index e2840f1..3264c0d 100644
@@ -73,10 +73,8 @@ config TWL6030_USB
 	help
 	  Enable this to support the USB OTG transceiver on TWL6030
 	  family chips. This TWL6030 transceiver has the VBUS and ID GND
-	  and OTG SRP events capabilities. For all other transceiver functionality
-	  UTMI PHY is embedded in OMAP4430. The internal PHY configurations APIs
-	  are hooked to this driver through platform_data structure.
-	  The definition of internal PHY APIs are in the mach-omap2 layer.
+          and OTG SRP events capabilities. For all other transceiver
+	  functionality UTMI PHY is embedded in OMAP4430.
 
 config OMAP4_USB_PHY
 	tristate "Texas Instruments OMAP4+ USB pin control driver"
@@ -91,6 +89,17 @@ config OMAP4_USB_PHY
 	  performing the above mentioned configuration, API's are added in
 	  by this children of the control module driver.
 
+config OMAP_USB2
+	tristate "OMAP USB2 PHY Driver"
+	depends on OMAP_OCP2SCP
+	depends on OMAP4_USB_PHY
+	select USB_OTG_UTILS
+	help
+	  Enable this to support the transceiver that is part of SOC. This
+	  driver takes care of all the PHY functionality apart from comparator.
+	  The USB OTG controller communicates with the comparator using this
+	  driver.
+
 config NOP_USB_XCEIV
 	tristate "NOP USB Transceiver Driver"
 	select USB_OTG_UTILS
drivers/usb/otg/Makefile +1 -0
index 60c8c83..2f02912 100644
@@ -14,6 +14,7 @@ obj-$(CONFIG_ISP1301_OMAP)	+= isp1301_omap.o
 obj-$(CONFIG_TWL4030_USB)	+= twl4030-usb.o
 obj-$(CONFIG_TWL6030_USB)	+= twl6030-usb.o
 obj-$(CONFIG_OMAP4_USB_PHY)	+= omap4-usb-phy.o
+obj-$(CONFIG_OMAP_USB2)		+= omap-usb2.o
 obj-$(CONFIG_NOP_USB_XCEIV)	+= nop-usb-xceiv.o
 obj-$(CONFIG_USB_ULPI)		+= ulpi.o
 obj-$(CONFIG_USB_ULPI_VIEWPORT)	+= ulpi_viewport.o
drivers/usb/otg/omap-usb2.c new file +232 -0

232 lines not on this page · raw message

include/linux/usb/omap_usb.h new file +47 -0

47 lines not on this page · raw message

include/linux/usb/phy_companion.h new file +34 -0
new file mode 100644
index 0000000..321290f
@@ -0,0 +1,34 @@
+/*
+ * phy-companion.h -- phy companion to indicate the comparator part of PHY
+ *
+ * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Author: Kishon Vijay Abraham I <[email protected]>
+ *
+ * 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.
+ *
+ */
+
+#ifndef __DRIVERS_PHY_COMPANION_H
+#define __DRIVERS_PHY_COMPANION_H
+
+#include <linux/usb/otg.h>
+
+/* phy_companion to take care of VBUS, ID and srp capabilities */
+struct phy_companion {
+
+	/* effective for A-peripheral, ignored for B devices */
+	int	(*set_vbus)(struct phy_companion *x, bool enabled);
+
+	/* for B devices only:  start session with A-Host */
+	int	(*start_srp)(struct phy_companion *x);
+};
+
+#endif /* __DRIVERS_PHY_COMPANION_H */
Signature · 1 line
1.7.5.4
#2 lore raw

Re: [RFC PATCH 1/3] drivers: usb: otg: add a new driver for omap usb2 phy

Quoted 17 lines · Kishon Vijay Abraham I

All phy related programming like enabling/disabling the clocks, powering on/off the phy is taken care of by this driver. It is also used for OTG related functionality like srp.

---

?drivers/usb/otg/Kconfig ? ? ? ? ? | ? 17 ++-
?drivers/usb/otg/Makefile ? ? ? ? ?| ? ?1 +
?drivers/usb/otg/omap-usb2.c ? ? ? | ?232 +++++++++++++++++++++++++++++++++++++
?include/linux/usb/omap_usb.h ? ? ?| ? 47 ++++++++
?include/linux/usb/phy_companion.h | ? 34 ++++++

?5 files changed, 327 insertions(+), 4 deletions(-) ?create mode 100644 drivers/usb/otg/omap-usb2.c ?create mode 100644 include/linux/usb/omap_usb.h ?create mode 100644 include/linux/usb/phy_companion.h

[...]

drivers/usb/otg/omap-usb2.c line 4

Quoted 10 lines
drivers/usb/otg/omap-usb2.c new file +4 -0
new file mode 100644
index 0000000..ccd74b6
@@ -0,0 +1,232 @@
+/*
+ * omap-usb2.c - USB PHY, talking to musb controller in OMAP.
+ *
+ * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com

s/2011/2012

Quoted 18 lines
drivers/usb/otg/omap-usb2.c new file +18 -0
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Author: Kishon Vijay Abraham I <[email protected]>
+ *
+ * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+

drivers/usb/otg/omap-usb2.c line 32

Quoted 10 lines
drivers/usb/otg/omap-usb2.c new file +10 -0
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <linux/of.h>
+#include <linux/usb/omap_usb.h>
+#include <linux/usb/phy_companion.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <linux/pm_runtime.h>
+#include <linux/delay.h>

Do you need it ?

Quoted 110 lines
drivers/usb/otg/omap-usb2.c new file +110 -0
+#include <linux/mfd/omap_control.h>
+#include <linux/usb/omap4_usb_phy.h>
+
+/**
+ * omap_usb2_set_comparator - links the comparator present in the sytem with
+ * ? ? this phy
+ * @comparator - the companion phy(comparator) for this phy
+ *
+ * The phy companion driver should call this API passing the phy_companion
+ * filled with set_vbus and start_srp to be used by usb phy.
+ *
+ * For use by phy companion driver
+ */
+void omap_usb2_set_comparator(struct phy_companion *comparator)
+{
+ ? ? ? struct usb_phy ?*x = usb_get_phy(USB_PHY_TYPE_USB2);
+ ? ? ? struct omap_usb *phy = phy_to_omapusb(x);
+
+ ? ? ? phy->comparator = comparator;
+}
+EXPORT_SYMBOL_GPL(omap_usb2_set_comparator);
+
+static int omap_usb_set_vbus(struct usb_otg *otg, bool enabled)
+{
+ ? ? ? struct omap_usb *phy = phy_to_omapusb(otg->phy);
+
+ ? ? ? if (!phy->comparator)
+ ? ? ? ? ? ? ? return -ENODEV;
+
+ ? ? ? return phy->comparator->set_vbus(phy->comparator, enabled);
+}
+
+static int omap_usb_start_srp(struct usb_otg *otg)
+{
+ ? ? ? struct omap_usb *phy = phy_to_omapusb(otg->phy);
+
+ ? ? ? if (!phy->comparator)
+ ? ? ? ? ? ? ? return -ENODEV;
+
+ ? ? ? return phy->comparator->start_srp(phy->comparator);
+}
+
+static int omap_usb_set_host(struct usb_otg *otg, struct usb_bus *host)
+{
+ ? ? ? struct usb_phy ?*phy = otg->phy;
+
+ ? ? ? otg->host = host;
+ ? ? ? if (!host)
+ ? ? ? ? ? ? ? phy->state = OTG_STATE_UNDEFINED;
+
+ ? ? ? return 0;
+}
+
+static int omap_usb_set_peripheral(struct usb_otg *otg,
+ ? ? ? ? ? ? ? struct usb_gadget *gadget)
+{
+ ? ? ? struct usb_phy ?*phy = otg->phy;
+
+ ? ? ? otg->gadget = gadget;
+ ? ? ? if (!gadget)
+ ? ? ? ? ? ? ? phy->state = OTG_STATE_UNDEFINED;
+
+ ? ? ? return 0;
+}
+
+static int omap_usb2_suspend(struct usb_phy *x, int suspend)
+{
+ ? ? ? struct omap_usb *phy = phy_to_omapusb(x);
+
+ ? ? ? if (suspend && !phy->is_suspended) {
+ ? ? ? ? ? ? ? pm_runtime_put_sync(phy->dev);
+ ? ? ? ? ? ? ? phy->is_suspended = 1;
+ ? ? ? } else if (!suspend && phy->is_suspended) {
+ ? ? ? ? ? ? ? pm_runtime_get_sync(phy->dev);
+ ? ? ? ? ? ? ? phy->is_suspended = 0;
+ ? ? ? }
+
+ ? ? ? return 0;
+}
+
+static int __devinit omap_usb2_probe(struct platform_device *pdev)
+{
+ ? ? ? struct omap_usb ? ? ? ? ? ? ? ? *phy;
+ ? ? ? struct usb_otg ? ? ? ? ? ? ? ? ?*otg;
+
+ ? ? ? phy = devm_kzalloc(&pdev->dev, sizeof(*phy), GFP_KERNEL);
+ ? ? ? if (!phy) {
+ ? ? ? ? ? ? ? dev_err(&pdev->dev, "unable to allocate memory for USB2 PHY\n");
+ ? ? ? ? ? ? ? return -ENOMEM;
+ ? ? ? }
+
+ ? ? ? otg = devm_kzalloc(&pdev->dev, sizeof(*otg), GFP_KERNEL);
+ ? ? ? if (!otg) {
+ ? ? ? ? ? ? ? dev_err(&pdev->dev, "unable to allocate memory for USB OTG\n");
+ ? ? ? ? ? ? ? return -ENOMEM;
+ ? ? ? }
+
+ ? ? ? phy->dev ? ? ? ? ? ? ? ?= &pdev->dev;
+
+ ? ? ? phy->phy.dev ? ? ? ? ? ?= phy->dev;
+ ? ? ? phy->phy.label ? ? ? ? ?= "omap-usb2";
+ ? ? ? phy->phy.set_suspend ? ?= omap_usb2_suspend;
+ ? ? ? phy->phy.otg ? ? ? ? ? ?= otg;
+
+ ? ? ? phy->control_dev ? ? ? ?= omap_control_get();
+ ? ? ? if (IS_ERR(phy->control_dev)) {
+ ? ? ? ? ? ? ? dev_err(&pdev->dev, "no control device present in system\n");
+ ? ? ? ? ? ? ? return PTR_ERR(phy->control_dev);
+ ? ? ? }
+

drivers/usb/otg/omap-usb2.c line 152

Quoted 10 lines
drivers/usb/otg/omap-usb2.c new file +10 -0
+ ? ? ? phy->is_suspended ? ? ? = 1;
+ ? ? ? omap4_usb_phy_power(phy->control_dev, 0);
+
+ ? ? ? otg->set_host ? ? ? ? ? = omap_usb_set_host;
+ ? ? ? otg->set_peripheral ? ? = omap_usb_set_peripheral;
+ ? ? ? otg->set_vbus ? ? ? ? ? = omap_usb_set_vbus;
+ ? ? ? otg->start_srp ? ? ? ? ?= omap_usb_start_srp;
+ ? ? ? otg->phy ? ? ? ? ? ? ? ?= &phy->phy;
+
+ ? ? ? phy->wkupclk = clk_get(phy->dev, "usb_phy_cm_clk32k");

Error check missing here.

drivers/usb/otg/omap-usb2.c line 35

Quoted 3 lines
drivers/usb/otg/omap-usb2.c new file +3 -0
+
+ ? ? ? usb_add_phy(&phy->phy, USB_PHY_TYPE_USB2);
+

unnecessary extra line

drivers/usb/otg/omap-usb2.c line 157

Quoted 2 lines
drivers/usb/otg/omap-usb2.c new file +2 -0
+ ? ? ? platform_set_drvdata(pdev, phy);
+

this one too

Quoted 6 lines
drivers/usb/otg/omap-usb2.c new file +6 -0
+ ? ? ? pm_runtime_enable(phy->dev);
+
+ ? ? ? return 0;
+}
+
+static int __devexit omap_usb2_remove(struct platform_device *pdev)

drivers/usb/otg/omap-usb2.c line 173

Quoted 10 lines
drivers/usb/otg/omap-usb2.c new file +10 -0
+{
+ ? ? ? struct omap_usb *phy = platform_get_drvdata(pdev);
+
+ ? ? ? usb_remove_phy(&phy->phy);
+ ? ? ? platform_set_drvdata(pdev, NULL);
+
+ ? ? ? return 0;
+}
+
+#ifdef CONFIG_PM

s/ CONFIG_PM/CONFIG_SUSPEND
otherwise you will get build warning with !CONFIG_SUSPEND

Quoted 65 lines
drivers/usb/otg/omap-usb2.c new file +59 -0
+
+static int omap_usb2_runtime_suspend(struct device *dev)
+{
+ ? ? ? struct platform_device ?*pdev = to_platform_device(dev);
+ ? ? ? struct omap_usb *phy = platform_get_drvdata(pdev);
+
+ ? ? ? clk_disable(phy->wkupclk);
+ ? ? ? omap4_usb_phy_power(phy->control_dev, 0);
+
+ ? ? ? return 0;
+}
+
+static int omap_usb2_runtime_resume(struct device *dev)
+{
+ ? ? ? struct platform_device ?*pdev = to_platform_device(dev);
+ ? ? ? struct omap_usb *phy = platform_get_drvdata(pdev);
+
+ ? ? ? omap4_usb_phy_power(phy->control_dev, 1);
+ ? ? ? clk_enable(phy->wkupclk);
+
+ ? ? ? return 0;
+}
+
+static const struct dev_pm_ops omap_usb2_pm_ops = {
+ ? ? ? SET_RUNTIME_PM_OPS(omap_usb2_runtime_suspend, omap_usb2_runtime_resume,
+ ? ? ? ? ? ? ? NULL)
+};
+
+#define DEV_PM_OPS ? ? (&omap_usb2_pm_ops)
+#else
+#define DEV_PM_OPS ? ? NULL
+#endif
+
+static struct platform_driver omap_usb2_driver = {
+ ? ? ? .probe ? ? ? ? ?= omap_usb2_probe,
+ ? ? ? .remove ? ? ? ? = __devexit_p(omap_usb2_remove),
+ ? ? ? .driver ? ? ? ? = {
+ ? ? ? ? ? ? ? .name ? = "omap-usb2",
+ ? ? ? ? ? ? ? .owner ?= THIS_MODULE,
+ ? ? ? ? ? ? ? .pm ? ? = DEV_PM_OPS,
+ ? ? ? },
+};
+
+static int __init usb2_omap_init(void)
+{
+ ? ? ? return platform_driver_register(&omap_usb2_driver);
+}
+arch_initcall(usb2_omap_init);
+
+static void __exit usb2_omap_exit(void)
+{
+ ? ? ? platform_driver_unregister(&omap_usb2_driver);
+}
+module_exit(usb2_omap_exit);
+
+MODULE_ALIAS("platform: omap_usb2");
+MODULE_AUTHOR("Kishon Vijay Abraham I <[email protected]>");
+MODULE_DESCRIPTION("OMAP USB2 PHY DRIVER");
+MODULE_LICENSE("GPL");
include/linux/usb/omap_usb.h new file +0 -0
new file mode 100644
index 0000000..8d781df

include/linux/usb/omap_usb.h line 4

Quoted 4 lines
include/linux/usb/omap_usb.h new file +4 -0
@@ -0,0 +1,47 @@
+/*
+ * omap_usb.h -- omap usb2 phy header file
+ *
+ * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com

s/2011/2012

Quoted 49 lines
include/linux/usb/omap_usb.h new file +43 -0
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Author: Kishon Vijay Abraham I <[email protected]>
+ *
+ * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef __DRIVERS_OMAP_USB2_H
+#define __DRIVERS_OMAP_USB2_H
+
+#include <linux/usb/otg.h>
+
+struct omap_usb {
+ ? ? ? struct usb_phy ? ? ? ? ?phy;
+ ? ? ? struct phy_companion ? ?*comparator;
+ ? ? ? struct device ? ? ? ? ? *dev;
+ ? ? ? struct device ? ? ? ? ? *control_dev;
+ ? ? ? struct clk ? ? ? ? ? ? ?*wkupclk;
+ ? ? ? u8 ? ? ? ? ? ? ? ? ? ? ?is_suspended:1;
+};
+
+#define ? ? ? ?phy_to_omapusb(x) ? ? ? container_of((x), struct omap_usb, phy)
+
+#if defined(CONFIG_OMAP_USB2) || defined(CONFIG_OMAP_USB2_MODULE)
+void omap_usb2_set_comparator(struct phy_companion *comparator);
+#else
+static inline void omap_usb2_set_comparator(struct phy_companion *comparator)
+{
+}
+#endif
+
+#endif /* __DRIVERS_OMAP_USB_H */
include/linux/usb/phy_companion.h new file +0 -0
new file mode 100644
index 0000000..321290f

include/linux/usb/phy_companion.h line 4

Quoted 4 lines
include/linux/usb/phy_companion.h new file +4 -0
@@ -0,0 +1,34 @@
+/*
+ * phy-companion.h -- phy companion to indicate the comparator part of PHY
+ *
+ * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com

Here too..

Regards
Santosh

#3 lore raw

RFC PATCH 2/3 usb: musb: omap glue: use omap-usb2 as the phy driver

In reply to Kishon Vijay Abraham I

The twl6030 which was the phy driver (phy + comparator) is now made only as comparator driver used for detecting VBUS and ID events and reporting it to the glue using an export API created in omap musb glue.

The MUSB should now use omap-usb2 as the phy driver.

Both twl6030 and twl4030 are made to use the export API from omap musb glue.

---
 arch/arm/mach-omap2/usb-musb.c |    3 -
 drivers/usb/musb/musb_core.h   |    1 -
 drivers/usb/musb/omap2430.c    |  150 +++++++++++++++++++++++++----------
 drivers/usb/otg/twl4030-usb.c  |   40 +++------
 drivers/usb/otg/twl6030-usb.c  |  172 ++++++++--------------------------------
 include/linux/usb/musb-omap.h  |   31 +++++++
 6 files changed, 187 insertions(+), 210 deletions(-)
 create mode 100644 include/linux/usb/musb-omap.h
arch/arm/mach-omap2/usb-musb.c +0 -3
index 8d5ed77..8ada8cc 100644
@@ -119,7 +119,4 @@ void __init usb_musb_init(struct omap_musb_board_data *musb_board_data)
 	dev->dma_mask = &musb_dmamask;
 	dev->coherent_dma_mask = musb_dmamask;
 	put_device(dev);
-
-	if (cpu_is_omap44xx())
-		omap4430_phy_init(dev);
 }
drivers/usb/musb/musb_core.h +0 -1
index f4a40f0..0b0174b 100644
@@ -327,7 +327,6 @@ struct musb {
 
 	irqreturn_t		(*isr)(int, void *);
 	struct work_struct	irq_work;
-	struct work_struct	otg_notifier_work;
 	u16			hwvers;
 
 /* this hub status bit is reserved by USB 2.0 and not seen by usbcore */
drivers/usb/musb/omap2430.c +108 -42

285 lines not on this page · raw message

drivers/usb/otg/twl4030-usb.c +14 -26
index f8139b3..d9357d4 100644
@@ -32,6 +32,7 @@
 #include <linux/workqueue.h>
 #include <linux/io.h>
 #include <linux/delay.h>
+#include <linux/usb/musb-omap.h>
 #include <linux/usb/otg.h>
 #include <linux/usb/ulpi.h>
 #include <linux/i2c/twl.h>
@@ -159,10 +160,11 @@ struct twl4030_usb {
 	enum twl4030_usb_mode	usb_mode;
 
 	int			irq;
-	u8			linkstat;
 	bool			vbus_supplied;
 	u8			asleep;
 	bool			irq_enabled;
+
+	enum omap_musb_vbus_id_status prev_status;
 };
 
 /* internal define on top of container_of */
@@ -250,7 +252,6 @@ static enum usb_phy_events twl4030_usb_linkstat(struct twl4030_usb *twl)
 {
 	int	status;
 	int	linkstat = USB_EVENT_NONE;
-	struct usb_otg *otg = twl->phy.otg;
 
 	twl->vbus_supplied = false;
 
@@ -272,33 +273,21 @@ static enum usb_phy_events twl4030_usb_linkstat(struct twl4030_usb *twl)
 		if (status & (BIT(7)))
                         twl->vbus_supplied = true;
 
-		if (status & BIT(2))
+		if (status & BIT(2)) {
+			twl->prev_status = OMAP_MUSB_ID_GROUND;
 			linkstat = USB_EVENT_ID;
-		else
+		} else {
+			twl->prev_status = OMAP_MUSB_VBUS_VALID;
 			linkstat = USB_EVENT_VBUS;
-	} else
+		}
+	} else {
+		twl->prev_status = OMAP_MUSB_VBUS_OFF;
 		linkstat = USB_EVENT_NONE;
+	}
 
 	dev_dbg(twl->dev, "HW_CONDITIONS 0x%02x/%d; link %d\n",
 			status, status, linkstat);
 
-	twl->phy.last_event = linkstat;
-
-	/* REVISIT this assumes host and peripheral controllers
-	 * are registered, and that both are active...
-	 */
-
-	spin_lock_irq(&twl->lock);
-	twl->linkstat = linkstat;
-	if (linkstat == USB_EVENT_ID) {
-		otg->default_a = true;
-		twl->phy.state = OTG_STATE_A_IDLE;
-	} else {
-		otg->default_a = false;
-		twl->phy.state = OTG_STATE_B_IDLE;
-	}
-	spin_unlock_irq(&twl->lock);
-
 	return linkstat;
 }
 
@@ -521,8 +510,7 @@ static irqreturn_t twl4030_usb_irq(int irq, void *_twl)
 		else
 			twl4030_phy_resume(twl);
 
-		atomic_notifier_call_chain(&twl->phy.notifier, status,
-				twl->phy.otg->gadget);
+		omap_musb_mailbox(twl->prev_status);
 	}
 	sysfs_notify(&twl->dev->kobj, NULL, "vbus");
 
@@ -543,8 +531,7 @@ static void twl4030_usb_phy_init(struct twl4030_usb *twl)
 			twl->asleep = 0;
 		}
 
-		atomic_notifier_call_chain(&twl->phy.notifier, status,
-				twl->phy.otg->gadget);
+		omap_musb_mailbox(twl->prev_status);
 	}
 	sysfs_notify(&twl->dev->kobj, NULL, "vbus");
 }
@@ -613,6 +600,7 @@ static int __devinit twl4030_usb_probe(struct platform_device *pdev)
 	twl->usb_mode		= pdata->usb_mode;
 	twl->vbus_supplied	= false;
 	twl->asleep		= 1;
+	twl->prev_status	= OMAP_MUSB_UNKNOWN;
 
 	twl->phy.dev		= twl->dev;
 	twl->phy.label		= "twl4030";
drivers/usb/otg/twl6030-usb.c +34 -138

326 lines not on this page · raw message

include/linux/usb/musb-omap.h new file +31 -0
new file mode 100644
index 0000000..c84224c
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2011-2012 by Texas Instruments
+ *
+ * The Inventra Controller Driver for Linux is free software; you
+ * can redistribute it and/or modify it under the terms of the GNU
+ * General Public License version 2 as published by the Free Software
+ * Foundation.
+ */
+
+#ifndef __MUSB_OMAP_H__
+#define __MUSB_OMAP_H__
+
+enum omap_musb_vbus_id_status {
+	OMAP_MUSB_UNKNOWN = 0,
+	OMAP_MUSB_ID_GROUND,
+	OMAP_MUSB_ID_FLOAT,
+	OMAP_MUSB_VBUS_VALID,
+	OMAP_MUSB_VBUS_OFF,
+};
+
+#if (defined(CONFIG_USB_MUSB_OMAP2PLUS) || \
+				defined(CONFIG_USB_MUSB_OMAP2PLUS_MODULE))
+int omap_musb_mailbox(enum omap_musb_vbus_id_status status);
+#else
+static inline int omap_musb_mailbox(enum omap_musb_vbus_id_status status)
+{
+	return -EINVAL;
+}
+#endif
+
+#endif	/* __MUSB_OMAP_H__ */
Signature · 1 line
1.7.5.4
#4 lore raw

RFC PATCH 3/3 arm: omap: phy: remove unused functions from omap-phy-internal.c

In reply to Kishon Vijay Abraham I

All the unnessary functions in omap-phy-internal is removed. These functionality are now handled by omap-usb2 phy driver.

---
 arch/arm/mach-omap2/omap_phy_internal.c |  138 -------------------------------
 arch/arm/mach-omap2/twl-common.c        |    5 -
 2 files changed, 0 insertions(+), 143 deletions(-)
arch/arm/mach-omap2/omap_phy_internal.c +0 -138
index b2c9253..9a9e960 100644
@@ -31,144 +31,6 @@
 #include <plat/usb.h>
 #include <mach/control.h>
 
-/* OMAP control module register for UTMI PHY */
-#define CONTROL_DEV_CONF		0x300
-#define PHY_PD				0x1
-
-#define USBOTGHS_CONTROL		0x33c
-#define	AVALID				BIT(0)
-#define	BVALID				BIT(1)
-#define	VBUSVALID			BIT(2)
-#define	SESSEND				BIT(3)
-#define	IDDIG				BIT(4)
-
-static struct clk *phyclk, *clk48m, *clk32k;
-static void __iomem *ctrl_base;
-static int usbotghs_control;
-
-int omap4430_phy_init(struct device *dev)
-{
-	ctrl_base = ioremap(OMAP443X_SCM_BASE, SZ_1K);
-	if (!ctrl_base) {
-		pr_err("control module ioremap failed\n");
-		return -ENOMEM;
-	}
-	/* Power down the phy */
-	__raw_writel(PHY_PD, ctrl_base + CONTROL_DEV_CONF);
-
-	if (!dev) {
-		iounmap(ctrl_base);
-		return 0;
-	}
-
-	phyclk = clk_get(dev, "ocp2scp_usb_phy_ick");
-	if (IS_ERR(phyclk)) {
-		dev_err(dev, "cannot clk_get ocp2scp_usb_phy_ick\n");
-		iounmap(ctrl_base);
-		return PTR_ERR(phyclk);
-	}
-
-	clk48m = clk_get(dev, "ocp2scp_usb_phy_phy_48m");
-	if (IS_ERR(clk48m)) {
-		dev_err(dev, "cannot clk_get ocp2scp_usb_phy_phy_48m\n");
-		clk_put(phyclk);
-		iounmap(ctrl_base);
-		return PTR_ERR(clk48m);
-	}
-
-	clk32k = clk_get(dev, "usb_phy_cm_clk32k");
-	if (IS_ERR(clk32k)) {
-		dev_err(dev, "cannot clk_get usb_phy_cm_clk32k\n");
-		clk_put(phyclk);
-		clk_put(clk48m);
-		iounmap(ctrl_base);
-		return PTR_ERR(clk32k);
-	}
-	return 0;
-}
-
-int omap4430_phy_set_clk(struct device *dev, int on)
-{
-	static int state;
-
-	if (on && !state) {
-		/* Enable the phy clocks */
-		clk_enable(phyclk);
-		clk_enable(clk48m);
-		clk_enable(clk32k);
-		state = 1;
-	} else if (state) {
-		/* Disable the phy clocks */
-		clk_disable(phyclk);
-		clk_disable(clk48m);
-		clk_disable(clk32k);
-		state = 0;
-	}
-	return 0;
-}
-
-int omap4430_phy_power(struct device *dev, int ID, int on)
-{
-	if (on) {
-		if (ID)
-			/* enable VBUS valid, IDDIG groung */
-			__raw_writel(AVALID | VBUSVALID, ctrl_base +
-							USBOTGHS_CONTROL);
-		else
-			/*
-			 * Enable VBUS Valid, AValid and IDDIG
-			 * high impedance
-			 */
-			__raw_writel(IDDIG | AVALID | VBUSVALID,
-						ctrl_base + USBOTGHS_CONTROL);
-	} else {
-		/* Enable session END and IDIG to high impedance. */
-		__raw_writel(SESSEND | IDDIG, ctrl_base +
-					USBOTGHS_CONTROL);
-	}
-	return 0;
-}
-
-int omap4430_phy_suspend(struct device *dev, int suspend)
-{
-	if (suspend) {
-		/* Disable the clocks */
-		omap4430_phy_set_clk(dev, 0);
-		/* Power down the phy */
-		__raw_writel(PHY_PD, ctrl_base + CONTROL_DEV_CONF);
-
-		/* save the context */
-		usbotghs_control = __raw_readl(ctrl_base + USBOTGHS_CONTROL);
-	} else {
-		/* Enable the internel phy clcoks */
-		omap4430_phy_set_clk(dev, 1);
-		/* power on the phy */
-		if (__raw_readl(ctrl_base + CONTROL_DEV_CONF) & PHY_PD) {
-			__raw_writel(~PHY_PD, ctrl_base + CONTROL_DEV_CONF);
-			mdelay(200);
-		}
-
-		/* restore the context */
-		__raw_writel(usbotghs_control, ctrl_base + USBOTGHS_CONTROL);
-	}
-
-	return 0;
-}
-
-int omap4430_phy_exit(struct device *dev)
-{
-	if (ctrl_base)
-		iounmap(ctrl_base);
-	if (phyclk)
-		clk_put(phyclk);
-	if (clk48m)
-		clk_put(clk48m);
-	if (clk32k)
-		clk_put(clk32k);
-
-	return 0;
-}
-
 void am35x_musb_reset(void)
 {
 	u32	regval;
arch/arm/mach-omap2/twl-common.c +0 -5
index 119d5a9..396d189 100644
@@ -250,11 +250,6 @@ void __init omap3_pmic_get_config(struct twl4030_platform_data *pmic_data,
 
 #if defined(CONFIG_ARCH_OMAP4)
 static struct twl4030_usb_data omap4_usb_pdata = {
-	.phy_init	= omap4430_phy_init,
-	.phy_exit	= omap4430_phy_exit,
-	.phy_power	= omap4430_phy_power,
-	.phy_set_clock	= omap4430_phy_set_clk,
-	.phy_suspend	= omap4430_phy_suspend,
 };
 
 static struct regulator_init_data omap4_vdac_idata = {
Signature · 1 line
1.7.5.4
#5 lore raw

Re: [RFC PATCH 3/3] arm: omap: phy: remove unused functions from omap-phy-internal.c

Quoted 3 lines · Kishon Vijay Abraham I

All the unnessary functions in omap-phy-internal is removed. These functionality are now handled by omap-usb2 phy driver.

Cool. One less item in platform code.

maintainer Acked-by on v1 3/3
#6 lore raw

Re: [RFC PATCH 3/3] arm: omap: phy: remove unused functions from omap-phy-internal.c

In reply to Kishon Vijay Abraham I
Quoted 2 lines · Kishon Vijay Abraham I

All the unnessary functions in omap-phy-internal is removed. These functionality are now handled by omap-usb2 phy driver.

Glad to see these move to live under drivers. Up to Felipe to merge via linux-usb once the driver parts are finished:

#7 lore raw
In reply to Kishon Vijay Abraham I
Quoted 17 lines · Kishon Vijay Abraham I

This series adds a new usb2 phy driver. The device for which is created by the ocp2scp driver. This also uses control module driver.

This series converts twl6030 as a comparator driver (previously it was also the phy driver) and makes use of omap-usb2 as the phy driver.

Instead of notification mechanism by power chip to omap glue to pass detection of any events, an export API has been added in omap glue. Both twl4030 and twl6030 will call to this API to pass any event. (twl6030 is used in omap4 and twl4030 is used in omap3).

This series depends on:
*[RFC PATCH 00/11] OMAP System Control Module* patch series However System Control Module driver has only dt support, so wouldn't be able to test this patch series. However I'll adapt omap usb2 phy driver and musb driver for dt and send it asap to the list.

Quoted 5 lines

This series also depends on:
*[PATCH v3 0/3] usb: multi-phy support* patch series *[RFC PATCH 0/5] omap: add ocp2scp as a misc driver* patch series

Compile tested only.

are we getting new version of this series ?

Signature · 8 lines
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120612/702f7f0b/attachment.sig>
#8 lore raw

Hi,

Quoted 18 lines · Felipe Balbi
Quoted 17 lines · Kishon Vijay Abraham I

This series adds a new usb2 phy driver. The device for which is created by the ocp2scp driver. This also uses control module driver.

This series converts twl6030 as a comparator driver (previously it was also the phy driver) and makes use of omap-usb2 as the phy driver.

Instead of notification mechanism by power chip to omap glue to pass detection of any events, an export API has been added in omap glue. Both twl4030 and twl6030 will call to this API to pass any event. (twl6030 is used in omap4 and twl4030 is used in omap3).

This series depends on:
*[RFC PATCH 00/11] OMAP System Control Module* patch series However System Control Module driver has only dt support, so wouldn't be able to test this patch series. However I'll adapt omap usb2 phy driver and musb driver for dt and send it asap to the list.

Quoted 7 lines
Quoted 5 lines

This series also depends on:
*[PATCH v3 0/3] usb: multi-phy support* patch series *[RFC PATCH 0/5] omap: add ocp2scp as a misc driver* patch series

Compile tested only.

are we getting new version of this series ?

Yes. I'm planning to send a new version with only dt support by next week.

Thanks
Kishon