~ubuntu-branches/ubuntu/saucy/u-boot/saucy

« back to all changes in this revision

Viewing changes to drivers/i2c/omap24xx_i2c.c

  • Committer: Package Import Robot
  • Author(s): Clint Adams
  • Date: 2012-05-01 18:07:19 UTC
  • mfrom: (16.1.23 sid)
  • Revision ID: package-import@ubuntu.com-20120501180719-rjntk3287im4a0ns
Tags: 2012.04.01-1
* New upstream version.
  - Update mipsel-native-endianness.diff.
  - Update no-error-on-set-but-unused-variables.diff (partially merged).
  - Drop kirkwood_spi-irq_mask.diff (merged).
  - Drop kirkwood-disable-l2c.diff (merged).

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
static u16 wait_for_pin(void);
36
36
static void flush_fifo(void);
37
37
 
38
 
static struct i2c *i2c_base = (struct i2c *)I2C_DEFAULT_BASE;
39
 
 
40
 
static unsigned int bus_initialized[I2C_BUS_MAX];
41
 
static unsigned int current_bus;
 
38
/*
 
39
 * For SPL boot some boards need i2c before SDRAM is initialised so force
 
40
 * variables to live in SRAM
 
41
 */
 
42
static struct i2c __attribute__((section (".data"))) *i2c_base =
 
43
                                        (struct i2c *)I2C_DEFAULT_BASE;
 
44
static unsigned int __attribute__((section (".data"))) bus_initialized[I2C_BUS_MAX] =
 
45
                                        { [0 ... (I2C_BUS_MAX-1)] = 0 };
 
46
static unsigned int __attribute__((section (".data"))) current_bus = 0;
42
47
 
43
48
void i2c_init(int speed, int slaveadd)
44
49
{
73
78
                fssclh -= I2C_HIGHSPEED_PHASE_ONE_SCLH_TRIM;
74
79
                if (((fsscll < 0) || (fssclh < 0)) ||
75
80
                    ((fsscll > 255) || (fssclh > 255))) {
76
 
                        printf("Error : I2C initializing first phase clock\n");
 
81
                        puts("Error : I2C initializing first phase clock\n");
77
82
                        return;
78
83
                }
79
84
 
84
89
                hssclh -= I2C_HIGHSPEED_PHASE_TWO_SCLH_TRIM;
85
90
                if (((fsscll < 0) || (fssclh < 0)) ||
86
91
                    ((fsscll > 255) || (fssclh > 255))) {
87
 
                        printf("Error : I2C initializing second phase clock\n");
 
92
                        puts("Error : I2C initializing second phase clock\n");
88
93
                        return;
89
94
                }
90
95
 
99
104
                fssclh -= I2C_FASTSPEED_SCLH_TRIM;
100
105
                if (((fsscll < 0) || (fssclh < 0)) ||
101
106
                    ((fsscll > 255) || (fssclh > 255))) {
102
 
                        printf("Error : I2C initializing clock\n");
 
107
                        puts("Error : I2C initializing clock\n");
103
108
                        return;
104
109
                }
105
110
 
118
123
        writew(I2C_CON_EN, &i2c_base->con);
119
124
        while (!(readw(&i2c_base->syss) & I2C_SYSS_RDONE) && timeout--) {
120
125
                if (timeout <= 0) {
121
 
                        printf("ERROR: Timeout in soft-reset\n");
 
126
                        puts("ERROR: Timeout in soft-reset\n");
122
127
                        return;
123
128
                }
124
129
                udelay(1000);
284
289
        }
285
290
 
286
291
        if (addr + len > 256) {
287
 
                printf("I2C read: address out of range\n");
 
292
                puts("I2C read: address out of range\n");
288
293
                return 1;
289
294
        }
290
295
 
291
296
        for (i = 0; i < len; i++) {
292
297
                if (i2c_read_byte(chip, addr + i, &buffer[i])) {
293
 
                        printf("I2C read: I/O error\n");
 
298
                        puts("I2C read: I/O error\n");
294
299
                        i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
295
300
                        return 1;
296
301
                }