Skip to content

Commit d3d76ae

Browse files
committed
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: Andy Shevchenko <[email protected]> Signed-off-by: Hans de Goede <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 71102bc commit d3d76ae

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

drivers/platform/x86/intel/int3472/tps68470.c

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,21 @@
55
#include <linux/mfd/core.h>
66
#include <linux/mfd/tps68470.h>
77
#include <linux/platform_device.h>
8+
#include <linux/platform_data/tps68470.h>
89
#include <linux/regmap.h>
910

1011
#include "common.h"
1112

1213
#define DESIGNED_FOR_CHROMEOS 1
1314
#define DESIGNED_FOR_WINDOWS 2
1415

16+
#define TPS68470_WIN_MFD_CELL_COUNT 3
17+
1518
static const struct mfd_cell tps68470_cros[] = {
1619
{ .name = "tps68470-gpio" },
1720
{ .name = "tps68470_pmic_opregion" },
1821
};
1922

20-
static const struct mfd_cell tps68470_win[] = {
21-
{ .name = "tps68470-gpio" },
22-
{ .name = "tps68470-clk" },
23-
{ .name = "tps68470-regulator" },
24-
};
25-
2623
static const struct regmap_config tps68470_regmap_config = {
2724
.reg_bits = 8,
2825
.val_bits = 8,
@@ -98,10 +95,17 @@ static int skl_int3472_tps68470_calc_type(struct acpi_device *adev)
9895
static int skl_int3472_tps68470_probe(struct i2c_client *client)
9996
{
10097
struct acpi_device *adev = ACPI_COMPANION(&client->dev);
98+
struct tps68470_clk_platform_data clk_pdata = {};
99+
struct mfd_cell *cells;
101100
struct regmap *regmap;
102101
int device_type;
103102
int ret;
104103

104+
ret = skl_int3472_get_sensor_adev_and_name(&client->dev, NULL,
105+
&clk_pdata.consumer_dev_name);
106+
if (ret)
107+
return ret;
108+
105109
regmap = devm_regmap_init_i2c(client, &tps68470_regmap_config);
106110
if (IS_ERR(regmap)) {
107111
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)
119123
device_type = skl_int3472_tps68470_calc_type(adev);
120124
switch (device_type) {
121125
case DESIGNED_FOR_WINDOWS:
126+
cells = kcalloc(TPS68470_WIN_MFD_CELL_COUNT, sizeof(*cells), GFP_KERNEL);
127+
if (!cells)
128+
return -ENOMEM;
129+
130+
/*
131+
* The order of the cells matters here! The clk must be first
132+
* because the regulator depends on it. The gpios must be last,
133+
* acpi_gpiochip_add() calls acpi_dev_clear_dependencies() and
134+
* the clk + regulators must be ready when this happens.
135+
*/
136+
cells[0].name = "tps68470-clk";
137+
cells[0].platform_data = &clk_pdata;
138+
cells[0].pdata_size = sizeof(clk_pdata);
139+
cells[1].name = "tps68470-regulator";
140+
cells[2].name = "tps68470-gpio";
141+
122142
ret = devm_mfd_add_devices(&client->dev, PLATFORM_DEVID_NONE,
123-
tps68470_win, ARRAY_SIZE(tps68470_win),
143+
cells, TPS68470_WIN_MFD_CELL_COUNT,
124144
NULL, 0, NULL);
145+
kfree(cells);
125146
break;
126147
case DESIGNED_FOR_CHROMEOS:
127148
ret = devm_mfd_add_devices(&client->dev, PLATFORM_DEVID_NONE,

0 commit comments

Comments
 (0)