From patchwork Thu Jan 10 19:02:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 10756641 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C2CD517E1 for ; Thu, 10 Jan 2019 19:02:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B345D29CEC for ; Thu, 10 Jan 2019 19:02:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A70E729D0C; Thu, 10 Jan 2019 19:02:43 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 5A1B429CF2 for ; Thu, 10 Jan 2019 19:02:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729123AbfAJTCm (ORCPT ); Thu, 10 Jan 2019 14:02:42 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:46835 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728561AbfAJTCm (ORCPT ); Thu, 10 Jan 2019 14:02:42 -0500 Received: by mail-lf1-f66.google.com with SMTP id y14so9045570lfg.13 for ; Thu, 10 Jan 2019 11:02:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cogentembedded-com.20150623.gappssmtp.com; s=20150623; h=subject:from:to:cc:references:organization:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=I4wFtu4ewvaxtn9SUALdhudsLahKkWpUyBhd3aLO95Y=; b=vkI0mW6lVQ250pw/B1OWoAK+ePxx7uw0KGsZ1NDmkCzAKSMOmtPBX2MkdQ23Wbt17S toVR6d/KaKnEly8+n88pNM7DYUA6Tl6o7HxUeCkZkN+P6v0NC5w1UnNBVbbPBuqbW/3I qOA/nCyYYI9FkL6wtl2dDYX5Fmqs2g95COW7UdUiLQD5JN8P+uwrVjDX/UDb6C/xg4iE nxFTx1ozYYu7qyj4nk+RQYkoR+aK6XmQY4YFQPychtQFCxM9IPD/FDdVF1m7oc8fHgXO 4aTBWHhL/66v6mToFaLafpLVDQNqexZKrC/AoLT8a0CZ79GfZw1SvfICgpXduFsTQcI/ PfTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=I4wFtu4ewvaxtn9SUALdhudsLahKkWpUyBhd3aLO95Y=; b=lgBzs4k2vdw0Y8x7Y3OItD6GeNOLhRZh9J/LbdhJRbB5+RaSX1+LTRElw9E3enF/eM bXF4mZy40OAQbNAvSoas6wpAdJYUKthZh6+6dONNgFKeA0yoXkndOJpJPo0QRlKun1Bv HoY2+js7+mBrF7w0HIfE/rA4KQkuGRHnSpJt+hCrTbRsXrt6Hy4ptv/S7+zXG+eFjSLH sTjyTxR/qUrfAeTE4kasWJ4E3slKzs3akG6wOBp8bujyf1tiR+p2SV4AH3QfQMKhjcIR U2r/8IQSNEDpiBMRMaCWXWOspRcDqTTrEI0d+ln1oJ1ITjff9+DSw99C8ima0Qm9Is1o Ntgg== X-Gm-Message-State: AJcUukftDjrYYmokPknWmH+za2LWzWkUSxKP0EBLSTO/MRkLk84W4Uyj deFF6sfgDy7NNDpue3BNFCgdxKLc3/4= X-Google-Smtp-Source: ALg8bN6SBs9BCzOy5LWo/57natk8/xT/nssxLyMa0v2ksb5Xpvo3CYntnDPtm4l3++mTRYOn9Xv2Ow== X-Received: by 2002:a19:be16:: with SMTP id o22mr6366391lff.22.1547146960437; Thu, 10 Jan 2019 11:02:40 -0800 (PST) Received: from wasted.cogentembedded.com ([31.173.83.92]) by smtp.gmail.com with ESMTPSA id g17sm14428911lfg.78.2019.01.10.11.02.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Jan 2019 11:02:39 -0800 (PST) Subject: [PATCH RFC 1/2] dt-bindings: spi: renesas-rpc: document R8A77970 bindings From: Sergei Shtylyov To: linux-spi@vger.kernel.org, Mason Yang , Rob Herring , "devicetree@vger.kernel.org" Cc: linux-renesas-soc@vger.kernel.org, Mark Rutland References: Organization: Cogent Embedded Message-ID: <36b5ecc8-e7df-e351-f267-97a0d94262a1@cogentembedded.com> Date: Thu, 10 Jan 2019 22:02:38 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-MW 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 Document the R-Car V3M (R8A77970) SoC in the Renesas RPC-IF bindings. Signed-off-by: Sergei Shtylyov Reviewed-by: Rob Herring --- Documentation/devicetree/bindings/spi/spi-renesas-rpc.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) Index: renesas/Documentation/devicetree/bindings/spi/spi-renesas-rpc.txt =================================================================== --- renesas.orig/Documentation/devicetree/bindings/spi/spi-renesas-rpc.txt +++ renesas/Documentation/devicetree/bindings/spi/spi-renesas-rpc.txt @@ -2,7 +2,8 @@ Renesas R-Car Gen3 RPC-IF controller Dev ---------------------------------------------------------- Required properties: -- compatible: should be "renesas,r8a77980-rpc" or +- compatible: should be "renesas,r8a77970-rpc" or + "renesas,r8a77980-rpc" or "renesas,r8a77995-rpc" - #address-cells: should be 1 - #size-cells: should be 0 From patchwork Thu Jan 10 19:04:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 10756655 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8C29C13B4 for ; Thu, 10 Jan 2019 19:04:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B8A0299C9 for ; Thu, 10 Jan 2019 19:04:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7043429A0E; Thu, 10 Jan 2019 19:04:23 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 0DC6B299C9 for ; Thu, 10 Jan 2019 19:04:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727000AbfAJTEW (ORCPT ); Thu, 10 Jan 2019 14:04:22 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:43470 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729127AbfAJTEW (ORCPT ); Thu, 10 Jan 2019 14:04:22 -0500 Received: by mail-lf1-f65.google.com with SMTP id u18so9050212lff.10 for ; Thu, 10 Jan 2019 11:04:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cogentembedded-com.20150623.gappssmtp.com; s=20150623; h=subject:from:to:cc:references:organization:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=EVoiI2Rzh0b2UJn7mUs/ie1462OcX7K+PDPyT4T//Ls=; b=xRDmh4fA7rezDA42WKhlrfpZYT3klWrO35MtLfFv4E9GuEBpFR3EJhQR67bmdmxjNr pGHY9ZKpV+c7bNBml0hRHMVdpRgOXRafW83ajTj9GRkJFeJYBjzgImd61iuLbvylqiNQ 7Keauimphe2RYGVsePoiCEO1WoKe4S0sdw3WCyQmF9Y1q8o1VoRHgHPpX4wOzpARJzo3 3UxNBLWgmhGGuPApcNiepqcNQip5NHkYcDmcWvxU4BXOSBXbAzcRfOlMCmwjfJ4VaI44 EdTaHgtm5OfPQJ94Y4+rEqG2BBE1IOYNmC49476VHOnBH8ues1acZ3k5W2eDakJ9Z21Q zqLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=EVoiI2Rzh0b2UJn7mUs/ie1462OcX7K+PDPyT4T//Ls=; b=heVzEmy6lRvt/jtvlEE+YQpsEqf7O42pufbfv4slW7aDWNNqYgp9/BqsHWxtvE7TGA mdrKyVVw1LxOyYqvmv2g8LsAf12fPFh7A9hyv29OTU0OOgNzaT9FRXlU3y/ziAVh4cET KHVU5Bks/12+huU5RRdpietgr2CRHLagK4ikTfanfPCaTYYwqzQSP42RQzbpW2OVLnjZ zB1Aj047UJZpOEo3eOIgDKZ72hyJ9e1zk9OtIBY2eCXi/mw4kYiwtlrh+CxROoRR/RZ2 fuF/EqxAhpoQBs9lNbhTAhgjftKSxowxCVu3hX2npvaNfV+dIQEoroUhRwDI8LdlM8Ty 9DGw== X-Gm-Message-State: AJcUukerg11tYcvZtF8LA0w+xNyDiym35aEU3C95wZ7/a3iiAjci3DdI rj5XJa3pgZV2Q5x+lt7V0SFbUg== X-Google-Smtp-Source: ALg8bN7DnrtxN4PR4hw7TQTYOHfSnwhfghRlKfKrUPzGv35B3xG5TH2E6en4HLkwTdNcK4lzvQZYPg== X-Received: by 2002:a19:7352:: with SMTP id o79mr6903282lfc.104.1547147059522; Thu, 10 Jan 2019 11:04:19 -0800 (PST) Received: from wasted.cogentembedded.com ([31.173.83.92]) by smtp.gmail.com with ESMTPSA id u21-v6sm15445318lju.46.2019.01.10.11.04.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Jan 2019 11:04:18 -0800 (PST) Subject: [PATCH RFC 2/2] spi-renesas-rpc: add R8A77970 support From: Sergei Shtylyov To: linux-spi@vger.kernel.org, Mason Yang , Rob Herring , "devicetree@vger.kernel.org" Cc: linux-renesas-soc@vger.kernel.org, Mark Rutland References: Organization: Cogent Embedded Message-ID: Date: Thu, 10 Jan 2019 22:04:17 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-MW 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 Add the R-Car V3M (R8A77970) SoC support to the Renesas RPC-IF SPI driver. This SoC has special RPC-IF register (DIVREG) that controls the RPC[D2]CK clock divider instead of the CPG register (RPCCKCR) present in all other R-Car gen3 SoC... Signed-off-by: Sergei Shtylyov --- drivers/spi/spi-renesas-rpc.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) Index: renesas/drivers/spi/spi-renesas-rpc.c =================================================================== --- renesas.orig/drivers/spi/spi-renesas-rpc.c +++ renesas/drivers/spi/spi-renesas-rpc.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -140,6 +141,9 @@ #define RPC_PHYOFFSET2 0x0084 // R/W #define RPC_PHYOFFSET2_OCTTMG(v) (((v) & 0x7) << 8) +#define RPC_DIVREG 0x00A8 // R8A77970 only +#define RPC_DIVREG_RATIO(v) (((v) & 0x3) << 0) + #define RPC_WBUF 0x8000 // Write Buffer #define RPC_WBUF_SIZE 256 // Write Buffer size @@ -158,8 +162,24 @@ struct rpc_spi { u32 totalxferlen; enum spi_mem_data_dir xfer_dir; struct reset_control *rstc; + int (*set_freq)(struct rpc_spi *rpc, unsigned long freq); }; +static int rpc_spi_clk_set_freq(struct rpc_spi *rpc, unsigned long freq) +{ + return clk_set_rate(rpc->clk_rpc, freq); +} + +static int rpc_spi_v3m_set_freq(struct rpc_spi *rpc, unsigned long freq) +{ + u32 ratio; + + ratio = ilog2(DIV_ROUND_UP(clk_get_rate(rpc->clk_rpc), freq)); + if (ratio > 2) + ratio = 2; + return regmap_write(rpc->regmap, RPC_DIVREG, RPC_DIVREG_RATIO(ratio)); +} + static int rpc_spi_set_freq(struct rpc_spi *rpc, unsigned long freq) { int ret; @@ -167,7 +187,7 @@ static int rpc_spi_set_freq(struct rpc_s if (rpc->cur_speed_hz == freq) return 0; - ret = clk_set_rate(rpc->clk_rpc, freq); + ret = rpc->set_freq(rpc, freq); if (ret) return ret; @@ -650,7 +670,7 @@ static const struct regmap_config rpc_sp .val_bits = 32, .reg_stride = 4, .fast_io = true, - .max_register = RPC_PHYOFFSET2, + .max_register = RPC_DIVREG, .volatile_table = &rpc_spi_volatile_table, }; @@ -708,6 +728,8 @@ static int rpc_spi_probe(struct platform if (IS_ERR(rpc->rstc)) return PTR_ERR(rpc->rstc); + rpc->set_freq = of_device_get_match_data(&pdev->dev); + pm_runtime_enable(&pdev->dev); master->auto_runtime_pm = true; @@ -745,8 +767,9 @@ static int rpc_spi_remove(struct platfor } static const struct of_device_id rpc_spi_of_ids[] = { - { .compatible = "renesas,r8a77980-rpc", }, - { .compatible = "renesas,r8a77995-rpc", }, + { .compatible = "renesas,r8a77970-rpc", .data = rpc_spi_v3m_set_freq, }, + { .compatible = "renesas,r8a77980-rpc", .data = rpc_spi_clk_set_freq, }, + { .compatible = "renesas,r8a77995-rpc", .data = rpc_spi_clk_set_freq, }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, rpc_spi_of_ids);