i2c: microchip: pci1xxxx: Add driver for I2C host controller in multifunction endpoint of pci1xxxx switch
Subsystems (2)
RFC PATCH 1/1 i2c: microchip: pci1xxxx: Add driver for I2C host controller in multifunction endpoint of pci1xxxx switch
Microchip PCI1XXXX is an unmanaged PCIe3.1a Switch for Consumer, Industrial and Automotive applications. This switch has multiple downstream ports. In one of the Switch's Downstream port, there is a multifunction endpoint for peripherals which includes an I2C host controller. The I2C function in the endpoint operates at 100KHz, 400KHz and 1 MHz and has buffer depth of 128 bytes.
This patch provides the I2C controller driver for the I2C endpoint of the switch.
--- MAINTAINERS | 8 + drivers/i2c/busses/Kconfig | 10 + drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-mchp-pci1xxxx.c | 1123 ++++++++++++++++++++++++ 4 files changed, 1142 insertions(+) create mode 100644 drivers/i2c/busses/i2c-mchp-pci1xxxx.c
MAINTAINERS +8 -0
@@ -13110,6 +13110,14 @@ S: Supported F: Documentation/devicetree/bindings/mtd/atmel-nand.txt F: drivers/mtd/nand/raw/atmel/* +MICROCHIP PCI1XXXX I2C DRIVER +M: Tharun Kumar P <[email protected]> +M: Kumaravel Thiagarajan <[email protected]> +M: Microchip Linux Driver Support <[email protected]> +L: [email protected] +S: Maintained +F: drivers/i2c/busses/i2c-mchp-pci1xxxx.c + MICROCHIP PWM DRIVER M: Claudiu Beznea <[email protected]> L: [email protected] (moderated for non-subscribers)
drivers/i2c/busses/Kconfig +10 -0
@@ -1290,6 +1290,16 @@ config I2C_VIPERBOARD River Tech's viperboard.h for detailed meaning of the module parameters. +config I2C_PCI1XXXX + tristate "PCI1XXXX I2C Host Adapter support" + depends on PCI + help + Say yes here to enable the I2C Host adapter support for the PCI1xxxx card + This is a PCI to I2C adapter + + This driver can be built as a module. If so, the module will be + called as i2c-mchp-pci1xxxx + comment "Other I2C/SMBus bus drivers" config I2C_ACORN
drivers/i2c/busses/Makefile +1 -0
@@ -135,6 +135,7 @@ obj-$(CONFIG_I2C_ROBOTFUZZ_OSIF) += i2c-robotfuzz-osif.o obj-$(CONFIG_I2C_TAOS_EVM) += i2c-taos-evm.o obj-$(CONFIG_I2C_TINY_USB) += i2c-tiny-usb.o obj-$(CONFIG_I2C_VIPERBOARD) += i2c-viperboard.o +obj-$(CONFIG_I2C_PCI1XXXX) += i2c-mchp-pci1xxxx.o # Other I2C/SMBus bus drivers obj-$(CONFIG_I2C_ACORN) += i2c-acorn.o
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +1123 -0
1,123 lines not on this page · raw message
Signature · 1 line
2.25.1
Quoted 8 lines · Tharun Kumar P
Microchip PCI1XXXX is an unmanaged PCIe3.1a Switch for Consumer, Industrial and Automotive applications. This switch has multiple downstream ports. In one of the Switch's Downstream port, there is a multifunction endpoint for peripherals which includes an I2C host controller. The I2C function in the endpoint operates at 100KHz, 400KHz and 1 MHz and has buffer depth of 128 bytes.
This patch provides the I2C controller driver for the I2C endpoint of the switch.
(...)
Quoted 8 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +8
-0+static int pci1xxxx_i2c_suspend (struct device *dev) +{ +struct pci1xxxx_i2c *i2c =dev_get_drvdata (dev); +struct pci_dev *pdev =to_pci_dev (dev); +u32 regval; + +i2c_mark_adapter_suspended (&i2c->adap); +
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 975
Quoted 10 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +10
-0+while ((i2c->i2c_xfer_in_progress)) +msleep (20 ); + +pci1xxxx_i2c_config_high_level_intr (i2c, +SMBALERT_WAKE_INTR_MASK , + true); + +/*Enable the PERST_DIS bit to mask the PERST from +*resetting the core regs +*/
Use Linux coding style comments. Everywhere...
(...)
Quoted 27 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +27
-0+ +static int pci1xxxx_i2c_probe_pci (struct pci_dev *pdev, +const struct pci_device_id *ent) +{ +struct pci1xxxx_i2c *i2c; +int ret; + + i2c =devm_kzalloc (&pdev->dev,sizeof (*i2c),GFP_KERNEL ); +if (!i2c) +return -ENOMEM ; + +pci_set_drvdata (pdev, i2c); + + i2c->i2c_xfer_in_progress = false; + + ret =pcim_enable_device (pdev); +if (ret) +return ret; + +pci_set_master (pdev); + +/* we are getting the base address of the SMB core. SMB core uses +* BAR0 and 32K is the size here pci_resource_len returns 32K by +* reading BAR0 +*/ + + ret =pcim_iomap_regions (pdev,BIT (0 ),pci_name (pdev));
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 1055
Quoted 10 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +10
-0+if (ret <0 ) +return -ENOMEM ; + + i2c->i2c_base =pcim_iomap_table (pdev)[0 ]; + +init_completion (&i2c->i2c_xfer_done); + +pci1xxxx_i2c_init (i2c); + +dev_info (&pdev->dev,"i2c clock freq: %d\n" , i2c->freq);
That's not a helpful print. Don't pollute dmesg.
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 1061
Quoted 6 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +6
-0+ + ret =pci_alloc_irq_vectors (pdev,1 ,1 ,PCI_IRQ_ALL_TYPES ); +if (ret <0 ) +return ret; + +/*Register the isr. we are not using any isr flags here.*/
Use Linux coding style comments. Everywhere...
Quoted 9 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +9
-0+ ret =devm_request_irq (&pdev->dev,pci_irq_vector (pdev,0 ), + pci1xxxx_i2c_isr,PCI1XXXX_IRQ_FLAGS , +pci_name (pdev), i2c); +if (ret) + goto err_free_region; + + i2c->adap = pci1xxxx_i2c_ops; + i2c->adap.class =I2C_CLASS_SPD ; + i2c->adap.dev.parent = &pdev->dev;
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 1080
Quoted 10 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +10
-0+ +snprintf (i2c->adap.name,sizeof (i2c->adap.name), +"MCHP PCI1xxxx i2c adapter at %s" ,pci_name (pdev)); + +i2c_set_adapdata (&i2c->adap, i2c); + + ret =i2c_add_adapter (&i2c->adap); +if (ret) { +dev_err (&pdev->dev,"i2c add adapter failed = %d\n" , ret); +pci1xxxx_i2c_shutdown (i2c);
Why do you call here pci1xxxx_i2c_shutdown() but not in previous error path?
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 1093
Quoted 13 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +13
-0+ goto err_free_region; + } + +return 0 ; + +err_free_region: +pci_free_irq_vectors (pdev); +return ret; +} + +static void pci1xxxx_i2c_remove_pci (struct pci_dev *pdev) +{ +struct pci1xxxx_i2c *i2c =pci_get_drvdata (pdev);
No need for pci_free_irq_vectors()?
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 1098
Quoted 5 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +5
-0+ +i2c_del_adapter (&i2c->adap); +pci1xxxx_i2c_shutdown (i2c); +} +
Best regards,
Krzysztof
Quoted 25 lines · Krzysztof Kozlowski
Quoted 8 lines · Tharun Kumar P
Microchip PCI1XXXX is an unmanaged PCIe3.1a Switch for Consumer, Industrial and Automotive applications. This switch has multiple downstream ports. In one of the Switch's Downstream port, there is a multifunction endpoint for peripherals which includes an I2C host controller. The I2C function in the endpoint operates at 100KHz, 400KHz and 1 MHz and has buffer depth of 128 bytes.
This patch provides the I2C controller driver for the I2C endpoint of the switch.(...)
Quoted 12 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +12
-0+static int pci1xxxx_i2c_suspend (struct device *dev) +{ + struct pci1xxxx_i2c *i2c = dev_get_drvdata(dev); + struct pci_dev *pdev = to_pci_dev(dev); + u32 regval; + + i2c_mark_adapter_suspended(&i2c->adap); + + while ((i2c->i2c_xfer_in_progress)) + msleep(20); + + pci1xxxx_i2c_config_high_level_intr(i2c,
Quoted 8 lines
Quoted 6 lines
+
SMBALERT_WAKE_INTR_MASK, + true);
+
+ /*Enable thePERST_DISbit to mask the PERST from + *resetting the core regs
+ */Use Linux coding style comments. Everywhere...
Okay. I will fix Linux coding style for comments throughout the file in upcoming patch.
Quoted 33 lines
(...)
Quoted 31 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +31
-0+ +static int pci1xxxx_i2c_probe_pci (struct pci_dev *pdev, + const struct pci_device_id *ent) +{ + struct pci1xxxx_i2c *i2c; + int ret; + + i2c = devm_kzalloc(&pdev->dev, sizeof(*i2c), GFP_KERNEL); + if (!i2c) + return -ENOMEM; + + pci_set_drvdata(pdev, i2c); + + i2c->i2c_xfer_in_progress = false; + + ret = pcim_enable_device(pdev); + if (ret) + return ret; + + pci_set_master(pdev); + + /* we are getting the base address of the SMB core. SMB core uses + * BAR0 and 32K is the size here pci_resource_len returns 32K by + * reading BAR0 + */ + + ret = pcim_iomap_regions(pdev, BIT(0), pci_name(pdev)); + if (ret < 0) + return -ENOMEM; + + i2c->i2c_base = pcim_iomap_table(pdev)[0];
Quoted 8 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 1055
Quoted 6 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +6
-0+ + init_completion(&i2c->i2c_xfer_done); + + pci1xxxx_i2c_init(i2c); + + dev_info(&pdev->dev, "i2c clock freq: %d\n", i2c->freq);That's not a helpful print. Don't pollute dmesg.
I will remove this print
Quoted 8 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 1061
Quoted 6 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +6
-0+ + ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES); + if (ret < 0) + return ret; + + /*Register the isr. we are not using any isr flags here.*/Use Linux coding style comments. Everywhere...
Okay
Quoted 13 lines
Quoted 13 lines
+ ret = devm_request_irq(&pdev->dev,
pci_irq_vector(pdev, 0), +pci1xxxx_i2c_isr,PCI1XXXX_IRQ_FLAGS, +pci_name(pdev), i2c);
+ if (ret)
+ gotoerr_free_region;drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +8
-0+ + i2c->adap = pci1xxxx_i2c_ops; + i2c->adap.class = I2C_CLASS_SPD; + i2c->adap.dev.parent = &pdev->dev; + + snprintf(i2c->adap.name, sizeof(i2c->adap.name), + "MCHP PCI1xxxx i2c adapter at %s", pci_name(pdev)); +
Quoted 8 lines
Quoted 6 lines
+
i2c_set_adapdata(&i2c->adap, i2c);
+
+ ret =i2c_add_adapter(&i2c->adap);
+ if (ret) {
+dev_err(&pdev->dev, "i2c add adapter failed = %d\n", ret); +pci1xxxx_i2c_shutdown(i2c);Why do you call here
pci1xxxx_i2c_shutdown()but not in previous error path?
pci1xxxx_i2c_shutdown API will reset the registers that are set as part of pci1xxxx_i2c_init API. I will update this API and also include this API in failure case of pci_alloc_irq_vectors as well as devm_request_irq
Quoted 7 lines
Quoted 7 lines
+ goto
err_free_region;
+ }drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +5
-0+ + return 0; + +err_free_region: + pci_free_irq_vectors(pdev);
Quoted 9 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 1093
Quoted 6 lines
+ return ret;
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +5
-0+} + +static void pci1xxxx_i2c_remove_pci (struct pci_dev *pdev) +{ + struct pci1xxxx_i2c *i2c = pci_get_drvdata(pdev);No need for
pci_free_irq_vectors()?
I will add this API in pci1xxxx_i2c_remove_pci
Quoted 5 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 1098
Quoted 5 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +5
-0+ + i2c_del_adapter(&i2c->adap); + pci1xxxx_i2c_shutdown(i2c); +} +
Thank you,
Tharun Kumar P
Quoted 6 lines · Krzysztof Kozlowski
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 1093
Quoted 3 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +3
-0+static void pci1xxxx_i2c_remove_pci (struct pci_dev *pdev) +{ + struct pci1xxxx_i2c *i2c = pci_get_drvdata(pdev);No need for
pci_free_irq_vectors()?
pci_free_irq_vectors API is not needed since pcim_enable_device API is used in the code. I will remove 'pci_free_irq_vectors' in all the places in upcoming version of the patch.
Thanks,
Tharun Kumar P
Quoted 1 line
Le 23/08/2022 à 16:56, Tharun Kumar P a écrit :
Quoted 77 lines
Microchip PCI1XXXX is an unmanaged PCIe3.1a Switch for Consumer, Industrial and Automotive applications. This switch has multiple downstream ports. In one of the Switch's Downstream port, there is a multifunction endpoint for peripherals which includes an I2C host controller. The I2C function in the endpoint operates at 100KHz, 400KHz and 1 MHz and has buffer depth of 128 bytes.
This patch provides the I2C controller driver for the I2C endpoint of the switch.Signed-off-by Tharun Kumar P <[email protected]>--- MAINTAINERS | 8 + drivers/i2c/busses/Kconfig | 10 + drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-mchp-pci1xxxx.c | 1123 ++++++++++++++++++++++++ 4 files changed, 1142 insertions(+)create mode 100644
drivers/i2c/busses/i2c-mchp-pci1xxxx.cdrivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +58
-0+static int pci1xxxx_i2c_probe_pci (struct pci_dev *pdev, +const struct pci_device_id *ent) +{ +struct pci1xxxx_i2c *i2c; +int ret; + + i2c =devm_kzalloc (&pdev->dev,sizeof (*i2c),GFP_KERNEL ); +if (!i2c) +return -ENOMEM ; + +pci_set_drvdata (pdev, i2c); + + i2c->i2c_xfer_in_progress = false; + + ret =pcim_enable_device (pdev); +if (ret) +return ret; + +pci_set_master (pdev); + +/* we are getting the base address of the SMB core. SMB core uses +* BAR0 and 32K is the size here pci_resource_len returns 32K by +* reading BAR0 +*/ + + ret =pcim_iomap_regions (pdev,BIT (0 ),pci_name (pdev)); +if (ret <0 ) +return -ENOMEM ; + + i2c->i2c_base =pcim_iomap_table (pdev)[0 ]; + +init_completion (&i2c->i2c_xfer_done); + +pci1xxxx_i2c_init (i2c); + +dev_info (&pdev->dev,"i2c clock freq: %d\n" , i2c->freq); + + ret =pci_alloc_irq_vectors (pdev,1 ,1 ,PCI_IRQ_ALL_TYPES ); +if (ret <0 ) +return ret; + +/*Register the isr. we are not using any isr flags here.*/ + ret =devm_request_irq (&pdev->dev,pci_irq_vector (pdev,0 ), + pci1xxxx_i2c_isr,PCI1XXXX_IRQ_FLAGS , +pci_name (pdev), i2c); +if (ret) + goto err_free_region; + + i2c->adap = pci1xxxx_i2c_ops; + i2c->adap.class =I2C_CLASS_SPD ; + i2c->adap.dev.parent = &pdev->dev; + +snprintf (i2c->adap.name,sizeof (i2c->adap.name), +"MCHP PCI1xxxx i2c adapter at %s" ,pci_name (pdev)); + +i2c_set_adapdata (&i2c->adap, i2c); + + ret =i2c_add_adapter (&i2c->adap);
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 1087
Quoted 10 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +10
-0+if (ret) { +dev_err (&pdev->dev,"i2c add adapter failed = %d\n" , ret); +pci1xxxx_i2c_shutdown (i2c); + goto err_free_region; + } + +return 0 ; + +err_free_region: +pci_free_irq_vectors (pdev);
Should this also be part of the .remove function?
CJ
Quoted 11 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +11
-0+return ret; +} + +static void pci1xxxx_i2c_remove_pci (struct pci_dev *pdev) +{ +struct pci1xxxx_i2c *i2c =pci_get_drvdata (pdev); + +i2c_del_adapter (&i2c->adap); +pci1xxxx_i2c_shutdown (i2c); +} +
Quoted 82 lines · Christophe JAILLET
Quoted 81 lines · Tharun Kumar P
Microchip PCI1XXXX is an unmanaged PCIe3.1a Switch for Consumer, Industrial and Automotive applications. This switch has multiple downstream ports. In one of the Switch's Downstream port, there is a multifunction endpoint for peripherals which includes an I2C host controller. The I2C function in the endpoint operates at 100KHz, 400KHz and 1 MHz and has buffer depth of 128 bytes.
This patch provides the I2C controller driver for the I2C endpoint of the switch.Signed-off-by Tharun Kumar P <[email protected]>---
MAINTAINERS | 8 + drivers/i2c/busses/Kconfig | 10 + drivers/i2c/busses/Makefile | 1 +drivers/i2c/busses/i2c-mchp-pci1xxxx.c| 1123 ++++++++++++++++++++++++4 files changed, 1142 insertions(+)create mode 100644
drivers/i2c/busses/i2c-mchp-pci1xxxx.cdrivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +62
-0+static int pci1xxxx_i2c_probe_pci (struct pci_dev *pdev, + const struct pci_device_id *ent) +{ + struct pci1xxxx_i2c *i2c; + int ret; + + i2c = devm_kzalloc(&pdev->dev, sizeof(*i2c), GFP_KERNEL); + if (!i2c) + return -ENOMEM; + + pci_set_drvdata(pdev, i2c); + + i2c->i2c_xfer_in_progress = false; + + ret = pcim_enable_device(pdev); + if (ret) + return ret; + + pci_set_master(pdev); + + /* we are getting the base address of the SMB core. SMB core uses + * BAR0 and 32K is the size here pci_resource_len returns 32K by + * reading BAR0 + */ + + ret = pcim_iomap_regions(pdev, BIT(0), pci_name(pdev)); + if (ret < 0) + return -ENOMEM; + + i2c->i2c_base = pcim_iomap_table(pdev)[0]; + + init_completion(&i2c->i2c_xfer_done); + + pci1xxxx_i2c_init(i2c); + + dev_info(&pdev->dev, "i2c clock freq: %d\n", i2c->freq); + + ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES); + if (ret < 0) + return ret; + + /*Register the isr. we are not using any isr flags here.*/ + ret = devm_request_irq(&pdev->dev, pci_irq_vector(pdev, 0), + pci1xxxx_i2c_isr, PCI1XXXX_IRQ_FLAGS, + pci_name(pdev), i2c); + if (ret) + goto err_free_region; + + i2c->adap = pci1xxxx_i2c_ops; + i2c->adap.class = I2C_CLASS_SPD; + i2c->adap.dev.parent = &pdev->dev; + + snprintf(i2c->adap.name, sizeof(i2c->adap.name), + "MCHP PCI1xxxx i2c adapter at %s", pci_name(pdev)); + + i2c_set_adapdata(&i2c->adap, i2c); + + ret = i2c_add_adapter(&i2c->adap); + if (ret) { + dev_err(&pdev->dev, "i2c add adapter failed = %d\n", ret); + pci1xxxx_i2c_shutdown(i2c); + goto err_free_region;
Quoted 8 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 1087
Quoted 6 lines
+ }
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +5
-0+ + return 0; + +err_free_region: + pci_free_irq_vectors(pdev);Should this also be part of the .remove function?
Yes, I will include this API in remove callback
Quoted 11 lines
Quoted 11 lines
+ return ret;
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +10
-0+} + +static void pci1xxxx_i2c_remove_pci (struct pci_dev *pdev) +{ + struct pci1xxxx_i2c *i2c = pci_get_drvdata(pdev); + + i2c_del_adapter(&i2c->adap); + pci1xxxx_i2c_shutdown(i2c); +} +
Quoted 5 lines · Christophe JAILLET
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 1087
Quoted 3 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +3
-0+ +err_free_region: + pci_free_irq_vectors(pdev);Should this also be part of the .remove function?
pci_free_irq_vectors API is not needed since pcim_enable_device API is used. I will remove 'pci_free_irq_vectors' in all the places in upcoming version of the patch.
Thanks,
Tharun Kumar P
Quoted 8 lines · Tharun Kumar P
Microchip PCI1XXXX is an unmanaged PCIe3.1a Switch for Consumer, Industrial and Automotive applications. This switch has multiple downstream ports. In one of the Switch's Downstream port, there is a multifunction endpoint for peripherals which includes an I2C host controller. The I2C function in the endpoint operates at 100KHz, 400KHz and 1 MHz and has buffer depth of 128 bytes.
This patch provides the I2C controller driver for the I2C endpoint of the switch.
...
drivers/i2c/busses/Kconfig config I2C_VIPERBOARD · line 1293
Quoted 5 lines
drivers/i2c/busses/Kconfig +1
-0@@ -1290,6 +1290,16 @@ config I2C_VIPERBOARD River Tech's viperboard.h for detailed meaning of the module parameters. +config I2C_PCI1XXXX
Looks unsorted.
drivers/i2c/busses/Kconfig config I2C_VIPERBOARD · line 1301
Quoted 8 lines
drivers/i2c/busses/Kconfig +8
-0+ tristate "PCI1XXXX I2C Host Adapter support" + depends on PCI + help + Say yes here to enable the I2C Host adapter support for the PCI1xxxx card + This is a PCI to I2C adapter + + This driver can be built as a module. If so, the module will be + called as i2c-mchp-pci1xxxx
English grammar and punctuation while keeping lines shorter (~76) please.
...
drivers/i2c/busses/Makefile obj-$(CONFIG_I2C_ROBOTFUZZ_OSIF) += i2c-robotfuzz-osif.o · line 138
Quoted 2 lines
drivers/i2c/busses/Makefile +1
-0obj-$(CONFIG_I2C_VIPERBOARD) += i2c-viperboard.o +obj-$(CONFIG_I2C_PCI1XXXX) += i2c-mchp-pci1xxxx.o
Why unsorted?
...
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 9
Quoted 2 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +2
-0+* Author: Tharun Kumar P <[email protected]> +* Kumaravel Thiagarajan <[email protected]>
Single or many?
...
Quoted 1 line
+/*SMB register space*/
Style.
...
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 29
Quoted 2 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +2
-0+#define SMB_CORE_CTRL_ESO 0x40 +#define SMB_CORE_CTRL_FW_ACK 0x10
Are they bits or numbers?
...
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 37
Quoted 3 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +3
-0+#define SMB_CORE_CMD_READM 0x10 +#define SMB_CORE_CMD_STOP 0x04 +#define SMB_CORE_CMD_START 0x01
Ditto.
...
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 42
Quoted 2 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +2
-0+#define SMB_CORE_CMD_M_PROCEED 0x02 +#define SMB_CORE_CMD_M_RUN 0x01
Ditto.
...
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 48
Quoted 3 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +3
-0+#define SR_HOLD_TIME_100KHZ 0x85 +#define SR_HOLD_TIME_400KHZ 0x14 +#define SR_HOLD_TIME_1000KHZ 0x0B
These has to be decimal, and why the ACPI / DT does not provide them?
Also, do they have units or are they proportional coefficients?
...
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 54
Quoted 3 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +3
-0+#define COMPLETION_MDONE 0x40 +#define COMPLETION_IDLE 0x20 +#define COMPLETION_MNAKX 0x01
Bits? Same Q for the rest similar stuff.
...
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 60
Quoted 3 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +3
-0+#define SMB_IDLE_SCALING_100KHZ 0x03E803C9 +#define SMB_IDLE_SCALING_400KHZ 0x01F4009D +#define SMB_IDLE_SCALING_1000KHZ 0x01F4009D
Shouldn't these magics be decimals?
Ditto for the rest similar stuff.
...
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 116
Quoted 2 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +2
-0+#define I2C_DIR_WRITE 0 +#define I2C_DIR_READ 1
Namespace collision. Doesn't I²C core provide these?
...
Quoted 1 line
+#define
PCI1XXXX_I2C_TIMEOUT1000
Units? Same to the rest similar cases.
...
Quoted 1 line
+#define
SMBUS_PERI_LOCKBIT(3)
BIT() out of a sudden. See above.
...
Quoted 4 lines
+/*
+ * structpci1xxxx_i2c- private structure for the I2C controller+ *
Redundant blank line.
Quoted 10 lines
+ * @adap: I2C adapter instance
+ * @dev: pointer to device struct
+ * @i2c_base: pci base address of the I2C ctrler
+ * @i2c_xfer_done: used for synchronisation between foreground & isr
+ * @freq: frequency of I2C transfer
+ * @flags: internal flags to store transfer conditions
+ * @irq: irq number
+ */+
Ditt.
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 207
Quoted 8 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +8
-0+struct pci1xxxx_i2c { +struct completion i2c_xfer_done; +bool i2c_xfer_in_progress; +struct i2c_adapter adap; +void __iomem *i2c_base; +u32 freq; +u32 flags; +};
I have lack of time to finish review, but you already have enough for the next version.
...
Review
Quoted 2 lines
(quoted diff) +2
-0+ transferlen = min((u16)(SMBUS_MAST_BUF_MAX_SIZE - 1), + remainingbytes);
min_t()
...
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 847
Quoted 2 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +2
-0+if (remainingbytes <= transferlen && (i2c->flags & +I2C_FLAGS_STOP ))
Strange indentation.
...
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 856
Quoted 5 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +5
-0+/* +* wait for the DMA_TERM interrupt and if the timer expires, it means +* the transaction has failed due to some bus lock as we dint get +* the interrupt +*/
You really have to go through all comments and fix grammar, etc.
...
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 858
Quoted 2 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +2
-0+ time_left =wait_for_completion_timeout + (&i2c->i2c_xfer_done,msecs_to_jiffies (PCI1XXXX_I2C_TIMEOUT ));
Strange indentation.
...
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 1095
Quoted 1 line
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +1
-0+i2c_del_adapter (&i2c->adap);
Can't you use devm_ variant?
...
Review
Quoted 1 line
(quoted diff) +1
-0+ pci1xxxx_i2c_shutdown(i2c);
Do you really need this in ->remove()? I would expect something in the ->suspend() / ->shutdown().
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 12 lines · Andy Shevchenko
Quoted 8 lines · Tharun Kumar P
Microchip PCI1XXXX is an unmanaged PCIe3.1a Switch for Consumer, Industrial and Automotive applications. This switch has multiple downstream ports. In one of the Switch's Downstream port, there is a multifunction endpoint for peripherals which includes an I2C host controller. The I2C function in the endpoint operates at 100KHz, 400KHz and 1 MHz and has buffer depth of 128 bytes.
This patch provides the I2C controller driver for the I2C endpoint of the switch....
Quoted 7 lines
Quoted 5 lines
(quoted diff) +0
-0@@ -1290,6 +1290,16 @@ config I2C_VIPERBOARDRiver Tech's
viperboard.hfor detailed meaning of the module parameters.+config
I2C_PCI1XXXXLooks unsorted.
Okay, I will sort in alphabetical order
Quoted 11 lines
Quoted 9 lines
+ tristate "PCI1XXXX I2C Host Adapter support"
+ depends on PCI
+ help
+ Say yes here to enable the I2C Host adapter support for the PCI1xxxx card
+ This is a PCI to I2C adapter
+
+ This driver can be built as a module. If so, the module will be + called as i2c-mchp-pci1xxxxEnglish grammar and punctuation while keeping lines shorter (~76) please.
Okay
Quoted 5 lines
Quoted 3 lines
obj-$(CONFIG_I2C_VIPERBOARD) += i2c-viperboard.o +obj-$(CONFIG_I2C_PCI1XXXX) += i2c-mchp-pci1xxxx.o
Why unsorted?
I will sort in alphabetical order
Quoted 5 lines
Quoted 3 lines
+ * Author: Tharun Kumar P <[email protected]>
+ * Kumaravel Thiagarajan <[email protected]>Single or many?
There are 2 authors for this file
Quoted 4 lines
Quoted 2 lines
+/*SMB register space*/
Style.
I will take care of styling for comments throughout file
Quoted 5 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 29
Quoted 3 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +2
-0+#define SMB_CORE_CTRL_ESO 0x40 +#define SMB_CORE_CTRL_FW_ACK 0x10Are they bits or numbers?
These are bits
Quoted 7 lines
...
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 37
Quoted 3 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +3
-0+#define SMB_CORE_CMD_READM 0x10 +#define SMB_CORE_CMD_STOP 0x04 +#define SMB_CORE_CMD_START 0x01Ditto.
These are bits
Quoted 6 lines
...
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 42
Quoted 2 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +2
-0+#define SMB_CORE_CMD_M_PROCEED 0x02 +#define SMB_CORE_CMD_M_RUN 0x01Ditto.
These are bits
Quoted 9 lines
...
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 48
Quoted 3 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +3
-0+#define SR_HOLD_TIME_100KHZ 0x85 +#define SR_HOLD_TIME_400KHZ 0x14 +#define SR_HOLD_TIME_1000KHZ 0x0BThese has to be decimal, and why the ACPI / DT does not provide them?
Also, do they have units or are they proportional coefficients?
There is no direct correlation between the hex value and time. Ex: 0x85 represents 0.5 us. Our device has an OTP region using which user can configure device to operate at 100KHz, 400KHz and 1MHz. Based on this configuration, SR_HOLD_TIME, IDLE_SCALING and few other registers will be configured in driver
Quoted 7 lines
...
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 54
Quoted 3 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +3
-0+#define COMPLETION_MDONE 0x40 +#define COMPLETION_IDLE 0x20 +#define COMPLETION_MNAKX 0x01Bits? Same Q for the rest similar stuff.
Yes. These are bits.
Quoted 8 lines
...
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 60
Quoted 3 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +3
-0+#define SMB_IDLE_SCALING_100KHZ 0x03E803C9 +#define SMB_IDLE_SCALING_400KHZ 0x01F4009D +#define SMB_IDLE_SCALING_1000KHZ 0x01F4009DShouldn't these magics be decimals?
Ditto for the rest similar stuff.
There is no direct correlation between the hex value and time. Configuring registers with these values in driver will set the time in device.
Quoted 6 lines
...
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 116
Quoted 2 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +2
-0+#define I2C_DIR_WRITE 0 +#define I2C_DIR_READ 1Namespace collision. Doesn't I²C core provide these?
I am unable to find any existing MACROs for WRITE and READ in I2C core. Kindly let me know the MACROs
Quoted 5 lines
...
Quoted 1 line
+#define
PCI1XXXX_I2C_TIMEOUT1000Units? Same to the rest similar cases.
Unit is milliseconds
Quoted 5 lines
...
Quoted 1 line
+#define SMBUS_PERI_LOCK BIT(3)
BIT()out of a sudden. See above.
Will use hex value for this like in other places to maintain uniformity
Quoted 8 lines
...
Quoted 4 lines
+/*
+ * structpci1xxxx_i2c- private structure for the I2C controller+ *
Redundant blank line.
Will take care of this in upcoming patch
Quoted 10 lines
Quoted 9 lines
+ * @adap: I2C adapter instance
+ * @dev: pointer to device struct
+ * @i2c_base: pci base address of the I2C ctrler
+ * @i2c_xfer_done: used for synchronisation between foreground & isr
+ * @freq: frequency of I2C transfer
+ * @flags: internal flags to store transfer conditions
+ * @irq: irq number
+ */
Quoted 3 lines
Quoted 1 line
+
Ditt.
Will take care of this in upcoming patch
Quoted 12 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 207
Quoted 8 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +8
-0+struct pci1xxxx_i2c { + struct completion i2c_xfer_done; + bool i2c_xfer_in_progress; + struct i2c_adapter adap; + void __iomem *i2c_base; + u32 freq; + u32 flags; +};I have lack of time to finish review, but you already have enough for the next version.
Quoted 6 lines
...
Quoted 2 lines
+ transferlen = min((u16)(SMBUS_MAST_BUF_MAX_SIZE - 1), + remainingbytes);
min_t()
Okay, Will replace min with min_t
Quoted 6 lines
...
Quoted 2 lines
+ if (remainingbytes <= transferlen && (
i2c->flags& +I2C_FLAGS_STOP))Strange indentation.
Okay, Will take care of indentation in upcoming patch
Quoted 11 lines
...
Quoted 7 lines
+ /*
+ * wait for theDMA_TERMinterrupt and if the timer expires, it means
+ * the transaction has failed due to some bus lock as we dint get
+ * the interrupt
+ */You really have to go through all comments and fix grammar, etc.
Okay
Quoted 7 lines
...
Quoted 3 lines
+
time_left=wait_for_completion_timeout+ (&i2c->i2c_xfer_done,msecs_to_jiffies(PCI1XXXX_I2C_TIMEOUT));Strange indentation.
Okay, Will take care of indentation
Quoted 5 lines
...
Quoted 1 line
+
i2c_del_adapter(&i2c->adap);Can't you use
devm_variant?
Okay, I will use devm_ variant
Quoted 6 lines
...
Quoted 1 line
+
pci1xxxx_i2c_shutdown(i2c);Do you really need this in ->remove()? I would expect something in the ->suspend() / ->shutdown().
pci1xxxx_i2c_shutdown API will reset the registers that are set as part of pci1xxxx_i2c_init. So, this API is present in ->remove() and not in ->suspend() callback
Thanks,
Tharun Kumar P
Quoted 2 lines · On Wed, Aug 24, 2022 at 6:04 PM <[email protected]> wrote:
Quoted 1 line · Andy Shevchenko
On Tue, Aug 23, 2022 at 08:26:03PM +0530, Tharun Kumar P wrote:
...
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
+ * Author: Tharun Kumar P <[email protected]>
+ * Kumaravel Thiagarajan <[email protected]>Single or many?
There are 2 authors for this file
Do you see the issue now?
...
Quoted 6 lines
Quoted 4 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 29
Quoted 2 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +2
-0+#define SMB_CORE_CTRL_ESO 0x40 +#define SMB_CORE_CTRL_FW_ACK 0x10Are they bits or numbers?
These are bits
Use BIT() then. Ditto for the rest of the bits.
...
Quoted 5 lines
Quoted 5 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 60
Quoted 3 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +3
-0+#define SMB_IDLE_SCALING_100KHZ 0x03E803C9 +#define SMB_IDLE_SCALING_400KHZ 0x01F4009D +#define SMB_IDLE_SCALING_1000KHZ 0x01F4009DShouldn't these magics be decimals?
This Q seems unanswered.
Quoted 4 lines
Quoted 1 line
Ditto for the rest similar stuff.
There is no direct correlation between the hex value and time. Configuring registers with these values in driver will set the time in device.
...
Quoted 2 lines
Quoted 2 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 116
Quoted 2 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +2
-0+#define I2C_DIR_WRITE 0 +#define I2C_DIR_READ 1
https://elixir.bootlin.com/linux/v6.0-rc2/source/include/uapi/linux/i2c.h#L24
Quoted 4 lines
Quoted 1 line
Namespace collision. Doesn't I²C core provide these?
I am unable to find any existing MACROs for WRITE and READ in I2C core. Kindly let me know the MACROs
...
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
+#define
PCI1XXXX_I2C_TIMEOUT1000Units? Same to the rest similar cases.
Unit is milliseconds
So you know what to do, right?
...
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
+#define
SMBUS_PERI_LOCKBIT(3)
BIT()out of a sudden. See above.Will use hex value for this like in other places to maintain uniformity
See above.
...
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
+
pci1xxxx_i2c_shutdown(i2c);Do you really need this in ->remove()? I would expect something in the ->suspend() / ->shutdown().
pci1xxxx_i2c_shutdownAPI will reset the registers that are set as part ofpci1xxxx_i2c_init. So, this API is present in ->remove() and not in ->suspend() callback
I understand that, but it doesn't really answer my question.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 7 lines · Andy Shevchenko
Quoted 2 lines · On Wed, Aug 24, 2022 at 6:04 PM <[email protected]> wrote:
Quoted 1 line · Andy Shevchenko
On Tue, Aug 23, 2022 at 08:26:03PM +0530, Tharun Kumar P wrote:
...
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
+ * Author: Tharun Kumar P <[email protected]>
+ * Kumaravel Thiagarajan <[email protected]>Single or many?
There are 2 authors for this file
Do you see the issue now?
Yes, I will change 'Author' to 'Authors'
Quoted 10 lines
...
Quoted 6 lines
Quoted 4 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 29
Quoted 2 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +2
-0+#define SMB_CORE_CTRL_ESO 0x40 +#define SMB_CORE_CTRL_FW_ACK 0x10Are they bits or numbers?
These are bits
Use
BIT()then. Ditto for the rest of the bits.
Okay
Quoted 9 lines
...
Quoted 5 lines
Quoted 5 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 60
Quoted 3 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +3
-0+#define SMB_IDLE_SCALING_100KHZ 0x03E803C9 +#define SMB_IDLE_SCALING_400KHZ 0x01F4009D +#define SMB_IDLE_SCALING_1000KHZ 0x01F4009DShouldn't these magics be decimals?
This Q seems unanswered.
These magic numbers need not be decimals. Configuring registers with these values in driver will set the time in device. However, these values do not convey any meaning when represented in decimals.
Quoted 11 lines
Quoted 4 lines
Quoted 1 line
Ditto for the rest similar stuff.
There is no direct correlation between the hex value and time. Configuring registers with these values in driver will set the time in device.
...
Quoted 2 lines
Quoted 2 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 116
Quoted 2 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +2
-0+#define I2C_DIR_WRITE 0 +#define I2C_DIR_READ 1https://elixir.bootlin.com/linux/v6.0-rc2/source/include/uapi/linux/i2c.h#L24
I2C_M_RD is used in driver. But the purpose of these MACROs is different. I2C_DIR_WRITE is used inside both pci1xxxx_i2c_write as well as in pci1xxxx_i2c_read (for sending slave address). Thus these MACROs are required
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Namespace collision. Doesn't I²C core provide these?
I am unable to find any existing MACROs for WRITE and READ in I2C core. Kindly
let me know the MACROs...
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
+#define
PCI1XXXX_I2C_TIMEOUT1000Units? Same to the rest similar cases.
Unit is milliseconds
So you know what to do, right?
Yes, I will change MACRO to PCI1XXXX_I2C_TIMEOUT_MS
Quoted 9 lines
...
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
+#define SMBUS_PERI_LOCK BIT(3)
BIT()out of a sudden. See above.Will use hex value for this like in other places to maintain uniformity
See above.
Okay.
Quoted 7 lines
...
Quoted 5 lines
Quoted 4 lines
Quoted 1 line
+
pci1xxxx_i2c_shutdown(i2c);Do you really need this in ->remove()? I would expect something in the ->suspend() / ->shutdown().
Quoted 6 lines
Quoted 4 lines
pci1xxxx_i2c_shutdownAPI will reset the registers that are set as part ofpci1xxxx_i2c_init. So, this API is present in ->remove() and not in -Quoted 1 line
suspend()callback
I understand that, but it doesn't really answer my question.
I will remove this API in ->remove() callback and add in ->suspend() callback
Thanks,
Tharun Kumar P
Quoted 4 lines · On Thu, Aug 25, 2022 at 01:15:42PM +0000, [email protected]…
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · On Wed, Aug 24, 2022 at 6:04 PM <[email protected]> wrote:
Quoted 1 line · Andy Shevchenko
On Tue, Aug 23, 2022 at 08:26:03PM +0530, Tharun Kumar P wrote:
...
Quoted 11 lines
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 60
Quoted 3 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +3
-0+#define SMB_IDLE_SCALING_100KHZ 0x03E803C9 +#define SMB_IDLE_SCALING_400KHZ 0x01F4009D +#define SMB_IDLE_SCALING_1000KHZ 0x01F4009DShouldn't these magics be decimals?
This Q seems unanswered.
These magic numbers need not be decimals. Configuring registers with these values in driver will set the time in device. However, these values do not convey any meaning when represented in decimals.
Hmm... Maybe you don't see this, but I see the following:
0x03E803C9 = 65536 (i.e. 2^16) * 1000 + 9690x01F4009D = 32768 (i.e. 2^15) * 1000 + 157
Pretty much sounds like a bit 15 for standard mode and bit 16 for fast modes shifted by 1000 to have a room for the time in presumably nanoseconds up to 1 us.
Please, dig up into the documentation, vendor chat, etc to get more information on these values.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Ditto for the rest similar stuff.
There is no direct correlation between the hex value and time. Configuring registers with these values in driver will set the time in device.
...
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 116
Quoted 2 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +2
-0+#define I2C_DIR_WRITE 0 +#define I2C_DIR_READ 1https://elixir.bootlin.com/linux/v6.0-rc2/source/include/uapi/linux/i2c.h#L24
I2C_M_RDis used in driver. But the purpose of these MACROs is different.I2C_DIR_WRITEis used inside bothpci1xxxx_i2c_writeas well as inpci1xxxx_i2c_read(for sending slave address). Thus these MACROs are required
OK. Name collision still stays.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Namespace collision. Doesn't I²C core provide these?
I am unable to find any existing MACROs for WRITE and READ in I2C core. Kindly let me know the MACROs
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 28 lines · Andy Shevchenko
Quoted 5 lines · On Thu, Aug 25, 2022 at 01:15:42PM +0000…
Quoted 4 lines · Andy Shevchenko
Quoted 2 lines · On Wed, Aug 24, 2022 at 6:04 PM <[email protected]> wrote:
Quoted 1 line · Andy Shevchenko
On Tue, Aug 23, 2022 at 08:26:03PM +0530, Tharun Kumar P wrote:
...
Quoted 11 lines
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 60
Quoted 3 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +3
-0+#define SMB_IDLE_SCALING_100KHZ 0x03E803C9 +#define SMB_IDLE_SCALING_400KHZ 0x01F4009D +#define SMB_IDLE_SCALING_1000KHZ 0x01F4009DShouldn't these magics be decimals?
This Q seems unanswered.
These magic numbers need not be decimals. Configuring registers with these values in driver will set the time in device. However, these values do not convey any meaning when represented in decimals.
Hmm... Maybe you don't see this, but I see the following:
0x03E803C9= 65536 (i.e. 2^16) * 1000 + 9690x01F4009D= 32768 (i.e. 2^15) * 1000 + 157
Quoted 7 lines
Pretty much sounds like a bit 15 for standard mode and bit 16 for fast modes shifted by 1000 to have a room for the time in presumably nanoseconds up to 1 us.
Please, dig up into the documentation, vendor chat, etc to get more information
on these values.
Sure, I will go through the documentation. Thanks. Also, I will modify these magic numbers to decimals.
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Ditto for the rest similar stuff.
There is no direct correlation between the hex value and time. Configuring
registers with these values in driver will set the time in device....
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c line 116
Quoted 2 lines
drivers/i2c/busses/i2c-mchp-pci1xxxx.c new file +2
-0+#define I2C_DIR_WRITE 0 +#define I2C_DIR_READ 1https://elixir.bootlin.com/linux/v6.0-rc2/source/include/uapi/linux/i2c.h#L24
Quoted 6 lines
Quoted 4 lines
I2C_M_RDis used in driver. But the purpose of these MACROs is different.I2C_DIR_WRITEis used inside bothpci1xxxx_i2c_writeas well as inpci1xxxx_i2c_read(for sending slave address). Thus these MACROs are requiredOK. Name collision still stays.
I will modify MACRO names to avoid name collision.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Namespace collision. Doesn't I²C core provide these?
I am unable to find any existing MACROs for WRITE and READ in I2C core. Kindly let me know the MACROs
Thanks,
Tharun Kumar P
Quoted 29 lines · On Fri, 2022-08-26 at 04:00 +0000, Tharunkumar Pasumarthi - I67821 wrote:
Quoted 28 lines · Andy Shevchenko
Quoted 5 lines · On Thu, Aug 25, 2022 at 01:15:42PM +0000…
Quoted 4 lines · Andy Shevchenko
Quoted 2 lines · On Wed, Aug 24, 2022 at 6:04 PM <[email protected]> wrote:
Quoted 1 line · Andy Shevchenko
On Tue, Aug 23, 2022 at 08:26:03PM +0530, Tharun Kumar P wrote:
...
Quoted 11 lines
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+#define SMB_IDLE_SCALING_100KHZ 0x03E803C9 +#define SMB_IDLE_SCALING_400KHZ 0x01F4009D +#define SMB_IDLE_SCALING_1000KHZ 0x01F4009DShouldn't these magics be decimals?
This Q seems unanswered.
These magic numbers need not be decimals. Configuring registers with these values in driver will set the time in device. However, these values do not convey any meaning when represented in decimals.
Hmm... Maybe you don't see this, but I see the following:
0x03E803C9= 65536 (i.e. 2^16) * 1000 + 9690x01F4009D= 32768 (i.e. 2^15) * 1000 + 157
Quoted 9 lines
Quoted 8 lines
Pretty much sounds like a bit 15 for standard mode and bit 16 for fast modes shifted by 1000 to have a room for the time in presumably nanoseconds up to 1
us.Please, dig up into the documentation, vendor chat, etc to get more information
on these values.
I have went through the documentation.
Following is the bit mapping of idle scaling register:
Reserved [31:28]
Fair Idle Delay [27:16]
Reserved [15:12]
Bus Idle Min [11:0]
'Bus Idle Min' field will indicate the number of ticks of the baud clock required to program 'bus idle period' delay and can have maximum value of 4095. 'Fair Idle Min' field will indicate the number of ticks of the baud clock required to program 'fair idle' delay and can have maximum value of 4095.
So, either the entire IDLE_SCALING_REG value can be in hex or I could do something like below:
#define BUS_IDLE_MIN_TICKS <VALUE_IN_DECIMAL>
#define FAIR_IDLE_DELAY_TICKS <VALUE_IN_DECIMAL>
#define IDLE_SCALING_REG ((FAIR_IDLE_DELAY_TICKS << 16) | BUS_IDLE_MIN_TICKS)
Which of these 2 approaches do you feel is better?
Quoted 2 lines
Sure, I will go through the documentation. Thanks. Also, I will modify these magic numbers to decimals.
Thanks,
Tharun Kumar P
Quoted 9 lines · On Fri, Aug 26, 2022 at 4:04 PM <[email protected]> wrote:
Quoted 8 lines · On Fri, 2022-08-26 at 04:00 +0000, Tharunkumar Pasumarthi - I67821 wrote:
Quoted 7 lines · Andy Shevchenko
Quoted 5 lines · On Thu, Aug 25, 2022 at 01:15:42PM +0000, [email protected]…
Quoted 4 lines · Andy Shevchenko
Quoted 2 lines · On Wed, Aug 24, 2022 at 6:04 PM <[email protected]> wrote:
Quoted 1 line · Andy Shevchenko
On Tue, Aug 23, 2022 at 08:26:03PM +0530, Tharun Kumar P wrote:
...
Quoted 35 lines
Quoted 17 lines
Quoted 17 lines
Quoted 11 lines
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+#define SMB_IDLE_SCALING_100KHZ 0x03E803C9 +#define SMB_IDLE_SCALING_400KHZ 0x01F4009D +#define SMB_IDLE_SCALING_1000KHZ 0x01F4009DShouldn't these magics be decimals?
This Q seems unanswered.
These magic numbers need not be decimals. Configuring registers with these values in driver will set the time in device. However, these values do not convey any meaning when represented in decimals.
Hmm... Maybe you don't see this, but I see the following:
0x03E803C9= 65536 (i.e. 2^16) * 1000 + 9690x01F4009D= 32768 (i.e. 2^15) * 1000 + 157Quoted 9 lines
Quoted 8 lines
Pretty much sounds like a bit 15 for standard mode and bit 16 for fast modes shifted by 1000 to have a room for the time in presumably nanoseconds up to 1
us.Please, dig up into the documentation, vendor chat, etc to get more information
on these values.I have went through the documentation.
Following is the bit mapping of idle scaling register:
Reserved [31:28]
Fair Idle Delay [27:16]
Reserved [15:12]
Bus Idle Min [11:0]
Quoted 7 lines
'Bus Idle Min' field will indicate the number of ticks of the baud clock required to program 'bus idle period' delay and can have maximum value of 4095. 'Fair Idle Min' field will indicate the number of ticks of the baud clock required to program 'fair idle' delay and can have maximum value of 4095.
So, either the entire
IDLE_SCALING_REGvalue can be in hex or I could do something like below:
No hex.
Quoted 6 lines
#define
BUS_IDLE_MIN_TICKS<VALUE_IN_DECIMAL>
#defineFAIR_IDLE_DELAY_TICKS<VALUE_IN_DECIMAL>#define
IDLE_SCALING_REG((FAIR_IDLE_DELAY_TICKS<< 16) |BUS_IDLE_MIN_TICKS)Which of these 2 approaches do you feel is better?
Of course one with the comment explaining the thing and two decimal numbers. Now, since we know that both values are
1000 and 969
500 and 157
It's easy to see the difference and meaning.
So per each mode you need to have those pairs of decimal numbers in ticks. and one comment explaining all what you have explained here in this mail.
Quoted 2 lines
Quoted 2 lines
Sure, I will go through the documentation. Thanks. Also, I will modify these magic numbers to decimals.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 75 lines · Andy Shevchenko
Quoted 10 lines · On Fri, Aug 26, 2022 at 4:04 PM <[email protected]> wrote:
Quoted 9 lines · On Fri, 2022-08-26 at 04:00 +0000, Tharunkumar Pasumarthi - I67821 wrote:
Quoted 8 lines · Andy Shevchenko
Quoted 6 lines · On Thu, Aug 25, 2022 at 01:15:42PM +0000…
Quoted 5 lines · Andy Shevchenko
Quoted 2 lines · On Wed, Aug 24, 2022 at 6:04 PM <[email protected]> wrote:
Quoted 1 line · Andy Shevchenko
On Tue, Aug 23, 2022 at 08:26:03PM +0530, Tharun Kumar P wrote:
...
Quoted 39 lines
Quoted 26 lines
Quoted 26 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+#define SMB_IDLE_SCALING_100KHZ 0x03E803C9 +#define SMB_IDLE_SCALING_400KHZ 0x01F4009D +#define SMB_IDLE_SCALING_1000KHZ 0x01F4009DShouldn't these magics be decimals?
Quoted 7 lines
Quoted 1 line
This Q seems unanswered.
These magic numbers need not be decimals. Configuring registers with these
values in driver will set the time in device. However, these values do not
convey any meaning when represented in decimals.Hmm... Maybe you don't see this, but I see the following:
0x03E803C9= 65536 (i.e. 2^16) * 1000 + 9690x01F4009D= 32768 (i.e. 2^15) * 1000 + 157Pretty much sounds like a bit 15 for standard mode and bit 16 for fast modes
shifted by 1000 to have a room for the time in presumably nanoseconds up to
1
us.Quoted 4 lines
Quoted 3 lines
Please, dig up into the documentation, vendor chat, etc to get more information
on these values.I have went through the documentation.
Following is the bit mapping of idle scaling register:
Reserved [31:28]
Fair Idle Delay [27:16]
Reserved [15:12]
Bus Idle Min [11:0]Quoted 8 lines
'Bus Idle Min' field will indicate the number of ticks of the baud clock required to program 'bus idle period' delay and can have maximum value of 4095.
'Fair Idle Min' field will indicate the number of ticks of the baud clock required to program 'fair idle' delay and can have maximum value of 4095.So, either the entire
IDLE_SCALING_REGvalue can be in hex or I could do something like below:No hex.
Quoted 7 lines
#define BUS_IDLE_MIN_TICKS <
VALUE_IN_DECIMAL>
#define FAIR_IDLE_DELAY_TICKS <VALUE_IN_DECIMAL>#define
IDLE_SCALING_REG((FAIR_IDLE_DELAY_TICKS<< 16) |BUS_IDLE_MIN_TICKS)Which of these 2 approaches do you feel is better?
Of course one with the comment explaining the thing and two decimal numbers. Now, since we know that both values are
Quoted 7 lines
1000 and 969
500 and 157It's easy to see the difference and meaning.
So per each mode you need to have those pairs of decimal numbers in ticks. and one comment explaining all what you have explained here in this mail.
Okay. I will follow this approach.
Thanks,
Tharun Kumar P