Commit f88fba1a authored by Hans de Goede's avatar Hans de Goede Committed by Mauro Carvalho Chehab
Browse files

media: atomisp_gmin_platform: Base CsiPort default on detected CLK

On devices with 2 cameras and no _DSM / EFI-vars providing CsiPort
clock info, defaulting to CsiPort 0 obviously is wrong for 1 of the
2 cameras.

The Intel Cherry Trail (ISP2401) reference design combines:
 pmc_plt_clk_2 with CsiPort 0
 pmc_plt_clk_4 with CsiPort 1

The Intel Bay Trail (ISP2400) reference design combines:
 pmc_plt_clk_1 with CsiPort 0
 pmc_plt_clk_0 with CsiPort 1

Use this knowledge to set the default CsiPort value based on
the detected CLK for the sensor.

Link: https://lore.kernel.org/linux-media/20220116215204.307649-9-hdegoede@redhat.com


Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent ee328dde
Loading
Loading
Loading
Loading
+16 −7
Original line number Diff line number Diff line
@@ -540,7 +540,7 @@ static int gmin_subdev_add(struct gmin_subdev *gs)
	struct i2c_client *client = v4l2_get_subdevdata(gs->subdev);
	struct device *dev = &client->dev;
	struct acpi_device *adev = ACPI_COMPANION(dev);
	int ret, clock_num = -1;
	int ret, default_val, clock_num = -1;

	dev_info(dev, "%s: ACPI path is %pfw\n", __func__, dev_fwnode(dev));

@@ -548,7 +548,20 @@ static int gmin_subdev_add(struct gmin_subdev *gs)
	gs->clock_src = gmin_get_var_int(dev, false, "ClkSrc",
				         VLV2_CLK_PLL_19P2MHZ);

	gs->csi_port = gmin_get_var_int(dev, false, "CsiPort", 0);
	/*
	 * Get ACPI _PR0 derived clock here already because it is used
	 * to determine the csi_port default.
	 */
	if (acpi_device_power_manageable(adev))
		clock_num = atomisp_get_acpi_power(dev);

	/* Compare clock to CsiPort 1 pmc-clock used in the CHT/BYT reference designs */
	if (IS_ISP2401)
		default_val = clock_num == 4 ? 1 : 0;
	else
		default_val = clock_num == 0 ? 1 : 0;

	gs->csi_port = gmin_get_var_int(dev, false, "CsiPort", default_val);
	gs->csi_lanes = gmin_get_var_int(dev, false, "CsiLanes", 1);

	gs->gpio0 = gpiod_get_index(dev, NULL, 0, GPIOD_OUT_LOW);
@@ -629,11 +642,7 @@ static int gmin_subdev_add(struct gmin_subdev *gs)
	 * otherwise.
	 */

	/* Try first to use ACPI to get the clock resource */
	if (acpi_device_power_manageable(adev))
		clock_num = atomisp_get_acpi_power(dev);

	/* Fall-back use EFI and/or DMI match */
	/* If getting the clock from _PR0 above failed, fall-back to EFI and/or DMI match */
	if (clock_num < 0)
		clock_num = gmin_get_var_int(dev, false, "CamClk", 0);