linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Wu, Hao" <hao.wu@intel.com>
To: Alan Tull <atull@kernel.org>,
	"matthew.gerlach@linux.intel.com"
	<matthew.gerlach@linux.intel.com>
Cc: "vndao@altera.com" <vndao@altera.com>,
	David Woodhouse <dwmw2@infradead.org>,
	"computersforpeace@gmail.com" <computersforpeace@gmail.com>,
	"boris.brezillon@free-electrons.com" 
	<boris.brezillon@free-electrons.com>,
	"marek.vasut@gmail.com" <marek.vasut@gmail.com>,
	"richard@nod.at" <richard@nod.at>,
	"cyrille.pitchen@wedev4u.fr" <cyrille.pitchen@wedev4u.fr>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	"linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"David S. Miller" <davem@davemloft.net>,
	"mchehab@kernel.org" <mchehab@kernel.org>,
	"linux-fpga@vger.kernel.org" <linux-fpga@vger.kernel.org>,
	"Whisonant, Tim" <tim.whisonant@intel.com>,
	"Luebbers, Enno" <enno.luebbers@intel.com>,
	"Rao, Shiva" <shiva.rao@intel.com>,
	"Rauer, Christopher" <christopher.rauer@intel.com>,
	"Kang, Luwei" <luwei.kang@intel.com>
Subject: RE: [PATCH 3/3] fpga: intel: Add QSPI FPGA Management Entity Feature
Date: Mon, 14 Aug 2017 13:30:48 +0000	[thread overview]
Message-ID: <BE8371DA886269458E0220A16DC1F8277E07D637@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <CANk1AXQmRi9UA6xP9YbyeOLynXET_t1CyZMHK76-CaunfZexAA@mail.gmail.com>

> On Sun, Aug 6, 2017 at 1:24 PM,  <matthew.gerlach@linux.intel.com> wrote:
> 
> + Wu Hao and the people who signed off on the Intel feature-dev stuff.
> 
> Hi Matthew,
> 
> By the way, this patch is against v1 of their patchset.  They have v2 out.
> 
> You could submit your next version with more conventional numbering
> and just note that the last patch is dependent on the Intel fpga
> patchset.
> 
> > From: Matthew Gerlach <matthew.gerlach@linux.intel.com>
> >
> > Add FPGA Management Entity Feature to support Atera
> > ASMI Parallel 2 IP core. This feature allows
> > the flash used to configure the FPGA at power up
> > to be updated over PCIe using mtd-utils.
> >
> > Signed-off-by: Matthew Gerlach <matthew.gerlach@linux.intel.com>
> > ---
> >  drivers/fpga/intel/feature-dev.h |   6 ++-
> >  drivers/fpga/intel/fme-main.c    | 100
> +++++++++++++++++++++++++++++++++++++++
> >  drivers/fpga/intel/pcie.c        |   7 +++
> >  drivers/fpga/intel/pcie_check.c  |   6 +++
> >  4 files changed, 117 insertions(+), 2 deletions(-)
> 
> The Intel patchset creates a new way to enumerate generic devices on
> fpga's and not just FME's and ports.  But it involves touching 4 files
> and adding 100 lines to fme-main.c.  Is there a way that adding a new
> device could just mean adding a struct in the device driver itself and
> registering it with that framework?

I think this is a sub feature of FME module implemented in BBS (static region),
so it follows the same way as other sub feature (e.g partial reconfiguration -
intel-fme-pr), and it needs to modify the fme driver module. The only difference
here is it doesn't put its own code to a separated file like intel-fme-pr.c for FME
Partial Reconfiguration sub feature, so you see it adds more lines to fme-main.c.

Thanks
Hao

