linux/drivers/staging/media/atomisp/pci/atomisp_csi2_bridge.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Code to build software firmware node graph for atomisp2 connected sensors
 * from ACPI tables.
 *
 * Copyright (C) 2023 Hans de Goede <[email protected]>
 *
 * Based on drivers/media/pci/intel/ipu3/cio2-bridge.c written by:
 * Dan Scally <[email protected]>
 */

#include <linux/acpi.h>
#include <linux/clk.h>
#include <linux/device.h>
#include <linux/dmi.h>
#include <linux/property.h>

#include <media/ipu-bridge.h>
#include <media/v4l2-fwnode.h>

#include "atomisp_cmd.h"
#include "atomisp_csi2.h"
#include "atomisp_internal.h"

#define PMC_CLK_RATE_19_2MHZ

/*
 * 79234640-9e10-4fea-a5c1-b5aa8b19756f
 * This _DSM GUID returns information about the GPIO lines mapped to a sensor.
 * Function number 1 returns a count of the GPIO lines that are mapped.
 * Subsequent functions return 32 bit ints encoding information about the GPIO.
 */
static const guid_t intel_sensor_gpio_info_guid =;

#define INTEL_GPIO_DSM_TYPE_SHIFT
#define INTEL_GPIO_DSM_TYPE_MASK
#define INTEL_GPIO_DSM_PIN_SHIFT
#define INTEL_GPIO_DSM_PIN_MASK
#define INTEL_GPIO_DSM_SENSOR_ON_VAL_SHIFT
#define INTEL_GPIO_DSM_SENSOR_ON_VAL_MASK

#define INTEL_GPIO_DSM_TYPE(x)
#define INTEL_GPIO_DSM_PIN(x)
#define INTEL_GPIO_DSM_SENSOR_ON_VAL(x)

/*
 * 822ace8f-2814-4174-a56b-5f029fe079ee
 * This _DSM GUID returns a string from the sensor device, which acts as a
 * module identifier.
 */
static const guid_t intel_sensor_module_guid =;

/*
 * dc2f6c4f-045b-4f1d-97b9-882a6860a4be
 * This _DSM GUID returns a package with n*2 strings, with each set of 2 strings
 * forming a key, value pair for settings like e.g. "CsiLanes" = "1".
 */
static const guid_t atomisp_dsm_guid =;

/*
 * 75c9a639-5c8a-4a00-9f48-a9c3b5da789f
 * This _DSM GUID returns a string giving the VCM type e.g. "AD5823".
 */
static const guid_t vcm_dsm_guid =;

struct atomisp_sensor_config {};

#define ATOMISP_SENSOR_CONFIG(_HID, _LANES, _VCM)

/*
 * gmin_cfg parsing code. This is a cleaned up version of the gmin_cfg parsing
 * code from atomisp_gmin_platform.c.
 * Once all sensors are moved to v4l2-async probing atomisp_gmin_platform.c can
 * be removed and the duplication of this code goes away.
 */
struct gmin_cfg_var {};

static struct gmin_cfg_var lenovo_ideapad_miix_310_vars[] =;

static struct gmin_cfg_var xiaomi_mipad2_vars[] =;

static const struct dmi_system_id gmin_cfg_dmi_overrides[] =;

static char *gmin_cfg_get_dsm(struct acpi_device *adev, const char *key)
{}

static char *gmin_cfg_get_dmi_override(struct acpi_device *adev, const char *key)
{}

static char *gmin_cfg_get(struct acpi_device *adev, const char *key)
{}

static int gmin_cfg_get_int(struct acpi_device *adev, const char *key, int default_val)
{}

static int atomisp_csi2_get_pmc_clk_nr_from_acpi_pr0(struct acpi_device *adev)
{}

static int atomisp_csi2_set_pmc_clk_freq(struct acpi_device *adev, int clock_num)
{}

static int atomisp_csi2_get_port(struct acpi_device *adev, int clock_num)
{}

/* Note this always returns 1 to continue looping so that res_count is accurate */
static int atomisp_csi2_handle_acpi_gpio_res(struct acpi_resource *ares, void *_data)
{}

/*
 * Helper function to create an ACPI GPIO lookup table for sensor reset and
 * powerdown signals on Intel Bay Trail (BYT) and Cherry Trail (CHT) devices,
 * including setting the correct polarity for the GPIO.
 *
 * This uses the "79234640-9e10-4fea-a5c1-b5aa8b19756f" DSM method directly
 * on the sensor device's ACPI node. This is different from later Intel
 * hardware which has a separate INT3472 acpi_device with this info.
 *
 * This function must be called before creating the sw-noded describing
 * the fwnode graph endpoint. And sensor drivers used on these devices
 * must return -EPROBE_DEFER when there is no endpoint description yet.
 * Together this guarantees that the GPIO lookups are in place before
 * the sensor driver tries to get GPIOs with gpiod_get().
 *
 * Note this code uses the same DSM GUID as the int3472_gpio_guid in
 * the INT3472 discrete.c code and there is some overlap, but there are
 * enough differences that it is difficult to share the code.
 */
static int atomisp_csi2_add_gpio_mappings(struct acpi_device *adev)
{}

static char *atomisp_csi2_get_vcm_type(struct acpi_device *adev)
{}

static const struct acpi_device_id atomisp_sensor_configs[] =;

static int atomisp_csi2_parse_sensor_fwnode(struct acpi_device *adev,
					    struct ipu_sensor *sensor)
{}

int atomisp_csi2_bridge_init(struct atomisp_device *isp)
{}

/******* V4L2 sub-device asynchronous registration callbacks***********/

struct sensor_async_subdev {};

#define to_sensor_asd(a)
#define notifier_to_atomisp(n)

/* .bound() notifier callback when a match is found */
static int atomisp_notifier_bound(struct v4l2_async_notifier *notifier,
				  struct v4l2_subdev *sd,
				  struct v4l2_async_connection *asd)
{}

/* The .unbind callback */
static void atomisp_notifier_unbind(struct v4l2_async_notifier *notifier,
				    struct v4l2_subdev *sd,
				    struct v4l2_async_connection *asd)
{}

/* .complete() is called after all subdevices have been located */
static int atomisp_notifier_complete(struct v4l2_async_notifier *notifier)
{}

static const struct v4l2_async_notifier_operations atomisp_async_ops =;

int atomisp_csi2_bridge_parse_firmware(struct atomisp_device *isp)
{}