Skip to content

Add Apple M1 support to PASemi i2c driver

Sven Peter linux-arm-kernel linux-devicetree linux-i2c linuxppc-dev lkml 2 versions – Applied

Status from this message: Applied to for-next with MAINTAINER bits dropped and added tags from

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest11 patches 12 repliesApplied
  2. v110 patches 7 repliesSuperseded

Changes in v2 from the cover letter

- Added reviewed-by/acks
- Switched from ioport_map to pci_iomap as suggested by Arnd Bergmann
- Renamed i2c-pasemi-apple.c to i2c-pasemi-platform.c as suggested by Wolfram Sang
- Replaced the ioport number in the adapter name with dev_name to be able to identify separate busses in e.g. i2cdetect.

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/11dt-bindings: i2c: Add Apple I2C controller bindingsDocumentation/devicetree/bindings/i2c/apple,i2c.yaml MAINTAINERS+62 -00 replies
2/11i2c: pasemi: Use io{read,write}32drivers/i2c/busses/i2c-pasemi.c+13 -30 replies
3/11i2c: pasemi: Use dev_name instead of port numberdrivers/i2c/busses/i2c-pasemi.c+1 -10 replies
4/11i2c: pasemi: Remove usage of pci_devdrivers/i2c/busses/i2c-pasemi.c+6 -60 replies
5/11i2c: pasemi: Split off common probing codedrivers/i2c/busses/i2c-pasemi.c+25 -140 replies
6/11i2c: pasemi: Split pci driver to its own filedrivers/i2c/busses/Makefile drivers/i2c/busses/i2c-pasemi-core.c drivers/i2c/busses/i2c-pasemi-core.h +1 more+118 -860 replies
7/11i2c: pasemi: Move common reset code to own functiondrivers/i2c/busses/i2c-pasemi-core.c+9 -60 replies
8/11i2c: pasemi: Allow to configure bus frequencydrivers/i2c/busses/i2c-pasemi-core.c drivers/i2c/busses/i2c-pasemi-core.h drivers/i2c/busses/i2c-pasemi-pci.c+8 -50 replies
9/11i2c: pasemi: Refactor _probe to use devm_*drivers/i2c/busses/i2c-pasemi-core.c drivers/i2c/busses/i2c-pasemi-core.h drivers/i2c/busses/i2c-pasemi-pci.c+15 -400 replies
10/11i2c: pasemi: Add Apple platform driverMAINTAINERS drivers/i2c/busses/Kconfig drivers/i2c/busses/Makefile +1 more+136 -02 replies
11/11i2c: pasemi: Set enable bit for Apple variantdrivers/i2c/busses/i2c-pasemi-core.c drivers/i2c/busses/i2c-pasemi-core.h drivers/i2c/busses/i2c-pasemi-pci.c+17 -00 replies

Reviews trailers per patch

10 of 11 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchArnd BergmannRob HerringOlof JohanssonChristian Zigotzky
SeriesA-b T-b
1/11R-b R-b
2/11R-b
3/11
4/11R-b
5/11R-b
6/11R-b
7/11R-b
8/11R-b
9/11R-b
10/11R-b
11/11R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v2 thread

Cover letter [PATCH v2 00/11] Add Apple M1 support to PASemi i2c driver

Hi,

v1: https://lore.kernel.org/linux-i2c/[email protected]/

Changes for v2:
- Added reviewed-by/acks
- Switched from ioport_map to pci_iomap as suggested by Arnd Bergmann
- Renamed i2c-pasemi-apple.c to i2c-pasemi-platform.c as suggested by Wolfram Sang
- Replaced the ioport number in the adapter name with dev_name to be able to identify separate busses in e.g. i2cdetect.

I still don't have access to any old PASemi hardware but the changes from v1 are pretty small and I expect them to still work. Would still be nice if someone with access to such hardware could give this a quick test.

And for those who didn't see v1 the (almost) unchanged original cover letter:

This series adds support for the I2C controller found on Apple Silicon Macs which has quite a bit of history:

Apple bought P.A. Semi in 2008 and it looks like a part of its legacy continues to live on in the M1. This controller has actually been used since at least the iPhone 4S and hasn't changed much since then.
Essentially, there are only a few differences that matter:

- The controller no longer is a PCI device
- Starting at some iPhone an additional bit in one register must be set in order to start transmissions.
- The reference clock and hence the clock dividers are different

In order to add support for a platform device I first replaced PCI-specific bits and split out the PCI driver to its own file. Then I added support to make the clock divider configurable and converted the driver to use managed device resources to make it a bit simpler.

The Apple and PASemi driver will never be compiled in the same kernel since the Apple one will run on arm64 while the original PASemi driver will only be useful on powerpc.
I've thus followed the octeon (mips)/thunderx(arm64) approach to do the
split: I created a -core.c file which contains the shared logic and just compile that one for both the PASemi and the new Apple driver.

Best,

Sven

Sven Peter (11):
dt-bindings: i2c: Add Apple I2C controller bindings
i2c: pasemi: Use io{read,write}32
i2c: pasemi: Use dev_name instead of port number
i2c: pasemi: Remove usage of pci_dev
i2c: pasemi: Split off common probing code
i2c: pasemi: Split pci driver to its own file
i2c: pasemi: Move common reset code to own function
i2c: pasemi: Allow to configure bus frequency
i2c: pasemi: Refactor _probe to use devm_*
i2c: pasemi: Add Apple platform driver
i2c: pasemi: Set enable bit for Apple variant

 .../devicetree/bindings/i2c/apple,i2c.yaml    |  61 +++++++++
 MAINTAINERS                                   |   2 +
 drivers/i2c/busses/Kconfig                    |  11 ++
 drivers/i2c/busses/Makefile                   |   3 +
 .../{i2c-pasemi.c => i2c-pasemi-core.c}       | 114 +++++-----------
 drivers/i2c/busses/i2c-pasemi-core.h          |  21 +++
 drivers/i2c/busses/i2c-pasemi-pci.c           |  85 ++++++++++++
 drivers/i2c/busses/i2c-pasemi-platform.c      | 122 ++++++++++++++++++
 8 files changed, 334 insertions(+), 85 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/i2c/apple,i2c.yaml
 rename drivers/i2c/busses/{i2c-pasemi.c => i2c-pasemi-core.c} (77%)
 create mode 100644 drivers/i2c/busses/i2c-pasemi-core.h
 create mode 100644 drivers/i2c/busses/i2c-pasemi-pci.c
 create mode 100644 drivers/i2c/busses/i2c-pasemi-platform.c
Signature · 1 line
2.25.1