i2c: designeware: Add Baikal-T1 SoC DW I2C specifics support
Subsystems (6)
cover i2c: designeware: Add Baikal-T1 SoC DW I2C specifics support
From: Serge Semin <[email protected]>
There are three DW I2C controllers embedded into the Baikal-T1 SoC. Two of them are normal with standard DW I2C IP-core configurations and registers accessible over normal MMIO space - so they are acceptable by the available DW I2C driver with no modification. But there is a third, which is a bit different. Its registers are indirectly accessed be means of "command/data in/data out" registers tuple. In order to have it also supported by the DW I2C driver, we must modify the code a bit. This is a main purpose of this patchset.
First of all traditionally we replaced the legacy plain text-based dt-binding file with yaml-based one. Then we found and fixed a bug in the DW I2C FIFO size detection algorithm which tried to do it too early before dw_readl/dw_writel methods could be used. Finally we introduced a platform-specific flag ACCESS_INDIRECT, which would enable the indirect access to the DW I2C registers implemented for one of the Baikal-T1 SoC DW I2C controllers. See the commit message of the corresponding patch for details.
This patchset is rebased and tested on the mainline Linux kernel 5.6-rc4:
commit 98d54f81e36b ("Linux 5.6-rc4").
Serge Semin (6):
scripts/dtc: check: Add additional i2c reg flags support
dt-bindings: i2c: Replace DW I2C legacy bindings with YAML-based one
dt-bindings: i2c: dw: Add Baikal-T1 SoC I2C controller
i2c: designware: Detect the FIFO size in the common code
i2c: designware: Discard i2c_dw_read_comp_param() function
i2c: designware: Add Baikal-T1 SoC I2C controller support
.../bindings/i2c/i2c-designware.txt | 73 -------- .../bindings/i2c/snps,designware-i2c.yaml | 158 ++++++++++++++++++ drivers/i2c/busses/i2c-designware-common.c | 107 ++++++++++-- drivers/i2c/busses/i2c-designware-core.h | 16 +- drivers/i2c/busses/i2c-designware-master.c | 3 + drivers/i2c/busses/i2c-designware-platdrv.c | 25 +-- drivers/i2c/busses/i2c-designware-slave.c | 3 + scripts/dtc/checks.c | 13 +- 8 files changed, 280 insertions(+), 118 deletions(-) delete mode 100644 Documentation/devicetree/bindings/i2c/i2c-designware.txt create mode 100644 Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml
Signature · 1 line
2.25.1
Andy Shevchenko
reviewerFirst of all, I got only 3 out of 6 patches. Are you sure you properly prepared the series?
Quoted 1 line · On Fri, Mar 06, 2020 at 04:19:49PM +0300, [email protected]…
From: Serge Semin <[email protected]>
Same comment as per DMA series, try next time to link the cover letter to the series correctly.
Quoted 11 lines
There are three DW I2C controllers embedded into the Baikal-T1 SoC. Two of them are normal with standard DW I2C IP-core configurations and registers accessible over normal MMIO space - so they are acceptable by the available DW I2C driver with no modification.
But there is a third, which is a bit
different. Its registers are indirectly accessed be means of "command/data in/data out" registers tuple. In order to have it also supported by the DW I2C driver, we must modify the code a bit. This is a main purpose of this patchset.
Quoted 4 lines
First of all traditionally we replaced the legacy plain text-based dt-binding file with yaml-based one. Then we found and fixed a bug in the DW I2C FIFO size detection algorithm which tried to do it too early before dw_readl/dw_writel methods could be used.
So far so good (looks like, I think colleagues of mine and myself will review individual patches later on).
Quoted 4 lines
Finally we introduced a platform-specific flag
ACCESS_INDIRECT, which would enable the indirect access to the DW I2C registers implemented for one of the Baikal-T1 SoC DW I2C controllers. See the commit message of the corresponding patch for details.
This is quite questionable. In Intel SoCs we have indirect I²C controllers to access (inside PMIC, for example). The approach used to do that is usually to have an IPC mechanism and specific bus controller driver. See i2c-cht-wc.c for instance.
I'm not sure if it makes a lot of duplication and if actually switching I²C DesignWare driver to regmap API will solve it. At least that is the second approach I would consider.
But I'll wait others to comment on this. We have to settle the solution before going further.
Quoted 2 lines
This patchset is rebased and tested on the mainline Linux kernel 5.6-rc4:
commit98d54f81e36b("Linux 5.6-rc4").
git format-patch --base ... should do the job.
Quoted 2 lines
Signed-off-by Serge Semin <[email protected]>Signed-off-by Alexey Malahov <[email protected]>
Same comment as per UART patch. Who is the Alexey in relation to the work done?
Signature · 2 lines
With Best Regards, Andy Shevchenko
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hello Andy,
Finally I've thought this through reasonably conformed with the changes requested in the framework of the other patchsets. My comments are below.
Quoted 38 lines · Andy Shevchenko
First of all, I got only 3 out of 6 patches. Are you sure you properly prepared the series?
Quoted 1 line · On Fri, Mar 06, 2020 at 04:19:49PM +0300, [email protected]…
From: Serge Semin <[email protected]>
Same comment as per DMA series, try next time to link the cover letter to the series correctly.
Quoted 11 lines
There are three DW I2C controllers embedded into the Baikal-T1 SoC. Two of them are normal with standard DW I2C IP-core configurations and registers accessible over normal MMIO space - so they are acceptable by the available DW I2C driver with no modification.
But there is a third, which is a bit
different. Its registers are indirectly accessed be means of "command/data in/data out" registers tuple. In order to have it also supported by the DW I2C driver, we must modify the code a bit. This is a main purpose of this patchset.Quoted 4 lines
First of all traditionally we replaced the legacy plain text-based dt-binding file with yaml-based one. Then we found and fixed a bug in the DW I2C FIFO size detection algorithm which tried to do it too early before dw_readl/dw_writel methods could be used.
So far so good (looks like, I think colleagues of mine and myself will review individual patches later on).
Quoted 4 lines
Finally we introduced a platform-specific flag
ACCESS_INDIRECT, which would enable the indirect access to the DW I2C registers implemented for one of the Baikal-T1 SoC DW I2C controllers. See the commit message of the corresponding patch for details.This is quite questionable. In Intel SoCs we have indirect I²C controllers to access (inside PMIC, for example). The approach used to do that is usually to have an IPC mechanism and specific bus controller driver. See
i2c-cht-wc.cfor instance.
Quoted 7 lines
I'm not sure if it makes a lot of duplication and if actually switching I²C DesignWare driver to regmap API will solve it. At least that is the second approach I would consider.
But I'll wait others to comment on this. We have to settle the solution before going further.
As I see the others have not comments.) Anyway I see your point and having the regmap-based interface might be better than the approach I've suggested in this patchset particularly seeing that our DW i2c IP registers are hidden behind a system controller register space.
In order to follow your proposition to create a dedicated regmap and to supply it to the DW i2c driver, I have to redevelop not only this patchset, but also an adjacent drivers. In particular the changes will concern the MFD-based System Controller driver (which will instantiate this DW i2c controller device), Clocks Control Unit drivers set, and a few others. The whole alteration I described in the RFC:
https://lkml.org/lkml/2020/3/22/393
You've been in Cc there, so fill free to send your comments regarding the changes I suggested. Though this time I hope the solution will satisfy everyone, who had issues with patchsets I've recently sent.
Getting back to your comment in the framework of this patchset. The approach used for CHT Whiskey Cove i2c isn't fully suitable in our case for the reason of the DW I2C controller nature. DW I2C controller is a generic controller and used on many different platforms, while AFAICS CHT Whiskey Cove I2C is the SoC-specific used to access a charger-IC. So in the former case we may have an arbitrary set of i2c-slaves connected to the controller on different platforms, while on the latter one - there is a fixed set of slaves. In addition due to the same reason the DW I2C IP might be embedded into different sub-blocks on different platforms, while the CHT Whiskey Cove I2C is known to be a part of Intel CHT WC SoC PMIC. For instance Baikal-T1 SoC has one DW I2C controller embedded into the System Controller with indirectly accessible registers and two DW I2C interfaces with normal memory mapped registers. Due to this in case of DW I2C driver we can't just "suck" the regmap out from a parental MFD or anywhere else as it's done in the CHT Whiskey Cove I2C driver, but instead we should somehow supply a regmap pointer to the driver.
Taking into account all of these we can utilize a combined approach implemented in ./drivers/i2c/busses/i2c-cht-wc.c and drivers/mfd/intel_quark_i2c_gpio.c . I'll add a regmap pointer field to the "struct dw_i2c_platform_data" structure, so in case if there is no IORESOURCE_MEM resources available (platform_get_resource() fails), we try to get a regmap pointer from the platform data. If there is no valid regmap available, then completely fail the driver probe procedure. Though due to this alteration I'll have to change the dw_i2c_platform_data.i2c_scl_freq field usage a bit. In case if it's zero, then call i2c_parse_fw_timings(). This won't hurt ACPI or dt-less platforms, but will let us cover a case when regmap is set while i2c clock frequency is supposed to be taken from the kernel firmware (like dtb, etc).
So if you are Ok with this, I'll send a v2 patchset with corresponding alteration implemented.
Regards,
-Sergey
Quoted 15 lines
Quoted 2 lines
This patchset is rebased and tested on the mainline Linux kernel 5.6-rc4:
commit98d54f81e36b("Linux 5.6-rc4").
git format-patch --base ...should do the job.Quoted 2 lines
Signed-off-by Serge Semin <[email protected]>Signed-off-by Alexey Malahov <[email protected]>Same comment as per UART patch. Who is the Alexey in relation to the work done?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Andy Shevchenko
reviewerQuoted 100 lines · Sergey Semin
Hello Andy,
Finally I've thought this through reasonably conformed with the changes requested in the framework of the other patchsets. My comments are below.
Quoted 38 lines · Andy Shevchenko
First of all, I got only 3 out of 6 patches. Are you sure you properly prepared the series?
Quoted 1 line · On Fri, Mar 06, 2020 at 04:19:49PM +0300, [email protected]…
From: Serge Semin <[email protected]>
Same comment as per DMA series, try next time to link the cover letter to the series correctly.
Quoted 11 lines
There are three DW I2C controllers embedded into the Baikal-T1 SoC. Two of them are normal with standard DW I2C IP-core configurations and registers accessible over normal MMIO space - so they are acceptable by the available DW I2C driver with no modification.
But there is a third, which is a bit
different. Its registers are indirectly accessed be means of "command/data in/data out" registers tuple. In order to have it also supported by the DW I2C driver, we must modify the code a bit. This is a main purpose of this patchset.Quoted 4 lines
First of all traditionally we replaced the legacy plain text-based dt-binding file with yaml-based one. Then we found and fixed a bug in the DW I2C FIFO size detection algorithm which tried to do it too early before dw_readl/dw_writel methods could be used.
So far so good (looks like, I think colleagues of mine and myself will review individual patches later on).
Quoted 4 lines
Finally we introduced a platform-specific flag
ACCESS_INDIRECT, which would enable the indirect access to the DW I2C registers implemented for one of the Baikal-T1 SoC DW I2C controllers. See the commit message of the corresponding patch for details.This is quite questionable. In Intel SoCs we have indirect I²C controllers to access (inside PMIC, for example). The approach used to do that is usually to have an IPC mechanism and specific bus controller driver. See
i2c-cht-wc.cfor instance.Quoted 7 lines
I'm not sure if it makes a lot of duplication and if actually switching I²C DesignWare driver to regmap API will solve it. At least that is the second approach I would consider.
But I'll wait others to comment on this. We have to settle the solution before going further.
As I see the others have not comments.) Anyway I see your point and having the regmap-based interface might be better than the approach I've suggested in this patchset particularly seeing that our DW i2c IP registers are hidden behind a system controller register space.
In order to follow your proposition to create a dedicated regmap and to supply it to the DW i2c driver, I have to redevelop not only this patchset, but also an adjacent drivers. In particular the changes will concern the MFD-based System Controller driver (which will instantiate this DW i2c controller device), Clocks Control Unit drivers set, and a few others. The whole alteration I described in the RFC:
https://lkml.org/lkml/2020/3/22/393
You've been in Cc there, so fill free to send your comments regarding the changes I suggested. Though this time I hope the solution will satisfy everyone, who had issues with patchsets I've recently sent.Getting back to your comment in the framework of this patchset. The approach used for CHT Whiskey Cove i2c isn't fully suitable in our case for the reason of the DW I2C controller nature. DW I2C controller is a generic controller and used on many different platforms, while AFAICS CHT Whiskey Cove I2C is the SoC-specific used to access a charger-IC. So in the former case we may have an arbitrary set of i2c-slaves connected to the controller on different platforms, while on the latter one - there is a fixed set of slaves. In addition due to the same reason the DW I2C IP might be embedded into different sub-blocks on different platforms, while the CHT Whiskey Cove I2C is known to be a part of Intel CHT WC SoC PMIC. For instance Baikal-T1 SoC has one DW I2C controller embedded into the System Controller with indirectly accessible registers and two DW I2C interfaces with normal memory mapped registers. Due to this in case of DW I2C driver we can't just "suck" the regmap out from a parental MFD or anywhere else as it's done in the CHT Whiskey Cove I2C driver, but instead we should somehow supply a regmap pointer to the driver.
Taking into account all of these we can utilize a combined approach implemented in
./drivers/i2c/busses/i2c-cht-wc.canddrivers/mfd/intel_quark_i2c_gpio.c. I'll add a regmap pointer field to the "structdw_i2c_platform_data" structure, so in case if there is noIORESOURCE_MEMresources available (platform_get_resource()fails), we try to get a regmap pointer from the platform data. If there is no valid regmap available, then completely fail the driver probe procedure. Though due to this alteration I'll have to change the dw_i2c_platform_data.i2c_scl_freq field usage a bit. In case if it's zero, then calli2c_parse_fw_timings(). This won't hurt ACPI or dt-less platforms, but will let us cover a case when regmap is set while i2c clock frequency is supposed to be taken from the kernel firmware (like dtb, etc).
Quoted 2 lines
So if you are Ok with this, I'll send a v2 patchset with corresponding alteration implemented.
I was thinking about something like this:
1/ core driver (library + master + slave) is converted to use regmap 2/ platform and PCI driver may provide regmap MMIO
3/ your glue driver will provide different regmap accessors
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 101 lines · Andy Shevchenko
Quoted 100 lines · Sergey Semin
Hello Andy,
Finally I've thought this through reasonably conformed with the changes requested in the framework of the other patchsets. My comments are below.
Quoted 38 lines · Andy Shevchenko
First of all, I got only 3 out of 6 patches. Are you sure you properly prepared the series?
Quoted 1 line · On Fri, Mar 06, 2020 at 04:19:49PM +0300…
From: Serge Semin <[email protected]>
Same comment as per DMA series, try next time to link the cover letter to the series correctly.
Quoted 11 lines
There are three DW I2C controllers embedded into the Baikal-T1 SoC. Two of them are normal with standard DW I2C IP-core configurations and registers accessible over normal MMIO space - so they are acceptable by the available DW I2C driver with no modification.
But there is a third, which is a bit
different. Its registers are indirectly accessed be means of "command/data in/data out" registers tuple. In order to have it also supported by the DW I2C driver, we must modify the code a bit. This is a main purpose of this patchset.Quoted 4 lines
First of all traditionally we replaced the legacy plain text-based dt-binding file with yaml-based one. Then we found and fixed a bug in the DW I2C FIFO size detection algorithm which tried to do it too early before dw_readl/dw_writel methods could be used.
So far so good (looks like, I think colleagues of mine and myself will review individual patches later on).
Quoted 4 lines
Finally we introduced a platform-specific flag
ACCESS_INDIRECT, which would enable the indirect access to the DW I2C registers implemented for one of the Baikal-T1 SoC DW I2C controllers. See the commit message of the corresponding patch for details.This is quite questionable. In Intel SoCs we have indirect I²C controllers to access (inside PMIC, for example). The approach used to do that is usually to have an IPC mechanism and specific bus controller driver. See
i2c-cht-wc.cfor instance.Quoted 7 lines
I'm not sure if it makes a lot of duplication and if actually switching I²C DesignWare driver to regmap API will solve it. At least that is the second approach I would consider.
But I'll wait others to comment on this. We have to settle the solution before going further.
As I see the others have not comments.) Anyway I see your point and having the regmap-based interface might be better than the approach I've suggested in this patchset particularly seeing that our DW i2c IP registers are hidden behind a system controller register space.
In order to follow your proposition to create a dedicated regmap and to supply it to the DW i2c driver, I have to redevelop not only this patchset, but also an adjacent drivers. In particular the changes will concern the MFD-based System Controller driver (which will instantiate this DW i2c controller device), Clocks Control Unit drivers set, and a few others. The whole alteration I described in the RFC:
https://lkml.org/lkml/2020/3/22/393
You've been in Cc there, so fill free to send your comments regarding the changes I suggested. Though this time I hope the solution will satisfy everyone, who had issues with patchsets I've recently sent.Getting back to your comment in the framework of this patchset. The approach used for CHT Whiskey Cove i2c isn't fully suitable in our case for the reason of the DW I2C controller nature. DW I2C controller is a generic controller and used on many different platforms, while AFAICS CHT Whiskey Cove I2C is the SoC-specific used to access a charger-IC. So in the former case we may have an arbitrary set of i2c-slaves connected to the controller on different platforms, while on the latter one - there is a fixed set of slaves. In addition due to the same reason the DW I2C IP might be embedded into different sub-blocks on different platforms, while the CHT Whiskey Cove I2C is known to be a part of Intel CHT WC SoC PMIC. For instance Baikal-T1 SoC has one DW I2C controller embedded into the System Controller with indirectly accessible registers and two DW I2C interfaces with normal memory mapped registers. Due to this in case of DW I2C driver we can't just "suck" the regmap out from a parental MFD or anywhere else as it's done in the CHT Whiskey Cove I2C driver, but instead we should somehow supply a regmap pointer to the driver.
Taking into account all of these we can utilize a combined approach implemented in
./drivers/i2c/busses/i2c-cht-wc.canddrivers/mfd/intel_quark_i2c_gpio.c. I'll add a regmap pointer field to the "structdw_i2c_platform_data" structure, so in case if there is noIORESOURCE_MEMresources available (platform_get_resource()fails), we try to get a regmap pointer from the platform data. If there is no valid regmap available, then completely fail the driver probe procedure. Though due to this alteration I'll have to change the dw_i2c_platform_data.i2c_scl_freq field usage a bit. In case if it's zero, then calli2c_parse_fw_timings(). This won't hurt ACPI or dt-less platforms, but will let us cover a case when regmap is set while i2c clock frequency is supposed to be taken from the kernel firmware (like dtb, etc).
Quoted 7 lines
Quoted 2 lines
So if you are Ok with this, I'll send a v2 patchset with corresponding alteration implemented.
I was thinking about something like this:
1/ core driver (library + master + slave) is converted to use regmap
Yes. I also intended to do this just by altering the dw_readl() and dw_writel() methods to work over regmap IO methods if regmap is available.
Quoted 1 line
2/ platform and PCI driver may provide regmap MMIO
Regmap pointer will be also a part of "struct dw_i2c_dev". So if PCI code intends the regmap-based access to the controller registers, then it shall just initialize the regmap pointer in the private i2c-designware data instance of the dw_i2c_dev structure. So, yes, this is also covered by my solution. Though the PCI code will be left untouched, since I can't predict a particular regmap-related use-case of it.
Quoted 1 line
3/ your glue driver will provide different regmap accessors
I was thinking of developing a more generic version so any platform with a specific access to the DW I2C register could use it just by supplying the regmap pointer in the dw_i2c_platform_data structure. Our DW I2C controller also perfectly fits to the generic i2c-designware-platdrv.c driver, so implementing an additional glue-layer would be too much seeing the difference only in the registers mapping.
Let me explain the difference of our solutions. In case of implementing the glue layer, as you suggest, I would have to do it in a way like the DW PCIe driver is designed. I would need to move the code of current dw_i2c_plat_probe() function to a dedicated method named like dw_i2c_plat_init(pdev, !regmap!), while former method dw_i2c_plat_probe() would just call dw_i2c_plat_init(pdev, !NULL!). Then I would have to create a dedicated glue-driver - i2c-designware-bt1drv.c, which would be bound to a "baikal,t1-sys-i2c" device, try to find a Baikal-T1 System Controller device node (though this would be just a parent device), then would get it' syscon regmap handler, then would initialize a dedicated regmap handler to indirectly access the DW I2C controller register, then it would call the dw_i2c_plat_init(pdev, !regmap!) method with new regmap handler passed (though the new regmap passing could be also implemented over the platform_data pointer). Also seeing you already have a platform-specific parts in the generic i2c-designware-platdrv.c driver (like ACPI-based platforms and Microsemi Ocelot SoC), there might raise a necessity to unpin that specifics to a dedicated method, since my glue-layer wouldn't need that checks and initializations. Such alteration won't be that easy to implement and regression errors prone, since I don't have other platforms to test it.
In case of my solution the whole glue-layer part would be moved to the MFD-based Baikal-T1 System Controller driver and a generic platform_data-based interface would be implemented, which would just need to alter the registers mapping part of the i2c-designware-platdrv.c driver. Note that that part would need to be fixed in case of any solution.
So comparing these too approaches, I would select a one, which would need less common code modifications and would provide a generic solution. As I see it would be a platform_data-based design. What do you think?
Regards,
-Sergey
Quoted 6 lines
Signature · 3 lines
-- With Best Regards, Andy Shevchenko
Quoted 3 lines · Sergey Semin
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Sergey Semin
On Fri, Mar 06, 2020 at 03:54:45PM +0200, Andy Shevchenko wrote:
...
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
As I see the others have not comments.) Anyway I see your point and having the regmap-based interface might be better than the approach I've suggested in this patchset particularly seeing that our DW i2c IP registers are hidden behind a system controller register space.
In order to follow your proposition to create a dedicated regmap and to supply it to the DW i2c driver, I have to redevelop not only this patchset, but also an adjacent drivers. In particular the changes will concern the MFD-based System Controller driver (which will instantiate this DW i2c controller device), Clocks Control Unit drivers set, and a few others. The whole alteration I described in the RFC:
https://lkml.org/lkml/2020/3/22/393
You've been in Cc there, so fill free to send your comments regarding the changes I suggested. Though this time I hope the solution will satisfy everyone, who had issues with patchsets I've recently sent.Getting back to your comment in the framework of this patchset. The approach used for CHT Whiskey Cove i2c isn't fully suitable in our case for the reason of the DW I2C controller nature. DW I2C controller is a generic controller and used on many different platforms, while AFAICS CHT Whiskey Cove I2C is the SoC-specific used to access a charger-IC. So in the former case we may have an arbitrary set of i2c-slaves connected to the controller on different platforms, while on the latter one - there is a fixed set of slaves. In addition due to the same reason the DW I2C IP might be embedded into different sub-blocks on different platforms, while the CHT Whiskey Cove I2C is known to be a part of Intel CHT WC SoC PMIC. For instance Baikal-T1 SoC has one DW I2C controller embedded into the System Controller with indirectly accessible registers and two DW I2C interfaces with normal memory mapped registers. Due to this in case of DW I2C driver we can't just "suck" the regmap out from a parental MFD or anywhere else as it's done in the CHT Whiskey Cove I2C driver, but instead we should somehow supply a regmap pointer to the driver.
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
Taking into account all of these we can utilize a combined approach implemented in
./drivers/i2c/busses/i2c-cht-wc.canddrivers/mfd/intel_quark_i2c_gpio.c. I'll add a regmap pointer field to the "structdw_i2c_platform_data" structure, so in case if there is noIORESOURCE_MEMresources available (platform_get_resource()fails), weQuoted 8 lines
Quoted 8 lines
try to get a regmap pointer from the platform data. If there is no valid regmap available, then completely fail the driver probe procedure. Though due to this alteration I'll have to change the dw_i2c_platform_data.i2c_scl_freq field usage a bit. In case if it's zero, then call
i2c_parse_fw_timings(). This won't hurt ACPI or dt-less platforms, but will let us cover a case when regmap is set while i2c clock frequency is supposed to be taken from the kernel firmware (like dtb, etc).
Whiskey Cove case provides an I²C controller with specific access. That's it. In your case you will need similar glue driver which will utilize DesignWare core driver.
Quoted 11 lines
Quoted 7 lines
Quoted 2 lines
So if you are Ok with this, I'll send a v2 patchset with corresponding alteration implemented.
I was thinking about something like this:
1/ core driver (library + master + slave) is converted to use regmap
Yes. I also intended to do this just by altering the
dw_readl()anddw_writel()methods to work over regmap IO methods if regmap is available.
Why? Simple always use regmap API calls. Moreover, regmap provides update() which may give a leverage in some cases by dropping r-m-w code.
Core part take a pointer to regmap when instantiate (probe) a driver on the device.
Quoted 3 lines
Quoted 1 line
2/ platform and PCI driver may provide regmap MMIO
Regmap pointer will be also a part of "struct
dw_i2c_dev".
Yes.
Quoted 4 lines
So if PCI
code intends the regmap-based access to the controller registers, then it shall just initialize the regmap pointer in the private i2c-designware data instance of thedw_i2c_devstructure.
Why data is being involved here?
Quoted 9 lines
So, yes, this is also covered by
my solution. Though the PCI code will be left untouched, since I can't predict a particular regmap-related use-case of it.Quoted 1 line
3/ your glue driver will provide different regmap accessors
I was thinking of developing a more generic version so any platform with a specific access to the DW I2C register could use it just by supplying the regmap pointer in the
dw_i2c_platform_datastructure.
regmap is not a platform data.
Quoted 4 lines
Our DW I2C
controller also perfectly fits to the generici2c-designware-platdrv.cdriver, so implementing an additional glue-layer would be too much seeing the difference only in the registers mapping.
Register accessing, mapping as far as I understood is the same. However, with regmap layer it just an implementation detail of certain glue driver.
Quoted 27 lines
Let me explain the difference of our solutions. In case of implementing the glue layer, as you suggest, I would have to do it in a way like the DW PCIe driver is designed. I would need to move the code of current
dw_i2c_plat_probe()function to a dedicated method named likedw_i2c_plat_init(pdev, !regmap!), while former methoddw_i2c_plat_probe()would just calldw_i2c_plat_init(pdev, !NULL!). Then I would have to create a dedicated glue-driver -i2c-designware-bt1drv.c, which would be bound to a "baikal,t1-sys-i2c" device, try to find a Baikal-T1 System Controller device node (though this would be just a parent device), then would get it' syscon regmap handler, then would initialize a dedicated regmap handler to indirectly access the DW I2C controller register, then it would call thedw_i2c_plat_init(pdev, !regmap!)method with new regmap handler passed (though the new regmap passing could be also implemented over theplatform_datapointer). Also seeing you already have a platform-specific parts in the generici2c-designware-platdrv.cdriver (like ACPI-based platforms and Microsemi Ocelot SoC), there might raise a necessity to unpin that specifics to a dedicated method, since my glue-layer wouldn't need that checks and initializations. Such alteration won't be that easy to implement and regression errors prone, since I don't have other platforms to test it.In case of my solution the whole glue-layer part would be moved to the MFD-based Baikal-T1 System Controller driver and a generic platform_data-based interface would be implemented, which would just need to alter the registers mapping part of the
i2c-designware-platdrv.cdriver. Note that that part would need to be fixed in case of any solution.
Quoted 4 lines
So comparing these too approaches, I would select a one, which would need less common code modifications and would provide a generic solution. As I see it would be a platform_data-based design. What do you think?
I think you may look at the existing examples how drivers are utilizing regmap layer.
Along with that look how glue (or let's say quirk in your case) drivers are implemented, for example USB or SDHCI comes to my mind.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 67 lines · Andy Shevchenko
Quoted 3 lines · Sergey Semin
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Sergey Semin
On Fri, Mar 06, 2020 at 03:54:45PM +0200, Andy Shevchenko wrote:
...
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
As I see the others have not comments.) Anyway I see your point and having the regmap-based interface might be better than the approach I've suggested in this patchset particularly seeing that our DW i2c IP registers are hidden behind a system controller register space.
In order to follow your proposition to create a dedicated regmap and to supply it to the DW i2c driver, I have to redevelop not only this patchset, but also an adjacent drivers. In particular the changes will concern the MFD-based System Controller driver (which will instantiate this DW i2c controller device), Clocks Control Unit drivers set, and a few others. The whole alteration I described in the RFC:
https://lkml.org/lkml/2020/3/22/393
You've been in Cc there, so fill free to send your comments regarding the changes I suggested. Though this time I hope the solution will satisfy everyone, who had issues with patchsets I've recently sent.Getting back to your comment in the framework of this patchset. The approach used for CHT Whiskey Cove i2c isn't fully suitable in our case for the reason of the DW I2C controller nature. DW I2C controller is a generic controller and used on many different platforms, while AFAICS CHT Whiskey Cove I2C is the SoC-specific used to access a charger-IC. So in the former case we may have an arbitrary set of i2c-slaves connected to the controller on different platforms, while on the latter one - there is a fixed set of slaves. In addition due to the same reason the DW I2C IP might be embedded into different sub-blocks on different platforms, while the CHT Whiskey Cove I2C is known to be a part of Intel CHT WC SoC PMIC. For instance Baikal-T1 SoC has one DW I2C controller embedded into the System Controller with indirectly accessible registers and two DW I2C interfaces with normal memory mapped registers. Due to this in case of DW I2C driver we can't just "suck" the regmap out from a parental MFD or anywhere else as it's done in the CHT Whiskey Cove I2C driver, but instead we should somehow supply a regmap pointer to the driver.
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
Taking into account all of these we can utilize a combined approach implemented in
./drivers/i2c/busses/i2c-cht-wc.canddrivers/mfd/intel_quark_i2c_gpio.c. I'll add a regmap pointer field to the "structdw_i2c_platform_data" structure, so in case if there is noIORESOURCE_MEMresources available (platform_get_resource()fails), weQuoted 8 lines
Quoted 8 lines
try to get a regmap pointer from the platform data. If there is no valid regmap available, then completely fail the driver probe procedure. Though due to this alteration I'll have to change the dw_i2c_platform_data.i2c_scl_freq field usage a bit. In case if it's zero, then call
i2c_parse_fw_timings(). This won't hurt ACPI or dt-less platforms, but will let us cover a case when regmap is set while i2c clock frequency is supposed to be taken from the kernel firmware (like dtb, etc).Whiskey Cove case provides an I²C controller with specific access. That's it. In your case you will need similar glue driver which will utilize DesignWare core driver.
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
So if you are Ok with this, I'll send a v2 patchset with corresponding alteration implemented.
I was thinking about something like this:
1/ core driver (library + master + slave) is converted to use regmap
Quoted 8 lines
Quoted 3 lines
Yes. I also intended to do this just by altering the
dw_readl()anddw_writel()methods to work over regmap IO methods if regmap is available.Why? Simple always use regmap API calls. Moreover, regmap provides
update()which may give a leverage in some cases by dropping r-m-w code.
See the last comment.
Quoted 7 lines
Core part take a pointer to regmap when instantiate (probe) a driver on the device.
Quoted 3 lines
Quoted 1 line
2/ platform and PCI driver may provide regmap MMIO
Regmap pointer will be also a part of "struct
dw_i2c_dev".
Quoted 9 lines
Yes.
Quoted 4 lines
So if PCI
code intends the regmap-based access to the controller registers, then it shall just initialize the regmap pointer in the private i2c-designware data instance of thedw_i2c_devstructure.Why data is being involved here?
This data is the driver private data. Have a better look at what I suggested. In my solution regmap is just an optional way of accessing the registers. The main part is left unchanged: IO-accessors usage to read/write MMIO registers range in currently implemented dw_readl()/dw_writel().
Quoted 11 lines
Quoted 9 lines
So, yes, this is also covered by
my solution. Though the PCI code will be left untouched, since I can't predict a particular regmap-related use-case of it.Quoted 1 line
3/ your glue driver will provide different regmap accessors
I was thinking of developing a more generic version so any platform with a specific access to the DW I2C register could use it just by supplying the regmap pointer in the
dw_i2c_platform_datastructure.regmap is not a platform data.
Nothing prevents us from adding a regmap pointer to the platform_data and according to the already defined platform_data's for other devices it could. Anyway see my last comment.
Quoted 10 lines
Quoted 5 lines
Our DW I2C
controller also perfectly fits to the generici2c-designware-platdrv.cdriver, so implementing an additional glue-layer would be too much seeing the difference only in the registers mapping.Register accessing, mapping as far as I understood is the same. However, with regmap layer it just an implementation detail of certain glue driver.
Yes, registers region structure is the same while the implementation is different. Though taking that implementation specifics into account is different in my and yours solutions. Anyway see my last comment.
Quoted 32 lines
Quoted 27 lines
Let me explain the difference of our solutions. In case of implementing the glue layer, as you suggest, I would have to do it in a way like the DW PCIe driver is designed. I would need to move the code of current
dw_i2c_plat_probe()function to a dedicated method named likedw_i2c_plat_init(pdev, !regmap!), while former methoddw_i2c_plat_probe()would just calldw_i2c_plat_init(pdev, !NULL!). Then I would have to create a dedicated glue-driver -i2c-designware-bt1drv.c, which would be bound to a "baikal,t1-sys-i2c" device, try to find a Baikal-T1 System Controller device node (though this would be just a parent device), then would get it' syscon regmap handler, then would initialize a dedicated regmap handler to indirectly access the DW I2C controller register, then it would call thedw_i2c_plat_init(pdev, !regmap!)method with new regmap handler passed (though the new regmap passing could be also implemented over theplatform_datapointer). Also seeing you already have a platform-specific parts in the generici2c-designware-platdrv.cdriver (like ACPI-based platforms and Microsemi Ocelot SoC), there might raise a necessity to unpin that specifics to a dedicated method, since my glue-layer wouldn't need that checks and initializations. Such alteration won't be that easy to implement and regression errors prone, since I don't have other platforms to test it.In case of my solution the whole glue-layer part would be moved to the MFD-based Baikal-T1 System Controller driver and a generic platform_data-based interface would be implemented, which would just need to alter the registers mapping part of the
i2c-designware-platdrv.cdriver. Note that that part would need to be fixed in case of any solution.Quoted 4 lines
So comparing these too approaches, I would select a one, which would need less common code modifications and would provide a generic solution. As I see it would be a platform_data-based design. What do you think?
Quoted 5 lines
I think you may look at the existing examples how drivers are utilizing regmap layer.
Along with that look how glue (or let's say quirk in your case) drivers are implemented, for example USB or SDHCI comes to my mind.
I know how drivers use regmaps. I also know the glue layers design. If you took a closer look at my suggestion you would find out that first I referred to a code which utilize the glue layers, second I was describing a solution which would have caused less changes, requires less work, wouldn't have needed so many alterations of the common code, which potentially would have caused less problems.
Regarding your design of the solution. Basically you want me to convert the DW I2C driver to using the regmap API. It shall involve the IO-accessors usage conversion so instead of calling the dw_readl() and dw_writel(), regmap_{read,write}() are supposed to be utilized. You also want me to alter the DW I2C generic platform and PCI code so it would convert the MMIO regions to simple regmap_init_mmio'es. Finally you want me to implement our DW I2C specifics in a dedicated "glue"-layer, and if not doing as I suggested of separating the dw_i2c_plat_probe() functionality (which is glue layer design), but to develop it as a quirk exporting a custom regmap pointer.
As I already said your solution needs much work, so will take greater time to implement and debug. It's much more complicated than mine, and potentially may cause more errors. While conceptually your suggestion seems a bit more suitable, my solution is also acceptable and perfectly fine to be part of the kernel. So I'll see what I can do in implementing your suggestion. If I have enough time to work on that, I'll do it. Otherwise I'll be working on my solution. Either of them will be sent in v2.
Regards,
-Sergey
Quoted 3 lines
Signature · 2 lines
With Best Regards, Andy Shevchenko
v2 cover i2c: designeware: Add Baikal-T1 System I2C support
In reply to [email protected]Initially this has been a small patchset which embedded the Baikal-T1 System I2C support into the DW APB I2C driver as is by using a simplest way. After a short discussion with Andy we decided to implement what he suggested (introduce regmap-based accessors and create a glue driver) and even more than that to provide some cleanups of the code. So here is what this patchset consists of.
First of all we've found out that current implementation of scripts/dtc didn't support i2c dt nodes with 10bit and slave flags set in the reg property. You'll see an error if you try to dt_binding_check it. So the very first patch fixes the problem by adding these flags support into the check_i2c_bus_reg() method.
Traditionally we converted the plain text-based DT binding to the DT schema and added Baikal-T1 System I2C device support there. This required to mark the reg property redundant for Baikal-T1 I2C since its reg-space is indirectly accessed by means of the System Controller cmd/read/write registers.
Then as Andy suggested we replaced the Synopsys DW APB I2C common driver registers IO accessors into the regmap API methods. This doesn't change the code logic much, though in two places we managed to replace some bulky peaces of code with a ready-to-use regmap methods.
Additionally before adding the glue layer API we initiated a set of cleanups:
- Define components of the multi-object drivers (like i2c-designware-core.o and i2c-designware-paltform.o) with using -y suffixed makefile variables instead of -objs suffixed one. This is encouraged by Documentation/kbuild/makefiles.rst text since -objs is supposed to be used to build host programs.
- Make DW I2C slave driver depended on the DW I2C core code instead of the platform one, which it really is.
- Move Intel Baytrail semaphore feature to the platform if-clause of the kernel config.
After this we finally can introduce the glue layer API for the DW APB I2C platform driver. So there are three methods exported from the driver:i2c_dw_plat_setup(), i2c_dw_plat_clear(), &i2c_dw_plat_dev_pm_ops to setup, cleanup and add PM operations to the glue driven I2C device. Before setting the platform DW I2C device up the glue probe code is supposed to create an instance of DW I2C device generic object and pre-initialize its struct device pointer together with optional platform-specific flags. In addition to that we converted the MSCC Ocelot SoC I2C specific code into the glue layer seeing it's really too specific and, which is more important, isn't that complicated so we could unpin it without much of worrying to break something.
Meanwhile we discovered that MODEL_CHERRYTRAIL and MODEL_MASK actually were no longer used in the code. MODEL_MSCC flag has been discarded since the MSCC Ocelot I2C code conversion to the glue driver. So now we can get rid of all the MODEL-specific flags.
Finally we introduced a glue driver with Baikal-T1 System I2C device support. The driver probe tries to find a syscon regmap, creates the DW APB I2C regmap based on it and passes it further to the DW I2C device descriptor. Then it does normal DW APB I2C platform setup by calling a generic setup method. Cleanup is straightforward. It's just calling a generic DW APB I2C clean method.
This patchset is rebased and tested on the mainline Linux kernel 5.6-rc4:
base-commit: 0e698dfa2822 ("Linux 5.7-rc4")
tag: v5.7-rc4
Note new vendor prefix for Baikal-T1 System I2C device will be added in the framework of the next patchset:
https://lkml.org/lkml/2020/5/6/1047
---
Changelog v2:
- Fix the SoB tags.
- Use a shorter summary describing the bindings convertion patch.
- Patch "i2c: designware: Detect the FIFO size in the common code" has been acked by Jarkko and applied by Wolfram to for-next so drop it from the set.
- Patch "i2c: designware: Discard i2c_dw_read_comp_param() function" has been acked by Jarkko and applied by Wolfram to for-next so drop it from the set.
- Make sure that "mscc,ocelot-i2c" compatible node may have up to two registers space defined in the DT node, while normal DW I2C controller will have only one registers space.
- Add "mscc,ocelot-i2c" DT schema example to test the previous fix.
- Declare "unevaluatedProperties" property instead of "additionalProperties" one in the DT schema.
- Due to the previous fix we can now discard the dummy boolean properties declaration, since the proper type evaluation will be performed by the generic i2c-controller.yaml schema.
- Refactor the DW I2C APB driver related series to address the Andies notes.
- Convert DW APB I2C driver to using regmap instead of handwritten accessors.
- Use -y to build multi-object DW APB drivers.
- Fix DW APB I2C slave code dependency. It should depend on I2C_DESIGNWARE_CORE instead I2C_DESIGNWARE_PLATFORM.
- Move Baytrail semaphore config to the platform if-clause.
- Introduce a glue-layer platform driver API.
- Unpin Microsemi Ocelot I2C code into a glue driver.
- Remove MODEL_CHERRYTRAIL and MODEL_MASK as no longer needed.
- Add support for custom regmap passed from glue driver.
- Add Baikal-T1 System I2C support in a dedicated glue layer driver.
Serge Semin (12):
scripts/dtc: check: Add 10bit/slave i2c reg flags support
dt-bindings: i2c: Convert DW I2C binding to DT schema
dt-bindings: i2c: dw: Add Baikal-T1 SoC I2C controller
i2c: designware: Convert driver to using regmap API
i2c: designware: Use -y to build multi-object modules
i2c: designware: slave: Set DW I2C core module dependency
i2c: designware: Move Baytrail sem config to the platform if-clause
i2c: designware: Introduce platform drivers glue layer interface
i2c: designware: Unpin Microsemi Ocelot I2C into a glue driver
i2c: designware: Discard Cherry Trail model flag
i2c: designware: Use provided regmap instead of reg resource
i2c: designware: Add Baikal-T1 System I2C glue driver
.../bindings/i2c/i2c-designware.txt | 73 ------- .../bindings/i2c/snps,designware-i2c.yaml | 164 ++++++++++++++++ drivers/i2c/busses/Kconfig | 56 ++++-- drivers/i2c/busses/Makefile | 19 +- drivers/i2c/busses/i2c-designware-bt1.c | 129 +++++++++++++ drivers/i2c/busses/i2c-designware-common.c | 178 +++++++++++++----- drivers/i2c/busses/i2c-designware-core.h | 26 ++- drivers/i2c/busses/i2c-designware-master.c | 125 ++++++------ drivers/i2c/busses/i2c-designware-mscc.c | 83 ++++++++ drivers/i2c/busses/i2c-designware-pcidrv.c | 1 - drivers/i2c/busses/i2c-designware-platdrv.c | 132 ++++++------- drivers/i2c/busses/i2c-designware-platdrv.h | 16 ++ drivers/i2c/busses/i2c-designware-slave.c | 77 ++++---- scripts/dtc/checks.c | 13 +- 14 files changed, 759 insertions(+), 333 deletions(-) delete mode 100644 Documentation/devicetree/bindings/i2c/i2c-designware.txt create mode 100644 Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml create mode 100644 drivers/i2c/busses/i2c-designware-bt1.c create mode 100644 drivers/i2c/busses/i2c-designware-mscc.c create mode 100644 drivers/i2c/busses/i2c-designware-platdrv.h
Signature · 1 line
2.25.1
PATCH v2 1/12 scripts/dtc: check: Add 10bit/slave i2c reg flags support
Recently the I2C-controllers slave interface support was added to the kernel I2C subsystem. In this case Linux can be used as, for example, a I2C EEPROM machine. See [1] for details. Other than instantiating the EEPROM-slave device from user-space there is a way to declare the device in dts. In this case firstly the I2C bus controller must support the slave interface. Secondly I2C-slave sub-node of that controller must have "reg"-property with flag I2C_OWN_SLAVE_ADDRESS set (flag is declared in [2]). That flag is declared as (1 << 30), which when set makes dtc unhappy about too big address set for a I2C-slave:
Warning (i2c_bus_reg): /example-2/i2c@1120000/eeprom@64: I2C bus unit address format error, expected "40000064" Warning (i2c_bus_reg): /example-2/i2c@1120000/eeprom@64:reg: I2C address must be less than 10-bits, got "0x40000064"
Similar problem would have happened if we had set the 10-bit address flag I2C_TEN_BIT_ADDRESS in the "reg"-property.
In order to fix the problem we suggest to alter the I2C-bus reg-check algorithm, so one would be aware of the upper bits set. Normally if no flag specified, the 7-bit address is expected in the "reg"-property. If I2C_TEN_BIT_ADDRESS is set, then the 10-bit address check will be performed. The I2C_OWN_SLAVE_ADDRESS flag will be just ignored.
[1] Documentation/i2c/slave-interface.rst
[2] include/dt-bindings/i2c/i2c.h
--- scripts/dtc/checks.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
scripts/dtc/checks.c +9 -4
@@ -1028,6 +1028,7 @@ static void check_i2c_bus_reg(struct check *c, struct dt_info *dti, struct nodeconst char *unitname =get_unitname (node);char unit_addr[17 ];uint32_t reg =0 ; +uint32_t addr;int len;cell_t *cells =NULL ;
@@ -1044,17 +1045,21 @@ static void check_i2c_bus_reg(struct check *c, struct dt_info *dti, struct node } reg =fdt32_to_cpu (*cells); -snprintf (unit_addr,sizeof (unit_addr),"%x" , reg); + addr = reg &0x3FFFFFFFU ; +snprintf (unit_addr,sizeof (unit_addr),"%x" , addr);if (!streq (unitname, unit_addr))FAIL (c, dti, node,"I2C bus unit address format error, expected \"%s\"" , unit_addr);for (len = prop->val.len; len >0 ; len -=4 ) { reg =fdt32_to_cpu (*(cells++)); -if (reg >0x3ff ) + addr = reg &0x3FFFFFFFU ; +if ((reg & (1 <<31 )) && addr >0x3ff )FAIL_PROP (c, dti, node, prop,"I2C address must be less than 10-bits, got \"0x%x\"" , - reg); - + addr); +else if (!(reg & (1 <<31 )) && addr >0x7f ) +FAIL_PROP (c, dti, node, prop,"I2C address must be less than 7-bits, got \"0x%x\"" , + addr); } }WARNING (i2c_bus_reg, check_i2c_bus_reg,NULL , ®_format, &i2c_bus_bridge);
Signature · 1 line
2.25.1
PATCH v2 2/12 dt-bindings: i2c: Convert DW I2C binding to DT schema
In reply to Serge SeminModern device tree bindings are supposed to be created as YAML-files in accordance with dt-schema. This commit replaces Synopsys DW I2C legacy bare text bindings with YAML file. As before the bindings file states that the corresponding dts node is supposed to be compatible either with generic DW I2C controller or with Microsemi Ocelot SoC I2C one, to have registers, interrupts and clocks properties. In addition the node may have clock-frequency, i2c-sda-hold-time-ns, i2c-scl-falling-time-ns and i2c-sda-falling-time-ns optional properties.
---
Changelog v2:
- Make sure that "mscc,ocelot-i2c" compatible node may have up to two registers space defined, while normal DW I2C controller will have only one registers space.
- Add "mscc,ocelot-i2c" example to test the previous fix.
- Declare "unevaluatedProperties" property instead of "additionalProperties" one.
- Due to the previous fix we can now discard the dummy boolean properties definitions, since the proper type evaluation will be performed by the generic i2c-controller.yaml schema.
--- .../bindings/i2c/i2c-designware.txt | 73 --------- .../bindings/i2c/snps,designware-i2c.yaml | 154 ++++++++++++++++++ 2 files changed, 154 insertions(+), 73 deletions(-) delete mode 100644 Documentation/devicetree/bindings/i2c/i2c-designware.txt create mode 100644 Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml
Documentation/devicetree/bindings/i2c/i2c-designware.txt deleted +0 -73
@@ -1,73 +0,0 @@ -* Synopsys DesignWare I2C - -Required properties : - - - compatible : should be "snps,designware-i2c" - or "mscc,ocelot-i2c" with "snps,designware-i2c" for fallback - - reg : Offset and length of the register set for the device - - interrupts : <IRQ> where IRQ is the interrupt number. - - clocks : phandles for the clocks, see the description of clock-names below. - The phandle for the "ic_clk" clock is required. The phandle for the "pclk" - clock is optional. If a single clock is specified but no clock-name, it is - the "ic_clk" clock. If both clocks are listed, the "ic_clk" must be first. - -Recommended properties : - - - clock-frequency : desired I2C bus clock frequency in Hz. - -Optional properties : - - - clock-names : Contains the names of the clocks: - "ic_clk", for the core clock used to generate the external I2C clock. - "pclk", the interface clock, required for register access. - - - reg : for "mscc,ocelot-i2c", a second register set to configure the SDA hold - time, named ICPU_CFG:TWI_DELAY in the datasheet. - - - i2c-sda-hold-time-ns : should contain the SDA hold time in nanoseconds. - This option is only supported in hardware blocks version 1.11a or newer and - on Microsemi SoCs ("mscc,ocelot-i2c" compatible). - - - i2c-scl-falling-time-ns : should contain the SCL falling time in nanoseconds. - This value which is by default 300ns is used to compute the tLOW period. - - - i2c-sda-falling-time-ns : should contain the SDA falling time in nanoseconds. - This value which is by default 300ns is used to compute the tHIGH period. - -Examples : - - i2c@f0000 { - #address-cells = <1>; - #size-cells = <0>; - compatible = "snps,designware-i2c"; - reg = <0xf0000 0x1000>; - interrupts = <11>; - clock-frequency = <400000>; - }; - - i2c@1120000 { - #address-cells = <1>; - #size-cells = <0>; - compatible = "snps,designware-i2c"; - reg = <0x1120000 0x1000>; - interrupt-parent = <&ictl>; - interrupts = <12 1>; - clock-frequency = <400000>; - i2c-sda-hold-time-ns = <300>; - i2c-sda-falling-time-ns = <300>; - i2c-scl-falling-time-ns = <300>; - }; - - i2c@1120000 { - #address-cells = <1>; - #size-cells = <0>; - reg = <0x2000 0x100>; - clock-frequency = <400000>; - clocks = <&i2cclk>; - interrupts = <0>; - - eeprom@64 { - compatible = "linux,slave-24c02"; - reg = <0x40000064>; - }; - };
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml new file +154 -0
154 lines not on this page · raw message
Signature · 1 line
2.25.1
Rob Herring
maintainerRe: [PATCH v2 02/12] dt-bindings: i2c: Convert DW I2C binding to DT schema
Quoted 181 lines · Serge Semin
Modern device tree bindings are supposed to be created as YAML-files in accordance with dt-schema. This commit replaces Synopsys DW I2C legacy bare text bindings with YAML file. As before the bindings file states that the corresponding dts node is supposed to be compatible either with generic DW I2C controller or with Microsemi Ocelot SoC I2C one, to have registers, interrupts and clocks properties. In addition the node may have clock-frequency, i2c-sda-hold-time-ns, i2c-scl-falling-time-ns and i2c-sda-falling-time-ns optional properties.
Signed-off-by Serge Semin <[email protected]>Cc Alexey Malahov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Paul Burton <[email protected]>Cc Ralf Baechle <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Mika Westerberg <[email protected]>Cc Wolfram Sang <[email protected]>Cc Frank Rowand <[email protected]>---
Changelog v2:
- Make sure that "mscc,ocelot-i2c" compatible node may have up to two registers space defined, while normal DW I2C controller will have only one registers space.
- Add "mscc,ocelot-i2c" example to test the previous fix.
- Declare "unevaluatedProperties" property instead of "additionalProperties" one.
- Due to the previous fix we can now discard the dummy boolean properties definitions, since the proper type evaluation will be performed by the generici2c-controller.yamlschema.--- .../bindings/i2c/i2c-designware.txt | 73 --------- .../bindings/i2c/snps,designware-i2c.yaml | 154 ++++++++++++++++++ 2 files changed, 154 insertions(+), 73 deletions(-) delete mode 100644 Documentation/devicetree/bindings/i2c/i2c-designware.txt create mode 100644 Documentation/devicetree/bindings/i2c/snps,designware-i2c.yamlDocumentation/devicetree/bindings/i2c/i2c-designware.txt deleted +0
-73@@ -1,73 +0,0 @@ -* Synopsys DesignWare I2C - -Required properties : - - - compatible : should be "snps,designware-i2c" - or "mscc,ocelot-i2c" with "snps,designware-i2c" for fallback - - reg : Offset and length of the register set for the device - - interrupts : <IRQ> where IRQ is the interrupt number. - - clocks : phandles for the clocks, see the description of clock-names below. - The phandle for the "ic_clk" clock is required. The phandle for the "pclk" - clock is optional. If a single clock is specified but no clock-name, it is - the "ic_clk" clock. If both clocks are listed, the "ic_clk" must be first. - -Recommended properties : - - - clock-frequency : desired I2C bus clock frequency in Hz. - -Optional properties : - - - clock-names : Contains the names of the clocks: - "ic_clk", for the core clock used to generate the external I2C clock. - "pclk", the interface clock, required for register access. - - - reg : for "mscc,ocelot-i2c", a second register set to configure the SDA hold - time, named ICPU_CFG:TWI_DELAY in the datasheet. - - - i2c-sda-hold-time-ns : should contain the SDA hold time in nanoseconds. - This option is only supported in hardware blocks version 1.11a or newer and - on Microsemi SoCs ("mscc,ocelot-i2c" compatible). - - - i2c-scl-falling-time-ns : should contain the SCL falling time in nanoseconds. - This value which is by default 300ns is used to compute the tLOW period. - - - i2c-sda-falling-time-ns : should contain the SDA falling time in nanoseconds. - This value which is by default 300ns is used to compute the tHIGH period. - -Examples : - - i2c@f0000 { - #address-cells = <1>; - #size-cells = <0>; - compatible = "snps,designware-i2c"; - reg = <0xf0000 0x1000>; - interrupts = <11>; - clock-frequency = <400000>; - }; - - i2c@1120000 { - #address-cells = <1>; - #size-cells = <0>; - compatible = "snps,designware-i2c"; - reg = <0x1120000 0x1000>; - interrupt-parent = <&ictl>; - interrupts = <12 1>; - clock-frequency = <400000>; - i2c-sda-hold-time-ns = <300>; - i2c-sda-falling-time-ns = <300>; - i2c-scl-falling-time-ns = <300>; - }; - - i2c@1120000 { - #address-cells = <1>; - #size-cells = <0>; - reg = <0x2000 0x100>; - clock-frequency = <400000>; - clocks = <&i2cclk>; - interrupts = <0>; - - eeprom@64 { - compatible = "linux,slave-24c02"; - reg = <0x40000064>; - }; - };Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml new file +57
-0@@ -0,0 +1,154 @@ +# SPDX-License-Identifier: GPL-2.0-only +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/i2c/snps,designware-i2c.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Synopsys DesignWare APB I2C Controller + +maintainers: + - Jarkko Nikula <[email protected]> + +allOf: + - $ref: /schemas/i2c/i2c-controller.yaml# + - if: + properties: + compatible: + not: + contains: + const: mscc,ocelot-i2c + then: + properties: + reg: + maxItems: 1 + +properties: + compatible: + oneOf: + - description: Generic Synopsys DesignWare I2C controller + const: snps,designware-i2c + - description: Microsemi Ocelot SoCs I2C controller + items: + - const: mscc,ocelot-i2c + - const: snps,designware-i2c + + reg: + minItems: 1 + items: + - description: DW APB I2C controller memory mapped registers + - description: | + ICPU_CFG:TWI_DELAY registers to setup the SDA hold time. + This registers are specific to the Ocelot I2C-controller. + + interrupts: + maxItems: 1 + + clocks: + minItems: 1 + items: + - description: I2C controller reference clock source + - description: APB interface clock source + + clock-names: + minItems: 1 + items: + - const: ref + - const: pclk +
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml line 67
Quoted 10 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml new file +10
-0+ resets: + maxItems: 1 + + clock-frequency: + description: Desired I2C bus clock frequency in Hz + enum: [100000, 400000, 1000000, 3400000] + default: 400000 + + i2c-sda-hold-time-ns: + $ref: /schemas/types.yaml#/definitions/uint32
Don't need a type ref as properties with a unit-suffix already have one.
Quoted 63 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml new file +63
-0+ description: | + The property should contain the SDA hold time in nanoseconds. This option + is only supported in hardware blocks version 1.11a or newer or on + Microsemi SoCs. + + i2c-scl-falling-time-ns: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + The property should contain the SCL falling time in nanoseconds. + This value is used to compute the tLOW period. + default: 300 + + i2c-sda-falling-time-ns: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + The property should contain the SDA falling time in nanoseconds. + This value is used to compute the tHIGH period. + default: 300 + + dmas: + items: + - description: TX DMA Channel + - description: RX DMA Channel + + dma-names: + items: + - const: tx + - const: rx + +unevaluatedProperties: false + +required: + - compatible + - reg + - "#address-cells" + - "#size-cells" + - interrupts + +examples: + - | + i2c@f0000 { + compatible = "snps,designware-i2c"; + reg = <0xf0000 0x1000>; + #address-cells = <1>; + #size-cells = <0>; + interrupts = <11>; + clock-frequency = <400000>; + }; + - | + i2c@1120000 { + compatible = "snps,designware-i2c"; + reg = <0x1120000 0x1000>; + #address-cells = <1>; + #size-cells = <0>; + interrupts = <12 1>; + clock-frequency = <400000>; + i2c-sda-hold-time-ns = <300>; + i2c-sda-falling-time-ns = <300>; + i2c-scl-falling-time-ns = <300>; + }; + - | + i2c@2000 { + compatible = "snps,designware-i2c";
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml line 140
Quoted 10 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml new file +10
-0+ reg = <0x2000 0x100>; + #address-cells = <1>; + #size-cells = <0>; + clock-frequency = <400000>; + clocks = <&i2cclk>; + interrupts = <0>; + + eeprom@64 { + compatible = "linux,slave-24c02"; + reg = <0x40000064>;
This causes 'make dt_binding_check' to fail. The unit-address should be '40000064'. However, there's a bug in dtc not liking the high bits set either. There's a fix pending, but I'd just fix the example here to avoid the issue.
Quoted 17 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml new file +14
-0+ }; + }; + - | + i2c@100400 { + compatible = "mscc,ocelot-i2c", "snps,designware-i2c"; + reg = <0x100400 0x100>, <0x198 0x8>; + pinctrl-0 = <&i2c_pins>; + pinctrl-names = "default"; + #address-cells = <1>; + #size-cells = <0>; + interrupts = <8>; + clocks = <&ahb_clk>; + }; +...Signature · 1 line
2.25.1
Re: [PATCH v2 02/12] dt-bindings: i2c: Convert DW I2C binding to DT schema
Quoted 186 lines · Rob Herring
Quoted 185 lines · Serge Semin
Modern device tree bindings are supposed to be created as YAML-files in accordance with dt-schema. This commit replaces Synopsys DW I2C legacy bare text bindings with YAML file. As before the bindings file states that the corresponding dts node is supposed to be compatible either with generic DW I2C controller or with Microsemi Ocelot SoC I2C one, to have registers, interrupts and clocks properties. In addition the node may have clock-frequency, i2c-sda-hold-time-ns, i2c-scl-falling-time-ns and i2c-sda-falling-time-ns optional properties.
Signed-off-by Serge Semin <[email protected]>Cc Alexey Malahov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Paul Burton <[email protected]>Cc Ralf Baechle <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Mika Westerberg <[email protected]>Cc Wolfram Sang <[email protected]>Cc Frank Rowand <[email protected]>---
Changelog v2:
- Make sure that "mscc,ocelot-i2c" compatible node may have up to two registers space defined, while normal DW I2C controller will have only one registers space.
- Add "mscc,ocelot-i2c" example to test the previous fix.
- Declare "unevaluatedProperties" property instead of "additionalProperties" one.
- Due to the previous fix we can now discard the dummy boolean properties definitions, since the proper type evaluation will be performed by the generici2c-controller.yamlschema.--- .../bindings/i2c/i2c-designware.txt | 73 --------- .../bindings/i2c/snps,designware-i2c.yaml | 154 ++++++++++++++++++ 2 files changed, 154 insertions(+), 73 deletions(-) delete mode 100644 Documentation/devicetree/bindings/i2c/i2c-designware.txt create mode 100644 Documentation/devicetree/bindings/i2c/snps,designware-i2c.yamlDocumentation/devicetree/bindings/i2c/i2c-designware.txt deleted +0
-73@@ -1,73 +0,0 @@ -* Synopsys DesignWare I2C - -Required properties : - - - compatible : should be "snps,designware-i2c" - or "mscc,ocelot-i2c" with "snps,designware-i2c" for fallback - - reg : Offset and length of the register set for the device - - interrupts : <IRQ> where IRQ is the interrupt number. - - clocks : phandles for the clocks, see the description of clock-names below. - The phandle for the "ic_clk" clock is required. The phandle for the "pclk" - clock is optional. If a single clock is specified but no clock-name, it is - the "ic_clk" clock. If both clocks are listed, the "ic_clk" must be first. - -Recommended properties : - - - clock-frequency : desired I2C bus clock frequency in Hz. - -Optional properties : - - - clock-names : Contains the names of the clocks: - "ic_clk", for the core clock used to generate the external I2C clock. - "pclk", the interface clock, required for register access. - - - reg : for "mscc,ocelot-i2c", a second register set to configure the SDA hold - time, named ICPU_CFG:TWI_DELAY in the datasheet. - - - i2c-sda-hold-time-ns : should contain the SDA hold time in nanoseconds. - This option is only supported in hardware blocks version 1.11a or newer and - on Microsemi SoCs ("mscc,ocelot-i2c" compatible). - - - i2c-scl-falling-time-ns : should contain the SCL falling time in nanoseconds. - This value which is by default 300ns is used to compute the tLOW period. - - - i2c-sda-falling-time-ns : should contain the SDA falling time in nanoseconds. - This value which is by default 300ns is used to compute the tHIGH period. - -Examples : - - i2c@f0000 { - #address-cells = <1>; - #size-cells = <0>; - compatible = "snps,designware-i2c"; - reg = <0xf0000 0x1000>; - interrupts = <11>; - clock-frequency = <400000>; - }; - - i2c@1120000 { - #address-cells = <1>; - #size-cells = <0>; - compatible = "snps,designware-i2c"; - reg = <0x1120000 0x1000>; - interrupt-parent = <&ictl>; - interrupts = <12 1>; - clock-frequency = <400000>; - i2c-sda-hold-time-ns = <300>; - i2c-sda-falling-time-ns = <300>; - i2c-scl-falling-time-ns = <300>; - }; - - i2c@1120000 { - #address-cells = <1>; - #size-cells = <0>; - reg = <0x2000 0x100>; - clock-frequency = <400000>; - clocks = <&i2cclk>; - interrupts = <0>; - - eeprom@64 { - compatible = "linux,slave-24c02"; - reg = <0x40000064>; - }; - };Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml new file +61
-0@@ -0,0 +1,154 @@ +# SPDX-License-Identifier: GPL-2.0-only +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/i2c/snps,designware-i2c.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Synopsys DesignWare APB I2C Controller + +maintainers: + - Jarkko Nikula <[email protected]> + +allOf: + - $ref: /schemas/i2c/i2c-controller.yaml# + - if: + properties: + compatible: + not: + contains: + const: mscc,ocelot-i2c + then: + properties: + reg: + maxItems: 1 + +properties: + compatible: + oneOf: + - description: Generic Synopsys DesignWare I2C controller + const: snps,designware-i2c + - description: Microsemi Ocelot SoCs I2C controller + items: + - const: mscc,ocelot-i2c + - const: snps,designware-i2c + + reg: + minItems: 1 + items: + - description: DW APB I2C controller memory mapped registers + - description: | + ICPU_CFG:TWI_DELAY registers to setup the SDA hold time. + This registers are specific to the Ocelot I2C-controller. + + interrupts: + maxItems: 1 + + clocks: + minItems: 1 + items: + - description: I2C controller reference clock source + - description: APB interface clock source + + clock-names: + minItems: 1 + items: + - const: ref + - const: pclk + + resets: + maxItems: 1 + + clock-frequency:
Quoted 8 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml line 67
Quoted 6 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml new file +6
-0+ description: Desired I2C bus clock frequency in Hz + enum: [100000, 400000, 1000000, 3400000] + default: 400000 + + i2c-sda-hold-time-ns: + $ref: /schemas/types.yaml#/definitions/uint32Don't need a type ref as properties with a unit-suffix already have one.
Ok. Seeing "-ns" suffixed properties have uint32-array type I'll have to add the restriction "maxItems: 1" here then.
Quoted 71 lines
Quoted 71 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml new file +70
-0+ description: | + The property should contain the SDA hold time in nanoseconds. This option + is only supported in hardware blocks version 1.11a or newer or on + Microsemi SoCs. + + i2c-scl-falling-time-ns: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + The property should contain the SCL falling time in nanoseconds. + This value is used to compute the tLOW period. + default: 300 + + i2c-sda-falling-time-ns: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + The property should contain the SDA falling time in nanoseconds. + This value is used to compute the tHIGH period. + default: 300 + + dmas: + items: + - description: TX DMA Channel + - description: RX DMA Channel + + dma-names: + items: + - const: tx + - const: rx + +unevaluatedProperties: false + +required: + - compatible + - reg + - "#address-cells" + - "#size-cells" + - interrupts + +examples: + - | + i2c@f0000 { + compatible = "snps,designware-i2c"; + reg = <0xf0000 0x1000>; + #address-cells = <1>; + #size-cells = <0>; + interrupts = <11>; + clock-frequency = <400000>; + }; + - | + i2c@1120000 { + compatible = "snps,designware-i2c"; + reg = <0x1120000 0x1000>; + #address-cells = <1>; + #size-cells = <0>; + interrupts = <12 1>; + clock-frequency = <400000>; + i2c-sda-hold-time-ns = <300>; + i2c-sda-falling-time-ns = <300>; + i2c-scl-falling-time-ns = <300>; + }; + - | + i2c@2000 { + compatible = "snps,designware-i2c"; + reg = <0x2000 0x100>; + #address-cells = <1>; + #size-cells = <0>; + clock-frequency = <400000>; + clocks = <&i2cclk>; + interrupts = <0>; +
Quoted 8 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml line 140
Quoted 3 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml new file +3
-0+ eeprom@64 { + compatible = "linux,slave-24c02"; + reg = <0x40000064>;This causes 'make
dt_binding_check' to fail. The unit-address should be '40000064'. However, there's a bug in dtc not liking the high bits set either. There's a fix pending, but I'd just fix the example here to avoid the issue.
Do you mean a fix suggested in this patchset or someplace else? I've submitted it before this patch so to solve the problem you've discovered.
Regarding the example. Do you suggest to completely remove the eeprom sub-node? I am asking because without proper reg flags setting the i2c-slave mode example would be just wrong.
-Sergey
Quoted 18 lines
Quoted 18 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml new file +14
-0+ }; + }; + - | + i2c@100400 { + compatible = "mscc,ocelot-i2c", "snps,designware-i2c"; + reg = <0x100400 0x100>, <0x198 0x8>; + pinctrl-0 = <&i2c_pins>; + pinctrl-names = "default"; + #address-cells = <1>; + #size-cells = <0>; + interrupts = <8>; + clocks = <&ahb_clk>; + }; +...Signature · 1 line
2.25.1
PATCH v2 3/12 dt-bindings: i2c: dw: Add Baikal-T1 SoC I2C controller
In reply to Serge SeminAdd the "baikal,bt1-sys-i2c" compatible string to the DW I2C binding and make sure the reg property isn't required in this case because the controller is embedded into the Baikal-T1 System Controller. The rest of the DW APB I2C properties are compatible and can be freely used to describe the Baikal-T1 I2C controller dts-node.
---
Rob, I had to remove your acked-by tag because of the changes introduced in v2 of the patch.
Changelog v2:
- Make the reg property being optional if it's Baikal-T1 System I2C DT node.
--- .../devicetree/bindings/i2c/snps,designware-i2c.yaml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml +11 -1
@@ -21,6 +21,15 @@ allOf: properties: reg: maxItems: 1 + - if: + properties: + compatible: + not: + contains: + const: baikal,bt1-sys-i2c + then: + required: + - reg properties: compatible:
@@ -31,6 +40,8 @@ properties: items: - const: mscc,ocelot-i2c - const: snps,designware-i2c + - description: Baikal-T1 SoC System I2C controller + const: baikal,bt1-sys-i2c reg: minItems: 1
@@ -98,7 +109,6 @@ unevaluatedProperties: false required: - compatible - - reg - "#address-cells" - "#size-cells" - interrupts
Signature · 1 line
2.25.1
Rob Herring
maintainerRe: [PATCH v2 03/12] dt-bindings: i2c: dw: Add Baikal-T1 SoC I2C controller
Quoted 5 lines · Serge Semin
Add the "baikal,bt1-sys-i2c" compatible string to the DW I2C binding and make sure the reg property isn't required in this case because the controller is embedded into the Baikal-T1 System Controller. The rest of the DW APB I2C properties are compatible and can be freely used to describe the Baikal-T1 I2C controller dts-node.
Is there not a sub-range of the system controller with the I2C registers? I'd assume there is, so you can still have 'reg' even if Linux doesn't use it (currently).
Quoted 64 lines
Signed-off-by Serge Semin <[email protected]>Cc Alexey Malahov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Paul Burton <[email protected]>Cc Ralf Baechle <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Mika Westerberg <[email protected]>Cc Wolfram Sang <[email protected]>Cc Frank Rowand <[email protected]>---
Rob, I had to remove your acked-by tag because of the changes introduced in v2 of the patch.
Changelog v2:
- Make the reg property being optional if it's Baikal-T1 System I2C DT node.--- .../devicetree/bindings/i2c/snps,designware-i2c.yaml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml +11
-1@@ -21,6 +21,15 @@ allOf: properties: reg: maxItems: 1 + - if: + properties: + compatible: + not: + contains: + const: baikal,bt1-sys-i2c + then: + required: + - reg properties: compatible:@@ -31,6 +40,8 @@ properties: items: - const: mscc,ocelot-i2c - const: snps,designware-i2c + - description: Baikal-T1 SoC System I2C controller + const: baikal,bt1-sys-i2c reg: minItems: 1@@ -98,7 +109,6 @@ unevaluatedProperties: false required: - compatible - - reg - "#address-cells" - "#size-cells" - interruptsSignature · 1 line
2.25.1
Re: [PATCH v2 03/12] dt-bindings: i2c: dw: Add Baikal-T1 SoC I2C controller
Quoted 10 lines · Rob Herring
Quoted 5 lines · Serge Semin
Add the "baikal,bt1-sys-i2c" compatible string to the DW I2C binding and make sure the reg property isn't required in this case because the controller is embedded into the Baikal-T1 System Controller. The rest of the DW APB I2C properties are compatible and can be freely used to describe the Baikal-T1 I2C controller dts-node.
Is there not a sub-range of the system controller with the I2C registers? I'd assume there is, so you can still have 'reg' even if Linux doesn't use it (currently).
Yes, there is a range. It's just three access registers. Is it wrong to make the reg property being optional in this case since it can be accessed over syscon regmap? Do you suggest to get back the reg property being required for our device?
-Sergey
Quoted 65 lines
Quoted 65 lines
Signed-off-by Serge Semin <[email protected]>Cc Alexey Malahov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Paul Burton <[email protected]>Cc Ralf Baechle <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Mika Westerberg <[email protected]>Cc Wolfram Sang <[email protected]>Cc Frank Rowand <[email protected]>---
Rob, I had to remove your acked-by tag because of the changes introduced in v2 of the patch.
Changelog v2:
- Make the reg property being optional if it's Baikal-T1 System I2C DT node.--- .../devicetree/bindings/i2c/snps,designware-i2c.yaml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml +11
-1@@ -21,6 +21,15 @@ allOf: properties: reg: maxItems: 1 + - if: + properties: + compatible: + not: + contains: + const: baikal,bt1-sys-i2c + then: + required: + - reg properties: compatible:@@ -31,6 +40,8 @@ properties: items: - const: mscc,ocelot-i2c - const: snps,designware-i2c + - description: Baikal-T1 SoC System I2C controller + const: baikal,bt1-sys-i2c reg: minItems: 1@@ -98,7 +109,6 @@ unevaluatedProperties: false required: - compatible - - reg - "#address-cells" - "#size-cells" - interruptsSignature · 1 line
2.25.1
PATCH v2 4/12 i2c: designware: Convert driver to using regmap API
In reply to Serge SeminSeeing the DW I2C driver is using flags-based accessors with two conditional clauses it would be better to replace them with the regmap API IO methods and to initialize the regmap object with read/write callbacks specific to the controller registers map implementation. This will be also handy for the drivers with non-standard registers mapping (like an embedded into the Baikal-T1 System Controller DW I2C block, which glue-driver is a part of this series).
As before the driver tries to detect the mapping setup at probe stage and creates a regmap object accordingly, which will be used by the rest of the code to correctly access the controller registers. In two places it was appropriate to convert the hand-written read-modify-write and read-poll-loop design patterns to the corresponding regmap API ready-to-use methods.
Note the regmap IO methods return value is checked only at the probe stage. The rest of the code won't do this because basically we have MMIO-based regmap so non of the read/write methods can fail (this also won't be needed for the Baikal-T1-specific I2C controller).
--- drivers/i2c/busses/Kconfig | 1 + drivers/i2c/busses/i2c-designware-common.c | 171 +++++++++++++++------ drivers/i2c/busses/i2c-designware-core.h | 18 +-- drivers/i2c/busses/i2c-designware-master.c | 125 ++++++++------- drivers/i2c/busses/i2c-designware-slave.c | 77 +++++----- 5 files changed, 239 insertions(+), 153 deletions(-)
drivers/i2c/busses/Kconfig +1 -0
@@ -526,6 +526,7 @@ config I2C_DAVINCI config I2C_DESIGNWARE_CORE tristate + select REGMAP config I2C_DESIGNWARE_PLATFORM tristate "Synopsys DesignWare Platform"
drivers/i2c/busses/i2c-designware-common.c +120 -51
283 lines not on this page · raw message
drivers/i2c/busses/i2c-designware-core.h +8 -10
@@ -10,6 +10,7 @@*/ #include <linux/i2c.h> +#include <linux/regmap.h> #define DW_IC_DEFAULT_FUNCTIONALITY (I2C_FUNC_I2C | \ I2C_FUNC_SMBUS_BYTE | \
@@ -120,8 +121,6 @@#define STATUS_WRITE_IN_PROGRESS 0x1#define STATUS_READ_IN_PROGRESS 0x2 -#define TIMEOUT 20/* ms */ -/* * operation modes */
@@ -174,7 +173,9 @@/** * struct dw_i2c_dev - private i2c-designware data * @dev: driver model device node +* @map: IO registers map * @base: IO registers pointer +* @ext: Extended IO registers pointer * @cmd_complete: tx completion indicator * @clk: input reference clock * @pclk: clock required to access the registers
@@ -224,6 +225,7 @@*/ struct dw_i2c_dev {struct device *dev; +struct regmap *map;void __iomem *base;void __iomem *ext;struct completion cmd_complete;
@@ -276,8 +278,6 @@ struct dw_i2c_dev {bool suspended; }; -#define ACCESS_SWAP 0x00000001 -#define ACCESS_16BIT 0x00000002#define ACCESS_INTR_MASK 0x00000004#define ACCESS_NO_IRQ_SUSPEND 0x00000008
@@ -285,9 +285,7 @@ struct dw_i2c_dev {#define MODEL_MSCC_OCELOT 0x00000200#define MODEL_MASK 0x00000f00 -u32 dw_readl (struct dw_i2c_dev *dev,int offset); -void dw_writel (struct dw_i2c_dev *dev,u32 b,int offset); -int i2c_dw_set_reg_access (struct dw_i2c_dev *dev); +int i2c_dw_init_regmap (struct dw_i2c_dev *dev);u32 i2c_dw_scl_hcnt (u32 ic_clk,u32 tSYMBOL,u32 tf,int cond,int offset);u32 i2c_dw_scl_lcnt (u32 ic_clk,u32 tLOW,u32 tf,int offset);int i2c_dw_set_sda_hold (struct dw_i2c_dev *dev);
@@ -297,19 +295,19 @@ int i2c_dw_acquire_lock(struct dw_i2c_dev *dev);void i2c_dw_release_lock (struct dw_i2c_dev *dev);int i2c_dw_wait_bus_not_busy (struct dw_i2c_dev *dev);int i2c_dw_handle_tx_abort (struct dw_i2c_dev *dev); -void i2c_dw_set_fifo_size (struct dw_i2c_dev *dev); +int i2c_dw_set_fifo_size (struct dw_i2c_dev *dev);u32 i2c_dw_func (struct i2c_adapter *adap);void i2c_dw_disable (struct dw_i2c_dev *dev);void i2c_dw_disable_int (struct dw_i2c_dev *dev);static inline void __i2c_dw_enable (struct dw_i2c_dev *dev) { -dw_writel (dev,1 ,DW_IC_ENABLE ); +regmap_write (dev->map,DW_IC_ENABLE ,1 ); }static inline void __i2c_dw_disable_nowait (struct dw_i2c_dev *dev) { -dw_writel (dev,0 ,DW_IC_ENABLE ); +regmap_write (dev->map,DW_IC_ENABLE ,0 ); }void __i2c_dw_disable (struct dw_i2c_dev *dev);
drivers/i2c/busses/i2c-designware-master.c +69 -56
308 lines not on this page · raw message
drivers/i2c/busses/i2c-designware-slave.c +41 -36
185 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v2 04/12] i2c: designware: Convert driver to using regmap API
Quoted 31 lines · Serge Semin
Seeing the DW I2C driver is using flags-based accessors with two conditional clauses it would be better to replace them with the regmap API IO methods and to initialize the regmap object with read/write callbacks specific to the controller registers map implementation. This will be also handy for the drivers with non-standard registers mapping (like an embedded into the Baikal-T1 System Controller DW I2C block, which glue-driver is a part of this series).
As before the driver tries to detect the mapping setup at probe stage and creates a regmap object accordingly, which will be used by the rest of the code to correctly access the controller registers. In two places it was appropriate to convert the hand-written read-modify-write and read-poll-loop design patterns to the corresponding regmap API ready-to-use methods.
Note the regmap IO methods return value is checked only at the probe stage. The rest of the code won't do this because basically we have MMIO-based regmap so non of the read/write methods can fail (this also won't be needed for the Baikal-T1-specific I2C controller).
Suggested-by Andy Shevchenko <[email protected]>Signed-off-by Serge Semin <[email protected]>Cc Alexey Malahov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Paul Burton <[email protected]>Cc Ralf Baechle <[email protected]>Cc Wolfram Sang <[email protected]>Cc Rob Herring <[email protected]>Cc Frank Rowand <[email protected]>
Quoted 8 lines
--- drivers/i2c/busses/Kconfig | 1 + drivers/i2c/busses/i2c-designware-common.c | 171 +++++++++++++++------ drivers/i2c/busses/i2c-designware-core.h | 18 +-- drivers/i2c/busses/i2c-designware-master.c | 125 ++++++++------- drivers/i2c/busses/i2c-designware-slave.c | 77 +++++----- 5 files changed, 239 insertions(+), 153 deletions(-)
Looking at patches 4/12-12/12 I think it would be good to move fixes and less invasive patches before this. Like
i2c: designware: slave: Set DW I2C core module dependency
i2c: designware: Use -y to build multi-object modules
i2c: designware: Move Baytrail sem config to the platform if-clause
That said, you may add:
Re: [PATCH v2 04/12] i2c: designware: Convert driver to using regmap API
Quoted 43 lines · Jarkko Nikula
Quoted 31 lines · Serge Semin
Seeing the DW I2C driver is using flags-based accessors with two conditional clauses it would be better to replace them with the regmap API IO methods and to initialize the regmap object with read/write callbacks specific to the controller registers map implementation. This will be also handy for the drivers with non-standard registers mapping (like an embedded into the Baikal-T1 System Controller DW I2C block, which glue-driver is a part of this series).
As before the driver tries to detect the mapping setup at probe stage and creates a regmap object accordingly, which will be used by the rest of the code to correctly access the controller registers. In two places it was appropriate to convert the hand-written read-modify-write and read-poll-loop design patterns to the corresponding regmap API ready-to-use methods.
Note the regmap IO methods return value is checked only at the probe stage. The rest of the code won't do this because basically we have MMIO-based regmap so non of the read/write methods can fail (this also won't be needed for the Baikal-T1-specific I2C controller).
Suggested-by Andy Shevchenko <[email protected]>Signed-off-by Serge Semin <[email protected]>Cc Alexey Malahov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Paul Burton <[email protected]>Cc Ralf Baechle <[email protected]>Cc Wolfram Sang <[email protected]>Cc Rob Herring <[email protected]>Cc Frank Rowand <[email protected]>Quoted 8 lines
--- drivers/i2c/busses/Kconfig | 1 + drivers/i2c/busses/i2c-designware-common.c | 171 +++++++++++++++------ drivers/i2c/busses/i2c-designware-core.h | 18 +-- drivers/i2c/busses/i2c-designware-master.c | 125 ++++++++------- drivers/i2c/busses/i2c-designware-slave.c | 77 +++++----- 5 files changed, 239 insertions(+), 153 deletions(-)Looking at patches 4/12-12/12 I think it would be good to move fixes and less invasive patches before this. Like
Quoted 8 lines
i2c: designware: slave: Set DW I2C core module dependency
i2c: designware: Use-yto build multi-object modules
i2c: designware: Move Baytrail sem config to the platform if-clauseThat said, you may add:
Tested-by Jarkko Nikula <[email protected]>Acked-by Jarkko Nikula <[email protected]>
Ok. I'll move those three patches to be before this one in v3. Thanks.
-Sergey
PATCH v2 5/12 i2c: designware: Use `-y` to build multi-object modules
In reply to Serge SeminSince commit 4f8272802739 ("Documentation: update kbuild loadable modules goals & examples") -objs is fitted for building host programs, lets change DW I2C core, platform and PCI driver kbuild directives to using -y, which more straightforward for device drivers. By doing so we can discard the ifeq construction in favor to the more natural and less bulky <module>-$(CONFIG_X) += x.o
--- drivers/i2c/busses/Makefile | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/i2c/busses/Makefile +8 -9
@@ -48,16 +48,15 @@ obj-$(CONFIG_I2C_CADENCE) += i2c-cadence.o obj-$(CONFIG_I2C_CBUS_GPIO) += i2c-cbus-gpio.o obj-$(CONFIG_I2C_CPM) += i2c-cpm.o obj-$(CONFIG_I2C_DAVINCI) += i2c-davinci.o -obj-$(CONFIG_I2C_DESIGNWARE_CORE) += i2c-designware-core.o -i2c-designware-core-objs := i2c-designware-common.o i2c-designware-master.o -ifeq ($(CONFIG_I2C_DESIGNWARE_SLAVE),y) -i2c-designware-core-objs += i2c-designware-slave.o -endif -obj-$(CONFIG_I2C_DESIGNWARE_PLATFORM) += i2c-designware-platform.o -i2c-designware-platform-objs := i2c-designware-platdrv.o +obj-$(CONFIG_I2C_DESIGNWARE_CORE) += i2c-designware-core.o +i2c-designware-core-y := i2c-designware-common.o +i2c-designware-core-y += i2c-designware-master.o +i2c-designware-core-$(CONFIG_I2C_DESIGNWARE_SLAVE) += i2c-designware-slave.o +obj-$(CONFIG_I2C_DESIGNWARE_PLATFORM) += i2c-designware-platform.o +i2c-designware-platform-y := i2c-designware-platdrv.o i2c-designware-platform-$(CONFIG_I2C_DESIGNWARE_BAYTRAIL) += i2c-designware-baytrail.o -obj-$(CONFIG_I2C_DESIGNWARE_PCI) += i2c-designware-pci.o -i2c-designware-pci-objs := i2c-designware-pcidrv.o +obj-$(CONFIG_I2C_DESIGNWARE_PCI) += i2c-designware-pci.o +i2c-designware-pci-y := i2c-designware-pcidrv.o obj-$(CONFIG_I2C_DIGICOLOR) += i2c-digicolor.o obj-$(CONFIG_I2C_EFM32) += i2c-efm32.o obj-$(CONFIG_I2C_EG20T) += i2c-eg20t.o
Signature · 1 line
2.25.1
Re: [PATCH v2 05/12] i2c: designware: Use `-y` to build multi-object modules
Quoted 19 lines · Serge Semin
Since commit
4f8272802739("Documentation: update kbuild loadable modules goals & examples")-objsis fitted for building host programs, lets change DW I2C core, platform and PCI driver kbuild directives to using-y, which more straightforward for device drivers. By doing so we can discard the ifeq construction in favor to the more natural and less bulky<module>-$(CONFIG_X) += x.oSigned-off-by Serge Semin <[email protected]>Cc Alexey Malahov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Paul Burton <[email protected]>Cc Ralf Baechle <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Mika Westerberg <[email protected]>Cc Wolfram Sang <[email protected]>Cc Rob Herring <[email protected]>Cc Frank Rowand <[email protected]>
Quoted 4 lines
--- drivers/i2c/busses/Makefile | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
PATCH v2 6/12 i2c: designware: slave: Set DW I2C core module dependency
In reply to Serge SeminDW APB I2C slave code in fact depends on the DW I2C driver core, but not on the platform code. Yes, the I2C slave interface is currently supported by the platform version of the IP core, but it doesn't make it dependent on it. So make sure the DW APB I2C slave config is only available if the I2C_DESIGNWARE_CORE config is enabled.
--- drivers/i2c/busses/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/Kconfig +1 -1
@@ -541,8 +541,8 @@ config I2C_DESIGNWARE_PLATFORM config I2C_DESIGNWARE_SLAVE bool "Synopsys DesignWare Slave" + depends on I2C_DESIGNWARE_CORE select I2C_SLAVE - depends on I2C_DESIGNWARE_PLATFORM help If you say yes to this option, support will be included for the Synopsys DesignWare I2C slave adapter.
Signature · 1 line
2.25.1
Re: [PATCH v2 06/12] i2c: designware: slave: Set DW I2C core module dependency
Quoted 18 lines · Serge Semin
DW APB I2C slave code in fact depends on the DW I2C driver core, but not on the platform code. Yes, the I2C slave interface is currently supported by the platform version of the IP core, but it doesn't make it dependent on it. So make sure the DW APB I2C slave config is only available if the
I2C_DESIGNWARE_COREconfig is enabled.Signed-off-by Serge Semin <[email protected]>Cc Alexey Malahov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Paul Burton <[email protected]>Cc Ralf Baechle <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Mika Westerberg <[email protected]>Cc Wolfram Sang <[email protected]>Cc Rob Herring <[email protected]>Cc Frank Rowand <[email protected]>
Quoted 4 lines
--- drivers/i2c/busses/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
PATCH v2 7/12 i2c: designware: Move Baytrail sem config to the platform if-clause
In reply to Serge SeminCurrently Intel Baytrail I2C semaphore is a feature of the DW APB I2C platform driver. It's a bit confusing to see it's config in the menu at some separated place with no reference to the platform code. Lets move the config definition under the if-I2C_DESIGNWARE_PLATFORM clause. By doing so the config menu will display the feature right below the DW I2C platform driver item and will indent it to the right so signifying its belonging.
--- drivers/i2c/busses/Kconfig | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-)
drivers/i2c/busses/Kconfig +17 -13
@@ -530,8 +530,8 @@ config I2C_DESIGNWARE_CORE config I2C_DESIGNWARE_PLATFORM tristate "Synopsys DesignWare Platform" - select I2C_DESIGNWARE_CORE depends on (ACPI && COMMON_CLK) || !ACPI + select I2C_DESIGNWARE_CORE help If you say yes to this option, support will be included for the Synopsys DesignWare I2C adapter.
@@ -539,6 +539,22 @@ config I2C_DESIGNWARE_PLATFORM This driver can also be built as a module. If so, the module will be called i2c-designware-platform. +if I2C_DESIGNWARE_PLATFORM + +config I2C_DESIGNWARE_BAYTRAIL + bool "Intel Baytrail I2C semaphore support" + depends on ACPI + depends on (I2C_DESIGNWARE_PLATFORM=m && IOSF_MBI) || \ + (I2C_DESIGNWARE_PLATFORM=y && IOSF_MBI=y) + help + This driver enables managed host access to the PMIC I2C bus on select + Intel BayTrail platforms using the X-Powers AXP288 PMIC. It allows + the host to request uninterrupted access to the PMIC's I2C bus from + the platform firmware controlling it. You should say Y if running on + a BayTrail system using the AXP288. + +endif # I2C_DESIGNWARE_PLATFORM + config I2C_DESIGNWARE_SLAVE bool "Synopsys DesignWare Slave" depends on I2C_DESIGNWARE_CORE
@@ -561,18 +577,6 @@ config I2C_DESIGNWARE_PCI This driver can also be built as a module. If so, the module will be called i2c-designware-pci. -config I2C_DESIGNWARE_BAYTRAIL - bool "Intel Baytrail I2C semaphore support" - depends on ACPI - depends on (I2C_DESIGNWARE_PLATFORM=m && IOSF_MBI) || \ - (I2C_DESIGNWARE_PLATFORM=y && IOSF_MBI=y) - help - This driver enables managed host access to the PMIC I2C bus on select - Intel BayTrail platforms using the X-Powers AXP288 PMIC. It allows - the host to request uninterrupted access to the PMIC's I2C bus from - the platform firmware controlling it. You should say Y if running on - a BayTrail system using the AXP288. - config I2C_DIGICOLOR tristate "Conexant Digicolor I2C driver" depends on ARCH_DIGICOLOR || COMPILE_TEST
Signature · 1 line
2.25.1
Re: [PATCH v2 07/12] i2c: designware: Move Baytrail sem config to the platform if-clause
Quoted 47 lines · Serge Semin
Currently Intel Baytrail I2C semaphore is a feature of the DW APB I2C platform driver. It's a bit confusing to see it's config in the menu at some separated place with no reference to the platform code. Lets move the config definition under the if-I2C_DESIGNWARE_PLATFORM clause. By doing so the config menu will display the feature right below the DW I2C platform driver item and will indent it to the right so signifying its belonging.
Signed-off-by Serge Semin <[email protected]>Cc Alexey Malahov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Paul Burton <[email protected]>Cc Ralf Baechle <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Mika Westerberg <[email protected]>Cc Wolfram Sang <[email protected]>Cc Rob Herring <[email protected]>Cc Frank Rowand <[email protected]>--- drivers/i2c/busses/Kconfig | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-)drivers/i2c/busses/Kconfig +7
-1@@ -530,8 +530,8 @@ config I2C_DESIGNWARE_CORE config I2C_DESIGNWARE_PLATFORM tristate "Synopsys DesignWare Platform" - select I2C_DESIGNWARE_CORE depends on (ACPI && COMMON_CLK) || !ACPI + select I2C_DESIGNWARE_CORE help If you say yes to this option, support will be included for the Synopsys DesignWare I2C adapter.@@ -539,6 +539,22 @@ config I2C_DESIGNWARE_PLATFORM This driver can also be built as a module. If so, the module will be called i2c-designware-platform. +if I2C_DESIGNWARE_PLATFORM + +config I2C_DESIGNWARE_BAYTRAIL + bool "Intel Baytrail I2C semaphore support" + depends on ACPI + depends on (I2C_DESIGNWARE_PLATFORM=m && IOSF_MBI) || \
drivers/i2c/busses/Kconfig config I2C_DESIGNWARE_PLATFORM · line 557
Quoted 10 lines
drivers/i2c/busses/Kconfig +10
-0+ (I2C_DESIGNWARE_PLATFORM=y && IOSF_MBI=y) + help + This driver enables managed host access to the PMIC I2C bus on select + Intel BayTrail platforms using the X-Powers AXP288 PMIC. It allows + the host to request uninterrupted access to the PMIC's I2C bus from + the platform firmware controlling it. You should say Y if running on + a BayTrail system using the AXP288. + +endif # I2C_DESIGNWARE_PLATFORM +
Is the added "if I2C_DESIGNWARE_PLATFORM" needed here? Should the "depends on" be enough?
Jarkko
Re: [PATCH v2 07/12] i2c: designware: Move Baytrail sem config to the platform if-clause
Quoted 51 lines · Jarkko Nikula
Quoted 50 lines · Serge Semin
Currently Intel Baytrail I2C semaphore is a feature of the DW APB I2C platform driver. It's a bit confusing to see it's config in the menu at some separated place with no reference to the platform code. Lets move the config definition under the if-I2C_DESIGNWARE_PLATFORM clause. By doing so the config menu will display the feature right below the DW I2C platform driver item and will indent it to the right so signifying its belonging.
Signed-off-by Serge Semin <[email protected]>Cc Alexey Malahov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Paul Burton <[email protected]>Cc Ralf Baechle <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Mika Westerberg <[email protected]>Cc Wolfram Sang <[email protected]>Cc Rob Herring <[email protected]>Cc Frank Rowand <[email protected]>--- drivers/i2c/busses/Kconfig | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-)drivers/i2c/busses/Kconfig +12
-1@@ -530,8 +530,8 @@ config I2C_DESIGNWARE_CORE config I2C_DESIGNWARE_PLATFORM tristate "Synopsys DesignWare Platform" - select I2C_DESIGNWARE_CORE depends on (ACPI && COMMON_CLK) || !ACPI + select I2C_DESIGNWARE_CORE help If you say yes to this option, support will be included for the Synopsys DesignWare I2C adapter.@@ -539,6 +539,22 @@ config I2C_DESIGNWARE_PLATFORM This driver can also be built as a module. If so, the module will be called i2c-designware-platform. +if I2C_DESIGNWARE_PLATFORM + +config I2C_DESIGNWARE_BAYTRAIL + bool "Intel Baytrail I2C semaphore support" + depends on ACPI + depends on (I2C_DESIGNWARE_PLATFORM=m && IOSF_MBI) || \ + (I2C_DESIGNWARE_PLATFORM=y && IOSF_MBI=y) + help + This driver enables managed host access to the PMIC I2C bus on select + Intel BayTrail platforms using the X-Powers AXP288 PMIC. It allows + the host to request uninterrupted access to the PMIC's I2C bus from
Quoted 8 lines
drivers/i2c/busses/Kconfig config I2C_DESIGNWARE_PLATFORM · line 557
Quoted 5 lines
drivers/i2c/busses/Kconfig +5
-0+ the platform firmware controlling it. You should say Y if running on + a BayTrail system using the AXP288. + +endif # I2C_DESIGNWARE_PLATFORM +Is the added "if
I2C_DESIGNWARE_PLATFORM" needed here? Should the "depends on" be enough?
The idea was to add if-endif clause here for features possibly added sometime in future. But using normal "depends on I2C_DESIGNWARE_PLATFORM" shall make the config depicted as an indented sub-config as well. Would you like me to remove the if-clause and use the depends on operator instead?
-Sergey
Quoted 2 lines
Jarkko
Re: [PATCH v2 07/12] i2c: designware: Move Baytrail sem config to the platform if-clause
Quoted 61 lines · Serge Semin
Quoted 51 lines · Jarkko Nikula
Quoted 50 lines · Serge Semin
Currently Intel Baytrail I2C semaphore is a feature of the DW APB I2C platform driver. It's a bit confusing to see it's config in the menu at some separated place with no reference to the platform code. Lets move the config definition under the if-I2C_DESIGNWARE_PLATFORM clause. By doing so the config menu will display the feature right below the DW I2C platform driver item and will indent it to the right so signifying its belonging.
Signed-off-by Serge Semin <[email protected]>Cc Alexey Malahov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Paul Burton <[email protected]>Cc Ralf Baechle <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Mika Westerberg <[email protected]>Cc Wolfram Sang <[email protected]>Cc Rob Herring <[email protected]>Cc Frank Rowand <[email protected]>--- drivers/i2c/busses/Kconfig | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-)drivers/i2c/busses/Kconfig +12
-1@@ -530,8 +530,8 @@ config I2C_DESIGNWARE_CORE config I2C_DESIGNWARE_PLATFORM tristate "Synopsys DesignWare Platform" - select I2C_DESIGNWARE_CORE depends on (ACPI && COMMON_CLK) || !ACPI + select I2C_DESIGNWARE_CORE help If you say yes to this option, support will be included for the Synopsys DesignWare I2C adapter.@@ -539,6 +539,22 @@ config I2C_DESIGNWARE_PLATFORM This driver can also be built as a module. If so, the module will be called i2c-designware-platform. +if I2C_DESIGNWARE_PLATFORM + +config I2C_DESIGNWARE_BAYTRAIL + bool "Intel Baytrail I2C semaphore support" + depends on ACPI + depends on (I2C_DESIGNWARE_PLATFORM=m && IOSF_MBI) || \ + (I2C_DESIGNWARE_PLATFORM=y && IOSF_MBI=y) + help + This driver enables managed host access to the PMIC I2C bus on select + Intel BayTrail platforms using the X-Powers AXP288 PMIC. It allows + the host to request uninterrupted access to the PMIC's I2C bus fromQuoted 8 lines
drivers/i2c/busses/Kconfig config I2C_DESIGNWARE_PLATFORM · line 557
Quoted 5 lines
drivers/i2c/busses/Kconfig +5
-0+ the platform firmware controlling it. You should say Y if running on + a BayTrail system using the AXP288. + +endif # I2C_DESIGNWARE_PLATFORM +Is the added "if
I2C_DESIGNWARE_PLATFORM" needed here? Should the "depends on" be enough?
Quoted 5 lines
The idea was to add if-endif clause here for features possibly added sometime in future. But using normal "depends on
I2C_DESIGNWARE_PLATFORM" shall make the config depicted as an indented sub-config as well. Would you like me to remove the if-clause and use the depends on operator instead?
Yes, please remove it from this patch. Keeps this patch simpler and if some future feature needs it then that patch(set) is the right place to add it.
Jarkko
Re: [PATCH v2 07/12] i2c: designware: Move Baytrail sem config to the platform if-clause
Quoted 62 lines · Jarkko Nikula
Quoted 61 lines · Serge Semin
Quoted 59 lines · Jarkko Nikula
Quoted 45 lines · Serge Semin
Currently Intel Baytrail I2C semaphore is a feature of the DW APB I2C platform driver. It's a bit confusing to see it's config in the menu at some separated place with no reference to the platform code. Lets move the config definition under the if-I2C_DESIGNWARE_PLATFORM clause. By doing so the config menu will display the feature right below the DW I2C platform driver item and will indent it to the right so signifying its belonging.
Signed-off-by Serge Semin <[email protected]>Cc Alexey Malahov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Paul Burton <[email protected]>Cc Ralf Baechle <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Mika Westerberg <[email protected]>Cc Wolfram Sang <[email protected]>Cc Rob Herring <[email protected]>Cc Frank Rowand <[email protected]>--- drivers/i2c/busses/Kconfig | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-)drivers/i2c/busses/Kconfig +7
-1@@ -530,8 +530,8 @@ config I2C_DESIGNWARE_CORE config I2C_DESIGNWARE_PLATFORM tristate "Synopsys DesignWare Platform" - select I2C_DESIGNWARE_CORE depends on (ACPI && COMMON_CLK) || !ACPI + select I2C_DESIGNWARE_CORE help If you say yes to this option, support will be included for the Synopsys DesignWare I2C adapter.@@ -539,6 +539,22 @@ config I2C_DESIGNWARE_PLATFORM This driver can also be built as a module. If so, the module will be called i2c-designware-platform. +if I2C_DESIGNWARE_PLATFORM + +config I2C_DESIGNWARE_BAYTRAIL + bool "Intel Baytrail I2C semaphore support" + depends on ACPI + depends on (I2C_DESIGNWARE_PLATFORM=m && IOSF_MBI) || \drivers/i2c/busses/Kconfig config I2C_DESIGNWARE_PLATFORM · line 556
Quoted 10 lines
drivers/i2c/busses/Kconfig +10
-0+ (I2C_DESIGNWARE_PLATFORM=y && IOSF_MBI=y) + help + This driver enables managed host access to the PMIC I2C bus on select + Intel BayTrail platforms using the X-Powers AXP288 PMIC. It allows + the host to request uninterrupted access to the PMIC's I2C bus from + the platform firmware controlling it. You should say Y if running on + a BayTrail system using the AXP288. + +endif # I2C_DESIGNWARE_PLATFORM +Is the added "if
I2C_DESIGNWARE_PLATFORM" needed here? Should the "depends on" be enough?
Quoted 7 lines
Quoted 5 lines
The idea was to add if-endif clause here for features possibly added sometime in future. But using normal "depends on
I2C_DESIGNWARE_PLATFORM" shall make the config depicted as an indented sub-config as well. Would you like me to remove the if-clause and use the depends on operator instead?Yes, please remove it from this patch. Keeps this patch simpler and if some future feature needs it then that patch(set) is the right place to add it.
Agreed. I'll do this in v3.
-Sergey
Quoted 2 lines
Jarkko
PATCH v2 8/12 i2c: designware: Introduce platform drivers glue layer interface
In reply to Serge SeminSeeing the DW I2C platform driver is getting overcomplicated with a lot of vendor-specific configs let's introduce a glue-layer interface so new platforms which equipped with Synopsys Designware APB I2C IP-core would be able to handle their peculiarities in the dedicated objects.
The generic platform setups and cleanups can now be performed by means of two new functions exported from the Dw I2C platform driver:
int i2c_dw_plat_setup(struct dw_i2c_dev *dev);
int i2c_dw_plat_clear(struct dw_i2c_dev *dev);
They also install and remove the I2C controller respectively. In addition if device supports the PM interface a glue driver can use the generic platform PM callbacks collected into the PM dev ops structure:
const struct dev_pm_ops i2c_dw_plat_dev_pm_ops;
Before setting the platform DW I2C device up the glue probe code is supposed to create an instance of struct dw_i2c_dev and pre-initialize its struct device pointer together with optional platform-specific flags. Currently the ACCESS_NO_IRQ_SUSPEND and ACCESS_INTR_MASK flags are supported.
Note we moved the platform driver private data setup to the generic platform probe method. By doing so the driver data pointer will be free to be used by the glue-layer driver.
--- drivers/i2c/busses/i2c-designware-core.h | 4 + drivers/i2c/busses/i2c-designware-platdrv.c | 84 +++++++++++++-------- drivers/i2c/busses/i2c-designware-platdrv.h | 16 ++++ 3 files changed, 71 insertions(+), 33 deletions(-) create mode 100644 drivers/i2c/busses/i2c-designware-platdrv.h
drivers/i2c/busses/i2c-designware-core.h +4 -0
@@ -8,6 +8,8 @@* Copyright (C) 2007 MontaVista Software Inc. * Copyright (C) 2009 Provigent Ltd. */ +#ifndef __I2C_DESIGNWARE_CORE_H__ +#define __I2C_DESIGNWARE_CORE_H__#include <linux/i2c.h> #include <linux/regmap.h>
@@ -324,3 +326,5 @@ extern int i2c_dw_probe_lock_support(struct dw_i2c_dev *dev);#else static inline int i2c_dw_probe_lock_support (struct dw_i2c_dev *dev) {return 0 ; }#endif + +#endif /* __I2C_DESIGNWARE_CORE_H__ */
drivers/i2c/busses/i2c-designware-platdrv.c +51 -33
175 lines not on this page · raw message
drivers/i2c/busses/i2c-designware-platdrv.h new file +16 -0
@@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* Synopsys DesignWare I2C adapter driver. +*/ +#ifndef __I2C_DESIGNWARE_PLATDRV_H__ +#define __I2C_DESIGNWARE_PLATDRV_H__ + +#include <linux/pm.h> + +#include "i2c-designware-core.h" + +extern int i2c_dw_plat_setup (struct dw_i2c_dev *dev); +extern int i2c_dw_plat_clear (struct dw_i2c_dev *dev); +extern const struct dev_pm_ops i2c_dw_plat_dev_pm_ops; + +#endif /* __I2C_DESIGNWARE_PLATDRV_H__ */
Signature · 1 line
2.25.1
Re: [PATCH v2 08/12] i2c: designware: Introduce platform drivers glue layer interface
Hi
Quoted 5 lines · Serge Semin
Seeing the DW I2C platform driver is getting overcomplicated with a lot of vendor-specific configs let's introduce a glue-layer interface so new platforms which equipped with Synopsys Designware APB I2C IP-core would be able to handle their peculiarities in the dedicated objects.
Comment to this patch and patches 9/12 and 12/12:
Currently i2c-designware-platdrv.c is about 500 lines of code so I don't think it's too overcomplicated. But I feel we have already too many Kconfig options and source modules for i2c-designware and obviously would like to push back a little from adding more.
I don't think i2c-designware-platdrv.c becomes yet too complicated if Baikal related code is added there, perhaps under #ifdef CONFIG_OF like MSCC Ocelot code is currently.
Signature · 1 line
Jarkko
Re: [PATCH v2 08/12] i2c: designware: Introduce platform drivers glue layer interface
Quoted 10 lines · Jarkko Nikula
Hi
Quoted 5 lines · Serge Semin
Seeing the DW I2C platform driver is getting overcomplicated with a lot of vendor-specific configs let's introduce a glue-layer interface so new platforms which equipped with Synopsys Designware APB I2C IP-core would be able to handle their peculiarities in the dedicated objects.
Comment to this patch and patches 9/12 and 12/12:
Quoted 8 lines
Currently
i2c-designware-platdrv.cis about 500 lines of code so I don't think it's too overcomplicated. But I feel we have already too manyKconfigoptions and source modules for i2c-designware and obviously would like to push back a little from adding more.I don't think
i2c-designware-platdrv.cbecomes yet too complicated if Baikal related code is added there, perhaps under #ifdefCONFIG_OFlike MSCC Ocelot code is currently.
Well, it's up to you to decide, what solution is more suitable for you to maintain. My idea of detaching the MSCC and Baikal-T1 code to the dedicated source files was to eventually move the whole i2c-designware-* set of files into a dedicated directory drivers/i2c/buses/dw as it's done for some others Synopsys DesignWare controllers: drivers/pci/controller/dwc/, drivers/usb/dwc2, drivers/usb/dwc3, drivers/net/ethernet/synopsys/ . If you think, that it's too early for Dw I2C code to live in a dedicated directory, fine with me. I can merge the MSCC and Baikal-T1 code back into the i2c-designware-platdrv.c . So what's your final word in this matter?
-Sergey
Quoted 3 lines
Signature · 2 lines
-- Jarkko
Re: [PATCH v2 08/12] i2c: designware: Introduce platform drivers glue layer interface
Hi
Quoted 20 lines · Serge Semin
Quoted 10 lines · Jarkko Nikula
Hi
Quoted 5 lines · Serge Semin
Seeing the DW I2C platform driver is getting overcomplicated with a lot of vendor-specific configs let's introduce a glue-layer interface so new platforms which equipped with Synopsys Designware APB I2C IP-core would be able to handle their peculiarities in the dedicated objects.
Comment to this patch and patches 9/12 and 12/12:
Quoted 8 lines
Currently
i2c-designware-platdrv.cis about 500 lines of code so I don't think it's too overcomplicated. But I feel we have already too manyKconfigoptions and source modules for i2c-designware and obviously would like to push back a little from adding more.I don't think
i2c-designware-platdrv.cbecomes yet too complicated if Baikal related code is added there, perhaps under #ifdefCONFIG_OFlike MSCC Ocelot code is currently.
Quoted 10 lines
Well, it's up to you to decide, what solution is more suitable for you to maintain. My idea of detaching the MSCC and Baikal-T1 code to the dedicated source files was to eventually move the whole i2c-designware-* set of files into a dedicated directory
drivers/i2c/buses/dwas it's done for some others Synopsys DesignWare controllers:drivers/pci/controller/dwc/,drivers/usb/dwc2,drivers/usb/dwc3,drivers/net/ethernet/synopsys/. If you think, that it's too early for Dw I2C code to live in a dedicated directory, fine with me. I can merge the MSCC and Baikal-T1 code back into thei2c-designware-platdrv.c. So what's your final word in this matter?
I think sub directory decision under each subsystem is more subsystem rather than vendor/driver specific. Good point anyway.
For this patchset I'd like more if changes are done to i2c-designware-platdrv.c since it's not too complicated yet :-)
If it starts to look too messy in the future then it's time split I think.
Jarkko
Andy Shevchenko
reviewerRe: [PATCH v2 08/12] i2c: designware: Introduce platform drivers glue layer interface
Quoted 4 lines · Jarkko Nikula
On 5/21/20 5:37 AM, Serge Semin wrote:
For this patchset I'd like more if changes are done to
i2c-designware-platdrv.csince it's not too complicated yet :-)
And after moving ACPI stuff to common code, the one has even been shrunk significantly.
Quoted 1 line
If it starts to look too messy in the future then it's time split I think.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 08/12] i2c: designware: Introduce platform drivers glue layer interface
In reply to Jarkko NikulaQuoted 33 lines · Jarkko Nikula
Hi
Quoted 20 lines · Serge Semin
Quoted 10 lines · Jarkko Nikula
Hi
Quoted 5 lines · Serge Semin
Seeing the DW I2C platform driver is getting overcomplicated with a lot of vendor-specific configs let's introduce a glue-layer interface so new platforms which equipped with Synopsys Designware APB I2C IP-core would be able to handle their peculiarities in the dedicated objects.
Comment to this patch and patches 9/12 and 12/12:
Quoted 8 lines
Currently
i2c-designware-platdrv.cis about 500 lines of code so I don't think it's too overcomplicated. But I feel we have already too manyKconfigoptions and source modules for i2c-designware and obviously would like to push back a little from adding more.I don't think
i2c-designware-platdrv.cbecomes yet too complicated if Baikal related code is added there, perhaps under #ifdefCONFIG_OFlike MSCC Ocelot code is currently.Quoted 10 lines
Well, it's up to you to decide, what solution is more suitable for you to maintain. My idea of detaching the MSCC and Baikal-T1 code to the dedicated source files was to eventually move the whole i2c-designware-* set of files into a dedicated directory
drivers/i2c/buses/dwas it's done for some others Synopsys DesignWare controllers:drivers/pci/controller/dwc/,drivers/usb/dwc2,drivers/usb/dwc3,drivers/net/ethernet/synopsys/. If you think, that it's too early for Dw I2C code to live in a dedicated directory, fine with me. I can merge the MSCC and Baikal-T1 code back into thei2c-designware-platdrv.c. So what's your final word in this matter?
Quoted 7 lines
I think sub directory decision under each subsystem is more subsystem rather than vendor/driver specific. Good point anyway.
For this patchset I'd like more if changes are done to
i2c-designware-platdrv.csince it's not too complicated yet :-)If it starts to look too messy in the future then it's time split I think.
Ok. I'll merge the MSCC back and add Baikal-T1 System I2C support into the DW I2C platform driver.
-Sergey
Quoted 2 lines
Jarkko
PATCH v2 9/12 i2c: designware: Unpin Microsemi Ocelot I2C into a glue driver
In reply to Serge SeminSince glue-layer drivers design is now supported by the DW APB I2C platform code lets unpin MSCC Ocelot I2C driver at least. It won't be that hard because the only difference between this controller and vanilly core is in what the former sets the sda hold time in a dedicated configure registers space.
Note I enabled the new driver by default for the MSCC Ocelot platform so one would be automatically built and we wouldn't need to alter the in- and out-of-source tree platform configs.
--- drivers/i2c/busses/Kconfig | 12 +++ drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-designware-core.h | 3 - drivers/i2c/busses/i2c-designware-mscc.c | 83 +++++++++++++++++++++ drivers/i2c/busses/i2c-designware-platdrv.c | 40 ---------- 5 files changed, 96 insertions(+), 43 deletions(-) create mode 100644 drivers/i2c/busses/i2c-designware-mscc.c
drivers/i2c/busses/Kconfig +12 -0
@@ -566,6 +566,18 @@ config I2C_DESIGNWARE_SLAVE This is not a standalone module, this module compiles together with i2c-designware-core. +config I2C_DESIGNWARE_MSCC + tristate "Microsemi Ocelot I2C" + depends on MSCC_OCELOT + select I2C_DESIGNWARE_PLATFORM + default y + help + This driver supports the Microsemi Ocelot SoC version of the Synopsys + Designware I2C IP-core. + + The driver can also be built as a module. If so, the module will be + called i2c-designware-mscc. + config I2C_DESIGNWARE_PCI tristate "Synopsys DesignWare PCI" depends on PCI
drivers/i2c/busses/Makefile +1 -0
@@ -55,6 +55,7 @@ i2c-designware-core-$(CONFIG_I2C_DESIGNWARE_SLAVE) += i2c-designware-slave.o obj-$(CONFIG_I2C_DESIGNWARE_PLATFORM) += i2c-designware-platform.o i2c-designware-platform-y := i2c-designware-platdrv.o i2c-designware-platform-$(CONFIG_I2C_DESIGNWARE_BAYTRAIL) += i2c-designware-baytrail.o +obj-$(CONFIG_I2C_DESIGNWARE_MSCC) += i2c-designware-mscc.o obj-$(CONFIG_I2C_DESIGNWARE_PCI) += i2c-designware-pci.o i2c-designware-pci-y := i2c-designware-pcidrv.o obj-$(CONFIG_I2C_DIGICOLOR) += i2c-digicolor.o
drivers/i2c/busses/i2c-designware-core.h +0 -3
@@ -177,7 +177,6 @@* @dev: driver model device node * @map: IO registers map * @base: IO registers pointer -* @ext: Extended IO registers pointer * @cmd_complete: tx completion indicator * @clk: input reference clock * @pclk: clock required to access the registers
@@ -229,7 +228,6 @@ struct dw_i2c_dev {struct device *dev;struct regmap *map;void __iomem *base; -void __iomem *ext;struct completion cmd_complete;struct clk *clk;struct clk *pclk;
@@ -284,7 +282,6 @@ struct dw_i2c_dev {#define ACCESS_NO_IRQ_SUSPEND 0x00000008#define MODEL_CHERRYTRAIL 0x00000100 -#define MODEL_MSCC_OCELOT 0x00000200#define MODEL_MASK 0x00000f00int i2c_dw_init_regmap (struct dw_i2c_dev *dev);
drivers/i2c/busses/i2c-designware-mscc.c new file +83 -0
83 lines not on this page · raw message
drivers/i2c/busses/i2c-designware-platdrv.c +0 -40
@@ -143,48 +143,11 @@ static inline int dw_i2c_acpi_configure(struct dw_i2c_dev *dev)#endif #ifdef CONFIG_OF -#define MSCC_ICPU_CFG_TWI_DELAY 0x0 -#define MSCC_ICPU_CFG_TWI_DELAY_ENABLE BIT(0) -#define MSCC_ICPU_CFG_TWI_SPIKE_FILTER 0x4 - -static int mscc_twi_set_sda_hold_time (struct dw_i2c_dev *dev) -{ -writel ((dev->sda_hold_time <<1 ) |MSCC_ICPU_CFG_TWI_DELAY_ENABLE , - dev->ext +MSCC_ICPU_CFG_TWI_DELAY ); - -return 0 ; -} - -static int dw_i2c_of_configure (struct dw_i2c_dev *dev) -{ -struct platform_device *pdev =to_platform_device (dev->dev); -struct resource *mem; - -switch (dev->flags &MODEL_MASK ) { -case MODEL_MSCC_OCELOT : - mem =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); - dev->ext =devm_ioremap_resource (&pdev->dev, mem); -if (!IS_ERR (dev->ext)) - dev->set_sda_hold_time = mscc_twi_set_sda_hold_time; -break ; -default : -break ; - } - -return 0 ; -} -static const struct of_device_id dw_i2c_of_match[] = { { .compatible ="snps,designware-i2c" , }, - { .compatible ="mscc,ocelot-i2c" , .data = (void *)MODEL_MSCC_OCELOT }, {}, };MODULE_DEVICE_TABLE (of, dw_i2c_of_match); -#else -static inline int dw_i2c_of_configure (struct dw_i2c_dev *dev) -{ -return -ENODEV ; -}#endif static void i2c_dw_configure_master (struct dw_i2c_dev *dev)
@@ -288,9 +251,6 @@ int i2c_dw_plat_setup(struct dw_i2c_dev *dev)else t->bus_freq_hz =I2C_MAX_FAST_MODE_FREQ ; -if (pdev->dev.of_node) -dw_i2c_of_configure (dev); -if (has_acpi_companion (&pdev->dev))dw_i2c_acpi_configure (dev);
Signature · 1 line
2.25.1
PATCH v2 10/12 i2c: designware: Discard Cherry Trail model flag
In reply to Serge SeminA PM workaround activated by the flag MODEL_CHERRYTRAIL has been removed since commit 9cbeeca05049 ("i2c: designware: Remove Cherry Trail PMIC I2C bus pm_disabled workaround"), but the flag most likely by mistake has been left in the Dw I2C drivers. Lets remove it.
By doing so we get rid from the last DW APB I2C IP-core model flag, so we can remove the MODEL_MASK macro too.
--- drivers/i2c/busses/i2c-designware-core.h | 3 --- drivers/i2c/busses/i2c-designware-pcidrv.c | 1 - drivers/i2c/busses/i2c-designware-platdrv.c | 2 +- 3 files changed, 1 insertion(+), 5 deletions(-)
drivers/i2c/busses/i2c-designware-core.h +0 -3
@@ -281,9 +281,6 @@ struct dw_i2c_dev {#define ACCESS_INTR_MASK 0x00000004#define ACCESS_NO_IRQ_SUSPEND 0x00000008 -#define MODEL_CHERRYTRAIL 0x00000100 -#define MODEL_MASK 0x00000f00 -int i2c_dw_init_regmap (struct dw_i2c_dev *dev);u32 i2c_dw_scl_hcnt (u32 ic_clk,u32 tSYMBOL,u32 tf,int cond,int offset);u32 i2c_dw_scl_lcnt (u32 ic_clk,u32 tLOW,u32 tf,int offset);
drivers/i2c/busses/i2c-designware-pcidrv.c +0 -1
@@ -166,7 +166,6 @@ static struct dw_pci_controller dw_pci_controllers[] = { .tx_fifo_depth = 32, .rx_fifo_depth = 32, .functionality = I2C_FUNC_10BIT_ADDR, - .flags = MODEL_CHERRYTRAIL, .scl_sda_cfg = &byt_config, }, [elkhartlake] = {
drivers/i2c/busses/i2c-designware-platdrv.c +1 -1
@@ -124,7 +124,7 @@ static const struct acpi_device_id dw_i2c_acpi_match[] = { { "INT3432", 0 }, { "INT3433", 0 }, { "80860F41", ACCESS_NO_IRQ_SUSPEND }, - { "808622C1", ACCESS_NO_IRQ_SUSPEND | MODEL_CHERRYTRAIL }, + { "808622C1", ACCESS_NO_IRQ_SUSPEND }, { "AMD0010", ACCESS_INTR_MASK }, { "AMDI0010", ACCESS_INTR_MASK }, { "AMDI0510", 0 },
Signature · 1 line
2.25.1
Re: [PATCH v2 10/12] i2c: designware: Discard Cherry Trail model flag
Quoted 17 lines · Serge Semin
A PM workaround activated by the flag
MODEL_CHERRYTRAILhas been removed since commit9cbeeca05049("i2c: designware: Remove Cherry Trail PMIC I2C buspm_disabledworkaround"), but the flag most likely by mistake has been left in the Dw I2C drivers. Lets remove it.By doing so we get rid from the last DW APB I2C IP-core model flag, so we can remove the
MODEL_MASKmacro too.Signed-off-by Serge Semin <[email protected]>Cc Alexey Malahov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Paul Burton <[email protected]>Cc Ralf Baechle <[email protected]>Cc Rob Herring <[email protected]>Cc Frank Rowand <[email protected]>
Quoted 6 lines
--- drivers/i2c/busses/i2c-designware-core.h | 3 --- drivers/i2c/busses/i2c-designware-pcidrv.c | 1 - drivers/i2c/busses/i2c-designware-platdrv.c | 2 +- 3 files changed, 1 insertion(+), 5 deletions(-)
PATCH v2 11/12 i2c: designware: Use provided regmap instead of reg resource
In reply to Serge SeminThis is a preparation patch before adding a glue platform driver for the Baikal-T1 I2C controller. Since the i2c controller registers are indirectly accessed by means of the Baikal-T1 System Controller registers we need to have a way to disable the default registers mapping setup procedure and make the DW I2C core/platform code to use a provided by a glue driver regmap.
--- drivers/i2c/busses/i2c-designware-common.c | 7 +++++++ drivers/i2c/busses/i2c-designware-platdrv.c | 14 ++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-designware-common.c +7 -0
@@ -133,6 +133,13 @@ int i2c_dw_init_regmap(struct dw_i2c_dev *dev)u32 reg;int ret; +/* +* Skip detecting the registers map configuration if the regmap has +* already been provided by a higher code. +*/ +if (dev->map) +return 0 ; + ret =i2c_dw_acquire_lock (dev);if (ret)return ret;
drivers/i2c/busses/i2c-designware-platdrv.c +10 -4
@@ -212,10 +212,16 @@ int i2c_dw_plat_setup(struct dw_i2c_dev *dev)if (dev->irq <0 )return dev->irq; - mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - dev->base =devm_ioremap_resource (&pdev->dev, mem); -if (IS_ERR (dev->base)) -return PTR_ERR (dev->base); +/* +* Don't try to get the controller registers MMIO space if regmap has +* been provided by a higher level code. +*/ +if (!dev->map) { + mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); + dev->base =devm_ioremap_resource (&pdev->dev, mem); +if (IS_ERR (dev->base)) +return PTR_ERR (dev->base); + } dev->rst =devm_reset_control_get_optional_exclusive (&pdev->dev,NULL );if (IS_ERR (dev->rst))
Signature · 1 line
2.25.1
PATCH v2 12/12 i2c: designware: Add Baikal-T1 System I2C glue driver
In reply to Serge SeminBaikal-T1 System Controller is equipped with a dedicated I2C Controller which functionality is based on the DW APB I2C IP-core, the only difference in a way it' registers are accessed. There are three access register provided in the System Controller registers map, which indirectly address the normal DW APB I2C registers space.
So in order to have the Baikal-T1 System I2C Controller supported by the common DW APB I2C driver we created a dedicated glue driver, which retrieves the syscon regmap from the parental dt node and creates a new regmap based on it. The new regmap is then passed to the generic DW I2C platform driver initializer.
--- drivers/i2c/busses/Kconfig | 11 ++ drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-designware-bt1.c | 129 ++++++++++++++++++++++++ 3 files changed, 141 insertions(+) create mode 100644 drivers/i2c/busses/i2c-designware-bt1.c
drivers/i2c/busses/Kconfig +11 -0
@@ -578,6 +578,17 @@ config I2C_DESIGNWARE_MSCC The driver can also be built as a module. If so, the module will be called i2c-designware-mscc. +config I2C_DESIGNWARE_BT1 + tristate "Baikal-T1 System I2C" + depends on (MIPS_BAIKAL_T1 && OF) || COMPILE_TEST + select I2C_DESIGNWARE_PLATFORM + help + This driver supports the Baikal-T1 SoC version of the Synopsys + Designware I2C IP-core. + + The driver can also be built as a module. If so, the module will be + called i2c-designware-bt1. + config I2C_DESIGNWARE_PCI tristate "Synopsys DesignWare PCI" depends on PCI
drivers/i2c/busses/Makefile +1 -0
@@ -56,6 +56,7 @@ obj-$(CONFIG_I2C_DESIGNWARE_PLATFORM) += i2c-designware-platform.o i2c-designware-platform-y := i2c-designware-platdrv.o i2c-designware-platform-$(CONFIG_I2C_DESIGNWARE_BAYTRAIL) += i2c-designware-baytrail.o obj-$(CONFIG_I2C_DESIGNWARE_MSCC) += i2c-designware-mscc.o +obj-$(CONFIG_I2C_DESIGNWARE_BT1) += i2c-designware-bt1.o obj-$(CONFIG_I2C_DESIGNWARE_PCI) += i2c-designware-pci.o i2c-designware-pci-y := i2c-designware-pcidrv.o obj-$(CONFIG_I2C_DIGICOLOR) += i2c-digicolor.o
drivers/i2c/busses/i2c-designware-bt1.c new file +129 -0
129 lines not on this page · raw message
Signature · 1 line
2.25.1