Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10446256imu; Thu, 6 Dec 2018 00:57:41 -0800 (PST) X-Google-Smtp-Source: AFSGD/WMHAfAHCuS4QlkZwV/zupQInXsYYJexiidiOrvG9vdzDi7SLWe1T7q62YCUVDwchJaTB+W X-Received: by 2002:a62:220d:: with SMTP id i13mr27538840pfi.162.1544086661140; Thu, 06 Dec 2018 00:57:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544086661; cv=none; d=google.com; s=arc-20160816; b=pJxONOXlCEa+TNpAkaheOBQn9yGIuGkxVWE7s8aIPXI9SkgruqDmhldtALCZ3qi1Xx fxdCkCaZwbA0qtK5XlEfE8D3HEnqyCwxEw1fdqTRFvHixBkzuLjQUTLv0f9IkAR42cyV nLoIc/zFtIhxmT73/v7FdxvsdkrmoCczw/WhPL+cFBDeQj797Pe20mQl4WthEHijYh/w yRo5RZXrgl0WsH4VIc3K3NBDFQzd9XxbOEpcJzImHiUXFNdhxgX/WVzajuGENKkkCabH 70ZmQ9tF4105MVG+ugSn9tX+OmAo6hP4W32r1xaustspz4/fMBjp6ywVT3bAv6C6bMPP xoOQ== 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=ppQG7sNryngECTu+LNkt4DIQCb8bcLgnVlG0Bpj+qVQ=; b=HmIFs4sC1LStr10T/iX/ILEtgZ7DKbShwG628+qRWSUcncPyTFA82WwkHbysNK2mdk h2oJ/+LvV3hjTpio4WGvsz5bo7wmb3SZTM9A/2fZuzEJ9bgaxKqnfArdfZ1f1lNMcAU9 eyHqylQ6nX2EhxNBZWCa3Pv6MXSCuVj5WPBBQu77cKsFVU6dExISpcrTenxNerSuJB2H m2GrjK9U8P2GEkQq5ocvWtpDXXJgJ06YnJfFEjAj+RgP8QVS/zeZKNJvwdYGtwSoaym2 YTfUd5lQco6wgXHDDPwR+LOD3lffd4rgIIataQi5qUgx/ayWQhypzNviNGaj07V7s+af c2+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=P6wFlKgE; 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 a193si22861280pfa.214.2018.12.06.00.57.25; Thu, 06 Dec 2018 00:57:41 -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=P6wFlKgE; 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 S1728865AbeLFI4t (ORCPT + 99 others); Thu, 6 Dec 2018 03:56:49 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:40693 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727575AbeLFI4s (ORCPT ); Thu, 6 Dec 2018 03:56:48 -0500 Received: by mail-wr1-f66.google.com with SMTP id p4so22381795wrt.7; Thu, 06 Dec 2018 00:56:46 -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=ppQG7sNryngECTu+LNkt4DIQCb8bcLgnVlG0Bpj+qVQ=; b=P6wFlKgEy2JX5KrhqwJZQ6CKo5Mg/B2QbnhEIHXyj4USiSbxZKUBsLojDylL03W3FC qCf1+90/vUwb56j8P1n/7xWaok/R/Pxh2nw9cNAapEvVqLMQk7wlpxlmGK69/fIpNGGH Qil5nV8Lqwqm/X+R/rqnw3KHks1bKQ+cNi1ZwFBHpc5+ElF2xNn1GsQIx4I9QPZVdEUC dnJcOFueno0N5Oo8WiJ3SEuZv/bRBox6E3ad0qKGUt2lwK/z7fQJK3MFL6VBn9KvjDEO TuGYvutMz/hnCp2nj70wZyX2yW/Q19IHqXXyYJJKM3jIWVB7g976WSVgRSgONCIG9fjs t9JA== 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=ppQG7sNryngECTu+LNkt4DIQCb8bcLgnVlG0Bpj+qVQ=; b=aiC996JHfS5pCHLakmZdsK/QDxZGUtdCXfe8wkzB/oNlkUhmW+RQlEgbfxaqkOYUvX VYrpflDmApGzPHlyzpuVjF1gl/sOrw8Hw6vLcMf5JIMlKMohJeucc2a+HKF5PlcfneSm vsfjUiF4Q1xnuyxLOYatS9/YoSVz0XZybyRiSkhF2h6KiGCX9OjDXccL+K5wi0QSjT5p LeWeySZzYBKlS2ZeMPDSOzvz1t2hp/VU+n6s1E1smp0DwA12D8h58sd3okiHMMDnEedN 6ufRi2ciQoV5Qae4/rW8KCcKzRzawssyqnWr/hgCY8+83onxM8Bo7cSAX2wbizqGKZl3 40mQ== X-Gm-Message-State: AA+aEWbG3Xx5joKLPKfd4DiRwWFcJzLcd+Huce6aGAtDX7Bd8lFuTvWl 8FlUruB4EmRGUsh2pjHJ5k0= X-Received: by 2002:adf:f101:: with SMTP id r1mr24950312wro.32.1544086606133; Thu, 06 Dec 2018 00:56:46 -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 k7sm25053359wrl.51.2018.12.06.00.56.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Dec 2018 00:56:45 -0800 (PST) Subject: Re: [PATCH v2 1/2] spi: Add Renesas R-Car Gen3 RPC SPI controller driver To: masonccyang@mxic.com.tw, Geert Uytterhoeven Cc: Boris Brezillon , Mark Brown , Geert Uytterhoeven , Simon Horman , juliensu@mxic.com.tw, Linux Kernel Mailing List , Linux-Renesas , linux-spi , zhengxunli@mxic.com.tw References: <1543828720-18345-1-git-send-email-masonccyang@mxic.com.tw> <1543828720-18345-2-git-send-email-masonccyang@mxic.com.tw> From: Marek Vasut Message-ID: <2c6c23fc-299a-f64d-c81f-4b4123f1577b@gmail.com> Date: Thu, 6 Dec 2018 09:56:43 +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 12/06/2018 06:56 AM, masonccyang@mxic.com.tw wrote: > Hi Geert, > >> "Geert Uytterhoeven" >> 2018/12/05 下午 05:06 >> >> To >> >> masonccyang@mxic.com.tw, >> >> cc >> >> "Mark Brown" , "Marek Vasut" >> , "Linux Kernel Mailing List" > kernel@vger.kernel.org>, "linux-spi" , >> "Boris Brezillon" , "Linux-Renesas" >> , "Geert Uytterhoeven" > +renesas@glider.be>, juliensu@mxic.com.tw, "Simon Horman" >> , zhengxunli@mxic.com.tw >> >> Subject >> >> Re: [PATCH v2 1/2] spi: Add Renesas R-Car Gen3 RPC SPI controller driver >> >> Hi Mason, >> >> On Mon, Dec 3, 2018 at 10:19 AM Mason Yang > wrote: >> > Add a driver for Renesas R-Car Gen3 RPC SPI controller. >> > >> > Signed-off-by: Mason Yang >> >> Thanks for your patch! >> >> > --- a/drivers/spi/Kconfig >> > +++ b/drivers/spi/Kconfig >> > @@ -528,6 +528,12 @@ config SPI_RSPI >> >         help >> >           SPI driver for Renesas RSPI and QSPI blocks. >> > >> > +config SPI_RENESAS_RPC >> > +       tristate "Renesas R-Car Gen3 RPC SPI controller" >> > +       depends on SUPERH || ARCH_RENESAS || COMPILE_TEST >> >> So this driver is intended for SuperH SoCs, too? >> If not, please drop the dependency. >> > > okay, I will drop "SUPERH". > >> > --- /dev/null >> > +++ b/drivers/spi/spi-renesas-rpc.c >> >> > +#ifdef CONFIG_RESET_CONTROLLER >> > +static int rpc_spi_do_reset(struct rpc_spi *rpc) >> >> What's the purpose of the reset routine? > > in case RPC xfer is time-out due to something wrong in RPC module, > as Marek comments. > >> Given the #ifdef, is it optional or required? >> >> > +{ >> > +       int i, ret; >> > + >> > +       ret = reset_control_reset(rpc->rstc); >> > +       if (ret) >> > +               return ret; >> > + >> > +       for (i = 0; i < LOOP_TIMEOUT; i++) { >> > +               ret = reset_control_status(rpc->rstc); >> > +               if (ret == 0) >> > +                       return 0; >> > +               usleep_range(0, 1); >> > +       } >> >> Why do you need this loop? >> The delay in cpg_mssr_reset() should be sufficient. >> > > yup, I know there is already 35 us delay in cpg_mssr_reset(). > If you think reset_control_status()checking is not necessary, > I will drop it. > >> > + >> > +       return -ETIMEDOUT; >> > +} >> > +#else >> > +static int rpc_spi_do_reset(struct rpc_spi *rpc) >> > +{ >> > +       return -ETIMEDOUT; >> > +} >> > +#endif >> >> > +static int rpc_spi_transfer_one_message(struct spi_master *master, >> > +                                       struct spi_message *msg) >> > +{ >> > +       struct rpc_spi *rpc = spi_master_get_devdata(master); >> > +       struct spi_transfer *t; >> > +       int ret; >> > + >> > +       rpc_spi_transfer_setup(rpc, msg); >> > + >> > +       list_for_each_entry(t, &msg->transfers, transfer_list) { >> > +               if (!list_is_last(&t->transfer_list, &msg->transfers)) >> > +                       continue; >> > +               ret = rpc_spi_xfer_message(rpc, t); >> >> rpc_spi_xfer_message() sounds like a bad name to me, given it operates >> on a transfer, not on a message. >> > > Because RPC send a entire SPI message at one time, not separately, > that is the 1'st transfer is for command, the 2'nd transfer is for > address/data > and so on. > The reason is CS# pin control restriction in RPC HW module. > > >> > +               if (ret) >> > +                       goto out; >> > +       } >> > + >> > +       msg->status = 0; >> > +       msg->actual_length = rpc->totalxferlen; >> > +out: >> > +       spi_finalize_current_message(master); >> > +       return 0; >> > +} >> >> >> > +static int rpc_spi_probe(struct platform_device *pdev) >> > +{ >> >> > +       rpc->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL); >> > +       if (IS_ERR(rpc->rstc)) >> > +               return PTR_ERR(rpc->rstc); >> >> This will return an error if CONFIG_RESET_CONTROLLER is not set, hence >> the #ifdef above is moot. >> > > You are right. > so, I should do > Option 1: remove #CONFIG_RESET_CONTROLLER > Option 2: add #CONFIG_RESET_CONTROLLER for > devm_reset_control_get_exclusive() > > please comments on it, thanks. > > >> > + >> > +       pm_runtime_enable(&pdev->dev); >> > +       master->auto_runtime_pm = true; >> > + >> > +       master->num_chipselect = 1; >> > +       master->mem_ops = &rpc_spi_mem_ops; >> > +       master->transfer_one_message = rpc_spi_transfer_one_message; >> >> Is there any reason you cannot use the standard >> spi_transfer_one_message, i.e. provide spi_controller.transfer_one() >> instead of spi_controller.transfer_one_message()? >> > > It seems there is a RPC HW restriction in CS# pin control. > Therefore, it can't send the 1'st spi-transfer for command and then > keeping CS# pin goes low for the 2'nd spi-transfer for address/data and > so on. Isn't register DRCR bit SSLN/SSLE exactly for this purpose ? -- Best regards, Marek Vasut