Skip to content

Commit 2448d13

Browse files
committed
Merge branches 'acpi-soc' and 'acpi-tables'
* acpi-soc: ACPI: APD: Add AMD misc clock handler support clk: x86: Add ST oscout platform clock ACPI / LPSS: Only call pwm_add_table() for Bay Trail PWM if PMIC HRV is 2 * acpi-tables: ACPI / tables: improve comments regarding acpi_parse_entries_array()
3 parents 6c128e7 + 3f4ba94 + 904aaf8 commit 2448d13

File tree

6 files changed

+155
-4
lines changed

6 files changed

+155
-4
lines changed

drivers/acpi/acpi_apd.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*/
1212

1313
#include <linux/clk-provider.h>
14+
#include <linux/platform_data/clk-st.h>
1415
#include <linux/platform_device.h>
1516
#include <linux/pm_domain.h>
1617
#include <linux/clkdev.h>
@@ -72,6 +73,47 @@ static int acpi_apd_setup(struct apd_private_data *pdata)
7273
}
7374

7475
#ifdef CONFIG_X86_AMD_PLATFORM_DEVICE
76+
77+
static int misc_check_res(struct acpi_resource *ares, void *data)
78+
{
79+
struct resource res;
80+
81+
return !acpi_dev_resource_memory(ares, &res);
82+
}
83+
84+
static int st_misc_setup(struct apd_private_data *pdata)
85+
{
86+
struct acpi_device *adev = pdata->adev;
87+
struct platform_device *clkdev;
88+
struct st_clk_data *clk_data;
89+
struct resource_entry *rentry;
90+
struct list_head resource_list;
91+
int ret;
92+
93+
clk_data = devm_kzalloc(&adev->dev, sizeof(*clk_data), GFP_KERNEL);
94+
if (!clk_data)
95+
return -ENOMEM;
96+
97+
INIT_LIST_HEAD(&resource_list);
98+
ret = acpi_dev_get_resources(adev, &resource_list, misc_check_res,
99+
NULL);
100+
if (ret < 0)
101+
return -ENOENT;
102+
103+
list_for_each_entry(rentry, &resource_list, node) {
104+
clk_data->base = devm_ioremap(&adev->dev, rentry->res->start,
105+
resource_size(rentry->res));
106+
break;
107+
}
108+
109+
acpi_dev_free_resource_list(&resource_list);
110+
111+
clkdev = platform_device_register_data(&adev->dev, "clk-st",
112+
PLATFORM_DEVID_NONE, clk_data,
113+
sizeof(*clk_data));
114+
return PTR_ERR_OR_ZERO(clkdev);
115+
}
116+
75117
static const struct apd_device_desc cz_i2c_desc = {
76118
.setup = acpi_apd_setup,
77119
.fixed_clk_rate = 133000000,
@@ -94,6 +136,10 @@ static const struct apd_device_desc cz_uart_desc = {
94136
.fixed_clk_rate = 48000000,
95137
.properties = uart_properties,
96138
};
139+
140+
static const struct apd_device_desc st_misc_desc = {
141+
.setup = st_misc_setup,
142+
};
97143
#endif
98144

99145
#ifdef CONFIG_ARM64
@@ -179,6 +225,7 @@ static const struct acpi_device_id acpi_apd_device_ids[] = {
179225
{ "AMD0020", APD_ADDR(cz_uart_desc) },
180226
{ "AMDI0020", APD_ADDR(cz_uart_desc) },
181227
{ "AMD0030", },
228+
{ "AMD0040", APD_ADDR(st_misc_desc)},
182229
#endif
183230
#ifdef CONFIG_ARM64
184231
{ "APMC0D0F", APD_ADDR(xgene_i2c_desc) },

drivers/acpi/acpi_lpss.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ ACPI_MODULE_NAME("acpi_lpss");
6969
#define LPSS_SAVE_CTX BIT(4)
7070
#define LPSS_NO_D3_DELAY BIT(5)
7171

72+
/* Crystal Cove PMIC shares same ACPI ID between different platforms */
73+
#define BYT_CRC_HRV 2
74+
#define CHT_CRC_HRV 3
75+
7276
struct lpss_private_data;
7377

7478
struct lpss_device_desc {
@@ -162,7 +166,7 @@ static void byt_pwm_setup(struct lpss_private_data *pdata)
162166
if (!adev->pnp.unique_id || strcmp(adev->pnp.unique_id, "1"))
163167
return;
164168

165-
if (!acpi_dev_present("INT33FD", NULL, -1))
169+
if (!acpi_dev_present("INT33FD", NULL, BYT_CRC_HRV))
166170
pwm_add_table(byt_pwm_lookup, ARRAY_SIZE(byt_pwm_lookup));
167171
}
168172

drivers/acpi/tables.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
222222
* acpi_parse_entries_array - for each proc_num find a suitable subtable
223223
*
224224
* @id: table id (for debugging purposes)
225-
* @table_size: single entry size
225+
* @table_size: size of the root table
226226
* @table_header: where does the table start?
227227
* @proc: array of acpi_subtable_proc struct containing entry id
228228
* and associated handler with it
@@ -233,6 +233,11 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
233233
* on it. Assumption is that there's only single handler for particular
234234
* entry id.
235235
*
236+
* The table_size is not the size of the complete ACPI table (the length
237+
* field in the header struct), but only the size of the root table; i.e.,
238+
* the offset from the very first byte of the complete ACPI table, to the
239+
* first byte of the very first subtable.
240+
*
236241
* On success returns sum of all matching entries for all proc handlers.
237242
* Otherwise, -ENODEV or -EINVAL is returned.
238243
*/
@@ -400,7 +405,7 @@ int __init acpi_table_parse(char *id, acpi_tbl_table_handler handler)
400405
return -ENODEV;
401406
}
402407

403-
/*
408+
/*
404409
* The BIOS is supposed to supply a single APIC/MADT,
405410
* but some report two. Provide a knob to use either.
406411
* (don't you wish instance 0 and 1 were not the same?)

drivers/clk/x86/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
obj-$(CONFIG_PMC_ATOM) += clk-pmc-atom.o
2+
obj-$(CONFIG_X86_AMD_PLATFORM_DEVICE) += clk-st.o
13
clk-x86-lpss-objs := clk-lpt.o
24
obj-$(CONFIG_X86_INTEL_LPSS) += clk-x86-lpss.o
3-
obj-$(CONFIG_PMC_ATOM) += clk-pmc-atom.o

drivers/clk/x86/clk-st.c

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// SPDX-License-Identifier: MIT
2+
/*
3+
* clock framework for AMD Stoney based clocks
4+
*
5+
* Copyright 2018 Advanced Micro Devices, Inc.
6+
*/
7+
8+
#include <linux/clk.h>
9+
#include <linux/clkdev.h>
10+
#include <linux/clk-provider.h>
11+
#include <linux/platform_data/clk-st.h>
12+
#include <linux/platform_device.h>
13+
14+
/* Clock Driving Strength 2 register */
15+
#define CLKDRVSTR2 0x28
16+
/* Clock Control 1 register */
17+
#define MISCCLKCNTL1 0x40
18+
/* Auxiliary clock1 enable bit */
19+
#define OSCCLKENB 2
20+
/* 25Mhz auxiliary output clock freq bit */
21+
#define OSCOUT1CLK25MHZ 16
22+
23+
#define ST_CLK_48M 0
24+
#define ST_CLK_25M 1
25+
#define ST_CLK_MUX 2
26+
#define ST_CLK_GATE 3
27+
#define ST_MAX_CLKS 4
28+
29+
static const char * const clk_oscout1_parents[] = { "clk48MHz", "clk25MHz" };
30+
static struct clk_hw *hws[ST_MAX_CLKS];
31+
32+
static int st_clk_probe(struct platform_device *pdev)
33+
{
34+
struct st_clk_data *st_data;
35+
36+
st_data = dev_get_platdata(&pdev->dev);
37+
if (!st_data || !st_data->base)
38+
return -EINVAL;
39+
40+
hws[ST_CLK_48M] = clk_hw_register_fixed_rate(NULL, "clk48MHz", NULL, 0,
41+
48000000);
42+
hws[ST_CLK_25M] = clk_hw_register_fixed_rate(NULL, "clk25MHz", NULL, 0,
43+
25000000);
44+
45+
hws[ST_CLK_MUX] = clk_hw_register_mux(NULL, "oscout1_mux",
46+
clk_oscout1_parents, ARRAY_SIZE(clk_oscout1_parents),
47+
0, st_data->base + CLKDRVSTR2, OSCOUT1CLK25MHZ, 3, 0, NULL);
48+
49+
clk_set_parent(hws[ST_CLK_MUX]->clk, hws[ST_CLK_25M]->clk);
50+
51+
hws[ST_CLK_GATE] = clk_hw_register_gate(NULL, "oscout1", "oscout1_mux",
52+
0, st_data->base + MISCCLKCNTL1, OSCCLKENB,
53+
CLK_GATE_SET_TO_DISABLE, NULL);
54+
55+
clk_hw_register_clkdev(hws[ST_CLK_GATE], "oscout1", NULL);
56+
57+
return 0;
58+
}
59+
60+
static int st_clk_remove(struct platform_device *pdev)
61+
{
62+
int i;
63+
64+
for (i = 0; i < ST_MAX_CLKS; i++)
65+
clk_hw_unregister(hws[i]);
66+
return 0;
67+
}
68+
69+
static struct platform_driver st_clk_driver = {
70+
.driver = {
71+
.name = "clk-st",
72+
.suppress_bind_attrs = true,
73+
},
74+
.probe = st_clk_probe,
75+
.remove = st_clk_remove,
76+
};
77+
builtin_platform_driver(st_clk_driver);

include/linux/platform_data/clk-st.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* SPDX-License-Identifier: MIT */
2+
/*
3+
* clock framework for AMD Stoney based clock
4+
*
5+
* Copyright 2018 Advanced Micro Devices, Inc.
6+
*/
7+
8+
#ifndef __CLK_ST_H
9+
#define __CLK_ST_H
10+
11+
#include <linux/compiler.h>
12+
13+
struct st_clk_data {
14+
void __iomem *base;
15+
};
16+
17+
#endif /* __CLK_ST_H */

0 commit comments

Comments
 (0)