Commit 0d814017 authored by Bryan O'Donoghue's avatar Bryan O'Donoghue Committed by Mauro Carvalho Chehab

media: camss: Add regulator_bulk support

Add the ability to enable or disable multiple regulators in bulk with
camss. This is useful for sm8250, sdm845 and it looks like sdm660 where we
have more than one CSI regulator to do at once.

It should just work for standalone existing vdda regulators and parts which
don't have an explicitly defined CSI regulator.

[hverkuil: fix camss-csid.c:163:13: warning: 'ret' may be used uninitialized in this function]
Reported-by: default avatarVladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Signed-off-by: default avatarBryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: default avatarRobert Foss <robert.foss@linaro.org>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent 088c0384
...@@ -160,7 +160,7 @@ static int csid_set_power(struct v4l2_subdev *sd, int on) ...@@ -160,7 +160,7 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)
struct device *dev = camss->dev; struct device *dev = camss->dev;
struct vfe_device *vfe = &camss->vfe[csid->id]; struct vfe_device *vfe = &camss->vfe[csid->id];
u32 version = camss->version; u32 version = camss->version;
int ret; int ret = 0;
if (on) { if (on) {
if (version == CAMSS_8250 || version == CAMSS_845) { if (version == CAMSS_8250 || version == CAMSS_845) {
...@@ -173,7 +173,8 @@ static int csid_set_power(struct v4l2_subdev *sd, int on) ...@@ -173,7 +173,8 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = csid->vdda ? regulator_enable(csid->vdda) : 0; ret = regulator_bulk_enable(csid->num_supplies,
csid->supplies);
if (ret < 0) { if (ret < 0) {
pm_runtime_put_sync(dev); pm_runtime_put_sync(dev);
return ret; return ret;
...@@ -181,16 +182,16 @@ static int csid_set_power(struct v4l2_subdev *sd, int on) ...@@ -181,16 +182,16 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)
ret = csid_set_clock_rates(csid); ret = csid_set_clock_rates(csid);
if (ret < 0) { if (ret < 0) {
if (csid->vdda) regulator_bulk_disable(csid->num_supplies,
regulator_disable(csid->vdda); csid->supplies);
pm_runtime_put_sync(dev); pm_runtime_put_sync(dev);
return ret; return ret;
} }
ret = camss_enable_clocks(csid->nclocks, csid->clock, dev); ret = camss_enable_clocks(csid->nclocks, csid->clock, dev);
if (ret < 0) { if (ret < 0) {
if (csid->vdda) regulator_bulk_disable(csid->num_supplies,
regulator_disable(csid->vdda); csid->supplies);
pm_runtime_put_sync(dev); pm_runtime_put_sync(dev);
return ret; return ret;
} }
...@@ -201,8 +202,8 @@ static int csid_set_power(struct v4l2_subdev *sd, int on) ...@@ -201,8 +202,8 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)
if (ret < 0) { if (ret < 0) {
disable_irq(csid->irq); disable_irq(csid->irq);
camss_disable_clocks(csid->nclocks, csid->clock); camss_disable_clocks(csid->nclocks, csid->clock);
if (csid->vdda) regulator_bulk_disable(csid->num_supplies,
regulator_disable(csid->vdda); csid->supplies);
pm_runtime_put_sync(dev); pm_runtime_put_sync(dev);
return ret; return ret;
} }
...@@ -211,7 +212,8 @@ static int csid_set_power(struct v4l2_subdev *sd, int on) ...@@ -211,7 +212,8 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)
} else { } else {
disable_irq(csid->irq); disable_irq(csid->irq);
camss_disable_clocks(csid->nclocks, csid->clock); camss_disable_clocks(csid->nclocks, csid->clock);
ret = csid->vdda ? regulator_disable(csid->vdda) : 0; regulator_bulk_disable(csid->num_supplies,
csid->supplies);
pm_runtime_put_sync(dev); pm_runtime_put_sync(dev);
if (version == CAMSS_8250 || version == CAMSS_845) if (version == CAMSS_8250 || version == CAMSS_845)
vfe_put(vfe); vfe_put(vfe);
...@@ -656,15 +658,28 @@ int msm_csid_subdev_init(struct camss *camss, struct csid_device *csid, ...@@ -656,15 +658,28 @@ int msm_csid_subdev_init(struct camss *camss, struct csid_device *csid,
} }
/* Regulator */ /* Regulator */
for (i = 0; i < ARRAY_SIZE(res->regulators); i++) {
if (res->regulators[i])
csid->num_supplies++;
}
csid->vdda = NULL; if (csid->num_supplies) {
if (res->regulator[0]) csid->supplies = devm_kmalloc_array(camss->dev,
csid->vdda = devm_regulator_get(dev, res->regulator[0]); csid->num_supplies,
if (IS_ERR(csid->vdda)) { sizeof(csid->supplies),
dev_err(dev, "could not get regulator\n"); GFP_KERNEL);
return PTR_ERR(csid->vdda); if (!csid->supplies)
return -ENOMEM;
} }
for (i = 0; i < csid->num_supplies; i++)
csid->supplies[i].supply = res->regulators[i];
ret = devm_regulator_bulk_get(camss->dev, csid->num_supplies,
csid->supplies);
if (ret)
return ret;
init_completion(&csid->reset_complete); init_completion(&csid->reset_complete);
return 0; return 0;
......
...@@ -152,7 +152,8 @@ struct csid_device { ...@@ -152,7 +152,8 @@ struct csid_device {
char irq_name[30]; char irq_name[30];
struct camss_clock *clock; struct camss_clock *clock;
int nclocks; int nclocks;
struct regulator *vdda; struct regulator_bulk_data *supplies;
int num_supplies;
struct completion reset_complete; struct completion reset_complete;
struct csid_testgen_config testgen; struct csid_testgen_config testgen;
struct csid_phy_config phy; struct csid_phy_config phy;
......
This diff is collapsed.
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
#define CAMSS_RES_MAX 17 #define CAMSS_RES_MAX 17
struct resources { struct resources {
char *regulator[CAMSS_RES_MAX]; char *regulators[CAMSS_RES_MAX];
char *clock[CAMSS_RES_MAX]; char *clock[CAMSS_RES_MAX];
u32 clock_rate[CAMSS_RES_MAX][CAMSS_RES_MAX]; u32 clock_rate[CAMSS_RES_MAX][CAMSS_RES_MAX];
char *reg[CAMSS_RES_MAX]; char *reg[CAMSS_RES_MAX];
......
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