mbox series

[v3,0/4] Port mxs-dcp to imx6ull and imx6sll

Message ID cover.1539705285.git.leonard.crestez@nxp.com
Headers show
Series Port mxs-dcp to imx6ull and imx6sll | expand

Message

Leonard Crestez Oct. 16, 2018, 3:57 p.m. UTC
The DCP block is present on 6sll and 6ull but not enabled. The hardware is
mostly compatible with 6sl, the only important difference is that explicit
clock enabling is required.

There were several issues with the functionality of this driver (it didn't
even probe properly) but they are fixed in cryptodev/master by this series:
    https://lore.kernel.org/patchwork/cover/994874/

---
Changes since v2:
 * Rename 6ull dcp node to crypto@*
 * Use clk_prepare_enable on probe
 * Fix not unpreparing on remove
 * Realign dcp_clk struct member with rest of attributes (using tabs)
 * Link to v2: https://lore.kernel.org/patchwork/cover/999795/

Changes since v1:
 * Add devicetree maintainers for dt-bindings
 * Add a patch enabling in imx_v6_v7_defconfig. Since tcrypt now passes this
shouldn't cause any issues
 * Link to v1: https://lore.kernel.org/patchwork/cover/994893/

Leonard Crestez (4):
  dt-bindings: crypto: Mention clocks for mxs-dcp
  crypto: mxs-dcp - Add support for dcp clk
  ARM: dts: imx6ull: Add dcp node
  ARM: imx_v6_v7_defconfig: Enable CRYPTO_DEV_MXS_DCP

 .../devicetree/bindings/crypto/fsl-dcp.txt        |  2 ++
 arch/arm/boot/dts/imx6ull.dtsi                    | 10 ++++++++++
 arch/arm/configs/imx_v6_v7_defconfig              |  1 +
 drivers/crypto/mxs-dcp.c                          | 15 +++++++++++++++
 4 files changed, 28 insertions(+)

Comments

Fabio Estevam Oct. 16, 2018, 4:03 p.m. UTC | #1
Hi Leonard,

On Tue, Oct 16, 2018 at 12:58 PM Leonard Crestez
<leonard.crestez@nxp.com> wrote:

> +       /* DCP clock is optional, only used on some SOCs */
> +       sdcp->dcp_clk = devm_clk_get(dev, "dcp");
> +       if (IS_ERR(sdcp->dcp_clk)) {
> +               if (sdcp->dcp_clk != ERR_PTR(-ENOENT))
> +                       return PTR_ERR(sdcp->dcp_clk);
> +               sdcp->dcp_clk = NULL;

This dcp_clk assignment to NULL does not seem to be necessary.

> +
> +       ret = clk_prepare_enable(sdcp->dcp_clk);
> +       if (ret)
> +               return ret;
>
>         ret = devm_request_irq(dev, dcp_vmi_irq, mxs_dcp_irq, 0,
>                                "dcp-vmi-irq", sdcp);
>         if (ret) {
>                 dev_err(dev, "Failed to claim DCP VMI IRQ!\n");

In case of subsequent errors you should call
clk_disable_unprepare(sdcp->dcp_clk).
Fabio Estevam Oct. 16, 2018, 4:04 p.m. UTC | #2
On Tue, Oct 16, 2018 at 12:59 PM Leonard Crestez
<leonard.crestez@nxp.com> wrote:
>
> The DCP block on 6ull has no major differences other than requiring
> explicit clock enabling.
>
> Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>

Reviewed-by: Fabio Estevam <festevam@gmail.com>
Leonard Crestez Oct. 16, 2018, 5:23 p.m. UTC | #3
On Tue, 2018-10-16 at 13:03 -0300, Fabio Estevam wrote:
> > +       /* DCP clock is optional, only used on some SOCs */
> > +       sdcp->dcp_clk = devm_clk_get(dev, "dcp");
> > +       if (IS_ERR(sdcp->dcp_clk)) {
> > +               if (sdcp->dcp_clk != ERR_PTR(-ENOENT))
> > +                       return PTR_ERR(sdcp->dcp_clk);
> > +               sdcp->dcp_clk = NULL;
> 
> This dcp_clk assignment to NULL does not seem to be necessary.

The clk API ignores all calls if clk == NULL (which is very nice) but
not if IS_ERR(clk). Setting dcp_clk to NULL avoids sprinkling other
checks.

> > +       ret = clk_prepare_enable(sdcp->dcp_clk);
> > +       if (ret)
> > +               return ret;
> > 
> >         ret = devm_request_irq(dev, dcp_vmi_irq, mxs_dcp_irq, 0,
> >                                "dcp-vmi-irq", sdcp);
> >         if (ret) {
> >                 dev_err(dev, "Failed to claim DCP VMI IRQ!\n");
> 
> In case of subsequent errors you should call
> clk_disable_unprepare(sdcp->dcp_clk).

Yes, will resend. Maybe some day clk consumer will automatically undo
pending prepare/enables on release?