Commit 2f6a470d authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Revert "Merge branch 'mctp-i2c-driver'"

This reverts commit 71812af7, reversing
changes made to cc0be1ad.

Wolfram Sang says:

Please revert. Besides the driver in net, it modifies the I2C core
code. This has not been acked by the I2C maintainer (in this case me).
So, please don't pull this in via the net tree. The question raised here
(extending SMBus calls to 255 byte) is complicated because we need ABI
backwards compatibility.

Link: https://lore.kernel.org/all/YZJ9H4eM%2FM7OXVN0@shikoro/


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 6d3b1b06
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -95,10 +95,6 @@ wants to support one of the below features, it should adapt these bindings.
- smbus-alert
	states that the optional SMBus-Alert feature apply to this bus.

- mctp-controller
	indicates that the system is accessible via this bus as an endpoint for
	MCTP over I2C transport.

Required properties (per child device)
--------------------------------------

+0 −92
Original line number Diff line number Diff line
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/net/mctp-i2c-controller.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: MCTP I2C transport binding

maintainers:
  - Matt Johnston <matt@codeconstruct.com.au>

description: |
  An mctp-i2c-controller defines a local MCTP endpoint on an I2C controller.
  MCTP I2C is specified by DMTF DSP0237.

  An mctp-i2c-controller must be attached to an I2C adapter which supports
  slave functionality. I2C busses (either directly or as subordinate mux
  busses) are attached to the mctp-i2c-controller with a 'mctp-controller'
  property on each used bus. Each mctp-controller I2C bus will be presented
  to the host system as a separate MCTP I2C instance.

properties:
  compatible:
    const: mctp-i2c-controller

  reg:
    minimum: 0x40000000
    maximum: 0x4000007f
    description: |
      7 bit I2C address of the local endpoint.
      I2C_OWN_SLAVE_ADDRESS (1<<30) flag must be set.

additionalProperties: false

required:
  - compatible
  - reg

examples:
  - |
    // Basic case of a single I2C bus
    #include <dt-bindings/i2c/i2c.h>

    i2c {
      #address-cells = <1>;
      #size-cells = <0>;
      mctp-controller;

      mctp@30 {
        compatible = "mctp-i2c-controller";
        reg = <(0x30 | I2C_OWN_SLAVE_ADDRESS)>;
      };
    };

  - |
    // Mux topology with multiple MCTP-handling busses under
    // a single mctp-i2c-controller.
    // i2c1 and i2c6 can have MCTP devices, i2c5 does not.
    #include <dt-bindings/i2c/i2c.h>

    i2c1: i2c {
      #address-cells = <1>;
      #size-cells = <0>;
      mctp-controller;

      mctp@50 {
        compatible = "mctp-i2c-controller";
        reg = <(0x50 | I2C_OWN_SLAVE_ADDRESS)>;
      };
    };

    i2c-mux {
      #address-cells = <1>;
      #size-cells = <0>;
      i2c-parent = <&i2c1>;

      i2c5: i2c@0 {
        #address-cells = <1>;
        #size-cells = <0>;
        reg = <0>;
        eeprom@33 {
          reg = <0x33>;
        };
      };

      i2c6: i2c@1 {
        #address-cells = <1>;
        #size-cells = <0>;
        reg = <1>;
        mctp-controller;
      };
    };
