linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Richard Zhu <r65037@freescale.com>
To: <linux-pci-owner@vger.kernel.org>
Cc: <linux-pci@vger.kernel.org>, <shawn.guo@freescale.com>,
	<festevam@gmail.com>, <l.stach@pengutronix.de>,
	<tharvey@gateworks.com>, Richard Zhu <r65037@freescale.com>
Subject: [PATCH v4 04/10] PCI: designware: refine setup_rc and add msi data restore
Date: Tue, 30 Sep 2014 17:36:38 +0800	[thread overview]
Message-ID: <1412069804-17162-5-git-send-email-r65037@freescale.com> (raw)
In-Reply-To: <1412069804-17162-1-git-send-email-r65037@freescale.com>

- move "program correct class for RC" from dw_pcie_host_init()
to dw_pcie_setup_rc(). since this is RC setup, it's
better to contained in dw_pcie_setup_rc function.
Then, RC can be re-setup really by dw_pcie_setup_rc().
- add one re-store msi data function. Because that
pcie controller maybe powered off during system suspend,
and the msi data configuration would be lost.
this functions can be used to restore the msi data
during the resume callback.

Signed-off-by: Richard Zhu <r65037@freescale.com>
---
 drivers/pci/host/pcie-designware.c | 15 ++++++++++++---
 drivers/pci/host/pcie-designware.h |  1 +
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/host/pcie-designware.c b/drivers/pci/host/pcie-designware.c
index 538bbf3..ae1e6c5 100644
--- a/drivers/pci/host/pcie-designware.c
+++ b/drivers/pci/host/pcie-designware.c
@@ -194,6 +194,13 @@ void dw_pcie_msi_init(struct pcie_port *pp)
 	dw_pcie_wr_own_conf(pp, PCIE_MSI_ADDR_HI, 4, 0);
 }
 
+void dw_pcie_msi_cfg_restore(struct pcie_port *pp)
+{
+	dw_pcie_wr_own_conf(pp, PCIE_MSI_ADDR_LO, 4,
+			virt_to_phys((void *)pp->msi_data));
+	dw_pcie_wr_own_conf(pp, PCIE_MSI_ADDR_HI, 4, 0);
+}
+
 static int find_valid_pos0(struct pcie_port *pp, int msgvec, int pos, int *pos0)
 {
 	int flag = 1;
@@ -570,9 +577,6 @@ int __init dw_pcie_host_init(struct pcie_port *pp)
 
 	dw_pcie_wr_own_conf(pp, PCI_BASE_ADDRESS_0, 4, 0);
 
-	/* program correct class for RC */
-	dw_pcie_wr_own_conf(pp, PCI_CLASS_DEVICE, 2, PCI_CLASS_BRIDGE_PCI);
-
 	dw_pcie_rd_own_conf(pp, PCIE_LINK_WIDTH_SPEED_CONTROL, 4, &val);
 	val |= PORT_LOGIC_SPEED_CHANGE;
 	dw_pcie_wr_own_conf(pp, PCIE_LINK_WIDTH_SPEED_CONTROL, 4, val);
@@ -917,6 +921,11 @@ void dw_pcie_setup_rc(struct pcie_port *pp)
 	val = memlimit | membase;
 	dw_pcie_writel_rc(pp, val, PCI_MEMORY_BASE);
 
+	/* program correct class for RC */
+	dw_pcie_readl_rc(pp, PCI_CLASS_REVISION, &val);
+	val |= PCI_CLASS_BRIDGE_PCI << 16;
+	dw_pcie_writel_rc(pp, val, PCI_CLASS_REVISION);
+
 	/* setup command register */
 	dw_pcie_readl_rc(pp, PCI_COMMAND, &val);
 	val &= 0xffff0000;
diff --git a/drivers/pci/host/pcie-designware.h b/drivers/pci/host/pcie-designware.h
index a476e60..bb75715 100644
--- a/drivers/pci/host/pcie-designware.h
+++ b/drivers/pci/host/pcie-designware.h
@@ -83,6 +83,7 @@ int dw_pcie_cfg_read(void __iomem *addr, int where, int size, u32 *val);
 int dw_pcie_cfg_write(void __iomem *addr, int where, int size, u32 val);
 irqreturn_t dw_handle_msi_irq(struct pcie_port *pp);
 void dw_pcie_msi_init(struct pcie_port *pp);
+void dw_pcie_msi_cfg_restore(struct pcie_port *pp);
 int dw_pcie_link_up(struct pcie_port *pp);
 void dw_pcie_setup_rc(struct pcie_port *pp);
 int dw_pcie_host_init(struct pcie_port *pp);
-- 
1.9.1


  parent reply	other threads:[~2014-09-30 10:07 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-30  9:36 [PATCH v4]PCI: imx6: enable pcie on imx6sx sdb and imx6qdl sabreauto Richard Zhu
2014-09-30  9:36 ` [PATCH v4 01/10] PCI: imx6: wait the clocks to stabilize after ref_en Richard Zhu
2014-09-30  9:36 ` [PATCH v4 02/10] PCI: imx6: add imx6sx pcie support Richard Zhu
2014-09-30 14:54   ` Lucas Stach
2014-10-02  2:38     ` Hong-Xing.Zhu
2014-10-08  7:30       ` Hong-Xing.Zhu
2014-09-30  9:36 ` [PATCH v4 03/10] PCI: imx6: Fix possible dead lock Richard Zhu
2014-09-30 14:57   ` Lucas Stach
2014-09-30  9:36 ` Richard Zhu [this message]
2014-09-30 14:58   ` [PATCH v4 04/10] PCI: designware: refine setup_rc and add msi data restore Lucas Stach
2014-10-08  6:45     ` Hong-Xing.Zhu
2014-09-30  9:36 ` [PATCH v4 05/10] PCI: designware: fix one potential assignment error of cfg start Richard Zhu
2014-09-30  9:36 ` [PATCH v4 06/10] ARM: imx6qdl: enable pcie on imx6qdl sabreauto Richard Zhu
2014-09-30  9:36 ` [PATCH v4 07/10] ARM: imx6: update dts and binding for imx6sx pcie Richard Zhu
2014-09-30  9:36 ` [PATCH v4 08/10] ARM: imx6sx: add syscon into gpc dts Richard Zhu
2014-09-30  9:36 ` [PATCH v4 09/10] ARM: imx6sx: add imx6sx pcie related gpr bits definitions Richard Zhu
2014-09-30  9:36 ` [PATCH v4 10/10] ARM: imx6sx: enable pcie on imx6sx sdb board Richard Zhu
2014-09-30 16:21   ` Fabio Estevam
2014-10-02  2:40     ` Hong-Xing.Zhu
2014-10-08  6:41       ` Hong-Xing.Zhu
2014-10-09  1:11         ` Fabio Estevam
2014-10-09  5:39           ` Hong-Xing.Zhu
  -- strict thread matches above, loose matches on Subject: below --
2014-09-30  9:19 [PATCH v4]PCI: imx6: enable pcie on imx6sx sdb and imx6qdl sabreauto Richard Zhu
2014-09-30  9:19 ` [PATCH v4 04/10] PCI: designware: refine setup_rc and add msi data restore Richard Zhu

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=1412069804-17162-5-git-send-email-r65037@freescale.com \
    --to=r65037@freescale.com \
    --cc=festevam@gmail.com \
    --cc=l.stach@pengutronix.de \
    --cc=linux-pci-owner@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=shawn.guo@freescale.com \
    --cc=tharvey@gateworks.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).