forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/iio/common/ssp_sensors/ssp_dev.c
....@@ -1,16 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Copyright (C) 2014, Samsung Electronics Co. Ltd. All Rights Reserved.
3
- *
4
- * This program is free software; you can redistribute it and/or modify
5
- * it under the terms of the GNU General Public License as published by
6
- * the Free Software Foundation; either version 2 of the License, or
7
- * (at your option) any later version.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU General Public License for more details.
13
- *
144 */
155
166 #include <linux/iio/iio.h>
....@@ -19,7 +9,6 @@
199 #include <linux/mfd/core.h>
2010 #include <linux/module.h>
2111 #include <linux/of.h>
22
-#include <linux/of_gpio.h>
2312 #include <linux/of_platform.h>
2413 #include "ssp.h"
2514
....@@ -71,9 +60,9 @@
7160
7261 static void ssp_toggle_mcu_reset_gpio(struct ssp_data *data)
7362 {
74
- gpio_set_value(data->mcu_reset_gpio, 0);
63
+ gpiod_set_value(data->mcu_reset_gpiod, 0);
7564 usleep_range(1000, 1200);
76
- gpio_set_value(data->mcu_reset_gpio, 1);
65
+ gpiod_set_value(data->mcu_reset_gpiod, 1);
7766 msleep(50);
7867 }
7968
....@@ -451,7 +440,6 @@
451440
452441 static struct ssp_data *ssp_parse_dt(struct device *dev)
453442 {
454
- int ret;
455443 struct ssp_data *data;
456444 struct device_node *node = dev->of_node;
457445 const struct of_device_id *match;
....@@ -460,45 +448,28 @@
460448 if (!data)
461449 return NULL;
462450
463
- data->mcu_ap_gpio = of_get_named_gpio(node, "mcu-ap-gpios", 0);
464
- if (data->mcu_ap_gpio < 0)
465
- goto err_free_pd;
451
+ data->mcu_ap_gpiod = devm_gpiod_get(dev, "mcu-ap", GPIOD_IN);
452
+ if (IS_ERR(data->mcu_ap_gpiod))
453
+ return NULL;
466454
467
- data->ap_mcu_gpio = of_get_named_gpio(node, "ap-mcu-gpios", 0);
468
- if (data->ap_mcu_gpio < 0)
469
- goto err_free_pd;
455
+ data->ap_mcu_gpiod = devm_gpiod_get(dev, "ap-mcu", GPIOD_OUT_HIGH);
456
+ if (IS_ERR(data->ap_mcu_gpiod))
457
+ return NULL;
470458
471
- data->mcu_reset_gpio = of_get_named_gpio(node, "mcu-reset-gpios", 0);
472
- if (data->mcu_reset_gpio < 0)
473
- goto err_free_pd;
474
-
475
- ret = devm_gpio_request_one(dev, data->ap_mcu_gpio, GPIOF_OUT_INIT_HIGH,
476
- "ap-mcu-gpios");
477
- if (ret)
478
- goto err_free_pd;
479
-
480
- ret = devm_gpio_request_one(dev, data->mcu_reset_gpio,
481
- GPIOF_OUT_INIT_HIGH, "mcu-reset-gpios");
482
- if (ret)
483
- goto err_ap_mcu;
459
+ data->mcu_reset_gpiod = devm_gpiod_get(dev, "mcu-reset",
460
+ GPIOD_OUT_HIGH);
461
+ if (IS_ERR(data->mcu_reset_gpiod))
462
+ return NULL;
484463
485464 match = of_match_node(ssp_of_match, node);
486465 if (!match)
487
- goto err_mcu_reset_gpio;
466
+ return NULL;
488467
489468 data->sensorhub_info = match->data;
490469
491470 dev_set_drvdata(dev, data);
492471
493472 return data;
494
-
495
-err_mcu_reset_gpio:
496
- devm_gpio_free(dev, data->mcu_reset_gpio);
497
-err_ap_mcu:
498
- devm_gpio_free(dev, data->ap_mcu_gpio);
499
-err_free_pd:
500
- devm_kfree(dev, data);
501
- return NULL;
502473 }
503474 #else
504475 static struct ssp_data *ssp_parse_dt(struct device *pdev)
....@@ -532,7 +503,8 @@
532503 return -ENODEV;
533504 }
534505
535
- ret = mfd_add_devices(&spi->dev, -1, sensorhub_sensor_devs,
506
+ ret = mfd_add_devices(&spi->dev, PLATFORM_DEVID_NONE,
507
+ sensorhub_sensor_devs,
536508 ARRAY_SIZE(sensorhub_sensor_devs), NULL, 0, NULL);
537509 if (ret < 0) {
538510 dev_err(&spi->dev, "mfd add devices fail\n");