> 
> Alan
> 
> >
> > diff --git a/drivers/fpga/intel/feature-dev.h b/drivers/fpga/intel/feature-dev.h
> > index 9303828..5ae799b 100644
> > --- a/drivers/fpga/intel/feature-dev.h
> > +++ b/drivers/fpga/intel/feature-dev.h
> > @@ -40,6 +40,7 @@
> >  #define FME_FEATURE_GLOBAL_PERF     "fme_gperf"
> >  #define FME_FEATURE_GLOBAL_ERR      "fme_error"
> >  #define FME_FEATURE_PR_MGMT         "fme_pr"
> > +#define FME_FEATURE_QSPI_FLASH     "fme_qspi_flash"
> >
> >  #define PORT_FEATURE_HEADER         "port_hdr"
> >  #define PORT_FEATURE_UAFU           "port_uafu"
> > @@ -60,6 +61,7 @@
> >  #define FME_GLOBAL_PERF_REVISION       0
> >  #define FME_GLOBAL_ERR_REVISION        0
> >  #define FME_PR_MGMT_REVISION           1
> > +#define FME_QSPI_REVISION 0
> >
> >  #define PORT_HEADER_REVISION           0
> >  /* UAFU's header info depends on the downloaded GBS */
> > @@ -1225,9 +1227,9 @@ enum fme_feature_id {
> >         FME_FEATURE_ID_GLOBAL_PERF = 0x3,
> >         FME_FEATURE_ID_GLOBAL_ERR = 0x4,
> >         FME_FEATURE_ID_PR_MGMT = 0x5,
> > -
> > +       FME_FEATURE_ID_QSPI_FLASH = 0x6,
> >         /* one for fme header. */
> > -       FME_FEATURE_ID_MAX = 0x6,
> > +       FME_FEATURE_ID_MAX = 0x7,
> >  };
> >
> >  enum port_feature_id {
> > diff --git a/drivers/fpga/intel/fme-main.c b/drivers/fpga/intel/fme-main.c
> > index 776fe36..03aacb3 100644
> > --- a/drivers/fpga/intel/fme-main.c
> > +++ b/drivers/fpga/intel/fme-main.c
> > @@ -27,6 +27,7 @@
> >  #include <linux/uaccess.h>
> >  #include <linux/intel-fpga.h>
> >  #include <linux/fpga/fpga-mgr.h>
> > +#include <linux/mtd/altera-asmip2.h>
> >
> >  #include "feature-dev.h"
> >  #include "fme.h"
> > @@ -659,6 +660,101 @@ struct feature_ops power_mgmt_ops = {
> >         .uinit = power_mgmt_uinit,
> >  };
> >
> > +#define FLASH_CAPABILITY_OFT 8
> > +
> > +static int qspi_flash_init(struct platform_device *pdev,
> > +                          struct feature *feature)
> > +{
> > +       u64 reg;
> > +       struct altera_asmip2_plat_data qdata;
> > +       struct platform_device *cdev;
> > +       int ret = 0;
> > +       char name[40];
> > +
> > +       scnprintf(name, sizeof(name), "%s-%p", feature->name, feature->ioaddr);
> > +
> > +       reg = readq(feature->ioaddr + FLASH_CAPABILITY_OFT);
> > +       dev_info(&pdev->dev, "%s %s %d 0x%llx 0x%x 0x%x\n",
> > +                __func__, name, feature->resource_index,
> > +                reg, readl(feature->ioaddr + FLASH_CAPABILITY_OFT),
> > +                readl(feature->ioaddr + FLASH_CAPABILITY_OFT + 4));
> > +
> > +
> > +       cdev = platform_device_alloc(name, PLATFORM_DEVID_NONE);
> > +
> > +       if (!cdev) {
> > +               dev_err(&pdev->dev, "platform_device_alloc failed in %s\n",
> > +                       __func__);
> > +               return -ENOMEM;
> > +       }
> > +
> > +       cdev->dev.parent = &pdev->dev;
> > +
> > +       memset(&qdata, 0, sizeof(qdata));
> > +       qdata.csr_base = feature->ioaddr + FLASH_CAPABILITY_OFT;
> > +       qdata.num_chip_sel = 1;
> > +
> > +       ret = platform_device_add_data(cdev, &qdata, sizeof(qdata));
> > +
> > +       if (ret) {
> > +               dev_err(&pdev->dev, "platform_device_add_data in %s\n",
> > +                       __func__);
> > +               goto error;
> > +       }
> > +
> > +       cdev->driver_override = kstrdup(ALTERA_ASMIP2_DRV_NAME,
> GFP_KERNEL);
> > +
> > +       ret = platform_device_add(cdev);
> > +
> > +       if (ret) {
> > +               dev_err(&pdev->dev, "platform_device_add failed with %d\n",
> > +                       ret);
> > +               goto error;
> > +       }
> > +       return ret;
> > +
> > +error:
> > +       platform_device_put(cdev);
> > +       return ret;
> > +}
> > +
> > +static int qspi_match(struct device *dev, void *data)
> > +{
> > +       return !strcmp(dev_name(dev), data);
> > +}
> > +
> > +static void qspi_flash_uinit(struct platform_device *pdev,
> > +                            struct feature *feature)
> > +{
> > +       struct device *parent = &pdev->dev;
> > +       struct device *dev;
> > +       struct platform_device *cdev;
> > +       char name[40];
> > +
> > +       scnprintf(name, sizeof(name), "%s-%p", feature->name, feature->ioaddr);
> > +
> > +       dev = device_find_child(parent, name, qspi_match);
> > +
> > +       if (!dev) {
> > +               dev_err(&pdev->dev, "%s NOT found\n",
> ALTERA_ASMIP2_DRV_NAME);
> > +               return;
> > +       }
> > +
> > +       cdev = to_platform_device(dev);
> > +
> > +       if (!cdev) {
> > +               dev_err(&pdev->dev, "no platform container\n");
> > +               return;
> > +       }
> > +
> > +       platform_device_unregister(cdev);
> > +}
> > +
> > +struct feature_ops qspi_flash_ops = {
> > +       .init = qspi_flash_init,
> > +       .uinit = qspi_flash_uinit,
> > +};
> > +
> >  static struct feature_driver fme_feature_drvs[] = {
> >         {
> >                 .name = FME_FEATURE_HEADER,
> > @@ -685,6 +781,10 @@ static struct feature_driver fme_feature_drvs[] = {
> >                 .ops = &global_perf_ops,
> >         },
> >         {
> > +               .name = FME_FEATURE_QSPI_FLASH,
> > +               .ops = &qspi_flash_ops,
> > +       },
> > +       {
> >                 .ops = NULL,
> >         },
> >  };
> > diff --git a/drivers/fpga/intel/pcie.c b/drivers/fpga/intel/pcie.c
> > index a64151a..8f4f3e0 100644
> > --- a/drivers/fpga/intel/pcie.c
> > +++ b/drivers/fpga/intel/pcie.c
> > @@ -28,6 +28,7 @@
> >  #include <linux/uuid.h>
> >  #include <linux/kdev_t.h>
> >  #include <linux/mfd/core.h>
> > +#include <linux/mtd/altera-asmip2.h>
> >
> >  #include "feature-dev.h"
> >
> > @@ -617,6 +618,12 @@ static struct feature_info fme_features[] = {
> >                 .resource_size = sizeof(struct feature_fme_pr),
> >                 .feature_index = FME_FEATURE_ID_PR_MGMT,
> >                 .revision_id = FME_PR_MGMT_REVISION
> > +       },
> > +       {
> > +               .name = FME_FEATURE_QSPI_FLASH,
> > +               .resource_size = ALTERA_ASMIP2_RESOURCE_SIZE,
> > +               .feature_index = FME_FEATURE_ID_QSPI_FLASH,
> > +               .revision_id = FME_QSPI_REVISION
> >         }
> >  };
> >
> > diff --git a/drivers/fpga/intel/pcie_check.c b/drivers/fpga/intel/pcie_check.c
> > index e707d72..f0027e1 100644
> > --- a/drivers/fpga/intel/pcie_check.c
> > +++ b/drivers/fpga/intel/pcie_check.c
> > @@ -51,6 +51,11 @@
> >  #define FME_FEATURE_PR_MGMT_ID                 0x5
> >  #define FME_FEATURE_PR_MGMT_VERSION            0x0
> >
> > +#define FME_FEATURE_QSPI_FLASH_TYPE            DFH_TYPE_PRIVATE
> > +#define FME_FEATURE_QSPI_FLASH_NEXT_OFFSET     0x2000
> > +#define FME_FEATURE_QSPI_FLASH_ID
> FME_FEATURE_ID_QSPI_FLASH
> > +#define FME_FEATURE_QSPI_FLASH_VERSION         FME_QSPI_REVISION
> > +
> >  #define PORT_FEATURE_HEADER_TYPE               DFH_TYPE_AFU
> >  #define PORT_FEATURE_HEADER_NEXT_OFFSET                0x1000
> >  #define PORT_FEATURE_HEADER_ID                 DFH_CCI_VERSION
> > @@ -91,6 +96,7 @@ static struct feature_header default_fme_feature_hdr[]
> = {
> >         DEFAULT_REG(FME_FEATURE_GLOBAL_PERF),
> >         DEFAULT_REG(FME_FEATURE_GLOBAL_ERR),
> >         DEFAULT_REG(FME_FEATURE_PR_MGMT),
> > +       DEFAULT_REG(FME_FEATURE_QSPI_FLASH),
> >  };
> >
> >  void check_features_header(struct pci_dev *pdev, struct feature_header *hdr,
> > --
> > 2.7.4
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe devicetree" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html

      reply	other threads:[~2017-08-14 13:30 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-06 18:24 [PATCH 0/3] Altera ASMI Parallel II IP Core matthew.gerlach
2017-08-06 18:24 ` [PATCH 1/2] dt-bindings: mtd: " matthew.gerlach
2017-08-10 20:35   ` Rob Herring
2017-08-14 16:38     ` matthew.gerlach
2017-08-06 18:24 ` [PATCH 2/2] mtd: spi-nor: " matthew.gerlach
2017-08-06 19:27   ` Marek Vasut
2017-08-07 15:21     ` matthew.gerlach
2017-08-11 17:20   ` Cyrille Pitchen
2017-08-15 17:20     ` matthew.gerlach
2017-08-15 20:08       ` Cyrille Pitchen
2017-08-27 15:42         ` matthew.gerlach
2017-08-06 18:24 ` [PATCH 3/3] fpga: intel: Add QSPI FPGA Management Entity Feature matthew.gerlach
2017-08-07 15:47   ` Alan Tull
2017-08-14 13:30     ` Wu, Hao [this message]

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=BE8371DA886269458E0220A16DC1F8277E07D637@SHSMSX104.ccr.corp.intel.com \
    --to=hao.wu@intel.com \
    --cc=atull@kernel.org \
    --cc=boris.brezillon@free-electrons.com \
    --cc=christopher.rauer@intel.com \
    --cc=computersforpeace@gmail.com \
    --cc=cyrille.pitchen@wedev4u.fr \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=dwmw2@infradead.org \
    --cc=enno.luebbers@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-fpga@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=luwei.kang@intel.com \
    --cc=marek.vasut@gmail.com \
    --cc=mark.rutland@arm.com \
    --cc=matthew.gerlach@linux.intel.com \
    --cc=mchehab@kernel.org \
    --cc=richard@nod.at \
    --cc=robh+dt@kernel.org \
    --cc=shiva.rao@intel.com \
    --cc=tim.whisonant@intel.com \
    --cc=vndao@altera.com \
    /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).