From: "Chew, Chiau Ee" <[email protected]>

Provide option to set the HCNT, LCNT and SDA if the target values are known
ahead. Instead of depends on formula to calculate the HCNT and LCNT.

Signed-off-by: Chew, Chiau Ee <[email protected]>
Signed-off-by: Maurice Petallo <[email protected]>
---
 drivers/i2c/busses/i2c-designware-pcidrv.c |   55 ++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c 
b/drivers/i2c/busses/i2c-designware-pcidrv.c
index 3599a6b..4f4398f 100644
--- a/drivers/i2c/busses/i2c-designware-pcidrv.c
+++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
@@ -70,6 +70,12 @@ struct dw_pci_controller {
        u32 tx_fifo_depth;
        u32 rx_fifo_depth;
        u32 clk_khz;
+       u32 ss_hcnt;
+       u32 ss_lcnt;
+       u32 fs_hcnt;
+       u32 fs_lcnt;
+       u32 ss_sda;
+       u32 fs_sda;
 };
 
 #define INTEL_MID_STD_CFG  (DW_IC_CON_MASTER |                 \
@@ -150,6 +156,12 @@ static struct  dw_pci_controller  dw_pci_controllers[] = {
                .tx_fifo_depth = 32,
                .rx_fifo_depth = 32,
                .clk_khz      = 100000,
+               .ss_hcnt        = 0x200,
+               .ss_lcnt        = 0x200,
+               .fs_hcnt        = 0x55,
+               .fs_lcnt        = 0x99,
+               .ss_sda         = 0x6,
+               .fs_sda         = 0x6,
        },
        [byt_1] = {
                .bus_num     = 1,
@@ -157,6 +169,12 @@ static struct  dw_pci_controller  dw_pci_controllers[] = {
                .tx_fifo_depth = 32,
                .rx_fifo_depth = 32,
                .clk_khz      = 100000,
+               .ss_hcnt        = 0x200,
+               .ss_lcnt        = 0x200,
+               .fs_hcnt        = 0x55,
+               .fs_lcnt        = 0x99,
+               .ss_sda         = 0x6,
+               .fs_sda         = 0x6,
        },
        [byt_2] = {
                .bus_num     = 2,
@@ -164,6 +182,12 @@ static struct  dw_pci_controller  dw_pci_controllers[] = {
                .tx_fifo_depth = 32,
                .rx_fifo_depth = 32,
                .clk_khz      = 100000,
+               .ss_hcnt        = 0x200,
+               .ss_lcnt        = 0x200,
+               .fs_hcnt        = 0x55,
+               .fs_lcnt        = 0x99,
+               .ss_sda         = 0x6,
+               .fs_sda         = 0x6,
        },
        [byt_3] = {
                .bus_num     = 3,
@@ -171,6 +195,12 @@ static struct  dw_pci_controller  dw_pci_controllers[] = {
                .tx_fifo_depth = 32,
                .rx_fifo_depth = 32,
                .clk_khz      = 100000,
+               .ss_hcnt        = 0x200,
+               .ss_lcnt        = 0x200,
+               .fs_hcnt        = 0x55,
+               .fs_lcnt        = 0x99,
+               .ss_sda         = 0x6,
+               .fs_sda         = 0x6,
        },
        [byt_4] = {
                .bus_num     = 4,
@@ -178,6 +208,12 @@ static struct  dw_pci_controller  dw_pci_controllers[] = {
                .tx_fifo_depth = 32,
                .rx_fifo_depth = 32,
                .clk_khz      = 100000,
+               .ss_hcnt        = 0x200,
+               .ss_lcnt        = 0x200,
+               .fs_hcnt        = 0x55,
+               .fs_lcnt        = 0x99,
+               .ss_sda         = 0x6,
+               .fs_sda         = 0x6,
        },
        [byt_5] = {
                .bus_num     = 5,
@@ -185,6 +221,12 @@ static struct  dw_pci_controller  dw_pci_controllers[] = {
                .tx_fifo_depth = 32,
                .rx_fifo_depth = 32,
                .clk_khz      = 100000,
+               .ss_hcnt        = 0x200,
+               .ss_lcnt        = 0x200,
+               .fs_hcnt        = 0x55,
+               .fs_lcnt        = 0x99,
+               .ss_sda         = 0x6,
+               .fs_sda         = 0x6,
        },
        [byt_6] = {
                .bus_num     = 6,
@@ -192,6 +234,12 @@ static struct  dw_pci_controller  dw_pci_controllers[] = {
                .tx_fifo_depth = 32,
                .rx_fifo_depth = 32,
                .clk_khz      = 100000,
+               .ss_hcnt        = 0x200,
+               .ss_lcnt        = 0x200,
+               .fs_hcnt        = 0x55,
+               .fs_lcnt        = 0x99,
+               .ss_sda         = 0x6,
+               .fs_sda         = 0x6,
        },
 };
 static struct i2c_algorithm i2c_dw_algo = {
@@ -315,7 +363,14 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
                I2C_FUNC_SMBUS_BYTE_DATA |
                I2C_FUNC_SMBUS_WORD_DATA |
                I2C_FUNC_SMBUS_I2C_BLOCK;
+
+       dev->ss_hcnt = controller->ss_hcnt;
+       dev->ss_lcnt = controller->ss_lcnt;
+       dev->fs_hcnt = controller->fs_hcnt;
+       dev->fs_lcnt = controller->fs_lcnt;
        dev->master_cfg =  controller->bus_cfg;
+       dev->sda_hold_time = (dev->master_cfg & DW_IC_CON_SPEED_FAST) ?
+                               controller->fs_sda : controller->ss_sda;
        pci_set_drvdata(pdev, dev);
 
        dev->tx_fifo_depth = controller->tx_fifo_depth;
-- 
1.7.10.4

-- 
_______________________________________________
linux-yocto mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/linux-yocto

Reply via email to