From patchwork Wed Jan 18 13:19:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 9523761 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5C6716020A for ; Wed, 18 Jan 2017 13:24:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D5E7285EB for ; Wed, 18 Jan 2017 13:24:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 405CC285EC; Wed, 18 Jan 2017 13:24:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DCB7E20246 for ; Wed, 18 Jan 2017 13:24:47 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cTqEH-0002tx-Cn; Wed, 18 Jan 2017 13:24:45 +0000 Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cTqAT-0006lU-AW for linux-arm-kernel@lists.infradead.org; Wed, 18 Jan 2017 13:20:52 +0000 Received: by mail-wm0-x231.google.com with SMTP id r126so244765511wmr.0 for ; Wed, 18 Jan 2017 05:20:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hFmDM2GBJ/vTixiXlDl8X9Ccc8JDAS1MatMHD9xw8Bw=; b=rrGKLiw1dNZt2Fxw+6U4YaIvmpWvN/cpC9uN4dPMyHs3MSy9WZSp9EgdLOOY4DZY/S g4RpbM8mxH6MX1+5MI2Bc8i2uVohB7R7XenQzFncWzET77W9B4V70sozLa5C0LwYKAnU 6wJhacvwatNUsyLBy+IiqeXh3JqihECLoWKJMqVgfPB52V1zXYV7xpirvUr35yhjR8SY hE8cOIlxbKwdjMgTtWfltqztoHcBCI+7M4DXNxFW/taiigMAEHGSQWRccGiSnRrrW4Ks QsXYtvljgxxqJwoh8i+jXVOboEqA9rQp9B5BEN+i5wPfNBv0QdqYT0fnSP14mWgJSPrZ 5Deg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hFmDM2GBJ/vTixiXlDl8X9Ccc8JDAS1MatMHD9xw8Bw=; b=eJCuD51TuWgaNPfAU4bQEWcK3As2eL3vQMHdVh9XdamhO3IMYJnMIWdozIfel+Nqkb fups6WZiUW+5AwyYTOLxLW+zfzyQDFE8kRKUmUTs+TUHSi4k15cDbbx1/hO9bffetjMx b4kP9dF8+TlkdW5aaxVeKZHkIqslxHutWxb05STLOV8qofR9mr8ElpjSIRTnQqNoyMNn AciXKt1tdqRvi3knCg8GUEfRKkDx99jg15egipPMs6VqEcHL2mXGxS2M5xmEjcD0Ir3F R17lxD3k3tkq9HkU4iKdQbpbZTty3LaLOM+LG/sP1S5PuhCNuNLKPHd5Xu1p0iwG/S6c JVvA== X-Gm-Message-State: AIkVDXL0y2AlKm8gV6+59ZfFSmjvDNMhb3E1pC7FAmQU4m4ndounpdSw6kfTHwmVqZhdVWvb X-Received: by 10.28.6.210 with SMTP id 201mr22415427wmg.85.1484745627387; Wed, 18 Jan 2017 05:20:27 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id w79sm4899569wmw.0.2017.01.18.05.20.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 18 Jan 2017 05:20:26 -0800 (PST) From: Bartosz Golaszewski To: Kevin Hilman , Sekhar Nori , Patrick Titiano , Michael Turquette , Tejun Heo , Rob Herring , Mark Rutland , Russell King , David Lechner Subject: [PATCH v3 08/13] sata: ahci-da850: implement a workaround for the softreset quirk Date: Wed, 18 Jan 2017 14:19:56 +0100 Message-Id: <1484745601-4769-9-git-send-email-bgolaszewski@baylibre.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1484745601-4769-1-git-send-email-bgolaszewski@baylibre.com> References: <1484745601-4769-1-git-send-email-bgolaszewski@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170118_052049_635524_0A22EB06 X-CRM114-Status: GOOD ( 17.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-ide@vger.kernel.org, Bartosz Golaszewski , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP There's an issue with the da850 SATA controller: if port multiplier support is compiled in, but we're connecting the drive directly to the SATA port on the board, the drive can't be detected. To make SATA work on the da850-lcdk board: first try to softreset with pmp - if the operation fails with -EBUSY, retry without pmp. Signed-off-by: Bartosz Golaszewski --- drivers/ata/ahci_da850.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/ata/ahci_da850.c b/drivers/ata/ahci_da850.c index 7f5328f..11dd87e 100644 --- a/drivers/ata/ahci_da850.c +++ b/drivers/ata/ahci_da850.c @@ -54,11 +54,42 @@ static void da850_sata_init(struct device *dev, void __iomem *pwrdn_reg, writel(val, ahci_base + SATA_P0PHYCR_REG); } +static int ahci_da850_softreset(struct ata_link *link, + unsigned int *class, unsigned long deadline) +{ + int pmp, ret; + + pmp = sata_srst_pmp(link); + + /* + * There's an issue with the SATA controller on da850 SoCs: if we + * enable Port Multiplier support, but the drive is connected directly + * to the board, it can't be detected. As a workaround: if PMP is + * enabled, we first call ahci_do_softreset() and pass it the result of + * sata_srst_pmp(). If this call fails, we retry with pmp = 0. + */ + ret = ahci_do_softreset(link, class, pmp, deadline, ahci_check_ready); + if (pmp && ret == -EBUSY) + return ahci_do_softreset(link, class, 0, + deadline, ahci_check_ready); + + return ret; +} + +static struct ata_port_operations ahci_da850_port_ops = { + .inherits = &ahci_platform_ops, + .softreset = ahci_da850_softreset, + /* + * No need to override .pmp_softreset - it's only used for actual + * PMP-enabled ports. + */ +}; + static const struct ata_port_info ahci_da850_port_info = { .flags = AHCI_FLAG_COMMON, .pio_mask = ATA_PIO4, .udma_mask = ATA_UDMA6, - .port_ops = &ahci_platform_ops, + .port_ops = &ahci_da850_port_ops, }; static struct scsi_host_template ahci_platform_sht = {