From patchwork Fri Jan 13 12:38:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 91391 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp170262qgi; Fri, 13 Jan 2017 04:41:15 -0800 (PST) X-Received: by 10.98.39.133 with SMTP id n127mr22742469pfn.26.1484311275094; Fri, 13 Jan 2017 04:41:15 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id 20si12656614pfx.116.2017.01.13.04.41.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Jan 2017 04:41:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@baylibre-com.20150623.gappssmtp.com; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org 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 1cS1AO-0007qM-Vq; Fri, 13 Jan 2017 12:41:13 +0000 Received: from mail-wm0-x230.google.com ([2a00:1450:400c:c09::230]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cS18j-0003rw-E4 for linux-arm-kernel@lists.infradead.org; Fri, 13 Jan 2017 12:39:35 +0000 Received: by mail-wm0-x230.google.com with SMTP id r126so63373238wmr.0 for ; Fri, 13 Jan 2017 04:39:08 -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=cQGtOly4MXsK3ATTGP3f/LJRa8MZ5vODx/FwG/LvLIk=; b=VRhBOSTrka+Wwm1N5Ubytg2T3Vrgqz9olEgJt6/6020j0VHplLBRDQJy6Jp+wTzljT yQGe/2rAzFcvMqm1PaIKLo3rNLswBXBCVGjlYYftVUHCJGjK057RF7Mz36Jzljb/UscE Jr74zcynLRPhQsPZWEB8V5u3hSdpInvdWh6P9qwKaeFxThqShzBhvQWHIA71ZWfmTWeY bKF5RihuYV4WffszlX1w0EHZfOJtJY1Sv/dqEKVKpxP0FdJk5ChDYP8bcCDzSVEu+onw lJnHwCqKVJolq8tSH9U3pun8TGLCz73m2Ycn11PefUbSGqILbVZDED8U2lY11jkR+zo1 h9jw== 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=cQGtOly4MXsK3ATTGP3f/LJRa8MZ5vODx/FwG/LvLIk=; b=kmiymK5CKVjqWfLKFGfbFdWzDre/4dDkyXgxdkuMeFv38zr+wvJwdWTLP6L3NF3ziA FkjJ3vxlLDF1letYEtebYUK84NTXO7nMkyYqdzLc5V/PeD6VE/EXQE1qogjvaQy16L6i WqBPp1770hZ/mJ4bdVq9KOcWfdhmC4EZgUdg0PAU9D28OgBYllrmRwV/vpCxN0COSLZT 2NAtqXmtyUkuWYCSsqbeGOQJsNCrWSuRJJL4ZAzeuHpvRCMMNQ4vXsAA72dPwjFIFaAs oDMSSChIDTF/L3n6rZ+afyKo/7nPG4hbYRMmxtUgY3bzfSNjqWoUPa1CI2uyRWGlyDlw x1Cw== X-Gm-Message-State: AIkVDXLnNasaJwHhxd9Fded+1BERhnJDfeCktNEw2cKMeNpG2pOgkFSv3I9LVb0OlmWIVVvs X-Received: by 10.223.163.199 with SMTP id m7mr11603245wrb.60.1484311147591; Fri, 13 Jan 2017 04:39:07 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id y127sm4022680wmg.12.2017.01.13.04.39.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 13 Jan 2017 04:39:06 -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 07/10] sata: ahci_da850: add support for the da850, clk_multiplier DT property Date: Fri, 13 Jan 2017 13:38:01 +0100 Message-Id: <1484311084-31547-8-git-send-email-bgolaszewski@baylibre.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1484311084-31547-1-git-send-email-bgolaszewski@baylibre.com> References: <1484311084-31547-1-git-send-email-bgolaszewski@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170113_043929_793921_7E29D711 X-CRM114-Status: GOOD ( 19.59 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:230 listed in] [list.dnswl.org] 0.7 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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+patch=linaro.org@lists.infradead.org Currently the clock multiplier is hardcoded in the driver for the da850-evm board. Make it configurable over DT, but keep the previous value as default in case the property is missing. Signed-off-by: Bartosz Golaszewski --- drivers/ata/ahci_da850.c | 83 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 75 insertions(+), 8 deletions(-) -- 2.9.3 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/drivers/ata/ahci_da850.c b/drivers/ata/ahci_da850.c index bb9eb4c..cd04caf 100644 --- a/drivers/ata/ahci_da850.c +++ b/drivers/ata/ahci_da850.c @@ -28,17 +28,70 @@ #define SATA_PHY_TXSWING(x) ((x) << 19) #define SATA_PHY_ENPLL(x) ((x) << 31) +struct da850_sata_mpy_mapping { + unsigned int multiplier; + unsigned int regval; +}; + +static const struct da850_sata_mpy_mapping da850_sata_mpy_table[] = { + { + .multiplier = 5, + .regval = 0x01, + }, + { + .multiplier = 6, + .regval = 0x02, + }, + { + .multiplier = 8, + .regval = 0x04, + }, + { + .multiplier = 10, + .regval = 0x05, + }, + { + .multiplier = 12, + .regval = 0x06, + }, + /* TODO Add 12.5 multiplier. */ + { + .multiplier = 15, + .regval = 0x08, + }, + { + .multiplier = 20, + .regval = 0x09, + }, + { + .multiplier = 25, + .regval = 0x0a, + } +}; + +static const struct da850_sata_mpy_mapping * +da850_sata_get_mpy(unsigned int multiplier) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(da850_sata_mpy_table); i++) + if (da850_sata_mpy_table[i].multiplier == multiplier) + return &da850_sata_mpy_table[i]; + + return NULL; +} + /* * The multiplier needed for 1.5GHz PLL output. * - * NOTE: This is currently hardcoded to be suitable for 100MHz crystal - * frequency (which is used by DA850 EVM board) and may need to be changed - * if you would like to use this driver on some other board. + * This is the default value suitable for the 100MHz crystal frequency + * used by DA850 EVM board, which doesn't use DT. */ -#define DA850_SATA_CLK_MULTIPLIER 7 +#define DA850_SATA_CLK_MULTIPLIER_DEFAULT 15 static void da850_sata_init(struct device *dev, void __iomem *pwrdn_reg, - void __iomem *ahci_base) + void __iomem *ahci_base, + const struct da850_sata_mpy_mapping *mpy) { unsigned int val; @@ -47,7 +100,7 @@ static void da850_sata_init(struct device *dev, void __iomem *pwrdn_reg, val &= ~BIT(0); writel(val, pwrdn_reg); - val = SATA_PHY_MPY(DA850_SATA_CLK_MULTIPLIER + 1) | SATA_PHY_LOS(1) | + val = SATA_PHY_MPY(mpy->regval) | SATA_PHY_LOS(1) | SATA_PHY_RXCDR(4) | SATA_PHY_RXEQ(1) | SATA_PHY_TXSWING(3) | SATA_PHY_ENPLL(1); @@ -87,10 +140,12 @@ static struct scsi_host_template ahci_platform_sht = { static int ahci_da850_probe(struct platform_device *pdev) { + const struct da850_sata_mpy_mapping *mpy; struct device *dev = &pdev->dev; struct ahci_host_priv *hpriv; - struct resource *res; + unsigned int multiplier; void __iomem *pwrdn_reg; + struct resource *res; int rc; hpriv = ahci_platform_get_resources(pdev); @@ -109,7 +164,19 @@ static int ahci_da850_probe(struct platform_device *pdev) if (!pwrdn_reg) goto disable_resources; - da850_sata_init(dev, pwrdn_reg, hpriv->mmio); + rc = of_property_read_u32(dev->of_node, + "da850,clk_multiplier", &multiplier); + if (rc) + multiplier = DA850_SATA_CLK_MULTIPLIER_DEFAULT; + + mpy = da850_sata_get_mpy(multiplier); + if (!mpy) { + dev_err(dev, "invalid multiplier value: %u\n", multiplier); + rc = -EINVAL; + goto disable_resources; + } + + da850_sata_init(dev, pwrdn_reg, hpriv->mmio, mpy); rc = ahci_platform_init_host(pdev, hpriv, &ahci_da850_port_info, &ahci_platform_sht);