Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4189333yba; Tue, 9 Apr 2019 13:08:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqybDnWVmpWOnLcZRz145s6UC/jSCRNZpNG8jGRHsbvc7GMgcH+oEpZHyyc9s9WGG9lYKnyb X-Received: by 2002:a63:9246:: with SMTP id s6mr37506820pgn.316.1554840493163; Tue, 09 Apr 2019 13:08:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554840493; cv=none; d=google.com; s=arc-20160816; b=hulYUshDS0clDkL+Wytp1+H7WFlLkIjccWK++bkUr0a3hHjybEy7ZCKLRu61zs2b2p 8FryUNt7UBsaXy3snTOGmaxXutVliNAZu+8drwjTqNarQovsWwHnJa9dQQKi7LrI+Gkh lMa5Gzb9hpLqCwWcbiV4Tzkbh5IAlMUZU5CiQFGqt01jZI68etAdy9CyEHvM9pE1iacR z/jb/+08sMJ6FWVyq1RNo8N8B+Fd3Wo0bmWESDw1+Ks066gh01lLjDDaw2J/xBCCUKLW NAAUa+BSYgdy8NrqkUjjVeDU7Mve6iMLsp6G2p9kr5YyuW6ZAS1CCZ5oZ3LpTR0YWrrV daUg== 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:organization:from:references:cc:to:subject :dkim-signature; bh=Suw+of2KaJH2zATB+QZvfdbvIVGQDJppxQSWgUkDE3E=; b=oYnRQtud+6QvgKECxyvEdbvxGO+GZAF7bAjJZnQH/dRnk3eJwl5yx8a2JP0+NejTdS 8xj81Skn44A58vpXwzontzEBO9/ShgoaxJfaGoXE9C3nS7FETR/bRCDqLoGaemOFO9DO wXDKX4U1NVLK3aMUKCOfntwFiLdghYrLNZvnAfNDEvbSJO1zlwXc86IyoIEX6upDt0Tz md1tbKjYoqsVb+3VzKn1bxn1plua7IYQQKIvTdX28A/b42FKhaajtGhCWLLo2d2yBFz8 wdbGM8KI4O4iT/t8ve4q0jjNdPgTpHAQtARvcx0WfQdmVJeun7UAM9/MbTnGRzEtsqrt LXwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cogentembedded-com.20150623.gappssmtp.com header.s=20150623 header.b=QlNN6nnI; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q11si29729489pff.201.2019.04.09.13.07.56; Tue, 09 Apr 2019 13:08:13 -0700 (PDT) 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=@cogentembedded-com.20150623.gappssmtp.com header.s=20150623 header.b=QlNN6nnI; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726699AbfDIUHR (ORCPT + 99 others); Tue, 9 Apr 2019 16:07:17 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:37627 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726512AbfDIUHR (ORCPT ); Tue, 9 Apr 2019 16:07:17 -0400 Received: by mail-lf1-f65.google.com with SMTP id o19so13309521lfl.4 for ; Tue, 09 Apr 2019 13:07:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cogentembedded-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:organization:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Suw+of2KaJH2zATB+QZvfdbvIVGQDJppxQSWgUkDE3E=; b=QlNN6nnI7UO9A/eH6AbZCtnZ8P+46TBOb4KOzu1xkjAesFjq0bpLlHg+5cVN5YBOel T4RN8DjcMMPLpaaEG+jqSlugnz8xo+nRr/yS/F/YCstTEFpRaTydwoEhVK6vHepPog74 g3XWIWdbbyxAssfbVbDFXsiWPgwAzbVd4Y6fczLXSiBK0wLmA+0T3T03JIiwiebYxDIJ Gq1tfijzh4NAf81Mmnnc2oidMkH+Rd7SjBR+4K9TRAdReNV+0MJDbruDebKdgAT0lexa u+YZ+7U5ZiOvQWPWGp/dgECR12ovRKRFL8CX3gQhH0sd4U8QHWoBVzss9M+I+qw6xFWf VQRA== 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:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=Suw+of2KaJH2zATB+QZvfdbvIVGQDJppxQSWgUkDE3E=; b=EA3VEki5D8ochWxUTtFTj/BvsOnZ+q0HuBMCpiys/MzvBiLyB88Rz3vlILvYzIuvxA 7FDEn+kcGxTsqeIghCk4fmwCDFmqm4znpOKlIYbrMHnDOk6jtmiM6YkYwzbZf+vbqHLb JmVnR36iH8ZqiuQFQswXeRqVYQy2WzlWbFKiVOWlGYyn2iGk4ZqgjUSLd0QeCwK5bo0o vZnQqE8C6Fpyw8nTXuHqquv1lzTW/dS7V5hiia7Ao6KkDmPYDa61622xsvP7QCkX93/J 5W0e/2/ntEOeu9M7c2lfposPQge9bYRYJrqCF55TBwdMdTc7SY8299AV54IallRyM8tM g/Jw== X-Gm-Message-State: APjAAAV3di9ORzjNW6XyjhKlVLYL09Ji7gfNgBru3McHzhGH9h4RZ7IG P/3IQfXNJQRN7FA3pFne1C+083ExPEk= X-Received: by 2002:ac2:4981:: with SMTP id f1mr984618lfl.67.1554840435469; Tue, 09 Apr 2019 13:07:15 -0700 (PDT) Received: from wasted.cogentembedded.com ([31.173.87.214]) by smtp.gmail.com with ESMTPSA id m28sm7419405lfc.54.2019.04.09.13.07.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 13:07:14 -0700 (PDT) Subject: Re: [PATCH v9 2/3] spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver To: Mason Yang , broonie@kernel.org, marek.vasut@gmail.com, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, bbrezillon@kernel.org, linux-renesas-soc@vger.kernel.org, Geert Uytterhoeven , devicetree@vger.kernel.org, mark.rutland@arm.com, robh+dt@kernel.org, lee.jones@linaro.org Cc: juliensu@mxic.com.tw, Simon Horman , zhengxunli@mxic.com.tw References: <1553847606-18122-1-git-send-email-masonccyang@mxic.com.tw> <1553847606-18122-3-git-send-email-masonccyang@mxic.com.tw> From: Sergei Shtylyov Organization: Cogent Embedded Message-ID: Date: Tue, 9 Apr 2019 23:07:13 +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: <1553847606-18122-3-git-send-email-masonccyang@mxic.com.tw> Content-Type: text/plain; charset=utf-8 Content-Language: en-MW Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello! On 03/29/2019 11:20 AM, Mason Yang wrote: > Add a driver for Renesas R-Car Gen3 RPC-IF SPI controller. > > Signed-off-by: Mason Yang > Signed-off-by: Sergei Shtylyov [...] > diff --git a/drivers/spi/spi-renesas-rpc.c b/drivers/spi/spi-renesas-rpc.c > new file mode 100644 > index 0000000..037f273 > --- /dev/null > +++ b/drivers/spi/spi-renesas-rpc.c [...] [...] > +static ssize_t rpc_spi_mem_dirmap_write(struct spi_mem_dirmap_desc *desc, > + u64 offs, size_t len, const void *buf) > +{ > + struct rpc_spi *rpc = > + spi_controller_get_devdata(desc->mem->spi->controller); > + int ret; > + > + if (offs + desc->info.offset + len > U32_MAX) > + return -EINVAL; > + > + if (len > RPC_WBUF_SIZE) > + len = RPC_WBUF_SIZE; > + > + ret = rpc_spi_set_freq(rpc, desc->mem->spi->max_speed_hz); > + if (ret) > + return ret; > + > + rpc_spi_mem_set_prep_op_cfg(desc->mem->spi, > + &desc->info.op_tmpl, &offs, &len); > + > + regmap_update_bits(rpc->regmap, RPC_CMNCR, RPC_CMNCR_MD, RPC_CMNCR_MD); > + > + regmap_write(rpc->regmap, RPC_SMDRENR, 0); > + > + regmap_update_bits(rpc->regmap, RPC_PHYCNT, RPC_PHYCNT_STRTIM(7) | > + RPC_PHYCNT_WBUF2 | RPC_PHYCNT_WBUF, > + RPC_PHYCNT_WBUF2 | RPC_PHYCNT_WBUF); > + > + memcpy_toio(rpc->wbuf, buf, len); Wait, doesn't the manual say that the whole 256-byte buffer should be filled? I think that short chunks have to be written w/o WBUF (done, in fact, by the HF driver). > + > + regmap_write(rpc->regmap, RPC_SMCMR, rpc->cmd); > + regmap_write(rpc->regmap, RPC_SMADR, offs); > + regmap_write(rpc->regmap, RPC_SMENR, rpc->smenr); > + regmap_write(rpc->regmap, RPC_SMCR, rpc->smcr | RPC_SMCR_SPIE); > + ret = wait_msg_xfer_end(rpc); > + if (ret) > + goto err_out; > + > + regmap_write(rpc->regmap, RPC_DRCR, RPC_DRCR_RCF); > + > + regmap_update_bits(rpc->regmap, RPC_PHYCNT, RPC_PHYCNT_STRTIM(7) | > + RPC_PHYCNT_WBUF2 | RPC_PHYCNT_WBUF, > + RPC_PHYCNT_STRTIM(6)); > + > + return len; > + > +err_out: > + return reset_control_reset(rpc->rstc); > +} [...] MBR, Sergei