linux icon indicating copy to clipboard operation
linux copied to clipboard

Driver for the I3C Controller IP Core

Open gastmaier opened this issue 9 months ago • 0 comments

PR Description

Creating this PR to get some preliminary feedback and because I'm sitting on it for a while without making changes. It is divided in two commits:

  • The first implements the mandatory ops
  • The second implements the optional ops, all In-band interrupt related

Even though the IP Core has an Offload engine, I didn't try to implement it, because the SPI Engine Offload is being/has been reworked and I would rather wait the final implementation to settle before trying to do the same on the I3C abstraction.

Using the upstream master/slave nomenclature for coherence, our IP core uses the spec controller/peripheral. I think we should only rename it when upstream updates the already upstream drivers.

Something that might catch the attention of reviewers is the call-back/entry point for IBIs, That is because it is allocated per driver device, along these lines:

// my_device_i3c.c

static void my_device_i3c_ibi_handler(struct i3c_device *dev,
                                      const struct i3c_ibi_payload *payload)
{
        printk("Got interrupt payload of length %u", payload->len);
}


static int my_device_i3c_probe(struct i3c_device *i3cdev)
{
        int ret;
        struct i3c_ibi_setup *ibireq;
        const struct i3c_device_id *id = i3c_device_match_id(i3cdev,
                                                             my_device_i3c_ids);

        if (!id)
                return PTR_ERR(id);

        ibireq = kzalloc(sizeof(struct i3c_ibi_setup), GFP_KERNEL);
        ibireq->max_payload_len = 1;
        ibireq->num_slots = 1;
        ibireq->handler = my_device_i3c_ibi_handler;
        ret = i3c_device_request_ibi(i3cdev, ibireq);
        kfree(ibireq);
        if (ret) {
                dev_err(&i3cdev->dev, "Failed to request i3c ibi %d\n",
                        ret);
        }

        ret = i3c_device_enable_ibi(i3cdev);
        if (ret) {
                dev_err(&i3cdev->dev, "Failed to enable i3c ibi %d\n",
                        ret);
        }

        return my_device_core_probe(&i3cdev->dev, ..., (uintptr_t)id->data);
}

PR Type

  • [ ] Bug fix (a change that fixes an issue)
  • [X] New feature (a change that adds new functionality)
  • [ ] Breaking change (a change that affects other repos or cause CIs to fail)

PR Checklist

  • [X] I have conducted a self-review of my own code changes
  • [ ] I have tested the changes on the relevant hardware
  • [ ] I have updated the documentation outside this repo accordingly (if there is the case)

gastmaier avatar May 07 '24 14:05 gastmaier