Re: [PATCH 2/2] i2c: designware-pci: set ideal HCNT, LCNT and SDA hold time value

From: Wolfram Sang
Date: Mon Mar 10 2014 - 11:21:23 EST


On Fri, Mar 07, 2014 at 10:12:51PM +0800, Chew Chiau Ee wrote:
> From: Chew, Chiau Ee <chiau.ee.chew@xxxxxxxxx>
>
> On Intel BayTrail, there was case whereby the resulting fast mode
> bus speed becomes slower (~20% slower compared to expected speed)
> if using the HCNT/LCNT calculated in the core layer. Thus, this
> patch is added to allow pci glue layer to pass in optimal
> HCNT/LCNT/SDA hold time values to core layer since the core
> layer supports cofigurable HCNT/LCNT/SDA hold time values now.
>
> Signed-off-by: Chew, Chiau Ee <chiau.ee.chew@xxxxxxxxx>
> ---
> drivers/i2c/busses/i2c-designware-pcidrv.c | 34 ++++++++++++++++++++++++++++
> 1 files changed, 34 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c
> index 87f2fc4..96417ca 100644
> --- a/drivers/i2c/busses/i2c-designware-pcidrv.c
> +++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
> @@ -58,6 +58,14 @@ enum dw_pci_ctl_id_t {
> baytrail,
> };
>
> +struct scl_sda_cfg {
> + u32 ss_hcnt;
> + u32 fs_hcnt;
> + u32 ss_lcnt;
> + u32 fs_lcnt;
> + u32 sda_hold;
> +};

'dw_' prefix for this struct name, please.

> #define INTEL_MID_STD_CFG (DW_IC_CON_MASTER | \
> @@ -77,6 +86,21 @@ struct dw_pci_controller {
> I2C_FUNC_SMBUS_WORD_DATA | \
> I2C_FUNC_SMBUS_I2C_BLOCK)
>
> +/* BayTrail HCNT/LCNT/SDA_HOLD */
> +#define BYT_STD_MODE_HCNT 0x200
> +#define BYT_STD_MODE_LCNT BYT_STD_MODE_HCNT
> +#define BYT_FAST_MODE_HCNT 0x55
> +#define BYT_FAST_MODE_LCNT 0x99
> +#define BYT_SDA_HOLD 0x6

I'd think you can use these values directly in the struct. They are not
supposed to be used outside anyhow.

> +static struct scl_sda_cfg byt_config = {
> + .ss_hcnt = BYT_STD_MODE_HCNT,
> + .fs_hcnt = BYT_FAST_MODE_HCNT,
> + .ss_lcnt = BYT_STD_MODE_LCNT,
> + .fs_lcnt = BYT_FAST_MODE_LCNT,
> + .sda_hold = BYT_SDA_HOLD,
> +};

I'd prefer no tabs before "=", just one space.

Thanks,

Wolfram

Attachment: signature.asc
Description: Digital signature