| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * AMD ACPI support for ACPI2platform device. |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (c) 2014,2015 AMD Corporation. |
|---|
| 5 | 6 | * Authors: Ken Xue <Ken.Xue@amd.com> |
|---|
| 6 | 7 | * 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. |
|---|
| 11 | 8 | */ |
|---|
| 12 | 9 | |
|---|
| 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> |
|---|
| 18 | 10 | #include <linux/acpi.h> |
|---|
| 11 | +#include <linux/clkdev.h> |
|---|
| 12 | +#include <linux/clk-provider.h> |
|---|
| 19 | 13 | #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> |
|---|
| 21 | 17 | |
|---|
| 22 | 18 | #include "internal.h" |
|---|
| 23 | 19 | |
|---|
| 24 | | -ACPI_MODULE_NAME("acpi_apd"); |
|---|
| 25 | 20 | struct apd_private_data; |
|---|
| 26 | 21 | |
|---|
| 27 | 22 | /** |
|---|
| 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 | | -/** |
|---|
| 35 | 23 | * struct apd_device_desc - a descriptor for apd device |
|---|
| 36 | | - * @flags: device flags like %ACPI_APD_SYSFS, %ACPI_APD_PM |
|---|
| 37 | 24 | * @fixed_clk_rate: fixed rate input clock source for acpi device; |
|---|
| 38 | 25 | * 0 means no fixed rate input clock source |
|---|
| 26 | + * @properties: build-in properties of the device such as UART |
|---|
| 39 | 27 | * @setup: a hook routine to set device resource during create platform device |
|---|
| 40 | 28 | * |
|---|
| 41 | 29 | * Device description defined as acpi_device_id.driver_data |
|---|
| 42 | 30 | */ |
|---|
| 43 | 31 | struct apd_device_desc { |
|---|
| 44 | | - unsigned int flags; |
|---|
| 45 | 32 | unsigned int fixed_clk_rate; |
|---|
| 46 | 33 | struct property_entry *properties; |
|---|
| 47 | 34 | int (*setup)(struct apd_private_data *pdata); |
|---|
| .. | .. |
|---|
| 59 | 46 | static int acpi_apd_setup(struct apd_private_data *pdata) |
|---|
| 60 | 47 | { |
|---|
| 61 | 48 | const struct apd_device_desc *dev_desc = pdata->dev_desc; |
|---|
| 62 | | - struct clk *clk = ERR_PTR(-ENODEV); |
|---|
| 49 | + struct clk *clk; |
|---|
| 63 | 50 | |
|---|
| 64 | 51 | if (dev_desc->fixed_clk_rate) { |
|---|
| 65 | 52 | clk = clk_register_fixed_rate(&pdata->adev->dev, |
|---|
| .. | .. |
|---|
| 73 | 60 | } |
|---|
| 74 | 61 | |
|---|
| 75 | 62 | #ifdef CONFIG_X86_AMD_PLATFORM_DEVICE |
|---|
| 76 | | - |
|---|
| 77 | 63 | static int misc_check_res(struct acpi_resource *ares, void *data) |
|---|
| 78 | 64 | { |
|---|
| 79 | 65 | struct resource res; |
|---|
| .. | .. |
|---|
| 81 | 67 | return !acpi_dev_resource_memory(ares, &res); |
|---|
| 82 | 68 | } |
|---|
| 83 | 69 | |
|---|
| 84 | | -static int st_misc_setup(struct apd_private_data *pdata) |
|---|
| 70 | +static int fch_misc_setup(struct apd_private_data *pdata) |
|---|
| 85 | 71 | { |
|---|
| 86 | 72 | struct acpi_device *adev = pdata->adev; |
|---|
| 73 | + const union acpi_object *obj; |
|---|
| 87 | 74 | struct platform_device *clkdev; |
|---|
| 88 | | - struct st_clk_data *clk_data; |
|---|
| 75 | + struct fch_clk_data *clk_data; |
|---|
| 89 | 76 | struct resource_entry *rentry; |
|---|
| 90 | 77 | struct list_head resource_list; |
|---|
| 91 | 78 | int ret; |
|---|
| .. | .. |
|---|
| 100 | 87 | if (ret < 0) |
|---|
| 101 | 88 | return -ENOENT; |
|---|
| 102 | 89 | |
|---|
| 90 | + if (!acpi_dev_get_property(adev, "is-rv", ACPI_TYPE_INTEGER, &obj)) |
|---|
| 91 | + clk_data->is_rv = obj->integer.value; |
|---|
| 92 | + |
|---|
| 103 | 93 | list_for_each_entry(rentry, &resource_list, node) { |
|---|
| 104 | 94 | clk_data->base = devm_ioremap(&adev->dev, rentry->res->start, |
|---|
| 105 | 95 | resource_size(rentry->res)); |
|---|
| .. | .. |
|---|
| 108 | 98 | |
|---|
| 109 | 99 | acpi_dev_free_resource_list(&resource_list); |
|---|
| 110 | 100 | |
|---|
| 111 | | - clkdev = platform_device_register_data(&adev->dev, "clk-st", |
|---|
| 101 | + clkdev = platform_device_register_data(&adev->dev, "clk-fch", |
|---|
| 112 | 102 | PLATFORM_DEVID_NONE, clk_data, |
|---|
| 113 | 103 | sizeof(*clk_data)); |
|---|
| 114 | 104 | return PTR_ERR_OR_ZERO(clkdev); |
|---|
| .. | .. |
|---|
| 137 | 127 | .properties = uart_properties, |
|---|
| 138 | 128 | }; |
|---|
| 139 | 129 | |
|---|
| 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, |
|---|
| 142 | 132 | }; |
|---|
| 143 | | -#endif |
|---|
| 133 | +#endif /* CONFIG_X86_AMD_PLATFORM_DEVICE */ |
|---|
| 144 | 134 | |
|---|
| 145 | 135 | #ifdef CONFIG_ARM64 |
|---|
| 146 | 136 | static const struct apd_device_desc xgene_i2c_desc = { |
|---|
| .. | .. |
|---|
| 162 | 152 | .setup = acpi_apd_setup, |
|---|
| 163 | 153 | .fixed_clk_rate = 250000000, |
|---|
| 164 | 154 | }; |
|---|
| 155 | + |
|---|
| 156 | +static const struct apd_device_desc hip08_lite_i2c_desc = { |
|---|
| 157 | + .setup = acpi_apd_setup, |
|---|
| 158 | + .fixed_clk_rate = 125000000, |
|---|
| 159 | +}; |
|---|
| 160 | + |
|---|
| 165 | 161 | static const struct apd_device_desc thunderx2_i2c_desc = { |
|---|
| 166 | 162 | .setup = acpi_apd_setup, |
|---|
| 167 | 163 | .fixed_clk_rate = 125000000, |
|---|
| 168 | 164 | }; |
|---|
| 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 | + |
|---|
| 169 | 177 | #endif |
|---|
| 170 | | - |
|---|
| 171 | | -#else |
|---|
| 172 | | - |
|---|
| 173 | | -#define APD_ADDR(desc) (0UL) |
|---|
| 174 | | - |
|---|
| 175 | | -#endif /* CONFIG_X86_AMD_PLATFORM_DEVICE */ |
|---|
| 176 | 178 | |
|---|
| 177 | 179 | /** |
|---|
| 178 | 180 | * Create platform device during acpi scan attach handle. |
|---|
| .. | .. |
|---|
| 224 | 226 | { "AMDI0010", APD_ADDR(wt_i2c_desc) }, |
|---|
| 225 | 227 | { "AMD0020", APD_ADDR(cz_uart_desc) }, |
|---|
| 226 | 228 | { "AMDI0020", APD_ADDR(cz_uart_desc) }, |
|---|
| 229 | + { "AMDI0022", APD_ADDR(cz_uart_desc) }, |
|---|
| 227 | 230 | { "AMD0030", }, |
|---|
| 228 | | - { "AMD0040", APD_ADDR(st_misc_desc)}, |
|---|
| 231 | + { "AMD0040", APD_ADDR(fch_misc_desc)}, |
|---|
| 232 | + { "HYGO0010", APD_ADDR(wt_i2c_desc) }, |
|---|
| 229 | 233 | #endif |
|---|
| 230 | 234 | #ifdef CONFIG_ARM64 |
|---|
| 231 | 235 | { "APMC0D0F", APD_ADDR(xgene_i2c_desc) }, |
|---|
| .. | .. |
|---|
| 234 | 238 | { "CAV9007", APD_ADDR(thunderx2_i2c_desc) }, |
|---|
| 235 | 239 | { "HISI02A1", APD_ADDR(hip07_i2c_desc) }, |
|---|
| 236 | 240 | { "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) }, |
|---|
| 237 | 244 | #endif |
|---|
| 238 | 245 | { } |
|---|
| 239 | 246 | }; |
|---|