* Qualcomm Technologies, Inc. MSM CCI

CCI (Camera Control Interface) is module that is use for camera sensor module
I2C communication.

=======================
Required Node Structure
=======================
The camera CCI node must be described in two levels of device nodes. The
first level describe the overall CCI node structure. Second level nodes
describe camera sensor submodule nodes which is using CCI for
i2c communication.

======================================
First Level Node - CCI device
======================================

- compatible
  Usage: required
  Value type: <string>
  Definition: Should be "qcom,cci".

- cell-index: cci hardware core index
  Usage: required
  Value type: <u32>
  Definition: Should specify the Hardware index id.

- reg
  Usage: required
  Value type: <u32>
  Definition: offset and length of the register set
	for the device for the cci operating in
	compatible mode.

- reg-names
  Usage: required
  Value type: <string>
  Definition: Should specify relevant names to each
	reg property defined.

- interrupts
  Usage: required
  Value type: <u32>
  Definition: Interrupt associated with CCI HW.

- interrupt-names
  Usage: required
  Value type: <string>
  Definition: Name of the interrupt.

- gpios
  Usage: required
  Value type: <phandle>
  Definition: should specify the gpios to be used for the CCI.

- gpio-req-tbl-num
  Usage: required
  Value type: <u32>
  Definition: should specify the gpio table index.

- gpio-req-tbl-flags
  Usage: required
  Value type: <u32>
  Definition: should specify the gpio functions.

- gpio-req-tbl-label
  Usage: required
  Value type: <string>
  Definition: should specify the gpio labels in
	gpio-req-tbl-num property (in the same order)

- clock-names
  Usage: required
  Value type: <string>
  Definition: List of clock names required for CCI HW.

- clock-rates
  Usage: required
  Value type: <u32>
  Definition: List of clock rates in Hz for CCI HW.

- clock-cntl-level
  Usage: required
  Value type: <string>
  Definition: All different clock level node can support.

- clocks
  Usage: required
  Value type: <phandle>
  Definition: all clock phandle and source clocks.

- src-clock-name
  Usage: required
  Value type: <string>
  Definition: name for the source clock.

- regulator-names
  Usage: required
  Value type: <string>
  Definition: name of the voltage regulators required for the device.

- gdscr-supply
  Usage: required
  Value type: <phandle>
  Definition: should contain gdsr regulator used for cci clocks.

- mmagic-supply
  Usage: optional
  Value type: <phandle>
  Definition: should contain mmagic regulator used for mmagic clocks.

=========================
CCI clock settings
=========================
- I2c speed settings (*)
  Usage: required
  Definition: List of i2c rates for CCI HW.
  - i2c_freq_100Khz
    Definition: qcom,i2c_standard_mode - node should contain clock settings for
		100Khz
  - i2c_freq_400Khz
    Definition: qcom,i2c_fast_mode - node should contain clock settings for
		400Khz
  - i2c_freq_custom
    Definition: qcom,i2c_custom_mode - node can contain clock settings for
		frequencies other than 100Khz and 400Khz which is specific to usecase.
		Currently it has settings for 375Khz.
  - i2c_freq_1Mhz
    Definition: qcom,i2c_fast_plus_mode - node should contain clock
		settings for 1Mhz
* if speed settings is not defined the low level driver can use "i2c_freq_custom"
like default

  - hw-thigh
    Definition: should contain high period of the SCL clock in terms of CCI clock cycle
  - hw-tlow
    Definition: should contain high period of the SCL clock in terms of CCI clock cycle
  - hw-tsu-sto
    Definition: should contain setup time for STOP condition
  - hw-tsu-sta
    Definition: should contain setup time for Repeated START condition
  - hw-thd-dat
    Definition: should contain hold time for the data
  - hw-thd-sta
    Definition: should contain hold time for START condition
  - hw-tbuf
    Definition: should contain free time between a STOP and a START condition
  - hw-scl-stretch-en
    Definition: should contain enable or disable clock stretching
  - hw-trdhld
    Definition: should contain internal hold time for SDA
  - hw-tsp
    Definition: should contain filtering of glitches

