2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-28 07:04:00 +08:00

at86rf230: make reset pin optionally

This patch make the reset pin optionally. Some devices like the atben
from qi-hardware don't have a reset pin externally. The usually way is
to turn power off/on for the atben device to initiate a device reset.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Alexander Aring 2014-03-15 09:29:06 +01:00 committed by David S. Miller
parent 56f023fbe8
commit 3fa2757124

View File

@ -1059,9 +1059,11 @@ static int at86rf230_probe(struct spi_device *spi)
return -EINVAL; return -EINVAL;
} }
if (gpio_is_valid(pdata->rstn)) {
rc = gpio_request(pdata->rstn, "rstn"); rc = gpio_request(pdata->rstn, "rstn");
if (rc) if (rc)
return rc; return rc;
}
if (gpio_is_valid(pdata->slp_tr)) { if (gpio_is_valid(pdata->slp_tr)) {
rc = gpio_request(pdata->slp_tr, "slp_tr"); rc = gpio_request(pdata->slp_tr, "slp_tr");
@ -1069,9 +1071,11 @@ static int at86rf230_probe(struct spi_device *spi)
goto err_slp_tr; goto err_slp_tr;
} }
if (gpio_is_valid(pdata->rstn)) {
rc = gpio_direction_output(pdata->rstn, 1); rc = gpio_direction_output(pdata->rstn, 1);
if (rc) if (rc)
goto err_gpio_dir; goto err_gpio_dir;
}
if (gpio_is_valid(pdata->slp_tr)) { if (gpio_is_valid(pdata->slp_tr)) {
rc = gpio_direction_output(pdata->slp_tr, 0); rc = gpio_direction_output(pdata->slp_tr, 0);
@ -1080,11 +1084,13 @@ static int at86rf230_probe(struct spi_device *spi)
} }
/* Reset */ /* Reset */
if (gpio_is_valid(pdata->rstn)) {
udelay(1); udelay(1);
gpio_set_value(pdata->rstn, 0); gpio_set_value(pdata->rstn, 0);
udelay(1); udelay(1);
gpio_set_value(pdata->rstn, 1); gpio_set_value(pdata->rstn, 1);
usleep_range(120, 240); usleep_range(120, 240);
}
rc = __at86rf230_detect_device(spi, &man_id, &part, &version); rc = __at86rf230_detect_device(spi, &man_id, &part, &version);
if (rc < 0) if (rc < 0)
@ -1198,6 +1204,7 @@ err_gpio_dir:
if (gpio_is_valid(pdata->slp_tr)) if (gpio_is_valid(pdata->slp_tr))
gpio_free(pdata->slp_tr); gpio_free(pdata->slp_tr);
err_slp_tr: err_slp_tr:
if (gpio_is_valid(pdata->rstn))
gpio_free(pdata->rstn); gpio_free(pdata->rstn);
return rc; return rc;
} }
@ -1214,6 +1221,7 @@ static int at86rf230_remove(struct spi_device *spi)
if (gpio_is_valid(pdata->slp_tr)) if (gpio_is_valid(pdata->slp_tr))
gpio_free(pdata->slp_tr); gpio_free(pdata->slp_tr);
if (gpio_is_valid(pdata->rstn))
gpio_free(pdata->rstn); gpio_free(pdata->rstn);
mutex_destroy(&lp->bmux); mutex_destroy(&lp->bmux);