Thomas Gleixner | d2912cb | 2019-06-04 10:11:33 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Andy Shevchenko | 4b45efe | 2015-07-27 18:04:03 +0300 | [diff] [blame] | 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> |
Andy Shevchenko | 4b45efe | 2015-07-27 18:04:03 +0300 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #include <linux/acpi.h> |
| 12 | #include <linux/ioport.h> |
| 13 | #include <linux/kernel.h> |
| 14 | #include <linux/module.h> |
Andy Shevchenko | 4b45efe | 2015-07-27 18:04:03 +0300 | [diff] [blame] | 15 | #include <linux/pm_runtime.h> |
| 16 | #include <linux/platform_device.h> |
Mika Westerberg | 028af59 | 2015-11-30 17:11:42 +0200 | [diff] [blame] | 17 | #include <linux/property.h> |
Andy Shevchenko | 4b45efe | 2015-07-27 18:04:03 +0300 | [diff] [blame] | 18 | |
| 19 | #include "intel-lpss.h" |
| 20 | |
Andy Shevchenko | c5b90cb | 2019-08-16 20:56:02 +0300 | [diff] [blame] | 21 | static const struct intel_lpss_platform_info spt_info = { |
| 22 | .clk_rate = 120000000, |
| 23 | }; |
| 24 | |
Andy Shevchenko | 9677e6f | 2021-03-01 16:42:20 +0200 | [diff] [blame] | 25 | static const struct property_entry spt_i2c_properties[] = { |
Mika Westerberg | 028af59 | 2015-11-30 17:11:42 +0200 | [diff] [blame] | 26 | PROPERTY_ENTRY_U32("i2c-sda-hold-time-ns", 230), |
| 27 | { }, |
| 28 | }; |
| 29 | |
Heikki Krogerus | 03152e3 | 2021-03-01 16:42:21 +0200 | [diff] [blame] | 30 | static const struct software_node spt_i2c_node = { |
| 31 | .properties = spt_i2c_properties, |
| 32 | }; |
| 33 | |
Mika Westerberg | 028af59 | 2015-11-30 17:11:42 +0200 | [diff] [blame] | 34 | static const struct intel_lpss_platform_info spt_i2c_info = { |
| 35 | .clk_rate = 120000000, |
Heikki Krogerus | 03152e3 | 2021-03-01 16:42:21 +0200 | [diff] [blame] | 36 | .swnode = &spt_i2c_node, |
Mika Westerberg | 028af59 | 2015-11-30 17:11:42 +0200 | [diff] [blame] | 37 | }; |
| 38 | |
Andy Shevchenko | 9677e6f | 2021-03-01 16:42:20 +0200 | [diff] [blame] | 39 | static const struct property_entry uart_properties[] = { |
Andy Shevchenko | c5b90cb | 2019-08-16 20:56:02 +0300 | [diff] [blame] | 40 | PROPERTY_ENTRY_U32("reg-io-width", 4), |
| 41 | PROPERTY_ENTRY_U32("reg-shift", 2), |
| 42 | PROPERTY_ENTRY_BOOL("snps,uart-16550-compatible"), |
| 43 | { }, |
| 44 | }; |
| 45 | |
Heikki Krogerus | 03152e3 | 2021-03-01 16:42:21 +0200 | [diff] [blame] | 46 | static const struct software_node uart_node = { |
| 47 | .properties = uart_properties, |
| 48 | }; |
| 49 | |
Andy Shevchenko | c5b90cb | 2019-08-16 20:56:02 +0300 | [diff] [blame] | 50 | static const struct intel_lpss_platform_info spt_uart_info = { |
| 51 | .clk_rate = 120000000, |
| 52 | .clk_con_id = "baudclk", |
Heikki Krogerus | 03152e3 | 2021-03-01 16:42:21 +0200 | [diff] [blame] | 53 | .swnode = &uart_node, |
Andy Shevchenko | c5b90cb | 2019-08-16 20:56:02 +0300 | [diff] [blame] | 54 | }; |
| 55 | |
Mika Westerberg | 6a636ec | 2015-10-21 12:41:47 +0300 | [diff] [blame] | 56 | static const struct intel_lpss_platform_info bxt_info = { |
| 57 | .clk_rate = 100000000, |
| 58 | }; |
| 59 | |
Andy Shevchenko | 9677e6f | 2021-03-01 16:42:20 +0200 | [diff] [blame] | 60 | static const struct property_entry bxt_i2c_properties[] = { |
Mika Westerberg | 0343b2f | 2016-01-26 14:17:49 +0200 | [diff] [blame] | 61 | PROPERTY_ENTRY_U32("i2c-sda-hold-time-ns", 42), |
| 62 | PROPERTY_ENTRY_U32("i2c-sda-falling-time-ns", 171), |
| 63 | PROPERTY_ENTRY_U32("i2c-scl-falling-time-ns", 208), |
| 64 | { }, |
| 65 | }; |
| 66 | |
Heikki Krogerus | 03152e3 | 2021-03-01 16:42:21 +0200 | [diff] [blame] | 67 | static const struct software_node bxt_i2c_node = { |
| 68 | .properties = bxt_i2c_properties, |
| 69 | }; |
| 70 | |
Mika Westerberg | 6a636ec | 2015-10-21 12:41:47 +0300 | [diff] [blame] | 71 | static const struct intel_lpss_platform_info bxt_i2c_info = { |
| 72 | .clk_rate = 133000000, |
Heikki Krogerus | 03152e3 | 2021-03-01 16:42:21 +0200 | [diff] [blame] | 73 | .swnode = &bxt_i2c_node, |
Mika Westerberg | 6a636ec | 2015-10-21 12:41:47 +0300 | [diff] [blame] | 74 | }; |
| 75 | |
Andy Shevchenko | 9677e6f | 2021-03-01 16:42:20 +0200 | [diff] [blame] | 76 | static const struct property_entry apl_i2c_properties[] = { |
Jarkko Nikula | c50cdd6 | 2016-09-12 14:41:33 +0300 | [diff] [blame] | 77 | PROPERTY_ENTRY_U32("i2c-sda-hold-time-ns", 207), |
| 78 | PROPERTY_ENTRY_U32("i2c-sda-falling-time-ns", 171), |
| 79 | PROPERTY_ENTRY_U32("i2c-scl-falling-time-ns", 208), |
| 80 | { }, |
| 81 | }; |
| 82 | |
Heikki Krogerus | 03152e3 | 2021-03-01 16:42:21 +0200 | [diff] [blame] | 83 | static const struct software_node apl_i2c_node = { |
| 84 | .properties = apl_i2c_properties, |
| 85 | }; |
| 86 | |
Jarkko Nikula | c50cdd6 | 2016-09-12 14:41:33 +0300 | [diff] [blame] | 87 | static const struct intel_lpss_platform_info apl_i2c_info = { |
| 88 | .clk_rate = 133000000, |
Heikki Krogerus | 03152e3 | 2021-03-01 16:42:21 +0200 | [diff] [blame] | 89 | .swnode = &apl_i2c_node, |
Jarkko Nikula | c50cdd6 | 2016-09-12 14:41:33 +0300 | [diff] [blame] | 90 | }; |
| 91 | |
Andy Shevchenko | 32979fc | 2021-06-03 19:51:28 +0300 | [diff] [blame] | 92 | static const struct intel_lpss_platform_info cnl_i2c_info = { |
| 93 | .clk_rate = 216000000, |
| 94 | .swnode = &spt_i2c_node, |
| 95 | }; |
| 96 | |
Andy Shevchenko | 4b45efe | 2015-07-27 18:04:03 +0300 | [diff] [blame] | 97 | static const struct acpi_device_id intel_lpss_acpi_ids[] = { |
| 98 | /* SPT */ |
Andy Shevchenko | c5b90cb | 2019-08-16 20:56:02 +0300 | [diff] [blame] | 99 | { "INT3440", (kernel_ulong_t)&spt_info }, |
| 100 | { "INT3441", (kernel_ulong_t)&spt_info }, |
| 101 | { "INT3442", (kernel_ulong_t)&spt_i2c_info }, |
| 102 | { "INT3443", (kernel_ulong_t)&spt_i2c_info }, |
| 103 | { "INT3444", (kernel_ulong_t)&spt_i2c_info }, |
| 104 | { "INT3445", (kernel_ulong_t)&spt_i2c_info }, |
Mika Westerberg | 028af59 | 2015-11-30 17:11:42 +0200 | [diff] [blame] | 105 | { "INT3446", (kernel_ulong_t)&spt_i2c_info }, |
| 106 | { "INT3447", (kernel_ulong_t)&spt_i2c_info }, |
Andy Shevchenko | c5b90cb | 2019-08-16 20:56:02 +0300 | [diff] [blame] | 107 | { "INT3448", (kernel_ulong_t)&spt_uart_info }, |
| 108 | { "INT3449", (kernel_ulong_t)&spt_uart_info }, |
| 109 | { "INT344A", (kernel_ulong_t)&spt_uart_info }, |
Andy Shevchenko | 32979fc | 2021-06-03 19:51:28 +0300 | [diff] [blame] | 110 | /* CNL */ |
| 111 | { "INT34B0", (kernel_ulong_t)&spt_info }, |
| 112 | { "INT34B1", (kernel_ulong_t)&spt_info }, |
| 113 | { "INT34B2", (kernel_ulong_t)&cnl_i2c_info }, |
| 114 | { "INT34B3", (kernel_ulong_t)&cnl_i2c_info }, |
| 115 | { "INT34B4", (kernel_ulong_t)&cnl_i2c_info }, |
| 116 | { "INT34B5", (kernel_ulong_t)&cnl_i2c_info }, |
| 117 | { "INT34B6", (kernel_ulong_t)&cnl_i2c_info }, |
| 118 | { "INT34B7", (kernel_ulong_t)&cnl_i2c_info }, |
| 119 | { "INT34B8", (kernel_ulong_t)&spt_uart_info }, |
| 120 | { "INT34B9", (kernel_ulong_t)&spt_uart_info }, |
| 121 | { "INT34BA", (kernel_ulong_t)&spt_uart_info }, |
| 122 | { "INT34BC", (kernel_ulong_t)&spt_info }, |
Mika Westerberg | 6a636ec | 2015-10-21 12:41:47 +0300 | [diff] [blame] | 123 | /* BXT */ |
| 124 | { "80860AAC", (kernel_ulong_t)&bxt_i2c_info }, |
| 125 | { "80860ABC", (kernel_ulong_t)&bxt_info }, |
| 126 | { "80860AC2", (kernel_ulong_t)&bxt_info }, |
| 127 | /* APL */ |
Jarkko Nikula | c50cdd6 | 2016-09-12 14:41:33 +0300 | [diff] [blame] | 128 | { "80865AAC", (kernel_ulong_t)&apl_i2c_info }, |
Mika Westerberg | 6a636ec | 2015-10-21 12:41:47 +0300 | [diff] [blame] | 129 | { "80865ABC", (kernel_ulong_t)&bxt_info }, |
| 130 | { "80865AC2", (kernel_ulong_t)&bxt_info }, |
Andy Shevchenko | 4b45efe | 2015-07-27 18:04:03 +0300 | [diff] [blame] | 131 | { } |
| 132 | }; |
| 133 | MODULE_DEVICE_TABLE(acpi, intel_lpss_acpi_ids); |
| 134 | |
| 135 | static int intel_lpss_acpi_probe(struct platform_device *pdev) |
| 136 | { |
| 137 | struct intel_lpss_platform_info *info; |
| 138 | const struct acpi_device_id *id; |
Andy Shevchenko | c9e1430 | 2021-11-01 21:00:08 +0200 | [diff] [blame] | 139 | int ret; |
Andy Shevchenko | 4b45efe | 2015-07-27 18:04:03 +0300 | [diff] [blame] | 140 | |
| 141 | id = acpi_match_device(intel_lpss_acpi_ids, &pdev->dev); |
| 142 | if (!id) |
| 143 | return -ENODEV; |
| 144 | |
| 145 | info = devm_kmemdup(&pdev->dev, (void *)id->driver_data, sizeof(*info), |
| 146 | GFP_KERNEL); |
| 147 | if (!info) |
| 148 | return -ENOMEM; |
| 149 | |
| 150 | info->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 151 | info->irq = platform_get_irq(pdev, 0); |
| 152 | |
Andy Shevchenko | c9e1430 | 2021-11-01 21:00:08 +0200 | [diff] [blame] | 153 | ret = intel_lpss_probe(&pdev->dev, info); |
| 154 | if (ret) |
| 155 | return ret; |
| 156 | |
Andy Shevchenko | 4b45efe | 2015-07-27 18:04:03 +0300 | [diff] [blame] | 157 | pm_runtime_set_active(&pdev->dev); |
| 158 | pm_runtime_enable(&pdev->dev); |
| 159 | |
Andy Shevchenko | c9e1430 | 2021-11-01 21:00:08 +0200 | [diff] [blame] | 160 | return 0; |
Andy Shevchenko | 4b45efe | 2015-07-27 18:04:03 +0300 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | static int intel_lpss_acpi_remove(struct platform_device *pdev) |
| 164 | { |
| 165 | intel_lpss_remove(&pdev->dev); |
| 166 | pm_runtime_disable(&pdev->dev); |
| 167 | |
| 168 | return 0; |
| 169 | } |
| 170 | |
| 171 | static INTEL_LPSS_PM_OPS(intel_lpss_acpi_pm_ops); |
| 172 | |
| 173 | static struct platform_driver intel_lpss_acpi_driver = { |
| 174 | .probe = intel_lpss_acpi_probe, |
| 175 | .remove = intel_lpss_acpi_remove, |
| 176 | .driver = { |
| 177 | .name = "intel-lpss", |
| 178 | .acpi_match_table = intel_lpss_acpi_ids, |
| 179 | .pm = &intel_lpss_acpi_pm_ops, |
| 180 | }, |
| 181 | }; |
| 182 | |
| 183 | module_platform_driver(intel_lpss_acpi_driver); |
| 184 | |
| 185 | MODULE_AUTHOR("Andy Shevchenko <andriy.shevchenko@linux.intel.com>"); |
| 186 | MODULE_AUTHOR("Mika Westerberg <mika.westerberg@linux.intel.com>"); |
| 187 | MODULE_DESCRIPTION("Intel LPSS ACPI driver"); |
| 188 | MODULE_LICENSE("GPL v2"); |