2021-01-07 08:28:38 -05:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
/* Author: Dan Scally <djrscally@gmail.com> */
|
2023-05-18 06:05:21 -04:00
|
|
|
#ifndef __IPU_BRIDGE_H
|
|
|
|
#define __IPU_BRIDGE_H
|
2021-01-07 08:28:38 -05:00
|
|
|
|
|
|
|
#include <linux/property.h>
|
|
|
|
#include <linux/types.h>
|
2023-07-05 17:30:00 -04:00
|
|
|
#include <media/v4l2-fwnode.h>
|
2021-01-07 08:28:38 -05:00
|
|
|
|
2023-05-18 06:05:21 -04:00
|
|
|
#define IPU_HID "INT343E"
|
|
|
|
#define IPU_MAX_LANES 4
|
2023-05-18 06:05:22 -04:00
|
|
|
#define IPU_MAX_PORTS 4
|
2021-01-07 08:28:38 -05:00
|
|
|
#define MAX_NUM_LINK_FREQS 3
|
|
|
|
|
2021-07-12 05:03:26 -04:00
|
|
|
/* Values are educated guesses as we don't have a spec */
|
2023-05-18 06:05:21 -04:00
|
|
|
#define IPU_SENSOR_ROTATION_NORMAL 0
|
|
|
|
#define IPU_SENSOR_ROTATION_INVERTED 1
|
2021-07-12 05:03:26 -04:00
|
|
|
|
2023-05-18 06:05:21 -04:00
|
|
|
#define IPU_SENSOR_CONFIG(_HID, _NR, ...) \
|
|
|
|
(const struct ipu_sensor_config) { \
|
2021-01-07 08:28:38 -05:00
|
|
|
.hid = _HID, \
|
|
|
|
.nr_link_freqs = _NR, \
|
|
|
|
.link_freqs = { __VA_ARGS__ } \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NODE_SENSOR(_HID, _PROPS) \
|
|
|
|
(const struct software_node) { \
|
|
|
|
.name = _HID, \
|
|
|
|
.properties = _PROPS, \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NODE_PORT(_PORT, _SENSOR_NODE) \
|
|
|
|
(const struct software_node) { \
|
|
|
|
.name = _PORT, \
|
|
|
|
.parent = _SENSOR_NODE, \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NODE_ENDPOINT(_EP, _PORT, _PROPS) \
|
|
|
|
(const struct software_node) { \
|
|
|
|
.name = _EP, \
|
|
|
|
.parent = _PORT, \
|
|
|
|
.properties = _PROPS, \
|
|
|
|
}
|
|
|
|
|
2021-12-03 05:28:57 -05:00
|
|
|
#define NODE_VCM(_TYPE) \
|
|
|
|
(const struct software_node) { \
|
|
|
|
.name = _TYPE, \
|
|
|
|
}
|
|
|
|
|
2023-05-18 06:05:21 -04:00
|
|
|
enum ipu_sensor_swnodes {
|
2021-01-07 08:28:38 -05:00
|
|
|
SWNODE_SENSOR_HID,
|
|
|
|
SWNODE_SENSOR_PORT,
|
|
|
|
SWNODE_SENSOR_ENDPOINT,
|
2023-05-18 06:05:21 -04:00
|
|
|
SWNODE_IPU_PORT,
|
|
|
|
SWNODE_IPU_ENDPOINT,
|
2023-08-03 01:38:14 -04:00
|
|
|
/* below are optional / maybe empty */
|
|
|
|
SWNODE_IVSC_HID,
|
|
|
|
SWNODE_IVSC_SENSOR_PORT,
|
|
|
|
SWNODE_IVSC_SENSOR_ENDPOINT,
|
|
|
|
SWNODE_IVSC_IPU_PORT,
|
|
|
|
SWNODE_IVSC_IPU_ENDPOINT,
|
2021-12-03 05:28:57 -05:00
|
|
|
SWNODE_VCM,
|
2021-01-07 08:28:38 -05:00
|
|
|
SWNODE_COUNT
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Data representation as it is in ACPI SSDB buffer */
|
2023-05-18 06:05:21 -04:00
|
|
|
struct ipu_sensor_ssdb {
|
2021-01-07 08:28:38 -05:00
|
|
|
u8 version;
|
|
|
|
u8 sku;
|
|
|
|
u8 guid_csi2[16];
|
|
|
|
u8 devfunction;
|
|
|
|
u8 bus;
|
|
|
|
u32 dphylinkenfuses;
|
|
|
|
u32 clockdiv;
|
|
|
|
u8 link;
|
|
|
|
u8 lanes;
|
|
|
|
u32 csiparams[10];
|
|
|
|
u32 maxlanespeed;
|
|
|
|
u8 sensorcalibfileidx;
|
|
|
|
u8 sensorcalibfileidxInMBZ[3];
|
|
|
|
u8 romtype;
|
|
|
|
u8 vcmtype;
|
|
|
|
u8 platforminfo;
|
|
|
|
u8 platformsubinfo;
|
|
|
|
u8 flash;
|
|
|
|
u8 privacyled;
|
|
|
|
u8 degree;
|
|
|
|
u8 mipilinkdefined;
|
|
|
|
u32 mclkspeed;
|
|
|
|
u8 controllogicid;
|
|
|
|
u8 reserved1[3];
|
|
|
|
u8 mclkport;
|
|
|
|
u8 reserved2[13];
|
|
|
|
} __packed;
|
|
|
|
|
2023-05-18 06:05:21 -04:00
|
|
|
struct ipu_property_names {
|
2021-01-07 08:28:38 -05:00
|
|
|
char clock_frequency[16];
|
|
|
|
char rotation[9];
|
2021-07-12 05:03:26 -04:00
|
|
|
char orientation[12];
|
2021-01-07 08:28:38 -05:00
|
|
|
char bus_type[9];
|
|
|
|
char data_lanes[11];
|
|
|
|
char remote_endpoint[16];
|
|
|
|
char link_frequencies[17];
|
|
|
|
};
|
|
|
|
|
2023-05-18 06:05:21 -04:00
|
|
|
struct ipu_node_names {
|
2021-01-07 08:28:38 -05:00
|
|
|
char port[7];
|
2023-08-03 01:38:14 -04:00
|
|
|
char ivsc_sensor_port[7];
|
|
|
|
char ivsc_ipu_port[7];
|
2021-01-07 08:28:38 -05:00
|
|
|
char endpoint[11];
|
media: ipu-bridge: increase sensor_name size
Fixes this compiler warning:
In file included from include/linux/property.h:14,
from include/linux/acpi.h:16,
from drivers/media/pci/intel/ipu-bridge.c:4:
In function 'ipu_bridge_init_swnode_names',
inlined from 'ipu_bridge_create_connection_swnodes' at drivers/media/pci/intel/ipu-bridge.c:445:2,
inlined from 'ipu_bridge_connect_sensor' at drivers/media/pci/intel/ipu-bridge.c:656:3:
include/linux/fwnode.h:81:49: warning: '%u' directive output may be truncated writing between 1 and 3 bytes into a region of size 2 [-Wformat-truncation=]
81 | #define SWNODE_GRAPH_PORT_NAME_FMT "port@%u"
| ^~~~~~~~~
drivers/media/pci/intel/ipu-bridge.c:384:18: note: in expansion of macro 'SWNODE_GRAPH_PORT_NAME_FMT'
384 | SWNODE_GRAPH_PORT_NAME_FMT, sensor->link);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/fwnode.h: In function 'ipu_bridge_connect_sensor':
include/linux/fwnode.h:81:55: note: format string is defined here
81 | #define SWNODE_GRAPH_PORT_NAME_FMT "port@%u"
| ^~
In function 'ipu_bridge_init_swnode_names',
inlined from 'ipu_bridge_create_connection_swnodes' at drivers/media/pci/intel/ipu-bridge.c:445:2,
inlined from 'ipu_bridge_connect_sensor' at drivers/media/pci/intel/ipu-bridge.c:656:3:
include/linux/fwnode.h:81:49: note: directive argument in the range [0, 255]
81 | #define SWNODE_GRAPH_PORT_NAME_FMT "port@%u"
| ^~~~~~~~~
drivers/media/pci/intel/ipu-bridge.c:384:18: note: in expansion of macro 'SWNODE_GRAPH_PORT_NAME_FMT'
384 | SWNODE_GRAPH_PORT_NAME_FMT, sensor->link);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/media/pci/intel/ipu-bridge.c:382:9: note: 'snprintf' output between 7 and 9 bytes into a destination of size 7
382 | snprintf(sensor->node_names.remote_port,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
383 | sizeof(sensor->node_names.remote_port),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
384 | SWNODE_GRAPH_PORT_NAME_FMT, sensor->link);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Acked-by: Arnd Bergmann <arnd@arndb.de>
2023-09-23 11:20:49 -04:00
|
|
|
char remote_port[9];
|
2023-07-05 17:29:54 -04:00
|
|
|
char vcm[16];
|
2021-01-07 08:28:38 -05:00
|
|
|
};
|
|
|
|
|
2023-05-18 06:05:21 -04:00
|
|
|
struct ipu_sensor_config {
|
2021-01-07 08:28:38 -05:00
|
|
|
const char *hid;
|
|
|
|
const u8 nr_link_freqs;
|
|
|
|
const u64 link_freqs[MAX_NUM_LINK_FREQS];
|
|
|
|
};
|
|
|
|
|
2023-05-18 06:05:21 -04:00
|
|
|
struct ipu_sensor {
|
2023-03-10 10:19:10 -05:00
|
|
|
/* append ssdb.link(u8) in "-%u" format as suffix of HID */
|
|
|
|
char name[ACPI_ID_LEN + 4];
|
2021-01-07 08:28:38 -05:00
|
|
|
struct acpi_device *adev;
|
|
|
|
|
2023-08-03 01:38:14 -04:00
|
|
|
struct device *csi_dev;
|
|
|
|
struct acpi_device *ivsc_adev;
|
|
|
|
char ivsc_name[ACPI_ID_LEN + 4];
|
|
|
|
|
2022-12-28 04:49:20 -05:00
|
|
|
/* SWNODE_COUNT + 1 for terminating NULL */
|
|
|
|
const struct software_node *group[SWNODE_COUNT + 1];
|
|
|
|
struct software_node swnodes[SWNODE_COUNT];
|
2023-05-18 06:05:21 -04:00
|
|
|
struct ipu_node_names node_names;
|
2021-01-07 08:28:38 -05:00
|
|
|
|
2023-07-05 17:30:00 -04:00
|
|
|
u8 link;
|
|
|
|
u8 lanes;
|
|
|
|
u32 mclkspeed;
|
|
|
|
u32 rotation;
|
|
|
|
enum v4l2_fwnode_orientation orientation;
|
|
|
|
const char *vcm_type;
|
2021-07-12 05:03:26 -04:00
|
|
|
|
2023-05-18 06:05:21 -04:00
|
|
|
struct ipu_property_names prop_names;
|
2021-01-07 08:28:38 -05:00
|
|
|
struct property_entry ep_properties[5];
|
2021-12-03 05:28:57 -05:00
|
|
|
struct property_entry dev_properties[5];
|
2023-05-18 06:05:21 -04:00
|
|
|
struct property_entry ipu_properties[3];
|
2023-08-03 01:38:14 -04:00
|
|
|
struct property_entry ivsc_properties[1];
|
|
|
|
struct property_entry ivsc_sensor_ep_properties[4];
|
|
|
|
struct property_entry ivsc_ipu_ep_properties[4];
|
|
|
|
|
2021-01-07 08:28:38 -05:00
|
|
|
struct software_node_ref_args local_ref[1];
|
|
|
|
struct software_node_ref_args remote_ref[1];
|
2021-12-03 05:28:57 -05:00
|
|
|
struct software_node_ref_args vcm_ref[1];
|
2023-08-03 01:38:14 -04:00
|
|
|
struct software_node_ref_args ivsc_sensor_ref[1];
|
|
|
|
struct software_node_ref_args ivsc_ipu_ref[1];
|
2021-01-07 08:28:38 -05:00
|
|
|
};
|
|
|
|
|
2023-07-05 17:30:02 -04:00
|
|
|
typedef int (*ipu_parse_sensor_fwnode_t)(struct acpi_device *adev,
|
|
|
|
struct ipu_sensor *sensor);
|
|
|
|
|
2023-05-18 06:05:21 -04:00
|
|
|
struct ipu_bridge {
|
2023-07-05 17:29:58 -04:00
|
|
|
struct device *dev;
|
2023-07-05 17:30:02 -04:00
|
|
|
ipu_parse_sensor_fwnode_t parse_sensor_fwnode;
|
2023-05-18 06:05:21 -04:00
|
|
|
char ipu_node_name[ACPI_ID_LEN];
|
|
|
|
struct software_node ipu_hid_node;
|
2021-01-07 08:28:38 -05:00
|
|
|
u32 data_lanes[4];
|
|
|
|
unsigned int n_sensors;
|
2023-05-18 06:05:22 -04:00
|
|
|
struct ipu_sensor sensors[IPU_MAX_PORTS];
|
2021-01-07 08:28:38 -05:00
|
|
|
};
|
|
|
|
|
2023-05-18 06:05:21 -04:00
|
|
|
#if IS_ENABLED(CONFIG_IPU_BRIDGE)
|
2023-07-05 17:30:02 -04:00
|
|
|
int ipu_bridge_init(struct device *dev,
|
|
|
|
ipu_parse_sensor_fwnode_t parse_sensor_fwnode);
|
|
|
|
int ipu_bridge_parse_ssdb(struct acpi_device *adev, struct ipu_sensor *sensor);
|
2023-07-05 17:30:05 -04:00
|
|
|
int ipu_bridge_instantiate_vcm(struct device *sensor);
|
2023-05-18 06:05:21 -04:00
|
|
|
#else
|
2023-07-05 17:30:02 -04:00
|
|
|
/* Use a define to avoid the @parse_sensor_fwnode argument getting evaluated */
|
|
|
|
#define ipu_bridge_init(dev, parse_sensor_fwnode) (0)
|
2023-07-05 17:30:05 -04:00
|
|
|
static inline int ipu_bridge_instantiate_vcm(struct device *s) { return 0; }
|
2023-05-18 06:05:21 -04:00
|
|
|
#endif
|
|
|
|
|
2021-01-07 08:28:38 -05:00
|
|
|
#endif
|