Commit | Line | Data |
---|---|---|
d2912cb1 | 1 | // SPDX-License-Identifier: GPL-2.0-only |
4b45efe8 AS |
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> | |
4b45efe8 AS |
9 | */ |
10 | ||
11 | #include <linux/acpi.h> | |
12 | #include <linux/ioport.h> | |
13 | #include <linux/kernel.h> | |
14 | #include <linux/module.h> | |
4b45efe8 AS |
15 | #include <linux/pm_runtime.h> |
16 | #include <linux/platform_device.h> | |
028af594 | 17 | #include <linux/property.h> |
5a2d27c2 | 18 | #include <linux/pxa2xx_ssp.h> |
4b45efe8 AS |
19 | |
20 | #include "intel-lpss.h" | |
21 | ||
5a2d27c2 AS |
22 | static const struct property_entry spt_spi_properties[] = { |
23 | PROPERTY_ENTRY_U32("intel,spi-pxa2xx-type", LPSS_SPT_SSP), | |
24 | { } | |
25 | }; | |
26 | ||
27 | static const struct software_node spt_spi_node = { | |
28 | .properties = spt_spi_properties, | |
29 | }; | |
30 | ||
c5b90cb2 AS |
31 | static const struct intel_lpss_platform_info spt_info = { |
32 | .clk_rate = 120000000, | |
5a2d27c2 | 33 | .swnode = &spt_spi_node, |
c5b90cb2 AS |
34 | }; |
35 | ||
9677e6f7 | 36 | static const struct property_entry spt_i2c_properties[] = { |
028af594 MW |
37 | PROPERTY_ENTRY_U32("i2c-sda-hold-time-ns", 230), |
38 | { }, | |
39 | }; | |
40 | ||
03152e35 HK |
41 | static const struct software_node spt_i2c_node = { |
42 | .properties = spt_i2c_properties, | |
43 | }; | |
44 | ||
028af594 MW |
45 | static const struct intel_lpss_platform_info spt_i2c_info = { |
46 | .clk_rate = 120000000, | |
03152e35 | 47 | .swnode = &spt_i2c_node, |
028af594 MW |
48 | }; |
49 | ||
9677e6f7 | 50 | static const struct property_entry uart_properties[] = { |
c5b90cb2 AS |
51 | PROPERTY_ENTRY_U32("reg-io-width", 4), |
52 | PROPERTY_ENTRY_U32("reg-shift", 2), | |
53 | PROPERTY_ENTRY_BOOL("snps,uart-16550-compatible"), | |
54 | { }, | |
55 | }; | |
56 | ||
03152e35 HK |
57 | static const struct software_node uart_node = { |
58 | .properties = uart_properties, | |
59 | }; | |
60 | ||
c5b90cb2 AS |
61 | static const struct intel_lpss_platform_info spt_uart_info = { |
62 | .clk_rate = 120000000, | |
63 | .clk_con_id = "baudclk", | |
03152e35 | 64 | .swnode = &uart_node, |
c5b90cb2 AS |
65 | }; |
66 | ||
5a2d27c2 AS |
67 | static const struct property_entry bxt_spi_properties[] = { |
68 | PROPERTY_ENTRY_U32("intel,spi-pxa2xx-type", LPSS_BXT_SSP), | |
69 | { } | |
70 | }; | |
71 | ||
72 | static const struct software_node bxt_spi_node = { | |
73 | .properties = bxt_spi_properties, | |
74 | }; | |
75 | ||
6a636ec0 MW |
76 | static const struct intel_lpss_platform_info bxt_info = { |
77 | .clk_rate = 100000000, | |
5a2d27c2 | 78 | .swnode = &bxt_spi_node, |
6a636ec0 MW |
79 | }; |
80 | ||
9677e6f7 | 81 | static const struct property_entry bxt_i2c_properties[] = { |
0343b2f4 MW |
82 | PROPERTY_ENTRY_U32("i2c-sda-hold-time-ns", 42), |
83 | PROPERTY_ENTRY_U32("i2c-sda-falling-time-ns", 171), | |
84 | PROPERTY_ENTRY_U32("i2c-scl-falling-time-ns", 208), | |
85 | { }, | |
86 | }; | |
87 | ||
03152e35 HK |
88 | static const struct software_node bxt_i2c_node = { |
89 | .properties = bxt_i2c_properties, | |
90 | }; | |
91 | ||
6a636ec0 MW |
92 | static const struct intel_lpss_platform_info bxt_i2c_info = { |
93 | .clk_rate = 133000000, | |
03152e35 | 94 | .swnode = &bxt_i2c_node, |
6a636ec0 MW |
95 | }; |
96 | ||
9677e6f7 | 97 | static const struct property_entry apl_i2c_properties[] = { |
c50cdd62 JN |
98 | PROPERTY_ENTRY_U32("i2c-sda-hold-time-ns", 207), |
99 | PROPERTY_ENTRY_U32("i2c-sda-falling-time-ns", 171), | |
100 | PROPERTY_ENTRY_U32("i2c-scl-falling-time-ns", 208), | |
101 | { }, | |
102 | }; | |
103 | ||
03152e35 HK |
104 | static const struct software_node apl_i2c_node = { |
105 | .properties = apl_i2c_properties, | |
106 | }; | |
107 | ||
c50cdd62 JN |
108 | static const struct intel_lpss_platform_info apl_i2c_info = { |
109 | .clk_rate = 133000000, | |
03152e35 | 110 | .swnode = &apl_i2c_node, |
c50cdd62 JN |
111 | }; |
112 | ||
5a2d27c2 AS |
113 | static const struct property_entry cnl_spi_properties[] = { |
114 | PROPERTY_ENTRY_U32("intel,spi-pxa2xx-type", LPSS_CNL_SSP), | |
115 | { } | |
116 | }; | |
117 | ||
118 | static const struct software_node cnl_spi_node = { | |
119 | .properties = cnl_spi_properties, | |
120 | }; | |
121 | ||
122 | static const struct intel_lpss_platform_info cnl_info = { | |
123 | .clk_rate = 120000000, | |
124 | .swnode = &cnl_spi_node, | |
125 | }; | |
126 | ||
32979fcf AS |
127 | static const struct intel_lpss_platform_info cnl_i2c_info = { |
128 | .clk_rate = 216000000, | |
129 | .swnode = &spt_i2c_node, | |
130 | }; | |
131 | ||
4b45efe8 AS |
132 | static const struct acpi_device_id intel_lpss_acpi_ids[] = { |
133 | /* SPT */ | |
c5b90cb2 AS |
134 | { "INT3440", (kernel_ulong_t)&spt_info }, |
135 | { "INT3441", (kernel_ulong_t)&spt_info }, | |
136 | { "INT3442", (kernel_ulong_t)&spt_i2c_info }, | |
137 | { "INT3443", (kernel_ulong_t)&spt_i2c_info }, | |
138 | { "INT3444", (kernel_ulong_t)&spt_i2c_info }, | |
139 | { "INT3445", (kernel_ulong_t)&spt_i2c_info }, | |
028af594 MW |
140 | { "INT3446", (kernel_ulong_t)&spt_i2c_info }, |
141 | { "INT3447", (kernel_ulong_t)&spt_i2c_info }, | |
c5b90cb2 AS |
142 | { "INT3448", (kernel_ulong_t)&spt_uart_info }, |
143 | { "INT3449", (kernel_ulong_t)&spt_uart_info }, | |
144 | { "INT344A", (kernel_ulong_t)&spt_uart_info }, | |
32979fcf | 145 | /* CNL */ |
5a2d27c2 AS |
146 | { "INT34B0", (kernel_ulong_t)&cnl_info }, |
147 | { "INT34B1", (kernel_ulong_t)&cnl_info }, | |
32979fcf AS |
148 | { "INT34B2", (kernel_ulong_t)&cnl_i2c_info }, |
149 | { "INT34B3", (kernel_ulong_t)&cnl_i2c_info }, | |
150 | { "INT34B4", (kernel_ulong_t)&cnl_i2c_info }, | |
151 | { "INT34B5", (kernel_ulong_t)&cnl_i2c_info }, | |
152 | { "INT34B6", (kernel_ulong_t)&cnl_i2c_info }, | |
153 | { "INT34B7", (kernel_ulong_t)&cnl_i2c_info }, | |
154 | { "INT34B8", (kernel_ulong_t)&spt_uart_info }, | |
155 | { "INT34B9", (kernel_ulong_t)&spt_uart_info }, | |
156 | { "INT34BA", (kernel_ulong_t)&spt_uart_info }, | |
5a2d27c2 | 157 | { "INT34BC", (kernel_ulong_t)&cnl_info }, |
6a636ec0 MW |
158 | /* BXT */ |
159 | { "80860AAC", (kernel_ulong_t)&bxt_i2c_info }, | |
160 | { "80860ABC", (kernel_ulong_t)&bxt_info }, | |
161 | { "80860AC2", (kernel_ulong_t)&bxt_info }, | |
162 | /* APL */ | |
c50cdd62 | 163 | { "80865AAC", (kernel_ulong_t)&apl_i2c_info }, |
6a636ec0 MW |
164 | { "80865ABC", (kernel_ulong_t)&bxt_info }, |
165 | { "80865AC2", (kernel_ulong_t)&bxt_info }, | |
4b45efe8 AS |
166 | { } |
167 | }; | |
168 | MODULE_DEVICE_TABLE(acpi, intel_lpss_acpi_ids); | |
169 | ||
170 | static int intel_lpss_acpi_probe(struct platform_device *pdev) | |
171 | { | |
172 | struct intel_lpss_platform_info *info; | |
173 | const struct acpi_device_id *id; | |
c9e14308 | 174 | int ret; |
4b45efe8 AS |
175 | |
176 | id = acpi_match_device(intel_lpss_acpi_ids, &pdev->dev); | |
177 | if (!id) | |
178 | return -ENODEV; | |
179 | ||
180 | info = devm_kmemdup(&pdev->dev, (void *)id->driver_data, sizeof(*info), | |
181 | GFP_KERNEL); | |
182 | if (!info) | |
183 | return -ENOMEM; | |
184 | ||
185 | info->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | |
186 | info->irq = platform_get_irq(pdev, 0); | |
187 | ||
c9e14308 AS |
188 | ret = intel_lpss_probe(&pdev->dev, info); |
189 | if (ret) | |
190 | return ret; | |
191 | ||
4b45efe8 AS |
192 | pm_runtime_set_active(&pdev->dev); |
193 | pm_runtime_enable(&pdev->dev); | |
194 | ||
c9e14308 | 195 | return 0; |
4b45efe8 AS |
196 | } |
197 | ||
198 | static int intel_lpss_acpi_remove(struct platform_device *pdev) | |
199 | { | |
200 | intel_lpss_remove(&pdev->dev); | |
201 | pm_runtime_disable(&pdev->dev); | |
202 | ||
203 | return 0; | |
204 | } | |
205 | ||
206 | static INTEL_LPSS_PM_OPS(intel_lpss_acpi_pm_ops); | |
207 | ||
208 | static struct platform_driver intel_lpss_acpi_driver = { | |
209 | .probe = intel_lpss_acpi_probe, | |
210 | .remove = intel_lpss_acpi_remove, | |
211 | .driver = { | |
212 | .name = "intel-lpss", | |
213 | .acpi_match_table = intel_lpss_acpi_ids, | |
214 | .pm = &intel_lpss_acpi_pm_ops, | |
215 | }, | |
216 | }; | |
217 | ||
218 | module_platform_driver(intel_lpss_acpi_driver); | |
219 | ||
220 | MODULE_AUTHOR("Andy Shevchenko <andriy.shevchenko@linux.intel.com>"); | |
221 | MODULE_AUTHOR("Mika Westerberg <mika.westerberg@linux.intel.com>"); | |
222 | MODULE_DESCRIPTION("Intel LPSS ACPI driver"); | |
223 | MODULE_LICENSE("GPL v2"); |