From patchwork Wed Jan 17 16:15:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Chevallier X-Patchwork-Id: 10169861 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 0D710603ED for ; Wed, 17 Jan 2018 16:23:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B96E228599 for ; Wed, 17 Jan 2018 16:23:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD0CF285D2; Wed, 17 Jan 2018 16:23:01 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 1B34028599 for ; Wed, 17 Jan 2018 16:23:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753764AbeAQQVn (ORCPT ); Wed, 17 Jan 2018 11:21:43 -0500 Received: from idris.smile.fr ([91.216.209.19]:55715 "EHLO idris.smile.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753666AbeAQQVk (ORCPT ); Wed, 17 Jan 2018 11:21:40 -0500 Received: from localhost (localhost [127.0.0.1]) by idris.smile.fr (Postfix) with ESMTP id 609D71EE2BBF; Wed, 17 Jan 2018 17:14:10 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at smile.fr Received: from idris.smile.fr ([127.0.0.1]) by localhost (bluemind-mta.prod.vitry.intranet [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TNQoOOjVGKOT; Wed, 17 Jan 2018 17:14:10 +0100 (CET) Received: from smile-e5570.sigfox.io (unknown [217.114.201.133]) by idris.smile.fr (Postfix) with ESMTPSA id 269CD1EE2BB0; Wed, 17 Jan 2018 17:14:10 +0100 (CET) From: Maxime Chevallier To: broonie@kernel.org Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, gregory.clement@free-electrons.com, Maxime Chevallier Subject: [PATCH 2/4] spi: a3700: Set frequency limits at startup Date: Wed, 17 Jan 2018 17:15:26 +0100 Message-Id: <1516205728-3256-3-git-send-email-maxime.chevallier@smile.fr> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1516205728-3256-1-git-send-email-maxime.chevallier@smile.fr> References: <1516205728-3256-1-git-send-email-maxime.chevallier@smile.fr> 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 Armada 3700 SPI controller has an internal clock divider which can divide the parent clock frequency by up to 30. This patch sets the limits in the spi_controller fields so that we can detect when a non-supported frequency is requested by a device for a transfer. Signed-off-by: Maxime Chevallier --- drivers/spi/spi-armada-3700.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/spi/spi-armada-3700.c b/drivers/spi/spi-armada-3700.c index c11ea6c..8048468 100644 --- a/drivers/spi/spi-armada-3700.c +++ b/drivers/spi/spi-armada-3700.c @@ -27,6 +27,8 @@ #define DRIVER_NAME "armada_3700_spi" +#define A3700_SPI_MAX_SPEED_HZ 100000000 +#define A3700_SPI_MAX_PRESCALE 30 #define A3700_SPI_TIMEOUT 10 /* SPI Register Offest */ @@ -823,6 +825,11 @@ static int a3700_spi_probe(struct platform_device *pdev) goto error; } + master->max_speed_hz = min_t(unsigned long, A3700_SPI_MAX_SPEED_HZ, + clk_get_rate(spi->clk)); + master->min_speed_hz = DIV_ROUND_UP(clk_get_rate(spi->clk), + A3700_SPI_MAX_PRESCALE); + ret = a3700_spi_init(spi); if (ret) goto error_clk;