Example:

	qcom,cci@0xfda0c000 {
		cell-index = <0>;
		compatible = "qcom,cci";
		reg = <0xfda0c000 0x300>;
		reg-names = "cci";
		interrupts = <0 50 0>;
		interrupt-names = "cci";
		clock-names = "camnoc_axi_clk", "soc_ahb_clk",
		"slow_ahb_src_clk", "cpas_ahb_clk",
		"cci_clk", "cci_clk_src";
		clock-rates = <0 0 80000000 0 0 37500000>;
		clock-cntl-level = "turbo";
		gpios = <&tlmm 17 0>,
			   <&tlmm 18 0>,
			   <&tlmm 19 0>,
			   <&tlmm 20 0>;
		gpio-tbl-num = <0 1 2 3>;
		gpio-tbl-flags = <1 1 1 1>;
		gpio-tbl-label = "CCI_I2C_DATA0",
				"CCI_I2C_CLK0",
				"CCI_I2C_DATA1",
				"CCI_I2C_CLK1";
		i2c_freq_100Khz: qcom,i2c_standard_mode {
			 hw-thigh = <78>;
			 hw-tlow = <114>;
			 hw-tsu-sto = <28>;
			 hw-tsu-sta = <28>;
			 hw-thd-dat = <10>;
			 hw-thd-sta = <77>;
			 hw-tbuf = <118>;
			 hw-scl-stretch-en = <0>;
			 hw-trdhld = <6>;
			 hw-tsp = <1>;
			 status = "ok";
		};
		i2c_freq_400Khz: qcom,i2c_fast_mode {
			 hw-thigh = <20>;
			 hw-tlow = <28>;
			 hw-tsu-sto = <21>;
			 hw-tsu-sta = <21>;
			 hw-thd-dat = <13>;
			 hw-thd-sta = <18>;
			 hw-tbuf = <25>;
			 hw-scl-stretch-en = <0>;
			 hw-trdhld = <6>;
			 hw-tsp = <3>;
			 status = "ok";
		};
		i2c_freq_custom: qcom,i2c_custom_mode {
			 hw-thigh = <15>;
			 hw-tlow = <28>;
			 hw-tsu-sto = <21>;
			 hw-tsu-sta = <21>;
			 hw-thd-dat = <13>;
			 hw-thd-sta = <18>;
			 hw-tbuf = <25>;
			 hw-scl-stretch-en = <1>;
			 hw-trdhld = <6>;
			 hw-tsp = <3>;
			 status = "ok";
		};
		i2c_freq_1Mhz: qcom,i2c_fast_plus_mode {
			 hw-thigh = <16>;
			 hw-tlow = <22>;
			 hw-tsu-sto = <17>;
			 hw-tsu-sta = <18>;
			 hw-thd-dat = <16>;
			 hw-thd-sta = <15>;
			 hw-tbuf = <19>;
			 hw-scl-stretch-en = <1>;
			 hw-trdhld = <3>;
			 hw-tsp = <3>;
			 cci-clk-src = <37500000>;
			 status = "ok";
		};
	};

=======================================
Second Level Node - CAM SENSOR MODULES
=======================================

=======================================
CAM SENSOR RESOURCE MANAGER
=======================================
Camera Sensor Resource manager node contains properties of shared camera
sensor resource.

- compatible
  Usage: required
  Value type: <string>
  Definition: Should be "qcom,cam-res-mgr".

- shared-gpios
  Usage: optional
  Value type: <u32>
  Definition: should contain the gpios which are used by two or more
	cameras, and these cameras may be opened together.

- pinctrl-names
  Usage: optional
  Value type: <string>
  Definition: List of names to assign the shared pin state defined in pinctrl device node

- pinctrl-<0..n>
  Usage: optional
  Value type: <phandle>
  Definition: Lists phandles each pointing to the pin configuration node within a pin
	controller. These pin configurations are installed in the pinctrl device node.


