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_IO_H_ |
| 14 | #define _CAM_SENSOR_IO_H_ |
| 15 | |
| 16 | #include <media/cam_sensor.h> |
| 17 | |
| 18 | #include "cam_sensor_cmn_header.h" |
| 19 | |
| 20 | #define CCI_MASTER 1 |
| 21 | #define I2C_MASTER 2 |
| 22 | #define SPI_MASTER 3 |
| 23 | |
| 24 | /** |
| 25 | * @master_type: CCI master type |
| 26 | * @client: I2C client information structure |
| 27 | * @cci_client: CCI client information structure |
| 28 | * @spi_client: SPI client information structure |
| 29 | */ |
| 30 | struct camera_io_master { |
| 31 | int master_type; |
| 32 | struct i2c_client *client; |
| 33 | struct cam_sensor_cci_client *cci_client; |
| 34 | struct cam_sensor_spi_client *spi_client; |
| 35 | }; |
| 36 | |
| 37 | /** |
| 38 | * @io_master_info: I2C/SPI master information |
| 39 | * @addr: I2C address |
| 40 | * @data: I2C data |
Jigarkumar Zala | a431ad6 | 2017-04-27 12:44:36 -0700 | [diff] [blame] | 41 | * @addr_type: I2C addr_type |
Viswanadha Raju Thotakura | b7ac375 | 2017-02-27 15:00:51 -0800 | [diff] [blame] | 42 | * @data_type: I2C data type |
| 43 | * |
| 44 | * This API abstracts read functionality based on master type |
| 45 | */ |
| 46 | int32_t camera_io_dev_read(struct camera_io_master *io_master_info, |
| 47 | uint32_t addr, uint32_t *data, |
Jigarkumar Zala | 2bb8164 | 2017-06-05 15:10:01 -0700 | [diff] [blame] | 48 | enum camera_sensor_i2c_type addr_type, |
Viswanadha Raju Thotakura | b7ac375 | 2017-02-27 15:00:51 -0800 | [diff] [blame] | 49 | enum camera_sensor_i2c_type data_type); |
| 50 | |
| 51 | /** |
| 52 | * @io_master_info: I2C/SPI master information |
Jigarkumar Zala | a431ad6 | 2017-04-27 12:44:36 -0700 | [diff] [blame] | 53 | * @addr: I2C address |
| 54 | * @data: I2C data |
Vivek Veenam | 2ad8de1 | 2017-04-04 18:56:22 +0530 | [diff] [blame] | 55 | * @data_type: I2C data type |
Jigarkumar Zala | a431ad6 | 2017-04-27 12:44:36 -0700 | [diff] [blame] | 56 | * @num_bytes: number of bytes |
| 57 | * |
Vivek Veenam | 2ad8de1 | 2017-04-04 18:56:22 +0530 | [diff] [blame] | 58 | * This API abstracts read functionality based on master type |
Jigarkumar Zala | a431ad6 | 2017-04-27 12:44:36 -0700 | [diff] [blame] | 59 | */ |
| 60 | int32_t camera_io_dev_read_seq(struct camera_io_master *io_master_info, |
| 61 | uint32_t addr, uint8_t *data, |
| 62 | enum camera_sensor_i2c_type addr_type, |
Vivek Veenam | 2ad8de1 | 2017-04-04 18:56:22 +0530 | [diff] [blame] | 63 | int32_t num_bytes); |
Jigarkumar Zala | a431ad6 | 2017-04-27 12:44:36 -0700 | [diff] [blame] | 64 | |
| 65 | /** |
| 66 | * @io_master_info: I2C/SPI master information |
Viswanadha Raju Thotakura | b7ac375 | 2017-02-27 15:00:51 -0800 | [diff] [blame] | 67 | * |
| 68 | * This API initializes the I2C/SPI master based on master type |
| 69 | */ |
| 70 | int32_t camera_io_init(struct camera_io_master *io_master_info); |
| 71 | |
| 72 | /** |
| 73 | * @io_master_info: I2C/SPI master information |
| 74 | * |
| 75 | * This API releases the I2C/SPI master based on master type |
| 76 | */ |
| 77 | int32_t camera_io_release(struct camera_io_master *io_master_info); |
| 78 | |
| 79 | /** |
| 80 | * @io_master_info: I2C/SPI master information |
| 81 | * @write_setting: write settings information |
| 82 | * |
| 83 | * This API abstracts write functionality based on master type |
| 84 | */ |
| 85 | int32_t camera_io_dev_write(struct camera_io_master *io_master_info, |
| 86 | struct cam_sensor_i2c_reg_setting *write_setting); |
| 87 | |
| 88 | /** |
| 89 | * @io_master_info: I2C/SPI master information |
Karthik Anantha Ram | 0fb02a3 | 2017-08-23 11:52:50 -0700 | [diff] [blame] | 90 | * @write_setting: write settings information |
| 91 | * @cam_sensor_i2c_write_flag: differentiate between burst & seq |
| 92 | * |
| 93 | * This API abstracts write functionality based on master type and |
| 94 | * write flag for continuous write |
| 95 | */ |
| 96 | int32_t camera_io_dev_write_continuous(struct camera_io_master *io_master_info, |
| 97 | struct cam_sensor_i2c_reg_setting *write_setting, |
| 98 | uint8_t cam_sensor_i2c_write_flag); |
| 99 | |
| 100 | /** |
| 101 | * @io_master_info: I2C/SPI master information |
Viswanadha Raju Thotakura | b7ac375 | 2017-02-27 15:00:51 -0800 | [diff] [blame] | 102 | * @addr: I2C address |
| 103 | * @data: I2C data |
| 104 | * @data_mask: I2C data mask |
| 105 | * @data_type: I2C data type |
| 106 | * @addr_type: I2C address type |
| 107 | * @delay_ms: delay in milli seconds |
| 108 | * |
| 109 | * This API abstracts poll functionality based on master type |
| 110 | */ |
| 111 | int32_t camera_io_dev_poll(struct camera_io_master *io_master_info, |
| 112 | uint32_t addr, uint16_t data, uint32_t data_mask, |
Viswanadha Raju Thotakura | b7ac375 | 2017-02-27 15:00:51 -0800 | [diff] [blame] | 113 | enum camera_sensor_i2c_type addr_type, |
Depeng Shao | 0817638 | 2017-11-20 19:40:09 +0800 | [diff] [blame] | 114 | enum camera_sensor_i2c_type data_type, |
Viswanadha Raju Thotakura | b7ac375 | 2017-02-27 15:00:51 -0800 | [diff] [blame] | 115 | uint32_t delay_ms); |
| 116 | |
Vivek Veenam | 2ad8de1 | 2017-04-04 18:56:22 +0530 | [diff] [blame] | 117 | #include "cam_sensor_i2c.h" |
| 118 | #include "cam_sensor_spi.h" |
Viswanadha Raju Thotakura | b7ac375 | 2017-02-27 15:00:51 -0800 | [diff] [blame] | 119 | #endif /* _CAM_SENSOR_IO_H_ */ |