|
14 | 14 |
|
15 | 15 | #include <linux/delay.h>
|
16 | 16 | #include <linux/gpio.h>
|
17 |
| -#include <linux/i2c.h> |
18 | 17 | #include <linux/module.h>
|
19 | 18 | #include <linux/of_device.h>
|
20 | 19 | #include <linux/of_gpio.h>
|
@@ -1286,19 +1285,23 @@ static int rk808_regulator_dt_parse_pdata(struct device *dev,
|
1286 | 1285 | static int rk808_regulator_probe(struct platform_device *pdev)
|
1287 | 1286 | {
|
1288 | 1287 | struct rk808 *rk808 = dev_get_drvdata(pdev->dev.parent);
|
1289 |
| - struct i2c_client *client = rk808->i2c; |
1290 | 1288 | struct regulator_config config = {};
|
1291 | 1289 | struct regulator_dev *rk808_rdev;
|
1292 | 1290 | struct rk808_regulator_data *pdata;
|
1293 | 1291 | const struct regulator_desc *regulators;
|
| 1292 | + struct regmap *regmap; |
1294 | 1293 | int ret, i, nregulators;
|
1295 | 1294 |
|
| 1295 | + regmap = dev_get_regmap(pdev->dev.parent, NULL); |
| 1296 | + if (!regmap) |
| 1297 | + return -ENODEV; |
| 1298 | + |
1296 | 1299 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
|
1297 | 1300 | if (!pdata)
|
1298 | 1301 | return -ENOMEM;
|
1299 | 1302 |
|
1300 |
| - ret = rk808_regulator_dt_parse_pdata(&pdev->dev, &client->dev, |
1301 |
| - rk808->regmap, pdata); |
| 1303 | + ret = rk808_regulator_dt_parse_pdata(&pdev->dev, pdev->dev.parent, |
| 1304 | + regmap, pdata); |
1302 | 1305 | if (ret < 0)
|
1303 | 1306 | return ret;
|
1304 | 1307 |
|
@@ -1326,21 +1329,22 @@ static int rk808_regulator_probe(struct platform_device *pdev)
|
1326 | 1329 | nregulators = RK818_NUM_REGULATORS;
|
1327 | 1330 | break;
|
1328 | 1331 | default:
|
1329 |
| - dev_err(&client->dev, "unsupported RK8XX ID %lu\n", |
| 1332 | + dev_err(&pdev->dev, "unsupported RK8XX ID %lu\n", |
1330 | 1333 | rk808->variant);
|
1331 | 1334 | return -EINVAL;
|
1332 | 1335 | }
|
1333 | 1336 |
|
1334 |
| - config.dev = &client->dev; |
| 1337 | + config.dev = &pdev->dev; |
| 1338 | + config.dev->of_node = pdev->dev.parent->of_node; |
1335 | 1339 | config.driver_data = pdata;
|
1336 |
| - config.regmap = rk808->regmap; |
| 1340 | + config.regmap = regmap; |
1337 | 1341 |
|
1338 | 1342 | /* Instantiate the regulators */
|
1339 | 1343 | for (i = 0; i < nregulators; i++) {
|
1340 | 1344 | rk808_rdev = devm_regulator_register(&pdev->dev,
|
1341 | 1345 | ®ulators[i], &config);
|
1342 | 1346 | if (IS_ERR(rk808_rdev)) {
|
1343 |
| - dev_err(&client->dev, |
| 1347 | + dev_err(&pdev->dev, |
1344 | 1348 | "failed to register %d regulator\n", i);
|
1345 | 1349 | return PTR_ERR(rk808_rdev);
|
1346 | 1350 | }
|
|
0 commit comments