Commit 8c8dc4c61518124eb35f4dd9d8466378ba247e9c

Authored by Tom Rini

Merge branch 'master' of git://git.denx.de/u-boot-i2c

Showing 2 changed files Side-by-side Diff

drivers/i2c/mv_i2c.c
... ... @@ -73,7 +73,7 @@
73 73 }
74 74  
75 75 #ifdef CONFIG_I2C_MULTI_BUS
76   -static u32 i2c_regs[CONFIG_MV_I2C_NUM] = CONFIG_MV_I2C_REG;
  76 +static unsigned long i2c_regs[CONFIG_MV_I2C_NUM] = CONFIG_MV_I2C_REG;
77 77 static unsigned int bus_initialized[CONFIG_MV_I2C_NUM];
78 78 static unsigned int current_bus;
79 79  
drivers/i2c/mvtwsi.c
... ... @@ -228,14 +228,15 @@
228 228 return status;
229 229 }
230 230  
231   -/*
232   - * Ugly formula to convert m and n values to a frequency comes from
233   - * TWSI specifications
234   - */
  231 +static unsigned int twsi_calc_freq(const int n, const int m)
  232 +{
  233 +#ifdef CONFIG_SUNXI
  234 + return CONFIG_SYS_TCLK / (10 * (m + 1) * (1 << n));
  235 +#else
  236 + return CONFIG_SYS_TCLK / (10 * (m + 1) * (2 << n));
  237 +#endif
  238 +}
235 239  
236   -#define TWSI_FREQUENCY(m, n) \
237   - (CONFIG_SYS_TCLK / (10 * (m + 1) * (1 << n)))
238   -
239 240 /*
240 241 * Reset controller.
241 242 * Controller reset also resets the baud rate and slave address, so
... ... @@ -266,7 +267,7 @@
266 267 /* compute m, n setting for highest speed not above requested speed */
267 268 for (n = 0; n < 8; n++) {
268 269 for (m = 0; m < 16; m++) {
269   - tmp_speed = TWSI_FREQUENCY(m, n);
  270 + tmp_speed = twsi_calc_freq(n, m);
270 271 if ((tmp_speed <= requested_speed)
271 272 && (tmp_speed > highest_speed)) {
272 273 highest_speed = tmp_speed;