intel-lpss-pci.c 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /*
  2. * Intel LPSS PCI support.
  3. *
  4. * Copyright (C) 2015, Intel Corporation
  5. *
  6. * Authors: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
  7. * Mika Westerberg <mika.westerberg@linux.intel.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/ioport.h>
  14. #include <linux/kernel.h>
  15. #include <linux/module.h>
  16. #include <linux/pci.h>
  17. #include <linux/pm.h>
  18. #include <linux/pm_runtime.h>
  19. #include <linux/property.h>
  20. #include "intel-lpss.h"
  21. static int intel_lpss_pci_probe(struct pci_dev *pdev,
  22. const struct pci_device_id *id)
  23. {
  24. struct intel_lpss_platform_info *info;
  25. int ret;
  26. ret = pcim_enable_device(pdev);
  27. if (ret)
  28. return ret;
  29. info = devm_kmemdup(&pdev->dev, (void *)id->driver_data, sizeof(*info),
  30. GFP_KERNEL);
  31. if (!info)
  32. return -ENOMEM;
  33. info->mem = &pdev->resource[0];
  34. info->irq = pdev->irq;
  35. /* Probably it is enough to set this for iDMA capable devices only */
  36. pci_set_master(pdev);
  37. ret = intel_lpss_probe(&pdev->dev, info);
  38. if (ret)
  39. return ret;
  40. pm_runtime_put(&pdev->dev);
  41. pm_runtime_allow(&pdev->dev);
  42. return 0;
  43. }
  44. static void intel_lpss_pci_remove(struct pci_dev *pdev)
  45. {
  46. pm_runtime_forbid(&pdev->dev);
  47. pm_runtime_get_sync(&pdev->dev);
  48. intel_lpss_remove(&pdev->dev);
  49. }
  50. static INTEL_LPSS_PM_OPS(intel_lpss_pci_pm_ops);
  51. static const struct intel_lpss_platform_info spt_info = {
  52. .clk_rate = 120000000,
  53. };
  54. static struct property_entry spt_i2c_properties[] = {
  55. PROPERTY_ENTRY_U32("i2c-sda-hold-time-ns", 230),
  56. { },
  57. };
  58. static struct property_set spt_i2c_pset = {
  59. .properties = spt_i2c_properties,
  60. };
  61. static const struct intel_lpss_platform_info spt_i2c_info = {
  62. .clk_rate = 120000000,
  63. .pset = &spt_i2c_pset,
  64. };
  65. static struct property_entry uart_properties[] = {
  66. PROPERTY_ENTRY_U32("reg-io-width", 4),
  67. PROPERTY_ENTRY_U32("reg-shift", 2),
  68. PROPERTY_ENTRY_BOOL("snps,uart-16550-compatible"),
  69. { },
  70. };
  71. static struct property_set uart_pset = {
  72. .properties = uart_properties,
  73. };
  74. static const struct intel_lpss_platform_info spt_uart_info = {
  75. .clk_rate = 120000000,
  76. .clk_con_id = "baudclk",
  77. .pset = &uart_pset,
  78. };
  79. static const struct intel_lpss_platform_info bxt_info = {
  80. .clk_rate = 100000000,
  81. };
  82. static const struct intel_lpss_platform_info bxt_uart_info = {
  83. .clk_rate = 100000000,
  84. .clk_con_id = "baudclk",
  85. .pset = &uart_pset,
  86. };
  87. static struct property_entry bxt_i2c_properties[] = {
  88. PROPERTY_ENTRY_U32("i2c-sda-hold-time-ns", 42),
  89. PROPERTY_ENTRY_U32("i2c-sda-falling-time-ns", 171),
  90. PROPERTY_ENTRY_U32("i2c-scl-falling-time-ns", 208),
  91. { },
  92. };
  93. static struct property_set bxt_i2c_pset = {
  94. .properties = bxt_i2c_properties,
  95. };
  96. static const struct intel_lpss_platform_info bxt_i2c_info = {
  97. .clk_rate = 133000000,
  98. .pset = &bxt_i2c_pset,
  99. };
  100. static const struct pci_device_id intel_lpss_pci_ids[] = {
  101. /* BXT A-Step */
  102. { PCI_VDEVICE(INTEL, 0x0aac), (kernel_ulong_t)&bxt_i2c_info },
  103. { PCI_VDEVICE(INTEL, 0x0aae), (kernel_ulong_t)&bxt_i2c_info },
  104. { PCI_VDEVICE(INTEL, 0x0ab0), (kernel_ulong_t)&bxt_i2c_info },
  105. { PCI_VDEVICE(INTEL, 0x0ab2), (kernel_ulong_t)&bxt_i2c_info },
  106. { PCI_VDEVICE(INTEL, 0x0ab4), (kernel_ulong_t)&bxt_i2c_info },
  107. { PCI_VDEVICE(INTEL, 0x0ab6), (kernel_ulong_t)&bxt_i2c_info },
  108. { PCI_VDEVICE(INTEL, 0x0ab8), (kernel_ulong_t)&bxt_i2c_info },
  109. { PCI_VDEVICE(INTEL, 0x0aba), (kernel_ulong_t)&bxt_i2c_info },
  110. { PCI_VDEVICE(INTEL, 0x0abc), (kernel_ulong_t)&bxt_uart_info },
  111. { PCI_VDEVICE(INTEL, 0x0abe), (kernel_ulong_t)&bxt_uart_info },
  112. { PCI_VDEVICE(INTEL, 0x0ac0), (kernel_ulong_t)&bxt_uart_info },
  113. { PCI_VDEVICE(INTEL, 0x0ac2), (kernel_ulong_t)&bxt_info },
  114. { PCI_VDEVICE(INTEL, 0x0ac4), (kernel_ulong_t)&bxt_info },
  115. { PCI_VDEVICE(INTEL, 0x0ac6), (kernel_ulong_t)&bxt_info },
  116. { PCI_VDEVICE(INTEL, 0x0aee), (kernel_ulong_t)&bxt_uart_info },
  117. /* BXT B-Step */
  118. { PCI_VDEVICE(INTEL, 0x1aac), (kernel_ulong_t)&bxt_i2c_info },
  119. { PCI_VDEVICE(INTEL, 0x1aae), (kernel_ulong_t)&bxt_i2c_info },
  120. { PCI_VDEVICE(INTEL, 0x1ab0), (kernel_ulong_t)&bxt_i2c_info },
  121. { PCI_VDEVICE(INTEL, 0x1ab2), (kernel_ulong_t)&bxt_i2c_info },
  122. { PCI_VDEVICE(INTEL, 0x1ab4), (kernel_ulong_t)&bxt_i2c_info },
  123. { PCI_VDEVICE(INTEL, 0x1ab6), (kernel_ulong_t)&bxt_i2c_info },
  124. { PCI_VDEVICE(INTEL, 0x1ab8), (kernel_ulong_t)&bxt_i2c_info },
  125. { PCI_VDEVICE(INTEL, 0x1aba), (kernel_ulong_t)&bxt_i2c_info },
  126. { PCI_VDEVICE(INTEL, 0x1abc), (kernel_ulong_t)&bxt_uart_info },
  127. { PCI_VDEVICE(INTEL, 0x1abe), (kernel_ulong_t)&bxt_uart_info },
  128. { PCI_VDEVICE(INTEL, 0x1ac0), (kernel_ulong_t)&bxt_uart_info },
  129. { PCI_VDEVICE(INTEL, 0x1ac2), (kernel_ulong_t)&bxt_info },
  130. { PCI_VDEVICE(INTEL, 0x1ac4), (kernel_ulong_t)&bxt_info },
  131. { PCI_VDEVICE(INTEL, 0x1ac6), (kernel_ulong_t)&bxt_info },
  132. { PCI_VDEVICE(INTEL, 0x1aee), (kernel_ulong_t)&bxt_uart_info },
  133. /* APL */
  134. { PCI_VDEVICE(INTEL, 0x5aac), (kernel_ulong_t)&bxt_i2c_info },
  135. { PCI_VDEVICE(INTEL, 0x5aae), (kernel_ulong_t)&bxt_i2c_info },
  136. { PCI_VDEVICE(INTEL, 0x5ab0), (kernel_ulong_t)&bxt_i2c_info },
  137. { PCI_VDEVICE(INTEL, 0x5ab2), (kernel_ulong_t)&bxt_i2c_info },
  138. { PCI_VDEVICE(INTEL, 0x5ab4), (kernel_ulong_t)&bxt_i2c_info },
  139. { PCI_VDEVICE(INTEL, 0x5ab6), (kernel_ulong_t)&bxt_i2c_info },
  140. { PCI_VDEVICE(INTEL, 0x5ab8), (kernel_ulong_t)&bxt_i2c_info },
  141. { PCI_VDEVICE(INTEL, 0x5aba), (kernel_ulong_t)&bxt_i2c_info },
  142. { PCI_VDEVICE(INTEL, 0x5abc), (kernel_ulong_t)&bxt_uart_info },
  143. { PCI_VDEVICE(INTEL, 0x5abe), (kernel_ulong_t)&bxt_uart_info },
  144. { PCI_VDEVICE(INTEL, 0x5ac0), (kernel_ulong_t)&bxt_uart_info },
  145. { PCI_VDEVICE(INTEL, 0x5ac2), (kernel_ulong_t)&bxt_info },
  146. { PCI_VDEVICE(INTEL, 0x5ac4), (kernel_ulong_t)&bxt_info },
  147. { PCI_VDEVICE(INTEL, 0x5ac6), (kernel_ulong_t)&bxt_info },
  148. { PCI_VDEVICE(INTEL, 0x5aee), (kernel_ulong_t)&bxt_uart_info },
  149. /* SPT-LP */
  150. { PCI_VDEVICE(INTEL, 0x9d27), (kernel_ulong_t)&spt_uart_info },
  151. { PCI_VDEVICE(INTEL, 0x9d28), (kernel_ulong_t)&spt_uart_info },
  152. { PCI_VDEVICE(INTEL, 0x9d29), (kernel_ulong_t)&spt_info },
  153. { PCI_VDEVICE(INTEL, 0x9d2a), (kernel_ulong_t)&spt_info },
  154. { PCI_VDEVICE(INTEL, 0x9d60), (kernel_ulong_t)&spt_i2c_info },
  155. { PCI_VDEVICE(INTEL, 0x9d61), (kernel_ulong_t)&spt_i2c_info },
  156. { PCI_VDEVICE(INTEL, 0x9d62), (kernel_ulong_t)&spt_i2c_info },
  157. { PCI_VDEVICE(INTEL, 0x9d63), (kernel_ulong_t)&spt_i2c_info },
  158. { PCI_VDEVICE(INTEL, 0x9d64), (kernel_ulong_t)&spt_i2c_info },
  159. { PCI_VDEVICE(INTEL, 0x9d65), (kernel_ulong_t)&spt_i2c_info },
  160. { PCI_VDEVICE(INTEL, 0x9d66), (kernel_ulong_t)&spt_uart_info },
  161. /* SPT-H */
  162. { PCI_VDEVICE(INTEL, 0xa127), (kernel_ulong_t)&spt_uart_info },
  163. { PCI_VDEVICE(INTEL, 0xa128), (kernel_ulong_t)&spt_uart_info },
  164. { PCI_VDEVICE(INTEL, 0xa129), (kernel_ulong_t)&spt_info },
  165. { PCI_VDEVICE(INTEL, 0xa12a), (kernel_ulong_t)&spt_info },
  166. { PCI_VDEVICE(INTEL, 0xa160), (kernel_ulong_t)&spt_i2c_info },
  167. { PCI_VDEVICE(INTEL, 0xa161), (kernel_ulong_t)&spt_i2c_info },
  168. { PCI_VDEVICE(INTEL, 0xa166), (kernel_ulong_t)&spt_uart_info },
  169. { }
  170. };
  171. MODULE_DEVICE_TABLE(pci, intel_lpss_pci_ids);
  172. static struct pci_driver intel_lpss_pci_driver = {
  173. .name = "intel-lpss",
  174. .id_table = intel_lpss_pci_ids,
  175. .probe = intel_lpss_pci_probe,
  176. .remove = intel_lpss_pci_remove,
  177. .driver = {
  178. .pm = &intel_lpss_pci_pm_ops,
  179. },
  180. };
  181. module_pci_driver(intel_lpss_pci_driver);
  182. MODULE_AUTHOR("Andy Shevchenko <andriy.shevchenko@linux.intel.com>");
  183. MODULE_AUTHOR("Mika Westerberg <mika.westerberg@linux.intel.com>");
  184. MODULE_DESCRIPTION("Intel LPSS PCI driver");
  185. MODULE_LICENSE("GPL v2");