wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Basic I2C functions |
| 3 | * |
| 4 | * Copyright (c) 2004 Texas Instruments |
| 5 | * |
| 6 | * This package is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the license found in the file |
| 8 | * named COPYING that should have accompanied this file. |
| 9 | * |
| 10 | * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
| 11 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
| 12 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
| 13 | * |
| 14 | * Author: Jian Zhang jzhang@ti.com, Texas Instruments |
| 15 | * |
| 16 | * Copyright (c) 2003 Wolfgang Denk, wd@denx.de |
| 17 | * Rewritten to fit into the current U-Boot framework |
| 18 | * |
| 19 | * Adapted for OMAP2420 I2C, r-woodruff2@ti.com |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | #include <common.h> |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 24 | |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 25 | #include <asm/arch/i2c.h> |
| 26 | #include <asm/io.h> |
| 27 | |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 28 | static void wait_for_bb (void); |
| 29 | static u16 wait_for_pin (void); |
Wolfgang Denk | 49a7581 | 2005-09-25 18:41:04 +0200 | [diff] [blame] | 30 | static void flush_fifo(void); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 31 | |
| 32 | void i2c_init (int speed, int slaveadd) |
| 33 | { |
| 34 | u16 scl; |
| 35 | |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 36 | writew(0x2, I2C_SYSC); /* for ES2 after soft reset */ |
Wolfgang Denk | 49a7581 | 2005-09-25 18:41:04 +0200 | [diff] [blame] | 37 | udelay(1000); |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 38 | writew(0x0, I2C_SYSC); /* will probably self clear but */ |
Wolfgang Denk | 49a7581 | 2005-09-25 18:41:04 +0200 | [diff] [blame] | 39 | |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 40 | if (readw (I2C_CON) & I2C_CON_EN) { |
| 41 | writew (0, I2C_CON); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 42 | udelay (50000); |
| 43 | } |
| 44 | |
Wolfgang Denk | 8ed44d9 | 2008-10-19 02:35:50 +0200 | [diff] [blame] | 45 | /* 12MHz I2C module clock */ |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 46 | writew (0, I2C_PSC); |
wdenk | 082acfd | 2005-01-10 00:01:04 +0000 | [diff] [blame] | 47 | speed = speed/1000; /* 100 or 400 */ |
| 48 | scl = ((12000/(speed*2)) - 7); /* use 7 when PSC = 0 */ |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 49 | writew (scl, I2C_SCLL); |
| 50 | writew (scl, I2C_SCLH); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 51 | /* own address */ |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 52 | writew (slaveadd, I2C_OA); |
| 53 | writew (I2C_CON_EN, I2C_CON); |
Wolfgang Denk | 49a7581 | 2005-09-25 18:41:04 +0200 | [diff] [blame] | 54 | |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 55 | /* have to enable intrrupts or OMAP i2c module doesn't work */ |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 56 | writew (I2C_IE_XRDY_IE | I2C_IE_RRDY_IE | I2C_IE_ARDY_IE | |
| 57 | I2C_IE_NACK_IE | I2C_IE_AL_IE, I2C_IE); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 58 | udelay (1000); |
Wolfgang Denk | 49a7581 | 2005-09-25 18:41:04 +0200 | [diff] [blame] | 59 | flush_fifo(); |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 60 | writew (0xFFFF, I2C_STAT); |
| 61 | writew (0, I2C_CNT); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | static int i2c_read_byte (u8 devaddr, u8 regoffset, u8 * value) |
| 65 | { |
| 66 | int i2c_error = 0; |
| 67 | u16 status; |
| 68 | |
| 69 | /* wait until bus not busy */ |
| 70 | wait_for_bb (); |
| 71 | |
| 72 | /* one byte only */ |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 73 | writew (1, I2C_CNT); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 74 | /* set slave address */ |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 75 | writew (devaddr, I2C_SA); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 76 | /* no stop bit needed here */ |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 77 | writew (I2C_CON_EN | I2C_CON_MST | I2C_CON_STT | I2C_CON_TRX, I2C_CON); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 78 | |
| 79 | status = wait_for_pin (); |
| 80 | |
| 81 | if (status & I2C_STAT_XRDY) { |
| 82 | /* Important: have to use byte access */ |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 83 | writeb (regoffset, I2C_DATA); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 84 | udelay (20000); |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 85 | if (readw (I2C_STAT) & I2C_STAT_NACK) { |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 86 | i2c_error = 1; |
| 87 | } |
| 88 | } else { |
| 89 | i2c_error = 1; |
| 90 | } |
| 91 | |
| 92 | if (!i2c_error) { |
| 93 | /* free bus, otherwise we can't use a combined transction */ |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 94 | writew (0, I2C_CON); |
| 95 | while (readw (I2C_STAT) || (readw (I2C_CON) & I2C_CON_MST)) { |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 96 | udelay (10000); |
| 97 | /* Have to clear pending interrupt to clear I2C_STAT */ |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 98 | writew (0xFFFF, I2C_STAT); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | wait_for_bb (); |
| 102 | /* set slave address */ |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 103 | writew (devaddr, I2C_SA); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 104 | /* read one byte from slave */ |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 105 | writew (1, I2C_CNT); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 106 | /* need stop bit here */ |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 107 | writew (I2C_CON_EN | I2C_CON_MST | I2C_CON_STT | I2C_CON_STP, |
| 108 | I2C_CON); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 109 | |
| 110 | status = wait_for_pin (); |
| 111 | if (status & I2C_STAT_RRDY) { |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 112 | *value = readw (I2C_DATA); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 113 | udelay (20000); |
| 114 | } else { |
| 115 | i2c_error = 1; |
| 116 | } |
| 117 | |
| 118 | if (!i2c_error) { |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 119 | writew (I2C_CON_EN, I2C_CON); |
| 120 | while (readw (I2C_STAT) |
| 121 | || (readw (I2C_CON) & I2C_CON_MST)) { |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 122 | udelay (10000); |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 123 | writew (0xFFFF, I2C_STAT); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 124 | } |
| 125 | } |
| 126 | } |
| 127 | flush_fifo(); |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 128 | writew (0xFFFF, I2C_STAT); |
| 129 | writew (0, I2C_CNT); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 130 | return i2c_error; |
| 131 | } |
| 132 | |
| 133 | static int i2c_write_byte (u8 devaddr, u8 regoffset, u8 value) |
| 134 | { |
| 135 | int i2c_error = 0; |
| 136 | u16 status, stat; |
| 137 | |
| 138 | /* wait until bus not busy */ |
| 139 | wait_for_bb (); |
| 140 | |
| 141 | /* two bytes */ |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 142 | writew (2, I2C_CNT); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 143 | /* set slave address */ |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 144 | writew (devaddr, I2C_SA); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 145 | /* stop bit needed here */ |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 146 | writew (I2C_CON_EN | I2C_CON_MST | I2C_CON_STT | I2C_CON_TRX | |
| 147 | I2C_CON_STP, I2C_CON); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 148 | |
| 149 | /* wait until state change */ |
| 150 | status = wait_for_pin (); |
| 151 | |
| 152 | if (status & I2C_STAT_XRDY) { |
| 153 | /* send out two bytes */ |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 154 | writew ((value << 8) + regoffset, I2C_DATA); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 155 | /* must have enough delay to allow BB bit to go low */ |
| 156 | udelay (50000); |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 157 | if (readw (I2C_STAT) & I2C_STAT_NACK) { |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 158 | i2c_error = 1; |
| 159 | } |
| 160 | } else { |
| 161 | i2c_error = 1; |
| 162 | } |
| 163 | |
| 164 | if (!i2c_error) { |
Wolfgang Denk | 49a7581 | 2005-09-25 18:41:04 +0200 | [diff] [blame] | 165 | int eout = 200; |
| 166 | |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 167 | writew (I2C_CON_EN, I2C_CON); |
| 168 | while ((stat = readw (I2C_STAT)) || (readw (I2C_CON) & I2C_CON_MST)) { |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 169 | udelay (1000); |
| 170 | /* have to read to clear intrrupt */ |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 171 | writew (0xFFFF, I2C_STAT); |
Wolfgang Denk | 49a7581 | 2005-09-25 18:41:04 +0200 | [diff] [blame] | 172 | if(--eout == 0) /* better leave with error than hang */ |
| 173 | break; |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 174 | } |
| 175 | } |
| 176 | flush_fifo(); |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 177 | writew (0xFFFF, I2C_STAT); |
| 178 | writew (0, I2C_CNT); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 179 | return i2c_error; |
| 180 | } |
| 181 | |
Wolfgang Denk | 49a7581 | 2005-09-25 18:41:04 +0200 | [diff] [blame] | 182 | static void flush_fifo(void) |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 183 | { u16 stat; |
wdenk | 082acfd | 2005-01-10 00:01:04 +0000 | [diff] [blame] | 184 | |
| 185 | /* note: if you try and read data when its not there or ready |
| 186 | * you get a bus error |
| 187 | */ |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 188 | while(1){ |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 189 | stat = readw(I2C_STAT); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 190 | if(stat == I2C_STAT_RRDY){ |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 191 | readw(I2C_DATA); |
| 192 | writew(I2C_STAT_RRDY,I2C_STAT); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 193 | udelay(1000); |
| 194 | }else |
| 195 | break; |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | int i2c_probe (uchar chip) |
| 200 | { |
| 201 | int res = 1; /* default = fail */ |
| 202 | |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 203 | if (chip == readw (I2C_OA)) { |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 204 | return res; |
| 205 | } |
| 206 | |
| 207 | /* wait until bus not busy */ |
| 208 | wait_for_bb (); |
| 209 | |
| 210 | /* try to read one byte */ |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 211 | writew (1, I2C_CNT); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 212 | /* set slave address */ |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 213 | writew (chip, I2C_SA); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 214 | /* stop bit needed here */ |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 215 | writew (I2C_CON_EN | I2C_CON_MST | I2C_CON_STT | I2C_CON_STP, I2C_CON); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 216 | /* enough delay for the NACK bit set */ |
| 217 | udelay (50000); |
| 218 | |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 219 | if (!(readw (I2C_STAT) & I2C_STAT_NACK)) { |
wdenk | 082acfd | 2005-01-10 00:01:04 +0000 | [diff] [blame] | 220 | res = 0; /* success case */ |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 221 | flush_fifo(); |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 222 | writew(0xFFFF, I2C_STAT); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 223 | } else { |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 224 | writew(0xFFFF, I2C_STAT); /* failue, clear sources*/ |
| 225 | writew (readw (I2C_CON) | I2C_CON_STP, I2C_CON); /* finish up xfer */ |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 226 | udelay(20000); |
| 227 | wait_for_bb (); |
| 228 | } |
| 229 | flush_fifo(); |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 230 | writew (0, I2C_CNT); /* don't allow any more data in...we don't want it.*/ |
| 231 | writew(0xFFFF, I2C_STAT); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 232 | return res; |
| 233 | } |
| 234 | |
| 235 | int i2c_read (uchar chip, uint addr, int alen, uchar * buffer, int len) |
| 236 | { |
| 237 | int i; |
| 238 | |
| 239 | if (alen > 1) { |
| 240 | printf ("I2C read: addr len %d not supported\n", alen); |
| 241 | return 1; |
| 242 | } |
| 243 | |
| 244 | if (addr + len > 256) { |
| 245 | printf ("I2C read: address out of range\n"); |
| 246 | return 1; |
| 247 | } |
| 248 | |
| 249 | for (i = 0; i < len; i++) { |
| 250 | if (i2c_read_byte (chip, addr + i, &buffer[i])) { |
| 251 | printf ("I2C read: I/O error\n"); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 252 | i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 253 | return 1; |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | return 0; |
| 258 | } |
| 259 | |
| 260 | int i2c_write (uchar chip, uint addr, int alen, uchar * buffer, int len) |
| 261 | { |
| 262 | int i; |
| 263 | |
| 264 | if (alen > 1) { |
| 265 | printf ("I2C read: addr len %d not supported\n", alen); |
| 266 | return 1; |
| 267 | } |
| 268 | |
| 269 | if (addr + len > 256) { |
| 270 | printf ("I2C read: address out of range\n"); |
| 271 | return 1; |
| 272 | } |
| 273 | |
| 274 | for (i = 0; i < len; i++) { |
| 275 | if (i2c_write_byte (chip, addr + i, buffer[i])) { |
| 276 | printf ("I2C read: I/O error\n"); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 277 | i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 278 | return 1; |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | return 0; |
| 283 | } |
| 284 | |
| 285 | static void wait_for_bb (void) |
| 286 | { |
| 287 | int timeout = 10; |
| 288 | u16 stat; |
| 289 | |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 290 | writew(0xFFFF, I2C_STAT); /* clear current interruts...*/ |
| 291 | while ((stat = readw (I2C_STAT) & I2C_STAT_BB) && timeout--) { |
| 292 | writew (stat, I2C_STAT); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 293 | udelay (50000); |
| 294 | } |
| 295 | |
| 296 | if (timeout <= 0) { |
| 297 | printf ("timed out in wait_for_bb: I2C_STAT=%x\n", |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 298 | readw (I2C_STAT)); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 299 | } |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 300 | writew(0xFFFF, I2C_STAT); /* clear delayed stuff*/ |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 301 | } |
| 302 | |
| 303 | static u16 wait_for_pin (void) |
| 304 | { |
| 305 | u16 status; |
| 306 | int timeout = 10; |
| 307 | |
| 308 | do { |
| 309 | udelay (1000); |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 310 | status = readw (I2C_STAT); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 311 | } while ( !(status & |
| 312 | (I2C_STAT_ROVR | I2C_STAT_XUDF | I2C_STAT_XRDY | |
| 313 | I2C_STAT_RRDY | I2C_STAT_ARDY | I2C_STAT_NACK | |
| 314 | I2C_STAT_AL)) && timeout--); |
| 315 | |
| 316 | if (timeout <= 0) { |
| 317 | printf ("timed out in wait_for_pin: I2C_STAT=%x\n", |
Dirk Behme | e23c7c9 | 2008-11-10 20:15:25 +0100 | [diff] [blame^] | 318 | readw (I2C_STAT)); |
| 319 | writew(0xFFFF, I2C_STAT); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 320 | } |
| 321 | return status; |
| 322 | } |