Commit c30f4cb2 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Mauro Carvalho Chehab

media: atomisp: Refactor PMIC detection to a separate function

Refactor PMIC detection to a separate function. In the future
we may move this code somewhere else where it's more suitable.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent e4fb745c
...@@ -478,7 +478,38 @@ static int atomisp_get_acpi_power(struct device *dev, acpi_handle handle) ...@@ -478,7 +478,38 @@ static int atomisp_get_acpi_power(struct device *dev, acpi_handle handle)
return clock_num; return clock_num;
} }
static struct i2c_client *power; static u8 gmin_get_pmic_id_and_addr(struct device *dev)
{
struct i2c_client *power;
static u8 pmic_i2c_addr;
if (pmic_id)
return pmic_i2c_addr;
if (gmin_i2c_dev_exists(dev, PMIC_ACPI_TI, &power))
pmic_id = PMIC_TI;
else if (gmin_i2c_dev_exists(dev, PMIC_ACPI_AXP, &power))
pmic_id = PMIC_AXP;
else if (gmin_i2c_dev_exists(dev, PMIC_ACPI_CRYSTALCOVE, &power))
pmic_id = PMIC_CRYSTALCOVE;
else
pmic_id = PMIC_REGULATOR;
pmic_i2c_addr = power ? power->addr : 0;
return pmic_i2c_addr;
}
static int gmin_detect_pmic(struct v4l2_subdev *subdev)
{
struct i2c_client *client = v4l2_get_subdevdata(subdev);
struct device *dev = &client->dev;
u8 pmic_i2c_addr;
pmic_i2c_addr = gmin_get_pmic_id_and_addr(dev);
dev_info(dev, "gmin: power management provided via %s (i2c addr 0x%02x)\n",
pmic_name[pmic_id], pmic_i2c_addr);
return pmic_i2c_addr;
}
static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev) static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev)
{ {
...@@ -580,27 +611,6 @@ static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev) ...@@ -580,27 +611,6 @@ static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev)
* in order to set clocks and do power management. * in order to set clocks and do power management.
*/ */
if (!pmic_id) {
if (gmin_i2c_dev_exists(dev, PMIC_ACPI_TI, &power))
pmic_id = PMIC_TI;
else if (gmin_i2c_dev_exists(dev, PMIC_ACPI_AXP, &power))
pmic_id = PMIC_AXP;
else if (gmin_i2c_dev_exists(dev, PMIC_ACPI_CRYSTALCOVE, &power))
pmic_id = PMIC_CRYSTALCOVE;
else
pmic_id = PMIC_REGULATOR;
}
if (power) {
gs->pwm_i2c_addr = power->addr;
dev_info(dev,
"gmin: power management provided via %s (i2c addr 0x%02x)\n",
pmic_name[pmic_id], power->addr);
} else {
dev_info(dev, "gmin: power management provided via %s\n",
pmic_name[pmic_id]);
}
/* /*
* According with : * According with :
* https://github.com/projectceladon/hardware-intel-kernelflinger/blob/master/doc/fastboot.md * https://github.com/projectceladon/hardware-intel-kernelflinger/blob/master/doc/fastboot.md
...@@ -1053,10 +1063,13 @@ struct camera_sensor_platform_data *gmin_camera_platform_data( ...@@ -1053,10 +1063,13 @@ struct camera_sensor_platform_data *gmin_camera_platform_data(
enum atomisp_input_format csi_format, enum atomisp_input_format csi_format,
enum atomisp_bayer_order csi_bayer) enum atomisp_bayer_order csi_bayer)
{ {
struct gmin_subdev *gs = gmin_subdev_add(subdev); struct gmin_subdev *gs;
u8 pmic_i2c_addr = gmin_detect_pmic(subdev);
gs = gmin_subdev_add(subdev);
gs->csi_fmt = csi_format; gs->csi_fmt = csi_format;
gs->csi_bayer = csi_bayer; gs->csi_bayer = csi_bayer;
gs->pwm_i2c_addr = pmic_i2c_addr;
if (gs->pmc_clk) if (gs->pmc_clk)
return &pmic_gmin_plat; return &pmic_gmin_plat;
......
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