aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Lin <shawn.lin@rock-chips.com>2016-11-10 12:14:37 -0500
committerBjorn Helgaas <bhelgaas@google.com>2016-11-10 12:14:37 -0500
commit31a3a7b5b26f75fbe82de10ca99f2b673f6c26b4 (patch)
tree9cb2f1cb7332d2da33a3e1ec17bc2f4677e445ac
parent16d917b130d782b94fa02afc7bdf0d4aae689da4 (diff)
PCI: rockchip: Add three new resets as required properties
pm_rst, aclk_rst, pclk_rst was controlled by ROM code so the software wasn't needed to control it again in theory. But it didn't work properly, so we do need to do it again and add enough delay between the assert of pm_rst and the deassert of pm_rst. The Soc intergrated with this controller, rk3399, is still under MP test internally, so the backward compatibility won't be a big deal. Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Heiko Stuebner <heiko@sntech.de> Acked-by: Rob Herring <robh@kernel.org>
-rw-r--r--Documentation/devicetree/bindings/pci/rockchip-pcie.txt11
-rw-r--r--drivers/pci/host/pcie-rockchip.c62
2 files changed, 70 insertions, 3 deletions
diff --git a/Documentation/devicetree/bindings/pci/rockchip-pcie.txt b/Documentation/devicetree/bindings/pci/rockchip-pcie.txt
index ba67b39939c1..71aeda1ca055 100644
--- a/Documentation/devicetree/bindings/pci/rockchip-pcie.txt
+++ b/Documentation/devicetree/bindings/pci/rockchip-pcie.txt
@@ -26,13 +26,16 @@ Required properties:
26 - "sys" 26 - "sys"
27 - "legacy" 27 - "legacy"
28 - "client" 28 - "client"
29- resets: Must contain five entries for each entry in reset-names. 29- resets: Must contain seven entries for each entry in reset-names.
30 See ../reset/reset.txt for details. 30 See ../reset/reset.txt for details.
31- reset-names: Must include the following names 31- reset-names: Must include the following names
32 - "core" 32 - "core"
33 - "mgmt" 33 - "mgmt"
34 - "mgmt-sticky" 34 - "mgmt-sticky"
35 - "pipe" 35 - "pipe"
36 - "pm"
37 - "aclk"
38 - "pclk"
36- pinctrl-names : The pin control state names 39- pinctrl-names : The pin control state names
37- pinctrl-0: The "default" pinctrl state 40- pinctrl-0: The "default" pinctrl state
38- #interrupt-cells: specifies the number of cells needed to encode an 41- #interrupt-cells: specifies the number of cells needed to encode an
@@ -86,8 +89,10 @@ pcie0: pcie@f8000000 {
86 reg = <0x0 0xf8000000 0x0 0x2000000>, <0x0 0xfd000000 0x0 0x1000000>; 89 reg = <0x0 0xf8000000 0x0 0x2000000>, <0x0 0xfd000000 0x0 0x1000000>;
87 reg-names = "axi-base", "apb-base"; 90 reg-names = "axi-base", "apb-base";
88 resets = <&cru SRST_PCIE_CORE>, <&cru SRST_PCIE_MGMT>, 91 resets = <&cru SRST_PCIE_CORE>, <&cru SRST_PCIE_MGMT>,
89 <&cru SRST_PCIE_MGMT_STICKY>, <&cru SRST_PCIE_PIPE>; 92 <&cru SRST_PCIE_MGMT_STICKY>, <&cru SRST_PCIE_PIPE> ,
90 reset-names = "core", "mgmt", "mgmt-sticky", "pipe"; 93 <&cru SRST_PCIE_PM>, <&cru SRST_P_PCIE>, <&cru SRST_A_PCIE>;
94 reset-names = "core", "mgmt", "mgmt-sticky", "pipe",
95 "pm", "pclk", "aclk";
91 phys = <&pcie_phy>; 96 phys = <&pcie_phy>;
92 phy-names = "pcie-phy"; 97 phy-names = "pcie-phy";
93 pinctrl-names = "default"; 98 pinctrl-names = "default";
diff --git a/drivers/pci/host/pcie-rockchip.c b/drivers/pci/host/pcie-rockchip.c
index e0b22dab9b7a..e04f69beb42d 100644
--- a/drivers/pci/host/pcie-rockchip.c
+++ b/drivers/pci/host/pcie-rockchip.c
@@ -190,6 +190,9 @@ struct rockchip_pcie {
190 struct reset_control *mgmt_rst; 190 struct reset_control *mgmt_rst;
191 struct reset_control *mgmt_sticky_rst; 191 struct reset_control *mgmt_sticky_rst;
192 struct reset_control *pipe_rst; 192 struct reset_control *pipe_rst;
193 struct reset_control *pm_rst;
194 struct reset_control *aclk_rst;
195 struct reset_control *pclk_rst;
193 struct clk *aclk_pcie; 196 struct clk *aclk_pcie;
194 struct clk *aclk_perf_pcie; 197 struct clk *aclk_perf_pcie;
195 struct clk *hclk_pcie; 198 struct clk *hclk_pcie;
@@ -408,6 +411,44 @@ static int rockchip_pcie_init_port(struct rockchip_pcie *rockchip)
408 411
409 gpiod_set_value(rockchip->ep_gpio, 0); 412 gpiod_set_value(rockchip->ep_gpio, 0);
410 413
414 err = reset_control_assert(rockchip->aclk_rst);
415 if (err) {
416 dev_err(dev, "assert aclk_rst err %d\n", err);
417 return err;
418 }
419
420 err = reset_control_assert(rockchip->pclk_rst);
421 if (err) {
422 dev_err(dev, "assert pclk_rst err %d\n", err);
423 return err;
424 }
425
426 err = reset_control_assert(rockchip->pm_rst);
427 if (err) {
428 dev_err(dev, "assert pm_rst err %d\n", err);
429 return err;
430 }
431
432 udelay(10);
433
434 err = reset_control_deassert(rockchip->pm_rst);
435 if (err) {
436 dev_err(dev, "deassert pm_rst err %d\n", err);
437 return err;
438 }
439
440 err = reset_control_deassert(rockchip->aclk_rst);
441 if (err) {
442 dev_err(dev, "deassert mgmt_sticky_rst err %d\n", err);
443 return err;
444 }
445
446 err = reset_control_deassert(rockchip->pclk_rst);
447 if (err) {
448 dev_err(dev, "deassert mgmt_sticky_rst err %d\n", err);
449 return err;
450 }
451
411 err = phy_init(rockchip->phy); 452 err = phy_init(rockchip->phy);
412 if (err < 0) { 453 if (err < 0) {
413 dev_err(dev, "fail to init phy, err %d\n", err); 454 dev_err(dev, "fail to init phy, err %d\n", err);
@@ -781,6 +822,27 @@ static int rockchip_pcie_parse_dt(struct rockchip_pcie *rockchip)
781 return PTR_ERR(rockchip->pipe_rst); 822 return PTR_ERR(rockchip->pipe_rst);
782 } 823 }
783 824
825 rockchip->pm_rst = devm_reset_control_get(dev, "pm");
826 if (IS_ERR(rockchip->pm_rst)) {
827 if (PTR_ERR(rockchip->pm_rst) != -EPROBE_DEFER)
828 dev_err(dev, "missing pm reset property in node\n");
829 return PTR_ERR(rockchip->pm_rst);
830 }
831
832 rockchip->pclk_rst = devm_reset_control_get(dev, "pclk");
833 if (IS_ERR(rockchip->pclk_rst)) {
834 if (PTR_ERR(rockchip->pclk_rst) != -EPROBE_DEFER)
835 dev_err(dev, "missing pclk reset property in node\n");
836 return PTR_ERR(rockchip->pclk_rst);
837 }
838
839 rockchip->aclk_rst = devm_reset_control_get(dev, "aclk");
840 if (IS_ERR(rockchip->aclk_rst)) {
841 if (PTR_ERR(rockchip->aclk_rst) != -EPROBE_DEFER)
842 dev_err(dev, "missing aclk reset property in node\n");
843 return PTR_ERR(rockchip->aclk_rst);
844 }
845
784 rockchip->ep_gpio = devm_gpiod_get(dev, "ep", GPIOD_OUT_HIGH); 846 rockchip->ep_gpio = devm_gpiod_get(dev, "ep", GPIOD_OUT_HIGH);
785 if (IS_ERR(rockchip->ep_gpio)) { 847 if (IS_ERR(rockchip->ep_gpio)) {
786 dev_err(dev, "missing ep-gpios property in node\n"); 848 dev_err(dev, "missing ep-gpios property in node\n");