diff options
Diffstat (limited to 'drivers/pci/host/pci-tegra.c')
-rw-r--r-- | drivers/pci/host/pci-tegra.c | 53 |
1 files changed, 38 insertions, 15 deletions
diff --git a/drivers/pci/host/pci-tegra.c b/drivers/pci/host/pci-tegra.c index 0afbbbc55c81..0175041ab728 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 | ||
@@ -952,13 +955,14 @@ static int tegra_pcie_power_on(struct tegra_pcie *pcie) | |||
952 | } | 955 | } |
953 | 956 | ||
954 | err = tegra_powergate_sequence_power_up(TEGRA_POWERGATE_PCIE, | 957 | err = tegra_powergate_sequence_power_up(TEGRA_POWERGATE_PCIE, |
955 | pcie->pex_clk); | 958 | pcie->pex_clk, |
959 | pcie->pex_rst); | ||
956 | if (err) { | 960 | if (err) { |
957 | dev_err(pcie->dev, "powerup sequence failed: %d\n", err); | 961 | dev_err(pcie->dev, "powerup sequence failed: %d\n", err); |
958 | return err; | 962 | return err; |
959 | } | 963 | } |
960 | 964 | ||
961 | tegra_periph_reset_deassert(pcie->afi_clk); | 965 | reset_control_deassert(pcie->afi_rst); |
962 | 966 | ||
963 | err = clk_prepare_enable(pcie->afi_clk); | 967 | err = clk_prepare_enable(pcie->afi_clk); |
964 | if (err < 0) { | 968 | if (err < 0) { |
@@ -996,10 +1000,6 @@ static int tegra_pcie_clocks_get(struct tegra_pcie *pcie) | |||
996 | if (IS_ERR(pcie->afi_clk)) | 1000 | if (IS_ERR(pcie->afi_clk)) |
997 | return PTR_ERR(pcie->afi_clk); | 1001 | return PTR_ERR(pcie->afi_clk); |
998 | 1002 | ||
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"); | 1003 | pcie->pll_e = devm_clk_get(pcie->dev, "pll_e"); |
1004 | if (IS_ERR(pcie->pll_e)) | 1004 | if (IS_ERR(pcie->pll_e)) |
1005 | return PTR_ERR(pcie->pll_e); | 1005 | return PTR_ERR(pcie->pll_e); |
@@ -1013,6 +1013,23 @@ static int tegra_pcie_clocks_get(struct tegra_pcie *pcie) | |||
1013 | return 0; | 1013 | return 0; |
1014 | } | 1014 | } |
1015 | 1015 | ||
1016 | static int tegra_pcie_resets_get(struct tegra_pcie *pcie) | ||
1017 | { | ||
1018 | pcie->pex_rst = devm_reset_control_get(pcie->dev, "pex"); | ||
1019 | if (IS_ERR(pcie->pex_rst)) | ||
1020 | return PTR_ERR(pcie->pex_rst); | ||
1021 | |||
1022 | pcie->afi_rst = devm_reset_control_get(pcie->dev, "afi"); | ||
1023 | if (IS_ERR(pcie->afi_rst)) | ||
1024 | return PTR_ERR(pcie->afi_rst); | ||
1025 | |||
1026 | pcie->pcie_xrst = devm_reset_control_get(pcie->dev, "pcie_x"); | ||
1027 | if (IS_ERR(pcie->pcie_xrst)) | ||
1028 | return PTR_ERR(pcie->pcie_xrst); | ||
1029 | |||
1030 | return 0; | ||
1031 | } | ||
1032 | |||
1016 | static int tegra_pcie_get_resources(struct tegra_pcie *pcie) | 1033 | static int tegra_pcie_get_resources(struct tegra_pcie *pcie) |
1017 | { | 1034 | { |
1018 | struct platform_device *pdev = to_platform_device(pcie->dev); | 1035 | struct platform_device *pdev = to_platform_device(pcie->dev); |
@@ -1025,6 +1042,12 @@ static int tegra_pcie_get_resources(struct tegra_pcie *pcie) | |||
1025 | return err; | 1042 | return err; |
1026 | } | 1043 | } |
1027 | 1044 | ||
1045 | err = tegra_pcie_resets_get(pcie); | ||
1046 | if (err) { | ||
1047 | dev_err(&pdev->dev, "failed to get resets: %d\n", err); | ||
1048 | return err; | ||
1049 | } | ||
1050 | |||
1028 | err = tegra_pcie_power_on(pcie); | 1051 | err = tegra_pcie_power_on(pcie); |
1029 | if (err) { | 1052 | if (err) { |
1030 | dev_err(&pdev->dev, "failed to power up: %d\n", err); | 1053 | dev_err(&pdev->dev, "failed to power up: %d\n", err); |