aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoger Quadros <rogerq@ti.com>2015-07-17 09:47:22 -0400
committerKishon Vijay Abraham I <kishon@ti.com>2015-08-01 06:22:58 -0400
commitc934b3612747bde6c81cf10c2bbde956c6690aec (patch)
tree548ab499e4d7646675aa9b15558efd29713ec8fe
parent7167bf8b7f3f19eeea4602ccc39f26a26a636d8e (diff)
phy: ti-pipe3: i783 workaround for SATA lockup after dpll unlock/relock
SATA_PLL_SOFT_RESET bit of CTRL_CORE_SMA_SW_0 must be toggled between a SATA DPLL unlock and re-lock to prevent SATA lockup. Introduce a new DT parameter 'syscon-pllreset' to provide the syscon regmap access to this register which sits in the control module. If the register is not provided we fallback to the old behaviour i.e. SATA DPLL refclk will not be disabled and we prevent SoC low power states. Signed-off-by: Roger Quadros <rogerq@ti.com> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
-rw-r--r--Documentation/devicetree/bindings/phy/ti-phy.txt16
-rw-r--r--drivers/phy/phy-ti-pipe3.c61
2 files changed, 71 insertions, 6 deletions
diff --git a/Documentation/devicetree/bindings/phy/ti-phy.txt b/Documentation/devicetree/bindings/phy/ti-phy.txt
index 305e3df3d9b1..9cf9446eaf2e 100644
--- a/Documentation/devicetree/bindings/phy/ti-phy.txt
+++ b/Documentation/devicetree/bindings/phy/ti-phy.txt
@@ -82,6 +82,9 @@ Optional properties:
82 - id: If there are multiple instance of the same type, in order to 82 - id: If there are multiple instance of the same type, in order to
83 differentiate between each instance "id" can be used (e.g., multi-lane PCIe 83 differentiate between each instance "id" can be used (e.g., multi-lane PCIe
84 PHY). If "id" is not provided, it is set to default value of '1'. 84 PHY). If "id" is not provided, it is set to default value of '1'.
85 - syscon-pllreset: Handle to system control region that contains the
86 CTRL_CORE_SMA_SW_0 register and register offset to the CTRL_CORE_SMA_SW_0
87 register that contains the SATA_PLL_SOFT_RESET bit. Only valid for sata_phy.
85 88
86This is usually a subnode of ocp2scp to which it is connected. 89This is usually a subnode of ocp2scp to which it is connected.
87 90
@@ -100,3 +103,16 @@ usb3phy@4a084400 {
100 "sysclk", 103 "sysclk",
101 "refclk"; 104 "refclk";
102}; 105};
106
107sata_phy: phy@4A096000 {
108 compatible = "ti,phy-pipe3-sata";
109 reg = <0x4A096000 0x80>, /* phy_rx */
110 <0x4A096400 0x64>, /* phy_tx */
111 <0x4A096800 0x40>; /* pll_ctrl */
112 reg-names = "phy_rx", "phy_tx", "pll_ctrl";
113 ctrl-module = <&omap_control_sata>;
114 clocks = <&sys_clkin1>, <&sata_ref_clk>;
115 clock-names = "sysclk", "refclk";
116 syscon-pllreset = <&scm_conf 0x3fc>;
117 #phy-cells = <0>;
118};
diff --git a/drivers/phy/phy-ti-pipe3.c b/drivers/phy/phy-ti-pipe3.c
index 3510b81db3fa..08020dc2c7c8 100644
--- a/drivers/phy/phy-ti-pipe3.c
+++ b/drivers/phy/phy-ti-pipe3.c
@@ -28,6 +28,8 @@
28#include <linux/delay.h> 28#include <linux/delay.h>
29#include <linux/phy/omap_control_phy.h> 29#include <linux/phy/omap_control_phy.h>
30#include <linux/of_platform.h> 30#include <linux/of_platform.h>
31#include <linux/mfd/syscon.h>
32#include <linux/regmap.h>
31 33
32#define PLL_STATUS 0x00000004 34#define PLL_STATUS 0x00000004
33#define PLL_GO 0x00000008 35#define PLL_GO 0x00000008
@@ -52,6 +54,8 @@
52#define PLL_LOCK 0x2 54#define PLL_LOCK 0x2
53#define PLL_IDLE 0x1 55#define PLL_IDLE 0x1
54 56
57#define SATA_PLL_SOFT_RESET BIT(18)
58
55/* 59/*
56 * This is an Empirical value that works, need to confirm the actual 60 * This is an Empirical value that works, need to confirm the actual
57 * value required for the PIPE3PHY_PLL_CONFIGURATION2.PLL_IDLE status 61 * value required for the PIPE3PHY_PLL_CONFIGURATION2.PLL_IDLE status
@@ -82,6 +86,9 @@ struct ti_pipe3 {
82 struct clk *refclk; 86 struct clk *refclk;
83 struct clk *div_clk; 87 struct clk *div_clk;
84 struct pipe3_dpll_map *dpll_map; 88 struct pipe3_dpll_map *dpll_map;
89 struct regmap *dpll_reset_syscon; /* ctrl. reg. acces */
90 unsigned int dpll_reset_reg; /* reg. index within syscon */
91 bool sata_refclk_enabled;
85}; 92};
86 93
87static struct pipe3_dpll_map dpll_map_usb[] = { 94static struct pipe3_dpll_map dpll_map_usb[] = {
@@ -249,8 +256,11 @@ static int ti_pipe3_exit(struct phy *x)
249 u32 val; 256 u32 val;
250 unsigned long timeout; 257 unsigned long timeout;
251 258
252 /* SATA DPLL can't be powered down due to Errata i783 */ 259 /* If dpll_reset_syscon is not present we wont power down SATA DPLL
253 if (of_device_is_compatible(phy->dev->of_node, "ti,phy-pipe3-sata")) 260 * due to Errata i783
261 */
262 if (of_device_is_compatible(phy->dev->of_node, "ti,phy-pipe3-sata") &&
263 !phy->dpll_reset_syscon)
254 return 0; 264 return 0;
255 265
256 /* PCIe doesn't have internal DPLL */ 266 /* PCIe doesn't have internal DPLL */
@@ -276,6 +286,14 @@ static int ti_pipe3_exit(struct phy *x)
276 } 286 }
277 } 287 }
278 288
289 /* i783: SATA needs control bit toggle after PLL unlock */
290 if (of_device_is_compatible(phy->dev->of_node, "ti,phy-pipe3-sata")) {
291 regmap_update_bits(phy->dpll_reset_syscon, phy->dpll_reset_reg,
292 SATA_PLL_SOFT_RESET, SATA_PLL_SOFT_RESET);
293 regmap_update_bits(phy->dpll_reset_syscon, phy->dpll_reset_reg,
294 SATA_PLL_SOFT_RESET, 0);
295 }
296
279 ti_pipe3_disable_clocks(phy); 297 ti_pipe3_disable_clocks(phy);
280 298
281 return 0; 299 return 0;
@@ -350,6 +368,21 @@ static int ti_pipe3_probe(struct platform_device *pdev)
350 } 368 }
351 } else { 369 } else {
352 phy->wkupclk = ERR_PTR(-ENODEV); 370 phy->wkupclk = ERR_PTR(-ENODEV);
371 phy->dpll_reset_syscon = syscon_regmap_lookup_by_phandle(node,
372 "syscon-pllreset");
373 if (IS_ERR(phy->dpll_reset_syscon)) {
374 dev_info(&pdev->dev,
375 "can't get syscon-pllreset, sata dpll won't idle\n");
376 phy->dpll_reset_syscon = NULL;
377 } else {
378 if (of_property_read_u32_index(node,
379 "syscon-pllreset", 1,
380 &phy->dpll_reset_reg)) {
381 dev_err(&pdev->dev,
382 "couldn't get pllreset reg. offset\n");
383 return -EINVAL;
384 }
385 }
353 } 386 }
354 387
355 if (of_device_is_compatible(node, "ti,phy-pipe3-pcie")) { 388 if (of_device_is_compatible(node, "ti,phy-pipe3-pcie")) {
@@ -402,10 +435,16 @@ static int ti_pipe3_probe(struct platform_device *pdev)
402 435
403 platform_set_drvdata(pdev, phy); 436 platform_set_drvdata(pdev, phy);
404 pm_runtime_enable(phy->dev); 437 pm_runtime_enable(phy->dev);
405 /* Prevent auto-disable of refclk for SATA PHY due to Errata i783 */ 438
406 if (of_device_is_compatible(node, "ti,phy-pipe3-sata")) 439 /*
407 if (!IS_ERR(phy->refclk)) 440 * Prevent auto-disable of refclk for SATA PHY due to Errata i783
441 */
442 if (of_device_is_compatible(node, "ti,phy-pipe3-sata")) {
443 if (!IS_ERR(phy->refclk)) {
408 clk_prepare_enable(phy->refclk); 444 clk_prepare_enable(phy->refclk);
445 phy->sata_refclk_enabled = true;
446 }
447 }
409 448
410 generic_phy = devm_phy_create(phy->dev, NULL, &ops); 449 generic_phy = devm_phy_create(phy->dev, NULL, &ops);
411 if (IS_ERR(generic_phy)) 450 if (IS_ERR(generic_phy))
@@ -472,8 +511,18 @@ static void ti_pipe3_disable_clocks(struct ti_pipe3 *phy)
472{ 511{
473 if (!IS_ERR(phy->wkupclk)) 512 if (!IS_ERR(phy->wkupclk))
474 clk_disable_unprepare(phy->wkupclk); 513 clk_disable_unprepare(phy->wkupclk);
475 if (!IS_ERR(phy->refclk)) 514 if (!IS_ERR(phy->refclk)) {
476 clk_disable_unprepare(phy->refclk); 515 clk_disable_unprepare(phy->refclk);
516 /*
517 * SATA refclk needs an additional disable as we left it
518 * on in probe to avoid Errata i783
519 */
520 if (phy->sata_refclk_enabled) {
521 clk_disable_unprepare(phy->refclk);
522 phy->sata_refclk_enabled = false;
523 }
524 }
525
477 if (!IS_ERR(phy->div_clk)) 526 if (!IS_ERR(phy->div_clk))
478 clk_disable_unprepare(phy->div_clk); 527 clk_disable_unprepare(phy->div_clk);
479} 528}