Commit 9bf48e2e authored by Jagan Teki's avatar Jagan Teki Committed by Tom Rini

spi: atmel: Add ifdef for DM_GPIO code

Few boards are configuring gpio directly from board instead
using drivers/gpio so add ifdef for DM_GPIO to compatible
for both the cases.
Signed-off-by: Jagan Teki's avatarJagan Teki <jagan@amarulasolutions.com>
Acked-by: default avatarWenyou Yang <wenyouya@gmail.com>
parent 6074c387
......@@ -236,7 +236,9 @@ struct atmel_spi_priv {
unsigned int freq; /* Default frequency */
unsigned int mode;
ulong bus_clk_rate;
#ifdef CONFIG_DM_GPIO
struct gpio_desc cs_gpios[MAX_CS_COUNT];
#endif
};
static int atmel_spi_claim_bus(struct udevice *dev)
......@@ -291,6 +293,7 @@ static int atmel_spi_release_bus(struct udevice *dev)
static void atmel_spi_cs_activate(struct udevice *dev)
{
#ifdef CONFIG_DM_GPIO
struct udevice *bus = dev_get_parent(dev);
struct atmel_spi_priv *priv = dev_get_priv(bus);
struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev);
......@@ -300,10 +303,12 @@ static void atmel_spi_cs_activate(struct udevice *dev)
return;
dm_gpio_set_value(&priv->cs_gpios[cs], 0);
#endif
}
static void atmel_spi_cs_deactivate(struct udevice *dev)
{
#ifdef CONFIG_DM_GPIO
struct udevice *bus = dev_get_parent(dev);
struct atmel_spi_priv *priv = dev_get_priv(bus);
struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev);
......@@ -313,6 +318,7 @@ static void atmel_spi_cs_deactivate(struct udevice *dev)
return;
dm_gpio_set_value(&priv->cs_gpios[cs], 1);
#endif
}
static int atmel_spi_xfer(struct udevice *dev, unsigned int bitlen,
......@@ -462,8 +468,7 @@ static int atmel_spi_enable_clk(struct udevice *bus)
static int atmel_spi_probe(struct udevice *bus)
{
struct atmel_spi_platdata *bus_plat = dev_get_platdata(bus);
struct atmel_spi_priv *priv = dev_get_priv(bus);
int i, ret;
int ret;
ret = atmel_spi_enable_clk(bus);
if (ret)
......@@ -471,6 +476,10 @@ static int atmel_spi_probe(struct udevice *bus)
bus_plat->regs = (struct at91_spi *)devfdt_get_addr(bus);
#ifdef CONFIG_DM_GPIO
struct atmel_spi_priv *priv = dev_get_priv(bus);
int i;
ret = gpio_request_list_by_name(bus, "cs-gpios", priv->cs_gpios,
ARRAY_SIZE(priv->cs_gpios), 0);
if (ret < 0) {
......@@ -485,6 +494,7 @@ static int atmel_spi_probe(struct udevice *bus)
dm_gpio_set_dir_flags(&priv->cs_gpios[i],
GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
}
#endif
writel(ATMEL_SPI_CR_SWRST, &bus_plat->regs->cr);
......
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