intel-lpss-pci.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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 "intel-lpss.h"
  20. static int intel_lpss_pci_probe(struct pci_dev *pdev,
  21. const struct pci_device_id *id)
  22. {
  23. struct intel_lpss_platform_info *info;
  24. int ret;
  25. ret = pcim_enable_device(pdev);
  26. if (ret)
  27. return ret;
  28. info = devm_kmemdup(&pdev->dev, (void *)id->driver_data, sizeof(*info),
  29. GFP_KERNEL);
  30. if (!info)
  31. return -ENOMEM;
  32. info->mem = &pdev->resource[0];
  33. info->irq = pdev->irq;
  34. /* Probably it is enough to set this for iDMA capable devices only */
  35. pci_set_master(pdev);
  36. ret = intel_lpss_probe(&pdev->dev, info);
  37. if (ret)
  38. return ret;
  39. pm_runtime_put(&pdev->dev);
  40. pm_runtime_allow(&pdev->dev);
  41. return 0;
  42. }
  43. static void intel_lpss_pci_remove(struct pci_dev *pdev)
  44. {
  45. pm_runtime_forbid(&pdev->dev);
  46. pm_runtime_get_sync(&pdev->dev);
  47. intel_lpss_remove(&pdev->dev);
  48. }
  49. static INTEL_LPSS_PM_OPS(intel_lpss_pci_pm_ops);
  50. static const struct intel_lpss_platform_info spt_info = {
  51. .clk_rate = 120000000,
  52. };
  53. static const struct intel_lpss_platform_info spt_uart_info = {
  54. .clk_rate = 120000000,
  55. .clk_con_id = "baudclk",
  56. };
  57. static const struct intel_lpss_platform_info bxt_info = {
  58. .clk_rate = 100000000,
  59. };
  60. static const struct intel_lpss_platform_info bxt_uart_info = {
  61. .clk_rate = 100000000,
  62. .clk_con_id = "baudclk",
  63. };
  64. static const struct intel_lpss_platform_info bxt_i2c_info = {
  65. .clk_rate = 133000000,
  66. };
  67. static const struct pci_device_id intel_lpss_pci_ids[] = {
  68. /* BXT */
  69. { PCI_VDEVICE(INTEL, 0x0aac), (kernel_ulong_t)&bxt_i2c_info },
  70. { PCI_VDEVICE(INTEL, 0x0aae), (kernel_ulong_t)&bxt_i2c_info },
  71. { PCI_VDEVICE(INTEL, 0x0ab0), (kernel_ulong_t)&bxt_i2c_info },
  72. { PCI_VDEVICE(INTEL, 0x0ab2), (kernel_ulong_t)&bxt_i2c_info },
  73. { PCI_VDEVICE(INTEL, 0x0ab4), (kernel_ulong_t)&bxt_i2c_info },
  74. { PCI_VDEVICE(INTEL, 0x0ab6), (kernel_ulong_t)&bxt_i2c_info },
  75. { PCI_VDEVICE(INTEL, 0x0ab8), (kernel_ulong_t)&bxt_i2c_info },
  76. { PCI_VDEVICE(INTEL, 0x0aba), (kernel_ulong_t)&bxt_i2c_info },
  77. { PCI_VDEVICE(INTEL, 0x0abc), (kernel_ulong_t)&bxt_uart_info },
  78. { PCI_VDEVICE(INTEL, 0x0abe), (kernel_ulong_t)&bxt_uart_info },
  79. { PCI_VDEVICE(INTEL, 0x0ac0), (kernel_ulong_t)&bxt_uart_info },
  80. { PCI_VDEVICE(INTEL, 0x0ac2), (kernel_ulong_t)&bxt_info },
  81. { PCI_VDEVICE(INTEL, 0x0ac4), (kernel_ulong_t)&bxt_info },
  82. { PCI_VDEVICE(INTEL, 0x0ac6), (kernel_ulong_t)&bxt_info },
  83. { PCI_VDEVICE(INTEL, 0x0aee), (kernel_ulong_t)&bxt_uart_info },
  84. /* APL */
  85. { PCI_VDEVICE(INTEL, 0x5aac), (kernel_ulong_t)&bxt_i2c_info },
  86. { PCI_VDEVICE(INTEL, 0x5aae), (kernel_ulong_t)&bxt_i2c_info },
  87. { PCI_VDEVICE(INTEL, 0x5ab0), (kernel_ulong_t)&bxt_i2c_info },
  88. { PCI_VDEVICE(INTEL, 0x5ab2), (kernel_ulong_t)&bxt_i2c_info },
  89. { PCI_VDEVICE(INTEL, 0x5ab4), (kernel_ulong_t)&bxt_i2c_info },
  90. { PCI_VDEVICE(INTEL, 0x5ab6), (kernel_ulong_t)&bxt_i2c_info },
  91. { PCI_VDEVICE(INTEL, 0x5ab8), (kernel_ulong_t)&bxt_i2c_info },
  92. { PCI_VDEVICE(INTEL, 0x5aba), (kernel_ulong_t)&bxt_i2c_info },
  93. { PCI_VDEVICE(INTEL, 0x5abc), (kernel_ulong_t)&bxt_uart_info },
  94. { PCI_VDEVICE(INTEL, 0x5abe), (kernel_ulong_t)&bxt_uart_info },
  95. { PCI_VDEVICE(INTEL, 0x5ac0), (kernel_ulong_t)&bxt_uart_info },
  96. { PCI_VDEVICE(INTEL, 0x5ac2), (kernel_ulong_t)&bxt_info },
  97. { PCI_VDEVICE(INTEL, 0x5ac4), (kernel_ulong_t)&bxt_info },
  98. { PCI_VDEVICE(INTEL, 0x5ac6), (kernel_ulong_t)&bxt_info },
  99. { PCI_VDEVICE(INTEL, 0x5aee), (kernel_ulong_t)&bxt_uart_info },
  100. /* SPT-LP */
  101. { PCI_VDEVICE(INTEL, 0x9d27), (kernel_ulong_t)&spt_uart_info },
  102. { PCI_VDEVICE(INTEL, 0x9d28), (kernel_ulong_t)&spt_uart_info },
  103. { PCI_VDEVICE(INTEL, 0x9d29), (kernel_ulong_t)&spt_info },
  104. { PCI_VDEVICE(INTEL, 0x9d2a), (kernel_ulong_t)&spt_info },
  105. { PCI_VDEVICE(INTEL, 0x9d60), (kernel_ulong_t)&spt_info },
  106. { PCI_VDEVICE(INTEL, 0x9d61), (kernel_ulong_t)&spt_info },
  107. { PCI_VDEVICE(INTEL, 0x9d62), (kernel_ulong_t)&spt_info },
  108. { PCI_VDEVICE(INTEL, 0x9d63), (kernel_ulong_t)&spt_info },
  109. { PCI_VDEVICE(INTEL, 0x9d64), (kernel_ulong_t)&spt_info },
  110. { PCI_VDEVICE(INTEL, 0x9d65), (kernel_ulong_t)&spt_info },
  111. { PCI_VDEVICE(INTEL, 0x9d66), (kernel_ulong_t)&spt_uart_info },
  112. /* SPT-H */
  113. { PCI_VDEVICE(INTEL, 0xa127), (kernel_ulong_t)&spt_uart_info },
  114. { PCI_VDEVICE(INTEL, 0xa128), (kernel_ulong_t)&spt_uart_info },
  115. { PCI_VDEVICE(INTEL, 0xa129), (kernel_ulong_t)&spt_info },
  116. { PCI_VDEVICE(INTEL, 0xa12a), (kernel_ulong_t)&spt_info },
  117. { PCI_VDEVICE(INTEL, 0xa160), (kernel_ulong_t)&spt_info },
  118. { PCI_VDEVICE(INTEL, 0xa161), (kernel_ulong_t)&spt_info },
  119. { PCI_VDEVICE(INTEL, 0xa166), (kernel_ulong_t)&spt_uart_info },
  120. { }
  121. };
  122. MODULE_DEVICE_TABLE(pci, intel_lpss_pci_ids);
  123. static struct pci_driver intel_lpss_pci_driver = {
  124. .name = "intel-lpss",
  125. .id_table = intel_lpss_pci_ids,
  126. .probe = intel_lpss_pci_probe,
  127. .remove = intel_lpss_pci_remove,
  128. .driver = {
  129. .pm = &intel_lpss_pci_pm_ops,
  130. },
  131. };
  132. module_pci_driver(intel_lpss_pci_driver);
  133. MODULE_AUTHOR("Andy Shevchenko <andriy.shevchenko@linux.intel.com>");
  134. MODULE_AUTHOR("Mika Westerberg <mika.westerberg@linux.intel.com>");
  135. MODULE_DESCRIPTION("Intel LPSS PCI driver");
  136. MODULE_LICENSE("GPL v2");