blob: ec5ed25c078507de6891c3cc426d5f982f01886e [file] [log] [blame]
Viswanadha Raju Thotakurab7ac3752017-02-27 15:00:51 -08001/* 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 */
30struct 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 Zalaa431ad62017-04-27 12:44:36 -070041 * @addr_type: I2C addr_type
Viswanadha Raju Thotakurab7ac3752017-02-27 15:00:51 -080042 * @data_type: I2C data type
43 *
44 * This API abstracts read functionality based on master type
45 */
46int32_t camera_io_dev_read(struct camera_io_master *io_master_info,
47 uint32_t addr, uint32_t *data,
Jigarkumar Zala2bb81642017-06-05 15:10:01 -070048 enum camera_sensor_i2c_type addr_type,
Viswanadha Raju Thotakurab7ac3752017-02-27 15:00:51 -080049 enum camera_sensor_i2c_type data_type);
50
51/**
52 * @io_master_info: I2C/SPI master information
Jigarkumar Zalaa431ad62017-04-27 12:44:36 -070053 * @addr: I2C address
54 * @data: I2C data
Vivek Veenam2ad8de12017-04-04 18:56:22 +053055 * @data_type: I2C data type
Jigarkumar Zalaa431ad62017-04-27 12:44:36 -070056 * @num_bytes: number of bytes
57 *
Vivek Veenam2ad8de12017-04-04 18:56:22 +053058 * This API abstracts read functionality based on master type
Jigarkumar Zalaa431ad62017-04-27 12:44:36 -070059 */
60int32_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 Veenam2ad8de12017-04-04 18:56:22 +053063 int32_t num_bytes);
Jigarkumar Zalaa431ad62017-04-27 12:44:36 -070064
65/**
66 * @io_master_info: I2C/SPI master information
Viswanadha Raju Thotakurab7ac3752017-02-27 15:00:51 -080067 *
68 * This API initializes the I2C/SPI master based on master type
69 */
70int32_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 */
77int32_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 */
85int32_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 Ram0fb02a32017-08-23 11:52:50 -070090 * @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 */
96int32_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 Thotakurab7ac3752017-02-27 15:00:51 -0800102 * @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 */
111int32_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 Thotakurab7ac3752017-02-27 15:00:51 -0800113 enum camera_sensor_i2c_type addr_type,
Depeng Shao08176382017-11-20 19:40:09 +0800114 enum camera_sensor_i2c_type data_type,
Viswanadha Raju Thotakurab7ac3752017-02-27 15:00:51 -0800115 uint32_t delay_ms);
116
Vivek Veenam2ad8de12017-04-04 18:56:22 +0530117#include "cam_sensor_i2c.h"
118#include "cam_sensor_spi.h"
Viswanadha Raju Thotakurab7ac3752017-02-27 15:00:51 -0800119#endif /* _CAM_SENSOR_IO_H_ */