aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/host
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2013-11-06 17:56:58 -0500
committerStephen Warren <swarren@nvidia.com>2013-12-11 18:42:56 -0500
commit3127a6b2a2342ecd7d7579ccbf39b50908b9df02 (patch)
treea22cadbf430f921da6ead11793245687dd62c858 /drivers/pci/host
parent6d5b988e7dc56bb97c39bdcbc006fadcd6ca371b (diff)
pci: tegra: use reset framework
Tegra's clock driver now provides an implementation of the common reset API (include/linux/reset.h). Use this instead of the old Tegra- specific API; that will soon be removed. The old Tegra-specific API used a struct clock to represent the module to reset. Some of the clocks retrieved during probe() were only used for reset purposes, and indeed aren't even true clocks. So, there's no need to get() them any more. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Thierry Reding <treding@nvidia.com> Acked-by: Thierry Reding <treding@nvidia.com>
Diffstat (limited to 'drivers/pci/host')
-rw-r--r--drivers/pci/host/pci-tegra.c50
1 files changed, 36 insertions, 14 deletions
diff --git a/drivers/pci/host/pci-tegra.c b/drivers/pci/host/pci-tegra.c
index 0afbbbc55c81..6681c3182c85 100644
--- a/drivers/pci/host/pci-tegra.c
+++ b/drivers/pci/host/pci-tegra.c
@@ -25,7 +25,6 @@
25 */ 25 */
26 26
27#include <linux/clk.h> 27#include <linux/clk.h>
28#include <linux/clk/tegra.h>
29#include <linux/delay.h> 28#include <linux/delay.h>
30#include <linux/export.h> 29#include <linux/export.h>
31#include <linux/interrupt.h> 30#include <linux/interrupt.h>
@@ -39,6 +38,7 @@
39#include <linux/of_platform.h> 38#include <linux/of_platform.h>
40#include <linux/pci.h> 39#include <linux/pci.h>
41#include <linux/platform_device.h> 40#include <linux/platform_device.h>
41#include <linux/reset.h>
42#include <linux/sizes.h> 42#include <linux/sizes.h>
43#include <linux/slab.h> 43#include <linux/slab.h>
44#include <linux/tegra-cpuidle.h> 44#include <linux/tegra-cpuidle.h>
@@ -259,10 +259,13 @@ struct tegra_pcie {
259 259
260 struct clk *pex_clk; 260 struct clk *pex_clk;
261 struct clk *afi_clk; 261 struct clk *afi_clk;
262 struct clk *pcie_xclk;
263 struct clk *pll_e; 262 struct clk *pll_e;
264 struct clk *cml_clk; 263 struct clk *cml_clk;
265 264
265 struct reset_control *pex_rst;
266 struct reset_control *afi_rst;
267 struct reset_control *pcie_xrst;
268
266 struct tegra_msi msi; 269 struct tegra_msi msi;
267 270
268 struct list_head ports; 271 struct list_head ports;
@@ -858,7 +861,7 @@ static int tegra_pcie_enable_controller(struct tegra_pcie *pcie)
858 pads_writel(pcie, value, PADS_CTL); 861 pads_writel(pcie, value, PADS_CTL);
859 862
860 /* take the PCIe interface module out of reset */ 863 /* take the PCIe interface module out of reset */
861 tegra_periph_reset_deassert(pcie->pcie_xclk); 864 reset_control_deassert(pcie->pcie_xrst);
862 865
863 /* finally enable PCIe */ 866 /* finally enable PCIe */
864 value = afi_readl(pcie, AFI_CONFIGURATION); 867 value = afi_readl(pcie, AFI_CONFIGURATION);
@@ -891,9 +894,9 @@ static void tegra_pcie_power_off(struct tegra_pcie *pcie)
891 894
892 /* TODO: disable and unprepare clocks? */ 895 /* TODO: disable and unprepare clocks? */
893 896
894 tegra_periph_reset_assert(pcie->pcie_xclk); 897 reset_control_assert(pcie->pcie_xrst);
895 tegra_periph_reset_assert(pcie->afi_clk); 898 reset_control_assert(pcie->afi_rst);
896 tegra_periph_reset_assert(pcie->pex_clk); 899 reset_control_assert(pcie->pex_rst);
897 900
898 tegra_powergate_power_off(TEGRA_POWERGATE_PCIE); 901 tegra_powergate_power_off(TEGRA_POWERGATE_PCIE);
899 902
@@ -921,9 +924,9 @@ static int tegra_pcie_power_on(struct tegra_pcie *pcie)
921 const struct tegra_pcie_soc_data *soc = pcie->soc_data; 924 const struct tegra_pcie_soc_data *soc = pcie->soc_data;
922 int err; 925 int err;
923 926
924 tegra_periph_reset_assert(pcie->pcie_xclk); 927 reset_control_assert(pcie->pcie_xrst);
925 tegra_periph_reset_assert(pcie->afi_clk); 928 reset_control_assert(pcie->afi_rst);
926 tegra_periph_reset_assert(pcie->pex_clk); 929 reset_control_assert(pcie->pex_rst);
927 930
928 tegra_powergate_power_off(TEGRA_POWERGATE_PCIE); 931 tegra_powergate_power_off(TEGRA_POWERGATE_PCIE);
929 932
@@ -958,7 +961,7 @@ static int tegra_pcie_power_on(struct tegra_pcie *pcie)
958 return err; 961 return err;
959 } 962 }
960 963
961 tegra_periph_reset_deassert(pcie->afi_clk); 964 reset_control_deassert(pcie->afi_rst);
962 965
963 err = clk_prepare_enable(pcie->afi_clk); 966 err = clk_prepare_enable(pcie->afi_clk);
964 if (err < 0) { 967 if (err < 0) {
@@ -996,10 +999,6 @@ static int tegra_pcie_clocks_get(struct tegra_pcie *pcie)
996 if (IS_ERR(pcie->afi_clk)) 999 if (IS_ERR(pcie->afi_clk))
997 return PTR_ERR(pcie->afi_clk); 1000 return PTR_ERR(pcie->afi_clk);
998 1001
999 pcie->pcie_xclk = devm_clk_get(pcie->dev, "pcie_xclk");
1000 if (IS_ERR(pcie->pcie_xclk))
1001 return PTR_ERR(pcie->pcie_xclk);
1002
1003 pcie->pll_e = devm_clk_get(pcie->dev, "pll_e"); 1002 pcie->pll_e = devm_clk_get(pcie->dev, "pll_e");
1004 if (IS_ERR(pcie->pll_e)) 1003 if (IS_ERR(pcie->pll_e))
1005 return PTR_ERR(pcie->pll_e); 1004 return PTR_ERR(pcie->pll_e);
@@ -1013,6 +1012,23 @@ static int tegra_pcie_clocks_get(struct tegra_pcie *pcie)
1013 return 0; 1012 return 0;
1014} 1013}
1015 1014
1015static int tegra_pcie_resets_get(struct tegra_pcie *pcie)
1016{
1017 pcie->pex_rst = devm_reset_control_get(pcie->dev, "pex");
1018 if (IS_ERR(pcie->pex_rst))
1019 return PTR_ERR(pcie->pex_rst);
1020
1021 pcie->afi_rst = devm_reset_control_get(pcie->dev, "afi");
1022 if (IS_ERR(pcie->afi_rst))
1023 return PTR_ERR(pcie->afi_rst);
1024
1025 pcie->pcie_xrst = devm_reset_control_get(pcie->dev, "pcie_x");
1026 if (IS_ERR(pcie->pcie_xrst))
1027 return PTR_ERR(pcie->pcie_xrst);
1028
1029 return 0;
1030}
1031
1016static int tegra_pcie_get_resources(struct tegra_pcie *pcie) 1032static int tegra_pcie_get_resources(struct tegra_pcie *pcie)
1017{ 1033{
1018 struct platform_device *pdev = to_platform_device(pcie->dev); 1034 struct platform_device *pdev = to_platform_device(pcie->dev);
@@ -1025,6 +1041,12 @@ static int tegra_pcie_get_resources(struct tegra_pcie *pcie)
1025 return err; 1041 return err;
1026 } 1042 }
1027 1043
1044 err = tegra_pcie_resets_get(pcie);
1045 if (err) {
1046 dev_err(&pdev->dev, "failed to get resets: %d\n", err);
1047 return err;
1048 }
1049
1028 err = tegra_pcie_power_on(pcie); 1050 err = tegra_pcie_power_on(pcie);
1029 if (err) { 1051 if (err) {
1030 dev_err(&pdev->dev, "failed to power up: %d\n", err); 1052 dev_err(&pdev->dev, "failed to power up: %d\n", err);