Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp686167imu; Tue, 20 Nov 2018 05:28:16 -0800 (PST) X-Google-Smtp-Source: AJdET5eiJqPpy2iSQD/Z51E4Wbb8jaWhKpzJcsujwK9RkxNDdn09iHqa2gVZqGF9Wi8Qx8vSWjPw X-Received: by 2002:aa7:814f:: with SMTP id d15-v6mr2226591pfn.78.1542720496254; Tue, 20 Nov 2018 05:28:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542720496; cv=none; d=google.com; s=arc-20160816; b=k3S/hCheQSTxd6/Hj6swpgpAznKbB1MkYNFy/UB58XheTzWH2rMKF4iu7AsxlLyRwT ula/BUfkZzvzB3gaRIInUhFWx6taT4M68GidJc5vEz05DW3FvE1QDUP5JwM2DtYfnFru BD2vDOVeTDrg3wynhkytN9UM1Eb4ddnz7qOdRumatFR3XEaCVGBAkwsBVMViBoDshRvY OVDb5mwMpC99tht0EOfKXxkArSTTweeNijHrpJepw4fqpfEIUXwX6nYCpCbWMbVoklzB GJaat5lF4tauyLBrPxAogfjdybtZxoQXtjVvqA5lb6shwUeE0siox4OZbmiQ6jsMp8Oe d8Ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=7NZ/xVlUfPpnqYC9BP/cMc65vHefuKvjMR7MCkPyfeg=; b=dssiSp/M22duTYDWnq4nPlJDdMHOJwRsXh+RoRlkXAAXcp20czoAc6C8Tjq1kZhilq 4ONw8eS1x+PYDmUU9NL1a1jqs8A/912GbkydpiLwGg1wpvz915BeklF3nAHZVJwg5QzY Qn0cr+cE2FC1RZ3ZQHOGvzhbByud0meywt0SCjB7UKd/N4rA9vAr1qAwvK6fw4j9WZe/ 2R5xD+tSdFkl79NHwZ5C7FLBbdrICZjQdV2gFmjbHK+Wsip99+xoTlsjfvIhaEaCEKOy XSayfrXydDo7WmgSemUpxA3EU6kAHu8tRIqnjwNYwpXAToa+19Yr1UcEjyVHZwzyagn3 wHSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QUg4cUck; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f63si11822001pfg.136.2018.11.20.05.28.00; Tue, 20 Nov 2018 05:28:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QUg4cUck; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726818AbeKTXiN (ORCPT + 99 others); Tue, 20 Nov 2018 18:38:13 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:42346 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725898AbeKTXiN (ORCPT ); Tue, 20 Nov 2018 18:38:13 -0500 Received: by mail-wr1-f67.google.com with SMTP id q18so1896944wrx.9; Tue, 20 Nov 2018 05:09:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=7NZ/xVlUfPpnqYC9BP/cMc65vHefuKvjMR7MCkPyfeg=; b=QUg4cUckU0TJ9Rfn2S+mKU38UqCf5W5oSxfTsxRIVTUOGkQv6ldQptI/4mJ9SH1w/z JFFxcGKBF0oY47gIwf0XukiWNiuKrCRF6qm2EMlqtrSLRbQ7V59lNHp0DC5fa8T+BS/1 0E5hsvU+iDlrZwCzsCySlLi5h52n8HlD7nKCXLlaox/vrj85dptJXhgygb9qrtyC5oek E9G59cAU8/TPqkMyCwBDUNPw7oWpAx8odWtoEzMXcnZJO09ht1ueIclJqL4bEUa/zW/D 95/KbNhDm6Er5TrYJkShBmLoEnnA2vB2bQ7Qy9Wp/X9fE8Oc9Pkudf+NLN1gay+hNGV7 F5wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=7NZ/xVlUfPpnqYC9BP/cMc65vHefuKvjMR7MCkPyfeg=; b=dNuGPryGGNu7DYzPmkGFoMrAGf+Y2lAq9IVGs2mkFAtkkJBtfZLiuMmitPStIouiKT NewKX/ADwMzvoCygf2k0ERlrtnnZRJJLZSrB+e3OaBhG1yOgHyIJLlk8I2DQjR0y0YlP F/muiEtcCdSWPu/QTGjQ62SBogfwoGkr0eybRt4GHJHvf5JeY5h+lY7IKKsaLIqYbDSO JQMs1D5ODffgmdretL0ULnHZ3uPXYOfBzoDW++oDeaNJN2hbpyHodDTklMEFFeN/GKYx fpc+jOZQInWs3pkgiybwLigsy/gRf0+tZIlPBKWUrF4UP1dEFoLwWBD+LeP9WKlNGqtR DH9Q== X-Gm-Message-State: AA+aEWZ1Hll+KDaH/25LjB5HMv9t+PTYgoiOP1ox5A2gPg3sLG5+xNv1 9q2FjFQHXp+y/KUnyWyFoGjp3BPDvRU= X-Received: by 2002:a5d:64c7:: with SMTP id y7mr1884663wrv.207.1542719347389; Tue, 20 Nov 2018 05:09:07 -0800 (PST) Received: from [192.168.1.4] (ip-86-49-110-70.net.upcbroadband.cz. [86.49.110.70]) by smtp.gmail.com with ESMTPSA id v189-v6sm33598381wmd.40.2018.11.20.05.09.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Nov 2018 05:09:06 -0800 (PST) Subject: Re: [PATCH 1/2] spi: Add Renesas R-Car RPC SPI controller driver To: masonccyang@mxic.com.tw Cc: boris.brezillon@bootlin.com, broonie@kernel.org, Geert Uytterhoeven , Simon Horman , juliensu@mxic.com.tw, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-spi@vger.kernel.org, tpiepho@impinj.com, zhengxunli@mxic.com.tw References: <1542621690-10229-1-git-send-email-masonccyang@mxic.com.tw> <1542621690-10229-2-git-send-email-masonccyang@mxic.com.tw> <0223f43b-c6a6-eade-49af-4e7b7ef7f022@gmail.com> From: Marek Vasut Message-ID: <6b024f18-d0bc-3e65-f07c-cef913f795ab@gmail.com> Date: Tue, 20 Nov 2018 14:09:05 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/20/2018 08:23 AM, masonccyang@mxic.com.tw wrote: > Hi Marek, Hi, >> Marek Vasut >> 2018/11/19 下午 10:12 >> >> To >> >> > + >> > +static int rpc_spi_set_freq(struct rpc_spi *rpc, unsigned long freq) >> > +{ >> > +   int ret; >> > + >> > +   if (rpc->cur_speed_hz == freq) >> > +      return 0; >> > + >> > +   clk_disable_unprepare(rpc->clk_rpc); >> > +   ret = clk_set_rate(rpc->clk_rpc, freq); >> > +   if (ret) >> > +      return ret; >> > + >> > +   ret = clk_prepare_enable(rpc->clk_rpc); >> > +   if (ret) >> > +      return ret; >> >> Is this clock disable/update/enable really needed ? I'd think that >> clk_set_rate() would handle the rate update correctly. > > This is for run time PM mechanism in spi-mem layer and __spi_sync(), > you may refer to another patch [1]. > > [1] > https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git/commit/?h=for-4.21&id=b942d80b0a394e8ea18fce3b032b4700439e8ca3 I think Geert commented on the clock topic, so let's move it there. Disabling and enabling clock to change their rate looks real odd to me. >> > +   rpc->cur_speed_hz = freq; >> > +   return ret; >> > +} >> > + >> > +static void rpc_spi_hw_init(struct rpc_spi *rpc) >> > +{ >> > +   /* >> > +    * NOTE: The 0x260 are undocumented bits, but they must be set. >> > +    */ >> >> FYI: >> > http://git.denx.de/?p=u-boot.git;a=blob;f=drivers/spi/renesas_rpc_spi.c#l207 >> >> I think the STRTIM should be 6 . >> > > In my D3 Draak board, the STRTIM is 0x3 for on board qspi flash and > mx25uw51245g. > And this is also refer to Renesas R-Car Gen3 bare-metal code, > mini-monitor v4.01. The copy of minimon I have says 6 , but maybe this is flash specific ? [...] >> > +         writel(rpc->cmd, rpc->regs + RPC_SMCMR); >> > +         writel(rpc->dummy, rpc->regs + RPC_SMDMCR); >> > +         writel(rpc->addr + pos, rpc->regs + RPC_SMADR); >> > +         writel(rpc->smenr, rpc->regs + RPC_SMENR); >> > +         writel(rpc->smcr | RPC_SMCR_SPIE, rpc->regs + RPC_SMCR); >> > +         ret = wait_msg_xfer_end(rpc); >> > +         if (ret) >> > +            goto out; >> > + >> > +         data = readl(rpc->regs + RPC_SMRDR0); >> > +         memcpy_fromio(rx_buf + pos, (void *)&data, nbytes); >> > +         pos += nbytes; >> > +      } >> > +   } else { >> > +      writel(rpc->cmd, rpc->regs + RPC_SMCMR); >> > +      writel(rpc->dummy, rpc->regs + RPC_SMDMCR); >> > +      writel(rpc->addr + pos, rpc->regs + RPC_SMADR); >> > +      writel(rpc->smenr, rpc->regs + RPC_SMENR); >> > +      writel(rpc->smcr | RPC_SMCR_SPIE, rpc->regs + RPC_SMCR); >> > +      ret = wait_msg_xfer_end(rpc); >> > +   } >> > +out: >> >> Dont you need to stop the RPC somehow in case the transmission fails ? > > It seems there is no any RPC registers bit to monitor xfer fail ! What happens if wait_msg_xfer_end() returns non-zero ? I guess that means the transfer timed out ? [...] >> > +static const struct of_device_id rpc_spi_of_ids[] = { >> > +   { .compatible = "renesas,rpc-r8a77995", }, >> > +   { /* sentinel */ } >> > +}; >> > +MODULE_DEVICE_TABLE(of, rpc_spi_of_ids); >> > + >> > +static struct platform_driver rpc_spi_driver = { >> > +   .probe = rpc_spi_probe, >> > +   .remove = rpc_spi_remove, >> > +   .driver = { >> > +      .name = "rpc-spi", >> > +      .of_match_table = rpc_spi_of_ids, >> > +      .pm = &rpc_spi_dev_pm_ops, >> > +   }, >> > +}; >> > +module_platform_driver(rpc_spi_driver); >> > + >> > +MODULE_AUTHOR("Mason Yang "); >> > +MODULE_DESCRIPTION("Renesas R-Car D3 RPC SPI controller driver"); >> >> This is not D3 specific and not SPI-only controller btw. > > In R-Car Gen3, there are some registers(i.e,. RPC_PHYCNT) in different > setting > for R-Car H3, M3-W, V3M, V3H, D3, M3-N and E3 model. > > I test this patch is based on D3 Draak board, it works fine but I am not > sure > if these registers setting is ok for others R-Card model. > > I think this could be a reference when patch others Gen3 model is needed. You can take a look into the U-Boot driver(s) I linked, that's used on the other SoCs you listed (except for V3H). -- Best regards, Marek Vasut