Commit f60d68e6 authored by Wolfram Sang's avatar Wolfram Sang
Browse files

Merge tag 'i2c-host-6.19-v2' of...

Merge tag 'i2c-host-6.19-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux into i2c/for-mergewindow

i2c-host for v6.19

- general cleanups in bcm2835, designware, pcf8584, and stm32
- amd-mp2: fix device refcount
- designware: avoid interrupt storms caused by bad firmware
- i801: fix supported features
- spacemit: fix device detection failures

New device support:
- Intel Diamond Rapids
- Rockchip RK3506
- Qualcomm Kaanapali, MSM8953
parents 41469074 25faa536
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ properties:
              - rockchip,px30-i2c
              - rockchip,rk3308-i2c
              - rockchip,rk3328-i2c
              - rockchip,rk3506-i2c
              - rockchip,rk3528-i2c
              - rockchip,rk3562-i2c
              - rockchip,rk3568-i2c
+4 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@ properties:
    oneOf:
      - enum:
          - qcom,msm8226-cci
          - qcom,msm8953-cci
          - qcom,msm8974-cci
          - qcom,msm8996-cci

@@ -25,6 +26,7 @@ properties:

      - items:
          - enum:
              - qcom,kaanapali-cci
              - qcom,qcm2290-cci
              - qcom,sa8775p-cci
              - qcom,sc7280-cci
@@ -128,6 +130,7 @@ allOf:
        compatible:
          contains:
            enum:
              - qcom,kaanapali-cci
              - qcom,qcm2290-cci
    then:
      properties:
@@ -146,6 +149,7 @@ allOf:
            - contains:
                enum:
                  - qcom,msm8916-cci
                  - qcom,msm8953-cci

            - const: qcom,msm8996-cci
    then:
+1 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ Supported adapters:
  * Intel Arrow Lake (SOC)
  * Intel Panther Lake (SOC)
  * Intel Wildcat Lake (SOC)
  * Intel Diamond Rapids (SOC)

   Datasheets: Publicly available at the Intel website

+25 −80
Original line number Diff line number Diff line
@@ -23,17 +23,8 @@
#include "i2c-algo-pcf.h"


#define DEB2(x) if (i2c_debug >= 2) x
#define DEB3(x) if (i2c_debug >= 3) x /* print several statistical values */
#define DEBPROTO(x) if (i2c_debug >= 9) x;
	/* debug the protocol by showing transferred bits */
#define DEF_TIMEOUT 16

/*
 * module parameters:
 */
static int i2c_debug;

/* setting states on the bus with the right timing: */

#define set_pcf(adap, ctl, val) adap->setpcf(adap->data, ctl, val)
@@ -47,27 +38,21 @@ static int i2c_debug;

static void i2c_start(struct i2c_algo_pcf_data *adap)
{
	DEBPROTO(printk(KERN_DEBUG "S "));
	set_pcf(adap, 1, I2C_PCF_START);
}

static void i2c_repstart(struct i2c_algo_pcf_data *adap)
{
	DEBPROTO(printk(" Sr "));
	set_pcf(adap, 1, I2C_PCF_REPSTART);
}

static void i2c_stop(struct i2c_algo_pcf_data *adap)
{
	DEBPROTO(printk("P\n"));
	set_pcf(adap, 1, I2C_PCF_STOP);
}

