| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * 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 | | - * |
|---|
| 14 | 4 | */ |
|---|
| 15 | 5 | |
|---|
| 16 | 6 | #include <linux/iio/iio.h> |
|---|
| .. | .. |
|---|
| 19 | 9 | #include <linux/mfd/core.h> |
|---|
| 20 | 10 | #include <linux/module.h> |
|---|
| 21 | 11 | #include <linux/of.h> |
|---|
| 22 | | -#include <linux/of_gpio.h> |
|---|
| 23 | 12 | #include <linux/of_platform.h> |
|---|
| 24 | 13 | #include "ssp.h" |
|---|
| 25 | 14 | |
|---|
| .. | .. |
|---|
| 71 | 60 | |
|---|
| 72 | 61 | static void ssp_toggle_mcu_reset_gpio(struct ssp_data *data) |
|---|
| 73 | 62 | { |
|---|
| 74 | | - gpio_set_value(data->mcu_reset_gpio, 0); |
|---|
| 63 | + gpiod_set_value(data->mcu_reset_gpiod, 0); |
|---|
| 75 | 64 | usleep_range(1000, 1200); |
|---|
| 76 | | - gpio_set_value(data->mcu_reset_gpio, 1); |
|---|
| 65 | + gpiod_set_value(data->mcu_reset_gpiod, 1); |
|---|
| 77 | 66 | msleep(50); |
|---|
| 78 | 67 | } |
|---|
| 79 | 68 | |
|---|
| .. | .. |
|---|
| 451 | 440 | |
|---|
| 452 | 441 | static struct ssp_data *ssp_parse_dt(struct device *dev) |
|---|
| 453 | 442 | { |
|---|
| 454 | | - int ret; |
|---|
| 455 | 443 | struct ssp_data *data; |
|---|
| 456 | 444 | struct device_node *node = dev->of_node; |
|---|
| 457 | 445 | const struct of_device_id *match; |
|---|
| .. | .. |
|---|
| 460 | 448 | if (!data) |
|---|
| 461 | 449 | return NULL; |
|---|
| 462 | 450 | |
|---|
| 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; |
|---|
| 466 | 454 | |
|---|
| 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; |
|---|
| 470 | 458 | |
|---|
| 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; |
|---|
| 484 | 463 | |
|---|
| 485 | 464 | match = of_match_node(ssp_of_match, node); |
|---|
| 486 | 465 | if (!match) |
|---|
| 487 | | - goto err_mcu_reset_gpio; |
|---|
| 466 | + return NULL; |
|---|
| 488 | 467 | |
|---|
| 489 | 468 | data->sensorhub_info = match->data; |
|---|
| 490 | 469 | |
|---|
| 491 | 470 | dev_set_drvdata(dev, data); |
|---|
| 492 | 471 | |
|---|
| 493 | 472 | 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; |
|---|
| 502 | 473 | } |
|---|
| 503 | 474 | #else |
|---|
| 504 | 475 | static struct ssp_data *ssp_parse_dt(struct device *pdev) |
|---|
| .. | .. |
|---|
| 532 | 503 | return -ENODEV; |
|---|
| 533 | 504 | } |
|---|
| 534 | 505 | |
|---|
| 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, |
|---|
| 536 | 508 | ARRAY_SIZE(sensorhub_sensor_devs), NULL, 0, NULL); |
|---|
| 537 | 509 | if (ret < 0) { |
|---|
| 538 | 510 | dev_err(&spi->dev, "mfd add devices fail\n"); |
|---|