H A D | pci-exynos.c | 29 #define to_exynos_pcie(x) container_of(x, struct exynos_pcie, pp) 31 struct exynos_pcie { struct 105 static inline void exynos_elb_writel(struct exynos_pcie *pcie, u32 val, u32 reg) exynos_elb_writel() 110 static inline u32 exynos_elb_readl(struct exynos_pcie *pcie, u32 reg) exynos_elb_readl() 115 static inline void exynos_phy_writel(struct exynos_pcie *pcie, u32 val, u32 reg) exynos_phy_writel() 120 static inline u32 exynos_phy_readl(struct exynos_pcie *pcie, u32 reg) exynos_phy_readl() 125 static inline void exynos_blk_writel(struct exynos_pcie *pcie, u32 val, u32 reg) exynos_blk_writel() 130 static inline u32 exynos_blk_readl(struct exynos_pcie *pcie, u32 reg) exynos_blk_readl() 138 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp); exynos_pcie_sideband_dbi_w_mode() local 141 val = exynos_elb_readl(exynos_pcie, PCIE_ELBI_SLV_AWMISC); exynos_pcie_sideband_dbi_w_mode() 143 exynos_elb_writel(exynos_pcie, val, PCIE_ELBI_SLV_AWMISC); exynos_pcie_sideband_dbi_w_mode() 145 val = exynos_elb_readl(exynos_pcie, PCIE_ELBI_SLV_AWMISC); exynos_pcie_sideband_dbi_w_mode() 147 exynos_elb_writel(exynos_pcie, val, PCIE_ELBI_SLV_AWMISC); exynos_pcie_sideband_dbi_w_mode() 154 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp); exynos_pcie_sideband_dbi_r_mode() local 157 val = exynos_elb_readl(exynos_pcie, PCIE_ELBI_SLV_ARMISC); exynos_pcie_sideband_dbi_r_mode() 159 exynos_elb_writel(exynos_pcie, val, PCIE_ELBI_SLV_ARMISC); exynos_pcie_sideband_dbi_r_mode() 161 val = exynos_elb_readl(exynos_pcie, PCIE_ELBI_SLV_ARMISC); exynos_pcie_sideband_dbi_r_mode() 163 exynos_elb_writel(exynos_pcie, val, PCIE_ELBI_SLV_ARMISC); exynos_pcie_sideband_dbi_r_mode() 170 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp); exynos_pcie_assert_core_reset() local 172 val = exynos_elb_readl(exynos_pcie, PCIE_CORE_RESET); exynos_pcie_assert_core_reset() 174 exynos_elb_writel(exynos_pcie, val, PCIE_CORE_RESET); exynos_pcie_assert_core_reset() 175 exynos_elb_writel(exynos_pcie, 0, PCIE_PWR_RESET); exynos_pcie_assert_core_reset() 176 exynos_elb_writel(exynos_pcie, 0, PCIE_STICKY_RESET); exynos_pcie_assert_core_reset() 177 exynos_elb_writel(exynos_pcie, 0, PCIE_NONSTICKY_RESET); exynos_pcie_assert_core_reset() 183 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp); exynos_pcie_deassert_core_reset() local 185 val = exynos_elb_readl(exynos_pcie, PCIE_CORE_RESET); exynos_pcie_deassert_core_reset() 188 exynos_elb_writel(exynos_pcie, val, PCIE_CORE_RESET); exynos_pcie_deassert_core_reset() 189 exynos_elb_writel(exynos_pcie, 1, PCIE_STICKY_RESET); exynos_pcie_deassert_core_reset() 190 exynos_elb_writel(exynos_pcie, 1, PCIE_NONSTICKY_RESET); exynos_pcie_deassert_core_reset() 191 exynos_elb_writel(exynos_pcie, 1, PCIE_APP_INIT_RESET); exynos_pcie_deassert_core_reset() 192 exynos_elb_writel(exynos_pcie, 0, PCIE_APP_INIT_RESET); exynos_pcie_deassert_core_reset() 193 exynos_blk_writel(exynos_pcie, 1, PCIE_PHY_MAC_RESET); exynos_pcie_deassert_core_reset() 198 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp); exynos_pcie_assert_phy_reset() local 200 exynos_blk_writel(exynos_pcie, 0, PCIE_PHY_MAC_RESET); exynos_pcie_assert_phy_reset() 201 exynos_blk_writel(exynos_pcie, 1, PCIE_PHY_GLOBAL_RESET); exynos_pcie_assert_phy_reset() 206 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp); exynos_pcie_deassert_phy_reset() local 208 exynos_blk_writel(exynos_pcie, 0, PCIE_PHY_GLOBAL_RESET); exynos_pcie_deassert_phy_reset() 209 exynos_elb_writel(exynos_pcie, 1, PCIE_PWR_RESET); exynos_pcie_deassert_phy_reset() 210 exynos_blk_writel(exynos_pcie, 0, PCIE_PHY_COMMON_RESET); exynos_pcie_deassert_phy_reset() 211 exynos_blk_writel(exynos_pcie, 0, PCIE_PHY_CMN_REG); exynos_pcie_deassert_phy_reset() 212 exynos_blk_writel(exynos_pcie, 0, PCIE_PHY_TRSVREG_RESET); exynos_pcie_deassert_phy_reset() 213 exynos_blk_writel(exynos_pcie, 0, PCIE_PHY_TRSV_RESET); exynos_pcie_deassert_phy_reset() 219 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp); exynos_pcie_power_on_phy() local 221 val = exynos_phy_readl(exynos_pcie, PCIE_PHY_COMMON_POWER); exynos_pcie_power_on_phy() 223 exynos_phy_writel(exynos_pcie, val, PCIE_PHY_COMMON_POWER); exynos_pcie_power_on_phy() 225 val = exynos_phy_readl(exynos_pcie, PCIE_PHY_TRSV0_POWER); exynos_pcie_power_on_phy() 227 exynos_phy_writel(exynos_pcie, val, PCIE_PHY_TRSV0_POWER); exynos_pcie_power_on_phy() 229 val = exynos_phy_readl(exynos_pcie, PCIE_PHY_TRSV1_POWER); exynos_pcie_power_on_phy() 231 exynos_phy_writel(exynos_pcie, val, PCIE_PHY_TRSV1_POWER); exynos_pcie_power_on_phy() 233 val = exynos_phy_readl(exynos_pcie, PCIE_PHY_TRSV2_POWER); exynos_pcie_power_on_phy() 235 exynos_phy_writel(exynos_pcie, val, PCIE_PHY_TRSV2_POWER); exynos_pcie_power_on_phy() 237 val = exynos_phy_readl(exynos_pcie, PCIE_PHY_TRSV3_POWER); exynos_pcie_power_on_phy() 239 exynos_phy_writel(exynos_pcie, val, PCIE_PHY_TRSV3_POWER); exynos_pcie_power_on_phy() 245 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp); exynos_pcie_power_off_phy() local 247 val = exynos_phy_readl(exynos_pcie, PCIE_PHY_COMMON_POWER); exynos_pcie_power_off_phy() 249 exynos_phy_writel(exynos_pcie, val, PCIE_PHY_COMMON_POWER); exynos_pcie_power_off_phy() 251 val = exynos_phy_readl(exynos_pcie, PCIE_PHY_TRSV0_POWER); exynos_pcie_power_off_phy() 253 exynos_phy_writel(exynos_pcie, val, PCIE_PHY_TRSV0_POWER); exynos_pcie_power_off_phy() 255 val = exynos_phy_readl(exynos_pcie, PCIE_PHY_TRSV1_POWER); exynos_pcie_power_off_phy() 257 exynos_phy_writel(exynos_pcie, val, PCIE_PHY_TRSV1_POWER); exynos_pcie_power_off_phy() 259 val = exynos_phy_readl(exynos_pcie, PCIE_PHY_TRSV2_POWER); exynos_pcie_power_off_phy() 261 exynos_phy_writel(exynos_pcie, val, PCIE_PHY_TRSV2_POWER); exynos_pcie_power_off_phy() 263 val = exynos_phy_readl(exynos_pcie, PCIE_PHY_TRSV3_POWER); exynos_pcie_power_off_phy() 265 exynos_phy_writel(exynos_pcie, val, PCIE_PHY_TRSV3_POWER); exynos_pcie_power_off_phy() 270 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp); exynos_pcie_init_phy() local 273 exynos_phy_writel(exynos_pcie, 0x29, PCIE_PHY_DCC_FEEDBACK); exynos_pcie_init_phy() 276 exynos_phy_writel(exynos_pcie, 0xd5, PCIE_PHY_IMPEDANCE); exynos_pcie_init_phy() 279 exynos_phy_writel(exynos_pcie, 0x14, PCIE_PHY_PLL_DIV_0); exynos_pcie_init_phy() 280 exynos_phy_writel(exynos_pcie, 0x12, PCIE_PHY_PLL_DIV_1); exynos_pcie_init_phy() 283 exynos_phy_writel(exynos_pcie, 0x7f, PCIE_PHY_TRSV0_DRV_LVL); exynos_pcie_init_phy() 286 exynos_phy_writel(exynos_pcie, 0x0, PCIE_PHY_TRSV0_EMP_LVL); exynos_pcie_init_phy() 289 exynos_phy_writel(exynos_pcie, 0xe7, PCIE_PHY_PLL_BIAS); exynos_pcie_init_phy() 290 exynos_phy_writel(exynos_pcie, 0x82, PCIE_PHY_TRSV0_RXCDR); exynos_pcie_init_phy() 291 exynos_phy_writel(exynos_pcie, 0x82, PCIE_PHY_TRSV1_RXCDR); exynos_pcie_init_phy() 292 exynos_phy_writel(exynos_pcie, 0x82, PCIE_PHY_TRSV2_RXCDR); exynos_pcie_init_phy() 293 exynos_phy_writel(exynos_pcie, 0x82, PCIE_PHY_TRSV3_RXCDR); exynos_pcie_init_phy() 296 exynos_phy_writel(exynos_pcie, 0x39, PCIE_PHY_TRSV0_EMP_LVL); exynos_pcie_init_phy() 297 exynos_phy_writel(exynos_pcie, 0x39, PCIE_PHY_TRSV1_EMP_LVL); exynos_pcie_init_phy() 298 exynos_phy_writel(exynos_pcie, 0x39, PCIE_PHY_TRSV2_EMP_LVL); exynos_pcie_init_phy() 299 exynos_phy_writel(exynos_pcie, 0x39, PCIE_PHY_TRSV3_EMP_LVL); exynos_pcie_init_phy() 302 exynos_phy_writel(exynos_pcie, 0x20, PCIE_PHY_TRSV0_LVCC); exynos_pcie_init_phy() 303 exynos_phy_writel(exynos_pcie, 0xa0, PCIE_PHY_TRSV1_LVCC); exynos_pcie_init_phy() 304 exynos_phy_writel(exynos_pcie, 0xa0, PCIE_PHY_TRSV2_LVCC); exynos_pcie_init_phy() 305 exynos_phy_writel(exynos_pcie, 0xa0, PCIE_PHY_TRSV3_LVCC); exynos_pcie_init_phy() 310 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp); exynos_pcie_assert_reset() local 312 if (exynos_pcie->reset_gpio >= 0) exynos_pcie_assert_reset() 313 devm_gpio_request_one(pp->dev, exynos_pcie->reset_gpio, exynos_pcie_assert_reset() 321 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp); exynos_pcie_establish_link() local 342 exynos_blk_writel(exynos_pcie, 1, PCIE_PHY_COMMON_RESET); exynos_pcie_establish_link() 344 exynos_blk_writel(exynos_pcie, 0, PCIE_PHY_COMMON_RESET); exynos_pcie_establish_link() 356 exynos_elb_writel(exynos_pcie, PCIE_ELBI_LTSSM_ENABLE, exynos_pcie_establish_link() 364 while (exynos_phy_readl(exynos_pcie, exynos_pcie_establish_link() 366 val = exynos_blk_readl(exynos_pcie, exynos_pcie_establish_link() 386 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp); exynos_pcie_clear_irq_pulse() local 388 val = exynos_elb_readl(exynos_pcie, PCIE_IRQ_PULSE); exynos_pcie_clear_irq_pulse() 389 exynos_elb_writel(exynos_pcie, val, PCIE_IRQ_PULSE); exynos_pcie_clear_irq_pulse() 395 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp); exynos_pcie_enable_irq_pulse() local 400 exynos_elb_writel(exynos_pcie, val, PCIE_IRQ_EN_PULSE); exynos_pcie_enable_irq_pulse() 421 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp); exynos_pcie_msi_init() local 426 val = exynos_elb_readl(exynos_pcie, PCIE_IRQ_EN_LEVEL); exynos_pcie_msi_init() 428 exynos_elb_writel(exynos_pcie, val, PCIE_IRQ_EN_LEVEL); exynos_pcie_msi_init() 480 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp); exynos_pcie_link_up() local 481 u32 val = exynos_elb_readl(exynos_pcie, PCIE_ELBI_RDLH_LINKUP); exynos_pcie_link_up() 552 struct exynos_pcie *exynos_pcie; exynos_pcie_probe() local 560 exynos_pcie = devm_kzalloc(&pdev->dev, sizeof(*exynos_pcie), exynos_pcie_probe() 562 if (!exynos_pcie) exynos_pcie_probe() 565 pp = &exynos_pcie->pp; exynos_pcie_probe() 569 exynos_pcie->reset_gpio = of_get_named_gpio(np, "reset-gpio", 0); exynos_pcie_probe() 571 exynos_pcie->clk = devm_clk_get(&pdev->dev, "pcie"); exynos_pcie_probe() 572 if (IS_ERR(exynos_pcie->clk)) { exynos_pcie_probe() 574 return PTR_ERR(exynos_pcie->clk); exynos_pcie_probe() 576 ret = clk_prepare_enable(exynos_pcie->clk); exynos_pcie_probe() 580 exynos_pcie->bus_clk = devm_clk_get(&pdev->dev, "pcie_bus"); exynos_pcie_probe() 581 if (IS_ERR(exynos_pcie->bus_clk)) { exynos_pcie_probe() 583 ret = PTR_ERR(exynos_pcie->bus_clk); exynos_pcie_probe() 586 ret = clk_prepare_enable(exynos_pcie->bus_clk); exynos_pcie_probe() 591 exynos_pcie->elbi_base = devm_ioremap_resource(&pdev->dev, elbi_base); exynos_pcie_probe() 592 if (IS_ERR(exynos_pcie->elbi_base)) { exynos_pcie_probe() 593 ret = PTR_ERR(exynos_pcie->elbi_base); exynos_pcie_probe() 598 exynos_pcie->phy_base = devm_ioremap_resource(&pdev->dev, phy_base); exynos_pcie_probe() 599 if (IS_ERR(exynos_pcie->phy_base)) { exynos_pcie_probe() 600 ret = PTR_ERR(exynos_pcie->phy_base); exynos_pcie_probe() 605 exynos_pcie->block_base = devm_ioremap_resource(&pdev->dev, block_base); exynos_pcie_probe() 606 if (IS_ERR(exynos_pcie->block_base)) { exynos_pcie_probe() 607 ret = PTR_ERR(exynos_pcie->block_base); exynos_pcie_probe() 615 platform_set_drvdata(pdev, exynos_pcie); exynos_pcie_probe() 619 clk_disable_unprepare(exynos_pcie->bus_clk); exynos_pcie_probe() 621 clk_disable_unprepare(exynos_pcie->clk); exynos_pcie_probe() 627 struct exynos_pcie *exynos_pcie = platform_get_drvdata(pdev); exynos_pcie_remove() local 629 clk_disable_unprepare(exynos_pcie->bus_clk); exynos_pcie_remove() 630 clk_disable_unprepare(exynos_pcie->clk); exynos_pcie_remove()
|