linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Magnus Damm <magnus.damm@gmail.com>
To: linux-pci@vger.kernel.org
Cc: horms@verge.net.au, linux-sh@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	valentine.barshak@cogentembedded.com, ben.dooks@codethink.co.uk,
	geert@linux-m68k.org, bhelgaas@google.com,
	Magnus Damm <magnus.damm@gmail.com>
Subject: [PATCH v2 05/08] PCI: rcar: Break out window size handling
Date: Thu, 13 Feb 2014 03:03:53 +0000	[thread overview]
Message-ID: <20140213030353.10398.71544.sendpatchset@w520> (raw)
In-Reply-To: <20140213030302.10398.37322.sendpatchset@w520>

From: Magnus Damm <damm@opensource.se>

Break out the hard coded window size code to allow
dynamic setup. The window size is still left at 1GiB
but with this patch changing window size is easy for
testing.

Signed-off-by: Magnus Damm <damm@opensource.se>
---

Changes since V1:
 - Updated to fit on top of patches from Ben Dooks

 drivers/pci/host/pci-rcar-gen2.c |   31 ++++++++++++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)

--- 0007/drivers/pci/host/pci-rcar-gen2.c
+++ work/drivers/pci/host/pci-rcar-gen2.c	2014-02-13 10:16:48.000000000 +0900
@@ -18,6 +18,7 @@
 #include <linux/pci.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
+#include <linux/sizes.h>
 #include <linux/slab.h>
 
 /* AHB-PCI Bridge PCI communication registers */
@@ -98,6 +99,7 @@ struct rcar_pci_priv {
 	struct resource mem_res;
 	struct resource *cfg_res;
 	int irq;
+	unsigned long window_size;
 };
 
 /* PCI configuration space operations */
@@ -241,10 +243,31 @@ static int __init rcar_pci_setup(int nr,
 	iowrite32(val, reg + RCAR_USBCTR_REG);
 	udelay(4);
 
-	/* De-assert reset and set PCIAHB window1 size to 1GB */
+	/* De-assert reset and reset PCIAHB window1 size */
 	val &= ~(RCAR_USBCTR_PCIAHB_WIN1_MASK | RCAR_USBCTR_PCICLK_MASK |
 		 RCAR_USBCTR_USBH_RST | RCAR_USBCTR_PLL_RST);
-	iowrite32(val | RCAR_USBCTR_PCIAHB_WIN1_1G, reg + RCAR_USBCTR_REG);
+
+	/* Setup PCIAHB window1 size */
+	switch (priv->window_size) {
+	case SZ_2G:
+		val |= RCAR_USBCTR_PCIAHB_WIN1_2G;
+		break;
+	case SZ_1G:
+		val |= RCAR_USBCTR_PCIAHB_WIN1_1G;
+		break;
+	case SZ_512M:
+		val |= RCAR_USBCTR_PCIAHB_WIN1_512M;
+		break;
+	default:
+		pr_warn("unknown window size %ld - defaulting to 256M\n",
+			priv->window_size);
+		priv->window_size = SZ_256M;
+		/* fall-through */
+	case SZ_256M:
+		val |= RCAR_USBCTR_PCIAHB_WIN1_256M;
+		break;
+	}
+	iowrite32(val, reg + RCAR_USBCTR_REG);
 
 	/* Configure AHB master and slave modes */
 	iowrite32(RCAR_AHB_BUS_MODE, reg + RCAR_AHB_BUS_CTR_REG);
@@ -255,7 +278,7 @@ static int __init rcar_pci_setup(int nr,
 	       RCAR_PCI_ARBITER_PCIBP_MODE;
 	iowrite32(val, reg + RCAR_PCI_ARBITER_CTR_REG);
 
-	/* PCI-AHB mapping: 0x40000000-0x80000000 */
+	/* PCI-AHB mapping: 0x40000000 base */
 	iowrite32(0x40000000 | RCAR_PCIAHB_PREFETCH16,
 		  reg + RCAR_PCIAHB_WIN1_CTR_REG);
 
@@ -341,6 +364,8 @@ static int rcar_pci_probe(struct platfor
 		return priv->irq;
 	}
 
+	priv->window_size = SZ_1G;
+
 	hw_private[0] = priv;
 	memset(&hw, 0, sizeof(hw));
 	hw.nr_controllers = ARRAY_SIZE(hw_private);

  parent reply	other threads:[~2014-02-13  3:03 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-13  3:03 [PATCH 00/08] PCI: rcar: Recent driver patches from Ben Dooks and me Magnus Damm
2014-02-13  3:03 ` [PATCH 01/08] PCI: rcar: check platform_get_irq() return code Magnus Damm
2014-02-13  3:03 ` [PATCH v2 02/08] PCI: rcar: add error interrupt handling Magnus Damm
2014-02-13  3:03 ` [PATCH 03/08] PCI: rcar: fix bridge logic configuration accesses Magnus Damm
2014-02-13  3:03 ` [PATCH v2 04/08] PCI: rcar: Register each instance independently Magnus Damm
2014-02-13  3:03 ` Magnus Damm [this message]
2014-02-13  3:04 ` [PATCH v2 06/08] PCI: rcar: Add DMABOUNCE support Magnus Damm
2014-02-13  3:04 ` [PATCH 07/08] PCI: rcar: Enable BOUNCE in case of HIGHMEM Magnus Damm
2014-02-13  3:04 ` [PATCH 08/08] PCI: rcar: Make the Kconfig dependencies more generic Magnus Damm
2014-02-13  4:39 ` [PATCH 00/08] PCI: rcar: Recent driver patches from Ben Dooks and me Simon Horman
2014-02-14 18:34   ` Bjorn Helgaas
2014-02-17  1:12     ` Simon Horman
2014-02-13 12:34 ` Ben Dooks
2014-02-14  5:40   ` Magnus Damm
2014-02-14 10:52     ` Ben Dooks
  -- strict thread matches above, loose matches on Subject: below --
2014-02-18  2:10 [PATCH v2 00/08] PCI: rcar: Recent driver patches from Ben Dooks and me (V2) Magnus Damm
2014-02-18  2:11 ` [PATCH v2 05/08] PCI: rcar: Break out window size handling Magnus Damm

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=20140213030353.10398.71544.sendpatchset@w520 \
    --to=magnus.damm@gmail.com \
    --cc=ben.dooks@codethink.co.uk \
    --cc=bhelgaas@google.com \
    --cc=geert@linux-m68k.org \
    --cc=horms@verge.net.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=valentine.barshak@cogentembedded.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).