=============================
CAMERA IMAGE SENSOR MODULE
=============================
Image sensor node contains properties of camera image sensor

- compatible
  Usage: required
  Value type: <string>
  Definition: Should be "qcom,cam-sensor".

- cell-index: cci hardware core index
  Usage: required
  Value type: <u32>
  Definition: Should specify the Hardware index id.

- reg
  Usage: required
  Value type: <u32>
  Definition: offset and length of the register set
	for the device for the cci operating in
	compatible mode.

- cci-device
  Usage: required
  Value type: <u32>
  Definition: should contain i2c device id to be used for this camera
	sensor

- cci-master
  Usage: required
  Value type: <u32>
  Definition: should contain i2c master id to be used for this camera
	sensor
	- 0 -> MASTER 0
	- 1 -> MASTER 1

- csiphy-sd-index
  Usage: required
  Value type: <u32>
  Definition: should contain csiphy instance that will used to
	receive sensor data (0, 1, 2, 3).

- cam_vdig-supply
  Usage: required
  Value type: <phandle>
  Definition: should contain regulator from which digital voltage is
	supplied

- cam_vana-supply
  Usage: required
  Value type: <phandle>
  Definition: should contain regulator from which analog voltage is
	supplied

- cam_vio-supply
  Usage: required
  Value type: <phandle>
  Definition: should contain regulator from which IO voltage is supplied

- cam_bob-supply
  Usage: optional
  Value type: <phandle>
  Definition: should contain regulator from which BoB voltage is supplied

- regulator-names
  Usage: required
  Value type: <string>
  Definition: should contain names of all regulators needed by this
	sensor

- rgltr-cntrl-support
  Usage: required
  Value type: <boolean>
  Definition: This property is required if the sw control regulator parameters
	e.g. rgltr-min-voltage

- rgltr-min-voltage
  Usage: required
  Value type: <u32>
  Definition: should contain minimum voltage level for regulators mentioned
	in regulator-names property (in the same order)

- rgltr-max-voltage
  Usage: required
  Value type: <u32>
  Definition: should contain maximum voltage level for regulators mentioned
	in regulator-names property (in the same order)

- rgltr-load-current
  Usage: required
  Value type: <u32>
  Definition: should contain optimum voltage level for regulators mentioned
	in regulator-names property (in the same order)

- sensor-position-roll
  Usage: required
  Value type: <u32>
  Definition: should contain sensor rotational angle with respect to axis of
	reference. i.e. 0, 90, 180, 360

- sensor-position-pitch
  Usage: required
  Value type: <u32>
  Definition: should contain sensor rotational angle with respect to axis of
	reference. i.e. 0, 90, 180, 360

- sensor-position-yaw
  Usage: required
  Value type: <u32>
  Definition: should contain sensor rotational angle  with respect to axis of
	reference. i.e. 0, 90, 180, 360

- qcom,secure
  Usage: optional
  Value type: <u32>
  Definition: should be enabled to operate the camera in secure mode

- gpio-no-mux
  Usage: optional
  Value type: <u32>
  Definition: should contain field to indicate whether gpio mux table is
	available. i.e. 1 if gpio mux is not available, 0 otherwise

- cam_vaf-supply
  Usage: optional
  Value type: <u32>
  Definition: should contain regulator from which AF voltage is supplied

- pwm-switch
  Usage: optional
  Value type: <boolean>
  Definition: This property is required for regulator to switch into PWM mode.

- gpios
  Usage: required
  Value type: <phandle>
  Definition: should contain phandle to gpio controller node and array of
	#gpio-cells specifying specific gpio (controller specific)

- gpio-reset
  Usage: required
  Value type: <u32>
  Definition: should contain index to gpio used by sensors reset_n

- gpio-standby
  Usage: optional
  Value type: <u32>
  Definition: should contain index to gpio used by sensors standby_n

- gpio-vio
  Usage: optional
  Value type: <u32>
  Definition: should contain index to gpio used by sensors io vreg enable

