phy: pipe3: insert delay to enumerate in GEN2 mode
authorKishon Vijay Abraham I <kishon@ti.com>
Wed, 25 Jun 2014 17:52:57 +0000 (23:22 +0530)
committerKishon Vijay Abraham I <kishon@ti.com>
Tue, 22 Jul 2014 07:16:10 +0000 (12:46 +0530)
8-bit delay value (0xF1) is required for GEN2 devices to be enumerated
consistently. Added an API to be called from PHY drivers to set this delay
value and called it from PIPE3 driver to set the delay value.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Reviewed-by: Roger Quadros <rogerq@ti.com>
Documentation/devicetree/bindings/phy/ti-phy.txt
drivers/phy/phy-omap-control.c
drivers/phy/phy-ti-pipe3.c
include/linux/phy/omap_control_phy.h

index b50e1c10a05d3d5ab998602772276720699c3ef3..305e3df3d9b1eb9a994c845eb28959275d2f20ed 100644 (file)
@@ -9,15 +9,17 @@ Required properties:
                         e.g. USB2_PHY on OMAP5.
  "ti,control-phy-pipe3" - if it has DPLL and individual Rx & Tx power control
                         e.g. USB3 PHY and SATA PHY on OMAP5.
+ "ti,control-phy-pcie" - for pcie to support external clock for pcie and to
+                       set PCS delay value.
+                       e.g. PCIE PHY in DRA7x
  "ti,control-phy-usb2-dra7" - if it has power down register like USB2 PHY on
                         DRA7 platform.
  "ti,control-phy-usb2-am437" - if it has power down register like USB2 PHY on
                         AM437 platform.
