mediatek: add support for rtl8367c
[openwrt/staging/rmilecki.git] / target / linux / mediatek / files-5.4 / drivers / net / phy / rtk / rtl8367c / include / i2c.h
1 /*
2 * Copyright (C) 2013 Realtek Semiconductor Corp.
3 * All Rights Reserved.
4 *
5 * Unless you and Realtek execute a separate written software license
6 * agreement governing use of this software, this software is licensed
7 * to you under the terms of the GNU General Public License version 2,
8 * available at https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
9 *
10 * Purpose : RTL8367/RTL8367C switch high-level API
11 *
12 * Feature : The file includes I2C module high-layer API defination
13 *
14 */
15
16
17 #ifndef __RTK_API_I2C_H__
18 #define __RTK_API_I2C_H__
19 #include <rtk_types.h>
20
21 #define I2C_GPIO_MAX_GROUP (3)
22
23 typedef enum rtk_I2C_16bit_mode_e{
24 I2C_LSB_16BIT_MODE = 0,
25 I2C_70B_LSB_16BIT_MODE,
26 I2C_Mode_END
27 }rtk_I2C_16bit_mode_t;
28
29
30 typedef enum rtk_I2C_gpio_pin_e{
31 I2C_GPIO_PIN_8_9 = 0,
32 I2C_GPIO_PIN_15_16 ,
33 I2C_GPIO_PIN_35_36 ,
34 I2C_GPIO_PIN_END
35 }rtk_I2C_gpio_pin_t;
36
37
38 /* Function Name:
39 * rtk_i2c_data_read
40 * Description:
41 * read i2c slave device register.
42 * Input:
43 * deviceAddr - access Slave device address
44 * slaveRegAddr - access Slave register address
45 * Output:
46 * pRegData - read data
47 * Return:
48 * RT_ERR_OK - OK
49 * RT_ERR_NULL_POINTER - input parameter is null pointer
50 * Note:
51 * The API can access i2c slave and read i2c slave device register.
52 */
53 extern rtk_api_ret_t rtk_i2c_data_read(rtk_uint8 deviceAddr, rtk_uint32 slaveRegAddr, rtk_uint32 *pRegData);
54
55 /* Function Name:
56 * rtk_i2c_data_write
57 * Description:
58 * write data to i2c slave device register
59 * Input:
60 * deviceAddr - access Slave device address
61 * slaveRegAddr - access Slave register address
62 * regData - data to set
63 * Output:
64 * None
65 * Return:
66 * RT_ERR_OK - OK
67 * Note:
68 * The API can access i2c slave and setting i2c slave device register.
69 */
70 extern rtk_api_ret_t rtk_i2c_data_write(rtk_uint8 deviceAddr, rtk_uint32 slaveRegAddr, rtk_uint32 regData);
71
72
73 /* Function Name:
74 * rtk_i2c_init
75 * Description:
76 * I2C smart function initialization.
77 * Input:
78 * None
79 * Output:
80 * None
81 * Return:
82 * RT_ERR_OK - OK
83 * RT_ERR_FAILED - Failed
84 * Note:
85 * This API is used to initialize EEE status.
86 * need used GPIO pins
87 * OpenDrain and clock
88 */
89 extern rtk_api_ret_t rtk_i2c_init(void);
90
91 /* Function Name:
92 * rtk_i2c_mode_set
93 * Description:
94 * Set I2C data byte-order.
95 * Input:
96 * i2cmode - byte-order mode
97 * Output:
98 * None
99 * Return:
100 * RT_ERR_OK - OK
101 * RT_ERR_FAILED - Failed
102 * RT_ERR_INPUT - Invalid input parameter.
103 * Note:
104 * This API can set I2c traffic's byte-order .
105 */
106 extern rtk_api_ret_t rtk_i2c_mode_set( rtk_I2C_16bit_mode_t i2cmode);
107
108 /* Function Name:
109 * rtk_i2c_mode_get
110 * Description:
111 * Get i2c traffic byte-order setting.
112 * Input:
113 * None
114 * Output:
115 * pI2cMode - i2c byte-order
116 * Return:
117 * RT_ERR_OK - OK
118 * RT_ERR_FAILED - Failed
119 * RT_ERR_NULL_POINTER - input parameter is null pointer
120 * Note:
121 * The API can get i2c traffic byte-order setting.
122 */
123 extern rtk_api_ret_t rtk_i2c_mode_get( rtk_I2C_16bit_mode_t * pI2cMode);
124
125
126 /* Function Name:
127 * rtk_i2c_gpioPinGroup_set
128 * Description:
129 * Set i2c SDA & SCL used GPIO pins group.
130 * Input:
131 * pins_group - GPIO pins group
132 * Output:
133 * None
134 * Return:
135 * RT_ERR_OK - OK
136 * RT_ERR_FAILED - Failed
137 * RT_ERR_INPUT - Invalid input parameter.
138 * Note:
139 * The API can set i2c used gpio pins group.
140 * There are three group pins could be used
141 */
142 extern rtk_api_ret_t rtk_i2c_gpioPinGroup_set( rtk_I2C_gpio_pin_t pins_group);
143
144 /* Function Name:
145 * rtk_i2c_gpioPinGroup_get
146 * Description:
147 * Get i2c SDA & SCL used GPIO pins group.
148 * Input:
149 * None
150 * Output:
151 * pPins_group - GPIO pins group
152 * Return:
153 * RT_ERR_OK - OK
154 * RT_ERR_NULL_POINTER - input parameter is null pointer
155 * Note:
156 * The API can get i2c used gpio pins group.
157 * There are three group pins could be used
158 */
159 extern rtk_api_ret_t rtk_i2c_gpioPinGroup_get(rtk_I2C_gpio_pin_t * pPins_group);
160
161
162
163
164
165
166
167 #endif
168