DT: ISP1504 init ulpi hook to phy-generic

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is my idea to hook the ulpi for my board.
This patch includes to support gpio-chipselect for the ISP1504 (pin29)

diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c
index fce3a9e..2b7bdf3 100644
--- a/drivers/usb/phy/phy-generic.c
+++ b/drivers/usb/phy/phy-generic.c
@@ -26,10 +26,12 @@
  *	autonomous such as isp1504, isp1707, etc.
  */
 +#define DEBUG
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
 #include <linux/usb/otg.h>
+#include <linux/usb/ulpi.h>
 #include <linux/usb/usb_phy_gen_xceiv.h>
 #include <linux/slab.h>
 #include <linux/clk.h>
@@ -150,7 +152,8 @@ static int nop_set_host(struct usb_otg *otg, struct usb_bus *host)
 }
  int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_gen_xceiv *nop,
-		enum usb_phy_type type, u32 clk_rate, bool needs_vcc)
+		enum usb_phy_type type, u32 clk_rate, bool needs_vcc,
+		bool needs_ulpi)
 {
 	int err;
@@ -159,6 +162,15 @@ int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_gen_xceiv *nop,
 	if (!nop->phy.otg)
 		return -ENOMEM;
 +	if (needs_ulpi) {
+		nop->ulpi = otg_ulpi_create(&ulpi_viewport_access_ops, 0);
+		if (!nop->ulpi) {
+			dev_err(dev, "otg_ulpi_create failed\n");
+			return -ENOMEM;
+		}
+	}
+
+
 	nop->clk = devm_clk_get(dev, "main_clk");
 	if (IS_ERR(nop->clk)) {
 		dev_dbg(dev, "Can't get phy clock: %ld\n",
@@ -181,6 +193,23 @@ int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_gen_xceiv *nop,
 			return -EPROBE_DEFER;
 	}
 +	if (nop->gpio_chipselect != -EPROBE_DEFER) {
+		dev_dbg(dev, "Requesting Chipselect GPIO %d\n",
+				nop->gpio_chipselect);
+		if( gpio_is_valid(nop->gpio_chipselect)) {
+			unsigned long gpio_flags;
+
+			gpio_flags = GPIOF_OUT_INIT_LOW;
+			err = devm_gpio_request_one(dev, nop->gpio_chipselect,
+					gpio_flags, dev_name(dev));
+			if (err) {
+				dev_err(dev, "Error requesting Chipselect GPIO %d\n",
+						nop->gpio_chipselect);
+				return err;
+			}
+		}
+	}
+
 	if (gpio_is_valid(nop->gpio_reset)) {
 		unsigned long gpio_flags;
@@ -225,6 +254,7 @@ static int usb_phy_gen_xceiv_probe(struct platform_device *pdev)
 	int err;
 	u32 clk_rate = 0;
 	bool needs_vcc = false;
+	bool needs_ulpi = false;
  	nop = devm_kzalloc(dev, sizeof(*nop), GFP_KERNEL);
 	if (!nop)
@@ -235,13 +265,19 @@ static int usb_phy_gen_xceiv_probe(struct platform_device *pdev)
 	if (dev->of_node) {
 		struct device_node *node = dev->of_node;
 		enum of_gpio_flags flags;
+		enum of_gpio_flags csflags;
  		if (of_property_read_u32(node, "clock-frequency", &clk_rate))
 			clk_rate = 0;
  		needs_vcc = of_property_read_bool(node, "vcc-supply");
+		needs_ulpi = of_property_read_bool(node, "ulpi_vbus_init");
+
 		nop->gpio_reset = of_get_named_gpio_flags(node, "reset-gpios",
 								0, &flags);
+
+		nop->gpio_chipselect = of_get_named_gpio_flags(node, "cs-gpios",
+								0, &csflags);
 		if (nop->gpio_reset == -EPROBE_DEFER)
 			return -EPROBE_DEFER;
@@ -254,7 +290,8 @@ static int usb_phy_gen_xceiv_probe(struct platform_device *pdev)
 		nop->gpio_reset = pdata->gpio_reset;
 	}
 -	err = usb_phy_gen_create_phy(dev, nop, type, clk_rate, needs_vcc);
+	err = usb_phy_gen_create_phy(dev, nop, type, clk_rate,
+			needs_vcc, needs_ulpi);
 	if (err)
 		return err;
 diff --git a/drivers/usb/phy/phy-generic.h b/drivers/usb/phy/phy-generic.h
index d2a220d..722fdac 100644
--- a/drivers/usb/phy/phy-generic.h
+++ b/drivers/usb/phy/phy-generic.h
@@ -3,10 +3,12 @@
  struct usb_phy_gen_xceiv {
 	struct usb_phy phy;
+	struct usb_phy *ulpi;
 	struct device *dev;
 	struct clk *clk;
 	struct regulator *vcc;
 	int gpio_reset;
+	int gpio_chipselect;
 	bool reset_active_low;
 };
 @@ -14,6 +16,7 @@ int usb_gen_phy_init(struct usb_phy *phy);
 void usb_gen_phy_shutdown(struct usb_phy *phy);
  int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_gen_xceiv *nop,
-		enum usb_phy_type type, u32 clk_rate, bool needs_vcc);
+		enum usb_phy_type type, u32 clk_rate,
+		bool needs_vcc, bool needs_ulpi);
  #endif



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




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux