2 * Copyright 2013 Red Hat Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
25 #define T_TIMEOUT 2200000
26 #define T_RISEFALL 1000
30 process(PROC_I2C_, #i2c_init, #i2c_recv)
33 /******************************************************************************
35 *****************************************************************************/
38 .b32 NV_PPWR_OUTPUT_I2C_0_SCL
39 .b32 NV_PPWR_OUTPUT_I2C_1_SCL
40 .b32 NV_PPWR_OUTPUT_I2C_2_SCL
41 .b32 NV_PPWR_OUTPUT_I2C_3_SCL
42 .b32 NV_PPWR_OUTPUT_I2C_4_SCL
43 .b32 NV_PPWR_OUTPUT_I2C_5_SCL
44 .b32 NV_PPWR_OUTPUT_I2C_6_SCL
45 .b32 NV_PPWR_OUTPUT_I2C_7_SCL
46 .b32 NV_PPWR_OUTPUT_I2C_8_SCL
47 .b32 NV_PPWR_OUTPUT_I2C_9_SCL
49 .b32 NV_PPWR_OUTPUT_I2C_0_SDA
50 .b32 NV_PPWR_OUTPUT_I2C_1_SDA
51 .b32 NV_PPWR_OUTPUT_I2C_2_SDA
52 .b32 NV_PPWR_OUTPUT_I2C_3_SDA
53 .b32 NV_PPWR_OUTPUT_I2C_4_SDA
54 .b32 NV_PPWR_OUTPUT_I2C_5_SDA
55 .b32 NV_PPWR_OUTPUT_I2C_6_SDA
56 .b32 NV_PPWR_OUTPUT_I2C_7_SDA
57 .b32 NV_PPWR_OUTPUT_I2C_8_SDA
58 .b32 NV_PPWR_OUTPUT_I2C_9_SDA
59 #if NVKM_PPWR_CHIPSET < GF119
74 /******************************************************************************
76 *****************************************************************************/
85 bra e #i2c_drive_scl_lo
86 nv_iowr(NV_PPWR_OUTPUT_SET, $r1)
89 nv_iowr(NV_PPWR_OUTPUT_CLR, $r1)
94 bra e #i2c_drive_sda_lo
95 nv_iowr(NV_PPWR_OUTPUT_SET, $r2)
98 nv_iowr(NV_PPWR_OUTPUT_CLR, $r2)
103 nv_iord($r3, NV_PPWR_INPUT)
105 bra z #i2c_sense_scl_done
112 nv_iord($r3, NV_PPWR_INPUT)
114 bra z #i2c_sense_sda_done
119 #define i2c_drive_scl(v) /*
121 */ call(i2c_drive_scl)
122 #define i2c_drive_sda(v) /*
124 */ call(i2c_drive_sda)
125 #define i2c_sense_scl() /*
126 */ call(i2c_sense_scl)
127 #define i2c_sense_sda() /*
128 */ call(i2c_sense_sda)
129 #define i2c_delay(v) /*
133 #define i2c_trace_init() /*
134 */ imm32($r6, 0x10000000) /*
135 */ sub b32 $r7 $r6 1 /*
137 #define i2c_trace_down() /*
140 */ shl b32 $r5 $r6 4 /*
141 */ sub b32 $r5 $r6 /*
146 #define i2c_trace_exit() /*
149 #define i2c_trace_next() /*
150 */ add b32 $r7 $r6 /*
152 #define i2c_trace_call(func) /*
153 */ i2c_trace_next() /*
154 */ i2c_trace_down() /*
156 */ i2c_trace_exit() /*
161 mov $r4 (T_TIMEOUT / T_RISEFALL)
164 i2c_delay(T_RISEFALL)
166 bra $p1 #i2c_raise_scl_done
168 bra nz #i2c_raise_scl_wait
175 bra not $p1 #i2c_start_rep
177 bra not $p1 #i2c_start_rep
182 i2c_trace_call(i2c_raise_scl)
183 bra not $p1 #i2c_start_out
195 i2c_delay(T_RISEFALL)
208 i2c_delay(T_RISEFALL)
209 i2c_trace_call(i2c_raise_scl)
210 bra not $p1 #i2c_bitw_out
223 i2c_delay(T_RISEFALL)
224 i2c_trace_call(i2c_raise_scl)
225 bra not $p1 #i2c_bitr_done
239 i2c_trace_call(i2c_bitr)
240 bra not $p1 #i2c_get_byte_done
243 bra nz #i2c_get_byte_next
245 i2c_trace_call(i2c_bitw)
254 i2c_trace_call(i2c_bitw)
255 bra not $p1 #i2c_put_byte_done
257 bra ne #i2c_put_byte_next
258 i2c_trace_call(i2c_bitr)
259 bra not $p1 #i2c_put_byte_done
262 bra ne #i2c_put_byte_done
263 bclr $flags $p1 // nack
268 i2c_trace_call(i2c_start)
269 bra not $p1 #i2c_addr_done
270 extr $r3 $r12 I2C__MSG_DATA0_ADDR
273 i2c_trace_call(i2c_put_byte)
278 extr $r14 $r12 I2C__MSG_DATA0_PORT
279 #if NVKM_PPWR_CHIPSET < GF119
281 add b32 $r14 #i2c_ctrl
285 add b32 $r14 0x00d014
290 call(i2c_acquire_addr)
297 call(i2c_acquire_addr)
305 // $r15 - current (i2c)
306 // $r14 - sender process name
313 extr $r1 $r12 I2C__MSG_DATA0_PORT
315 cmp b32 $r1 (#i2c_sda_map - #i2c_scl_map)
316 bra ge #i2c_recv_done
317 add b32 $r3 $r1 #i2c_sda_map
319 add b32 $r3 $r1 #i2c_scl_map
328 i2c_trace_call(i2c_acquire)
331 cmp b32 $r13 I2C__MSG_RD08
332 bra ne #i2c_recv_not_rd08
334 i2c_trace_call(i2c_addr)
335 bra not $p1 #i2c_recv_done
336 extr $r5 $r12 I2C__MSG_DATA0_RD08_REG
337 i2c_trace_call(i2c_put_byte)
338 bra not $p1 #i2c_recv_done
340 i2c_trace_call(i2c_addr)
341 bra not $p1 #i2c_recv_done
342 i2c_trace_call(i2c_get_byte)
343 bra not $p1 #i2c_recv_done
344 ins $r11 $r5 I2C__MSG_DATA1_RD08_VAL
345 i2c_trace_call(i2c_stop)
351 cmp b32 $r13 I2C__MSG_WR08
352 bra ne #i2c_recv_not_wr08
355 bra not $p1 #i2c_recv_done
356 extr $r5 $r12 I2C__MSG_DATA0_WR08_REG
358 bra not $p1 #i2c_recv_done
361 bra not $p1 #i2c_recv_done
362 extr $r5 $r11 I2C__MSG_DATA1_WR08_VAL
364 bra not $p1 #i2c_recv_done
367 extr $r5 $r12 I2C__MSG_DATA0_WR08_SYNC
368 bra nz #i2c_recv_done
375 extr $r14 $r12 I2C__MSG_DATA0_PORT
380 bra not $p2 #i2c_recv_exit
389 // $r15 - current (i2c)