mbox series

[v2,00/11] Add Apple M1 support to PASemi i2c driver

Message ID 20211008163532.75569-1-sven@svenpeter.dev (mailing list archive)
Headers show
Series Add Apple M1 support to PASemi i2c driver | expand

Message

Sven Peter Oct. 8, 2021, 4:35 p.m. UTC
Hi,

v1: https://lore.kernel.org/linux-i2c/20210926095847.38261-1-sven@svenpeter.dev/

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

Comments

Olof Johansson Oct. 8, 2021, 8:49 p.m. UTC | #1
Hi,

On Fri, Oct 8, 2021 at 9:36 AM Sven Peter <sven@svenpeter.dev> wrote:
>
> Hi,
>
> v1: https://lore.kernel.org/linux-i2c/20210926095847.38261-1-sven@svenpeter.dev/
>
> 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.

Series:

Acked-by: Olof Johansson <olof@lixom.net>


-Olof
Wolfram Sang Oct. 9, 2021, 10:10 a.m. UTC | #2
> 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.

Looks good to me. I will wait a few more days so that people can report
their tests. But it will be in the next merge window.
Sven Peter Oct. 9, 2021, 11:30 a.m. UTC | #3
On Sat, Oct 9, 2021, at 12:10, Wolfram Sang wrote:
>> 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.
>
> Looks good to me. I will wait a few more days so that people can report
> their tests. But it will be in the next merge window.

Sounds great, thanks!


Sven
Christian Zigotzky Oct. 9, 2021, 1:57 p.m. UTC | #4
On 09 October 2021 at 12:10 pm, Wolfram Sang wrote:
>> 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.
> Looks good to me. I will wait a few more days so that people can report
> their tests. But it will be in the next merge window.
>
Series v2:

Tested-by: Christian Zigotzky <chzigotzky@xenosoft.de> [1]

- Christian

[1] https://forum.hyperion-entertainment.com/viewtopic.php?p=54213#p54213
Sven Peter Oct. 10, 2021, 1:17 p.m. UTC | #5
On Sat, Oct 9, 2021, at 15:57, Christian Zigotzky wrote:
> On 09 October 2021 at 12:10 pm, Wolfram Sang wrote:
>>> 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.
>> Looks good to me. I will wait a few more days so that people can report
>> their tests. But it will be in the next merge window.
>>
> Series v2:
>
> Tested-by: Christian Zigotzky <chzigotzky@xenosoft.de> [1]

thanks a lot, glad to hear everything works on P.A Semi CPUs as well!

And regarding that git am issue you wrote about: I think I based this series on
torvald's tree instead of 5.15-rc4 and there have been some changes to at least
MAINTAINERS. It'll probably apply cleanly to 5.15-rc5 but if that happens again
in the future you can try

  git am -3 mbox

instead. It'll try to do a three way merge if the patch doesn't apply cleanly.


Sven
Wolfram Sang Oct. 11, 2021, 8:54 a.m. UTC | #6
> MAINTAINERS. It'll probably apply cleanly to 5.15-rc5 but if that happens again

It doesn't because Linus' git doesn't have:

Documentation/devicetree/bindings/pci/apple,pcie.yaml

Because MAINTAINER dependencies can be a bit nasty, I suggest I drop the
MAINTAINER additions for now and we add them later. Then, you can add
the pasemi-core as well. D'accord?
Hector Martin Oct. 11, 2021, 9:23 a.m. UTC | #7
On 11/10/2021 17.54, Wolfram Sang wrote:
>> MAINTAINERS. It'll probably apply cleanly to 5.15-rc5 but if that happens again
> 
> It doesn't because Linus' git doesn't have:
> 
> Documentation/devicetree/bindings/pci/apple,pcie.yaml
> 
> Because MAINTAINER dependencies can be a bit nasty, I suggest I drop the
> MAINTAINER additions for now and we add them later. Then, you can add
> the pasemi-core as well. D'accord?
> 

We can just split the MAINTAINERS changes into a separate patch and I 
can push that one through the SoC tree, along with other MAINTAINERS 
updates. Does that work for everyone?
Wolfram Sang Oct. 11, 2021, 9:37 a.m. UTC | #8
> > Because MAINTAINER dependencies can be a bit nasty, I suggest I drop the
> > MAINTAINER additions for now and we add them later. Then, you can add
> > the pasemi-core as well. D'accord?
> > 
> 
> We can just split the MAINTAINERS changes into a separate patch and I can
> push that one through the SoC tree, along with other MAINTAINERS updates.
> Does that work for everyone?

That would also work for me. Thank you!
Wolfram Sang Oct. 11, 2021, 10:04 a.m. UTC | #9
On Fri, Oct 08, 2021 at 06:35:21PM +0200, Sven Peter wrote:
> Hi,
> 
> v1: https://lore.kernel.org/linux-i2c/20210926095847.38261-1-sven@svenpeter.dev/
> 
> 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 +

Applied to for-next with MAINTAINER bits dropped and added tags from
Olof and Christian, thanks!
Christian Zigotzky Oct. 13, 2021, 8:06 a.m. UTC | #10
On 09 October 2021 at 03:57 pm, Christian Zigotzky wrote:
 > On 09 October 2021 at 12:10 pm, Wolfram Sang wrote:
 >>> 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.
 >> Looks good to me. I will wait a few more days so that people can report
 >> their tests. But it will be in the next merge window.
 >>
 > Series v2:
 >
 > Tested-by: Christian Zigotzky <chzigotzky@xenosoft.de> [1]
 >
 > - Christian
 >
 > [1] 
https://forum.hyperion-entertainment.com/viewtopic.php?p=54213#p54213

Series v2:

Tested-by: Damien Stewart (Hypex) [1]

- Christian

[1] https://forum.hyperion-entertainment.com/viewtopic.php?p=54217#p54217