*/
#include <linux/module.h>
+#include <linux/err.h>
#include <linux/errno.h>
#include <linux/of_platform.h>
#include <linux/interrupt.h>
#include <linux/gpio/consumer.h>
#include <linux/spi/spi.h>
#include <linux/io.h>
-#include <linux/of_gpio.h>
#include <linux/slab.h>
#include <linux/of_address.h>
#include <linux/of_irq.h>
const u8 *tx_buf;
int cs_change;
int gpio_cs_count;
- unsigned int *gpio_cs;
+ struct gpio_desc **gpio_cs;
};
/*
if (ms->gpio_cs_count > 0) {
cs = ms->message->spi->chip_select;
- gpio_set_value(ms->gpio_cs[cs], value ? 0 : 1);
- } else
+ gpiod_set_value(ms->gpio_cs[cs], value);
+ } else {
out_8(ms->regs + SPI_PORTDATA, value ? 0 : 0x08);
+ }
}
/*
{
struct spi_master *master;
struct mpc52xx_spi *ms;
+ struct gpio_desc *gpio_cs;
void __iomem *regs;
u8 ctrl1;
int rc, i = 0;
- int gpio_cs;
/* MMIO registers */
dev_dbg(&op->dev, "probing mpc5200 SPI device\n");
}
for (i = 0; i < ms->gpio_cs_count; i++) {
- gpio_cs = of_get_gpio(op->dev.of_node, i);
- if (!gpio_is_valid(gpio_cs)) {
- dev_err(&op->dev,
- "could not parse the gpio field in oftree\n");
- rc = -ENODEV;
- goto err_gpio;
- }
-
- rc = gpio_request(gpio_cs, dev_name(&op->dev));
+ gpio_cs = gpiod_get_index(&op->dev,
+ NULL, i, GPIOD_OUT_LOW);
+ rc = PTR_ERR_OR_ZERO(gpio_cs);
if (rc) {
dev_err(&op->dev,
- "can't request spi cs gpio #%d on gpio line %d\n",
- i, gpio_cs);
+ "failed to get spi cs gpio #%d: %d\n",
+ i, rc);
goto err_gpio;
}
- gpio_direction_output(gpio_cs, 1);
ms->gpio_cs[i] = gpio_cs;
}
}
dev_err(&ms->master->dev, "initialization failed\n");
err_gpio:
while (i-- > 0)
- gpio_free(ms->gpio_cs[i]);
+ gpiod_put(ms->gpio_cs[i]);
kfree(ms->gpio_cs);
err_alloc_gpio:
free_irq(ms->irq1, ms);
for (i = 0; i < ms->gpio_cs_count; i++)
- gpio_free(ms->gpio_cs[i]);
+ gpiod_put(ms->gpio_cs[i]);
kfree(ms->gpio_cs);
spi_unregister_master(master);