iio: ssp_sensors: Convert to use GPIO descriptors
These three GPIO lines used by the Samsung sensor hub is pretty straight-forward to convert to use GPIO descriptors. Cc: Karol Wrona <k.wrona@samsung.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
7c93f54e5b
commit
4cf01d6d4e
@ -7,7 +7,7 @@
|
|||||||
#define __SSP_SENSORHUB_H__
|
#define __SSP_SENSORHUB_H__
|
||||||
|
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
#include <linux/gpio.h>
|
#include <linux/gpio/consumer.h>
|
||||||
#include <linux/iio/common/ssp_sensors.h>
|
#include <linux/iio/common/ssp_sensors.h>
|
||||||
#include <linux/iio/iio.h>
|
#include <linux/iio/iio.h>
|
||||||
#include <linux/spi/spi.h>
|
#include <linux/spi/spi.h>
|
||||||
@ -168,9 +168,9 @@ struct ssp_sensorhub_info {
|
|||||||
* @fw_dl_state: firmware download state
|
* @fw_dl_state: firmware download state
|
||||||
* @comm_lock: lock protecting the handshake
|
* @comm_lock: lock protecting the handshake
|
||||||
* @pending_lock: lock protecting pending list and completion
|
* @pending_lock: lock protecting pending list and completion
|
||||||
* @mcu_reset_gpio: mcu reset line
|
* @mcu_reset_gpiod: mcu reset line
|
||||||
* @ap_mcu_gpio: ap to mcu gpio line
|
* @ap_mcu_gpiod: ap to mcu gpio line
|
||||||
* @mcu_ap_gpio: mcu to ap gpio line
|
* @mcu_ap_gpiod: mcu to ap gpio line
|
||||||
* @pending_list: pending list for messages queued to be sent/read
|
* @pending_list: pending list for messages queued to be sent/read
|
||||||
* @sensor_devs: registered IIO devices table
|
* @sensor_devs: registered IIO devices table
|
||||||
* @enable_refcount: enable reference count for wdt (watchdog timer)
|
* @enable_refcount: enable reference count for wdt (watchdog timer)
|
||||||
@ -212,9 +212,9 @@ struct ssp_data {
|
|||||||
struct mutex comm_lock;
|
struct mutex comm_lock;
|
||||||
struct mutex pending_lock;
|
struct mutex pending_lock;
|
||||||
|
|
||||||
int mcu_reset_gpio;
|
struct gpio_desc *mcu_reset_gpiod;
|
||||||
int ap_mcu_gpio;
|
struct gpio_desc *ap_mcu_gpiod;
|
||||||
int mcu_ap_gpio;
|
struct gpio_desc *mcu_ap_gpiod;
|
||||||
|
|
||||||
struct list_head pending_list;
|
struct list_head pending_list;
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
#include <linux/mfd/core.h>
|
#include <linux/mfd/core.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
#include <linux/of_gpio.h>
|
|
||||||
#include <linux/of_platform.h>
|
#include <linux/of_platform.h>
|
||||||
#include "ssp.h"
|
#include "ssp.h"
|
||||||
|
|
||||||
@ -61,9 +60,9 @@ static const struct mfd_cell sensorhub_sensor_devs[] = {
|
|||||||
|
|
||||||
static void ssp_toggle_mcu_reset_gpio(struct ssp_data *data)
|
static void ssp_toggle_mcu_reset_gpio(struct ssp_data *data)
|
||||||
{
|
{
|
||||||
gpio_set_value(data->mcu_reset_gpio, 0);
|
gpiod_set_value(data->mcu_reset_gpiod, 0);
|
||||||
usleep_range(1000, 1200);
|
usleep_range(1000, 1200);
|
||||||
gpio_set_value(data->mcu_reset_gpio, 1);
|
gpiod_set_value(data->mcu_reset_gpiod, 1);
|
||||||
msleep(50);
|
msleep(50);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -441,7 +440,6 @@ MODULE_DEVICE_TABLE(of, ssp_of_match);
|
|||||||
|
|
||||||
static struct ssp_data *ssp_parse_dt(struct device *dev)
|
static struct ssp_data *ssp_parse_dt(struct device *dev)
|
||||||
{
|
{
|
||||||
int ret;
|
|
||||||
struct ssp_data *data;
|
struct ssp_data *data;
|
||||||
struct device_node *node = dev->of_node;
|
struct device_node *node = dev->of_node;
|
||||||
const struct of_device_id *match;
|
const struct of_device_id *match;
|
||||||
@ -450,26 +448,17 @@ static struct ssp_data *ssp_parse_dt(struct device *dev)
|
|||||||
if (!data)
|
if (!data)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
data->mcu_ap_gpio = of_get_named_gpio(node, "mcu-ap-gpios", 0);
|
data->mcu_ap_gpiod = devm_gpiod_get(dev, "mcu-ap", GPIOD_IN);
|
||||||
if (data->mcu_ap_gpio < 0)
|
if (IS_ERR(data->mcu_ap_gpiod))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
data->ap_mcu_gpio = of_get_named_gpio(node, "ap-mcu-gpios", 0);
|
data->ap_mcu_gpiod = devm_gpiod_get(dev, "ap-mcu", GPIOD_OUT_HIGH);
|
||||||
if (data->ap_mcu_gpio < 0)
|
if (IS_ERR(data->ap_mcu_gpiod))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
data->mcu_reset_gpio = of_get_named_gpio(node, "mcu-reset-gpios", 0);
|
data->mcu_reset_gpiod = devm_gpiod_get(dev, "mcu-reset",
|
||||||
if (data->mcu_reset_gpio < 0)
|
GPIOD_OUT_HIGH);
|
||||||
return NULL;
|
if (IS_ERR(data->mcu_reset_gpiod))
|
||||||
|
|
||||||
ret = devm_gpio_request_one(dev, data->ap_mcu_gpio, GPIOF_OUT_INIT_HIGH,
|
|
||||||
"ap-mcu-gpios");
|
|
||||||
if (ret)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
ret = devm_gpio_request_one(dev, data->mcu_reset_gpio,
|
|
||||||
GPIOF_OUT_INIT_HIGH, "mcu-reset-gpios");
|
|
||||||
if (ret)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
match = of_match_node(ssp_of_match, node);
|
match = of_match_node(ssp_of_match, node);
|
||||||
|
@ -155,9 +155,9 @@ static int ssp_check_lines(struct ssp_data *data, bool state)
|
|||||||
{
|
{
|
||||||
int delay_cnt = 0;
|
int delay_cnt = 0;
|
||||||
|
|
||||||
gpio_set_value_cansleep(data->ap_mcu_gpio, state);
|
gpiod_set_value_cansleep(data->ap_mcu_gpiod, state);
|
||||||
|
|
||||||
while (gpio_get_value_cansleep(data->mcu_ap_gpio) != state) {
|
while (gpiod_get_value_cansleep(data->mcu_ap_gpiod) != state) {
|
||||||
usleep_range(3000, 3500);
|
usleep_range(3000, 3500);
|
||||||
|
|
||||||
if (data->shut_down || delay_cnt++ > 500) {
|
if (data->shut_down || delay_cnt++ > 500) {
|
||||||
@ -165,7 +165,7 @@ static int ssp_check_lines(struct ssp_data *data, bool state)
|
|||||||
__func__, state);
|
__func__, state);
|
||||||
|
|
||||||
if (!state)
|
if (!state)
|
||||||
gpio_set_value_cansleep(data->ap_mcu_gpio, 1);
|
gpiod_set_value_cansleep(data->ap_mcu_gpiod, 1);
|
||||||
|
|
||||||
return -ETIMEDOUT;
|
return -ETIMEDOUT;
|
||||||
}
|
}
|
||||||
@ -197,7 +197,7 @@ static int ssp_do_transfer(struct ssp_data *data, struct ssp_msg *msg,
|
|||||||
|
|
||||||
status = spi_write(data->spi, msg->buffer, SSP_HEADER_SIZE);
|
status = spi_write(data->spi, msg->buffer, SSP_HEADER_SIZE);
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
gpio_set_value_cansleep(data->ap_mcu_gpio, 1);
|
gpiod_set_value_cansleep(data->ap_mcu_gpiod, 1);
|
||||||
dev_err(SSP_DEV, "%s spi_write fail\n", __func__);
|
dev_err(SSP_DEV, "%s spi_write fail\n", __func__);
|
||||||
goto _error_locked;
|
goto _error_locked;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user