Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4cb3f538 authored by Virupax Sadashivpetimath's avatar Virupax Sadashivpetimath Committed by Ben Dooks
Browse files

i2c-nomadik: print abort cause only on abort tag



Modify the code to:
1)Print the cause of i2c failure only if the status is set to ABORT.
2)Print slave address on send/receive fail, will help in which slave
failed.

Signed-off-by: default avatarVirupax Sadashivpetimath <virupax.sadashivpetimath@stericsson.com>
Reviewed-by: default avatarJonas Aberg <jonas.aberg@stericsson.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarBen Dooks <ben-linux@fluff.org>
parent cd20e4fa
Loading
Loading
Loading
Loading
+19 −8
Original line number Original line Diff line number Diff line
@@ -442,7 +442,8 @@ static int read_i2c(struct nmk_i2c_dev *dev)


	if (timeout == 0) {
	if (timeout == 0) {
		/* controller has timedout, re-init the h/w */
		/* controller has timedout, re-init the h/w */
		dev_err(&dev->pdev->dev, "controller timed out, re-init h/w\n");
		dev_err(&dev->pdev->dev, "read from slave 0x%x timed out\n",
				dev->cli.slave_adr);
		(void) init_hw(dev);
		(void) init_hw(dev);
		status = -ETIMEDOUT;
		status = -ETIMEDOUT;
	}
	}
@@ -506,7 +507,8 @@ static int write_i2c(struct nmk_i2c_dev *dev)


	if (timeout == 0) {
	if (timeout == 0) {
		/* controller has timedout, re-init the h/w */
		/* controller has timedout, re-init the h/w */
		dev_err(&dev->pdev->dev, "controller timed out, re-init h/w\n");
		dev_err(&dev->pdev->dev, "write to slave 0x%x timed out\n",
				dev->cli.slave_adr);
		(void) init_hw(dev);
		(void) init_hw(dev);
		status = -ETIMEDOUT;
		status = -ETIMEDOUT;
	}
	}
@@ -568,6 +570,7 @@ static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap,
	int i;
	int i;
	u32 cause;
	u32 cause;
	struct nmk_i2c_dev *dev = i2c_get_adapdata(i2c_adap);
	struct nmk_i2c_dev *dev = i2c_get_adapdata(i2c_adap);
	u32 i2c_sr;


	dev->busy = true;
	dev->busy = true;


@@ -607,14 +610,22 @@ static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap,
			status = write_i2c(dev);
			status = write_i2c(dev);
		}
		}
		if (status || (dev->result)) {
		if (status || (dev->result)) {
			i2c_sr = readl(dev->virtbase + I2C_SR);
			/*
			 * Check if the controller I2C operation status is set
			 * to ABORT(11b).
			 */
			if (((i2c_sr >> 2) & 0x3) == 0x3) {
				/* get the abort cause */
				/* get the abort cause */
			cause =	(readl(dev->virtbase + I2C_SR) >> 4) & 0x7;
				cause =	(i2c_sr >> 4)
			dev_err(&dev->pdev->dev, "%s\n",
					& 0x7;
				cause >= ARRAY_SIZE(abort_causes)
				dev_err(&dev->pdev->dev, "%s\n", cause >=
				? "unknown reason" : abort_causes[cause]);
						ARRAY_SIZE(abort_causes) ?
						"unknown reason" :
						abort_causes[cause]);
			}


			status = status ? status : dev->result;
			status = status ? status : dev->result;

			goto out;
			goto out;
		}
		}
		udelay(I2C_DELAY);
		udelay(I2C_DELAY);