Skip to content

Commit 3f4ba94

Browse files
Akshu Agrawalrafaeljw
authored andcommitted
ACPI: APD: Add AMD misc clock handler support
AMD SoC exposes clock for general purpose use. The clock registration is done in clk-st driver. The MMIO mapping are passed on to the clock driver for accessing the registers. The misc clock handler will create MMIO mappings to access the clock registers and enable the clock driver to expose the clock for use of drivers which will connect to it. Signed-off-by: Akshu Agrawal <[email protected]> Reviewed-by: Daniel Kurtz <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 421bf6a commit 3f4ba94

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
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) },

0 commit comments

Comments
 (0)