- gpio-vana
  Usage: optional
  Value type: <u32>
  Definition: should contain index to gpio used by sensors analog vreg enable

- gpio-vdig
  Usage: optional
  Value type: <u32>
  Definition: should contain index to gpio used by sensors digital vreg enable

- gpio-vaf
  Usage: optional
  Value type: <u32>
  Definition: should contain index to gpio used by sensors af vreg enable

- gpio-af-pwdm
  Usage: optional
  Value type: <u32>
  Definition: should contain index to gpio used by sensors af pwdm_n

- gpio-req-tbl-num
  Usage: optional
  Value type: <u32>
  Definition: should contain index to gpios specific to this sensor

- gpio-req-tbl-flags
  Usage: optional
  Value type: <u32>
  Definition: should contain direction of gpios present in
	gpio-req-tbl-num property (in the same order)

- gpio-req-tbl-label
  Usage: optional
  Value type: <u32>
  Definition: should contain name of gpios present in
	gpio-req-tbl-num property (in the same order)

- gpio-set-tbl-num
  Usage: optional
  Value type: <u32>
  Definition: should contain index of gpios that need to be
	configured by msm

- gpio-set-tbl-flags
  Usage: optional
  Value type: <u32>
  Definition: should contain value to be configured for the gpios
	present in gpio-set-tbl-num property (in the same order)

- gpio-set-tbl-delay
  Usage: optional
  Value type: <u32>
  Definition: should contain amount of delay after configuring
	gpios as specified in gpio_set_tbl_flags property (in the same order)

- actuator-src
  Usage: optional
  Value type: <phandle>
  Definition: if auto focus is supported by this sensor, this
	property should contain phandle of respective actuator node

- led-flash-src
  Usage: optional
  Value type: <phandle>
  Definition: if LED flash is supported by this sensor, this
	property should contain phandle of respective LED flash node

- qcom,vdd-cx-supply
  Usage: optional
  Value type: <phandle>
  Definition: should contain regulator from which cx voltage is supplied

- qcom,vdd-cx-name
  Usage: optional
  Value type: <string>
  Definition: should contain names of cx regulator

- eeprom-src
  Usage: optional
  Value type: <phandle>
  Definition: if eeprom memory is supported by this sensor, this
	property should contain phandle of respective eeprom nodes

- ois-src
  Usage: optional
  Value type: <phandle>
  Definition: if optical image stabilization is supported by this sensor,
	this property should contain phandle of respective ois node

- ir-led-src
  Usage: optional
  Value type: <phandle>
  Definition: if ir led is supported by this sensor, this property
	should contain phandle of respective ir-led node

- qcom,ir-cut-src
  Usage: optional
  Value type: <phandle>
  Definition: if ir cut is supported by this sensor, this property
	should contain phandle of respective ir-cut node

- qcom,special-support-sensors
  Usage: required
  Value type: <string>
  Definition: if only some special sensors are supported
	on this board, add sensor name in this property.

- use-shared-clk
  Usage: optional
  Value type: <boolean>
  Definition: It is booloean property. This property is required
	if the clk is shared clk between different sensor and ois, if this
	device need to be opened together.

- clock-rates
  Usage: required
  Value type: <u32>
  Definition: clock rate in Hz.

- clock-cntl-level
  Usage: required
  Value type: <string>
  Definition: All different clock level node can support.

- clock-cntl-support
  Usage: optional
  Value type: <boolean>
  Definition: Says whether clock control support is present or not

- clocks
  Usage: required
  Value type: <phandle>
  Definition: all clock phandle and source clocks.

- clock-control
  Usage: optional
  Value type: <string>
  Definition: The valid fields are "NO_SET_RATE", "INIT_RATE" and
	"SET_RATE". "NO_SET_RATE" the corresponding clock is enabled without setting
	the rate assuming some other driver has already set it to appropriate rate.
	"INIT_RATE" clock rate is not queried assuming some other driver has set
	the clock rate and ispif will set the the clock to this rate.
	"SET_RATE" clock is enabled and the rate is set to the value specified
	in the property clock-rates.