+2 −3
Original line number Diff line number Diff line
@@ -533,7 +533,7 @@ static u32 aspeed_i2c_master_irq(struct aspeed_i2c_bus *bus, u32 irq_status)
		msg->buf[bus->buf_index++] = recv_byte;

		if (msg->flags & I2C_M_RECV_LEN) {
			if (unlikely(recv_byte > I2C_SMBUS_V3_BLOCK_MAX)) {
			if (unlikely(recv_byte > I2C_SMBUS_BLOCK_MAX)) {
				bus->cmd_err = -EPROTO;
				aspeed_i2c_do_stop(bus);
				goto out_no_complete;
@@ -718,8 +718,7 @@ static int aspeed_i2c_master_xfer(struct i2c_adapter *adap,

static u32 aspeed_i2c_functionality(struct i2c_adapter *adap)
{
	return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL |
		I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_SMBUS_V3_BLOCK;
	return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_SMBUS_BLOCK_DATA;
}

#if IS_ENABLED(CONFIG_I2C_SLAVE)
+1 −2
Original line number Diff line number Diff line
@@ -1399,7 +1399,7 @@ static void npcm_i2c_irq_master_handler_read(struct npcm_i2c *bus)
		if (bus->read_block_use) {
			/* first byte in block protocol is the size: */
			data = npcm_i2c_rd_byte(bus);
			data = clamp_val(data, 1, I2C_SMBUS_V3_BLOCK_MAX);
			data = clamp_val(data, 1, I2C_SMBUS_BLOCK_MAX);
			bus->rd_size = data + block_extra_bytes_size;
			bus->rd_buf[bus->rd_ind++] = data;

@@ -2187,7 +2187,6 @@ static u32 npcm_i2c_functionality(struct i2c_adapter *adap)
	       I2C_FUNC_SMBUS_EMUL |
	       I2C_FUNC_SMBUS_BLOCK_DATA |
	       I2C_FUNC_SMBUS_PEC |
	       I2C_FUNC_SMBUS_V3_BLOCK |
	       I2C_FUNC_SLAVE;
}

+7 −13
Original line number Diff line number Diff line
@@ -303,8 +303,7 @@ static void i2c_smbus_try_get_dmabuf(struct i2c_msg *msg, u8 init_val)
	bool is_read = msg->flags & I2C_M_RD;
	unsigned char *dma_buf;

	dma_buf = kzalloc(I2C_SMBUS_V3_BLOCK_MAX + (is_read ? 2 : 3),
		GFP_KERNEL);
	dma_buf = kzalloc(I2C_SMBUS_BLOCK_MAX + (is_read ? 2 : 3), GFP_KERNEL);
	if (!dma_buf)
		return;

@@ -330,10 +329,9 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr,
	 * initialize most things with sane defaults, to keep the code below
	 * somewhat simpler.
	 */
	unsigned char msgbuf0[I2C_SMBUS_V3_BLOCK_MAX+3];
	unsigned char msgbuf1[I2C_SMBUS_V3_BLOCK_MAX+2];
	unsigned char msgbuf0[I2C_SMBUS_BLOCK_MAX+3];
	unsigned char msgbuf1[I2C_SMBUS_BLOCK_MAX+2];
	int nmsgs = read_write == I2C_SMBUS_READ ? 2 : 1;
	u16 block_max;
	u8 partial_pec = 0;
	int status;
	struct i2c_msg msg[2] = {
@@ -352,10 +350,6 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr,
	bool wants_pec = ((flags & I2C_CLIENT_PEC) && size != I2C_SMBUS_QUICK
			  && size != I2C_SMBUS_I2C_BLOCK_DATA);

	/* Drivers must opt in to 255 byte max block size */
	block_max = i2c_check_functionality(adapter, I2C_FUNC_SMBUS_V3_BLOCK)
			? I2C_SMBUS_V3_BLOCK_MAX : I2C_SMBUS_BLOCK_MAX;

	msgbuf0[0] = command;
	switch (size) {
	case I2C_SMBUS_QUICK:
@@ -405,7 +399,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr,
			i2c_smbus_try_get_dmabuf(&msg[1], 0);
		} else {
			msg[0].len = data->block[0] + 2;
			if (msg[0].len > block_max + 2) {
			if (msg[0].len > I2C_SMBUS_BLOCK_MAX + 2) {
				dev_err(&adapter->dev,
					"Invalid block write size %d\n",
					data->block[0]);
@@ -419,7 +413,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr,
	case I2C_SMBUS_BLOCK_PROC_CALL:
		nmsgs = 2; /* Another special case */
		read_write = I2C_SMBUS_READ;
		if (data->block[0] > block_max) {
		if (data->block[0] > I2C_SMBUS_BLOCK_MAX) {
			dev_err(&adapter->dev,
				"Invalid block write size %d\n",
				data->block[0]);
@@ -436,7 +430,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr,
		i2c_smbus_try_get_dmabuf(&msg[1], 0);
		break;
	case I2C_SMBUS_I2C_BLOCK_DATA:
		if (data->block[0] > block_max) {
		if (data->block[0] > I2C_SMBUS_BLOCK_MAX) {
			dev_err(&adapter->dev, "Invalid block %s size %d\n",
				read_write == I2C_SMBUS_READ ? "read" : "write",
				data->block[0]);
@@ -504,7 +498,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr,
			break;
		case I2C_SMBUS_BLOCK_DATA:
		case I2C_SMBUS_BLOCK_PROC_CALL:
			if (msg[1].buf[0] > block_max) {
			if (msg[1].buf[0] > I2C_SMBUS_BLOCK_MAX) {
				dev_err(&adapter->dev,
					"Invalid block size returned: %d\n",
					msg[1].buf[0]);
Loading