- - reg : Address and length of the register set for the device. It contains
-   the address of "otghs_control" for control-phy-otghs or "power" register
-   for other types.
- - reg-names: should be "otghs_control" control-phy-otghs and "power" for
-   other types.
+ - reg : register ranges as listed in the reg-names property
+ - reg-names: "otghs_control" for control-phy-otghs
+             "power", "pcie_pcs" and "control_sma" for control-phy-pcie
+             "power" for all other types
 
 omap_control_usb: omap-control-usb@4a002300 {
         compatible = "ti,control-phy-otghs";
index 311b4f9a51323a7eda3c35ea16a2ab3a9a61cc06..9487bf112267bebdbb7c1c92c6cdb349ee3ccc51 100644 (file)
 #include <linux/clk.h>
 #include <linux/phy/omap_control_phy.h>
 
+/**
+ * omap_control_pcie_pcs - set the PCS delay count
+ * @dev: the control module device
+ * @id: index of the pcie PHY (should be 1 or 2)
+ * @delay: 8 bit delay value
+ */
+void omap_control_pcie_pcs(struct device *dev, u8 id, u8 delay)
+{
+       u32 val;
+       struct omap_control_phy *control_phy;
+
+       if (IS_ERR(dev) || !dev) {
+               pr_err("%s: invalid device\n", __func__);
+               return;
+       }
+
+       control_phy = dev_get_drvdata(dev);
+       if (!control_phy) {
+               dev_err(dev, "%s: invalid control phy device\n", __func__);
+               return;
+       }
+
+       if (control_phy->type != OMAP_CTRL_TYPE_PCIE) {
+               dev_err(dev, "%s: unsupported operation\n", __func__);
+               return;
+       }
+
+       val = readl(control_phy->pcie_pcs);
+       val &= ~(OMAP_CTRL_PCIE_PCS_MASK <<
+               (id * OMAP_CTRL_PCIE_PCS_DELAY_COUNT_SHIFT));
+       val |= delay << (id * OMAP_CTRL_PCIE_PCS_DELAY_COUNT_SHIFT);
+       writel(val, control_phy->pcie_pcs);
+}
+EXPORT_SYMBOL_GPL(omap_control_pcie_pcs);
+
 /**
  * omap_control_phy_power - power on/off the phy using control module reg
  * @dev: the control module device
@@ -61,6 +96,7 @@ void omap_control_phy_power(struct device *dev, int on)
                        val |= OMAP_CTRL_DEV_PHY_PD;
                break;
 
+       case OMAP_CTRL_TYPE_PCIE:
        case OMAP_CTRL_TYPE_PIPE3:
                rate = clk_get_rate(control_phy->sys_clk);
                rate = rate/1000000;
@@ -211,6 +247,7 @@ EXPORT_SYMBOL_GPL(omap_control_usb_set_mode);
 static const enum omap_control_phy_type otghs_data = OMAP_CTRL_TYPE_OTGHS;
 static const enum omap_control_phy_type usb2_data = OMAP_CTRL_TYPE_USB2;
 static const enum omap_control_phy_type pipe3_data = OMAP_CTRL_TYPE_PIPE3;
+static const enum omap_control_phy_type pcie_data = OMAP_CTRL_TYPE_PCIE;
 static const enum omap_control_phy_type dra7usb2_data = OMAP_CTRL_TYPE_DRA7USB2;
 static const enum omap_control_phy_type am437usb2_data = OMAP_CTRL_TYPE_AM437USB2;
 
@@ -227,6 +264,10 @@ static const struct of_device_id omap_control_phy_id_table[] = {
                .compatible = "ti,control-phy-pipe3",
                .data = &pipe3_data,
        },
+       {
+               .compatible = "ti,control-phy-pcie",
+               .data = &pcie_data,
+       },
        {
                .compatible = "ti,control-phy-usb2-dra7",
                .data = &dra7usb2_data,
@@ -279,7 +320,8 @@ static int omap_control_phy_probe(struct platform_device *pdev)
                }
        }
 
-       if (control_phy->type == OMAP_CTRL_TYPE_PIPE3) {
+       if (control_phy->type == OMAP_CTRL_TYPE_PIPE3 ||
+           control_phy->type == OMAP_CTRL_TYPE_PCIE) {
                control_phy->sys_clk = devm_clk_get(control_phy->dev,
                        "sys_clkin");
                if (IS_ERR(control_phy->sys_clk)) {
@@ -288,6 +330,14 @@ static int omap_control_phy_probe(struct platform_device *pdev)
                }
        }
 
+       if (control_phy->type == OMAP_CTRL_TYPE_PCIE) {
+               res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+                                                  "pcie_pcs");
+               control_phy->pcie_pcs = devm_ioremap_resource(&pdev->dev, res);
+               if (IS_ERR(control_phy->pcie_pcs))
+                       return PTR_ERR(control_phy->pcie_pcs);
+       }
+
        dev_set_drvdata(control_phy->dev, control_phy);
 
        return 0;
index 6174f4b1a5de52fd57bdc7975019501809d7b493..93bcd67f1b22f8341489142ac194b67ce49cc301 100644 (file)
@@ -217,8 +217,10 @@ static int ti_pipe3_init(struct phy *x)
        u32 val;
        int ret = 0;
 
-       if (of_device_is_compatible(phy->dev->of_node, "ti,phy-pipe3-pcie"))
+       if (of_device_is_compatible(phy->dev->of_node, "ti,phy-pipe3-pcie")) {
+               omap_control_pcie_pcs(phy->control_dev, phy->id, 0xF1);
                return 0;
+       }
 
        /* Bring it out of IDLE if it is IDLE */
        val = ti_pipe3_readl(phy->pll_ctrl_base, PLL_CONFIGURATION2);
index 5450403c7546d4e9429468a9225cf62e0fa9d7f6..e9e6cfbfbb589d0393060e2fed0422ec402dd612 100644 (file)
@@ -23,6 +23,7 @@ enum omap_control_phy_type {
        OMAP_CTRL_TYPE_OTGHS = 1,       /* Mailbox OTGHS_CONTROL */
        OMAP_CTRL_TYPE_USB2,    /* USB2_PHY, power down in CONTROL_DEV_CONF */
        OMAP_CTRL_TYPE_PIPE3,   /* PIPE3 PHY, DPLL & seperate Rx/Tx power */
+       OMAP_CTRL_TYPE_PCIE,    /* RX TX control of ACSPCIE */
        OMAP_CTRL_TYPE_DRA7USB2, /* USB2 PHY, power and power_aux e.g. DRA7 */
        OMAP_CTRL_TYPE_AM437USB2, /* USB2 PHY, power e.g. AM437x */
 };
@@ -33,6 +34,7 @@ struct omap_control_phy {
        u32 __iomem *otghs_control;
        u32 __iomem *power;
        u32 __iomem *power_aux;
+       u32 __iomem *pcie_pcs;
 
        struct clk *sys_clk;
 
@@ -63,6 +65,9 @@ enum omap_control_usb_mode {
 #define        OMAP_CTRL_PIPE3_PHY_TX_RX_POWERON       0x3
 #define        OMAP_CTRL_PIPE3_PHY_TX_RX_POWEROFF      0x0
 
+#define        OMAP_CTRL_PCIE_PCS_MASK                 0xff
+#define        OMAP_CTRL_PCIE_PCS_DELAY_COUNT_SHIFT    0x8
+
 #define OMAP_CTRL_USB2_PHY_PD          BIT(28)
 
 #define AM437X_CTRL_USB2_PHY_PD                BIT(0)
@@ -74,6 +79,7 @@ enum omap_control_usb_mode {
 void omap_control_phy_power(struct device *dev, int on);
 void omap_control_usb_set_mode(struct device *dev,
                               enum omap_control_usb_mode mode);
+void omap_control_pcie_pcs(struct device *dev, u8 id, u8 delay);
 #else
 
 static inline void omap_control_phy_power(struct device *dev, int on)
@@ -84,6 +90,10 @@ static inline void omap_control_usb_set_mode(struct device *dev,
        enum omap_control_usb_mode mode)
 {
 }
+
+static inline void omap_control_pcie_pcs(struct device *dev, u8 id, u8 delay)
+{
+}
 #endif
 
 #endif /* __OMAP_CONTROL_PHY_H__ */