=============================
ACTUATOR MODULE
=============================

- compatible
  Usage: required
  Value type: <string>
  Definition: Should be "qcom,actuator".

- cell-index: cci hardware core index
  Usage: required
  Value type: <u32>
  Definition: Should specify the Hardware index id.

- reg
  Usage: required
  Value type: <u32>
  Definition: offset and length of the register set
	for the device for the cci operating in
	compatible mode.

- cci-device
  Usage: required
  Value type: <u32>
  Definition: should contain i2c device id to be used for this camera
	sensor

- cci-master
  Usage: required
  Value type: <u32>
  Definition: should contain i2c master id to be used for this camera
	sensor
	- 0 -> MASTER 0
	- 1 -> MASTER 1

- cam_vaf-supply
  Usage: required
  Value type: <phandle>
  Definition: should contain regulator from which AF voltage is supplied

- regulator-names
  Usage: required
  Value type: <string>
  Definition: should contain names of all regulators needed by this
	actuator. i.e. "cam_vaf"

- rgltr-cntrl-support
  Usage: optional
  Value type: <boolean>
  Definition: It is booloean property. This property is required
	if the code and regulator control parameters e.g. rgltr-min-voltage

- rgltr-min-voltage
  Usage: optional
  Value type: <u32>
  Definition: should contain minimum voltage level in mcrovolts
	for regulators mentioned in regulator-names property (in the same order)

- rgltr-max-voltage
  Usage: optional
  Value type: <u32>
  Definition: should contain maximum voltage level in mcrovolts
	for regulators mentioned in regulator-names property (in the same order)

- rgltr-load-current
  Usage: optional
  Value type: <u32>
  Definition: should contain the maximum current in microamps
	required from the regulators mentioned in the regulator-names property
	(in the same order).

=============================
OIS MODULE
=============================

- compatible
  Usage: required
  Value type: <string>
  Definition: Should be "qcom,ois".

- cell-index: cci hardware core index
  Usage: required
  Value type: <u32>
  Definition: Should specify the Hardware index id.

- reg
  Usage: required
  Value type: <u32>
  Definition: offset and length of the register set
	for the device for the cci operating in
	compatible mode.

- cci-device
  Usage: required
  Value type: <u32>
  Definition: should contain i2c device id to be used for this camera
	sensor

- cci-master
  Usage: required
  Value type: <u32>
  Definition: should contain i2c master id to be used for this camera
	sensor
	- 0 -> MASTER 0
	- 1 -> MASTER 1

- cam_vaf-supply
  Usage: required
  Value type: <phandle>
  Definition: should contain regulator from which AF voltage is supplied

- regulator-names
  Usage: required
  Value type: <string>
  Definition: should contain names of all regulators needed by this
	actuator. i.e. "cam_vaf"

- rgltr-cntrl-support
  Usage: optional
  Value type: <boolean>
  Definition: It is booloean property. This property is required
	if the code and regulator control parameters e.g. rgltr-min-voltage

- rgltr-min-voltage
  Usage: optional
  Value type: <u32>
  Definition: should contain minimum voltage level in mcrovolts
	for regulators mentioned in regulator-names property (in the same order)

- rgltr-max-voltage
  Usage: optional
  Value type: <u32>
  Definition: should contain maximum voltage level in mcrovolts
	for regulators mentioned in regulator-names property (in the same order)

- rgltr-load-current
  Usage: optional
  Value type: <u32>
  Definition: should contain the maximum current in microamps
	required from the regulators mentioned in the regulator-names property
	(in the same order).

- use-shared-clk
  Usage: optional
  Value type: <boolean>
  Definition: This property is required if the clk is shared clk between different
	sensor and ois, if this device need to be opened together.

