From: Jon Derrick <jonathan.derrick@intel.com>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: <linux-pci@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
Andy Shevchenko <andriy.shevchenko@intel.com>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
Pawel Baldysiak <pawel.baldysiak@intel.com>,
Sinan Kaya <okaya@kernel.org>,
Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
Keith Busch <kbusch@kernel.org>,
Alexandru Gagniuc <mr.nuke.me@gmail.com>,
Christoph Hellwig <hch@lst.de>,
Jon Derrick <jonathan.derrick@intel.com>
Subject: [RFC 3/9] PCI: pci-bridge-emul: Provide a helper to set behavior
Date: Fri, 7 Feb 2020 17:00:01 -0700 [thread overview]
Message-ID: <1581120007-5280-4-git-send-email-jonathan.derrick@intel.com> (raw)
In-Reply-To: <1581120007-5280-1-git-send-email-jonathan.derrick@intel.com>
Add a handler to set behavior of a PCI or PCIe register. Add the
appropriate enums to specify the register's Read-Only, Read-Write, and
Write-1-to-Clear behaviors.
Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
---
drivers/pci/pci-bridge-emul.c | 19 +++++++++++++++++++
drivers/pci/pci-bridge-emul.h | 10 ++++++++++
2 files changed, 29 insertions(+)
diff --git a/drivers/pci/pci-bridge-emul.c b/drivers/pci/pci-bridge-emul.c
index e0567ca..aa18091 100644
--- a/drivers/pci/pci-bridge-emul.c
+++ b/drivers/pci/pci-bridge-emul.c
@@ -44,6 +44,25 @@ struct pci_bridge_reg_behavior {
u32 w1c;
};
+void pci_bridge_emul_set_reg_behavior(struct pci_bridge_emul *bridge,
+ bool pcie, int reg, u32 val,
+ enum pci_bridge_emul_reg_behavior type)
+{
+ struct pci_bridge_reg_behavior *behavior;
+
+ if (pcie)
+ behavior = &bridge->pcie_cap_regs_behavior[reg / 4];
+ else
+ behavior = &bridge->pci_regs_behavior[reg / 4];
+
+ if (type == PCI_BRIDGE_EMUL_REG_BEHAVIOR_RO)
+ behavior->ro = val;
+ else if (type == PCI_BRIDGE_EMUL_REG_BEHAVIOR_RW)
+ behavior->rw = val;
+ else /* PCI_BRIDGE_EMUL_REG_BEHAVIOR_W1C */
+ behavior->w1c = val;
+}
+
static const struct pci_bridge_reg_behavior pci_regs_behavior[] = {
[PCI_VENDOR_ID / 4] = { .ro = ~0 },
[PCI_COMMAND / 4] = {
diff --git a/drivers/pci/pci-bridge-emul.h b/drivers/pci/pci-bridge-emul.h
index b318830..f7027e1 100644
--- a/drivers/pci/pci-bridge-emul.h
+++ b/drivers/pci/pci-bridge-emul.h
@@ -72,6 +72,12 @@ struct pci_bridge_emul_pcie_conf {
typedef enum { PCI_BRIDGE_EMUL_HANDLED,
PCI_BRIDGE_EMUL_NOT_HANDLED } pci_bridge_emul_read_status_t;
+enum pci_bridge_emul_reg_behavior {
+ PCI_BRIDGE_EMUL_REG_BEHAVIOR_RO,
+ PCI_BRIDGE_EMUL_REG_BEHAVIOR_RW,
+ PCI_BRIDGE_EMUL_REG_BEHAVIOR_W1C,
+};
+
struct pci_bridge_emul_ops {
/*
* Called when reading from the regular PCI bridge
@@ -132,4 +138,8 @@ int pci_bridge_emul_conf_read(struct pci_bridge_emul *bridge, int where,
int pci_bridge_emul_conf_write(struct pci_bridge_emul *bridge, int where,
int size, u32 value);
+void pci_bridge_emul_set_reg_behavior(struct pci_bridge_emul *bridge,
+ bool pcie, int reg, u32 val,
+ enum pci_bridge_emul_reg_behavior type);
+
#endif /* __PCI_BRIDGE_EMUL_H__ */
--
1.8.3.1
next prev parent reply other threads:[~2020-02-08 0:00 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-07 23:59 [RFC 0/9] PCIe Hotplug Slot Emulation driver Jon Derrick
2020-02-07 23:59 ` [RFC 1/9] PCI: pci-bridge-emul: Update PCIe register behaviors Jon Derrick
2020-02-08 9:55 ` Andy Shevchenko
2020-03-28 21:42 ` Bjorn Helgaas
2020-02-08 0:00 ` [RFC 2/9] PCI: pci-bridge-emul: Eliminate reserved member Jon Derrick
2020-03-28 21:43 ` Bjorn Helgaas
2020-02-08 0:00 ` Jon Derrick [this message]
2020-02-08 0:00 ` [RFC 4/9] PCI: pciehp: Indirect slot register operations Jon Derrick
2020-02-08 0:00 ` [RFC 5/9] PCI: Add pcie_port_slot_emulated stub Jon Derrick
2020-02-08 0:00 ` [RFC 6/9] PCI: pciehp: Expose the poll loop to other drivers Jon Derrick
2020-02-08 0:00 ` [RFC 7/9] PCI: Move pci_dev_str_match to search.c Jon Derrick
2020-02-08 0:00 ` [RFC 8/9] PCI: pciehp: Add hotplug slot emulation driver Jon Derrick
2020-02-08 0:00 ` [RFC 9/9] PCI: pciehp: Wire up pcie_port_emulate_slot and pciehp_emul Jon Derrick
2020-02-10 7:01 ` [RFC 0/9] PCIe Hotplug Slot Emulation driver Christoph Hellwig
2020-02-10 15:05 ` Derrick, Jonathan
2020-02-10 16:58 ` hch
2020-02-10 17:09 ` Derrick, Jonathan
2020-03-28 21:51 ` Bjorn Helgaas
2020-03-30 17:43 ` Derrick, Jonathan
2020-03-30 17:49 ` hch
2020-04-01 21:45 ` Bjorn Helgaas
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=1581120007-5280-4-git-send-email-jonathan.derrick@intel.com \
--to=jonathan.derrick@intel.com \
--cc=andriy.shevchenko@intel.com \
--cc=hch@lst.de \
--cc=helgaas@kernel.org \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=mika.westerberg@linux.intel.com \
--cc=mr.nuke.me@gmail.com \
--cc=okaya@kernel.org \
--cc=pawel.baldysiak@intel.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).