Commit 61305436 authored by Dmitry Torokhov's avatar Dmitry Torokhov Committed by Stefan Schmidt

ieee802154: at86rf230: switch to using gpiod API

Switch the driver from legacy gpio API that is deprecated to the newer
gpiod API that respects line polarities described in ACPI/DT.
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
Link: https://lore.kernel.org/r/20230201053447.4098486-2-dmitry.torokhov@gmail.comSigned-off-by: default avatarStefan Schmidt <stefan@datenfreihafen.org>
parent 9b26ed18
......@@ -82,7 +82,7 @@ struct at86rf230_local {
struct ieee802154_hw *hw;
struct at86rf2xx_chip_data *data;
struct regmap *regmap;
int slp_tr;
struct gpio_desc *slp_tr;
bool sleep;
struct completion state_complete;
......@@ -107,8 +107,8 @@ at86rf230_async_state_change(struct at86rf230_local *lp,
static inline void
at86rf230_sleep(struct at86rf230_local *lp)
{
if (gpio_is_valid(lp->slp_tr)) {
gpio_set_value(lp->slp_tr, 1);
if (lp->slp_tr) {
gpiod_set_value(lp->slp_tr, 1);
usleep_range(lp->data->t_off_to_sleep,
lp->data->t_off_to_sleep + 10);
lp->sleep = true;
......@@ -118,8 +118,8 @@ at86rf230_sleep(struct at86rf230_local *lp)
static inline void
at86rf230_awake(struct at86rf230_local *lp)
{
if (gpio_is_valid(lp->slp_tr)) {
gpio_set_value(lp->slp_tr, 0);
if (lp->slp_tr) {
gpiod_set_value(lp->slp_tr, 0);
usleep_range(lp->data->t_sleep_to_off,
lp->data->t_sleep_to_off + 100);
lp->sleep = false;
......@@ -204,9 +204,9 @@ at86rf230_write_subreg(struct at86rf230_local *lp,
static inline void
at86rf230_slp_tr_rising_edge(struct at86rf230_local *lp)
{
gpio_set_value(lp->slp_tr, 1);
gpiod_set_value(lp->slp_tr, 1);
udelay(1);
gpio_set_value(lp->slp_tr, 0);
gpiod_set_value(lp->slp_tr, 0);
}
static bool
......@@ -819,7 +819,7 @@ at86rf230_write_frame_complete(void *context)
ctx->trx.len = 2;
if (gpio_is_valid(lp->slp_tr))
if (lp->slp_tr)
at86rf230_slp_tr_rising_edge(lp);
else
at86rf230_async_write_reg(lp, RG_TRX_STATE, STATE_BUSY_TX, ctx,
......@@ -1520,8 +1520,10 @@ static int at86rf230_probe(struct spi_device *spi)
{
struct ieee802154_hw *hw;
struct at86rf230_local *lp;
struct gpio_desc *slp_tr;
struct gpio_desc *rstn;
unsigned int status;
int rc, irq_type, rstn, slp_tr;
int rc, irq_type;
u8 xtal_trim;
if (!spi->irq) {
......@@ -1539,28 +1541,26 @@ static int at86rf230_probe(struct spi_device *spi)
xtal_trim = 0;
}
rstn = of_get_named_gpio(spi->dev.of_node, "reset-gpio", 0);
if (gpio_is_valid(rstn)) {
rc = devm_gpio_request_one(&spi->dev, rstn,
GPIOF_OUT_INIT_HIGH, "rstn");
if (rc)
return rc;
}
rstn = devm_gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT_LOW);
rc = PTR_ERR_OR_ZERO(rstn);
if (rc)
return rc;
slp_tr = of_get_named_gpio(spi->dev.of_node, "sleep-gpio", 0);
if (gpio_is_valid(slp_tr)) {
rc = devm_gpio_request_one(&spi->dev, slp_tr,
GPIOF_OUT_INIT_LOW, "slp_tr");
if (rc)
return rc;
}
gpiod_set_consumer_name(rstn, "rstn");
slp_tr = devm_gpiod_get_optional(&spi->dev, "sleep", GPIOD_OUT_LOW);
rc = PTR_ERR_OR_ZERO(slp_tr);
if (rc)
return rc;
gpiod_set_consumer_name(slp_tr, "slp_tr");
/* Reset */
if (gpio_is_valid(rstn)) {
if (rstn) {
udelay(1);
gpio_set_value_cansleep(rstn, 0);
gpiod_set_value_cansleep(rstn, 1);
udelay(1);
gpio_set_value_cansleep(rstn, 1);
gpiod_set_value_cansleep(rstn, 0);
usleep_range(120, 240);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment