msm: camera: secure camera support
Adding relay driver functionality for camera sensor module to pass cci commands to trustzone and operate in secure mode. Change-Id: I3d1345118df151f8521d5ad230311a56105b5f4a Signed-off-by: Alexander Kolesnikov <akolesni@codeaurora.org> Signed-off-by: Amit Blay <ablay@codeaurora.org> Signed-off-by: Nishant Pandit <npandit@codeaurora.org> Signed-off-by: Sureshnaidu Laveti <lsuresh@codeaurora.org>
This commit is contained in:
parent
e94b446eac
commit
e41cdfc745
8 changed files with 1243 additions and 21 deletions
|
@ -106,6 +106,8 @@ Optional properties:
|
|||
- qcom,mount-angle : should contain the physical mount angle of the sensor on
|
||||
the target
|
||||
- 0, 90, 180, 360
|
||||
- qcom,secure : should be enabled to operate the camera in secure mode
|
||||
- 0, 1
|
||||
- qcom,mclk-23880000 : should be enabled if the supported mclk is 23.88Mhz and
|
||||
not 24 Mhz.
|
||||
- qcom,gpio-no-mux : should contain field to indicate whether gpio mux table is
|
||||
|
@ -273,6 +275,7 @@ Example:
|
|||
qcom,csiphy-sd-index = <0>;
|
||||
qcom,csid-sd-index = <0>;
|
||||
qcom,mount-angle = <90>;
|
||||
qcom,secure = <1>;
|
||||
qcom,led-flash-src = <&led_flash0>;
|
||||
qcom,actuator-src = <&actuator0>;
|
||||
qcom,eeprom-src = <&eeprom0>;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
config MSM_CAMERA_SENSOR
|
||||
bool "Qualcomm MSM camera sensor support"
|
||||
bool "QTI MSM camera sensor support"
|
||||
depends on MSMB_CAMERA
|
||||
select NEW_LEDS
|
||||
select LEDS_CLASS
|
||||
|
@ -10,7 +10,7 @@ config MSM_CAMERA_SENSOR
|
|||
subdev APIs.
|
||||
|
||||
config MSM_CPP
|
||||
bool "Qualcomm MSM Camera Post Processing Engine support"
|
||||
bool "QTI MSM Camera Post Processing Engine support"
|
||||
depends on MSMB_CAMERA
|
||||
---help---
|
||||
Enable support for Camera Post-processing Engine
|
||||
|
@ -19,7 +19,7 @@ config MSM_CPP
|
|||
APIs.
|
||||
|
||||
config MSM_CCI
|
||||
bool "Qualcomm MSM Camera Control Interface support"
|
||||
bool "QTI MSM Camera Control Interface support"
|
||||
depends on MSMB_CAMERA
|
||||
---help---
|
||||
Enable support for Camera Control Interface driver only
|
||||
|
@ -29,7 +29,7 @@ config MSM_CCI
|
|||
GPIO and data frames.
|
||||
|
||||
config MSM_CSI20_HEADER
|
||||
bool "Qualcomm MSM CSI 2.0 Header"
|
||||
bool "QTI MSM CSI 2.0 Header"
|
||||
depends on MSMB_CAMERA
|
||||
---help---
|
||||
Enable support for CSI drivers to include 2.0
|
||||
|
@ -39,7 +39,7 @@ config MSM_CSI20_HEADER
|
|||
8930 and 8064 platforms.
|
||||
|
||||
config MSM_CSI22_HEADER
|
||||
bool "Qualcomm MSM CSI 2.2 Header"
|
||||
bool "QTI MSM CSI 2.2 Header"
|
||||
depends on MSMB_CAMERA
|
||||
---help---
|
||||
Enable support for CSI drivers to include 2.2
|
||||
|
@ -49,7 +49,7 @@ config MSM_CSI22_HEADER
|
|||
platform.
|
||||
|
||||
config MSM_CSI30_HEADER
|
||||
bool "Qualcomm MSM CSI 3.0 Header"
|
||||
bool "QTI MSM CSI 3.0 Header"
|
||||
depends on MSMB_CAMERA
|
||||
---help---
|
||||
Enable support for CSI drivers to include 3.0
|
||||
|
@ -59,7 +59,7 @@ config MSM_CSI30_HEADER
|
|||
8064 platforms.
|
||||
|
||||
config MSM_CSI31_HEADER
|
||||
bool "Qualcomm MSM CSI 3.1 Header"
|
||||
bool "QTI MSM CSI 3.1 Header"
|
||||
depends on MSMB_CAMERA
|
||||
---help---
|
||||
Enable support for CSI drivers to include 3.0
|
||||
|
@ -69,7 +69,7 @@ config MSM_CSI31_HEADER
|
|||
APQ8084 platform.
|
||||
|
||||
config MSM_CSIPHY
|
||||
bool "Qualcomm MSM Camera Serial Interface Physical receiver support"
|
||||
bool "QTI MSM Camera Serial Interface Physical receiver support"
|
||||
depends on MSMB_CAMERA
|
||||
---help---
|
||||
Enable support for Camera Serial Interface
|
||||
|
@ -78,7 +78,7 @@ config MSM_CSIPHY
|
|||
signalling.
|
||||
|
||||
config MSM_CSID
|
||||
bool "Qualcomm MSM Camera Serial Interface decoder support"
|
||||
bool "QTI MSM Camera Serial Interface decoder support"
|
||||
depends on MSMB_CAMERA
|
||||
---help---
|
||||
Enable support for Camera Serial Interface decoder.
|
||||
|
@ -87,7 +87,7 @@ config MSM_CSID
|
|||
and datatype.
|
||||
|
||||
config MSM_EEPROM
|
||||
bool "Qualcomm MSM Camera ROM Interface for Calibration support"
|
||||
bool "QTI MSM Camera ROM Interface for Calibration support"
|
||||
depends on MSMB_CAMERA
|
||||
---help---
|
||||
Enable support for ROM Interface for Calibration
|
||||
|
@ -96,7 +96,7 @@ config MSM_EEPROM
|
|||
Currently supports I2C, CCI and SPI protocol
|
||||
|
||||
config MSM_ISPIF
|
||||
bool "Qualcomm MSM Image Signal Processing interface support"
|
||||
bool "QTI MSM Image Signal Processing interface support"
|
||||
depends on MSMB_CAMERA
|
||||
---help---
|
||||
Enable support for Image Signal Processing interface module.
|
||||
|
@ -105,7 +105,7 @@ config MSM_ISPIF
|
|||
data interface in VFE.
|
||||
|
||||
config MSM_ISPIF_V1
|
||||
bool "Qualcomm MSM Image Signal Processing interface support"
|
||||
bool "QTI MSM Image Signal Processing interface support"
|
||||
depends on MSMB_CAMERA
|
||||
---help---
|
||||
Enable support for Image Signal Processing interface module.
|
||||
|
@ -114,7 +114,7 @@ config MSM_ISPIF_V1
|
|||
or raw data interface in VFE.
|
||||
|
||||
config MSM_ISPIF_V2
|
||||
bool "Qualcomm MSM Image Signal Processing interface support"
|
||||
bool "QTI MSM Image Signal Processing interface support"
|
||||
depends on MSMB_CAMERA
|
||||
---help---
|
||||
Enable support for Image Signal Processing interface module.
|
||||
|
@ -204,7 +204,7 @@ config OV12830
|
|||
2 lanes max fps is 18, 4 lanes max fps is 24.
|
||||
|
||||
config MSM_V4L2_VIDEO_OVERLAY_DEVICE
|
||||
tristate "Qualcomm MSM V4l2 video overlay device"
|
||||
tristate "QTI MSM V4l2 video overlay device"
|
||||
---help---
|
||||
Enables support for the MSM V4L2 video
|
||||
overlay driver. This allows video rendering
|
||||
|
@ -212,7 +212,7 @@ config MSM_V4L2_VIDEO_OVERLAY_DEVICE
|
|||
APIs, by using /dev/videoX device
|
||||
|
||||
config MSMB_JPEG
|
||||
tristate "Qualcomm MSM Jpeg Encoder Engine support"
|
||||
tristate "QTI MSM Jpeg Encoder Engine support"
|
||||
depends on MSMB_CAMERA && (ARCH_MSM8974 || ARCH_MSM8226 || ARCH_APQ8084 || ARCH_MSM8916 || ARCH_QCOM)
|
||||
---help---
|
||||
Enable support for Jpeg Encoder/Decoder
|
||||
|
@ -221,7 +221,7 @@ config MSMB_JPEG
|
|||
for the JPEG 1.0 encoder and decoder.
|
||||
|
||||
config MSM_GEMINI
|
||||
tristate "Qualcomm MSM Gemini JPEG engine support"
|
||||
tristate "QTI MSM Gemini JPEG engine support"
|
||||
depends on MSMB_CAMERA && (ARCH_MSM7X30 || ARCH_MSM8X60 || ARCH_MSM8960)
|
||||
---help---
|
||||
Enables support for the Gemini JPEG encoder
|
||||
|
@ -230,14 +230,26 @@ config MSM_GEMINI
|
|||
for JPEG encoding functionality.
|
||||
|
||||
config MSM_FD
|
||||
tristate "Qualcomm MSM FD face detection engine support"
|
||||
tristate "QTI MSM FD face detection engine support"
|
||||
depends on MSMB_CAMERA
|
||||
---help---
|
||||
Enables support for the MSM FD face detection engine.
|
||||
|
||||
config MSM_JPEGDMA
|
||||
tristate "Qualcomm Technologies Inc. MSM Jpeg dma"
|
||||
tristate "QTI MSM Jpeg dma"
|
||||
depends on MSMB_CAMERA
|
||||
select V4L2_MEM2MEM_DEV
|
||||
---help---
|
||||
Enable support for Jpeg dma engine.
|
||||
|
||||
config MSM_SEC_CCI_TA_NAME
|
||||
string "Name of TA to handle Secure CCI transactions"
|
||||
depends on MSM_CCI
|
||||
default "seccamdemo64"
|
||||
|
||||
config MSM_SEC_CCI_DEBUG
|
||||
bool "QTI MSM Secure CCI Relay Debug"
|
||||
depends on MSM_CCI
|
||||
---help---
|
||||
Enables simulation of secure camera for Secure CCI Realy
|
||||
debugging.
|
||||
|
|
|
@ -2,4 +2,5 @@ ccflags-y += -Idrivers/media/platform/msm/camera_v2/
|
|||
ccflags-y += -Idrivers/media/platform/msm/camera_v2/common
|
||||
ccflags-y += -Idrivers/media/platform/msm/camera_v2/sensor
|
||||
ccflags-y += -Idrivers/media/platform/msm/camera_v2/sensor/cci
|
||||
obj-$(CONFIG_MSMB_CAMERA) += msm_camera_cci_i2c.o msm_camera_qup_i2c.o msm_camera_spi.o msm_camera_dt_util.o
|
||||
ccflags-y += -Idrivers/misc/
|
||||
obj-$(CONFIG_MSMB_CAMERA) += msm_camera_cci_i2c.o msm_camera_qup_i2c.o msm_camera_spi.o msm_camera_dt_util.o msm_camera_tz_i2c.o
|
||||
|
|
|
@ -152,4 +152,60 @@ int32_t msm_camera_qup_i2c_poll(struct msm_camera_i2c_client *client,
|
|||
uint32_t addr, uint16_t data,
|
||||
enum msm_camera_i2c_data_type data_type, uint32_t delay_ms);
|
||||
|
||||
int32_t msm_camera_tz_i2c_register_sensor(void *s_ctrl_p);
|
||||
|
||||
int32_t msm_camera_tz_i2c_power_up(struct msm_camera_i2c_client *client);
|
||||
|
||||
int32_t msm_camera_tz_i2c_power_down(struct msm_camera_i2c_client *client);
|
||||
|
||||
int32_t msm_camera_tz_i2c_read(struct msm_camera_i2c_client *client,
|
||||
uint32_t addr, uint16_t *data,
|
||||
enum msm_camera_i2c_data_type data_type);
|
||||
|
||||
int32_t msm_camera_tz_i2c_read_seq(struct msm_camera_i2c_client *client,
|
||||
uint32_t addr, uint8_t *data, uint32_t num_byte);
|
||||
|
||||
int32_t msm_camera_tz_i2c_write(struct msm_camera_i2c_client *client,
|
||||
uint32_t addr, uint16_t data,
|
||||
enum msm_camera_i2c_data_type data_type);
|
||||
|
||||
int32_t msm_camera_tz_i2c_write_seq(struct msm_camera_i2c_client *client,
|
||||
uint32_t addr, uint8_t *data, uint32_t num_byte);
|
||||
|
||||
int32_t msm_camera_tz_i2c_write_table(
|
||||
struct msm_camera_i2c_client *client,
|
||||
struct msm_camera_i2c_reg_setting *write_setting);
|
||||
|
||||
int32_t msm_camera_tz_i2c_write_table_async(
|
||||
struct msm_camera_i2c_client *client,
|
||||
struct msm_camera_i2c_reg_setting *write_setting);
|
||||
|
||||
int32_t msm_camera_tz_i2c_write_table_sync(
|
||||
struct msm_camera_i2c_client *client,
|
||||
struct msm_camera_i2c_reg_setting *write_setting);
|
||||
|
||||
int32_t msm_camera_tz_i2c_write_table_sync_block(
|
||||
struct msm_camera_i2c_client *client,
|
||||
struct msm_camera_i2c_reg_setting *write_setting);
|
||||
|
||||
int32_t msm_camera_tz_i2c_write_seq_table(
|
||||
struct msm_camera_i2c_client *client,
|
||||
struct msm_camera_i2c_seq_reg_setting *write_setting);
|
||||
|
||||
int32_t msm_camera_tz_i2c_write_table_w_microdelay(
|
||||
struct msm_camera_i2c_client *client,
|
||||
struct msm_camera_i2c_reg_setting *write_setting);
|
||||
|
||||
int32_t msm_camera_tz_i2c_write_conf_tbl(
|
||||
struct msm_camera_i2c_client *client,
|
||||
struct msm_camera_i2c_reg_conf *reg_conf_tbl, uint16_t size,
|
||||
enum msm_camera_i2c_data_type data_type);
|
||||
|
||||
int32_t msm_sensor_tz_i2c_util(struct msm_camera_i2c_client *client,
|
||||
uint16_t cci_cmd);
|
||||
|
||||
int32_t msm_camera_tz_i2c_poll(struct msm_camera_i2c_client *client,
|
||||
uint32_t addr, uint16_t data,
|
||||
enum msm_camera_i2c_data_type data_type);
|
||||
|
||||
#endif
|
||||
|
|
1093
drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_tz_i2c.c
Normal file
1093
drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_tz_i2c.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -21,6 +21,9 @@
|
|||
#undef CDBG
|
||||
#define CDBG(fmt, args...) pr_debug(fmt, ##args)
|
||||
|
||||
static struct msm_camera_i2c_fn_t msm_sensor_cci_func_tbl;
|
||||
static struct msm_camera_i2c_fn_t msm_sensor_secure_func_tbl;
|
||||
|
||||
static void msm_sensor_adjust_mclk(struct msm_camera_power_ctrl_t *ctrl)
|
||||
{
|
||||
int idx;
|
||||
|
@ -132,6 +135,11 @@ int msm_sensor_power_down(struct msm_sensor_ctrl_t *s_ctrl)
|
|||
__func__, __LINE__, power_info, sensor_i2c_client);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Power down secure session if it exist*/
|
||||
if (s_ctrl->is_secure)
|
||||
msm_camera_tz_i2c_power_down(sensor_i2c_client);
|
||||
|
||||
return msm_camera_power_down(power_info, sensor_device_type,
|
||||
sensor_i2c_client);
|
||||
}
|
||||
|
@ -170,7 +178,27 @@ int msm_sensor_power_up(struct msm_sensor_ctrl_t *s_ctrl)
|
|||
if (s_ctrl->set_mclk_23880000)
|
||||
msm_sensor_adjust_mclk(power_info);
|
||||
|
||||
CDBG("Sensor %d tagged as %s\n", s_ctrl->id,
|
||||
(s_ctrl->is_secure)?"SECURE":"NON-SECURE");
|
||||
|
||||
for (retry = 0; retry < 3; retry++) {
|
||||
if (s_ctrl->is_secure) {
|
||||
rc = msm_camera_tz_i2c_power_up(sensor_i2c_client);
|
||||
if (rc < 0) {
|
||||
#ifdef CONFIG_MSM_SEC_CCI_DEBUG
|
||||
CDBG("Secure Sensor %d use cci\n", s_ctrl->id);
|
||||
/* session is not secure */
|
||||
s_ctrl->sensor_i2c_client->i2c_func_tbl =
|
||||
&msm_sensor_cci_func_tbl;
|
||||
#else /* CONFIG_MSM_SEC_CCI_DEBUG */
|
||||
return rc;
|
||||
#endif /* CONFIG_MSM_SEC_CCI_DEBUG */
|
||||
} else {
|
||||
/* session is secure */
|
||||
s_ctrl->sensor_i2c_client->i2c_func_tbl =
|
||||
&msm_sensor_secure_func_tbl;
|
||||
}
|
||||
}
|
||||
rc = msm_camera_power_up(power_info, s_ctrl->sensor_device_type,
|
||||
sensor_i2c_client);
|
||||
if (rc < 0)
|
||||
|
@ -1433,6 +1461,21 @@ static struct msm_camera_i2c_fn_t msm_sensor_qup_func_tbl = {
|
|||
.i2c_write_table_sync_block = msm_camera_qup_i2c_write_table,
|
||||
};
|
||||
|
||||
static struct msm_camera_i2c_fn_t msm_sensor_secure_func_tbl = {
|
||||
.i2c_read = msm_camera_tz_i2c_read,
|
||||
.i2c_read_seq = msm_camera_tz_i2c_read_seq,
|
||||
.i2c_write = msm_camera_tz_i2c_write,
|
||||
.i2c_write_table = msm_camera_tz_i2c_write_table,
|
||||
.i2c_write_seq_table = msm_camera_tz_i2c_write_seq_table,
|
||||
.i2c_write_table_w_microdelay =
|
||||
msm_camera_tz_i2c_write_table_w_microdelay,
|
||||
.i2c_util = msm_sensor_tz_i2c_util,
|
||||
.i2c_write_conf_tbl = msm_camera_tz_i2c_write_conf_tbl,
|
||||
.i2c_write_table_async = msm_camera_tz_i2c_write_table_async,
|
||||
.i2c_write_table_sync = msm_camera_tz_i2c_write_table_sync,
|
||||
.i2c_write_table_sync_block = msm_camera_tz_i2c_write_table_sync_block,
|
||||
};
|
||||
|
||||
int32_t msm_sensor_init_default_params(struct msm_sensor_ctrl_t *s_ctrl)
|
||||
{
|
||||
struct msm_camera_cci_client *cci_client = NULL;
|
||||
|
@ -1466,6 +1509,9 @@ int32_t msm_sensor_init_default_params(struct msm_sensor_ctrl_t *s_ctrl)
|
|||
/* Get CCI subdev */
|
||||
cci_client->cci_subdev = msm_cci_get_subdev();
|
||||
|
||||
if (s_ctrl->is_secure)
|
||||
msm_camera_tz_i2c_register_sensor((void *)s_ctrl);
|
||||
|
||||
/* Update CCI / I2C function table */
|
||||
if (!s_ctrl->sensor_i2c_client->i2c_func_tbl)
|
||||
s_ctrl->sensor_i2c_client->i2c_func_tbl =
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.
|
||||
/* Copyright (c) 2011-2016, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 and
|
||||
|
@ -88,6 +88,7 @@ struct msm_sensor_ctrl_t {
|
|||
enum msm_camera_stream_type_t camera_stream_type;
|
||||
uint32_t set_mclk_23880000;
|
||||
uint8_t is_csid_tg_mode;
|
||||
uint32_t is_secure;
|
||||
};
|
||||
|
||||
int msm_sensor_config(struct msm_sensor_ctrl_t *s_ctrl, void __user *argp);
|
||||
|
|
|
@ -992,7 +992,7 @@ CSID_TG:
|
|||
}
|
||||
/* Update sensor mount angle and position in media entity flag */
|
||||
is_yuv = (slave_info->output_format == MSM_SENSOR_YCBCR) ? 1 : 0;
|
||||
mount_pos = is_yuv << 25 |
|
||||
mount_pos = ((s_ctrl->is_secure & 0x1) << 26) | is_yuv << 25 |
|
||||
(s_ctrl->sensordata->sensor_info->position << 16) |
|
||||
((s_ctrl->sensordata->
|
||||
sensor_info->sensor_mount_angle / 90) << 8);
|
||||
|
@ -1079,6 +1079,16 @@ static int32_t msm_sensor_driver_get_dt_data(struct msm_sensor_ctrl_t *s_ctrl)
|
|||
goto FREE_VREG_DATA;
|
||||
}
|
||||
|
||||
/* Get custom mode */
|
||||
rc = of_property_read_u32(of_node, "qcom,secure",
|
||||
&s_ctrl->is_secure);
|
||||
CDBG("qcom,secure = %d, rc %d", s_ctrl->is_secure, rc);
|
||||
if (rc < 0) {
|
||||
/* Set default to non-secure mode */
|
||||
s_ctrl->is_secure = 0;
|
||||
rc = 0;
|
||||
}
|
||||
|
||||
/* Get CCI master */
|
||||
rc = of_property_read_u32(of_node, "qcom,cci-master",
|
||||
&s_ctrl->cci_i2c_master);
|
||||
|
|
Loading…
Add table
Reference in a new issue