intel-lpss-acpi.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Intel LPSS ACPI support.
  4. *
  5. * Copyright (C) 2015, Intel Corporation
  6. *
  7. * Authors: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
  8. * Mika Westerberg <mika.westerberg@linux.intel.com>
  9. */
  10. #include <linux/acpi.h>
  11. #include <linux/ioport.h>
  12. #include <linux/kernel.h>
  13. #include <linux/module.h>
  14. #include <linux/pm_runtime.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/property.h>
  17. #include "intel-lpss.h"
  18. static const struct intel_lpss_platform_info spt_info = {
  19. .clk_rate = 120000000,
  20. };
  21. static struct property_entry spt_i2c_properties[] = {
  22. PROPERTY_ENTRY_U32("i2c-sda-hold-time-ns", 230),
  23. { },
  24. };
  25. static const struct intel_lpss_platform_info spt_i2c_info = {
  26. .clk_rate = 120000000,
  27. .properties = spt_i2c_properties,
  28. };
  29. static struct property_entry uart_properties[] = {
  30. PROPERTY_ENTRY_U32("reg-io-width", 4),
  31. PROPERTY_ENTRY_U32("reg-shift", 2),
  32. PROPERTY_ENTRY_BOOL("snps,uart-16550-compatible"),
  33. { },
  34. };
  35. static const struct intel_lpss_platform_info spt_uart_info = {
  36. .clk_rate = 120000000,
  37. .clk_con_id = "baudclk",
  38. .properties = uart_properties,
  39. };
  40. static const struct intel_lpss_platform_info bxt_info = {
  41. .clk_rate = 100000000,
  42. };
  43. static struct property_entry bxt_i2c_properties[] = {
  44. PROPERTY_ENTRY_U32("i2c-sda-hold-time-ns", 42),
  45. PROPERTY_ENTRY_U32("i2c-sda-falling-time-ns", 171),
  46. PROPERTY_ENTRY_U32("i2c-scl-falling-time-ns", 208),
  47. { },
  48. };
  49. static const struct intel_lpss_platform_info bxt_i2c_info = {
  50. .clk_rate = 133000000,
  51. .properties = bxt_i2c_properties,
  52. };
  53. static struct property_entry apl_i2c_properties[] = {
  54. PROPERTY_ENTRY_U32("i2c-sda-hold-time-ns", 207),
  55. PROPERTY_ENTRY_U32("i2c-sda-falling-time-ns", 171),
  56. PROPERTY_ENTRY_U32("i2c-scl-falling-time-ns", 208),
  57. { },
  58. };
  59. static const struct intel_lpss_platform_info apl_i2c_info = {
  60. .clk_rate = 133000000,
  61. .properties = apl_i2c_properties,
  62. };
  63. static const struct acpi_device_id intel_lpss_acpi_ids[] = {
  64. /* SPT */
  65. { "INT3440", (kernel_ulong_t)&spt_info },
  66. { "INT3441", (kernel_ulong_t)&spt_info },
  67. { "INT3442", (kernel_ulong_t)&spt_i2c_info },
  68. { "INT3443", (kernel_ulong_t)&spt_i2c_info },
  69. { "INT3444", (kernel_ulong_t)&spt_i2c_info },
  70. { "INT3445", (kernel_ulong_t)&spt_i2c_info },
  71. { "INT3446", (kernel_ulong_t)&spt_i2c_info },
  72. { "INT3447", (kernel_ulong_t)&spt_i2c_info },
  73. { "INT3448", (kernel_ulong_t)&spt_uart_info },
  74. { "INT3449", (kernel_ulong_t)&spt_uart_info },
  75. { "INT344A", (kernel_ulong_t)&spt_uart_info },
  76. /* BXT */
  77. { "80860AAC", (kernel_ulong_t)&bxt_i2c_info },
  78. { "80860ABC", (kernel_ulong_t)&bxt_info },
  79. { "80860AC2", (kernel_ulong_t)&bxt_info },
  80. /* APL */
  81. { "80865AAC", (kernel_ulong_t)&apl_i2c_info },
  82. { "80865ABC", (kernel_ulong_t)&bxt_info },
  83. { "80865AC2", (kernel_ulong_t)&bxt_info },
  84. { }
  85. };
  86. MODULE_DEVICE_TABLE(acpi, intel_lpss_acpi_ids);
  87. static int intel_lpss_acpi_probe(struct platform_device *pdev)
  88. {
  89. struct intel_lpss_platform_info *info;
  90. const struct acpi_device_id *id;
  91. int ret;
  92. id = acpi_match_device(intel_lpss_acpi_ids, &pdev->dev);
  93. if (!id)
  94. return -ENODEV;
  95. info = devm_kmemdup(&pdev->dev, (void *)id->driver_data, sizeof(*info),
  96. GFP_KERNEL);
  97. if (!info)
  98. return -ENOMEM;
  99. info->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  100. info->irq = platform_get_irq(pdev, 0);
  101. ret = intel_lpss_probe(&pdev->dev, info);
  102. if (ret)
  103. return ret;
  104. pm_runtime_set_active(&pdev->dev);
  105. pm_runtime_enable(&pdev->dev);
  106. return 0;
  107. }
  108. static int intel_lpss_acpi_remove(struct platform_device *pdev)
  109. {
  110. intel_lpss_remove(&pdev->dev);
  111. pm_runtime_disable(&pdev->dev);
  112. return 0;
  113. }
  114. static INTEL_LPSS_PM_OPS(intel_lpss_acpi_pm_ops);
  115. static struct platform_driver intel_lpss_acpi_driver = {
  116. .probe = intel_lpss_acpi_probe,
  117. .remove = intel_lpss_acpi_remove,
  118. .driver = {
  119. .name = "intel-lpss",
  120. .acpi_match_table = intel_lpss_acpi_ids,
  121. .pm = &intel_lpss_acpi_pm_ops,
  122. },
  123. };
  124. module_platform_driver(intel_lpss_acpi_driver);
  125. MODULE_AUTHOR("Andy Shevchenko <andriy.shevchenko@linux.intel.com>");
  126. MODULE_AUTHOR("Mika Westerberg <mika.westerberg@linux.intel.com>");
  127. MODULE_DESCRIPTION("Intel LPSS ACPI driver");
  128. MODULE_LICENSE("GPL v2");