Commit 4c1ce07b authored by Uri Mashiach's avatar Uri Mashiach Committed by Kalle Valo

wlcore/wl12xx: spi: add power operation function

The power function uses a consumer regulator access to update the WiFi
enable GPIO value.
Signed-off-by: default avatarUri Mashiach <uri.mashiach@compulab.co.il>
Tested-By: default avatarSebastian Reichel <sre@kernel.org>
Reviewed-by: default avatarGrygorii Strashko <grygorii.strashko@ti.com>
Acked-by: default avatarIgor Grinberg <grinberg@compulab.co.il>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent 7a26019f
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/wl12xx.h> #include <linux/wl12xx.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/regulator/consumer.h>
#include "wlcore.h" #include "wlcore.h"
#include "wl12xx_80211.h" #include "wl12xx_80211.h"
...@@ -81,6 +82,7 @@ ...@@ -81,6 +82,7 @@
struct wl12xx_spi_glue { struct wl12xx_spi_glue {
struct device *dev; struct device *dev;
struct platform_device *core; struct platform_device *core;
struct regulator *reg; /* Power regulator */
}; };
static void wl12xx_spi_reset(struct device *child) static void wl12xx_spi_reset(struct device *child)
...@@ -318,11 +320,40 @@ static int __must_check wl12xx_spi_raw_write(struct device *child, int addr, ...@@ -318,11 +320,40 @@ static int __must_check wl12xx_spi_raw_write(struct device *child, int addr,
return 0; return 0;
} }
/**
* wl12xx_spi_set_power - power on/off the wl12xx unit
* @child: wl12xx device handle.
* @enable: true/false to power on/off the unit.
*
* use the WiFi enable regulator to enable/disable the WiFi unit.
*/
static int wl12xx_spi_set_power(struct device *child, bool enable)
{
int ret = 0;
struct wl12xx_spi_glue *glue = dev_get_drvdata(child->parent);
WARN_ON(!glue->reg);
/* Update regulator state */
if (enable) {
ret = regulator_enable(glue->reg);
if (ret)
dev_err(child, "Power enable failure\n");
} else {
ret = regulator_disable(glue->reg);
if (ret)
dev_err(child, "Power disable failure\n");
}
return ret;
}
static struct wl1271_if_operations spi_ops = { static struct wl1271_if_operations spi_ops = {
.read = wl12xx_spi_raw_read, .read = wl12xx_spi_raw_read,
.write = wl12xx_spi_raw_write, .write = wl12xx_spi_raw_write,
.reset = wl12xx_spi_reset, .reset = wl12xx_spi_reset,
.init = wl12xx_spi_init, .init = wl12xx_spi_init,
.power = wl12xx_spi_set_power,
.set_block_size = NULL, .set_block_size = NULL,
}; };
...@@ -353,6 +384,14 @@ static int wl1271_probe(struct spi_device *spi) ...@@ -353,6 +384,14 @@ static int wl1271_probe(struct spi_device *spi)
* comes from the board-peripherals file */ * comes from the board-peripherals file */
spi->bits_per_word = 32; spi->bits_per_word = 32;
glue->reg = devm_regulator_get(&spi->dev, "vwlan");
if (PTR_ERR(glue->reg) == -EPROBE_DEFER)
return -EPROBE_DEFER;
if (IS_ERR(glue->reg)) {
dev_err(glue->dev, "can't get regulator\n");
return PTR_ERR(glue->reg);
}
ret = spi_setup(spi); ret = spi_setup(spi);
if (ret < 0) { if (ret < 0) {
dev_err(glue->dev, "spi_setup failed\n"); dev_err(glue->dev, "spi_setup failed\n");
......
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