5
5
#include <linux/mfd/core.h>
6
6
#include <linux/mfd/tps68470.h>
7
7
#include <linux/platform_device.h>
8
+ #include <linux/platform_data/tps68470.h>
8
9
#include <linux/regmap.h>
9
10
10
11
#include "common.h"
11
12
12
13
#define DESIGNED_FOR_CHROMEOS 1
13
14
#define DESIGNED_FOR_WINDOWS 2
14
15
16
+ #define TPS68470_WIN_MFD_CELL_COUNT 3
17
+
15
18
static const struct mfd_cell tps68470_cros [] = {
16
19
{ .name = "tps68470-gpio" },
17
20
{ .name = "tps68470_pmic_opregion" },
18
21
};
19
22
20
- static const struct mfd_cell tps68470_win [] = {
21
- { .name = "tps68470-gpio" },
22
- { .name = "tps68470-clk" },
23
- { .name = "tps68470-regulator" },
24
- };
25
-
26
23
static const struct regmap_config tps68470_regmap_config = {
27
24
.reg_bits = 8 ,
28
25
.val_bits = 8 ,
@@ -98,10 +95,17 @@ static int skl_int3472_tps68470_calc_type(struct acpi_device *adev)
98
95
static int skl_int3472_tps68470_probe (struct i2c_client * client )
99
96
{
100
97
struct acpi_device * adev = ACPI_COMPANION (& client -> dev );
98
+ struct tps68470_clk_platform_data clk_pdata = {};
99
+ struct mfd_cell * cells ;
101
100
struct regmap * regmap ;
102
101
int device_type ;
103
102
int ret ;
104
103
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
+
105
109
regmap = devm_regmap_init_i2c (client , & tps68470_regmap_config );
106
110
if (IS_ERR (regmap )) {
107
111
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
123
device_type = skl_int3472_tps68470_calc_type (adev );
120
124
switch (device_type ) {
121
125
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
+
122
142
ret = devm_mfd_add_devices (& client -> dev , PLATFORM_DEVID_NONE ,
123
- tps68470_win , ARRAY_SIZE ( tps68470_win ) ,
143
+ cells , TPS68470_WIN_MFD_CELL_COUNT ,
124
144
NULL , 0 , NULL );
145
+ kfree (cells );
125
146
break ;
126
147
case DESIGNED_FOR_CHROMEOS :
127
148
ret = devm_mfd_add_devices (& client -> dev , PLATFORM_DEVID_NONE ,
0 commit comments