xref: /openbmc/linux/drivers/mfd/intel-lpss-acpi.c (revision 7ae5c03a)
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 
11 #include <linux/acpi.h>
12 #include <linux/ioport.h>
13 #include <linux/kernel.h>
14 #include <linux/module.h>
15 #include <linux/pm_runtime.h>
16 #include <linux/platform_device.h>
17 #include <linux/property.h>
18 #include <linux/pxa2xx_ssp.h>
19 
20 #include "intel-lpss.h"
21 
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 
31 static const struct intel_lpss_platform_info spt_info = {
32 	.clk_rate = 120000000,
33 	.swnode = &spt_spi_node,
34 };
35 
36 static const struct property_entry spt_i2c_properties[] = {
37 	PROPERTY_ENTRY_U32("i2c-sda-hold-time-ns", 230),
38 	{ },
39 };
40 
41 static const struct software_node spt_i2c_node = {
42 	.properties = spt_i2c_properties,
43 };
44 
45 static const struct intel_lpss_platform_info spt_i2c_info = {
46 	.clk_rate = 120000000,
47 	.swnode = &spt_i2c_node,
48 };
49 
50 static const struct property_entry uart_properties[] = {
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 
57 static const struct software_node uart_node = {
58 	.properties = uart_properties,
59 };
60 
61 static const struct intel_lpss_platform_info spt_uart_info = {
62 	.clk_rate = 120000000,
63 	.clk_con_id = "baudclk",
64 	.swnode = &uart_node,
65 };
66 
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 
76 static const struct intel_lpss_platform_info bxt_info = {
77 	.clk_rate = 100000000,
78 	.swnode = &bxt_spi_node,
79 };
80 
81 static const struct property_entry bxt_i2c_properties[] = {
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 
88 static const struct software_node bxt_i2c_node = {
89 	.properties = bxt_i2c_properties,
90 };
91 
92 static const struct intel_lpss_platform_info bxt_i2c_info = {
93 	.clk_rate = 133000000,
94 	.swnode = &bxt_i2c_node,
95 };
96 
97 static const struct property_entry apl_i2c_properties[] = {
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 
104 static const struct software_node apl_i2c_node = {
105 	.properties = apl_i2c_properties,
106 };
107 
108 static const struct intel_lpss_platform_info apl_i2c_info = {
109 	.clk_rate = 133000000,
110 	.swnode = &apl_i2c_node,
111 };
112 
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 
127 static const struct intel_lpss_platform_info cnl_i2c_info = {
128 	.clk_rate = 216000000,
129 	.swnode = &spt_i2c_node,
130 };
131 
132 static const struct acpi_device_id intel_lpss_acpi_ids[] = {
133 	/* SPT */
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 },
140 	{ "INT3446", (kernel_ulong_t)&spt_i2c_info },
141 	{ "INT3447", (kernel_ulong_t)&spt_i2c_info },
142 	{ "INT3448", (kernel_ulong_t)&spt_uart_info },
143 	{ "INT3449", (kernel_ulong_t)&spt_uart_info },
144 	{ "INT344A", (kernel_ulong_t)&spt_uart_info },
145 	/* CNL */
146 	{ "INT34B0", (kernel_ulong_t)&cnl_info },
147 	{ "INT34B1", (kernel_ulong_t)&cnl_info },
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 },
157 	{ "INT34BC", (kernel_ulong_t)&cnl_info },
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 */
163 	{ "80865AAC", (kernel_ulong_t)&apl_i2c_info },
164 	{ "80865ABC", (kernel_ulong_t)&bxt_info },
165 	{ "80865AC2", (kernel_ulong_t)&bxt_info },
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;
174 	int ret;
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 
188 	ret = intel_lpss_probe(&pdev->dev, info);
189 	if (ret)
190 		return ret;
191 
192 	pm_runtime_set_active(&pdev->dev);
193 	pm_runtime_enable(&pdev->dev);
194 
195 	return 0;
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");
224