All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tim Harvey <tharvey@gateworks.com>
To: u-boot@lists.denx.de
Subject: [U-Boot]  [RFC/RESEND 17/22] ahci: support 64bit systems
Date: Mon,  4 Mar 2019 09:34:32 -0800	[thread overview]
Message-ID: <20190304173437.26989-18-tharvey@gateworks.com> (raw)
In-Reply-To: <20190304173437.26989-1-tharvey@gateworks.com>

Signed-off-by: Tim Harvey <tharvey@gateworks.com>
---
 drivers/ata/ahci.c | 26 +++++++++++++++++---------
 include/ahci.h     |  3 +++
 2 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index d6753f140d..81d16925dd 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -26,6 +26,9 @@
 #include <dm/device-internal.h>
 #include <dm/lists.h>
 
+#define LOWER32(val)	(u32)((u64)(val) & 0xffffffff)
+#define UPPER32(val)	(u32)(((u64)(val) & 0xffffffff00000000) >> 32)
+
 static int ata_io_flush(struct ahci_uc_priv *uc_priv, u8 port);
 
 #ifndef CONFIG_DM_SCSI
@@ -517,8 +520,9 @@ static int ahci_fill_sg(struct ahci_uc_priv *uc_priv, u8 port,
 
 	for (i = 0; i < sg_count; i++) {
 		ahci_sg->addr =
-		    cpu_to_le32((unsigned long) buf + i * MAX_DATA_BYTE_COUNT);
-		ahci_sg->addr_hi = 0;
+			cpu_to_le32(LOWER32(buf + i * MAX_DATA_BYTE_COUNT));
+		ahci_sg->addr_hi =
+			cpu_to_le32(UPPER32(buf + i * MAX_DATA_BYTE_COUNT));
 		ahci_sg->flags_size = cpu_to_le32(0x3fffff &
 					  (buf_len < MAX_DATA_BYTE_COUNT
 					   ? (buf_len - 1)
@@ -535,11 +539,8 @@ static void ahci_fill_cmd_slot(struct ahci_ioports *pp, u32 opts)
 {
 	pp->cmd_slot->opts = cpu_to_le32(opts);
 	pp->cmd_slot->status = 0;
-	pp->cmd_slot->tbl_addr = cpu_to_le32((u32)pp->cmd_tbl & 0xffffffff);
-#ifdef CONFIG_PHYS_64BIT
-	pp->cmd_slot->tbl_addr_hi =
-	    cpu_to_le32((u32)(((pp->cmd_tbl) >> 16) >> 16));
-#endif
+	pp->cmd_slot->tbl_addr = cpu_to_le32(LOWER32(pp->cmd_tbl));
+	pp->cmd_slot->tbl_addr_hi = cpu_to_le32(UPPER32(pp->cmd_tbl));
 }
 
 static int wait_spinup(void __iomem *port_mmio)
@@ -609,10 +610,17 @@ static int ahci_port_start(struct ahci_uc_priv *uc_priv, u8 port)
 	pp->cmd_tbl_sg =
 			(struct ahci_sg *)(uintptr_t)virt_to_phys((void *)mem);
 
-	writel_with_flush((unsigned long)pp->cmd_slot,
+	if (uc_priv->cap & HOST_CAP_64)
+		writel_with_flush(cpu_to_le32(UPPER32(pp->cmd_slot)),
+				  port_mmio + PORT_LST_ADDR_HI);
+	writel_with_flush(cpu_to_le32(LOWER32(pp->cmd_slot)),
 			  port_mmio + PORT_LST_ADDR);
 
-	writel_with_flush(pp->rx_fis, port_mmio + PORT_FIS_ADDR);
+	if (uc_priv->cap & HOST_CAP_64)
+		writel_with_flush(cpu_to_le32(UPPER32(pp->rx_fis)),
+				  port_mmio + PORT_FIS_ADDR_HI);
+	writel_with_flush(cpu_to_le32(LOWER32(pp->rx_fis)),
+			  port_mmio + PORT_FIS_ADDR);
 
 #ifdef CONFIG_SUNXI_AHCI
 	sunxi_dma_init(port_mmio);
diff --git a/include/ahci.h b/include/ahci.h
index b42df6c77e..6e439c184c 100644
--- a/include/ahci.h
+++ b/include/ahci.h
@@ -40,6 +40,9 @@
 #define HOST_IRQ_EN		(1 << 1)  /* global IRQ enable */
 #define HOST_AHCI_EN		(1 << 31) /* AHCI enabled */
 
+/* HOST_CAP bits */
+#define HOST_CAP_64		(1 << 31) /* 64-bit addressing supported */
+
 /* Registers for each SATA port */
 #define PORT_LST_ADDR		0x00 /* command list DMA addr */
 #define PORT_LST_ADDR_HI	0x04 /* command list DMA addr hi */
-- 
2.17.1

  parent reply	other threads:[~2019-03-04 17:34 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-04 17:34 [U-Boot] [RFC/RESEND 00/22] Add support for Cavium Octeon-TX CN80XX/CN81XX Tim Harvey
2019-03-04 17:34 ` [U-Boot] [RFC/RESEND 01/22] arm: introduce ARCH_THUNDERX Tim Harvey
2019-03-04 19:05   ` Chandrakala Chavva
2019-03-04 20:07     ` Tim Harvey
2019-03-15 23:02       ` Tim Harvey
2019-03-22 18:23         ` Suneel Garapati
2019-05-07 15:10           ` Tim Harvey
2019-05-16 17:07             ` Suneel Garapati
     [not found]               ` <26d005ea-ec43-013c-a830-bc214dd44178@suse.com>
2019-08-01  0:32                 ` Suneel Garapati
2019-08-26 17:54                   ` Tim Harvey
2019-08-27  0:59                     ` [U-Boot] [EXT] " Chandrakala Chavva
2019-09-02 14:19                       ` Matthias Brugger
2019-09-04  6:03                         ` Suneel Garapati
2019-09-27  8:59                           ` Matthias Brugger
2019-10-28  5:34                             ` Suneel Garapati
2019-10-29 19:10                               ` Tim Harvey
2019-10-29 21:09                                 ` Suneel Garapati
2019-03-04 17:34 ` [U-Boot] [RFC/RESEND 02/22] arm: add thunderx_81xx Tim Harvey
2019-03-04 17:34 ` [U-Boot] [RFC/RESEND 03/22] thunderx: add FDT support Tim Harvey
2019-03-04 17:34 ` [U-Boot] [RFC/RESEND 04/22] thunderx: add thunderx register definitions and misc functions Tim Harvey
2019-03-04 17:34 ` [U-Boot] [RFC/RESEND 05/22] thunderx: move DRAM prints to debug Tim Harvey
2019-03-04 17:34 ` [U-Boot] [RFC/RESEND 06/22] dm: pci: add PCI SR-IOV EA support Tim Harvey
2019-03-04 17:34 ` [U-Boot] [RFC/RESEND 07/22] fdt: add fdtdec_get_pci_bus_range Tim Harvey
2019-03-04 17:34 ` [U-Boot] [RFC/RESEND 08/22] pci: add thunderx pci/ecam driver Tim Harvey
2019-03-04 17:34 ` [U-Boot] [RFC/RESEND 09/22] pci: fix pce enumeration on thunderx Tim Harvey
2019-03-04 17:34 ` [U-Boot] [RFC/RESEND 10/22] arm: include 64bit io accessors Tim Harvey
2019-03-04 17:34 ` [U-Boot] [RFC/RESEND 11/22] gpio: add thunderx gpio driver Tim Harvey
2019-03-04 17:34 ` [U-Boot] [RFC/RESEND 12/22] i2c: add thunderx I2C driver Tim Harvey
2019-03-04 17:34 ` [U-Boot] [RFC/RESEND 13/22] spi: add thunderx SPI driver Tim Harvey
2019-03-04 17:34 ` [U-Boot] [RFC/RESEND 14/22] xhci: add support for cavium thunderx XHCI Tim Harvey
2019-03-04 17:34 ` [U-Boot] [RFC/RESEND 15/22] thunderx_81xx: add support for XHCI Tim Harvey
2019-03-04 17:34 ` [U-Boot] [RFC/RESEND 16/22] thunderx_81xx: enable usb mass storage and usb ethernet Tim Harvey
2019-03-04 17:34 ` Tim Harvey [this message]
2019-03-04 17:34 ` [U-Boot] [RFC/RESEND 18/22] ahci: set n_ports from host caps Tim Harvey
2019-03-04 17:34 ` [U-Boot] [RFC/RESEND 19/22] ahci: add support for ThunderX AHCI Tim Harvey
2019-03-04 17:34 ` [U-Boot] [RFC/RESEND 20/22] thunderx_81xx: add AHCI support Tim Harvey
2019-03-04 17:34 ` [U-Boot] [RFC/RESEND 21/22] net: add thunderx vnic drivers Tim Harvey
2019-03-04 17:34 ` [U-Boot] [RFC/RESEND 22/22] pci: auto probe thunderx NIC devices Tim Harvey

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=20190304173437.26989-18-tharvey@gateworks.com \
    --to=tharvey@gateworks.com \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.