aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAkshu Agrawal <Akshu.Agrawal@amd.com>2018-05-09 05:59:01 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2018-05-17 06:44:06 -0400
commit3f4ba94e3615fe6f8a82e3a5f30677347d15130f (patch)
tree3ce10f71521bae572f3143d4f4538aed338c40ef
parent421bf6a1f061a6edba47e5e7a5458f29eb791de9 (diff)
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 <akshu.agrawal@amd.com> Reviewed-by: Daniel Kurtz <djkurtz@chromium.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/acpi/acpi_apd.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/drivers/acpi/acpi_apd.c b/drivers/acpi/acpi_apd.c
index d553b0087947..2664452fa112 100644
--- a/drivers/acpi/acpi_apd.c
+++ b/drivers/acpi/acpi_apd.c
@@ -11,6 +11,7 @@
11 */ 11 */
12 12
13#include <linux/clk-provider.h> 13#include <linux/clk-provider.h>
14#include <linux/platform_data/clk-st.h>
14#include <linux/platform_device.h> 15#include <linux/platform_device.h>
15#include <linux/pm_domain.h> 16#include <linux/pm_domain.h>
16#include <linux/clkdev.h> 17#include <linux/clkdev.h>
@@ -72,6 +73,47 @@ static int acpi_apd_setup(struct apd_private_data *pdata)
72} 73}
73 74
74#ifdef CONFIG_X86_AMD_PLATFORM_DEVICE 75#ifdef CONFIG_X86_AMD_PLATFORM_DEVICE
76
77static 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
84static 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
75static const struct apd_device_desc cz_i2c_desc = { 117static const struct apd_device_desc cz_i2c_desc = {
76 .setup = acpi_apd_setup, 118 .setup = acpi_apd_setup,
77 .fixed_clk_rate = 133000000, 119 .fixed_clk_rate = 133000000,
@@ -94,6 +136,10 @@ static const struct apd_device_desc cz_uart_desc = {
94 .fixed_clk_rate = 48000000, 136 .fixed_clk_rate = 48000000,
95 .properties = uart_properties, 137 .properties = uart_properties,
96}; 138};
139
140static const struct apd_device_desc st_misc_desc = {
141 .setup = st_misc_setup,
142};
97#endif 143#endif
98 144
99#ifdef CONFIG_ARM64 145#ifdef CONFIG_ARM64
@@ -179,6 +225,7 @@ static const struct acpi_device_id acpi_apd_device_ids[] = {
179 { "AMD0020", APD_ADDR(cz_uart_desc) }, 225 { "AMD0020", APD_ADDR(cz_uart_desc) },
180 { "AMDI0020", APD_ADDR(cz_uart_desc) }, 226 { "AMDI0020", APD_ADDR(cz_uart_desc) },
181 { "AMD0030", }, 227 { "AMD0030", },
228 { "AMD0040", APD_ADDR(st_misc_desc)},
182#endif 229#endif
183#ifdef CONFIG_ARM64 230#ifdef CONFIG_ARM64
184 { "APMC0D0F", APD_ADDR(xgene_i2c_desc) }, 231 { "APMC0D0F", APD_ADDR(xgene_i2c_desc) },