linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Moritz Fischer <moritz.fischer@ettus.com>
To: Alan Tull <atull@opensource.altera.com>
Cc: Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Dinh Nguyen <dinguyen@opensource.altera.com>,
	Devicetree List <devicetree@vger.kernel.org>,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Alan Tull <delicious.quinoa@gmail.com>
Subject: Re: [PATCH 2/2] fpga-manager: Add Socfpga Arria10 support
Date: Tue, 12 Jul 2016 14:31:05 -0700	[thread overview]
Message-ID: <CAAtXAHfSBzLisqBgF4Vry0vrcL3+DB4b1ctMOrTdOq5ue4D7JQ@mail.gmail.com> (raw)
In-Reply-To: <20160712190709.5964-3-atull@opensource.altera.com>

Hi Alan,

couple of nits inline below.

On Tue, Jul 12, 2016 at 12:07 PM, Alan Tull <atull@opensource.altera.com> wrote:

> +static int socfpga_a10_fpga_write_complete(struct fpga_manager *mgr, u32 flags)
> +{
> +       struct a10_fpga_priv *priv = mgr->priv;
> +       u32 reg;
> +       int ret;
> +
> +       /* Wait for pr_done */
> +       ret = socfpga_a10_fpga_wait_for_pr_done(priv);
> +
> +       /* Clear pr_request */
> +       regmap_update_bits(priv->regmap, A10_FPGAMGR_IMGCFG_CTL_01_OFST,
> +                          A10_FPGAMGR_IMGCFG_CTL_01_S2F_PR_REQUEST, 0);
> +
> +       /* Send some clocks to clear out any errors */
> +       socfpga_a10_fpga_generate_dclks(priv, 256);
> +
> +       /* Disable s2f dclk and data */
> +       regmap_update_bits(priv->regmap, A10_FPGAMGR_IMGCFG_CTL_02_OFST,
> +                          A10_FPGAMGR_IMGCFG_CTL_02_EN_CFG_CTRL, 0);

Maybe replace 0 with named constant.
> +
> +       /* Deassert chip select */
> +       regmap_update_bits(priv->regmap, A10_FPGAMGR_IMGCFG_CTL_01_OFST,
> +                          A10_FPGAMGR_IMGCFG_CTL_01_S2F_NCE,
> +                          A10_FPGAMGR_IMGCFG_CTL_01_S2F_NCE);
> +
> +       /* Disable data, dclk, nce, and pr_request override to CSS */
> +       regmap_update_bits(priv->regmap, A10_FPGAMGR_IMGCFG_CTL_01_OFST,
> +                          A10_FPGAMGR_IMGCFG_CTL_01_S2F_NENABLE_CONFIG,
> +                          A10_FPGAMGR_IMGCFG_CTL_01_S2F_NENABLE_CONFIG);
> +
> +       /* Return any errors regarding pr_done or pr_error */
> +       if (ret)
> +               return ret;
> +
> +       /* Final check */
> +       reg = socfpga_a10_fpga_read_stat(priv);
> +
> +       if (((reg & A10_FPGAMGR_IMGCFG_STAT_F2S_USERMODE) == 0) ||
> +           ((reg & A10_FPGAMGR_IMGCFG_STAT_F2S_CONDONE_PIN) == 0) ||
> +           ((reg & A10_FPGAMGR_IMGCFG_STAT_F2S_NSTATUS_PIN) == 0)) {
> +               dev_dbg(&mgr->dev,
> +                       "Timeout in final check. Status=%08xf\n", reg);
> +               return -ETIMEDOUT;
> +       }
> +
> +       return 0;
> +}
> +
> +static enum fpga_mgr_states socfpga_a10_fpga_state(struct fpga_manager *mgr)
> +{
> +       struct a10_fpga_priv *priv = mgr->priv;
> +       u32 reg = socfpga_a10_fpga_read_stat(priv);
> +
> +       if (reg & A10_FPGAMGR_IMGCFG_STAT_F2S_USERMODE)
> +               return FPGA_MGR_STATE_OPERATING;
> +
> +       if (reg & A10_FPGAMGR_IMGCFG_STAT_F2S_PR_READY)
> +               return FPGA_MGR_STATE_WRITE;
> +
> +       if (reg & A10_FPGAMGR_IMGCFG_STAT_F2S_CRC_ERROR)
> +               return FPGA_MGR_STATE_WRITE_COMPLETE_ERR;
> +
> +       if ((reg & A10_FPGAMGR_IMGCFG_STAT_F2S_NSTATUS_PIN) == 0)
> +               return FPGA_MGR_STATE_RESET;
> +
> +       return FPGA_MGR_STATE_UNKNOWN;
> +}
> +
> +static const struct fpga_manager_ops socfpga_a10_fpga_mgr_ops = {
> +       .state = socfpga_a10_fpga_state,
> +       .write_init = socfpga_a10_fpga_write_init,
> +       .write = socfpga_a10_fpga_write,
> +       .write_complete = socfpga_a10_fpga_write_complete,
> +};
> +
> +static int socfpga_a10_fpga_probe(struct platform_device *pdev)
> +{
> +       struct device *dev = &pdev->dev;
> +       struct a10_fpga_priv *priv;
> +       void __iomem *reg_base;
> +       struct resource *res;
> +       int ret;
> +
> +       priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> +       if (!priv)
> +               return -ENOMEM;
> +
> +       /* First mmio base is for register access */
> +       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +       reg_base = devm_ioremap_resource(dev, res);
> +       if (IS_ERR(reg_base))
> +               return PTR_ERR(reg_base);
> +
> +       /* Second mmio base is for writing FPGA image data */
> +       res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> +       priv->fpga_data_addr = devm_ioremap_resource(dev, res);
> +       if (IS_ERR(priv->fpga_data_addr))
> +               return PTR_ERR(priv->fpga_data_addr);
> +
> +       /* regmap for register access */
> +       priv->regmap = devm_regmap_init_mmio(dev, reg_base,
> +                                            &socfpga_a10_fpga_regmap_config);
> +       if (IS_ERR(priv->regmap))
> +               return -ENODEV;
> +
> +       priv->clk = devm_clk_get(dev, NULL);
> +       if (IS_ERR(priv->clk)) {
> +               dev_err(dev, "no clock specified\n");
> +               return PTR_ERR(priv->clk);
> +       }
> +
> +       ret = clk_prepare_enable(priv->clk);
> +       if (ret) {
> +               dev_err(dev, "could not enable clock\n");
> +               clk_put(priv->clk);

Seen that you used devm_clk_get() is this one necessary?

> +static int socfpga_a10_fpga_remove(struct platform_device *pdev)
> +{
> +       struct fpga_manager *mgr = platform_get_drvdata(pdev);
> +       struct a10_fpga_priv *priv = mgr->priv;
> +
> +       fpga_mgr_unregister(&pdev->dev);
> +       clk_disable_unprepare(priv->clk);
> +       clk_put(priv->clk);

Same here, if needed at all shouldn't it be devm_clk_put() ?

Cheers,

Moritz

  reply	other threads:[~2016-07-12 21:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-12 19:07 [PATCH 0/2] FPGA Manager support for Arria10 Alan Tull
2016-07-12 19:07 ` [PATCH 1/2] ARM: socfpga: add bindings doc for arria10 fpga manager Alan Tull
2016-07-16 22:06   ` Rob Herring
2016-07-19  2:39     ` atull
2016-07-17 20:40   ` Moritz Fischer
2016-07-19 13:45     ` atull
2016-07-12 19:07 ` [PATCH 2/2] fpga-manager: Add Socfpga Arria10 support Alan Tull
2016-07-12 21:31   ` Moritz Fischer [this message]
2016-07-12 22:20     ` Russell King - ARM Linux
2016-07-13 14:47       ` atull
2016-07-13 14:58     ` atull

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAAtXAHfSBzLisqBgF4Vry0vrcL3+DB4b1ctMOrTdOq5ue4D7JQ@mail.gmail.com \
    --to=moritz.fischer@ettus.com \
    --cc=atull@opensource.altera.com \
    --cc=delicious.quinoa@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dinguyen@opensource.altera.com \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).