- I2C_CON_STP, &i2c_base->con);
-
- /* wait for Transmit ready condition */
- status = wait_for_status_mask(I2C_STAT_XRDY | I2C_STAT_NACK);
-
- if (status & (I2C_STAT_NACK | I2C_STAT_TIMEO))
- i2c_error = 1;
-
- if (!i2c_error) {
- if (status & I2C_STAT_XRDY) {
- switch (alen) {
-#if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX) || \
- defined(CONFIG_AM33XX)
- case 2:
- /* send out MSB byte */
- writeb(((addr >> 8) & 0xFF), &i2c_base->data);
-#else
- writeb((addr & 0xFFFF), &i2c_base->data);
- break;
-#endif
- /* Clearing XRDY event */
- writew((status & I2C_STAT_XRDY),
- &i2c_base->stat);
- /*waiting for Transmit ready * condition */
- status = wait_for_status_mask(I2C_STAT_XRDY |
- I2C_STAT_NACK);
-
- if (status & (I2C_STAT_NACK | I2C_STAT_TIMEO)) {
- i2c_error = 1;
- break;
- }
- case 1:
-#if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX) || \
- defined(CONFIG_AM33XX)
- /* send out MSB byte */
- writeb((addr & 0xFF), &i2c_base->data);
-#else
- writew(((buffer[0] << 8) | (addr & 0xFF)),
- &i2c_base->data);
-#endif
- }
-
- /* Clearing XRDY event */
- writew((status & I2C_STAT_XRDY), &i2c_base->stat);
+ I2C_CON_STP, &i2c_base->con);
+
+ while (alen) {
+ /* Must write reg offset (one or two bytes) */
+ status = wait_for_event(adap);
+ /* Try to identify bus that is not padconf'd for I2C */
+ if (status == I2C_STAT_XRDY) {
+ i2c_error = 2;
+ printf("i2c_write: pads on bus %d probably not configured (status=0x%x)\n",
+ adap->hwadapnr, status);
+ goto wr_exit;