Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit de10c161 authored by Sakari Ailus's avatar Sakari Ailus Committed by Mauro Carvalho Chehab
Browse files

[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: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent f689866a
Loading
Loading
Loading
Loading
+33 −19
Original line number Diff line number Diff line
@@ -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,7 +2898,12 @@ static int smiapp_probe(struct i2c_client *client,
		return -EPROBE_DEFER;
	}

	rval = clk_set_rate(sensor->ext_clk, sensor->hwcfg->ext_clk);
	if (sensor->ext_clk) {
		if (sensor->hwcfg->ext_clk) {
			unsigned long rate;

			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",
@@ -2916,6 +2918,18 @@ static int smiapp_probe(struct i2c_client *client,
					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",
						    GPIOD_OUT_LOW);