Commit d3d76ae1 authored by Hans de Goede's avatar Hans de Goede

platform/x86: int3472: Pass tps68470_clk_platform_data to the tps68470-regulator MFD-cell

Pass tps68470_clk_platform_data to the tps68470-clk MFD-cell,
so that sensors which use the TPS68470 can find their clock.
Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211203102857.44539-10-hdegoede@redhat.com
parent 71102bc7
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <linux/mfd/core.h> #include <linux/mfd/core.h>
#include <linux/mfd/tps68470.h> #include <linux/mfd/tps68470.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/platform_data/tps68470.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include "common.h" #include "common.h"
...@@ -12,17 +13,13 @@ ...@@ -12,17 +13,13 @@
#define DESIGNED_FOR_CHROMEOS 1 #define DESIGNED_FOR_CHROMEOS 1
#define DESIGNED_FOR_WINDOWS 2 #define DESIGNED_FOR_WINDOWS 2
#define TPS68470_WIN_MFD_CELL_COUNT 3
static const struct mfd_cell tps68470_cros[] = { static const struct mfd_cell tps68470_cros[] = {
{ .name = "tps68470-gpio" }, { .name = "tps68470-gpio" },
{ .name = "tps68470_pmic_opregion" }, { .name = "tps68470_pmic_opregion" },
}; };
static const struct mfd_cell tps68470_win[] = {
{ .name = "tps68470-gpio" },
{ .name = "tps68470-clk" },
{ .name = "tps68470-regulator" },
};
static const struct regmap_config tps68470_regmap_config = { static const struct regmap_config tps68470_regmap_config = {
.reg_bits = 8, .reg_bits = 8,
.val_bits = 8, .val_bits = 8,
...@@ -98,10 +95,17 @@ static int skl_int3472_tps68470_calc_type(struct acpi_device *adev) ...@@ -98,10 +95,17 @@ static int skl_int3472_tps68470_calc_type(struct acpi_device *adev)
static int skl_int3472_tps68470_probe(struct i2c_client *client) static int skl_int3472_tps68470_probe(struct i2c_client *client)
{ {
struct acpi_device *adev = ACPI_COMPANION(&client->dev); struct acpi_device *adev = ACPI_COMPANION(&client->dev);
struct tps68470_clk_platform_data clk_pdata = {};
struct mfd_cell *cells;
struct regmap *regmap; struct regmap *regmap;
int device_type; int device_type;
int ret; int ret;
ret = skl_int3472_get_sensor_adev_and_name(&client->dev, NULL,
&clk_pdata.consumer_dev_name);
if (ret)
return ret;
regmap = devm_regmap_init_i2c(client, &tps68470_regmap_config); regmap = devm_regmap_init_i2c(client, &tps68470_regmap_config);
if (IS_ERR(regmap)) { if (IS_ERR(regmap)) {
dev_err(&client->dev, "Failed to create regmap: %ld\n", PTR_ERR(regmap)); dev_err(&client->dev, "Failed to create regmap: %ld\n", PTR_ERR(regmap));
...@@ -119,9 +123,26 @@ static int skl_int3472_tps68470_probe(struct i2c_client *client) ...@@ -119,9 +123,26 @@ static int skl_int3472_tps68470_probe(struct i2c_client *client)
device_type = skl_int3472_tps68470_calc_type(adev); device_type = skl_int3472_tps68470_calc_type(adev);
switch (device_type) { switch (device_type) {
case DESIGNED_FOR_WINDOWS: case DESIGNED_FOR_WINDOWS:
cells = kcalloc(TPS68470_WIN_MFD_CELL_COUNT, sizeof(*cells), GFP_KERNEL);
if (!cells)
return -ENOMEM;
/*
* The order of the cells matters here! The clk must be first
* because the regulator depends on it. The gpios must be last,
* acpi_gpiochip_add() calls acpi_dev_clear_dependencies() and
* the clk + regulators must be ready when this happens.
*/
cells[0].name = "tps68470-clk";
cells[0].platform_data = &clk_pdata;
cells[0].pdata_size = sizeof(clk_pdata);
cells[1].name = "tps68470-regulator";
cells[2].name = "tps68470-gpio";
ret = devm_mfd_add_devices(&client->dev, PLATFORM_DEVID_NONE, ret = devm_mfd_add_devices(&client->dev, PLATFORM_DEVID_NONE,
tps68470_win, ARRAY_SIZE(tps68470_win), cells, TPS68470_WIN_MFD_CELL_COUNT,
NULL, 0, NULL); NULL, 0, NULL);
kfree(cells);
break; break;
case DESIGNED_FOR_CHROMEOS: case DESIGNED_FOR_CHROMEOS:
ret = devm_mfd_add_devices(&client->dev, PLATFORM_DEVID_NONE, ret = devm_mfd_add_devices(&client->dev, PLATFORM_DEVID_NONE,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment