From: Sven Peter <hidden> Date: 2021-10-08 16:36:28
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
--
2.25.1
From: Sven Peter <hidden> Date: 2021-10-08 16:36:30
The Apple I2C controller is based on the PASemi I2C controller.
It is present on Apple SoCs such as the M1.
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sven Peter <redacted>
---
v1 -> v2: no changes
.../devicetree/bindings/i2c/apple,i2c.yaml | 61 +++++++++++++++++++
MAINTAINERS | 1 +
2 files changed, 62 insertions(+)
create mode 100644 Documentation/devicetree/bindings/i2c/apple,i2c.yaml
@@ -0,0 +1,61 @@+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)+%YAML1.2+---+$id:"http://devicetree.org/schemas/i2c/apple,i2c.yaml#"+$schema:"http://devicetree.org/meta-schemas/core.yaml#"++title:Apple/PASemi I2C controller++maintainers:+-Sven Peter <sven@svenpeter.dev>++description:|+Apple SoCs such as the M1 come with a I2C controller based on the one found+in machines with P. A. Semi's PWRficient processors.+The bus is used to communicate with e.g. USB PD chips or the speaker+amp.++allOf:+-$ref:/schemas/i2c/i2c-controller.yaml#++properties:+compatible:+enum:+-apple,t8103-i2c+-apple,i2c++reg:+maxItems:1++clocks:+items:+-description:I2C bus reference clock++interrupts:+maxItems:1++clock-frequency:+description:|+Desired I2C bus clock frequency in Hz. If not specified, 100 kHz will be+used. This frequency is generated by dividing the reference clock.+Allowed values are between ref_clk/(16*4) and ref_clk/(16*255).++required:+-compatible+-reg+-clocks+-interrupts++unevaluatedProperties:false++examples:+-|+i2c@35010000 {+compatible = "apple,t8103-i2c";+reg = <0x35010000 0x4000>;+interrupt-parent = <&aic>;+interrupts = <0 627 4>;+clocks = <&ref_clk>;+#address-cells = <1>;+#size-cells = <0>;+};
From: Sven Peter <hidden> Date: 2021-10-08 16:36:33
In preparation for splitting this driver up into a platform_driver
and a pci_driver, replace outl/inl usage with pci_iomap and
ioread32/iowrite32.
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sven Peter <redacted>
---
v1 -> v2: replaced ioport_map with pci_iomap
drivers/i2c/busses/i2c-pasemi.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
From: Sven Peter <hidden> Date: 2021-10-08 16:36:35
Right now the i2c adapter name includes the port number which can
indirectly be used to identify the device. Replace that with dev_name
to directly identify the device and to also allow this to work correctly
once we add platform support.
Signed-off-by: Sven Peter <redacted>
---
v1 -> v2: new commit
drivers/i2c/busses/i2c-pasemi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Sven Peter <hidden> Date: 2021-10-08 16:36:39
Prepare to create a platform driver by removing all usages of pci_dev we
can.
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sven Peter <redacted>
---
v1 -> v2: no changes
drivers/i2c/busses/i2c-pasemi.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
@@ -52,7 +52,7 @@ struct pasemi_smbus {staticinlinevoidreg_write(structpasemi_smbus*smbus,intreg,intval){-dev_dbg(&smbus->dev->dev,"smbus write reg %lx val %08x\n",+dev_dbg(smbus->dev,"smbus write reg %lx val %08x\n",smbus->base+reg,val);iowrite32(val,smbus->ioaddr+reg);}
@@ -61,7 +61,7 @@ static inline int reg_read(struct pasemi_smbus *smbus, int reg){intret;ret=ioread32(smbus->ioaddr+reg);-dev_dbg(&smbus->dev->dev,"smbus read reg %lx val %08x\n",+dev_dbg(smbus->dev,"smbus read reg %lx val %08x\n",smbus->base+reg,ret);returnret;}
@@ -94,7 +94,7 @@ static int pasemi_smb_waitready(struct pasemi_smbus *smbus)return-ENXIO;if(timeout<0){-dev_warn(&smbus->dev->dev,"Timeout, status 0x%08x\n",status);+dev_warn(smbus->dev,"Timeout, status 0x%08x\n",status);reg_write(smbus,REG_SMSTA,status);return-ETIME;}
@@ -342,7 +342,7 @@ static int pasemi_smb_probe(struct pci_dev *dev,if(!smbus)return-ENOMEM;-smbus->dev=dev;+smbus->dev=&dev->dev;smbus->base=pci_resource_start(dev,0);smbus->size=pci_resource_len(dev,0);
@@ -366,7 +366,7 @@ static int pasemi_smb_probe(struct pci_dev *dev,smbus->adapter.algo_data=smbus;/* set up the sysfs linkage to our parent device */-smbus->adapter.dev.parent=&dev->dev;+smbus->adapter.dev.parent=smbus->dev;reg_write(smbus,REG_CTL,(CTL_MTR|CTL_MRR|(CLK_100K_DIV&CTL_CLK_M)));
From: Sven Peter <hidden> Date: 2021-10-08 16:36:42
Split off common probing code that will be used by both the PCI and the
platform device.
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sven Peter <redacted>
---
v1 -> v2: no changes
drivers/i2c/busses/i2c-pasemi.c | 39 +++++++++++++++++++++------------
1 file changed, 25 insertions(+), 14 deletions(-)
@@ -329,6 +329,30 @@ static const struct i2c_algorithm smbus_algorithm = {.functionality=pasemi_smb_func,};+staticintpasemi_i2c_common_probe(structpasemi_smbus*smbus)+{+interror;++smbus->adapter.owner=THIS_MODULE;+snprintf(smbus->adapter.name,sizeof(smbus->adapter.name),+"PA Semi SMBus adapter (%s)",dev_name(smbus->dev));+smbus->adapter.class=I2C_CLASS_HWMON|I2C_CLASS_SPD;+smbus->adapter.algo=&smbus_algorithm;+smbus->adapter.algo_data=smbus;++/* set up the sysfs linkage to our parent device */+smbus->adapter.dev.parent=smbus->dev;++reg_write(smbus,REG_CTL,(CTL_MTR|CTL_MRR|+(CLK_100K_DIV&CTL_CLK_M)));++error=i2c_add_adapter(&smbus->adapter);+if(error)+returnerror;++return0;+}+staticintpasemi_smb_probe(structpci_dev*dev,conststructpci_device_id*id){
@@ -358,20 +382,7 @@ static int pasemi_smb_probe(struct pci_dev *dev,gotoout_release_region;}-smbus->adapter.owner=THIS_MODULE;-snprintf(smbus->adapter.name,sizeof(smbus->adapter.name),-"PA Semi SMBus adapter (%s)",dev_name(smbus->dev));-smbus->adapter.class=I2C_CLASS_HWMON|I2C_CLASS_SPD;-smbus->adapter.algo=&smbus_algorithm;-smbus->adapter.algo_data=smbus;--/* set up the sysfs linkage to our parent device */-smbus->adapter.dev.parent=smbus->dev;--reg_write(smbus,REG_CTL,(CTL_MTR|CTL_MRR|-(CLK_100K_DIV&CTL_CLK_M)));--error=i2c_add_adapter(&smbus->adapter);+interror=pasemi_i2c_common_probe(smbus);if(error)gotoout_ioport_unmap;
diff --git a/drivers/i2c/busses/i2c-pasemi.c b/drivers/i2c/busses/i2c-pasemi-core.csimilarity index 81%rename from drivers/i2c/busses/i2c-pasemi.crename to drivers/i2c/busses/i2c-pasemi-core.cindex baf338149673..d1cab11a4d50 100644--- a/drivers/i2c/busses/i2c-pasemi.c+++ b/drivers/i2c/busses/i2c-pasemi-core.c
From: Sven Peter <hidden> Date: 2021-10-08 16:36:56
Split out common reset call to its own function so that we
can later add support for selecting the clock frequency
and an additional enable bit found in newer revisions.
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sven Peter <redacted>
---
v1 -> v2: no changes
drivers/i2c/busses/i2c-pasemi-core.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
@@ -61,6 +61,12 @@ static inline int reg_read(struct pasemi_smbus *smbus, int reg)#define TXFIFO_WR(smbus, reg) reg_write((smbus), REG_MTXFIFO, (reg))#define RXFIFO_RD(smbus) reg_read((smbus), REG_MRXFIFO)+staticvoidpasemi_reset(structpasemi_smbus*smbus)+{+reg_write(smbus,REG_CTL,(CTL_MTR|CTL_MRR|+(CLK_100K_DIV&CTL_CLK_M)));+}+staticvoidpasemi_smb_clear(structpasemi_smbus*smbus){unsignedintstatus;
@@ -135,8 +141,7 @@ static int pasemi_i2c_xfer_msg(struct i2c_adapter *adapter,return0;reset_out:-reg_write(smbus,REG_CTL,(CTL_MTR|CTL_MRR|-(CLK_100K_DIV&CTL_CLK_M)));+pasemi_reset(smbus);returnerr;}
@@ -302,8 +307,7 @@ static int pasemi_smb_xfer(struct i2c_adapter *adapter,return0;reset_out:-reg_write(smbus,REG_CTL,(CTL_MTR|CTL_MRR|-(CLK_100K_DIV&CTL_CLK_M)));+pasemi_reset(smbus);returnerr;}
@@ -335,8 +339,7 @@ int pasemi_i2c_common_probe(struct pasemi_smbus *smbus)/* set up the sysfs linkage to our parent device */smbus->adapter.dev.parent=smbus->dev;-reg_write(smbus,REG_CTL,(CTL_MTR|CTL_MRR|-(CLK_100K_DIV&CTL_CLK_M)));+pasemi_reset(smbus);error=i2c_add_adapter(&smbus->adapter);if(error)
From: Sven Peter <hidden> Date: 2021-10-08 16:37:02
Right now the bus frequency has always been hardcoded as
100 KHz with the specific reference clock used in the PASemi
PCI controllers. Make this configurable to prepare for the
platform driver.
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sven Peter <redacted>
---
v1 -> v2: no changes
drivers/i2c/busses/i2c-pasemi-core.c | 8 +++-----
drivers/i2c/busses/i2c-pasemi-core.h | 1 +
drivers/i2c/busses/i2c-pasemi-pci.c | 4 ++++
3 files changed, 8 insertions(+), 5 deletions(-)
From: Sven Peter <hidden> Date: 2021-10-08 16:37:05
Using managed device resources means there's nothing left to be done in
pasemi_smb_pci_remove and also allows to remove base and size from
struct pasemi_smbus.
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sven Peter <redacted>
---
v1 -> v2: no changes
drivers/i2c/busses/i2c-pasemi-core.c | 8 ++---
drivers/i2c/busses/i2c-pasemi-core.h | 2 --
drivers/i2c/busses/i2c-pasemi-pci.c | 45 ++++++++--------------------
3 files changed, 15 insertions(+), 40 deletions(-)
From: Sven Peter <hidden> Date: 2021-10-08 16:37:11
With all the previous preparations we can now finally add
the platform driver to support the PASemi-based controllers
in Apple SoCs. This does not work on the M1 yet but should
work on the early iPhones already.
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sven Peter <redacted>
---
v1 -> v2:
- renamed i2c-pasemi-apple.c to i2c-pasemi-platform.c and adjusted
function names as well
- removed unused struct pinctrl *pctrl which snuck into v1
MAINTAINERS | 1 +
drivers/i2c/busses/Kconfig | 11 ++
drivers/i2c/busses/Makefile | 2 +
drivers/i2c/busses/i2c-pasemi-platform.c | 122 +++++++++++++++++++++++
4 files changed, 136 insertions(+)
create mode 100644 drivers/i2c/busses/i2c-pasemi-platform.c
@@ -0,0 +1,122 @@+// SPDX-License-Identifier: GPL-2.0-only+/*+*Copyright(C)2021TheAsahiLinuxContributors+*+*PASemiPWRficientSMBushostdriverforAppleSoCs+*/++#include<linux/clk.h>+#include<linux/i2c.h>+#include<linux/io.h>+#include<linux/kernel.h>+#include<linux/module.h>+#include<linux/platform_device.h>+#include<linux/types.h>++#include"i2c-pasemi-core.h"++structpasemi_platform_i2c_data{+structpasemi_smbussmbus;+structclk*clk_ref;+};++staticint+pasemi_platform_i2c_calc_clk_div(structpasemi_platform_i2c_data*data,+u32frequency)+{+unsignedlongclk_rate=clk_get_rate(data->clk_ref);++if(!clk_rate)+return-EINVAL;++data->smbus.clk_div=DIV_ROUND_UP(clk_rate,16*frequency);+if(data->smbus.clk_div<4)+returndev_err_probe(data->smbus.dev,-EINVAL,+"Bus frequency %d is too fast.\n",+frequency);+if(data->smbus.clk_div>0xff)+returndev_err_probe(data->smbus.dev,-EINVAL,+"Bus frequency %d is too slow.\n",+frequency);++return0;+}++staticintpasemi_platform_i2c_probe(structplatform_device*pdev)+{+structdevice*dev=&pdev->dev;+structpasemi_platform_i2c_data*data;+structpasemi_smbus*smbus;+u32frequency;+interror;++data=devm_kzalloc(dev,sizeof(structpasemi_platform_i2c_data),+GFP_KERNEL);+if(!data)+return-ENOMEM;++smbus=&data->smbus;+smbus->dev=dev;++smbus->ioaddr=devm_platform_ioremap_resource(pdev,0);+if(IS_ERR(smbus->ioaddr))+returnPTR_ERR(smbus->ioaddr);++if(of_property_read_u32(dev->of_node,"clock-frequency",&frequency))+frequency=I2C_MAX_STANDARD_MODE_FREQ;++data->clk_ref=devm_clk_get(dev,NULL);+if(IS_ERR(data->clk_ref))+returnPTR_ERR(data->clk_ref);++error=clk_prepare_enable(data->clk_ref);+if(error)+returnerror;++error=pasemi_platform_i2c_calc_clk_div(data,frequency);+if(error)+gotoout_clk_disable;++smbus->adapter.dev.of_node=pdev->dev.of_node;+error=pasemi_i2c_common_probe(smbus);+if(error)+gotoout_clk_disable;++platform_set_drvdata(pdev,data);++return0;++out_clk_disable:+clk_disable_unprepare(data->clk_ref);++returnerror;+}++staticintpasemi_platform_i2c_remove(structplatform_device*pdev)+{+structpasemi_platform_i2c_data*data=platform_get_drvdata(pdev);++clk_disable_unprepare(data->clk_ref);+return0;+}++staticconststructof_device_idpasemi_platform_i2c_of_match[]={+{.compatible="apple,t8103-i2c"},+{.compatible="apple,i2c"},+{},+};+MODULE_DEVICE_TABLE(of,pasemi_platform_i2c_of_match);++staticstructplatform_driverpasemi_platform_i2c_driver={+.driver={+.name="i2c-apple",+.of_match_table=pasemi_platform_i2c_of_match,+},+.probe=pasemi_platform_i2c_probe,+.remove=pasemi_platform_i2c_remove,+};+module_platform_driver(pasemi_platform_i2c_driver);++MODULE_LICENSE("GPL");+MODULE_AUTHOR("Sven Peter <sven@svenpeter.dev>");+MODULE_DESCRIPTION("Apple/PASemi SMBus platform driver");
From: Sven Peter <hidden> Date: 2021-10-08 16:37:19
Some later revisions after the original PASemi I2C controller introduce
what likely is an enable bit to the CTL register. Without setting it the
actual i2c transmission is never started.
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sven Peter <redacted>
---
v1 -> v2: no changes
drivers/i2c/busses/i2c-pasemi-core.c | 8 ++++++++
drivers/i2c/busses/i2c-pasemi-core.h | 3 +++
drivers/i2c/busses/i2c-pasemi-pci.c | 6 ++++++
3 files changed, 17 insertions(+)
@@ -335,6 +340,9 @@ int pasemi_i2c_common_probe(struct pasemi_smbus *smbus)/* set up the sysfs linkage to our parent device */smbus->adapter.dev.parent=smbus->dev;+if(smbus->hw_rev!=PASEMI_HW_REV_PCI)+smbus->hw_rev=reg_read(smbus,REG_REV);+pasemi_reset(smbus);error=devm_i2c_add_adapter(smbus->dev,&smbus->adapter);
From: Olof Johansson <hidden> Date: 2021-10-08 20:49:20
Hi,
On Fri, Oct 8, 2021 at 9:36 AM Sven Peter [off-list ref] 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.
We have no dedicated maintainer for PASEMI. Are maybe you or your
project interested in maintaining the pasemi-core, too? I guess not many
patches will show up and they will likely be for M1 anyhow.
If so, then no need to resend, I could add the extra line while
applying.
From: Wolfram Sang <wsa@kernel.org> Date: 2021-10-09 10:11:01
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.
We have no dedicated maintainer for PASEMI. Are maybe you or your
project interested in maintaining the pasemi-core, too? I guess not many
patches will show up and they will likely be for M1 anyhow.
If so, then no need to resend, I could add the extra line while
applying.
Sure, feel free to add the core to the entry as well.
Best,
Sven
From: Sven Peter <hidden> Date: 2021-10-09 11:30:35
On Sat, Oct 9, 2021, at 12:10, Wolfram Sang wrote:
quoted
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.
From: Christian Zigotzky <hidden> Date: 2021-10-09 13:58:49
On 09 October 2021 at 12:10 pm, Wolfram Sang wrote:
quoted
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.
From: Sven Peter <hidden> Date: 2021-10-10 13:17:40
On Sat, Oct 9, 2021, at 15:57, Christian Zigotzky wrote:
On 09 October 2021 at 12:10 pm, Wolfram Sang wrote:
quoted
quoted
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 <redacted> [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
From: Wolfram Sang <wsa@kernel.org> Date: 2021-10-11 08:54:53
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?
From: Hector Martin <hidden> Date: 2021-10-11 09:24:36
On 11/10/2021 17.54, Wolfram Sang wrote:
quoted
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?
--
Hector Martin (marcan@marcan.st)
Public Key: https://mrcn.st/pub
From: Wolfram Sang <wsa@kernel.org> Date: 2021-10-11 09:37:43
quoted
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?
From: Wolfram Sang <wsa@kernel.org> Date: 2021-10-11 10:05:03
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!
From: Christian Zigotzky <hidden> Date: 2021-10-13 08:08:16
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 [off-list ref] [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