lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 14 Jun 2017 15:21:30 +0300
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     Luis Oliveira <Luis.Oliveira@...opsys.com>
Cc:     Wolfram Sang <wsa@...-dreams.de>, Rob Herring <robh+dt@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Jarkko Nikula <jarkko.nikula@...ux.intel.com>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        Mika Westerberg <mika.westerberg@...ux.intel.com>,
        linux-i2c <linux-i2c@...r.kernel.org>,
        devicetree <devicetree@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Ramiro Oliveira <Ramiro.Oliveira@...opsys.com>,
        Joao Pinto <Joao.Pinto@...opsys.com>,
        CARLOS.PALMINHA@...opsys.com
Subject: Re: [PATCH v11 6/6] i2c: designware: enable SLAVE in platform module

On Wed, Jun 14, 2017 at 1:43 PM, Luis Oliveira
<Luis.Oliveira@...opsys.com> wrote:
> - Slave mode selected in platform module if the support is detected in
>   the DT.
>
> Signed-off-by: Luis Oliveira <lolivei@...opsys.com>

This one looks fine to me.

Reviewed-by: Andy Shevchenko <andy.shevchenko@...il.com>

> ---
> v10-v11
> - no changes
>
>  drivers/i2c/busses/i2c-designware-core.h    |  2 ++
>  drivers/i2c/busses/i2c-designware-platdrv.c | 41 +++++++++++++++++++++++++----
>  2 files changed, 38 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-designware-core.h b/drivers/i2c/busses/i2c-designware-core.h
> index 64a39a983410..7bfbcc62f6c5 100644
> --- a/drivers/i2c/busses/i2c-designware-core.h
> +++ b/drivers/i2c/busses/i2c-designware-core.h
> @@ -228,6 +228,7 @@
>   * @disable: function to disable the controller
>   * @disable_int: function to disable all interrupts
>   * @init: function to initialize the I2C hardware
> + * @mode: operation mode - DW_IC_MASTER or DW_IC_SLAVE
>   *
>   * HCNT and LCNT parameters can be used if the platform knows more accurate
>   * values than the one computed based only on the input clock frequency.
> @@ -282,6 +283,7 @@ struct dw_i2c_dev {
>         void                    (*disable)(struct dw_i2c_dev *dev);
>         void                    (*disable_int)(struct dw_i2c_dev *dev);
>         int                     (*init)(struct dw_i2c_dev *dev);
> +       int                     mode;
>  };
>
>  #define ACCESS_SWAP            0x00000001
> diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
> index 1f38c807be5f..2ea6d0d25a01 100644
> --- a/drivers/i2c/busses/i2c-designware-platdrv.c
> +++ b/drivers/i2c/busses/i2c-designware-platdrv.c
> @@ -1,5 +1,5 @@
>  /*
> - * Synopsys DesignWare I2C adapter driver (master only).
> + * Synopsys DesignWare I2C adapter driver.
>   *
>   * Based on the TI DAVINCI I2C adapter driver.
>   *
> @@ -174,9 +174,13 @@ static inline int dw_i2c_acpi_configure(struct platform_device *pdev)
>
>  static void i2c_dw_configure_master(struct dw_i2c_dev *dev)
>  {
> +       dev->functionality = I2C_FUNC_10BIT_ADDR | DW_IC_DEFAULT_FUNCTIONALITY;
> +
>         dev->master_cfg = DW_IC_CON_MASTER | DW_IC_CON_SLAVE_DISABLE |
>                           DW_IC_CON_RESTART_EN;
>
> +       dev->mode = DW_IC_MASTER;
> +
>         switch (dev->clk_freq) {
>         case 100000:
>                 dev->master_cfg |= DW_IC_CON_SPEED_STD;
> @@ -189,6 +193,28 @@ static void i2c_dw_configure_master(struct dw_i2c_dev *dev)
>         }
>  }
>
> +static void i2c_dw_configure_slave(struct dw_i2c_dev *dev)
> +{
> +       dev->functionality = I2C_FUNC_SLAVE | DW_IC_DEFAULT_FUNCTIONALITY;
> +
> +       dev->slave_cfg = DW_IC_CON_RX_FIFO_FULL_HLD_CTRL |
> +                        DW_IC_CON_RESTART_EN | DW_IC_CON_STOP_DET_IFADDRESSED |
> +                        DW_IC_CON_SPEED_FAST;
> +
> +       dev->mode = DW_IC_SLAVE;
> +
> +       switch (dev->clk_freq) {
> +       case 100000:
> +               dev->slave_cfg |= DW_IC_CON_SPEED_STD;
> +               break;
> +       case 3400000:
> +               dev->slave_cfg |= DW_IC_CON_SPEED_HIGH;
> +               break;
> +       default:
> +               dev->slave_cfg |= DW_IC_CON_SPEED_FAST;
> +       }
> +}
> +
>  static int i2c_dw_plat_prepare_clk(struct dw_i2c_dev *i_dev, bool prepare)
>  {
>         if (IS_ERR(i_dev->clk))
> @@ -302,9 +328,10 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
>         if (ret)
>                 goto exit_reset;
>
> -       dev->functionality = I2C_FUNC_10BIT_ADDR | DW_IC_DEFAULT_FUNCTIONALITY;
> -
> -       i2c_dw_configure_master(dev);
> +       if (i2c_detect_slave_mode(&pdev->dev))
> +               i2c_dw_configure_slave(dev);
> +       else
> +               i2c_dw_configure_master(dev);
>
>         dev->clk = devm_clk_get(&pdev->dev, NULL);
>         if (!i2c_dw_plat_prepare_clk(dev, true)) {
> @@ -333,7 +360,11 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
>                 pm_runtime_enable(&pdev->dev);
>         }
>
> -       ret = i2c_dw_probe(dev);
> +       if (dev->mode == DW_IC_SLAVE)
> +               ret = i2c_dw_probe_slave(dev);
> +       else
> +               ret = i2c_dw_probe(dev);
> +
>         if (ret)
>                 goto exit_probe;
>
> --
> 2.13.0
>
>



-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