Example:
&soc {
    led_flash0: qcom,camera-flash@0 {
         cell-index = <0>;
         compatible = "qcom,camera-flash";
         flash-source = <&pmi8994_flash0 &pmi8994_flash1>;
         torch-source = <&pmi8998_torch0 &pmi8998_torch1>;
         switch-source = <&pmi8998_switch>;
         status = "ok";
    };
};

&cam_cci0 {
    actuator0: qcom,actuator@0 {
         cell-index = <0>;
         reg = <0x0>;
         compatible = "qcom,actuator";
         cci-device = <0>;
         cci-master = <0>;
         cam_vaf-supply = <&pmi8998_bob>;
         regulator-names = "cam_vaf";
         rgltr-cntrl-support;
         rgltr-min-voltage = <2800000>;
         rgltr-max-voltage = <2800000>;
         rgltr-load-current = <100000>;
    };

	ois0: qcom,ois@0 {
         cell-index = <0>;
         reg = <0x0>;
         compatible = "qcom,ois";
         cci-device = <0>;
         cci-master = <0>;
         cam_vaf-supply = <&pmi8998_bob>;
         regulator-names = "cam_vaf";
         rgltr-cntrl-support;
         rgltr-min-voltage = <2800000>;
         rgltr-max-voltage = <2800000>;
         rgltr-load-current = <100000>;
    };

    qcom,cam-res-mgr {
         compatible = "qcom,cam-res-mgr";
         status = "ok";
         shared-gpios = <18 19>;
         pinctrl-names = "cam_res_mgr_default", "cam_res_mgr_suspend";
         pinctrl-0 = <&cam_shared_clk_active &cam_res_mgr_active>;
         pinctrl-1 = <&cam_shared_clk_suspend &cam_res_mgr_suspend>;
    };

    qcom,cam-sensor@0 {
         cell-index = <0>;
         compatible = "qcom,camera";
         reg = <0x0>;
         csiphy-sd-index = <0>;
         sensor-position-roll = <90>;
         sensor-position-pitch = <0>;
         sensor-position-yaw = <180>;
         secure = <1>;
         led-flash-src = <&led_flash0>;
         actuator-src = <&actuator0>;
         ois-src = <&ois0>;
         eeprom-src = <&eeprom0>;
         cam_vdig-supply = <&pm8009_l2>;
         cam_vio-supply = <&pm8009l_l1>;
         cam_vana-supply = <&pm8009l_l5>;
         cam_bob-supply = <&pm8150l_bob>;
         cam_clk-supply = <&tital_top_gdsc>;
         regulator-names = "cam_vio", "cam_vana", "cam_vdig",
                "cam_clk", "cam_bob";
         rgltr-cntrl-support;
         pwm-switch;
         rgltr-min-voltage = <0 2800000 1200000 0 3008000>;
         rgltr-max-voltage = <0 2800000 1200000 0 4000000>;
         rgltr-load-current = <0 80000 1200000 0 2000000>;
         gpio-no-mux = <0>;
         pinctrl-names = "cam_default", "cam_suspend";
         pinctrl-0 = <&cam_sensor_mclk0_active
                   &cam_sensor_rear_active>;
         pinctrl-1 = <&cam_sensor_mclk0_suspend
                   &cam_sensor_rear_suspend>;
         gpios = <&tlmm 13 0>,
              <&tlmm 80 0>,
              <&tlmm 79 0>;
         gpio-reset = <1>;
         gpio-standby = <2>;
         gpio-req-tbl-num = <0 1 2>;
         gpio-req-tbl-flags = <1 0 0>;
         gpio-req-tbl-label = "CAMIF_MCLK0",
                         "CAM_RESET0",
                         "CAM_VANA";
         sensor-position = <0>;
         sensor-mode = <0>;
         cci-device = <0>;
         cci-master = <0>;
         status = "ok";
         use-shared-clk;
         clocks = <&clock_mmss clk_mclk0_clk_src>,
               <&clock_mmss clk_camss_mclk0_clk>;
         clock-names = "cam_src_clk", "cam_clk";
         clock-cntl-leveli = "turbo";
         clock-rates = <24000000>;
    };
};
