2 * PCIe host controller driver for Samsung EXYNOS SoCs
4 * Copyright (C) 2013 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com
7 * Author: Jingoo Han <jg1.han@samsung.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
14 #include <linux/clk.h>
15 #include <linux/delay.h>
16 #include <linux/gpio.h>
17 #include <linux/interrupt.h>
18 #include <linux/kernel.h>
19 #include <linux/init.h>
20 #include <linux/of_gpio.h>
21 #include <linux/pci.h>
22 #include <linux/platform_device.h>
23 #include <linux/resource.h>
24 #include <linux/signal.h>
25 #include <linux/types.h>
27 #include "pcie-designware.h"
29 #define to_exynos_pcie(x) container_of(x, struct exynos_pcie, pp)
33 void __iomem *elbi_base; /* DT 0th resource */
34 void __iomem *phy_base; /* DT 1st resource */
35 void __iomem *block_base; /* DT 2nd resource */
41 /* PCIe ELBI registers */
42 #define PCIE_IRQ_PULSE 0x000
43 #define IRQ_INTA_ASSERT (0x1 << 0)
44 #define IRQ_INTB_ASSERT (0x1 << 2)
45 #define IRQ_INTC_ASSERT (0x1 << 4)
46 #define IRQ_INTD_ASSERT (0x1 << 6)
47 #define PCIE_IRQ_LEVEL 0x004
48 #define PCIE_IRQ_SPECIAL 0x008
49 #define PCIE_IRQ_EN_PULSE 0x00c
50 #define PCIE_IRQ_EN_LEVEL 0x010
51 #define IRQ_MSI_ENABLE (0x1 << 2)
52 #define PCIE_IRQ_EN_SPECIAL 0x014
53 #define PCIE_PWR_RESET 0x018
54 #define PCIE_CORE_RESET 0x01c
55 #define PCIE_CORE_RESET_ENABLE (0x1 << 0)
56 #define PCIE_STICKY_RESET 0x020
57 #define PCIE_NONSTICKY_RESET 0x024
58 #define PCIE_APP_INIT_RESET 0x028
59 #define PCIE_APP_LTSSM_ENABLE 0x02c
60 #define PCIE_ELBI_RDLH_LINKUP 0x064
61 #define PCIE_ELBI_LTSSM_ENABLE 0x1
62 #define PCIE_ELBI_SLV_AWMISC 0x11c
63 #define PCIE_ELBI_SLV_ARMISC 0x120
64 #define PCIE_ELBI_SLV_DBI_ENABLE (0x1 << 21)
66 /* PCIe Purple registers */
67 #define PCIE_PHY_GLOBAL_RESET 0x000
68 #define PCIE_PHY_COMMON_RESET 0x004
69 #define PCIE_PHY_CMN_REG 0x008
70 #define PCIE_PHY_MAC_RESET 0x00c
71 #define PCIE_PHY_PLL_LOCKED 0x010
72 #define PCIE_PHY_TRSVREG_RESET 0x020
73 #define PCIE_PHY_TRSV_RESET 0x024
75 /* PCIe PHY registers */
76 #define PCIE_PHY_IMPEDANCE 0x004
77 #define PCIE_PHY_PLL_DIV_0 0x008
78 #define PCIE_PHY_PLL_BIAS 0x00c
79 #define PCIE_PHY_DCC_FEEDBACK 0x014
80 #define PCIE_PHY_PLL_DIV_1 0x05c
81 #define PCIE_PHY_COMMON_POWER 0x064
82 #define PCIE_PHY_COMMON_PD_CMN (0x1 << 3)
83 #define PCIE_PHY_TRSV0_EMP_LVL 0x084
84 #define PCIE_PHY_TRSV0_DRV_LVL 0x088
85 #define PCIE_PHY_TRSV0_RXCDR 0x0ac
86 #define PCIE_PHY_TRSV0_POWER 0x0c4
87 #define PCIE_PHY_TRSV0_PD_TSV (0x1 << 7)
88 #define PCIE_PHY_TRSV0_LVCC 0x0dc
89 #define PCIE_PHY_TRSV1_EMP_LVL 0x144
90 #define PCIE_PHY_TRSV1_RXCDR 0x16c
91 #define PCIE_PHY_TRSV1_POWER 0x184
92 #define PCIE_PHY_TRSV1_PD_TSV (0x1 << 7)
93 #define PCIE_PHY_TRSV1_LVCC 0x19c
94 #define PCIE_PHY_TRSV2_EMP_LVL 0x204
95 #define PCIE_PHY_TRSV2_RXCDR 0x22c
96 #define PCIE_PHY_TRSV2_POWER 0x244
97 #define PCIE_PHY_TRSV2_PD_TSV (0x1 << 7)
98 #define PCIE_PHY_TRSV2_LVCC 0x25c
99 #define PCIE_PHY_TRSV3_EMP_LVL 0x2c4
100 #define PCIE_PHY_TRSV3_RXCDR 0x2ec
101 #define PCIE_PHY_TRSV3_POWER 0x304
102 #define PCIE_PHY_TRSV3_PD_TSV (0x1 << 7)
103 #define PCIE_PHY_TRSV3_LVCC 0x31c
105 static void exynos_elb_writel(struct exynos_pcie *exynos_pcie, u32 val, u32 reg)
107 writel(val, exynos_pcie->elbi_base + reg);
110 static u32 exynos_elb_readl(struct exynos_pcie *exynos_pcie, u32 reg)
112 return readl(exynos_pcie->elbi_base + reg);
115 static void exynos_phy_writel(struct exynos_pcie *exynos_pcie, u32 val, u32 reg)
117 writel(val, exynos_pcie->phy_base + reg);
120 static u32 exynos_phy_readl(struct exynos_pcie *exynos_pcie, u32 reg)
122 return readl(exynos_pcie->phy_base + reg);
125 static void exynos_blk_writel(struct exynos_pcie *exynos_pcie, u32 val, u32 reg)
127 writel(val, exynos_pcie->block_base + reg);
130 static u32 exynos_blk_readl(struct exynos_pcie *exynos_pcie, u32 reg)
132 return readl(exynos_pcie->block_base + reg);
135 static void exynos_pcie_sideband_dbi_w_mode(struct exynos_pcie *exynos_pcie,
141 val = exynos_elb_readl(exynos_pcie, PCIE_ELBI_SLV_AWMISC);
142 val |= PCIE_ELBI_SLV_DBI_ENABLE;
143 exynos_elb_writel(exynos_pcie, val, PCIE_ELBI_SLV_AWMISC);
145 val = exynos_elb_readl(exynos_pcie, PCIE_ELBI_SLV_AWMISC);
146 val &= ~PCIE_ELBI_SLV_DBI_ENABLE;
147 exynos_elb_writel(exynos_pcie, val, PCIE_ELBI_SLV_AWMISC);
151 static void exynos_pcie_sideband_dbi_r_mode(struct exynos_pcie *exynos_pcie,
157 val = exynos_elb_readl(exynos_pcie, PCIE_ELBI_SLV_ARMISC);
158 val |= PCIE_ELBI_SLV_DBI_ENABLE;
159 exynos_elb_writel(exynos_pcie, val, PCIE_ELBI_SLV_ARMISC);
161 val = exynos_elb_readl(exynos_pcie, PCIE_ELBI_SLV_ARMISC);
162 val &= ~PCIE_ELBI_SLV_DBI_ENABLE;
163 exynos_elb_writel(exynos_pcie, val, PCIE_ELBI_SLV_ARMISC);
167 static void exynos_pcie_assert_core_reset(struct exynos_pcie *exynos_pcie)
171 val = exynos_elb_readl(exynos_pcie, PCIE_CORE_RESET);
172 val &= ~PCIE_CORE_RESET_ENABLE;
173 exynos_elb_writel(exynos_pcie, val, PCIE_CORE_RESET);
174 exynos_elb_writel(exynos_pcie, 0, PCIE_PWR_RESET);
175 exynos_elb_writel(exynos_pcie, 0, PCIE_STICKY_RESET);
176 exynos_elb_writel(exynos_pcie, 0, PCIE_NONSTICKY_RESET);
179 static void exynos_pcie_deassert_core_reset(struct exynos_pcie *exynos_pcie)
183 val = exynos_elb_readl(exynos_pcie, PCIE_CORE_RESET);
184 val |= PCIE_CORE_RESET_ENABLE;
186 exynos_elb_writel(exynos_pcie, val, PCIE_CORE_RESET);
187 exynos_elb_writel(exynos_pcie, 1, PCIE_STICKY_RESET);
188 exynos_elb_writel(exynos_pcie, 1, PCIE_NONSTICKY_RESET);
189 exynos_elb_writel(exynos_pcie, 1, PCIE_APP_INIT_RESET);
190 exynos_elb_writel(exynos_pcie, 0, PCIE_APP_INIT_RESET);
191 exynos_blk_writel(exynos_pcie, 1, PCIE_PHY_MAC_RESET);
194 static void exynos_pcie_assert_phy_reset(struct exynos_pcie *exynos_pcie)
196 exynos_blk_writel(exynos_pcie, 0, PCIE_PHY_MAC_RESET);
197 exynos_blk_writel(exynos_pcie, 1, PCIE_PHY_GLOBAL_RESET);
200 static void exynos_pcie_deassert_phy_reset(struct exynos_pcie *exynos_pcie)
202 exynos_blk_writel(exynos_pcie, 0, PCIE_PHY_GLOBAL_RESET);
203 exynos_elb_writel(exynos_pcie, 1, PCIE_PWR_RESET);
204 exynos_blk_writel(exynos_pcie, 0, PCIE_PHY_COMMON_RESET);
205 exynos_blk_writel(exynos_pcie, 0, PCIE_PHY_CMN_REG);
206 exynos_blk_writel(exynos_pcie, 0, PCIE_PHY_TRSVREG_RESET);
207 exynos_blk_writel(exynos_pcie, 0, PCIE_PHY_TRSV_RESET);
210 static void exynos_pcie_power_on_phy(struct exynos_pcie *exynos_pcie)
214 val = exynos_phy_readl(exynos_pcie, PCIE_PHY_COMMON_POWER);
215 val &= ~PCIE_PHY_COMMON_PD_CMN;
216 exynos_phy_writel(exynos_pcie, val, PCIE_PHY_COMMON_POWER);
218 val = exynos_phy_readl(exynos_pcie, PCIE_PHY_TRSV0_POWER);
219 val &= ~PCIE_PHY_TRSV0_PD_TSV;
220 exynos_phy_writel(exynos_pcie, val, PCIE_PHY_TRSV0_POWER);
222 val = exynos_phy_readl(exynos_pcie, PCIE_PHY_TRSV1_POWER);
223 val &= ~PCIE_PHY_TRSV1_PD_TSV;
224 exynos_phy_writel(exynos_pcie, val, PCIE_PHY_TRSV1_POWER);
226 val = exynos_phy_readl(exynos_pcie, PCIE_PHY_TRSV2_POWER);
227 val &= ~PCIE_PHY_TRSV2_PD_TSV;
228 exynos_phy_writel(exynos_pcie, val, PCIE_PHY_TRSV2_POWER);
230 val = exynos_phy_readl(exynos_pcie, PCIE_PHY_TRSV3_POWER);
231 val &= ~PCIE_PHY_TRSV3_PD_TSV;
232 exynos_phy_writel(exynos_pcie, val, PCIE_PHY_TRSV3_POWER);
235 static void exynos_pcie_power_off_phy(struct exynos_pcie *exynos_pcie)
239 val = exynos_phy_readl(exynos_pcie, PCIE_PHY_COMMON_POWER);
240 val |= PCIE_PHY_COMMON_PD_CMN;
241 exynos_phy_writel(exynos_pcie, val, PCIE_PHY_COMMON_POWER);
243 val = exynos_phy_readl(exynos_pcie, PCIE_PHY_TRSV0_POWER);
244 val |= PCIE_PHY_TRSV0_PD_TSV;
245 exynos_phy_writel(exynos_pcie, val, PCIE_PHY_TRSV0_POWER);
247 val = exynos_phy_readl(exynos_pcie, PCIE_PHY_TRSV1_POWER);
248 val |= PCIE_PHY_TRSV1_PD_TSV;
249 exynos_phy_writel(exynos_pcie, val, PCIE_PHY_TRSV1_POWER);
251 val = exynos_phy_readl(exynos_pcie, PCIE_PHY_TRSV2_POWER);
252 val |= PCIE_PHY_TRSV2_PD_TSV;
253 exynos_phy_writel(exynos_pcie, val, PCIE_PHY_TRSV2_POWER);
255 val = exynos_phy_readl(exynos_pcie, PCIE_PHY_TRSV3_POWER);
256 val |= PCIE_PHY_TRSV3_PD_TSV;
257 exynos_phy_writel(exynos_pcie, val, PCIE_PHY_TRSV3_POWER);
260 static void exynos_pcie_init_phy(struct exynos_pcie *exynos_pcie)
262 /* DCC feedback control off */
263 exynos_phy_writel(exynos_pcie, 0x29, PCIE_PHY_DCC_FEEDBACK);
265 /* set TX/RX impedance */
266 exynos_phy_writel(exynos_pcie, 0xd5, PCIE_PHY_IMPEDANCE);
268 /* set 50Mhz PHY clock */
269 exynos_phy_writel(exynos_pcie, 0x14, PCIE_PHY_PLL_DIV_0);
270 exynos_phy_writel(exynos_pcie, 0x12, PCIE_PHY_PLL_DIV_1);
272 /* set TX Differential output for lane 0 */
273 exynos_phy_writel(exynos_pcie, 0x7f, PCIE_PHY_TRSV0_DRV_LVL);
275 /* set TX Pre-emphasis Level Control for lane 0 to minimum */
276 exynos_phy_writel(exynos_pcie, 0x0, PCIE_PHY_TRSV0_EMP_LVL);
278 /* set RX clock and data recovery bandwidth */
279 exynos_phy_writel(exynos_pcie, 0xe7, PCIE_PHY_PLL_BIAS);
280 exynos_phy_writel(exynos_pcie, 0x82, PCIE_PHY_TRSV0_RXCDR);
281 exynos_phy_writel(exynos_pcie, 0x82, PCIE_PHY_TRSV1_RXCDR);
282 exynos_phy_writel(exynos_pcie, 0x82, PCIE_PHY_TRSV2_RXCDR);
283 exynos_phy_writel(exynos_pcie, 0x82, PCIE_PHY_TRSV3_RXCDR);
285 /* change TX Pre-emphasis Level Control for lanes */
286 exynos_phy_writel(exynos_pcie, 0x39, PCIE_PHY_TRSV0_EMP_LVL);
287 exynos_phy_writel(exynos_pcie, 0x39, PCIE_PHY_TRSV1_EMP_LVL);
288 exynos_phy_writel(exynos_pcie, 0x39, PCIE_PHY_TRSV2_EMP_LVL);
289 exynos_phy_writel(exynos_pcie, 0x39, PCIE_PHY_TRSV3_EMP_LVL);
292 exynos_phy_writel(exynos_pcie, 0x20, PCIE_PHY_TRSV0_LVCC);
293 exynos_phy_writel(exynos_pcie, 0xa0, PCIE_PHY_TRSV1_LVCC);
294 exynos_phy_writel(exynos_pcie, 0xa0, PCIE_PHY_TRSV2_LVCC);
295 exynos_phy_writel(exynos_pcie, 0xa0, PCIE_PHY_TRSV3_LVCC);
298 static void exynos_pcie_assert_reset(struct exynos_pcie *exynos_pcie)
300 struct pcie_port *pp = &exynos_pcie->pp;
301 struct device *dev = pp->dev;
303 if (exynos_pcie->reset_gpio >= 0)
304 devm_gpio_request_one(dev, exynos_pcie->reset_gpio,
305 GPIOF_OUT_INIT_HIGH, "RESET");
308 static int exynos_pcie_establish_link(struct exynos_pcie *exynos_pcie)
310 struct pcie_port *pp = &exynos_pcie->pp;
311 struct device *dev = pp->dev;
314 if (dw_pcie_link_up(pp)) {
315 dev_err(dev, "Link already up\n");
319 exynos_pcie_assert_core_reset(exynos_pcie);
320 exynos_pcie_assert_phy_reset(exynos_pcie);
321 exynos_pcie_deassert_phy_reset(exynos_pcie);
322 exynos_pcie_power_on_phy(exynos_pcie);
323 exynos_pcie_init_phy(exynos_pcie);
325 /* pulse for common reset */
326 exynos_blk_writel(exynos_pcie, 1, PCIE_PHY_COMMON_RESET);
328 exynos_blk_writel(exynos_pcie, 0, PCIE_PHY_COMMON_RESET);
330 exynos_pcie_deassert_core_reset(exynos_pcie);
331 dw_pcie_setup_rc(pp);
332 exynos_pcie_assert_reset(exynos_pcie);
334 /* assert LTSSM enable */
335 exynos_elb_writel(exynos_pcie, PCIE_ELBI_LTSSM_ENABLE,
336 PCIE_APP_LTSSM_ENABLE);
338 /* check if the link is up or not */
339 if (!dw_pcie_wait_for_link(pp))
342 while (exynos_phy_readl(exynos_pcie, PCIE_PHY_PLL_LOCKED) == 0) {
343 val = exynos_blk_readl(exynos_pcie, PCIE_PHY_PLL_LOCKED);
344 dev_info(dev, "PLL Locked: 0x%x\n", val);
346 exynos_pcie_power_off_phy(exynos_pcie);
350 static void exynos_pcie_clear_irq_pulse(struct exynos_pcie *exynos_pcie)
354 val = exynos_elb_readl(exynos_pcie, PCIE_IRQ_PULSE);
355 exynos_elb_writel(exynos_pcie, val, PCIE_IRQ_PULSE);
358 static void exynos_pcie_enable_irq_pulse(struct exynos_pcie *exynos_pcie)
362 /* enable INTX interrupt */
363 val = IRQ_INTA_ASSERT | IRQ_INTB_ASSERT |
364 IRQ_INTC_ASSERT | IRQ_INTD_ASSERT;
365 exynos_elb_writel(exynos_pcie, val, PCIE_IRQ_EN_PULSE);
368 static irqreturn_t exynos_pcie_irq_handler(int irq, void *arg)
370 struct exynos_pcie *exynos_pcie = arg;
372 exynos_pcie_clear_irq_pulse(exynos_pcie);
376 static irqreturn_t exynos_pcie_msi_irq_handler(int irq, void *arg)
378 struct exynos_pcie *exynos_pcie = arg;
379 struct pcie_port *pp = &exynos_pcie->pp;
381 return dw_handle_msi_irq(pp);
384 static void exynos_pcie_msi_init(struct exynos_pcie *exynos_pcie)
386 struct pcie_port *pp = &exynos_pcie->pp;
389 dw_pcie_msi_init(pp);
391 /* enable MSI interrupt */
392 val = exynos_elb_readl(exynos_pcie, PCIE_IRQ_EN_LEVEL);
393 val |= IRQ_MSI_ENABLE;
394 exynos_elb_writel(exynos_pcie, val, PCIE_IRQ_EN_LEVEL);
397 static void exynos_pcie_enable_interrupts(struct exynos_pcie *exynos_pcie)
399 exynos_pcie_enable_irq_pulse(exynos_pcie);
401 if (IS_ENABLED(CONFIG_PCI_MSI))
402 exynos_pcie_msi_init(exynos_pcie);
405 static u32 exynos_pcie_readl_rc(struct pcie_port *pp, u32 reg)
407 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp);
410 exynos_pcie_sideband_dbi_r_mode(exynos_pcie, true);
411 val = readl(pp->dbi_base + reg);
412 exynos_pcie_sideband_dbi_r_mode(exynos_pcie, false);
416 static void exynos_pcie_writel_rc(struct pcie_port *pp, u32 reg, u32 val)
418 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp);
420 exynos_pcie_sideband_dbi_w_mode(exynos_pcie, true);
421 writel(val, pp->dbi_base + reg);
422 exynos_pcie_sideband_dbi_w_mode(exynos_pcie, false);
425 static int exynos_pcie_rd_own_conf(struct pcie_port *pp, int where, int size,
428 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp);
431 exynos_pcie_sideband_dbi_r_mode(exynos_pcie, true);
432 ret = dw_pcie_cfg_read(pp->dbi_base + where, size, val);
433 exynos_pcie_sideband_dbi_r_mode(exynos_pcie, false);
437 static int exynos_pcie_wr_own_conf(struct pcie_port *pp, int where, int size,
440 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp);
443 exynos_pcie_sideband_dbi_w_mode(exynos_pcie, true);
444 ret = dw_pcie_cfg_write(pp->dbi_base + where, size, val);
445 exynos_pcie_sideband_dbi_w_mode(exynos_pcie, false);
449 static int exynos_pcie_link_up(struct pcie_port *pp)
451 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp);
454 val = exynos_elb_readl(exynos_pcie, PCIE_ELBI_RDLH_LINKUP);
455 if (val == PCIE_ELBI_LTSSM_ENABLE)
461 static void exynos_pcie_host_init(struct pcie_port *pp)
463 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp);
465 exynos_pcie_establish_link(exynos_pcie);
466 exynos_pcie_enable_interrupts(exynos_pcie);
469 static struct pcie_host_ops exynos_pcie_host_ops = {
470 .readl_rc = exynos_pcie_readl_rc,
471 .writel_rc = exynos_pcie_writel_rc,
472 .rd_own_conf = exynos_pcie_rd_own_conf,
473 .wr_own_conf = exynos_pcie_wr_own_conf,
474 .link_up = exynos_pcie_link_up,
475 .host_init = exynos_pcie_host_init,
478 static int __init exynos_add_pcie_port(struct exynos_pcie *exynos_pcie,
479 struct platform_device *pdev)
481 struct pcie_port *pp = &exynos_pcie->pp;
482 struct device *dev = pp->dev;
485 pp->irq = platform_get_irq(pdev, 1);
487 dev_err(dev, "failed to get irq\n");
490 ret = devm_request_irq(dev, pp->irq, exynos_pcie_irq_handler,
491 IRQF_SHARED, "exynos-pcie", exynos_pcie);
493 dev_err(dev, "failed to request irq\n");
497 if (IS_ENABLED(CONFIG_PCI_MSI)) {
498 pp->msi_irq = platform_get_irq(pdev, 0);
500 dev_err(dev, "failed to get msi irq\n");
504 ret = devm_request_irq(dev, pp->msi_irq,
505 exynos_pcie_msi_irq_handler,
506 IRQF_SHARED | IRQF_NO_THREAD,
507 "exynos-pcie", exynos_pcie);
509 dev_err(dev, "failed to request msi irq\n");
514 pp->root_bus_nr = -1;
515 pp->ops = &exynos_pcie_host_ops;
517 ret = dw_pcie_host_init(pp);
519 dev_err(dev, "failed to initialize host\n");
526 static int __init exynos_pcie_probe(struct platform_device *pdev)
528 struct device *dev = &pdev->dev;
529 struct exynos_pcie *exynos_pcie;
530 struct pcie_port *pp;
531 struct device_node *np = dev->of_node;
532 struct resource *elbi_base;
533 struct resource *phy_base;
534 struct resource *block_base;
537 exynos_pcie = devm_kzalloc(dev, sizeof(*exynos_pcie), GFP_KERNEL);
541 pp = &exynos_pcie->pp;
544 exynos_pcie->reset_gpio = of_get_named_gpio(np, "reset-gpio", 0);
546 exynos_pcie->clk = devm_clk_get(dev, "pcie");
547 if (IS_ERR(exynos_pcie->clk)) {
548 dev_err(dev, "Failed to get pcie rc clock\n");
549 return PTR_ERR(exynos_pcie->clk);
551 ret = clk_prepare_enable(exynos_pcie->clk);
555 exynos_pcie->bus_clk = devm_clk_get(dev, "pcie_bus");
556 if (IS_ERR(exynos_pcie->bus_clk)) {
557 dev_err(dev, "Failed to get pcie bus clock\n");
558 ret = PTR_ERR(exynos_pcie->bus_clk);
561 ret = clk_prepare_enable(exynos_pcie->bus_clk);
565 elbi_base = platform_get_resource(pdev, IORESOURCE_MEM, 0);
566 exynos_pcie->elbi_base = devm_ioremap_resource(dev, elbi_base);
567 if (IS_ERR(exynos_pcie->elbi_base)) {
568 ret = PTR_ERR(exynos_pcie->elbi_base);
572 phy_base = platform_get_resource(pdev, IORESOURCE_MEM, 1);
573 exynos_pcie->phy_base = devm_ioremap_resource(dev, phy_base);
574 if (IS_ERR(exynos_pcie->phy_base)) {
575 ret = PTR_ERR(exynos_pcie->phy_base);
579 block_base = platform_get_resource(pdev, IORESOURCE_MEM, 2);
580 exynos_pcie->block_base = devm_ioremap_resource(dev, block_base);
581 if (IS_ERR(exynos_pcie->block_base)) {
582 ret = PTR_ERR(exynos_pcie->block_base);
586 ret = exynos_add_pcie_port(exynos_pcie, pdev);
590 platform_set_drvdata(pdev, exynos_pcie);
594 clk_disable_unprepare(exynos_pcie->bus_clk);
596 clk_disable_unprepare(exynos_pcie->clk);
600 static int __exit exynos_pcie_remove(struct platform_device *pdev)
602 struct exynos_pcie *exynos_pcie = platform_get_drvdata(pdev);
604 clk_disable_unprepare(exynos_pcie->bus_clk);
605 clk_disable_unprepare(exynos_pcie->clk);
610 static const struct of_device_id exynos_pcie_of_match[] = {
611 { .compatible = "samsung,exynos5440-pcie", },
615 static struct platform_driver exynos_pcie_driver = {
616 .remove = __exit_p(exynos_pcie_remove),
618 .name = "exynos-pcie",
619 .of_match_table = exynos_pcie_of_match,
623 /* Exynos PCIe driver does not allow module unload */
625 static int __init exynos_pcie_init(void)
627 return platform_driver_probe(&exynos_pcie_driver, exynos_pcie_probe);
629 subsys_initcall(exynos_pcie_init);