From patchwork Thu Jun 15 03:28:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 776089 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3wp8Vf6wBTz9s65 for ; Thu, 15 Jun 2017 13:43:38 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="rhVum5Uw"; dkim-atps=neutral Received: by lists.denx.de (Postfix, from userid 105) id A771FC21CE7; Thu, 15 Jun 2017 03:39:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 6B243C21D07; Thu, 15 Jun 2017 03:30:41 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 96578C21D11; Thu, 15 Jun 2017 03:30:40 +0000 (UTC) Received: from mail-ot0-f174.google.com (mail-ot0-f174.google.com [74.125.82.174]) by lists.denx.de (Postfix) with ESMTPS id AF831C21CDF for ; Thu, 15 Jun 2017 03:30:08 +0000 (UTC) Received: by mail-ot0-f174.google.com with SMTP id k4so1591801otd.0 for ; Wed, 14 Jun 2017 20:30:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=PXpUBA1m4W3HW7DjcOxTswLxdmr0i3AGpphbtGIRXYU=; b=rhVum5UwNqE7mfpjZr7O1DlxJ7hOufZf2c81PQF5ctoMF7hAZHzp/1+gw6pNXSzo7b acvTmd1hHV1dO3XllF/wlJjH880LMLCwdYgjuLr1PGmAx++ew0HNEbaZEPJEGtLwncD+ cF2LkXoZhCT2Nn32V0JJfwEskyZLAJiIKp4jyLfdswoh6kmO6VECZXnGufnGIpTxAGFa DkesqOnS+Qpf9GCFEka817FfTR7zgG8E50Pcz4I5rR+KTDVTgS88ikPNfAADOugWVtxP +6VcYhlRaIvKX+AFu5vD35OGcXoBpPl4VnTBDEsZN5eEQrSa5y9TptqwvKdIYgOnvYGu gkkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=PXpUBA1m4W3HW7DjcOxTswLxdmr0i3AGpphbtGIRXYU=; b=fwGodtifxzooUwUU8mouNh0zEXwdryLRTFnZFzR6QOgSO8AQ4lvOm/TrY33EE2KeoS k1x6Fo8gW1dqodQQwEBDqlvzpOdMXQvuNR/XW9749UfcXgK4VErfeGzvohG8Ud/yf04Q HCfHm2L9K5p7hD8L7iyaiInorqSI0O4B29Ow1BSoKGEvIbPimRp010WilGLJ7inPta+G 5BKhRTUyC5AZ76dg5mNg8GYxpLI1H7B/OhwTHDbqHS1SR4sCMuRKngx2FYG0tst09z6v 5BbWvHRJYTJpXC1qP1oeX3jqAkGJ6OOBaPvDT65apY+xghwN24ydqPLaOfhmKLiracJY Qe8w== X-Gm-Message-State: AKS2vOz52whG03NJmJA5Kct6mbh6OGB2/EhZuDy5B0Z6Cn47aj06E4sn LmL2hGFjCGXdvdFt X-Received: by 10.157.60.4 with SMTP id q4mr1880891otc.116.1497497407348; Wed, 14 Jun 2017 20:30:07 -0700 (PDT) Received: from kaki.bld.corp.google.com ([100.100.197.131]) by smtp.gmail.com with ESMTPSA id r133sm962831oif.41.2017.06.14.20.30.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Jun 2017 20:30:06 -0700 (PDT) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id A959040139; Wed, 14 Jun 2017 21:30:04 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Wed, 14 Jun 2017 21:28:33 -0600 Message-Id: <20170615032848.9343-15-sjg@chromium.org> X-Mailer: git-send-email 2.13.1.518.g3df882009-goog In-Reply-To: <20170615032848.9343-1-sjg@chromium.org> References: <20170615032848.9343-1-sjg@chromium.org> Subject: [U-Boot] [PATCH v2 14/29] dm: sata: Move ataid into struct ahci_uc_priv X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This array relates to the AHCI controller so should be exist out on its own in the file. Move it into the structure. Adjust functions that need access to this to take the structure as a parameter. Signed-off-by: Simon Glass Reviewed-by: Bin Meng Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- Changes in v2: None drivers/ata/ahci.c | 50 +++++++++++++++++++++++++++----------------------- include/ahci.h | 1 + 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 2caa29b4c5..3fb41de4c9 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c @@ -25,7 +25,6 @@ static int ata_io_flush(u8 port); struct ahci_uc_priv *probe_ent = NULL; -u16 *ataid[AHCI_MAX_PORTS]; #define writel_with_flush(a,b) do { writel(a,b); readl(b); } while (0) @@ -109,11 +108,11 @@ static int waiting_for_cmd_completed(void __iomem *offset, return (i < timeout_msec) ? 0 : -1; } -int __weak ahci_link_up(struct ahci_uc_priv *probe_ent, u8 port) +int __weak ahci_link_up(struct ahci_uc_priv *uc_priv, u8 port) { u32 tmp; int j = 0; - void __iomem *port_mmio = probe_ent->port[port].port_mmio; + void __iomem *port_mmio = uc_priv->port[port].port_mmio; /* * Bring up SATA link. @@ -555,7 +554,7 @@ static int wait_spinup(void __iomem *port_mmio) return -ETIMEDOUT; } -static int ahci_port_start(u8 port) +static int ahci_port_start(struct ahci_uc_priv *probe_ent, u8 port) { struct ahci_ioports *pp = &(probe_ent->port[port]); void __iomem *port_mmio = pp->port_mmio; @@ -689,7 +688,8 @@ static char *ata_id_strcpy(u16 *target, u16 *src, int len) /* * SCSI INQUIRY command operation. */ -static int ata_scsiop_inquiry(struct scsi_cmd *pccb) +static int ata_scsiop_inquiry(struct ahci_uc_priv *uc_priv, + struct scsi_cmd *pccb) { static const u8 hdr[] = { 0, @@ -726,15 +726,15 @@ static int ata_scsiop_inquiry(struct scsi_cmd *pccb) return -EIO; } - if (!ataid[port]) { - ataid[port] = malloc(ATA_ID_WORDS * 2); - if (!ataid[port]) { + if (!uc_priv->ataid[port]) { + uc_priv->ataid[port] = malloc(ATA_ID_WORDS * 2); + if (!uc_priv->ataid[port]) { printf("%s: No memory for ataid[port]\n", __func__); return -ENOMEM; } } - idbuf = ataid[port]; + idbuf = uc_priv->ataid[port]; memcpy(idbuf, tmpid, ATA_ID_WORDS * 2); ata_swap_buf_le16(idbuf, ATA_ID_WORDS); @@ -864,20 +864,21 @@ static int ata_scsiop_read_write(struct scsi_cmd *pccb, u8 is_write) /* * SCSI READ CAPACITY10 command operation. */ -static int ata_scsiop_read_capacity10(struct scsi_cmd *pccb) +static int ata_scsiop_read_capacity10(struct ahci_uc_priv *uc_priv, + struct scsi_cmd *pccb) { u32 cap; u64 cap64; u32 block_size; - if (!ataid[pccb->target]) { + if (!uc_priv->ataid[pccb->target]) { printf("scsi_ahci: SCSI READ CAPACITY10 command failure. " "\tNo ATA info!\n" "\tPlease run SCSI command INQUIRY first!\n"); return -EPERM; } - cap64 = ata_id_n_sectors(ataid[pccb->target]); + cap64 = ata_id_n_sectors(uc_priv->ataid[pccb->target]); if (cap64 > 0x100000000ULL) cap64 = 0xffffffff; @@ -894,19 +895,20 @@ static int ata_scsiop_read_capacity10(struct scsi_cmd *pccb) /* * SCSI READ CAPACITY16 command operation. */ -static int ata_scsiop_read_capacity16(struct scsi_cmd *pccb) +static int ata_scsiop_read_capacity16(struct ahci_uc_priv *uc_priv, + struct scsi_cmd *pccb) { u64 cap; u64 block_size; - if (!ataid[pccb->target]) { + if (!uc_priv->ataid[pccb->target]) { printf("scsi_ahci: SCSI READ CAPACITY16 command failure. " "\tNo ATA info!\n" "\tPlease run SCSI command INQUIRY first!\n"); return -EPERM; } - cap = ata_id_n_sectors(ataid[pccb->target]); + cap = ata_id_n_sectors(uc_priv->ataid[pccb->target]); cap = cpu_to_be64(cap); memcpy(pccb->pdata, &cap, sizeof(cap)); @@ -920,14 +922,16 @@ static int ata_scsiop_read_capacity16(struct scsi_cmd *pccb) /* * SCSI TEST UNIT READY command operation. */ -static int ata_scsiop_test_unit_ready(struct scsi_cmd *pccb) +static int ata_scsiop_test_unit_ready(struct ahci_uc_priv *uc_priv, + struct scsi_cmd *pccb) { - return (ataid[pccb->target]) ? 0 : -EPERM; + return (uc_priv->ataid[pccb->target]) ? 0 : -EPERM; } int scsi_exec(struct scsi_cmd *pccb) { + struct ahci_uc_priv *uc_priv = probe_ent; int ret; switch (pccb->cmd[0]) { @@ -939,16 +943,16 @@ int scsi_exec(struct scsi_cmd *pccb) ret = ata_scsiop_read_write(pccb, 1); break; case SCSI_RD_CAPAC10: - ret = ata_scsiop_read_capacity10(pccb); + ret = ata_scsiop_read_capacity10(uc_priv, pccb); break; case SCSI_RD_CAPAC16: - ret = ata_scsiop_read_capacity16(pccb); + ret = ata_scsiop_read_capacity16(uc_priv, pccb); break; case SCSI_TST_U_RDY: - ret = ata_scsiop_test_unit_ready(pccb); + ret = ata_scsiop_test_unit_ready(uc_priv, pccb); break; case SCSI_INQUIRY: - ret = ata_scsiop_inquiry(pccb); + ret = ata_scsiop_inquiry(uc_priv, pccb); break; default: printf("Unsupport SCSI command 0x%02x\n", pccb->cmd[0]); @@ -992,7 +996,7 @@ void scsi_low_level_init(int busdevfunc) for (i = 0; i < CONFIG_SYS_SCSI_MAX_SCSI_ID; i++) { if (((linkmap >> i) & 0x01)) { - if (ahci_port_start((u8) i)) { + if (ahci_port_start(probe_ent, (u8) i)) { printf("Can not start port %d\n", i); continue; } @@ -1035,7 +1039,7 @@ int ahci_init(void __iomem *base) for (i = 0; i < CONFIG_SYS_SCSI_MAX_SCSI_ID; i++) { if (((linkmap >> i) & 0x01)) { - if (ahci_port_start((u8) i)) { + if (ahci_port_start(probe_ent, (u8) i)) { printf("Can not start port %d\n", i); continue; } diff --git a/include/ahci.h b/include/ahci.h index 1f441d1c80..4262ab75c8 100644 --- a/include/ahci.h +++ b/include/ahci.h @@ -162,6 +162,7 @@ struct ahci_uc_priv { pci_dev_t dev; #endif struct ahci_ioports port[AHCI_MAX_PORTS]; + u16 *ataid[AHCI_MAX_PORTS]; u32 n_ports; u32 hard_port_no; u32 host_flags;