public inbox for linux-ide@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
To: Tejun Heo <tj@kernel.org>, Hans de Goede <hdegoede@redhat.com>,
	devicetree@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Pawel Moll <pawel.moll@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Kumar Gala <galak@codeaurora.org>
Cc: linux-ide@vger.kernel.org, Nadav Haklai <nadavh@marvell.com>,
	Lior Amsalem <alior@marvell.com>, Hanna Hawa <hannah@marvell.com>,
	Yehuda Yitschak <yehuday@marvell.com>,
	Jason Cooper <jason@lakedaemon.net>, Andrew Lunn <andrew@lunn.ch>,
	Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
	Gregory Clement <gregory.clement@free-electrons.com>,
	Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Subject: [PATCH 1/5] ata: ahci: add support for non-standard port offset/length
Date: Fri, 22 Apr 2016 16:32:37 +0200	[thread overview]
Message-ID: <1461335561-18363-2-git-send-email-thomas.petazzoni@free-electrons.com> (raw)
In-Reply-To: <1461335561-18363-1-git-send-email-thomas.petazzoni@free-electrons.com>

By default, the AHCI registers start at a base of 0x100 bytes from the
base register address, and have a length of 0x80 bytes for each
port. Unfortunately, the ARM64 Marvell Armada 7K/8K deviates from this
default, with a base of 0x10000 bytes and a register length of 0x10000
bytes per port.

In order to support the Armada 7K/8K AHCI controller easily, this
commit extends the ahci_host_priv structure with two members:

 - port_offset, which contains the offset from the base, which
   defaults to AHCI_DEFAULT_PORT_OFFSET (0x100 bytes)

 - port_length, which contains the length of the per-port register
   area, which defaults to AHCI_DEFAULT_PORT_LENGTH (0x80 bytes)

This commit adds the structure members, initializes them to their
default value in ahci_platform_get_resources() and uses those
structure members were appropriate in the AHCI core.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 drivers/ata/ahci.c             | 5 +++--
 drivers/ata/ahci.h             | 7 ++++++-
 drivers/ata/libahci_platform.c | 7 ++++++-
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index a83bbcc..a695c17 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -1714,10 +1714,11 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	for (i = 0; i < host->n_ports; i++) {
 		struct ata_port *ap = host->ports[i];
+		unsigned int offset =
+			hpriv->port_offset + ap->port_no * hpriv->port_length;
 
 		ata_port_pbar_desc(ap, ahci_pci_bar, -1, "abar");
-		ata_port_pbar_desc(ap, ahci_pci_bar,
-				   0x100 + ap->port_no * 0x80, "port");
+		ata_port_pbar_desc(ap, ahci_pci_bar, offset, "port");
 
 		/* set enclosure management message type */
 		if (ap->flags & ATA_FLAG_EM)
diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h
index 70b06bc..aca6bb2 100644
--- a/drivers/ata/ahci.h
+++ b/drivers/ata/ahci.h
@@ -326,6 +326,9 @@ struct ahci_port_priv {
 	char			*irq_desc;	/* desc in /proc/interrupts */
 };
 
+#define AHCI_DEFAULT_PORT_OFFSET	0x100
+#define AHCI_DEFAULT_PORT_LENGTH	0x80
+
 struct ahci_host_priv {
 	/* Input fields */
 	unsigned int		flags;		/* AHCI_HFLAG_* */
@@ -333,6 +336,8 @@ struct ahci_host_priv {
 	u32			mask_port_map;	/* mask out particular bits */
 
 	void __iomem *		mmio;		/* bus-independent mem map */
+	u32			port_offset;	/* offset of ports from base */
+	u32			port_length;	/* length of per-port area */
 	u32			cap;		/* cap to use */
 	u32			cap2;		/* cap2 to use */
 	u32			version;	/* cached version */
@@ -433,7 +438,7 @@ static inline void __iomem *__ahci_port_base(struct ata_host *host,
 	struct ahci_host_priv *hpriv = host->private_data;
 	void __iomem *mmio = hpriv->mmio;
 
-	return mmio + 0x100 + (port_no * 0x80);
+	return mmio + hpriv->port_offset + (port_no * hpriv->port_length);
 }
 
 static inline void __iomem *ahci_port_base(struct ata_port *ap)
diff --git a/drivers/ata/libahci_platform.c b/drivers/ata/libahci_platform.c
index aaa761b..727fe66 100644
--- a/drivers/ata/libahci_platform.c
+++ b/drivers/ata/libahci_platform.c
@@ -371,6 +371,9 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev)
 		goto err_out;
 	}
 
+	hpriv->port_offset = AHCI_DEFAULT_PORT_OFFSET;
+	hpriv->port_length = AHCI_DEFAULT_PORT_LENGTH;
+
 	for (i = 0; i < AHCI_MAX_CLKS; i++) {
 		/*
 		 * For now we must use clk_get(dev, NULL) for the first clock,
@@ -556,10 +559,12 @@ int ahci_platform_init_host(struct platform_device *pdev,
 
 	for (i = 0; i < host->n_ports; i++) {
 		struct ata_port *ap = host->ports[i];
+		unsigned int offset =
+			hpriv->port_offset + ap->port_no * hpriv->port_length;
 
 		ata_port_desc(ap, "mmio %pR",
 			      platform_get_resource(pdev, IORESOURCE_MEM, 0));
-		ata_port_desc(ap, "port 0x%x", 0x100 + ap->port_no * 0x80);
+		ata_port_desc(ap, "port 0x%x", offset);
 
 		/* set enclosure management message type */
 		if (ap->flags & ATA_FLAG_EM)
-- 
2.6.4


  reply	other threads:[~2016-04-22 14:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-22 14:32 [PATCH 0/5] ata: add support for Marvell Armada 7K/8K AHCI Thomas Petazzoni
2016-04-22 14:32 ` Thomas Petazzoni [this message]
     [not found]   ` <1461335561-18363-2-git-send-email-thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2016-04-22 17:59     ` [PATCH 1/5] ata: ahci: add support for non-standard port offset/length Tejun Heo
2016-04-27 12:22       ` Thomas Petazzoni
     [not found]         ` <20160427142250.12764279-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2016-05-02 16:38           ` Tejun Heo
2016-04-22 14:32 ` [PATCH 2/5] ata: acard-ahci: use the new port_{offset,length} members Thomas Petazzoni
2016-04-22 14:32 ` [PATCH 3/5] ata: ahci_ceva: " Thomas Petazzoni
2016-04-22 14:32 ` [PATCH 4/5] ata: ahci_mvebu: add support for Armada 8K Thomas Petazzoni
2016-04-22 14:32 ` [PATCH 5/5] dt-bindings: ata: add compatible string for Armada 8K to ahci-platform Thomas Petazzoni
2016-04-25 12:47   ` Rob Herring
2016-05-19  8:19 ` [PATCH 0/5] ata: add support for Marvell Armada 7K/8K AHCI Thomas Petazzoni

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=1461335561-18363-2-git-send-email-thomas.petazzoni@free-electrons.com \
    --to=thomas.petazzoni@free-electrons.com \
    --cc=alior@marvell.com \
    --cc=andrew@lunn.ch \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=gregory.clement@free-electrons.com \
    --cc=hannah@marvell.com \
    --cc=hdegoede@redhat.com \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=jason@lakedaemon.net \
    --cc=linux-ide@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=nadavh@marvell.com \
    --cc=pawel.moll@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=sebastian.hesselbarth@gmail.com \
    --cc=tj@kernel.org \
    --cc=yehuday@marvell.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