mirror of https://gitee.com/openkylin/linux.git
[media] smiapp: Get clock rate if it's not available through DT
Obtain the clock rate from the clock framework if it's not available through DT. The assumption is that the parent device (camera module) defines the rate as clock control is a part of the power on and power off sequences --- which are camera module specific. Also use the clock rate from DT if no clock is provided. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
This commit is contained in:
parent
f689866aec
commit
de10c1619c
|
@ -2829,12 +2829,10 @@ static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev)
|
|||
/* NVM size is not mandatory */
|
||||
fwnode_property_read_u32(fwnode, "nokia,nvm-size", &hwcfg->nvm_size);
|
||||
|
||||
rval = fwnode_property_read_u32(fwnode, "clock-frequency",
|
||||
rval = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency",
|
||||
&hwcfg->ext_clk);
|
||||
if (rval) {
|
||||
dev_warn(dev, "can't get clock-frequency\n");
|
||||
goto out_err;
|
||||
}
|
||||
if (rval)
|
||||
dev_info(dev, "can't get clock-frequency\n");
|
||||
|
||||
dev_dbg(dev, "nvm %d, clk %d, mode %d\n",
|
||||
hwcfg->nvm_size, hwcfg->ext_clk, hwcfg->csi_signalling_mode);
|
||||
|
@ -2870,7 +2868,6 @@ static int smiapp_probe(struct i2c_client *client,
|
|||
{
|
||||
struct smiapp_sensor *sensor;
|
||||
struct smiapp_hwconfig *hwcfg = smiapp_get_hwconfig(&client->dev);
|
||||
unsigned long rate;
|
||||
unsigned int i;
|
||||
int rval;
|
||||
|
||||
|
@ -2901,20 +2898,37 @@ static int smiapp_probe(struct i2c_client *client,
|
|||
return -EPROBE_DEFER;
|
||||
}
|
||||
|
||||
rval = clk_set_rate(sensor->ext_clk, sensor->hwcfg->ext_clk);
|
||||
if (rval < 0) {
|
||||
dev_err(&client->dev,
|
||||
"unable to set clock freq to %u\n",
|
||||
sensor->hwcfg->ext_clk);
|
||||
return rval;
|
||||
}
|
||||
if (sensor->ext_clk) {
|
||||
if (sensor->hwcfg->ext_clk) {
|
||||
unsigned long rate;
|
||||
|
||||
rate = clk_get_rate(sensor->ext_clk);
|
||||
if (rate != sensor->hwcfg->ext_clk) {
|
||||
dev_err(&client->dev,
|
||||
"can't set clock freq, asked for %u but got %lu\n",
|
||||
sensor->hwcfg->ext_clk, rate);
|
||||
return rval;
|
||||
rval = clk_set_rate(sensor->ext_clk,
|
||||
sensor->hwcfg->ext_clk);
|
||||
if (rval < 0) {
|
||||
dev_err(&client->dev,
|
||||
"unable to set clock freq to %u\n",
|
||||
sensor->hwcfg->ext_clk);
|
||||
return rval;
|
||||
}
|
||||
|
||||
rate = clk_get_rate(sensor->ext_clk);
|
||||
if (rate != sensor->hwcfg->ext_clk) {
|
||||
dev_err(&client->dev,
|
||||
"can't set clock freq, asked for %u but got %lu\n",
|
||||
sensor->hwcfg->ext_clk, rate);
|
||||
return rval;
|
||||
}
|
||||
} else {
|
||||
sensor->hwcfg->ext_clk = clk_get_rate(sensor->ext_clk);
|
||||
dev_dbg(&client->dev, "obtained clock freq %u\n",
|
||||
sensor->hwcfg->ext_clk);
|
||||
}
|
||||
} else if (sensor->hwcfg->ext_clk) {
|
||||
dev_dbg(&client->dev, "assuming clock freq %u\n",
|
||||
sensor->hwcfg->ext_clk);
|
||||
} else {
|
||||
dev_err(&client->dev, "unable to obtain clock freq\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
sensor->xshutdown = devm_gpiod_get_optional(&client->dev, "xshutdown",
|
||||
|
|
Loading…
Reference in New Issue