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: 10169783 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 EE4B8603ED for ; Wed, 17 Jan 2018 16:16:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DCD7A26861 for ; Wed, 17 Jan 2018 16:16:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D162328599; Wed, 17 Jan 2018 16:16:52 +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.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6A1EC26861 for ; Wed, 17 Jan 2018 16:16:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=iRzYW32rsAnW+dK5A4q1L1Ad8lfjDn/0hoaI7lyf/c0=; b=owUecQcVYkiwIdWsObcREV1BH0 YrOSY5x28K5U4xNeeWRH1F3Vl5PK44/7dQfgPml4H0tcHr/G7ufcVZUBRltFu0fcd6v5CGB01kuH7 GGYp270NeBx3BN/580ZJFgC8xZqWfTzWz2FEIdJi0PcYS07IYbt6JtR50Q5CjzWSlvYp8eux3ovlJ JeTy1nwS4kdeNU6TjrX6EKrtWYPB+bkbyXkJKm7UuXwqAN4VxSIlwxih2Y6Rlbzi74stNtX7WjF4l OSieXvNQP4OJSWFQ+IPHPJBdFrsh5CQie9rQZvyIXj/OKbdMsHEH2YCY2xApsBHUnI+QB1lN4PkIu JxpGBmkQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ebqOQ-0001h0-T0; Wed, 17 Jan 2018 16:16:51 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ebqM8-0007MZ-TC for linux-arm-kernel@bombadil.infradead.org; Wed, 17 Jan 2018 16:14:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=wSohSo2IU9x+njJjzSU7v0cNjD4JFN9MH55HtBzecWs=; b=O6RXy+b0HJwZhcB2Himx69aSd 2exsdESVIHgGFVFpi92HbqDSe061v0oggeuFSdN++R3UvPp22clyOjfK+4EAM0xVVN1gPDZhSpHyn uF5Ej3AtlWZaqZAuypwxhMnB/MphHwy5zZO3wMg0E03VUm56TsoPnEv1u1vMce31lUtrrp/u9J6hH R2mqjVS6e/vIfTw0IGd+7JPes4IxtmPk88McJhIBMyKIJAkfiRw7mhDU+PSuW4N7+L43K22qFXX9V k+bX+r3ZCqaQp8v7itWBEuY1KAD66bLHHsuUKxdIrfRqdz7z1flVRt3HQt1gKdeoPdFZkhcmknsEL ssfnD83EA==; Received: from idris.smile.fr ([91.216.209.19]) by casper.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ebqM2-0006AZ-M9 for linux-arm-kernel@lists.infradead.org; Wed, 17 Jan 2018 16:14:26 +0000 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180117_161422_804898_34EAD77F X-CRM114-Status: UNSURE ( 8.84 ) X-CRM114-Notice: Please train this message. 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: gregory.clement@free-electrons.com, Maxime Chevallier , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-spi@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 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;