hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/drivers/acpi/acpi_apd.c
....@@ -1,47 +1,34 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * AMD ACPI support for ACPI2platform device.
34 *
45 * Copyright (c) 2014,2015 AMD Corporation.
56 * Authors: Ken Xue <Ken.Xue@amd.com>
67 * Wu, Jeff <Jeff.Wu@amd.com>
7
- *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License version 2 as
10
- * published by the Free Software Foundation.
118 */
129
13
-#include <linux/clk-provider.h>
14
-#include <linux/platform_data/clk-st.h>
15
-#include <linux/platform_device.h>
16
-#include <linux/pm_domain.h>
17
-#include <linux/clkdev.h>
1810 #include <linux/acpi.h>
11
+#include <linux/clkdev.h>
12
+#include <linux/clk-provider.h>
1913 #include <linux/err.h>
20
-#include <linux/pm.h>
14
+#include <linux/io.h>
15
+#include <linux/platform_data/clk-fch.h>
16
+#include <linux/platform_device.h>
2117
2218 #include "internal.h"
2319
24
-ACPI_MODULE_NAME("acpi_apd");
2520 struct apd_private_data;
2621
2722 /**
28
- * ACPI_APD_SYSFS : add device attributes in sysfs
29
- * ACPI_APD_PM : attach power domain to device
30
- */
31
-#define ACPI_APD_SYSFS BIT(0)
32
-#define ACPI_APD_PM BIT(1)
33
-
34
-/**
3523 * struct apd_device_desc - a descriptor for apd device
36
- * @flags: device flags like %ACPI_APD_SYSFS, %ACPI_APD_PM
3724 * @fixed_clk_rate: fixed rate input clock source for acpi device;
3825 * 0 means no fixed rate input clock source
26
+ * @properties: build-in properties of the device such as UART
3927 * @setup: a hook routine to set device resource during create platform device
4028 *
4129 * Device description defined as acpi_device_id.driver_data
4230 */
4331 struct apd_device_desc {
44
- unsigned int flags;
4532 unsigned int fixed_clk_rate;
4633 struct property_entry *properties;
4734 int (*setup)(struct apd_private_data *pdata);
....@@ -59,7 +46,7 @@
5946 static int acpi_apd_setup(struct apd_private_data *pdata)
6047 {
6148 const struct apd_device_desc *dev_desc = pdata->dev_desc;
62
- struct clk *clk = ERR_PTR(-ENODEV);
49
+ struct clk *clk;
6350
6451 if (dev_desc->fixed_clk_rate) {
6552 clk = clk_register_fixed_rate(&pdata->adev->dev,
....@@ -73,7 +60,6 @@
7360 }
7461
7562 #ifdef CONFIG_X86_AMD_PLATFORM_DEVICE
76
-
7763 static int misc_check_res(struct acpi_resource *ares, void *data)
7864 {
7965 struct resource res;
....@@ -81,11 +67,12 @@
8167 return !acpi_dev_resource_memory(ares, &res);
8268 }
8369
84
-static int st_misc_setup(struct apd_private_data *pdata)
70
+static int fch_misc_setup(struct apd_private_data *pdata)
8571 {
8672 struct acpi_device *adev = pdata->adev;
73
+ const union acpi_object *obj;
8774 struct platform_device *clkdev;
88
- struct st_clk_data *clk_data;
75
+ struct fch_clk_data *clk_data;
8976 struct resource_entry *rentry;
9077 struct list_head resource_list;
9178 int ret;
....@@ -100,6 +87,9 @@
10087 if (ret < 0)
10188 return -ENOENT;
10289
90
+ if (!acpi_dev_get_property(adev, "is-rv", ACPI_TYPE_INTEGER, &obj))
91
+ clk_data->is_rv = obj->integer.value;
92
+
10393 list_for_each_entry(rentry, &resource_list, node) {
10494 clk_data->base = devm_ioremap(&adev->dev, rentry->res->start,
10595 resource_size(rentry->res));
....@@ -108,7 +98,7 @@
10898
10999 acpi_dev_free_resource_list(&resource_list);
110100
111
- clkdev = platform_device_register_data(&adev->dev, "clk-st",
101
+ clkdev = platform_device_register_data(&adev->dev, "clk-fch",
112102 PLATFORM_DEVID_NONE, clk_data,
113103 sizeof(*clk_data));
114104 return PTR_ERR_OR_ZERO(clkdev);
....@@ -137,10 +127,10 @@
137127 .properties = uart_properties,
138128 };
139129
140
-static const struct apd_device_desc st_misc_desc = {
141
- .setup = st_misc_setup,
130
+static const struct apd_device_desc fch_misc_desc = {
131
+ .setup = fch_misc_setup,
142132 };
143
-#endif
133
+#endif /* CONFIG_X86_AMD_PLATFORM_DEVICE */
144134
145135 #ifdef CONFIG_ARM64
146136 static const struct apd_device_desc xgene_i2c_desc = {
....@@ -162,17 +152,29 @@
162152 .setup = acpi_apd_setup,
163153 .fixed_clk_rate = 250000000,
164154 };
155
+
156
+static const struct apd_device_desc hip08_lite_i2c_desc = {
157
+ .setup = acpi_apd_setup,
158
+ .fixed_clk_rate = 125000000,
159
+};
160
+
165161 static const struct apd_device_desc thunderx2_i2c_desc = {
166162 .setup = acpi_apd_setup,
167163 .fixed_clk_rate = 125000000,
168164 };
165
+
166
+static const struct apd_device_desc nxp_i2c_desc = {
167
+ .setup = acpi_apd_setup,
168
+ .fixed_clk_rate = 350000000,
169
+};
170
+
171
+static const struct apd_device_desc hip08_spi_desc = {
172
+ .setup = acpi_apd_setup,
173
+ .fixed_clk_rate = 250000000,
174
+};
175
+#endif /* CONFIG_ARM64 */
176
+
169177 #endif
170
-
171
-#else
172
-
173
-#define APD_ADDR(desc) (0UL)
174
-
175
-#endif /* CONFIG_X86_AMD_PLATFORM_DEVICE */
176178
177179 /**
178180 * Create platform device during acpi scan attach handle.
....@@ -224,8 +226,10 @@
224226 { "AMDI0010", APD_ADDR(wt_i2c_desc) },
225227 { "AMD0020", APD_ADDR(cz_uart_desc) },
226228 { "AMDI0020", APD_ADDR(cz_uart_desc) },
229
+ { "AMDI0022", APD_ADDR(cz_uart_desc) },
227230 { "AMD0030", },
228
- { "AMD0040", APD_ADDR(st_misc_desc)},
231
+ { "AMD0040", APD_ADDR(fch_misc_desc)},
232
+ { "HYGO0010", APD_ADDR(wt_i2c_desc) },
229233 #endif
230234 #ifdef CONFIG_ARM64
231235 { "APMC0D0F", APD_ADDR(xgene_i2c_desc) },
....@@ -234,6 +238,9 @@
234238 { "CAV9007", APD_ADDR(thunderx2_i2c_desc) },
235239 { "HISI02A1", APD_ADDR(hip07_i2c_desc) },
236240 { "HISI02A2", APD_ADDR(hip08_i2c_desc) },
241
+ { "HISI02A3", APD_ADDR(hip08_lite_i2c_desc) },
242
+ { "HISI0173", APD_ADDR(hip08_spi_desc) },
243
+ { "NXP0001", APD_ADDR(nxp_i2c_desc) },
237244 #endif
238245 { }
239246 };