1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Support for Medifield PNW Camera Imaging ISP subsystem.
5 * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License version
9 * 2 as published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
18 #ifndef __ATOMISP_CSI2_H__
19 #define __ATOMISP_CSI2_H__
21 #include <linux/gpio/consumer.h>
22 #include <linux/property.h>
24 #include <media/v4l2-subdev.h>
25 #include <media/v4l2-ctrls.h>
27 #include "../../include/linux/atomisp.h"
29 #define CSI2_PAD_SINK 0
30 #define CSI2_PAD_SOURCE 1
31 #define CSI2_PADS_NUM 2
33 #define CSI2_MAX_LANES 4
34 #define CSI2_MAX_LINK_FREQS 3
36 #define CSI2_MAX_ACPI_GPIOS 2u
41 struct atomisp_device;
42 struct atomisp_sub_device;
44 struct atomisp_csi2_acpi_gpio_map {
45 struct acpi_gpio_params params[CSI2_MAX_ACPI_GPIOS];
46 struct acpi_gpio_mapping mapping[CSI2_MAX_ACPI_GPIOS + 1];
49 struct atomisp_csi2_acpi_gpio_parsing_data {
50 struct acpi_device *adev;
51 struct atomisp_csi2_acpi_gpio_map *map;
52 u32 settings[CSI2_MAX_ACPI_GPIOS];
53 unsigned int settings_count;
54 unsigned int res_count;
55 unsigned int map_count;
58 enum atomisp_csi2_sensor_swnodes {
61 SWNODE_SENSOR_ENDPOINT,
67 struct atomisp_csi2_property_names {
68 char clock_frequency[16];
72 char remote_endpoint[16];
73 char link_frequencies[17];
76 struct atomisp_csi2_node_names {
82 struct atomisp_csi2_sensor_config {
86 u64 link_freqs[CSI2_MAX_LINK_FREQS];
89 struct atomisp_csi2_sensor {
90 /* Append port in "-%u" format as suffix of HID */
91 char name[ACPI_ID_LEN + 4];
92 struct acpi_device *adev;
96 /* SWNODE_COUNT + 1 for terminating NULL */
97 const struct software_node *group[SWNODE_COUNT + 1];
98 struct software_node swnodes[SWNODE_COUNT];
99 struct atomisp_csi2_node_names node_names;
100 struct atomisp_csi2_property_names prop_names;
101 /* "clock-frequency", "rotation" + terminating entry */
102 struct property_entry dev_properties[3];
103 /* "bus-type", "data-lanes", "remote-endpoint" + "link-freq" + terminating entry */
104 struct property_entry ep_properties[5];
105 /* "data-lanes", "remote-endpoint" + terminating entry */
106 struct property_entry csi2_properties[3];
107 struct software_node_ref_args local_ref[1];
108 struct software_node_ref_args remote_ref[1];
109 struct software_node_ref_args vcm_ref[1];
110 /* GPIO mappings storage */
111 struct atomisp_csi2_acpi_gpio_map gpio_map;
114 struct atomisp_csi2_bridge {
115 struct software_node csi2_node;
116 char csi2_node_name[14];
117 u32 data_lanes[CSI2_MAX_LANES];
118 unsigned int n_sensors;
119 struct atomisp_csi2_sensor sensors[ATOMISP_CAMERA_NR_PORTS];
122 struct atomisp_mipi_csi2_device {
123 struct v4l2_subdev subdev;
124 struct media_pad pads[CSI2_PADS_NUM];
125 struct v4l2_mbus_framefmt formats[CSI2_PADS_NUM];
127 struct v4l2_ctrl_handler ctrls;
128 struct atomisp_device *isp;
131 int atomisp_csi2_set_ffmt(struct v4l2_subdev *sd,
132 struct v4l2_subdev_state *sd_state,
133 unsigned int which, uint16_t pad,
134 struct v4l2_mbus_framefmt *ffmt);
135 int atomisp_mipi_csi2_init(struct atomisp_device *isp);
136 void atomisp_mipi_csi2_cleanup(struct atomisp_device *isp);
137 void atomisp_mipi_csi2_unregister_entities(
138 struct atomisp_mipi_csi2_device *csi2);
139 int atomisp_mipi_csi2_register_entities(struct atomisp_mipi_csi2_device *csi2,
140 struct v4l2_device *vdev);
141 int atomisp_csi2_bridge_init(struct atomisp_device *isp);
142 int atomisp_csi2_bridge_parse_firmware(struct atomisp_device *isp);
144 void atomisp_csi2_configure(struct atomisp_sub_device *asd);
146 #endif /* __ATOMISP_CSI2_H__ */