linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kishon Vijay Abraham I <kishon-l0cyMroinI0@public.gmane.org>
To: rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org,
	rob-VoJi6FS/r0vR7s880joybQ@public.gmane.org,
	balbi-l0cyMroinI0@public.gmane.org,
	sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org,
	gg-kDsPt+C1G03kYMGBc/C6ZA@public.gmane.org,
	s-guiriec-l0cyMroinI0@public.gmane.org,
	broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org,
	linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
Cc: grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org,
	kishon-l0cyMroinI0@public.gmane.org
Subject: [PATCH v1 1/8] usb: otg: palmas-usb: make palmas-usb as a comparator driver
Date: Fri, 25 Jan 2013 08:42:24 +0530	[thread overview]
Message-ID: <1359083551-8524-2-git-send-email-kishon@ti.com> (raw)
In-Reply-To: <1359083551-8524-1-git-send-email-kishon-l0cyMroinI0@public.gmane.org>

palmas-usb is made as a comparator driver to omap usb2 phy, so that
omap usb can make use of palmas for srp and also to set vbus.

Signed-off-by: Kishon Vijay Abraham I <kishon-l0cyMroinI0@public.gmane.org>
---
 drivers/usb/otg/palmas-usb.c |   20 ++++++++++++++++++--
 include/linux/mfd/palmas.h   |    3 +++
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/otg/palmas-usb.c b/drivers/usb/otg/palmas-usb.c
index 8389ad6..76240ef 100644
--- a/drivers/usb/otg/palmas-usb.c
+++ b/drivers/usb/otg/palmas-usb.c
@@ -31,6 +31,8 @@
 #include <linux/platform_device.h>
 #include <linux/io.h>
 #include <linux/usb/otg.h>
+#include <linux/usb/phy_companion.h>
+#include <linux/usb/omap_usb.h>
 #include <linux/regulator/consumer.h>
 #include <linux/err.h>
 #include <linux/notifier.h>
@@ -208,16 +210,20 @@ static void palmas_set_vbus_work(struct work_struct *data)
 		regulator_disable(palmas_usb->vbus_reg);
 }
 
-static int palmas_set_vbus(struct palmas_usb *palmas_usb, bool enabled)
+static int palmas_set_vbus(struct phy_companion *comparator, bool enabled)
 {
+	struct palmas_usb *palmas_usb = comparator_to_palmas(comparator);
+
 	palmas_usb->vbus_enable = enabled;
 	schedule_work(&palmas_usb->set_vbus_work);
 
 	return 0;
 }
 
-static int palmas_start_srp(struct palmas_usb *palmas_usb)
+static int palmas_start_srp(struct phy_companion *comparator)
 {
+	struct palmas_usb *palmas_usb = comparator_to_palmas(comparator);
+
 	palmas_usb_write(palmas_usb->palmas, PALMAS_USB_VBUS_CTRL_SET,
 			PALMAS_USB_VBUS_CTRL_SET_VBUS_DISCHRG |
 			PALMAS_USB_VBUS_CTRL_SET_VBUS_IADP_SINK);
@@ -253,6 +259,7 @@ static void palmas_dt_to_pdata(struct device_node *node,
 
 static int palmas_usb_probe(struct platform_device *pdev)
 {
+	u32 ret;
 	struct palmas *palmas = dev_get_drvdata(pdev->dev.parent);
 	struct palmas_usb_platform_data	*pdata = pdev->dev.platform_data;
 	struct device_node *node = pdev->dev.of_node;
@@ -289,6 +296,15 @@ static int palmas_usb_probe(struct platform_device *pdev)
 	palmas_usb->irq4 = regmap_irq_get_virq(palmas->irq_data,
 						PALMAS_VBUS_IRQ);
 
+	palmas_usb->comparator.set_vbus	= palmas_set_vbus;
+	palmas_usb->comparator.start_srp = palmas_start_srp;
+
+	ret = omap_usb2_set_comparator(&palmas_usb->comparator);
+	if (ret == -ENODEV) {
+		dev_info(&pdev->dev, "phy not ready, deferring probe");
+		return -EPROBE_DEFER;
+	}
+
 	palmas_usb_wakeup(palmas, pdata->wakeup);
 
 	/* init spinlock for workqueue */
diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h
index 82932db..a557db6 100644
--- a/include/linux/mfd/palmas.h
+++ b/include/linux/mfd/palmas.h
@@ -19,6 +19,7 @@
 #include <linux/leds.h>
 #include <linux/regmap.h>
 #include <linux/regulator/driver.h>
+#include <linux/usb/phy_companion.h>
 
 #define PALMAS_NUM_CLIENTS		3
 
@@ -343,6 +344,8 @@ struct palmas_usb {
 	struct palmas *palmas;
 	struct device *dev;
 
+	struct phy_companion comparator;
+
 	/* for vbus reporting with irqs disabled */
 	spinlock_t lock;
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2013-01-25  3:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-25  3:12 [PATCH v1 0/8] usb: otg: palmas-usb: fixes/cleanups to get dwc3 working Kishon Vijay Abraham I
     [not found] ` <1359083551-8524-1-git-send-email-kishon-l0cyMroinI0@public.gmane.org>
2013-01-25  3:12   ` Kishon Vijay Abraham I [this message]
2013-01-25  7:43     ` [PATCH v1 1/8] usb: otg: palmas-usb: make palmas-usb as a comparator driver Felipe Balbi
     [not found]       ` <20130125074339.GD15886-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
2013-01-25  8:44         ` kishon
     [not found]           ` <510245D7.4090008-l0cyMroinI0@public.gmane.org>
2013-01-25  8:59             ` Felipe Balbi
2013-01-25  3:12   ` [PATCH v1 2/8] usb: otg: palmas-usb: use devres API to allocate resources Kishon Vijay Abraham I
2013-01-25  3:12   ` [PATCH v1 4/8] usb: otg: palmas-usb: use mailbox API to send VBUS or ID events Kishon Vijay Abraham I
2013-01-25  3:12   ` [PATCH v1 5/8] usb: otg: palmas-usb: use bool to read property instead of u32 Kishon Vijay Abraham I
2013-01-25  3:12 ` [PATCH v1 3/8] usb: otg: palmas-usb: remove compiler warning Kishon Vijay Abraham I
2013-01-25  3:12 ` [PATCH v1 6/8] usb: otg: palmas-usb: call regulator enable/disable only on valid regulator Kishon Vijay Abraham I
2013-01-25  3:12 ` [PATCH v1 7/8] usb: otg: palmas-usb: pass the correct dev ptr in regulator get Kishon Vijay Abraham I
2013-01-25  3:12 ` [PATCH v1 8/8] usb: otg: palmas-usb: fix cold plug issue Kishon Vijay Abraham I

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=1359083551-8524-2-git-send-email-kishon@ti.com \
    --to=kishon-l0cymroini0@public.gmane.org \
    --cc=balbi-l0cyMroinI0@public.gmane.org \
    --cc=broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=gg-kDsPt+C1G03kYMGBc/C6ZA@public.gmane.org \
    --cc=grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org \
    --cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
    --cc=linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=rob-VoJi6FS/r0vR7s880joybQ@public.gmane.org \
    --cc=rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org \
    --cc=s-guiriec-l0cyMroinI0@public.gmane.org \
    --cc=sameo-VuQAYsv1563Yd54FQh9/CA@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 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).