From patchwork Wed Jul 8 20:21:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cory Tusar X-Patchwork-Id: 6751101 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 74262C05AC for ; Wed, 8 Jul 2015 20:25:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8A9E420668 for ; Wed, 8 Jul 2015 20:25:08 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9E330205B4 for ; Wed, 8 Jul 2015 20:25:07 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZCvrv-0002Pu-Vw; Wed, 08 Jul 2015 20:23:00 +0000 Received: from mail-qk0-f174.google.com ([209.85.220.174]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZCvrG-0001lq-Cm for linux-arm-kernel@lists.infradead.org; Wed, 08 Jul 2015 20:22:19 +0000 Received: by qkbp125 with SMTP id p125so171802881qkb.2 for ; Wed, 08 Jul 2015 13:21:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jjwHJ74Y0Nssfgp5ytbqQho/ApCDNKepT0hYhEw765M=; b=K6JWrywIy+n5ra8nu3PCP5FCxTKfFup5JtVqVMJbritIbKyePu1GSMdQswnDdULuTq IzmCMT6i4WryNC+WiCHJ9tztXco5ceXUcQ4337WG+JMuOqEkJ3RN1wkVS9gEznhWvYV+ XxGanPc05I8i0m5h4Rcxm+3UK5n+bGlmTIGV4pjReymKaiCx/I0/0YR7g8ZmqLTdMEjl K262W+kBXCyc9Hi8E7lQP3xuiuZTiaPk2/AzSFJIDBNanH4O+DaoFFkgfkQJ7gHxxJ89 Od5OYjvzrmbhqwa2oAV2Xga72YFIkoZSdxD70Gb+M9vLVLWZ0KAp/ZZKT6U08xKnu1yf 0VpQ== X-Gm-Message-State: ALoCoQm4Sq1KiVx354APYmiwuYDWO9/1WBd+EpwTr/g+TeowJhgOeZL0Pa0V3qevfLhQwybPeBhy X-Received: by 10.140.28.247 with SMTP id 110mr7926849qgz.16.1436386917245; Wed, 08 Jul 2015 13:21:57 -0700 (PDT) Received: from ctusar.lan (c-71-58-209-198.hsd1.pa.comcast.net. [71.58.209.198]) by smtp.gmail.com with ESMTPSA id q22sm1803184qkh.35.2015.07.08.13.21.55 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Jul 2015 13:21:56 -0700 (PDT) From: Cory Tusar To: robh+dt@kernel.org, pawel.moll@arm.com, mark.rutland@arm.com, ijc+devicetree@hellion.org.uk, galak@codeaurora.org, shawnguo@kernel.org, kernel@pengutronix.de, han.xu@freescale.com, dwmw2@infradead.org, computersforpeace@gmail.com Subject: [PATCH v1 4/7] mtd: fsl-quadspi: Use per-device clk_rate. Date: Wed, 8 Jul 2015 16:21:18 -0400 Message-Id: <1436386881-28088-5-git-send-email-cory.tusar@pid1solutions.com> X-Mailer: git-send-email 2.3.6 In-Reply-To: <1436386881-28088-1-git-send-email-cory.tusar@pid1solutions.com> References: <1436386881-28088-1-git-send-email-cory.tusar@pid1solutions.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150708_132218_524598_9FD6DB7D X-CRM114-Status: GOOD ( 17.15 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux@arm.linux.org.uk, andrew@lunn.ch, linux-kernel@vger.kernel.org, stefan@agner.ch, linux-mtd@lists.infradead.org, Cory Tusar , linux-arm-kernel@lists.infradead.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-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The current fsl-quadspi implementation re-parses the 'spi-max-frequency' property for each device, potentially allowing for an earlier, lower frequency to be overwritten with a greater value. This commit modifies the parsing logic to extract the clock frequency for each flash device and then configures for that frequency as part of the prepare() method prior to accessing a given device. Signed-off-by: Cory Tusar --- drivers/mtd/spi-nor/fsl-quadspi.c | 41 +++++++++++++++------------------------ 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/drivers/mtd/spi-nor/fsl-quadspi.c b/drivers/mtd/spi-nor/fsl-quadspi.c index 4b8038b..d0cf0b7 100644 --- a/drivers/mtd/spi-nor/fsl-quadspi.c +++ b/drivers/mtd/spi-nor/fsl-quadspi.c @@ -233,7 +233,7 @@ struct fsl_qspi { struct fsl_qspi_devtype_data *devtype_data; u32 nor_size; u32 nor_num; - u32 clk_rate; + u32 clk_rate[FSL_QSPI_MAX_CHIP]; unsigned int chip_base_addr; /* We may support two chips. */ bool has_second_chip; }; @@ -645,25 +645,13 @@ static int fsl_qspi_nor_setup(struct fsl_qspi *q) return 0; } -static int fsl_qspi_nor_setup_last(struct fsl_qspi *q) +static void fsl_qspi_nor_setup_last(struct fsl_qspi *q) { - unsigned long rate = q->clk_rate; - int ret; - - if (is_imx6sx_qspi(q)) - rate *= 4; - - ret = clk_set_rate(q->clk, rate); - if (ret) - return ret; - /* Init the LUT table again. */ fsl_qspi_init_lut(q); /* Init for AHB read */ fsl_qspi_init_abh_read(q); - - return 0; } static const struct of_device_id fsl_qspi_dt_ids[] = { @@ -763,6 +751,8 @@ static int fsl_qspi_erase(struct spi_nor *nor, loff_t offs) static int fsl_qspi_prep(struct spi_nor *nor, enum spi_nor_ops ops) { struct fsl_qspi *q = nor->priv; + int nor_idx = nor - q->nor; + unsigned long rate = q->clk_rate[nor_idx]; int ret; ret = clk_enable(q->clk_en); @@ -775,6 +765,16 @@ static int fsl_qspi_prep(struct spi_nor *nor, enum spi_nor_ops ops) return ret; } + if (is_imx6sx_qspi(q)) + rate *= 4; + + ret = clk_set_rate(q->clk, rate); + if (ret) { + clk_disable(q->clk); + clk_disable(q->clk_en); + return ret; + } + fsl_qspi_set_base_addr(q, nor); return 0; } @@ -899,7 +899,7 @@ static int fsl_qspi_probe(struct platform_device *pdev) goto irq_failed; ret = of_property_read_u32(np, "spi-max-frequency", - &q->clk_rate); + &q->clk_rate[i]); if (ret < 0) goto irq_failed; @@ -939,21 +939,12 @@ static int fsl_qspi_probe(struct platform_device *pdev) } /* finish the rest init. */ - ret = fsl_qspi_nor_setup_last(q); - if (ret) - goto last_init_failed; + fsl_qspi_nor_setup_last(q); clk_disable(q->clk); clk_disable(q->clk_en); return 0; -last_init_failed: - for (i = 0; i < q->nor_num; i++) { - /* skip the holes */ - if (!q->has_second_chip) - i *= 2; - mtd_device_unregister(&q->mtd[i]); - } irq_failed: clk_disable_unprepare(q->clk); clk_failed: