Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp332644ybh; Wed, 22 Jul 2020 01:38:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTG8prZbuLdzNswmPF3QAFwSxY5C8yXenF+hF9DUhST18OGh437mDCKjNEyBLoeSzYOSrV X-Received: by 2002:a17:906:3152:: with SMTP id e18mr30021480eje.137.1595407107860; Wed, 22 Jul 2020 01:38:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595407107; cv=none; d=google.com; s=arc-20160816; b=ay8WxneV5/uoyxq0klgEoGJYb1lUD0QS6pthUZjUWEvLT5+LrFyJ/j3JJI01UsXR1A kF/x1+uu8NzeSSVuphBLoblJOD1zgr5NvDeVpm22BJpwPUkBHVmz2R5qLrxUCQXYGkWi 276dQezqKn8tRefPg4aJ4fBFhdYOoo27GgKj6WulJ98LE6XVPvt6+DUaWGuodcKJPrBo 8ka0uPut+k6sfmBS2igj+XrMpcUJbbUaAFLAge5ugHor1Iwn8a7YnZZ3p+MBTdHi8G7l xnE4BgSI2crtrvMB0YlcK9deiogRksshhK164RG0uQ71Hd7C6MdEU+1MFW6zuaTYNUnD VF/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=hhHMUHO/+tbayX7+QhtvGQvA2XNoXfE0PK8YAtLfwLc=; b=T2uvpzhGg9CIvQseR0VBS0pEEtLNfVQDUfhkqj3EMK3d3W2HFTr3KYt32NJu4FKm0B 0d/pry0FvNZmwMY2xJFtDal9Qp7J50mkS3O1jLF3Am5FP+zhYkfKMF2M4j/dMS+G8T9E 1g6cDEsCIzDYWKh+zY/qOFRN0700cvJNXt0ygevM+nTJJYuyL06y6h58swSmyV29OECC d2IKn0S9/RhfNy1fnFItiMqGeBeocEFxYE2S11JlGaJNEVHiC3i9m3umRdkkw8PyaFDf pfKc7mso43aeKolQOL/8e3/CsI6AH7NaX7SRbroPuONVdKqr0EIgOoMsrm+7yH0DqW4e mSvQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d26si14049831edz.108.2020.07.22.01.38.04; Wed, 22 Jul 2020 01:38:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730415AbgGVIhz (ORCPT + 99 others); Wed, 22 Jul 2020 04:37:55 -0400 Received: from lucky1.263xmail.com ([211.157.147.131]:58162 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726506AbgGVIhy (ORCPT ); Wed, 22 Jul 2020 04:37:54 -0400 X-Greylist: delayed 6286 seconds by postgrey-1.27 at vger.kernel.org; Wed, 22 Jul 2020 04:37:52 EDT Received: from localhost (unknown [192.168.167.69]) by lucky1.263xmail.com (Postfix) with ESMTP id D6D23B06D9; Wed, 22 Jul 2020 16:37:46 +0800 (CST) X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-ADDR-CHECKED4: 1 X-ANTISPAM-LEVEL: 2 X-ABS-CHECKED: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (postfix) whith ESMTP id P18496T139713711163136S1595407061138531_; Wed, 22 Jul 2020 16:37:46 +0800 (CST) X-IP-DOMAINF: 1 X-UNIQUE-TAG: <64c73d06eb89aff01dd3061ed0c7d184> X-RL-SENDER: jon.lin@rock-chips.com X-SENDER: jon.lin@rock-chips.com X-LOGIN-NAME: jon.lin@rock-chips.com X-FST-TO: broonie@kernel.org X-SENDER-IP: 58.22.7.114 X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 X-System-Flag: 0 From: Jon Lin To: broonie@kernel.org Cc: heiko@sntech.de, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Jon Lin Subject: [PATCH v2 2/3] spi: rockchip: Support 64-location deep FIFOs Date: Wed, 22 Jul 2020 16:37:36 +0800 Message-Id: <20200722083737.8820-2-jon.lin@rock-chips.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200722083737.8820-1-jon.lin@rock-chips.com> References: <20200722083737.8820-1-jon.lin@rock-chips.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The FIFO depth of SPI V2 is 64 instead of 32, add support for it. Signed-off-by: Jon Lin --- drivers/spi/spi-rockchip.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c index 63593a5b87fa..a451dacab5cf 100644 --- a/drivers/spi/spi-rockchip.c +++ b/drivers/spi/spi-rockchip.c @@ -39,8 +39,9 @@ #define ROCKCHIP_SPI_RISR 0x0034 #define ROCKCHIP_SPI_ICR 0x0038 #define ROCKCHIP_SPI_DMACR 0x003c -#define ROCKCHIP_SPI_DMATDLR 0x0040 -#define ROCKCHIP_SPI_DMARDLR 0x0044 +#define ROCKCHIP_SPI_DMATDLR 0x0040 +#define ROCKCHIP_SPI_DMARDLR 0x0044 +#define ROCKCHIP_SPI_VERSION 0x0048 #define ROCKCHIP_SPI_TXDR 0x0400 #define ROCKCHIP_SPI_RXDR 0x0800 @@ -156,6 +157,8 @@ #define ROCKCHIP_SPI_MAX_TRANLEN 0xffff #define ROCKCHIP_SPI_MAX_CS_NUM 2 +#define ROCKCHIP_SPI_VER2_TYPE1 0x05EC0002 +#define ROCKCHIP_SPI_VER2_TYPE2 0x00110002 struct rockchip_spi { struct device *dev; @@ -206,17 +209,17 @@ static inline void wait_for_idle(struct rockchip_spi *rs) static u32 get_fifo_len(struct rockchip_spi *rs) { - u32 fifo; + u32 ver; - for (fifo = 2; fifo < 32; fifo++) { - writel_relaxed(fifo, rs->regs + ROCKCHIP_SPI_TXFTLR); - if (fifo != readl_relaxed(rs->regs + ROCKCHIP_SPI_TXFTLR)) - break; - } - - writel_relaxed(0, rs->regs + ROCKCHIP_SPI_TXFTLR); + ver = readl_relaxed(rs->regs + ROCKCHIP_SPI_VERSION); - return (fifo == 31) ? 0 : fifo; + switch (ver) { + case ROCKCHIP_SPI_VER2_TYPE1: + case ROCKCHIP_SPI_VER2_TYPE2: + return 64; + default: + return 32; + } } static void rockchip_spi_set_cs(struct spi_device *spi, bool enable) -- 2.17.1