static void handle_lab(struct i2c_algo_pcf_data *adap, const int *status)
{
	DEB2(printk(KERN_INFO
		"i2c-algo-pcf.o: lost arbitration (CSR 0x%02x)\n",
		*status));
	/*
	 * Cleanup from LAB -- reset and enable ESO.
	 * This resets the PCF8584; since we've lost the bus, no
@@ -88,9 +73,6 @@ static void handle_lab(struct i2c_algo_pcf_data *adap, const int *status)
	if (adap->lab_mdelay)
		mdelay(adap->lab_mdelay);

	DEB2(printk(KERN_INFO
		"i2c-algo-pcf.o: reset LAB condition (CSR 0x%02x)\n",
		get_pcf(adap, 1)));
}

static int wait_for_bb(struct i2c_algo_pcf_data *adap)
@@ -151,52 +133,44 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
{
	unsigned char temp;

	DEB3(printk(KERN_DEBUG "i2c-algo-pcf.o: PCF state 0x%02x\n",
				get_pcf(adap, 1)));

	/* S1=0x80: S0 selected, serial interface off */
	set_pcf(adap, 1, I2C_PCF_PIN);
	/*
	 * check to see S1 now used as R/W ctrl -
	 * PCF8584 does that when ESO is zero
	 */
	if (((temp = get_pcf(adap, 1)) & 0x7f) != (0)) {
		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S0 (0x%02x).\n", temp));
	temp = get_pcf(adap, 1);
	if ((temp & 0x7f) != 0)
		return -ENXIO; /* definitely not PCF8584 */
	}

	/* load own address in S0, effective address is (own << 1) */
	i2c_outb(adap, get_own(adap));
	/* check it's really written */
	if ((temp = i2c_inb(adap)) != get_own(adap)) {
		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't set S0 (0x%02x).\n", temp));
	temp = i2c_inb(adap);
	if (temp != get_own(adap))
		return -ENXIO;
	}

	/* S1=0xA0, next byte in S2 */
	set_pcf(adap, 1, I2C_PCF_PIN | I2C_PCF_ES1);
	/* check to see S2 now selected */
	if (((temp = get_pcf(adap, 1)) & 0x7f) != I2C_PCF_ES1) {
		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S2 (0x%02x).\n", temp));
	temp = get_pcf(adap, 1);
	if ((temp & 0x7f) != I2C_PCF_ES1)
		return -ENXIO;
	}

	/* load clock register S2 */
	i2c_outb(adap, get_clock(adap));
	/* check it's really written, the only 5 lowest bits does matter */
	if (((temp = i2c_inb(adap)) & 0x1f) != get_clock(adap)) {
		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't set S2 (0x%02x).\n", temp));
	temp = i2c_inb(adap);
	if ((temp & 0x1f) != get_clock(adap))
		return -ENXIO;
	}

	/* Enable serial interface, idle, S0 selected */
	set_pcf(adap, 1, I2C_PCF_IDLE);

	/* check to see PCF is really idled and we can access status register */
	if ((temp = get_pcf(adap, 1)) != (I2C_PCF_PIN | I2C_PCF_BB)) {
		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S1` (0x%02x).\n", temp));
	temp = get_pcf(adap, 1);
	if (temp != (I2C_PCF_PIN | I2C_PCF_BB))
		return -ENXIO;
	}

	printk(KERN_DEBUG "i2c-algo-pcf.o: detected and initialized PCF8584.\n");

@@ -210,8 +184,6 @@ static int pcf_sendbytes(struct i2c_adapter *i2c_adap, const char *buf,
	int wrcount, status, timeout;

	for (wrcount = 0; wrcount < count; ++wrcount) {
		DEB2(dev_dbg(&i2c_adap->dev, "i2c_write: writing %2.2X\n",
				buf[wrcount] & 0xff));
		i2c_outb(adap, buf[wrcount]);
		timeout = wait_for_pin(adap, &status);
		if (timeout) {
@@ -246,7 +218,8 @@ static int pcf_readbytes(struct i2c_adapter *i2c_adap, char *buf,
	/* increment number of bytes to read by one -- read dummy byte */
	for (i = 0; i <= count; i++) {

		if ((wfp = wait_for_pin(adap, &status))) {
		wfp = wait_for_pin(adap, &status);
		if (wfp) {
			if (wfp == -EINTR)
				return -EINTR; /* arbitration lost */

@@ -280,7 +253,7 @@ static int pcf_readbytes(struct i2c_adapter *i2c_adap, char *buf,
}


static int pcf_doAddress(struct i2c_algo_pcf_data *adap,
static void pcf_send_address(struct i2c_algo_pcf_data *adap,
			 struct i2c_msg *msg)
{
	unsigned char addr = i2c_8bit_addr_from_msg(msg);
@@ -288,8 +261,6 @@ static int pcf_doAddress(struct i2c_algo_pcf_data *adap,
	if (msg->flags & I2C_M_REV_DIR_ADDR)
		addr ^= 1;
	i2c_outb(adap, addr);

	return 0;
}

static int pcf_xfer(struct i2c_adapter *i2c_adap,
@@ -299,7 +270,7 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
	struct i2c_algo_pcf_data *adap = i2c_adap->algo_data;
	struct i2c_msg *pmsg;
	int i;
	int ret=0, timeout, status;
	int timeout, status;

	if (adap->xfer_begin)
		adap->xfer_begin(adap->data);
@@ -307,20 +278,15 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
	/* Check for bus busy */
	timeout = wait_for_bb(adap);
	if (timeout) {
		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: "
			    "Timeout waiting for BB in pcf_xfer\n");)
		i = -EIO;
		goto out;
	}

	for (i = 0;ret >= 0 && i < num; i++) {
		pmsg = &msgs[i];

		DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: Doing %s %d bytes to 0x%02x - %d of %d messages\n",
		     str_read_write(pmsg->flags & I2C_M_RD),
		     pmsg->len, pmsg->addr, i + 1, num);)
	for (i = 0; i < num; i++) {
		int ret;

		ret = pcf_doAddress(adap, pmsg);
		pmsg = &msgs[i];
		pcf_send_address(adap, pmsg);

		/* Send START */
		if (i == 0)
@@ -335,8 +301,6 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
				goto out;
			}
			i2c_stop(adap);
			DEB2(printk(KERN_ERR "i2c-algo-pcf.o: Timeout waiting "
				    "for PIN(1) in pcf_xfer\n");)
			i = -EREMOTEIO;
			goto out;
		}
@@ -344,35 +308,21 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
		/* Check LRB (last rcvd bit - slave ack) */
		if (status & I2C_PCF_LRB) {
			i2c_stop(adap);
			DEB2(printk(KERN_ERR "i2c-algo-pcf.o: No LRB(1) in pcf_xfer\n");)
			i = -EREMOTEIO;
			goto out;
		}

		DEB3(printk(KERN_DEBUG "i2c-algo-pcf.o: Msg %d, addr=0x%x, flags=0x%x, len=%d\n",
			    i, msgs[i].addr, msgs[i].flags, msgs[i].len);)

		if (pmsg->flags & I2C_M_RD) {
			ret = pcf_readbytes(i2c_adap, pmsg->buf, pmsg->len,
					    (i + 1 == num));

			if (ret != pmsg->len) {
				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: fail: "
					    "only read %d bytes.\n",ret));
			} else {
				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: read %d bytes.\n",ret));
			}
		} else {
			ret = pcf_sendbytes(i2c_adap, pmsg->buf, pmsg->len,
					    (i + 1 == num));

			if (ret != pmsg->len) {
				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: fail: "
					    "only wrote %d bytes.\n",ret));
			} else {
				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: wrote %d bytes.\n",ret));
			}
		}

		if (ret < 0)
			goto out;
	}

out:
@@ -401,12 +351,11 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap)
	struct i2c_algo_pcf_data *pcf_adap = adap->algo_data;
	int rval;

	DEB2(dev_dbg(&adap->dev, "hw routines registered.\n"));

	/* register new adapter to i2c module... */
	adap->algo = &pcf_algo;

	if ((rval = pcf_init_8584(pcf_adap)))
	rval = pcf_init_8584(pcf_adap);
	if (rval)
		return rval;

	rval = i2c_add_adapter(adap);
@@ -418,7 +367,3 @@ EXPORT_SYMBOL(i2c_pcf_add_bus);
MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>");
MODULE_DESCRIPTION("I2C-Bus PCF8584 algorithm");
MODULE_LICENSE("GPL");

module_param(i2c_debug, int, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(i2c_debug,
	"debug level - 0 off; 1 normal; 2,3 more verbose; 9 pcf-protocol");
+1 −0
Original line number Diff line number Diff line
@@ -166,6 +166,7 @@ config I2C_I801
	    Arrow Lake (SOC)
	    Panther Lake (SOC)
	    Wildcat Lake (SOC)
	    Diamond Rapids (SOC)

	  This driver can also be built as a module.  If so, the module
	  will be called i2c-i801.
Loading