summaryrefslogtreecommitdiffstats
path: root/drivers/media/spi/cxd2880-spi.c
diff options
context:
space:
mode:
authorNeil Armstrong <narmstrong@baylibre.com>2018-11-08 07:50:09 -0500
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>2018-12-03 13:33:16 -0500
commitcb496cd472af3ec922063c14fd71a72db4467f6f (patch)
tree444c9ccefb920bb30f940c8b9f6632fb502583e2 /drivers/media/spi/cxd2880-spi.c
parent6c0943cdb54d77989126339e8ea44d91b33dda15 (diff)
downloadlinux-cb496cd472af3ec922063c14fd71a72db4467f6f.tar.gz
linux-cb496cd472af3ec922063c14fd71a72db4467f6f.tar.bz2
linux-cb496cd472af3ec922063c14fd71a72db4467f6f.zip
media: cxd2880-spi: Add optional vcc regulator
This patchset adds an optional VCC regulator to the driver probe function to make sure power is enabled to the module before starting attaching to the device. Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> Acked-by: Yasunari Takiguchi <Yasunari.Takiguchi@sony.com> Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Diffstat (limited to 'drivers/media/spi/cxd2880-spi.c')
-rw-r--r--drivers/media/spi/cxd2880-spi.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/media/spi/cxd2880-spi.c b/drivers/media/spi/cxd2880-spi.c
index c43730977f53..d5c433e20d4a 100644
--- a/drivers/media/spi/cxd2880-spi.c
+++ b/drivers/media/spi/cxd2880-spi.c
@@ -10,6 +10,7 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": %s: " fmt, __func__
#include <linux/spi/spi.h>
+#include <linux/regulator/consumer.h>
#include <linux/ktime.h>
#include <media/dvb_demux.h>
@@ -51,6 +52,7 @@ struct cxd2880_dvb_spi {
struct mutex spi_mutex; /* For SPI access exclusive control */
int feed_count;
int all_pid_feed_count;
+ struct regulator *vcc_supply;
u8 *ts_buf;
struct cxd2880_pid_filter_config filter_config;
};
@@ -518,6 +520,17 @@ cxd2880_spi_probe(struct spi_device *spi)
if (!dvb_spi)
return -ENOMEM;
+ dvb_spi->vcc_supply = devm_regulator_get_optional(&spi->dev, "vcc");
+ if (IS_ERR(dvb_spi->vcc_supply)) {
+ if (PTR_ERR(dvb_spi->vcc_supply) == -EPROBE_DEFER)
+ return -EPROBE_DEFER;
+ dvb_spi->vcc_supply = NULL;
+ } else {
+ ret = regulator_enable(dvb_spi->vcc_supply);
+ if (ret)
+ return ret;
+ }
+
dvb_spi->spi = spi;
mutex_init(&dvb_spi->spi_mutex);
dev_set_drvdata(&spi->dev, dvb_spi);
@@ -631,6 +644,9 @@ cxd2880_spi_remove(struct spi_device *spi)
dvb_frontend_detach(&dvb_spi->dvb_fe);
dvb_unregister_adapter(&dvb_spi->adapter);
+ if (dvb_spi->vcc_supply)
+ regulator_disable(dvb_spi->vcc_supply);
+
kfree(dvb_spi);
pr_info("cxd2880_spi remove ok.\n");