pci-exynos.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. /*
  2. * PCIe host controller driver for Samsung EXYNOS SoCs
  3. *
  4. * Copyright (C) 2013 Samsung Electronics Co., Ltd.
  5. * http://www.samsung.com
  6. *
  7. * Author: Jingoo Han <jg1.han@samsung.com>
  8. *
  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.
  12. */
  13. #include <linux/clk.h>
  14. #include <linux/delay.h>
  15. #include <linux/gpio.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/kernel.h>
  18. #include <linux/module.h>
  19. #include <linux/of_gpio.h>
  20. #include <linux/pci.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/resource.h>
  23. #include <linux/signal.h>
  24. #include <linux/types.h>
  25. #include "pcie-designware.h"
  26. #define to_exynos_pcie(x) container_of(x, struct exynos_pcie, pp)
  27. struct exynos_pcie {
  28. void __iomem *elbi_base;
  29. void __iomem *phy_base;
  30. void __iomem *block_base;
  31. int reset_gpio;
  32. struct clk *clk;
  33. struct clk *bus_clk;
  34. struct pcie_port pp;
  35. };
  36. /* PCIe ELBI registers */
  37. #define PCIE_IRQ_PULSE 0x000
  38. #define IRQ_INTA_ASSERT (0x1 << 0)
  39. #define IRQ_INTB_ASSERT (0x1 << 2)
  40. #define IRQ_INTC_ASSERT (0x1 << 4)
  41. #define IRQ_INTD_ASSERT (0x1 << 6)
  42. #define PCIE_IRQ_LEVEL 0x004
  43. #define PCIE_IRQ_SPECIAL 0x008
  44. #define PCIE_IRQ_EN_PULSE 0x00c
  45. #define PCIE_IRQ_EN_LEVEL 0x010
  46. #define PCIE_IRQ_EN_SPECIAL 0x014
  47. #define PCIE_PWR_RESET 0x018
  48. #define PCIE_CORE_RESET 0x01c
  49. #define PCIE_CORE_RESET_ENABLE (0x1 << 0)
  50. #define PCIE_STICKY_RESET 0x020
  51. #define PCIE_NONSTICKY_RESET 0x024
  52. #define PCIE_APP_INIT_RESET 0x028
  53. #define PCIE_APP_LTSSM_ENABLE 0x02c
  54. #define PCIE_ELBI_RDLH_LINKUP 0x064
  55. #define PCIE_ELBI_LTSSM_ENABLE 0x1
  56. #define PCIE_ELBI_SLV_AWMISC 0x11c
  57. #define PCIE_ELBI_SLV_ARMISC 0x120
  58. #define PCIE_ELBI_SLV_DBI_ENABLE (0x1 << 21)
  59. /* PCIe Purple registers */
  60. #define PCIE_PHY_GLOBAL_RESET 0x000
  61. #define PCIE_PHY_COMMON_RESET 0x004
  62. #define PCIE_PHY_CMN_REG 0x008
  63. #define PCIE_PHY_MAC_RESET 0x00c
  64. #define PCIE_PHY_PLL_LOCKED 0x010
  65. #define PCIE_PHY_TRSVREG_RESET 0x020
  66. #define PCIE_PHY_TRSV_RESET 0x024
  67. /* PCIe PHY registers */
  68. #define PCIE_PHY_IMPEDANCE 0x004
  69. #define PCIE_PHY_PLL_DIV_0 0x008
  70. #define PCIE_PHY_PLL_BIAS 0x00c
  71. #define PCIE_PHY_DCC_FEEDBACK 0x014
  72. #define PCIE_PHY_PLL_DIV_1 0x05c
  73. #define PCIE_PHY_TRSV0_EMP_LVL 0x084
  74. #define PCIE_PHY_TRSV0_DRV_LVL 0x088
  75. #define PCIE_PHY_TRSV0_RXCDR 0x0ac
  76. #define PCIE_PHY_TRSV0_LVCC 0x0dc
  77. #define PCIE_PHY_TRSV1_EMP_LVL 0x144
  78. #define PCIE_PHY_TRSV1_RXCDR 0x16c
  79. #define PCIE_PHY_TRSV1_LVCC 0x19c
  80. #define PCIE_PHY_TRSV2_EMP_LVL 0x204
  81. #define PCIE_PHY_TRSV2_RXCDR 0x22c
  82. #define PCIE_PHY_TRSV2_LVCC 0x25c
  83. #define PCIE_PHY_TRSV3_EMP_LVL 0x2c4
  84. #define PCIE_PHY_TRSV3_RXCDR 0x2ec
  85. #define PCIE_PHY_TRSV3_LVCC 0x31c
  86. static inline void exynos_elb_writel(struct exynos_pcie *pcie, u32 val, u32 reg)
  87. {
  88. writel(val, pcie->elbi_base + reg);
  89. }
  90. static inline u32 exynos_elb_readl(struct exynos_pcie *pcie, u32 reg)
  91. {
  92. return readl(pcie->elbi_base + reg);
  93. }
  94. static inline void exynos_phy_writel(struct exynos_pcie *pcie, u32 val, u32 reg)
  95. {
  96. writel(val, pcie->phy_base + reg);
  97. }
  98. static inline u32 exynos_phy_readl(struct exynos_pcie *pcie, u32 reg)
  99. {
  100. return readl(pcie->phy_base + reg);
  101. }
  102. static inline void exynos_blk_writel(struct exynos_pcie *pcie, u32 val, u32 reg)
  103. {
  104. writel(val, pcie->block_base + reg);
  105. }
  106. static inline u32 exynos_blk_readl(struct exynos_pcie *pcie, u32 reg)
  107. {
  108. return readl(pcie->block_base + reg);
  109. }
  110. static void exynos_pcie_sideband_dbi_w_mode(struct pcie_port *pp, bool on)
  111. {
  112. u32 val;
  113. struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp);
  114. if (on) {
  115. val = exynos_elb_readl(exynos_pcie, PCIE_ELBI_SLV_AWMISC);
  116. val |= PCIE_ELBI_SLV_DBI_ENABLE;
  117. exynos_elb_writel(exynos_pcie, val, PCIE_ELBI_SLV_AWMISC);
  118. } else {
  119. val = exynos_elb_readl(exynos_pcie, PCIE_ELBI_SLV_AWMISC);
  120. val &= ~PCIE_ELBI_SLV_DBI_ENABLE;
  121. exynos_elb_writel(exynos_pcie, val, PCIE_ELBI_SLV_AWMISC);
  122. }
  123. }
  124. static void exynos_pcie_sideband_dbi_r_mode(struct pcie_port *pp, bool on)
  125. {
  126. u32 val;
  127. struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp);
  128. if (on) {
  129. val = exynos_elb_readl(exynos_pcie, PCIE_ELBI_SLV_ARMISC);
  130. val |= PCIE_ELBI_SLV_DBI_ENABLE;
  131. exynos_elb_writel(exynos_pcie, val, PCIE_ELBI_SLV_ARMISC);
  132. } else {
  133. val = exynos_elb_readl(exynos_pcie, PCIE_ELBI_SLV_ARMISC);
  134. val &= ~PCIE_ELBI_SLV_DBI_ENABLE;
  135. exynos_elb_writel(exynos_pcie, val, PCIE_ELBI_SLV_ARMISC);
  136. }
  137. }
  138. static void exynos_pcie_assert_core_reset(struct pcie_port *pp)
  139. {
  140. u32 val;
  141. struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp);
  142. val = exynos_elb_readl(exynos_pcie, PCIE_CORE_RESET);
  143. val &= ~PCIE_CORE_RESET_ENABLE;
  144. exynos_elb_writel(exynos_pcie, val, PCIE_CORE_RESET);
  145. exynos_elb_writel(exynos_pcie, 0, PCIE_PWR_RESET);
  146. exynos_elb_writel(exynos_pcie, 0, PCIE_STICKY_RESET);
  147. exynos_elb_writel(exynos_pcie, 0, PCIE_NONSTICKY_RESET);
  148. }
  149. static void exynos_pcie_deassert_core_reset(struct pcie_port *pp)
  150. {
  151. u32 val;
  152. struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp);
  153. val = exynos_elb_readl(exynos_pcie, PCIE_CORE_RESET);
  154. val |= PCIE_CORE_RESET_ENABLE;
  155. exynos_elb_writel(exynos_pcie, val, PCIE_CORE_RESET);
  156. exynos_elb_writel(exynos_pcie, 1, PCIE_STICKY_RESET);
  157. exynos_elb_writel(exynos_pcie, 1, PCIE_NONSTICKY_RESET);
  158. exynos_elb_writel(exynos_pcie, 1, PCIE_APP_INIT_RESET);
  159. exynos_elb_writel(exynos_pcie, 0, PCIE_APP_INIT_RESET);
  160. exynos_blk_writel(exynos_pcie, 1, PCIE_PHY_MAC_RESET);
  161. }
  162. static void exynos_pcie_assert_phy_reset(struct pcie_port *pp)
  163. {
  164. struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp);
  165. exynos_blk_writel(exynos_pcie, 0, PCIE_PHY_MAC_RESET);
  166. exynos_blk_writel(exynos_pcie, 1, PCIE_PHY_GLOBAL_RESET);
  167. }
  168. static void exynos_pcie_deassert_phy_reset(struct pcie_port *pp)
  169. {
  170. struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp);
  171. exynos_blk_writel(exynos_pcie, 0, PCIE_PHY_GLOBAL_RESET);
  172. exynos_elb_writel(exynos_pcie, 1, PCIE_PWR_RESET);
  173. exynos_blk_writel(exynos_pcie, 0, PCIE_PHY_COMMON_RESET);
  174. exynos_blk_writel(exynos_pcie, 0, PCIE_PHY_CMN_REG);
  175. exynos_blk_writel(exynos_pcie, 0, PCIE_PHY_TRSVREG_RESET);
  176. exynos_blk_writel(exynos_pcie, 0, PCIE_PHY_TRSV_RESET);
  177. }
  178. static void exynos_pcie_init_phy(struct pcie_port *pp)
  179. {
  180. struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp);
  181. /* DCC feedback control off */
  182. exynos_phy_writel(exynos_pcie, 0x29, PCIE_PHY_DCC_FEEDBACK);
  183. /* set TX/RX impedance */
  184. exynos_phy_writel(exynos_pcie, 0xd5, PCIE_PHY_IMPEDANCE);
  185. /* set 50Mhz PHY clock */
  186. exynos_phy_writel(exynos_pcie, 0x14, PCIE_PHY_PLL_DIV_0);
  187. exynos_phy_writel(exynos_pcie, 0x12, PCIE_PHY_PLL_DIV_1);
  188. /* set TX Differential output for lane 0 */
  189. exynos_phy_writel(exynos_pcie, 0x7f, PCIE_PHY_TRSV0_DRV_LVL);
  190. /* set TX Pre-emphasis Level Control for lane 0 to minimum */
  191. exynos_phy_writel(exynos_pcie, 0x0, PCIE_PHY_TRSV0_EMP_LVL);
  192. /* set RX clock and data recovery bandwidth */
  193. exynos_phy_writel(exynos_pcie, 0xe7, PCIE_PHY_PLL_BIAS);
  194. exynos_phy_writel(exynos_pcie, 0x82, PCIE_PHY_TRSV0_RXCDR);
  195. exynos_phy_writel(exynos_pcie, 0x82, PCIE_PHY_TRSV1_RXCDR);
  196. exynos_phy_writel(exynos_pcie, 0x82, PCIE_PHY_TRSV2_RXCDR);
  197. exynos_phy_writel(exynos_pcie, 0x82, PCIE_PHY_TRSV3_RXCDR);
  198. /* change TX Pre-emphasis Level Control for lanes */
  199. exynos_phy_writel(exynos_pcie, 0x39, PCIE_PHY_TRSV0_EMP_LVL);
  200. exynos_phy_writel(exynos_pcie, 0x39, PCIE_PHY_TRSV1_EMP_LVL);
  201. exynos_phy_writel(exynos_pcie, 0x39, PCIE_PHY_TRSV2_EMP_LVL);
  202. exynos_phy_writel(exynos_pcie, 0x39, PCIE_PHY_TRSV3_EMP_LVL);
  203. /* set LVCC */
  204. exynos_phy_writel(exynos_pcie, 0x20, PCIE_PHY_TRSV0_LVCC);
  205. exynos_phy_writel(exynos_pcie, 0xa0, PCIE_PHY_TRSV1_LVCC);
  206. exynos_phy_writel(exynos_pcie, 0xa0, PCIE_PHY_TRSV2_LVCC);
  207. exynos_phy_writel(exynos_pcie, 0xa0, PCIE_PHY_TRSV3_LVCC);
  208. }
  209. static void exynos_pcie_assert_reset(struct pcie_port *pp)
  210. {
  211. struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp);
  212. if (exynos_pcie->reset_gpio >= 0)
  213. devm_gpio_request_one(pp->dev, exynos_pcie->reset_gpio,
  214. GPIOF_OUT_INIT_HIGH, "RESET");
  215. return;
  216. }
  217. static int exynos_pcie_establish_link(struct pcie_port *pp)
  218. {
  219. u32 val;
  220. int count = 0;
  221. struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp);
  222. if (dw_pcie_link_up(pp)) {
  223. dev_err(pp->dev, "Link already up\n");
  224. return 0;
  225. }
  226. /* assert reset signals */
  227. exynos_pcie_assert_core_reset(pp);
  228. exynos_pcie_assert_phy_reset(pp);
  229. /* de-assert phy reset */
  230. exynos_pcie_deassert_phy_reset(pp);
  231. /* initialize phy */
  232. exynos_pcie_init_phy(pp);
  233. /* pulse for common reset */
  234. exynos_blk_writel(exynos_pcie, 1, PCIE_PHY_COMMON_RESET);
  235. udelay(500);
  236. exynos_blk_writel(exynos_pcie, 0, PCIE_PHY_COMMON_RESET);
  237. /* de-assert core reset */
  238. exynos_pcie_deassert_core_reset(pp);
  239. /* setup root complex */
  240. dw_pcie_setup_rc(pp);
  241. /* assert reset signal */
  242. exynos_pcie_assert_reset(pp);
  243. /* assert LTSSM enable */
  244. exynos_elb_writel(exynos_pcie, PCIE_ELBI_LTSSM_ENABLE,
  245. PCIE_APP_LTSSM_ENABLE);
  246. /* check if the link is up or not */
  247. while (!dw_pcie_link_up(pp)) {
  248. mdelay(100);
  249. count++;
  250. if (count == 10) {
  251. while (exynos_phy_readl(exynos_pcie,
  252. PCIE_PHY_PLL_LOCKED) == 0) {
  253. val = exynos_blk_readl(exynos_pcie,
  254. PCIE_PHY_PLL_LOCKED);
  255. dev_info(pp->dev, "PLL Locked: 0x%x\n", val);
  256. }
  257. dev_err(pp->dev, "PCIe Link Fail\n");
  258. return -EINVAL;
  259. }
  260. }
  261. dev_info(pp->dev, "Link up\n");
  262. return 0;
  263. }
  264. static void exynos_pcie_clear_irq_pulse(struct pcie_port *pp)
  265. {
  266. u32 val;
  267. struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp);
  268. val = exynos_elb_readl(exynos_pcie, PCIE_IRQ_PULSE);
  269. exynos_elb_writel(exynos_pcie, val, PCIE_IRQ_PULSE);
  270. return;
  271. }
  272. static void exynos_pcie_enable_irq_pulse(struct pcie_port *pp)
  273. {
  274. u32 val;
  275. struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp);
  276. /* enable INTX interrupt */
  277. val = IRQ_INTA_ASSERT | IRQ_INTB_ASSERT |
  278. IRQ_INTC_ASSERT | IRQ_INTD_ASSERT,
  279. exynos_elb_writel(exynos_pcie, val, PCIE_IRQ_EN_PULSE);
  280. return;
  281. }
  282. static irqreturn_t exynos_pcie_irq_handler(int irq, void *arg)
  283. {
  284. struct pcie_port *pp = arg;
  285. exynos_pcie_clear_irq_pulse(pp);
  286. return IRQ_HANDLED;
  287. }
  288. static void exynos_pcie_enable_interrupts(struct pcie_port *pp)
  289. {
  290. exynos_pcie_enable_irq_pulse(pp);
  291. return;
  292. }
  293. static inline void exynos_pcie_readl_rc(struct pcie_port *pp,
  294. void __iomem *dbi_base, u32 *val)
  295. {
  296. exynos_pcie_sideband_dbi_r_mode(pp, true);
  297. *val = readl(dbi_base);
  298. exynos_pcie_sideband_dbi_r_mode(pp, false);
  299. return;
  300. }
  301. static inline void exynos_pcie_writel_rc(struct pcie_port *pp,
  302. u32 val, void __iomem *dbi_base)
  303. {
  304. exynos_pcie_sideband_dbi_w_mode(pp, true);
  305. writel(val, dbi_base);
  306. exynos_pcie_sideband_dbi_w_mode(pp, false);
  307. return;
  308. }
  309. static int exynos_pcie_rd_own_conf(struct pcie_port *pp, int where, int size,
  310. u32 *val)
  311. {
  312. int ret;
  313. exynos_pcie_sideband_dbi_r_mode(pp, true);
  314. ret = cfg_read(pp->dbi_base + (where & ~0x3), where, size, val);
  315. exynos_pcie_sideband_dbi_r_mode(pp, false);
  316. return ret;
  317. }
  318. static int exynos_pcie_wr_own_conf(struct pcie_port *pp, int where, int size,
  319. u32 val)
  320. {
  321. int ret;
  322. exynos_pcie_sideband_dbi_w_mode(pp, true);
  323. ret = cfg_write(pp->dbi_base + (where & ~0x3), where, size, val);
  324. exynos_pcie_sideband_dbi_w_mode(pp, false);
  325. return ret;
  326. }
  327. static int exynos_pcie_link_up(struct pcie_port *pp)
  328. {
  329. struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp);
  330. u32 val = exynos_elb_readl(exynos_pcie, PCIE_ELBI_RDLH_LINKUP);
  331. if (val == PCIE_ELBI_LTSSM_ENABLE)
  332. return 1;
  333. return 0;
  334. }
  335. static void exynos_pcie_host_init(struct pcie_port *pp)
  336. {
  337. exynos_pcie_establish_link(pp);
  338. exynos_pcie_enable_interrupts(pp);
  339. }
  340. static struct pcie_host_ops exynos_pcie_host_ops = {
  341. .readl_rc = exynos_pcie_readl_rc,
  342. .writel_rc = exynos_pcie_writel_rc,
  343. .rd_own_conf = exynos_pcie_rd_own_conf,
  344. .wr_own_conf = exynos_pcie_wr_own_conf,
  345. .link_up = exynos_pcie_link_up,
  346. .host_init = exynos_pcie_host_init,
  347. };
  348. static int add_pcie_port(struct pcie_port *pp, struct platform_device *pdev)
  349. {
  350. int ret;
  351. pp->irq = platform_get_irq(pdev, 1);
  352. if (!pp->irq) {
  353. dev_err(&pdev->dev, "failed to get irq\n");
  354. return -ENODEV;
  355. }
  356. ret = devm_request_irq(&pdev->dev, pp->irq, exynos_pcie_irq_handler,
  357. IRQF_SHARED, "exynos-pcie", pp);
  358. if (ret) {
  359. dev_err(&pdev->dev, "failed to request irq\n");
  360. return ret;
  361. }
  362. pp->root_bus_nr = -1;
  363. pp->ops = &exynos_pcie_host_ops;
  364. spin_lock_init(&pp->conf_lock);
  365. ret = dw_pcie_host_init(pp);
  366. if (ret) {
  367. dev_err(&pdev->dev, "failed to initialize host\n");
  368. return ret;
  369. }
  370. return 0;
  371. }
  372. static int __init exynos_pcie_probe(struct platform_device *pdev)
  373. {
  374. struct exynos_pcie *exynos_pcie;
  375. struct pcie_port *pp;
  376. struct device_node *np = pdev->dev.of_node;
  377. struct resource *elbi_base;
  378. struct resource *phy_base;
  379. struct resource *block_base;
  380. int ret;
  381. exynos_pcie = devm_kzalloc(&pdev->dev, sizeof(*exynos_pcie),
  382. GFP_KERNEL);
  383. if (!exynos_pcie) {
  384. dev_err(&pdev->dev, "no memory for exynos pcie\n");
  385. return -ENOMEM;
  386. }
  387. pp = &exynos_pcie->pp;
  388. pp->dev = &pdev->dev;
  389. exynos_pcie->reset_gpio = of_get_named_gpio(np, "reset-gpio", 0);
  390. exynos_pcie->clk = devm_clk_get(&pdev->dev, "pcie");
  391. if (IS_ERR(exynos_pcie->clk)) {
  392. dev_err(&pdev->dev, "Failed to get pcie rc clock\n");
  393. return PTR_ERR(exynos_pcie->clk);
  394. }
  395. ret = clk_prepare_enable(exynos_pcie->clk);
  396. if (ret)
  397. return ret;
  398. exynos_pcie->bus_clk = devm_clk_get(&pdev->dev, "pcie_bus");
  399. if (IS_ERR(exynos_pcie->bus_clk)) {
  400. dev_err(&pdev->dev, "Failed to get pcie bus clock\n");
  401. ret = PTR_ERR(exynos_pcie->bus_clk);
  402. goto fail_clk;
  403. }
  404. ret = clk_prepare_enable(exynos_pcie->bus_clk);
  405. if (ret)
  406. goto fail_clk;
  407. elbi_base = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  408. exynos_pcie->elbi_base = devm_ioremap_resource(&pdev->dev, elbi_base);
  409. if (IS_ERR(exynos_pcie->elbi_base))
  410. return PTR_ERR(exynos_pcie->elbi_base);
  411. phy_base = platform_get_resource(pdev, IORESOURCE_MEM, 1);
  412. exynos_pcie->phy_base = devm_ioremap_resource(&pdev->dev, phy_base);
  413. if (IS_ERR(exynos_pcie->phy_base))
  414. return PTR_ERR(exynos_pcie->phy_base);
  415. block_base = platform_get_resource(pdev, IORESOURCE_MEM, 2);
  416. exynos_pcie->block_base = devm_ioremap_resource(&pdev->dev, block_base);
  417. if (IS_ERR(exynos_pcie->block_base))
  418. return PTR_ERR(exynos_pcie->block_base);
  419. ret = add_pcie_port(pp, pdev);
  420. if (ret < 0)
  421. goto fail_bus_clk;
  422. platform_set_drvdata(pdev, exynos_pcie);
  423. return 0;
  424. fail_bus_clk:
  425. clk_disable_unprepare(exynos_pcie->bus_clk);
  426. fail_clk:
  427. clk_disable_unprepare(exynos_pcie->clk);
  428. return ret;
  429. }
  430. static int __exit exynos_pcie_remove(struct platform_device *pdev)
  431. {
  432. struct exynos_pcie *exynos_pcie = platform_get_drvdata(pdev);
  433. clk_disable_unprepare(exynos_pcie->bus_clk);
  434. clk_disable_unprepare(exynos_pcie->clk);
  435. return 0;
  436. }
  437. static const struct of_device_id exynos_pcie_of_match[] = {
  438. { .compatible = "samsung,exynos5440-pcie", },
  439. {},
  440. };
  441. MODULE_DEVICE_TABLE(of, exynos_pcie_of_match);
  442. static struct platform_driver exynos_pcie_driver = {
  443. .remove = __exit_p(exynos_pcie_remove),
  444. .driver = {
  445. .name = "exynos-pcie",
  446. .owner = THIS_MODULE,
  447. .of_match_table = of_match_ptr(exynos_pcie_of_match),
  448. },
  449. };
  450. /* Exynos PCIe driver does not allow module unload */
  451. static int __init pcie_init(void)
  452. {
  453. return platform_driver_probe(&exynos_pcie_driver, exynos_pcie_probe);
  454. }
  455. subsys_initcall(pcie_init);
  456. MODULE_AUTHOR("Jingoo Han <jg1.han@samsung.com>");
  457. MODULE_DESCRIPTION("Samsung PCIe host controller driver");
  458. MODULE_LICENSE("GPL v2");