Viswanadha Raju Thotakura | b7ac375 | 2017-02-27 15:00:51 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2017, The Linux Foundation. All rights reserved. |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
| 12 | |
| 13 | #ifndef _CAM_SENSOR_I2C_H_ |
| 14 | #define _CAM_SENSOR_I2C_H_ |
| 15 | |
| 16 | #include <linux/delay.h> |
| 17 | #include <media/v4l2-subdev.h> |
| 18 | #include <media/cam_sensor.h> |
| 19 | #include <media/cam_sensor.h> |
| 20 | #include "cam_cci_dev.h" |
| 21 | #include "cam_sensor_io.h" |
| 22 | |
| 23 | #define I2C_POLL_TIME_MS 5 |
| 24 | #define MAX_POLL_DELAY_MS 100 |
| 25 | |
| 26 | #define I2C_COMPARE_MATCH 0 |
| 27 | #define I2C_COMPARE_MISMATCH 1 |
| 28 | |
Vivek Veenam | 2ad8de1 | 2017-04-04 18:56:22 +0530 | [diff] [blame] | 29 | #define I2C_REG_DATA_MAX (8*1024) |
| 30 | |
Viswanadha Raju Thotakura | b7ac375 | 2017-02-27 15:00:51 -0800 | [diff] [blame] | 31 | /** |
| 32 | * @client: CCI client structure |
| 33 | * @data: I2C data |
| 34 | * @addr_type: I2c address type |
| 35 | * @data_type: I2C data type |
| 36 | * |
| 37 | * This API handles CCI read |
| 38 | */ |
| 39 | int32_t cam_cci_i2c_read(struct cam_sensor_cci_client *client, |
| 40 | uint32_t addr, uint32_t *data, |
| 41 | enum camera_sensor_i2c_type addr_type, |
| 42 | enum camera_sensor_i2c_type data_type); |
| 43 | |
| 44 | /** |
| 45 | * @client: CCI client structure |
Vivek Veenam | 2ad8de1 | 2017-04-04 18:56:22 +0530 | [diff] [blame] | 46 | * @addr: I2c address |
| 47 | * @data: I2C data |
| 48 | * @addr_type: I2c address type |
| 49 | * @num_byte: number of bytes |
| 50 | * |
| 51 | * This API handles CCI sequential read |
| 52 | */ |
| 53 | int32_t cam_camera_cci_i2c_read_seq(struct cam_sensor_cci_client *client, |
| 54 | uint32_t addr, uint8_t *data, |
| 55 | enum camera_sensor_i2c_type addr_type, |
| 56 | uint32_t num_byte); |
| 57 | |
| 58 | /** |
| 59 | * @client: CCI client structure |
Karthik Anantha Ram | 0fb02a3 | 2017-08-23 11:52:50 -0700 | [diff] [blame] | 60 | * @write_setting: I2C register setting |
Viswanadha Raju Thotakura | b7ac375 | 2017-02-27 15:00:51 -0800 | [diff] [blame] | 61 | * |
| 62 | * This API handles CCI random write |
| 63 | */ |
| 64 | int32_t cam_cci_i2c_write_table( |
| 65 | struct camera_io_master *client, |
| 66 | struct cam_sensor_i2c_reg_setting *write_setting); |
| 67 | |
| 68 | /** |
Karthik Anantha Ram | 0fb02a3 | 2017-08-23 11:52:50 -0700 | [diff] [blame] | 69 | * @client: CCI client structure |
| 70 | * @write_setting: I2C register setting |
| 71 | * @cam_sensor_i2c_write_flag: burst or seq write |
| 72 | * |
| 73 | * This API handles CCI continuous write |
| 74 | */ |
| 75 | int32_t cam_cci_i2c_write_continuous_table( |
| 76 | struct camera_io_master *client, |
| 77 | struct cam_sensor_i2c_reg_setting *write_setting, |
| 78 | uint8_t cam_sensor_i2c_write_flag); |
| 79 | |
| 80 | /** |
Viswanadha Raju Thotakura | b7ac375 | 2017-02-27 15:00:51 -0800 | [diff] [blame] | 81 | * @cci_client: CCI client structure |
| 82 | * @cci_cmd: CCI command type |
| 83 | * |
| 84 | * Does I2C call to I2C functionalities |
| 85 | */ |
| 86 | int32_t cam_sensor_cci_i2c_util(struct cam_sensor_cci_client *cci_client, |
| 87 | uint16_t cci_cmd); |
| 88 | |
| 89 | /** |
| 90 | * @client: CCI client structure |
| 91 | * @addr: I2C address |
| 92 | * @data: I2C data |
| 93 | * @data_mask: I2C data mask |
| 94 | * @data_type: I2C data type |
| 95 | * @addr_type: I2C addr type |
| 96 | * @delay_ms: Delay in milli seconds |
| 97 | * |
| 98 | * This API implements CCI based I2C poll |
| 99 | */ |
| 100 | int32_t cam_cci_i2c_poll(struct cam_sensor_cci_client *client, |
| 101 | uint32_t addr, uint16_t data, uint16_t data_mask, |
| 102 | enum camera_sensor_i2c_type data_type, |
| 103 | enum camera_sensor_i2c_type addr_type, |
| 104 | uint32_t delay_ms); |
| 105 | |
Jigarkumar Zala | a431ad6 | 2017-04-27 12:44:36 -0700 | [diff] [blame] | 106 | |
| 107 | /** |
| 108 | * cam_qup_i2c_read : QUP based i2c read |
| 109 | * @client : QUP I2C client structure |
| 110 | * @data : I2C data |
| 111 | * @addr_type : I2c address type |
| 112 | * @data_type : I2C data type |
| 113 | * |
| 114 | * This API handles QUP I2C read |
| 115 | */ |
| 116 | |
| 117 | int32_t cam_qup_i2c_read(struct i2c_client *client, |
| 118 | uint32_t addr, uint32_t *data, |
| 119 | enum camera_sensor_i2c_type addr_type, |
| 120 | enum camera_sensor_i2c_type data_type); |
| 121 | |
| 122 | /** |
| 123 | * cam_qup_i2c_read_seq : QUP based I2C sequential read |
| 124 | * @client : QUP I2C client structure |
| 125 | * @data : I2C data |
| 126 | * @addr_type : I2c address type |
| 127 | * @num_bytes : number of bytes to read |
| 128 | * This API handles QUP I2C Sequential read |
| 129 | */ |
| 130 | |
| 131 | int32_t cam_qup_i2c_read_seq(struct i2c_client *client, |
| 132 | uint32_t addr, uint8_t *data, |
| 133 | enum camera_sensor_i2c_type addr_type, |
| 134 | uint32_t num_byte); |
| 135 | |
| 136 | /** |
| 137 | * cam_qup_i2c_poll : QUP based I2C poll operation |
| 138 | * @client : QUP I2C client structure |
| 139 | * @addr : I2C address |
| 140 | * @data : I2C data |
| 141 | * @data_mask : I2C data mask |
| 142 | * @data_type : I2C data type |
| 143 | * @addr_type : I2C addr type |
| 144 | * @delay_ms : Delay in milli seconds |
| 145 | * |
| 146 | * This API implements QUP based I2C poll |
| 147 | */ |
| 148 | |
| 149 | int32_t cam_qup_i2c_poll(struct i2c_client *client, |
| 150 | uint32_t addr, uint16_t data, uint16_t data_mask, |
| 151 | enum camera_sensor_i2c_type addr_type, |
| 152 | enum camera_sensor_i2c_type data_type, |
| 153 | uint32_t delay_ms); |
| 154 | |
| 155 | /** |
| 156 | * cam_qup_i2c_write_table : QUP based I2C write random |
| 157 | * @client : QUP I2C client structure |
| 158 | * @write_setting : I2C register settings |
| 159 | * |
| 160 | * This API handles QUP I2C random write |
| 161 | */ |
| 162 | |
| 163 | int32_t cam_qup_i2c_write_table( |
| 164 | struct camera_io_master *client, |
| 165 | struct cam_sensor_i2c_reg_setting *write_setting); |
| 166 | #endif /*_CAM_SENSOR_I2C_H*/ |