media: qcom: camss: add management of supply regulators to CSIPHY

This change allows to properly assign and manage supply regulator
resources by CSIPHY subdevices of CAMSS, this is needed to fine tune
description of supply regulators on newer platforms, conversion of
old platforms to the new scheme is also anticipated.

Signed-off-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Tested-by: Depeng Shao <quic_depengs@quicinc.com> # SM8550
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
This commit is contained in:
Vladimir Zapolskiy 2024-09-27 00:19:56 +03:00 committed by Hans Verkuil
parent 288db22ef9
commit 44fdbb9d1a
2 changed files with 36 additions and 1 deletions

View File

@ -212,14 +212,25 @@ static int csiphy_set_power(struct v4l2_subdev *sd, int on)
if (ret < 0)
return ret;
ret = regulator_bulk_enable(csiphy->num_supplies,
csiphy->supplies);
if (ret < 0) {
pm_runtime_put_sync(dev);
return ret;
}
ret = csiphy_set_clock_rates(csiphy);
if (ret < 0) {
regulator_bulk_disable(csiphy->num_supplies,
csiphy->supplies);
pm_runtime_put_sync(dev);
return ret;
}
ret = camss_enable_clocks(csiphy->nclocks, csiphy->clock, dev);
if (ret < 0) {
regulator_bulk_disable(csiphy->num_supplies,
csiphy->supplies);
pm_runtime_put_sync(dev);
return ret;
}
@ -234,6 +245,8 @@ static int csiphy_set_power(struct v4l2_subdev *sd, int on)
camss_disable_clocks(csiphy->nclocks, csiphy->clock);
regulator_bulk_disable(csiphy->num_supplies, csiphy->supplies);
pm_runtime_put_sync(dev);
}
@ -676,7 +689,27 @@ int msm_csiphy_subdev_init(struct camss *camss,
}
}
return 0;
/* CSIPHY supplies */
for (i = 0; i < ARRAY_SIZE(res->regulators); i++) {
if (res->regulators[i])
csiphy->num_supplies++;
}
if (csiphy->num_supplies) {
csiphy->supplies = devm_kmalloc_array(camss->dev,
csiphy->num_supplies,
sizeof(*csiphy->supplies),
GFP_KERNEL);
if (!csiphy->supplies)
return -ENOMEM;
}
for (i = 0; i < csiphy->num_supplies; i++)
csiphy->supplies[i].supply = res->regulators[i];
ret = devm_regulator_bulk_get(camss->dev, csiphy->num_supplies,
csiphy->supplies);
return ret;
}
/*

View File

@ -91,6 +91,8 @@ struct csiphy_device {
bool *rate_set;
int nclocks;
u32 timer_clk_rate;
struct regulator_bulk_data *supplies;
int num_supplies;
struct csiphy_config cfg;
struct v4l2_mbus_framefmt fmt[MSM_CSIPHY_PADS_NUM];
const struct csiphy_subdev_resources *res;