intel-lpss-acpi.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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 <[email protected]>
  8. * Mika Westerberg <[email protected]>
  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 <linux/pxa2xx_ssp.h>
  18. #include "intel-lpss.h"
  19. static const struct property_entry spt_spi_properties[] = {
  20. PROPERTY_ENTRY_U32("intel,spi-pxa2xx-type", LPSS_SPT_SSP),
  21. { }
  22. };
  23. static const struct software_node spt_spi_node = {
  24. .properties = spt_spi_properties,
  25. };
  26. static const struct intel_lpss_platform_info spt_info = {
  27. .clk_rate = 120000000,
  28. .swnode = &spt_spi_node,
  29. };
  30. static const struct property_entry spt_i2c_properties[] = {
  31. PROPERTY_ENTRY_U32("i2c-sda-hold-time-ns", 230),
  32. { },
  33. };
  34. static const struct software_node spt_i2c_node = {
  35. .properties = spt_i2c_properties,
  36. };
  37. static const struct intel_lpss_platform_info spt_i2c_info = {
  38. .clk_rate = 120000000,
  39. .swnode = &spt_i2c_node,
  40. };
  41. static const struct property_entry uart_properties[] = {
  42. PROPERTY_ENTRY_U32("reg-io-width", 4),
  43. PROPERTY_ENTRY_U32("reg-shift", 2),
  44. PROPERTY_ENTRY_BOOL("snps,uart-16550-compatible"),
  45. { },
  46. };
  47. static const struct software_node uart_node = {
  48. .properties = uart_properties,
  49. };
  50. static const struct intel_lpss_platform_info spt_uart_info = {
  51. .clk_rate = 120000000,
  52. .clk_con_id = "baudclk",
  53. .swnode = &uart_node,
  54. };
  55. static const struct property_entry bxt_spi_properties[] = {
  56. PROPERTY_ENTRY_U32("intel,spi-pxa2xx-type", LPSS_BXT_SSP),
  57. { }
  58. };
  59. static const struct software_node bxt_spi_node = {
  60. .properties = bxt_spi_properties,
  61. };
  62. static const struct intel_lpss_platform_info bxt_info = {
  63. .clk_rate = 100000000,
  64. .swnode = &bxt_spi_node,
  65. };
  66. static const struct property_entry bxt_i2c_properties[] = {
  67. PROPERTY_ENTRY_U32("i2c-sda-hold-time-ns", 42),
  68. PROPERTY_ENTRY_U32("i2c-sda-falling-time-ns", 171),
  69. PROPERTY_ENTRY_U32("i2c-scl-falling-time-ns", 208),
  70. { },
  71. };
  72. static const struct software_node bxt_i2c_node = {
  73. .properties = bxt_i2c_properties,
  74. };
  75. static const struct intel_lpss_platform_info bxt_i2c_info = {
  76. .clk_rate = 133000000,
  77. .swnode = &bxt_i2c_node,
  78. };
  79. static const struct property_entry apl_i2c_properties[] = {
  80. PROPERTY_ENTRY_U32("i2c-sda-hold-time-ns", 207),
  81. PROPERTY_ENTRY_U32("i2c-sda-falling-time-ns", 171),
  82. PROPERTY_ENTRY_U32("i2c-scl-falling-time-ns", 208),
  83. { },
  84. };
  85. static const struct software_node apl_i2c_node = {
  86. .properties = apl_i2c_properties,
  87. };
  88. static const struct intel_lpss_platform_info apl_i2c_info = {
  89. .clk_rate = 133000000,
  90. .swnode = &apl_i2c_node,
  91. };
  92. static const struct property_entry cnl_spi_properties[] = {
  93. PROPERTY_ENTRY_U32("intel,spi-pxa2xx-type", LPSS_CNL_SSP),
  94. { }
  95. };
  96. static const struct software_node cnl_spi_node = {
  97. .properties = cnl_spi_properties,
  98. };
  99. static const struct intel_lpss_platform_info cnl_info = {
  100. .clk_rate = 120000000,
  101. .swnode = &cnl_spi_node,
  102. };
  103. static const struct intel_lpss_platform_info cnl_i2c_info = {
  104. .clk_rate = 216000000,
  105. .swnode = &spt_i2c_node,
  106. };
  107. static const struct acpi_device_id intel_lpss_acpi_ids[] = {
  108. /* SPT */
  109. { "INT3440", (kernel_ulong_t)&spt_info },
  110. { "INT3441", (kernel_ulong_t)&spt_info },
  111. { "INT3442", (kernel_ulong_t)&spt_i2c_info },
  112. { "INT3443", (kernel_ulong_t)&spt_i2c_info },
  113. { "INT3444", (kernel_ulong_t)&spt_i2c_info },
  114. { "INT3445", (kernel_ulong_t)&spt_i2c_info },
  115. { "INT3446", (kernel_ulong_t)&spt_i2c_info },
  116. { "INT3447", (kernel_ulong_t)&spt_i2c_info },
  117. { "INT3448", (kernel_ulong_t)&spt_uart_info },
  118. { "INT3449", (kernel_ulong_t)&spt_uart_info },
  119. { "INT344A", (kernel_ulong_t)&spt_uart_info },
  120. /* CNL */
  121. { "INT34B0", (kernel_ulong_t)&cnl_info },
  122. { "INT34B1", (kernel_ulong_t)&cnl_info },
  123. { "INT34B2", (kernel_ulong_t)&cnl_i2c_info },
  124. { "INT34B3", (kernel_ulong_t)&cnl_i2c_info },
  125. { "INT34B4", (kernel_ulong_t)&cnl_i2c_info },
  126. { "INT34B5", (kernel_ulong_t)&cnl_i2c_info },
  127. { "INT34B6", (kernel_ulong_t)&cnl_i2c_info },
  128. { "INT34B7", (kernel_ulong_t)&cnl_i2c_info },
  129. { "INT34B8", (kernel_ulong_t)&spt_uart_info },
  130. { "INT34B9", (kernel_ulong_t)&spt_uart_info },
  131. { "INT34BA", (kernel_ulong_t)&spt_uart_info },
  132. { "INT34BC", (kernel_ulong_t)&cnl_info },
  133. /* BXT */
  134. { "80860AAC", (kernel_ulong_t)&bxt_i2c_info },
  135. { "80860ABC", (kernel_ulong_t)&bxt_info },
  136. { "80860AC2", (kernel_ulong_t)&bxt_info },
  137. /* APL */
  138. { "80865AAC", (kernel_ulong_t)&apl_i2c_info },
  139. { "80865ABC", (kernel_ulong_t)&bxt_info },
  140. { "80865AC2", (kernel_ulong_t)&bxt_info },
  141. { }
  142. };
  143. MODULE_DEVICE_TABLE(acpi, intel_lpss_acpi_ids);
  144. static int intel_lpss_acpi_probe(struct platform_device *pdev)
  145. {
  146. struct intel_lpss_platform_info *info;
  147. const struct acpi_device_id *id;
  148. int ret;
  149. id = acpi_match_device(intel_lpss_acpi_ids, &pdev->dev);
  150. if (!id)
  151. return -ENODEV;
  152. info = devm_kmemdup(&pdev->dev, (void *)id->driver_data, sizeof(*info),
  153. GFP_KERNEL);
  154. if (!info)
  155. return -ENOMEM;
  156. info->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  157. if (!info->mem)
  158. return -ENODEV;
  159. info->irq = platform_get_irq(pdev, 0);
  160. ret = intel_lpss_probe(&pdev->dev, info);
  161. if (ret)
  162. return ret;
  163. pm_runtime_set_active(&pdev->dev);
  164. pm_runtime_enable(&pdev->dev);
  165. return 0;
  166. }
  167. static int intel_lpss_acpi_remove(struct platform_device *pdev)
  168. {
  169. intel_lpss_remove(&pdev->dev);
  170. pm_runtime_disable(&pdev->dev);
  171. return 0;
  172. }
  173. static INTEL_LPSS_PM_OPS(intel_lpss_acpi_pm_ops);
  174. static struct platform_driver intel_lpss_acpi_driver = {
  175. .probe = intel_lpss_acpi_probe,
  176. .remove = intel_lpss_acpi_remove,
  177. .driver = {
  178. .name = "intel-lpss",
  179. .acpi_match_table = intel_lpss_acpi_ids,
  180. .pm = &intel_lpss_acpi_pm_ops,
  181. },
  182. };
  183. module_platform_driver(intel_lpss_acpi_driver);
  184. MODULE_AUTHOR("Andy Shevchenko <[email protected]>");
  185. MODULE_AUTHOR("Mika Westerberg <[email protected]>");
  186. MODULE_DESCRIPTION("Intel LPSS ACPI driver");
  187. MODULE_LICENSE("GPL v2");