Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1 | #define USE_HW_I2C |
| 2 | #ifdef USE_HW_I2C |
| 3 | #include "ddk750_help.h" |
| 4 | #include "ddk750_reg.h" |
| 5 | #include "ddk750_hwi2c.h" |
| 6 | #include "ddk750_power.h" |
| 7 | |
| 8 | #define MAX_HWI2C_FIFO 16 |
| 9 | #define HWI2C_WAIT_TIMEOUT 0xF0000 |
| 10 | |
Mike Rapoport | 19f70ea | 2015-09-12 11:07:33 +0300 | [diff] [blame] | 11 | int sm750_hw_i2c_init( |
Mike Rapoport | a503da6 | 2015-09-12 11:07:43 +0300 | [diff] [blame] | 12 | unsigned char bus_speed_mode |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 13 | ) |
| 14 | { |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 15 | unsigned int value; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 16 | |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 17 | /* Enable GPIO 30 & 31 as IIC clock & data */ |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 18 | value = PEEK32(GPIO_MUX); |
| 19 | |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 20 | value = FIELD_SET(value, GPIO_MUX, 30, I2C) | |
| 21 | FIELD_SET(0, GPIO_MUX, 31, I2C); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 22 | POKE32(GPIO_MUX, value); |
| 23 | |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 24 | /* Enable Hardware I2C power. |
| 25 | TODO: Check if we need to enable GPIO power? |
| 26 | */ |
| 27 | enableI2C(1); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 28 | |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 29 | /* Enable the I2C Controller and set the bus speed mode */ |
| 30 | value = PEEK32(I2C_CTRL); |
Mike Rapoport | a503da6 | 2015-09-12 11:07:43 +0300 | [diff] [blame] | 31 | if (bus_speed_mode == 0) |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 32 | value = FIELD_SET(value, I2C_CTRL, MODE, STANDARD); |
| 33 | else |
| 34 | value = FIELD_SET(value, I2C_CTRL, MODE, FAST); |
| 35 | value = FIELD_SET(value, I2C_CTRL, EN, ENABLE); |
| 36 | POKE32(I2C_CTRL, value); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 37 | |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 38 | return 0; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 39 | } |
| 40 | |
Mike Rapoport | ed7042e | 2015-09-12 11:07:34 +0300 | [diff] [blame] | 41 | void sm750_hw_i2c_close(void) |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 42 | { |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 43 | unsigned int value; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 44 | |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 45 | /* Disable I2C controller */ |
| 46 | value = PEEK32(I2C_CTRL); |
| 47 | value = FIELD_SET(value, I2C_CTRL, EN, DISABLE); |
| 48 | POKE32(I2C_CTRL, value); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 49 | |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 50 | /* Disable I2C Power */ |
| 51 | enableI2C(0); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 52 | |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 53 | /* Set GPIO 30 & 31 back as GPIO pins */ |
| 54 | value = PEEK32(GPIO_MUX); |
| 55 | value = FIELD_SET(value, GPIO_MUX, 30, GPIO); |
| 56 | value = FIELD_SET(value, GPIO_MUX, 31, GPIO); |
| 57 | POKE32(GPIO_MUX, value); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 58 | } |
| 59 | |
Mike Rapoport | ac11895 | 2015-09-12 11:07:37 +0300 | [diff] [blame] | 60 | static long hw_i2c_wait_tx_done(void) |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 61 | { |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 62 | unsigned int timeout; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 63 | |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 64 | /* Wait until the transfer is completed. */ |
| 65 | timeout = HWI2C_WAIT_TIMEOUT; |
Mike Rapoport | 9137f81 | 2015-09-12 11:07:49 +0300 | [diff] [blame] | 66 | while ((FIELD_GET(PEEK32(I2C_STATUS), |
| 67 | I2C_STATUS, TX) != I2C_STATUS_TX_COMPLETED) && |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 68 | (timeout != 0)) |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 69 | timeout--; |
| 70 | |
| 71 | if (timeout == 0) |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 72 | return (-1); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 73 | |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 74 | return 0; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 75 | } |
| 76 | |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 77 | /* |
| 78 | * This function writes data to the i2c slave device registers. |
| 79 | * |
| 80 | * Parameters: |
Mike Rapoport | b3696b7 | 2015-09-12 11:07:45 +0300 | [diff] [blame] | 81 | * addr - i2c Slave device address |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 82 | * length - Total number of bytes to be written to the device |
Mike Rapoport | b3696b7 | 2015-09-12 11:07:45 +0300 | [diff] [blame] | 83 | * buf - The buffer that contains the data to be written to the |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 84 | * i2c device. |
| 85 | * |
| 86 | * Return Value: |
| 87 | * Total number of bytes those are actually written. |
| 88 | */ |
Mike Rapoport | ac11895 | 2015-09-12 11:07:37 +0300 | [diff] [blame] | 89 | static unsigned int hw_i2c_write_data( |
Mike Rapoport | b3696b7 | 2015-09-12 11:07:45 +0300 | [diff] [blame] | 90 | unsigned char addr, |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 91 | unsigned int length, |
Mike Rapoport | b3696b7 | 2015-09-12 11:07:45 +0300 | [diff] [blame] | 92 | unsigned char *buf |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 93 | ) |
| 94 | { |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 95 | unsigned char count, i; |
Mike Rapoport | b3696b7 | 2015-09-12 11:07:45 +0300 | [diff] [blame] | 96 | unsigned int total_bytes = 0; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 97 | |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 98 | /* Set the Device Address */ |
Mike Rapoport | b3696b7 | 2015-09-12 11:07:45 +0300 | [diff] [blame] | 99 | POKE32(I2C_SLAVE_ADDRESS, addr & ~0x01); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 100 | |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 101 | /* Write data. |
| 102 | * Note: |
| 103 | * Only 16 byte can be accessed per i2c start instruction. |
| 104 | */ |
Juston Li | 259fef3 | 2015-07-14 21:14:45 -0700 | [diff] [blame] | 105 | do { |
Mike Rapoport | 9137f81 | 2015-09-12 11:07:49 +0300 | [diff] [blame] | 106 | /* |
| 107 | * Reset I2C by writing 0 to I2C_RESET register to |
| 108 | * clear the previous status. |
| 109 | */ |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 110 | POKE32(I2C_RESET, 0); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 111 | |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 112 | /* Set the number of bytes to be written */ |
| 113 | if (length < MAX_HWI2C_FIFO) |
| 114 | count = length - 1; |
| 115 | else |
| 116 | count = MAX_HWI2C_FIFO - 1; |
| 117 | POKE32(I2C_BYTE_COUNT, count); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 118 | |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 119 | /* Move the data to the I2C data register */ |
| 120 | for (i = 0; i <= count; i++) |
Mike Rapoport | b3696b7 | 2015-09-12 11:07:45 +0300 | [diff] [blame] | 121 | POKE32(I2C_DATA0 + i, *buf++); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 122 | |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 123 | /* Start the I2C */ |
Mike Rapoport | 9137f81 | 2015-09-12 11:07:49 +0300 | [diff] [blame] | 124 | POKE32(I2C_CTRL, |
| 125 | FIELD_SET(PEEK32(I2C_CTRL), I2C_CTRL, CTRL, START)); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 126 | |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 127 | /* Wait until the transfer is completed. */ |
Mike Rapoport | ac11895 | 2015-09-12 11:07:37 +0300 | [diff] [blame] | 128 | if (hw_i2c_wait_tx_done() != 0) |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 129 | break; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 130 | |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 131 | /* Substract length */ |
| 132 | length -= (count + 1); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 133 | |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 134 | /* Total byte written */ |
Mike Rapoport | b3696b7 | 2015-09-12 11:07:45 +0300 | [diff] [blame] | 135 | total_bytes += (count + 1); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 136 | |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 137 | } while (length > 0); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 138 | |
Mike Rapoport | b3696b7 | 2015-09-12 11:07:45 +0300 | [diff] [blame] | 139 | return total_bytes; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 140 | } |
| 141 | |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 142 | /* |
| 143 | * This function reads data from the slave device and stores them |
| 144 | * in the given buffer |
| 145 | * |
| 146 | * Parameters: |
Mike Rapoport | b3696b7 | 2015-09-12 11:07:45 +0300 | [diff] [blame] | 147 | * addr - i2c Slave device address |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 148 | * length - Total number of bytes to be read |
Mike Rapoport | b3696b7 | 2015-09-12 11:07:45 +0300 | [diff] [blame] | 149 | * buf - Pointer to a buffer to be filled with the data read |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 150 | * from the slave device. It has to be the same size as the |
| 151 | * length to make sure that it can keep all the data read. |
| 152 | * |
| 153 | * Return Value: |
| 154 | * Total number of actual bytes read from the slave device |
| 155 | */ |
Mike Rapoport | ac11895 | 2015-09-12 11:07:37 +0300 | [diff] [blame] | 156 | static unsigned int hw_i2c_read_data( |
Mike Rapoport | b3696b7 | 2015-09-12 11:07:45 +0300 | [diff] [blame] | 157 | unsigned char addr, |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 158 | unsigned int length, |
Mike Rapoport | b3696b7 | 2015-09-12 11:07:45 +0300 | [diff] [blame] | 159 | unsigned char *buf |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 160 | ) |
| 161 | { |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 162 | unsigned char count, i; |
Mike Rapoport | b3696b7 | 2015-09-12 11:07:45 +0300 | [diff] [blame] | 163 | unsigned int total_bytes = 0; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 164 | |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 165 | /* Set the Device Address */ |
Mike Rapoport | b3696b7 | 2015-09-12 11:07:45 +0300 | [diff] [blame] | 166 | POKE32(I2C_SLAVE_ADDRESS, addr | 0x01); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 167 | |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 168 | /* Read data and save them to the buffer. |
| 169 | * Note: |
| 170 | * Only 16 byte can be accessed per i2c start instruction. |
| 171 | */ |
Juston Li | 259fef3 | 2015-07-14 21:14:45 -0700 | [diff] [blame] | 172 | do { |
Mike Rapoport | 9137f81 | 2015-09-12 11:07:49 +0300 | [diff] [blame] | 173 | /* |
| 174 | * Reset I2C by writing 0 to I2C_RESET register to |
| 175 | * clear all the status. |
| 176 | */ |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 177 | POKE32(I2C_RESET, 0); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 178 | |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 179 | /* Set the number of bytes to be read */ |
| 180 | if (length <= MAX_HWI2C_FIFO) |
| 181 | count = length - 1; |
| 182 | else |
| 183 | count = MAX_HWI2C_FIFO - 1; |
| 184 | POKE32(I2C_BYTE_COUNT, count); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 185 | |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 186 | /* Start the I2C */ |
Mike Rapoport | 9137f81 | 2015-09-12 11:07:49 +0300 | [diff] [blame] | 187 | POKE32(I2C_CTRL, |
| 188 | FIELD_SET(PEEK32(I2C_CTRL), I2C_CTRL, CTRL, START)); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 189 | |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 190 | /* Wait until transaction done. */ |
Mike Rapoport | ac11895 | 2015-09-12 11:07:37 +0300 | [diff] [blame] | 191 | if (hw_i2c_wait_tx_done() != 0) |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 192 | break; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 193 | |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 194 | /* Save the data to the given buffer */ |
| 195 | for (i = 0; i <= count; i++) |
Mike Rapoport | b3696b7 | 2015-09-12 11:07:45 +0300 | [diff] [blame] | 196 | *buf++ = PEEK32(I2C_DATA0 + i); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 197 | |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 198 | /* Substract length by 16 */ |
| 199 | length -= (count + 1); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 200 | |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 201 | /* Number of bytes read. */ |
Mike Rapoport | b3696b7 | 2015-09-12 11:07:45 +0300 | [diff] [blame] | 202 | total_bytes += (count + 1); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 203 | |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 204 | } while (length > 0); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 205 | |
Mike Rapoport | b3696b7 | 2015-09-12 11:07:45 +0300 | [diff] [blame] | 206 | return total_bytes; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 207 | } |
| 208 | |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 209 | /* |
| 210 | * This function reads the slave device's register |
| 211 | * |
| 212 | * Parameters: |
| 213 | * deviceAddress - i2c Slave device address which register |
| 214 | * to be read from |
| 215 | * registerIndex - Slave device's register to be read |
| 216 | * |
| 217 | * Return Value: |
| 218 | * Register value |
| 219 | */ |
Mike Rapoport | 5ccf734 | 2015-09-12 11:07:35 +0300 | [diff] [blame] | 220 | unsigned char sm750_hw_i2c_read_reg( |
Mike Rapoport | 938ad7e | 2015-09-12 11:07:44 +0300 | [diff] [blame] | 221 | unsigned char addr, |
| 222 | unsigned char reg |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 223 | ) |
| 224 | { |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 225 | unsigned char value = (0xFF); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 226 | |
Mike Rapoport | 938ad7e | 2015-09-12 11:07:44 +0300 | [diff] [blame] | 227 | if (hw_i2c_write_data(addr, 1, ®) == 1) |
| 228 | hw_i2c_read_data(addr, 1, &value); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 229 | |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 230 | return value; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 231 | } |
| 232 | |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 233 | /* |
| 234 | * This function writes a value to the slave device's register |
| 235 | * |
| 236 | * Parameters: |
| 237 | * deviceAddress - i2c Slave device address which register |
| 238 | * to be written |
| 239 | * registerIndex - Slave device's register to be written |
| 240 | * data - Data to be written to the register |
| 241 | * |
| 242 | * Result: |
| 243 | * 0 - Success |
| 244 | * -1 - Fail |
| 245 | */ |
Mike Rapoport | 6bdbe62 | 2015-09-12 11:07:36 +0300 | [diff] [blame] | 246 | int sm750_hw_i2c_write_reg( |
Mike Rapoport | 938ad7e | 2015-09-12 11:07:44 +0300 | [diff] [blame] | 247 | unsigned char addr, |
| 248 | unsigned char reg, |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 249 | unsigned char data |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 250 | ) |
| 251 | { |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 252 | unsigned char value[2]; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 253 | |
Mike Rapoport | 938ad7e | 2015-09-12 11:07:44 +0300 | [diff] [blame] | 254 | value[0] = reg; |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 255 | value[1] = data; |
Mike Rapoport | 938ad7e | 2015-09-12 11:07:44 +0300 | [diff] [blame] | 256 | if (hw_i2c_write_data(addr, 2, value) == 2) |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 257 | return 0; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 258 | |
Juston Li | 7837653 | 2015-07-14 21:14:30 -0700 | [diff] [blame] | 259 | return (-1); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 260 | } |
| 261 | |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 262 | #endif |