diff options
| author | Andrey Smirnov <andrew.smirnov@gmail.com> | 2019-02-01 19:15:20 -0500 |
|---|---|---|
| committer | Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> | 2019-02-04 06:52:19 -0500 |
| commit | e8e4d4e95701a10691c53165c55789e5e50ba3f5 (patch) | |
| tree | d148d48df846fc20b816fc65d83f5f88e9bc3206 /drivers | |
| parent | 657722570a555c728c59f17f7825c812c124dc28 (diff) | |
PCI: imx6: Introduce drvdata
Introduce driver data struct. This will simplify handling of device
specific differences.
Signed-off-by: Stefan Agner <stefan@agner.ch>
[andrew.smirnov@gmail.com reformatted drvdata, to simplify future diffs]
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: Chris Healy <cphealy@gmail.com>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Leonard Crestez <leonard.crestez@nxp.com>
Cc: "A.s. Dong" <aisheng.dong@nxp.com>
Cc: Richard Zhu <hongxing.zhu@nxp.com>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/pci/controller/dwc/pci-imx6.c | 56 |
1 files changed, 37 insertions, 19 deletions
diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index 52e47dac028f..1e940ba7e4c4 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c | |||
| @@ -41,6 +41,10 @@ enum imx6_pcie_variants { | |||
| 41 | IMX7D, | 41 | IMX7D, |
| 42 | }; | 42 | }; |
| 43 | 43 | ||
| 44 | struct imx6_pcie_drvdata { | ||
| 45 | enum imx6_pcie_variants variant; | ||
| 46 | }; | ||
| 47 | |||
| 44 | struct imx6_pcie { | 48 | struct imx6_pcie { |
| 45 | struct dw_pcie *pci; | 49 | struct dw_pcie *pci; |
| 46 | int reset_gpio; | 50 | int reset_gpio; |
| @@ -53,7 +57,6 @@ struct imx6_pcie { | |||
| 53 | struct reset_control *pciephy_reset; | 57 | struct reset_control *pciephy_reset; |
| 54 | struct reset_control *apps_reset; | 58 | struct reset_control *apps_reset; |
| 55 | struct reset_control *turnoff_reset; | 59 | struct reset_control *turnoff_reset; |
| 56 | enum imx6_pcie_variants variant; | ||
| 57 | u32 tx_deemph_gen1; | 60 | u32 tx_deemph_gen1; |
| 58 | u32 tx_deemph_gen2_3p5db; | 61 | u32 tx_deemph_gen2_3p5db; |
| 59 | u32 tx_deemph_gen2_6db; | 62 | u32 tx_deemph_gen2_6db; |
| @@ -66,6 +69,7 @@ struct imx6_pcie { | |||
| 66 | struct device *pd_pcie; | 69 | struct device *pd_pcie; |
| 67 | /* power domain for pcie phy */ | 70 | /* power domain for pcie phy */ |
| 68 | struct device *pd_pcie_phy; | 71 | struct device *pd_pcie_phy; |
| 72 | const struct imx6_pcie_drvdata *drvdata; | ||
| 69 | }; | 73 | }; |
| 70 | 74 | ||
| 71 | /* Parameters for the waiting for PCIe PHY PLL to lock on i.MX7 */ | 75 | /* Parameters for the waiting for PCIe PHY PLL to lock on i.MX7 */ |
| @@ -339,7 +343,7 @@ static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie) | |||
| 339 | { | 343 | { |
| 340 | struct device *dev = imx6_pcie->pci->dev; | 344 | struct device *dev = imx6_pcie->pci->dev; |
| 341 | 345 | ||
| 342 | switch (imx6_pcie->variant) { | 346 | switch (imx6_pcie->drvdata->variant) { |
| 343 | case IMX7D: | 347 | case IMX7D: |
| 344 | reset_control_assert(imx6_pcie->pciephy_reset); | 348 | reset_control_assert(imx6_pcie->pciephy_reset); |
| 345 | reset_control_assert(imx6_pcie->apps_reset); | 349 | reset_control_assert(imx6_pcie->apps_reset); |
| @@ -381,7 +385,7 @@ static int imx6_pcie_enable_ref_clk(struct imx6_pcie *imx6_pcie) | |||
| 381 | struct device *dev = pci->dev; | 385 | struct device *dev = pci->dev; |
| 382 | int ret = 0; | 386 | int ret = 0; |
| 383 | 387 | ||
| 384 | switch (imx6_pcie->variant) { | 388 | switch (imx6_pcie->drvdata->variant) { |
| 385 | case IMX6SX: | 389 | case IMX6SX: |
| 386 | ret = clk_prepare_enable(imx6_pcie->pcie_inbound_axi); | 390 | ret = clk_prepare_enable(imx6_pcie->pcie_inbound_axi); |
| 387 | if (ret) { | 391 | if (ret) { |
| @@ -484,7 +488,7 @@ static void imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie) | |||
| 484 | !imx6_pcie->gpio_active_high); | 488 | !imx6_pcie->gpio_active_high); |
| 485 | } | 489 | } |
| 486 | 490 | ||
| 487 | switch (imx6_pcie->variant) { | 491 | switch (imx6_pcie->drvdata->variant) { |
| 488 | case IMX7D: | 492 | case IMX7D: |
| 489 | reset_control_deassert(imx6_pcie->pciephy_reset); | 493 | reset_control_deassert(imx6_pcie->pciephy_reset); |
| 490 | imx7d_pcie_wait_for_phy_pll_lock(imx6_pcie); | 494 | imx7d_pcie_wait_for_phy_pll_lock(imx6_pcie); |
| @@ -522,7 +526,7 @@ err_pcie_phy: | |||
| 522 | 526 | ||
| 523 | static void imx6_pcie_init_phy(struct imx6_pcie *imx6_pcie) | 527 | static void imx6_pcie_init_phy(struct imx6_pcie *imx6_pcie) |
| 524 | { | 528 | { |
| 525 | switch (imx6_pcie->variant) { | 529 | switch (imx6_pcie->drvdata->variant) { |
| 526 | case IMX7D: | 530 | case IMX7D: |
| 527 | regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, | 531 | regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, |
| 528 | IMX7D_GPR12_PCIE_PHY_REFCLK_SEL, 0); | 532 | IMX7D_GPR12_PCIE_PHY_REFCLK_SEL, 0); |
| @@ -644,7 +648,7 @@ static void imx6_pcie_ltssm_enable(struct device *dev) | |||
| 644 | { | 648 | { |
| 645 | struct imx6_pcie *imx6_pcie = dev_get_drvdata(dev); | 649 | struct imx6_pcie *imx6_pcie = dev_get_drvdata(dev); |
| 646 | 650 | ||
| 647 | switch (imx6_pcie->variant) { | 651 | switch (imx6_pcie->drvdata->variant) { |
| 648 | case IMX6Q: | 652 | case IMX6Q: |
| 649 | case IMX6SX: | 653 | case IMX6SX: |
| 650 | case IMX6QP: | 654 | case IMX6QP: |
| @@ -697,7 +701,7 @@ static int imx6_pcie_establish_link(struct imx6_pcie *imx6_pcie) | |||
| 697 | tmp |= PORT_LOGIC_SPEED_CHANGE; | 701 | tmp |= PORT_LOGIC_SPEED_CHANGE; |
| 698 | dw_pcie_writel_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL, tmp); | 702 | dw_pcie_writel_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL, tmp); |
| 699 | 703 | ||
| 700 | if (imx6_pcie->variant != IMX7D) { | 704 | if (imx6_pcie->drvdata->variant != IMX7D) { |
| 701 | /* | 705 | /* |
| 702 | * On i.MX7, DIRECT_SPEED_CHANGE behaves differently | 706 | * On i.MX7, DIRECT_SPEED_CHANGE behaves differently |
| 703 | * from i.MX6 family when no link speed transition | 707 | * from i.MX6 family when no link speed transition |
| @@ -794,7 +798,7 @@ static void imx6_pcie_ltssm_disable(struct device *dev) | |||
| 794 | { | 798 | { |
| 795 | struct imx6_pcie *imx6_pcie = dev_get_drvdata(dev); | 799 | struct imx6_pcie *imx6_pcie = dev_get_drvdata(dev); |
| 796 | 800 | ||
| 797 | switch (imx6_pcie->variant) { | 801 | switch (imx6_pcie->drvdata->variant) { |
| 798 | case IMX6SX: | 802 | case IMX6SX: |
| 799 | case IMX6QP: | 803 | case IMX6QP: |
| 800 | regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, | 804 | regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, |
| @@ -820,7 +824,7 @@ static void imx6_pcie_pm_turnoff(struct imx6_pcie *imx6_pcie) | |||
| 820 | } | 824 | } |
| 821 | 825 | ||
| 822 | /* Others poke directly at IOMUXC registers */ | 826 | /* Others poke directly at IOMUXC registers */ |
| 823 | switch (imx6_pcie->variant) { | 827 | switch (imx6_pcie->drvdata->variant) { |
| 824 | case IMX6SX: | 828 | case IMX6SX: |
| 825 | regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, | 829 | regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, |
| 826 | IMX6SX_GPR12_PCIE_PM_TURN_OFF, | 830 | IMX6SX_GPR12_PCIE_PM_TURN_OFF, |
| @@ -850,7 +854,7 @@ static void imx6_pcie_clk_disable(struct imx6_pcie *imx6_pcie) | |||
| 850 | clk_disable_unprepare(imx6_pcie->pcie_phy); | 854 | clk_disable_unprepare(imx6_pcie->pcie_phy); |
| 851 | clk_disable_unprepare(imx6_pcie->pcie_bus); | 855 | clk_disable_unprepare(imx6_pcie->pcie_bus); |
| 852 | 856 | ||
| 853 | switch (imx6_pcie->variant) { | 857 | switch (imx6_pcie->drvdata->variant) { |
| 854 | case IMX6SX: | 858 | case IMX6SX: |
| 855 | clk_disable_unprepare(imx6_pcie->pcie_inbound_axi); | 859 | clk_disable_unprepare(imx6_pcie->pcie_inbound_axi); |
| 856 | break; | 860 | break; |
| @@ -866,8 +870,8 @@ static void imx6_pcie_clk_disable(struct imx6_pcie *imx6_pcie) | |||
| 866 | 870 | ||
| 867 | static inline bool imx6_pcie_supports_suspend(struct imx6_pcie *imx6_pcie) | 871 | static inline bool imx6_pcie_supports_suspend(struct imx6_pcie *imx6_pcie) |
| 868 | { | 872 | { |
| 869 | return (imx6_pcie->variant == IMX7D || | 873 | return (imx6_pcie->drvdata->variant == IMX7D || |
| 870 | imx6_pcie->variant == IMX6SX); | 874 | imx6_pcie->drvdata->variant == IMX6SX); |
| 871 | } | 875 | } |
| 872 | 876 | ||
| 873 | static int imx6_pcie_suspend_noirq(struct device *dev) | 877 | static int imx6_pcie_suspend_noirq(struct device *dev) |
| @@ -933,8 +937,7 @@ static int imx6_pcie_probe(struct platform_device *pdev) | |||
| 933 | pci->ops = &dw_pcie_ops; | 937 | pci->ops = &dw_pcie_ops; |
| 934 | 938 | ||
| 935 | imx6_pcie->pci = pci; | 939 | imx6_pcie->pci = pci; |
| 936 | imx6_pcie->variant = | 940 | imx6_pcie->drvdata = of_device_get_match_data(dev); |
| 937 | (enum imx6_pcie_variants)of_device_get_match_data(dev); | ||
| 938 | 941 | ||
| 939 | dbi_base = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 942 | dbi_base = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 940 | pci->dbi_base = devm_ioremap_resource(dev, dbi_base); | 943 | pci->dbi_base = devm_ioremap_resource(dev, dbi_base); |
| @@ -978,7 +981,7 @@ static int imx6_pcie_probe(struct platform_device *pdev) | |||
| 978 | return PTR_ERR(imx6_pcie->pcie); | 981 | return PTR_ERR(imx6_pcie->pcie); |
| 979 | } | 982 | } |
| 980 | 983 | ||
| 981 | switch (imx6_pcie->variant) { | 984 | switch (imx6_pcie->drvdata->variant) { |
| 982 | case IMX6SX: | 985 | case IMX6SX: |
| 983 | imx6_pcie->pcie_inbound_axi = devm_clk_get(dev, | 986 | imx6_pcie->pcie_inbound_axi = devm_clk_get(dev, |
| 984 | "pcie_inbound_axi"); | 987 | "pcie_inbound_axi"); |
| @@ -1084,11 +1087,26 @@ static void imx6_pcie_shutdown(struct platform_device *pdev) | |||
| 1084 | imx6_pcie_assert_core_reset(imx6_pcie); | 1087 | imx6_pcie_assert_core_reset(imx6_pcie); |
| 1085 | } | 1088 | } |
| 1086 | 1089 | ||
| 1090 | static const struct imx6_pcie_drvdata drvdata[] = { | ||
| 1091 | [IMX6Q] = { | ||
| 1092 | .variant = IMX6Q, | ||
| 1093 | }, | ||
| 1094 | [IMX6SX] = { | ||
| 1095 | .variant = IMX6SX, | ||
| 1096 | }, | ||
| 1097 | [IMX6QP] = { | ||
| 1098 | .variant = IMX6QP, | ||
| 1099 | }, | ||
| 1100 | [IMX7D] = { | ||
| 1101 | .variant = IMX7D, | ||
| 1102 | }, | ||
| 1103 | }; | ||
| 1104 | |||
| 1087 | static const struct of_device_id imx6_pcie_of_match[] = { | 1105 | static const struct of_device_id imx6_pcie_of_match[] = { |
| 1088 | { .compatible = "fsl,imx6q-pcie", .data = (void *)IMX6Q, }, | 1106 | { .compatible = "fsl,imx6q-pcie", .data = &drvdata[IMX6Q], }, |
| 1089 | { .compatible = "fsl,imx6sx-pcie", .data = (void *)IMX6SX, }, | 1107 | { .compatible = "fsl,imx6sx-pcie", .data = &drvdata[IMX6SX], }, |
| 1090 | { .compatible = "fsl,imx6qp-pcie", .data = (void *)IMX6QP, }, | 1108 | { .compatible = "fsl,imx6qp-pcie", .data = &drvdata[IMX6QP], }, |
| 1091 | { .compatible = "fsl,imx7d-pcie", .data = (void *)IMX7D, }, | 1109 | { .compatible = "fsl,imx7d-pcie", .data = &drvdata[IMX7D], }, |
| 1092 | {}, | 1110 | {}, |
| 1093 | }; | 1111 | }; |
| 1094 | 1112 | ||
