From patchwork Mon Nov 28 03:03:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gao Pan X-Patchwork-Id: 9449157 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 73F8E6071C for ; Mon, 28 Nov 2016 07:37:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6317D20649 for ; Mon, 28 Nov 2016 07:37:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 579AF204C2; Mon, 28 Nov 2016 07:37:34 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E95C20649 for ; Mon, 28 Nov 2016 07:37:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754468AbcK1Hh1 (ORCPT ); Mon, 28 Nov 2016 02:37:27 -0500 Received: from mail-db5eur01on0086.outbound.protection.outlook.com ([104.47.2.86]:51648 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754447AbcK1HhX (ORCPT ); Mon, 28 Nov 2016 02:37:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=CFjLcAcC9NU4rkRPeRm2BwYp0tkhkj33UlGAIUKCrBM=; b=d+aPTeN2d4QiKB1z7xRaos5f69PzKgamw3CAjzNwJ6JV+bnhZpXs7WWKovQyFQ6r8jH3QMaqczNPJl712O/Oh6csM8IOKTO0VBPqG5Ehd4FswBp3F4JWNObcI4WLMg01YmWfZDq6jJ96PGaJ1M284vIDxF3i/vEOkiOYiVSBSB4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=pandy.gao@nxp.com; Received: from b54642-OptiPlex-3020.ap.freescale.net (199.59.225.131) by VI1PR0401MB1792.eurprd04.prod.outlook.com (10.165.234.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.747.13; Mon, 28 Nov 2016 03:04:24 +0000 From: Gao Pan To: CC: , , , Subject: [Patch V1 2/2] imx: spi: read lpspi tx/rx fifo size in probe() Date: Mon, 28 Nov 2016 11:03:00 +0800 Message-ID: <1480302180-15550-2-git-send-email-pandy.gao@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1480302180-15550-1-git-send-email-pandy.gao@nxp.com> References: <1480302180-15550-1-git-send-email-pandy.gao@nxp.com> MIME-Version: 1.0 X-Originating-IP: [199.59.225.131] X-ClientProxiedBy: KL1PR06CA0004.apcprd06.prod.outlook.com (10.165.15.142) To VI1PR0401MB1792.eurprd04.prod.outlook.com (10.165.234.154) X-MS-Office365-Filtering-Correlation-Id: 6b1b3707-fa41-426a-8d87-08d4173b44d4 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:VI1PR0401MB1792; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0401MB1792; 3:+zXcaJs46zxqGqIWD2K/dG8tF6mI30altQJ+o2EiurRW81AFAB4qp3iY044h7U1JMvNQxwTdTrr4my/s0Ensrbh6/TJQNUpwaGkmo0DipsN35NMw8sn5AJPDvq8EMp9U3z7M2rmHtMo3BRZT951VFbtnT6u7lashL7uoew29Xar9J4UHYQa9JCqIKXJzKW51VfCWpZGoOutTnf02h7xS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2/bTtnu4t2nkKWvgiemi3E/3FYrQwED5wE7TjRzA6B5KSI5wDV6S7LMNWyXpRsX2vN1yGBmniIhAY8CWVv0n; 20:Gcwv0/DM5lGh+mnbT9Yc8McO59Y1uivpFn5//qkfr1NUwY7ejgf2DyqmUtaLwZiD1aJZO91kv+w+BknhUckp8p6bg/9hR/AtYrkc3JKgxpqUPWMLlW8Uz+T+W/v6NKGtlflg2LDreo7jN/bp3m7CZkKNw680bRxD8aV3z8760O7EC0c/FB2Tob0VRCxE4/W2twjJXy+sV0o+uxFB//s9tdt5FpKvHVoz0nR8iiIJiwgHbY4TGbaBtxxpLgJ1Vsbd3D5P9yxnFktCkRd85+N+fLAQucGcu5J+8sEEQ8zh7OBAlvMgZsLkZ5DmVsyFmN8VMzNdwxWaD5ITnk762+0zpgTnYMpx+8YGKJtBb5X6zr3PQchRzIgrgU4242iy//lTLizmN2iR0+AxIbu2SKhBY+CLfj2Fo0UFjEFIgoZzINc0cQV6g8asfsBleGQ87obAJGzwOkFCt0ZT5iuVk20+l4gzPAO3/pu2l79lB6apNMo0gh1p93dr3Vr3VlIA40o1 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6060326)(6040361)(6045199)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026)(6046074)(6041248)(6061324)(20161123560025)(20161123555025)(20161123564025)(20161123562025); SRVR:VI1PR0401MB1792; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0401MB1792; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0401MB1792; 4:mewMBQVXpW1OiySTAyMAFqvyhTv9tjUNW7eG9tnWDTqK6IhYLBuaGvIzj19eOzJD8fHLY6AnErA4VU5xJk/Jee/Oq65JiY+4rZEP0fZAwVxEh/IqRHsztbMc0S9rVm2W5wfSb6935k7qufGONTsSqM/mIeahQZzfVuUicoKRegxW4UWJ0uocRNg1Jihm8qc2YDFFC50h0Meb/3E6NaupOT6Y/T4mQ80WrBcwgmZPpIJDD51trRKETLnLZNKdS86IfcBlIgPxbJ4dDl8RXa9p5RJtZAfmQMqbzuGKEu0d8ZKR2eIxbD8zns1aqXmtTNrF018V+XSJFV2Aabcg/Fp9QAByFTlGdWO+31cxmkKbqipIUmc0UqqhpV4fXp029xtt4DgslUV5NbbNn9hOSmKX6ckTvIMgicUunBKn+EkmK9zcz//iO4gSAd+Cvd9rnWBeu00X/kaYdtU8JNsSK0ggrKkVr9H3U5EW90UNOOqK6AEYjrgtVjH1Qj5UF1ud37hpnOAJPf89hkD0AihAy72r8BRN9D71Ml2no+oyQ3uceZbSivG/6pESZWBVjTPZ7fH4kJIkUeZFjd+KUwQjxOd+EU9VVDmEHc8TYhVFulKvkd5gpMCrACc0JvsOW7QrHQQh5gOROUu2Kx71zQbobGdbBSDYARDC3NWno5YLNFSz5ts+RLoPBbgNZHDGN4O4EmA9 X-Forefront-PRVS: 01401330D1 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(189002)(199003)(6666003)(6916009)(2950100002)(2351001)(6116002)(305945005)(42186005)(110136003)(92566002)(97736004)(36756003)(189998001)(7846002)(105586002)(66066001)(47776003)(3846002)(106356001)(5660300001)(5003940100001)(7736002)(76176999)(575784001)(81166006)(8676002)(86362001)(4326007)(68736007)(81156014)(39450400002)(733004)(50226002)(6486002)(50466002)(48376002)(33646002)(38730400001)(50986999)(39400400001)(39410400001)(2906002)(39380400001)(101416001)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0401MB1792; H:b54642-OptiPlex-3020.ap.freescale.net; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0401MB1792; 23:Awbre3dvQH/j9RS+G/vFhkc34vrPTHr4bFfxMup?= =?us-ascii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TCm4EoiV+UmFFloJONPHGVBVYnBrh84qQi4GRl9wy/0FVJrShaNZ0rEaV7oq5rsX8PnKavOyuJ0LV/tbg= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR0401MB1792; 7:8wTEmPdkpqLyY0g6Yx700tFs14a7YIOfjuuKS5IfRWw6YNoMYh6p7dOpz3C86aYl4+SwXUdDek82afkWE9fgcDIHdqgr2uNxUx03UvwofMkONUFxnovNWEsVEiJ9BAIPh+5JaZNhLQhKDzcAevNezAEaFsVOW7wniOdCaaJnenvJULX8h3t4dHZseTKICvBuZpw61tnRZR/6s4Lcqyjry/RMp+FufG+SEfd036rJ0MAsOflUfncjaLqZiJdgld5PNxa+3OEFadFkuGjAnFUYNH/rKsvl5gEIt7tkHf+RI8baQimziiXTsjXKvxnasehbvAIiE8/CKIqbqU97l/I7REV+1mWSaamNZLxK6K1OZuyXPJSwBWJ7cFRPcE6KCFzGqIXzPgMg2MO/qjdITfliERIrAs5iWyT9/J4xe7eA9kQROGV+RsIOu9FF/MoyK6VVfbtAGcJyj3V5OuwtIZAaSQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Nov 2016 03:04:24.9328 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB1792 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The lpspi tx/rx fifo size is a read only parameter resides lpspi Parameter Register. It's better to read lpspi tx/rx fifo size in probe(). Signed-off-by: Gao Pan --- drivers/spi/spi-fsl-lpspi.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c index 47a97ad..71eca6e 100644 --- a/drivers/spi/spi-fsl-lpspi.c +++ b/drivers/spi/spi-fsl-lpspi.c @@ -236,15 +236,9 @@ static void fsl_lpspi_set_cmd(struct fsl_lpspi_data *fsl_lpspi, static void fsl_lpspi_set_watermark(struct fsl_lpspi_data *fsl_lpspi) { - u8 txwatermark, rxwatermark; u32 temp; - temp = readl(fsl_lpspi->base + IMX7ULP_PARAM); - fsl_lpspi->txfifosize = 1 << (temp & 0x0f); - fsl_lpspi->rxfifosize = 1 << ((temp >> 8) & 0x0f); - rxwatermark = fsl_lpspi->txfifosize >> 1; - txwatermark = fsl_lpspi->rxfifosize >> 1; - temp = txwatermark | rxwatermark << 16; + temp = fsl_lpspi->txfifosize >> 1 | (fsl_lpspi->rxfifosize >> 1) << 16; writel(temp, fsl_lpspi->base + IMX7ULP_FCR); @@ -427,6 +421,7 @@ static int fsl_lpspi_probe(struct platform_device *pdev) struct spi_master *master; struct resource *res; int ret, irq; + u32 temp; master = spi_alloc_master(&pdev->dev, sizeof(struct fsl_lpspi_data)); if (!master) @@ -476,6 +471,18 @@ static int fsl_lpspi_probe(struct platform_device *pdev) goto out_master_put; } + ret = clk_prepare_enable(fsl_lpspi->clk); + if (ret) { + dev_err(&pdev->dev, "can't enable lpspi clock, ret=%d\n", ret); + goto out_master_put; + } + + temp = readl(fsl_lpspi->base + IMX7ULP_PARAM); + fsl_lpspi->txfifosize = 1 << (temp & 0x0f); + fsl_lpspi->rxfifosize = 1 << ((temp >> 8) & 0x0f); + + clk_disable_unprepare(fsl_lpspi->clk); + ret = devm_spi_register_master(&pdev->dev, master); if (ret < 0) { dev_err(&pdev->dev, "spi_register_master error.\n");