From patchwork Mon Dec 12 18:07:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 13071308 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47919C4167B for ; Mon, 12 Dec 2022 18:08:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233346AbiLLSIj (ORCPT ); Mon, 12 Dec 2022 13:08:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233268AbiLLSIK (ORCPT ); Mon, 12 Dec 2022 13:08:10 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E56915F6E for ; Mon, 12 Dec 2022 10:07:43 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id r7-20020a1c4407000000b003d1e906ca23so4745586wma.3 for ; Mon, 12 Dec 2022 10:07:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=X/E0yrCX/w68NetnkW1cEsRRs5XY/9DzIPnhuqKIJns=; b=OyvO0QzJj1fhziCAWdsYVx/UKbdbBA4bx3cDt9uIGpPMmdedpdt31DOtoeammzLoea MJHFt3njOaFOOeUELbZ842aNblDbokMI4RvBNRkbc5qj7w4gep0sp+vzAnVOqBZnQYIu 1N/LYxrLJXJXhrZNwbAXDmsP+xlnSfu8aZEZwFTKBElspvB0NyPKR4Hx1J1MUKVnqPML CeljWIj8fpFup/xt1GaK8CEXQ7e53MUv7wnTbo3eChXfo9LZ7nn8wZ2ciILLn6syxDxt wVbjBG5Is6qAE+oVIaJXAxzQPY9eWtWGmNkuivM7/+CLj3ByttgPD8BSV770u4X0IQ+n pbVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=X/E0yrCX/w68NetnkW1cEsRRs5XY/9DzIPnhuqKIJns=; b=NZ1Vti6NaHYSfGCFjaK20kLznzpgCUyCvo9R2K5dexcbatND9CBCzmZ6C7JRv1zpxd LfGgn19sPbIYCwkPBVoJPTS4SrKKhIkf/+ZtvgNGHLOqxKv6Wqx7ekMNvslK/R0zGeqj pQvo2m0WBeqgWIMftH40440jYeOLiJi+51T8ETjOnTF2f+pib2zDNrIgHay9iG3NzBGa bOvhW1qXJ9ykMazSG0Ghqmhe3+P2we73A12VNGzBF5wGYw+wt/GpCAZjo1CYYdS9q/Fr bG9Vy12jC8VUUZIm6UGEOpwnoZwtputo4lTrrUworW9zUlBk9V1OKOiGjYl03JZGLD1U MjAA== X-Gm-Message-State: ANoB5pluZtMUczUUowEvX9oQHSd9olHQEdBsGHGXCVzBhiBuMWO0or/t Aip0wLKV0HEXU918WWnSIfBl4g== X-Google-Smtp-Source: AA0mqf71R8FCWfC8x8sqet7rycmRYXZKz3wn9O5O4w6CxCK/2v61XZyRVq4eLvrmv7PTC/CGlUpUqw== X-Received: by 2002:a05:600c:1e18:b0:3d2:26e1:bd45 with SMTP id ay24-20020a05600c1e1800b003d226e1bd45mr3859314wmb.29.1670868462552; Mon, 12 Dec 2022 10:07:42 -0800 (PST) Received: from localhost.localdomain (host-78-150-37-98.as13285.net. [78.150.37.98]) by smtp.gmail.com with ESMTPSA id t123-20020a1c4681000000b003a3170a7af9sm10156808wma.4.2022.12.12.10.07.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 10:07:41 -0800 (PST) From: Sudip Mukherjee To: Serge Semin , Mark Brown , Rob Herring , Krzysztof Kozlowski Cc: jude.onyenegecha@sifive.com, ben.dooks@sifive.com, jeegar.lakhani@sifive.com, linux-spi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Sudip Mukherjee Subject: [PATCH v2 01/15] spi: dw: Introduce spi_frf and STD_SPI Date: Mon, 12 Dec 2022 18:07:18 +0000 Message-Id: <20221212180732.79167-2-sudip.mukherjee@sifive.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221212180732.79167-1-sudip.mukherjee@sifive.com> References: <20221212180732.79167-1-sudip.mukherjee@sifive.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org The DW APB SSI controllers of v4.x and newer and DW AHB SSI controllers supports enhanced SPI modes which can be defined from SPI_FRF of DW_SPI_CTRLR0 register. Without enhanced mode, these controllers will work in the standard spi mode. Signed-off-by: Sudip Mukherjee --- drivers/spi/spi-dw-core.c | 13 ++++++++++++- drivers/spi/spi-dw.h | 6 ++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c index 99edddf9958b9..77c23772bb3d9 100644 --- a/drivers/spi/spi-dw-core.c +++ b/drivers/spi/spi-dw-core.c @@ -333,6 +333,16 @@ void dw_spi_update_config(struct dw_spi *dws, struct spi_device *spi, /* CTRLR0[11:10] Transfer Mode */ cr0 |= FIELD_PREP(DW_HSSI_CTRLR0_TMOD_MASK, cfg->tmode); + if (dw_spi_ver_is_ge(dws, HSSI, 103A)) { + cr0 &= ~DW_HSSI_CTRLR0_SPI_FRF_MASK; + cr0 |= FIELD_PREP(DW_HSSI_CTRLR0_SPI_FRF_MASK, + cfg->spi_frf); + } else if (dw_spi_ver_is_ge(dws, PSSI, 400A)) { + cr0 &= ~DW_PSSI_CTRLR0_SPI_FRF_MASK; + cr0 |= FIELD_PREP(DW_PSSI_CTRLR0_SPI_FRF_MASK, + cfg->spi_frf); + } + dw_writel(dws, DW_SPI_CTRLR0, cr0); if (cfg->tmode == DW_SPI_CTRLR0_TMOD_EPROMREAD || @@ -422,6 +432,7 @@ static int dw_spi_transfer_one(struct spi_controller *master, .tmode = DW_SPI_CTRLR0_TMOD_TR, .dfs = transfer->bits_per_word, .freq = transfer->speed_hz, + .spi_frf = DW_SPI_CTRLR0_SPI_FRF_STD_SPI, }; int ret; @@ -664,7 +675,7 @@ static void dw_spi_stop_mem_op(struct dw_spi *dws, struct spi_device *spi) static int dw_spi_exec_mem_op(struct spi_mem *mem, const struct spi_mem_op *op) { struct dw_spi *dws = spi_controller_get_devdata(mem->spi->controller); - struct dw_spi_cfg cfg; + struct dw_spi_cfg cfg = {0}; unsigned long flags; int ret; diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h index 9e8eb2b52d5c7..414a415deb42a 100644 --- a/drivers/spi/spi-dw.h +++ b/drivers/spi/spi-dw.h @@ -17,6 +17,8 @@ /* Synopsys DW SSI component versions (FourCC sequence) */ #define DW_HSSI_102A 0x3130322a +#define DW_HSSI_103A 0x3130332a +#define DW_PSSI_400A 0x3430302a /* DW SSI IP-core ID and version check helpers */ #define dw_spi_ip_is(_dws, _ip) \ @@ -94,6 +96,9 @@ #define DW_HSSI_CTRLR0_TMOD_MASK GENMASK(11, 10) #define DW_HSSI_CTRLR0_SRL BIT(13) #define DW_HSSI_CTRLR0_MST BIT(31) +#define DW_HSSI_CTRLR0_SPI_FRF_MASK GENMASK(23, 22) +#define DW_PSSI_CTRLR0_SPI_FRF_MASK GENMASK(22, 21) +#define DW_SPI_CTRLR0_SPI_FRF_STD_SPI 0x0 /* Bit fields in CTRLR1 */ #define DW_SPI_NDF_MASK GENMASK(15, 0) @@ -135,6 +140,7 @@ struct dw_spi_cfg { u8 dfs; u32 ndf; u32 freq; + u8 spi_frf; }; struct dw_spi; From patchwork Mon Dec 12 18:07:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 13071309 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01612C10F31 for ; Mon, 12 Dec 2022 18:08:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233058AbiLLSIl (ORCPT ); Mon, 12 Dec 2022 13:08:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233060AbiLLSIL (ORCPT ); Mon, 12 Dec 2022 13:08:11 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D97F5F7A for ; Mon, 12 Dec 2022 10:07:44 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id ay40so6225507wmb.2 for ; Mon, 12 Dec 2022 10:07:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QJpkfVk+rL7x2b/nU0sS6OBZ4oN2z+03SLnndpdgjrU=; b=coay2wl1/s4NDUzaAH2FelFujb/pQqhfoq0CyZRpTKnSSwiKcrzDD+0bA4jNeymiZq G6f/dJWF/DY2krfbefg0qOwxesLZjGG9xa095p/CHtnx54LwSN/fhQvceSupQdQjrTDu n9E3MRzbuQI1d3G16erMlXsPmD/wqVgbaDynUY2jXO9sWteacVm0Jm0htSHkQqurCeEL lbZiNQLFjqXhS98gCH2lw+ifkT5cVUP6awQdApA5uARg4sBrrqBSR03Fq6a2eRVB2vkg X3tUGPhyuNH5knqXkzt3HFg3bzQJ8dgYnSZu5Hp8LcAu7q9DqCXjL5fSNOF1q99kpYSi CuXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QJpkfVk+rL7x2b/nU0sS6OBZ4oN2z+03SLnndpdgjrU=; b=JjbfadHeO1fk4D9n1iDRHnASQ5NhXDF2EnMNhNGlQNQDdR1eW9QlMvItBR7VMgCVp2 WfXDlYXY1Wkp1rUCXk2mmr3E5VKj1KPEJsSoGwqnX1CgaC2bV1EfT2ZljxZ/PK6P8it4 BMsCRpUdyQaJ3HZry4iin0TryWXsMAte88uvrzejO6hNBzvjX+uSmWZ1EeAtnKx852B9 vd5P/X27WLAa46+a9o/911kwE3INbdTpOtgTYiM8YH5rEZHU7W5kBoT7N8vI7d51/i1a CU7vXQWDv4REf0lp7Bp/qPNkQO7rLyl9GUTqDidWLbt3is1p+rB4F2zLM9tCic1Xlgoo pACA== X-Gm-Message-State: ANoB5pkqSziccGS38JyKaUXxI8gbxsoARXbVrODXVW2yi59UoIVyMvlm 6NlMFmQok5I+xwhkJhw9R5RtKw== X-Google-Smtp-Source: AA0mqf5cAskf49A0ST3HZiQkCFRj43GVuLuMuTT6xeW8YU6CvinMbu6M9kKaMkfbKpgF9qujMnRkLw== X-Received: by 2002:a7b:c5c4:0:b0:3d1:f234:12cc with SMTP id n4-20020a7bc5c4000000b003d1f23412ccmr12919514wmk.33.1670868463449; Mon, 12 Dec 2022 10:07:43 -0800 (PST) Received: from localhost.localdomain (host-78-150-37-98.as13285.net. [78.150.37.98]) by smtp.gmail.com with ESMTPSA id t123-20020a1c4681000000b003a3170a7af9sm10156808wma.4.2022.12.12.10.07.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 10:07:43 -0800 (PST) From: Sudip Mukherjee To: Serge Semin , Mark Brown , Rob Herring , Krzysztof Kozlowski Cc: jude.onyenegecha@sifive.com, ben.dooks@sifive.com, jeegar.lakhani@sifive.com, linux-spi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Sudip Mukherjee Subject: [PATCH v2 02/15] spi: dw: update NDF while using enhanced spi mode Date: Mon, 12 Dec 2022 18:07:19 +0000 Message-Id: <20221212180732.79167-3-sudip.mukherjee@sifive.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221212180732.79167-1-sudip.mukherjee@sifive.com> References: <20221212180732.79167-1-sudip.mukherjee@sifive.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org If the transfer of Transmit only mode is using dual/quad/octal SPI then NDF needs to be updated with the number of data frames. If the Transmit FIFO goes empty in-between, DWC_ssi masks the serial clock and wait for rest of the data until the programmed amount of frames are transferred successfully. Signed-off-by: Sudip Mukherjee --- drivers/spi/spi-dw-core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c index 77c23772bb3d9..8c47a4d14b666 100644 --- a/drivers/spi/spi-dw-core.c +++ b/drivers/spi/spi-dw-core.c @@ -346,7 +346,9 @@ void dw_spi_update_config(struct dw_spi *dws, struct spi_device *spi, dw_writel(dws, DW_SPI_CTRLR0, cr0); if (cfg->tmode == DW_SPI_CTRLR0_TMOD_EPROMREAD || - cfg->tmode == DW_SPI_CTRLR0_TMOD_RO) + cfg->tmode == DW_SPI_CTRLR0_TMOD_RO || + (cfg->tmode == DW_SPI_CTRLR0_TMOD_TO && + cfg->spi_frf != DW_SPI_CTRLR0_SPI_FRF_STD_SPI)) dw_writel(dws, DW_SPI_CTRLR1, cfg->ndf ? cfg->ndf - 1 : 0); /* Note DW APB SSI clock divider doesn't support odd numbers */ From patchwork Mon Dec 12 18:07:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 13071311 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB88CC4167B for ; Mon, 12 Dec 2022 18:08:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233375AbiLLSIt (ORCPT ); Mon, 12 Dec 2022 13:08:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233209AbiLLSIN (ORCPT ); Mon, 12 Dec 2022 13:08:13 -0500 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05BD96242 for ; Mon, 12 Dec 2022 10:07:45 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id r7-20020a1c4407000000b003d1e906ca23so4745649wma.3 for ; Mon, 12 Dec 2022 10:07:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8xbJ67M7jKeuB1IJ5u3bcr0Za5IuyIS26G5fd5X0pUA=; b=fa/TInl4rJ2lDHUu5pDHgcAEOUC2/WYrg9+qcebp/lkZ8OeOls//4/jDHGVQjpKfpw TKtJY556TrXdt+grSc2oM5LoQj6rw7NMQyzgMH6NkJ/YdMn5RMzkCe3spTsJmW9tQOyH dnd8Ib5JaCvll3f8S7aIq+o3n7wvZdSEskaq0F7alC5SxLWzKI7/+0s0IPX8UW1dwaEM ajAU2Gmyn4XQ94AgicH9gDUpzt8BR9CoLURbRry74KWXsFZtQ41FyHNfQ8tu9B7BBsjU cxPQU6w3qsd7m6BhxWshl+2a1LZB1otDmO1qM/8N6U8m7dIaV9ap8NJBfBhGCgGa3XDh jzfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8xbJ67M7jKeuB1IJ5u3bcr0Za5IuyIS26G5fd5X0pUA=; b=gjCf7X/F+P1ixIS5n/JboJCXBnzEdweTrDhYR4IZXlHO3vAhPzZRvXiWtFzBVh6m10 JdcGerecNIKZdAYykqvYIY8Xl9jYIQh4U3wjm5UtHosYbkec53SktnekkS9Bz06yW2jA JvLEy5pUkciHi45JpsRfMCb2mbDEyLXdxzSg2WMfXhqYOVkMpGs0fnTD9wq7/vgDyXW/ igS7vqmfMiWOjRcUIA8Gxofj2gPBmGPtTCUgQZNZcLAxuKpylVmRhca7iCkolVwfgWnm jefUkc7CNTlW/hAzuEoDlBUt6MajLZ6F8QkRsOQV1B07HhSKda+l9rfhrHA7/dQ9imvz 4jow== X-Gm-Message-State: ANoB5pmrY4vMzBxj20cfd61Va8JyIeg4R6+jS2OPGIJaWXmD3OXnl7mL 3vV0/r8IsbcUfj0ZIJkWUyER1Q== X-Google-Smtp-Source: AA0mqf6Bytvk/F6U22VWQx4z6V2kb2UXjONKxGpmi3o1oRmp2cGf8KUnDe8XAi0fsPVsM+XJjpHNlg== X-Received: by 2002:a05:600c:2215:b0:3cf:6d5b:875e with SMTP id z21-20020a05600c221500b003cf6d5b875emr13385139wml.12.1670868464393; Mon, 12 Dec 2022 10:07:44 -0800 (PST) Received: from localhost.localdomain (host-78-150-37-98.as13285.net. [78.150.37.98]) by smtp.gmail.com with ESMTPSA id t123-20020a1c4681000000b003a3170a7af9sm10156808wma.4.2022.12.12.10.07.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 10:07:44 -0800 (PST) From: Sudip Mukherjee To: Serge Semin , Mark Brown , Rob Herring , Krzysztof Kozlowski Cc: jude.onyenegecha@sifive.com, ben.dooks@sifive.com, jeegar.lakhani@sifive.com, linux-spi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Sudip Mukherjee Subject: [PATCH v2 03/15] spi: dw: update SPI_CTRLR0 register Date: Mon, 12 Dec 2022 18:07:20 +0000 Message-Id: <20221212180732.79167-4-sudip.mukherjee@sifive.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221212180732.79167-1-sudip.mukherjee@sifive.com> References: <20221212180732.79167-1-sudip.mukherjee@sifive.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org If the SPI transfer is being done in enhanced mode then SPI_CTRLR0 register needs to be updated to mention the instruction length, address length, address and instruction transfer format, wait cycles. And, we also need to enable clock stretching. Signed-off-by: Sudip Mukherjee --- drivers/spi/spi-dw-core.c | 14 +++++++++++++- drivers/spi/spi-dw.h | 11 +++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c index 8c47a4d14b666..d59401f16c47a 100644 --- a/drivers/spi/spi-dw-core.c +++ b/drivers/spi/spi-dw-core.c @@ -320,7 +320,7 @@ void dw_spi_update_config(struct dw_spi *dws, struct spi_device *spi, { struct dw_spi_chip_data *chip = spi_get_ctldata(spi); u32 cr0 = chip->cr0; - u32 speed_hz; + u32 speed_hz, spi_ctrlr0; u16 clk_div; /* CTRLR0[ 4/3: 0] or CTRLR0[ 20: 16] Data Frame Size */ @@ -365,6 +365,18 @@ void dw_spi_update_config(struct dw_spi *dws, struct spi_device *spi, dw_writel(dws, DW_SPI_RX_SAMPLE_DLY, chip->rx_sample_dly); dws->cur_rx_sample_dly = chip->rx_sample_dly; } + + if (cfg->spi_frf != DW_SPI_CTRLR0_SPI_FRF_STD_SPI) { + spi_ctrlr0 = DW_SPI_SPI_CTRLR0_CLK_STRETCH_EN; + spi_ctrlr0 |= FIELD_PREP(DW_SPI_SPI_CTRLR0_WAIT_CYCLE_MASK, + cfg->wait_c); + spi_ctrlr0 |= FIELD_PREP(DW_SPI_SPI_CTRLR0_INST_L_MASK, + cfg->inst_l); + spi_ctrlr0 |= FIELD_PREP(DW_SPI_SPI_CTRLR0_ADDR_L_MASK, + cfg->addr_l); + spi_ctrlr0 |= cfg->trans_t; + dw_writel(dws, DW_SPI_SPI_CTRLR0, spi_ctrlr0); + } } EXPORT_SYMBOL_NS_GPL(dw_spi_update_config, SPI_DW_CORE); diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h index 414a415deb42a..f29d89d05f34b 100644 --- a/drivers/spi/spi-dw.h +++ b/drivers/spi/spi-dw.h @@ -63,6 +63,7 @@ #define DW_SPI_DR 0x60 #define DW_SPI_RX_SAMPLE_DLY 0xf0 #define DW_SPI_CS_OVERRIDE 0xf4 +#define DW_SPI_SPI_CTRLR0 0xf4 /* Bit fields in CTRLR0 (DWC APB SSI) */ #define DW_PSSI_CTRLR0_DFS_MASK GENMASK(3, 0) @@ -126,6 +127,12 @@ #define DW_SPI_DMACR_RDMAE BIT(0) #define DW_SPI_DMACR_TDMAE BIT(1) +/* Bit fields in SPI_CTRLR0 */ +#define DW_SPI_SPI_CTRLR0_CLK_STRETCH_EN BIT(30) +#define DW_SPI_SPI_CTRLR0_WAIT_CYCLE_MASK GENMASK(15, 11) +#define DW_SPI_SPI_CTRLR0_INST_L_MASK GENMASK(9, 8) +#define DW_SPI_SPI_CTRLR0_ADDR_L_MASK GENMASK(5, 2) + /* Mem/DMA operations helpers */ #define DW_SPI_WAIT_RETRIES 5 #define DW_SPI_BUF_SIZE \ @@ -141,6 +148,10 @@ struct dw_spi_cfg { u32 ndf; u32 freq; u8 spi_frf; + u8 trans_t; + u8 inst_l; + u8 addr_l; + u8 wait_c; }; struct dw_spi; From patchwork Mon Dec 12 18:07:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 13071312 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0F2AC00145 for ; Mon, 12 Dec 2022 18:08:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233379AbiLLSIu (ORCPT ); Mon, 12 Dec 2022 13:08:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233281AbiLLSIP (ORCPT ); Mon, 12 Dec 2022 13:08:15 -0500 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98C2F62C0 for ; Mon, 12 Dec 2022 10:07:46 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id ay14-20020a05600c1e0e00b003cf6ab34b61so5918826wmb.2 for ; Mon, 12 Dec 2022 10:07:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nw+ztXnGHyYMBnK3u6yi+RJj9VVFK1mXZxrwwWAC58Q=; b=EvYV9N3cBCbuzunyGyGBwPjVCAOQTwLKBpRwnztfxX/N0iezAJEtIytpW67I/MdrQD KNrYxyvS+4vv6nkIbCMWvJ+SEsNj1uFJMDG7rIqyqU4Zs5kpglFNYR5483GCntPab2kD VGpvXxQVl8pOTKbQDFxYVqmGi0wY2DYroI4eJQLdkR52cG5Pcx1pTz1+86O7zjBE8xiD Fyw4SHZVm15O1EX5AsP+NiX/AdMPTfdXmyb5R0gnbOUcgsYt/JbAT7uRrg3u7Iwo51Jh ZJHhhILurAA0Q79eBpGlPWuBqe73HU228C3hThXTIxoldWacfOTBBDXGzlXzunqbl9iN Djsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nw+ztXnGHyYMBnK3u6yi+RJj9VVFK1mXZxrwwWAC58Q=; b=p6n9uxgiAAarvH12bK5tdVp6/9kKEVLld1CHB1HL4FK2vaaqeuHP6yWcIn+5yYV0Uh fu4w7hw/DpYKJyo7DCT9vJ7pnkL0fPzQIhTZ3CzlDFav4b24DDQFK3zpm9mKCNZffTWc nTc9T7CMmV4cEjpidxpqov4pEAhOAWYLdbxzVwUUFtMOPAbP1j+zWGp8eQhZ1u0WLiMs FNwja5a0IiZGfEWbI460KjND76hocUYebd/uxOQ8B8E4MTY1EA+FpiLBVXv9p8SQb304 CgkmxZS2pRRocKG5n/OjBFFYp+JUJTtk8yiWsrFZRXuQ83RcoQQAfpOpEAyqBZzKHedR dSTA== X-Gm-Message-State: ANoB5pnFhzqITQu2rZZEtsO/JpnZmPK6RQkMptHvxyHjh3STWSxWcxyQ XT4XJBzYU0yjk0Uphf2hHNUpsA== X-Google-Smtp-Source: AA0mqf5KMcfn7iP1eT6WO0H/6cWI/GBnzosK+colz6z78tS3vV/u6E7QlnAPi4MFVqa+WDaCiLR39A== X-Received: by 2002:a05:600c:3512:b0:3d1:fcb4:4074 with SMTP id h18-20020a05600c351200b003d1fcb44074mr16382196wmq.22.1670868465259; Mon, 12 Dec 2022 10:07:45 -0800 (PST) Received: from localhost.localdomain (host-78-150-37-98.as13285.net. [78.150.37.98]) by smtp.gmail.com with ESMTPSA id t123-20020a1c4681000000b003a3170a7af9sm10156808wma.4.2022.12.12.10.07.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 10:07:44 -0800 (PST) From: Sudip Mukherjee To: Serge Semin , Mark Brown , Rob Herring , Krzysztof Kozlowski Cc: jude.onyenegecha@sifive.com, ben.dooks@sifive.com, jeegar.lakhani@sifive.com, linux-spi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Sudip Mukherjee Subject: [PATCH v2 04/15] spi: dw: add check for support of enhanced spi Date: Mon, 12 Dec 2022 18:07:21 +0000 Message-Id: <20221212180732.79167-5-sudip.mukherjee@sifive.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221212180732.79167-1-sudip.mukherjee@sifive.com> References: <20221212180732.79167-1-sudip.mukherjee@sifive.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Before doing the mem op, spi controller will be queried about the buswidths it supports. Add the dual/quad/octal if the controller has the DW_SPI_CAP_EMODE capability. The DW_SPI_CAP_EMODE capability will be enabled in a later patch. Signed-off-by: Sudip Mukherjee --- drivers/spi/spi-dw-core.c | 25 ++++++++++++++++++++++++- drivers/spi/spi-dw.h | 1 + 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c index d59401f16c47a..49fad58ceb94a 100644 --- a/drivers/spi/spi-dw-core.c +++ b/drivers/spi/spi-dw-core.c @@ -510,6 +510,26 @@ static int dw_spi_adjust_mem_op_size(struct spi_mem *mem, struct spi_mem_op *op) return 0; } +static bool dw_spi_supports_enh_mem_op(struct spi_mem *mem, + const struct spi_mem_op *op) +{ + if (op->addr.nbytes != 0 && op->addr.buswidth != 1 && + op->addr.buswidth != op->data.buswidth) + return false; + + if (op->cmd.buswidth != 1 && op->cmd.buswidth != op->addr.buswidth && + op->cmd.buswidth != op->data.buswidth) + return false; + + if (op->dummy.nbytes != 0 && op->data.dir == SPI_MEM_DATA_OUT) + return false; + + if (op->dummy.nbytes != 0 && op->dummy.nbytes / op->dummy.buswidth > 4) + return false; + + return spi_mem_default_supports_op(mem, op); +} + static bool dw_spi_supports_mem_op(struct spi_mem *mem, const struct spi_mem_op *op) { @@ -792,7 +812,10 @@ static void dw_spi_init_mem_ops(struct dw_spi *dws) if (!dws->mem_ops.exec_op && !(dws->caps & DW_SPI_CAP_CS_OVERRIDE) && !dws->set_cs) { dws->mem_ops.adjust_op_size = dw_spi_adjust_mem_op_size; - dws->mem_ops.supports_op = dw_spi_supports_mem_op; + if (dws->caps & DW_SPI_CAP_EMODE) + dws->mem_ops.supports_op = dw_spi_supports_enh_mem_op; + else + dws->mem_ops.supports_op = dw_spi_supports_mem_op; dws->mem_ops.exec_op = dw_spi_exec_mem_op; if (!dws->max_mem_freq) dws->max_mem_freq = dws->max_freq; diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h index f29d89d05f34b..327d037bdb10e 100644 --- a/drivers/spi/spi-dw.h +++ b/drivers/spi/spi-dw.h @@ -34,6 +34,7 @@ /* DW SPI controller capabilities */ #define DW_SPI_CAP_CS_OVERRIDE BIT(0) #define DW_SPI_CAP_DFS32 BIT(1) +#define DW_SPI_CAP_EMODE BIT(2) /* Register offsets (Generic for both DWC APB SSI and DWC SSI IP-cores) */ #define DW_SPI_CTRLR0 0x00 From patchwork Mon Dec 12 18:07:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 13071313 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A3BFC4167B for ; Mon, 12 Dec 2022 18:09:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233398AbiLLSJC (ORCPT ); Mon, 12 Dec 2022 13:09:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233282AbiLLSIQ (ORCPT ); Mon, 12 Dec 2022 13:08:16 -0500 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 413FC633E for ; Mon, 12 Dec 2022 10:07:47 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id ay40so6225612wmb.2 for ; Mon, 12 Dec 2022 10:07:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MsoM+2FQBABifbzzxTm/pfwezHeQcE6N/+8ll5MsoOw=; b=Md4f76Y0GJL7Vusa6Dqcb75nScdp9KXiro9C6IUfaV5m/P2cv0FNSMcyKuhcRr9moJ RKXVyj6Hga4nhoIZG59Dtp5eKMln5OP8+USKZMHuyNledotanueS+ZWKILZAhsj/CCdL 5WYRPvL4/mJ0CvhHGl1xk/5snCv/sMCEhprJflSP47TnRgbSPRMqxT9NbsMc0O2igNen esg7TeKa5T6GqfZvtqwbE359U4TGNMSb6l3StEnxQOQxu2B7YOyT5EiU9lJsQCj4nDhQ YFWvQ3t1dcwlmLXT9/+476ETjI/b84lPxPOpS8EZriHQWkwOZqTh2UXMiouAce0ox7Mj E09Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MsoM+2FQBABifbzzxTm/pfwezHeQcE6N/+8ll5MsoOw=; b=2hTlllssyzXoGEMKJrEnJ4J2p/BLtwfXfmLkx33ntKsK1Sz3gzNdvIYbOBHpKm5BA0 APjA4OI21WQzBIvc2zIUh6hsPwnBcAzADNamSMpWRXRR/mhs25dwSWAuOnZZWxeEIXiC yS9DyI+V0u1ofnuWurnlQas6WHrlg+dES965jofimfedrnf0Cww7UvfnGuD44A7N6ajH aUaR48689kwX6ecxgFuBkbwLm4kmSgi4zRT+fNjgwDlzUmjY0p7WiIC/Wu4ARF4YaQTJ qR+vxVQkdLQLBLji0zDPEKZ9ccsPSJMP8dqD4AjHSfJ171wPBD7me2qQg9EUChgFnTo8 ranQ== X-Gm-Message-State: ANoB5pk16nAgS4pxLJHtMdkMbRLkv4Ig2ey9O0iMw69jEGU4OoC1S+a0 XTjCjmlxJaLJ122Gt/C7j19xPw== X-Google-Smtp-Source: AA0mqf58t5AAEzi2mt41RHcVRzC+q6XS9ky+fMUt4rgRNTY0Dq23Pd0YT8xJH5fSQPmdLlJ73IBW4g== X-Received: by 2002:a05:600c:3c95:b0:3d0:4af1:a36e with SMTP id bg21-20020a05600c3c9500b003d04af1a36emr13112831wmb.26.1670868466182; Mon, 12 Dec 2022 10:07:46 -0800 (PST) Received: from localhost.localdomain (host-78-150-37-98.as13285.net. [78.150.37.98]) by smtp.gmail.com with ESMTPSA id t123-20020a1c4681000000b003a3170a7af9sm10156808wma.4.2022.12.12.10.07.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 10:07:45 -0800 (PST) From: Sudip Mukherjee To: Serge Semin , Mark Brown , Rob Herring , Krzysztof Kozlowski Cc: jude.onyenegecha@sifive.com, ben.dooks@sifive.com, jeegar.lakhani@sifive.com, linux-spi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Sudip Mukherjee Subject: [PATCH v2 05/15] spi: dw: Introduce enhanced mem_op Date: Mon, 12 Dec 2022 18:07:22 +0000 Message-Id: <20221212180732.79167-6-sudip.mukherjee@sifive.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221212180732.79167-1-sudip.mukherjee@sifive.com> References: <20221212180732.79167-1-sudip.mukherjee@sifive.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org If the DW_SPI_CAP_EMODE capability is enabled then dw_spi_exec_enh_mem_op() will be used as the new enhanced mem_op. Lets initialize the buffer and get the pointers to receive and transmit data buffers. The DW_SPI_CAP_EMODE capability will be enabled in a later patch. Signed-off-by: Sudip Mukherjee --- drivers/spi/spi-dw-core.c | 53 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c index 49fad58ceb94a..89438ae2df17d 100644 --- a/drivers/spi/spi-dw-core.c +++ b/drivers/spi/spi-dw-core.c @@ -798,6 +798,51 @@ static int dw_spi_exec_mem_op(struct spi_mem *mem, const struct spi_mem_op *op) return ret; } +static void dw_spi_init_enh_mem_buf(struct dw_spi *dws, const struct spi_mem_op *op) +{ + unsigned int i, j; + u8 *out; + + out = dws->buf; + for (i = 0; i < DW_SPI_BUF_SIZE; ++i) + out[i] = 0; + + for (i = 0, j = op->cmd.nbytes; i < op->cmd.nbytes; ++i, --j) + out[i] = DW_SPI_GET_BYTE(op->cmd.opcode, op->cmd.nbytes - j); + + for (j = op->addr.nbytes, i = dws->reg_io_width; j > 0; ++i, --j) + out[i] = DW_SPI_GET_BYTE(op->addr.val, op->addr.nbytes - j); + + dws->n_bytes = 1; + if (op->data.dir == SPI_MEM_DATA_IN) { + dws->rx = op->data.buf.in; + dws->rx_len = op->data.nbytes; + dws->tx = NULL; + dws->tx_len = 0; + } else if (op->data.dir == SPI_MEM_DATA_OUT) { + dws->tx_len = op->data.nbytes; + dws->tx = (void *)op->data.buf.out; + dws->rx = NULL; + dws->rx_len = 0; + } else { + dws->rx = NULL; + dws->rx_len = 0; + dws->tx = NULL; + dws->tx_len = 0; + } +} + +static int dw_spi_exec_enh_mem_op(struct spi_mem *mem, const struct spi_mem_op *op) +{ + struct spi_controller *ctlr = mem->spi->controller; + struct dw_spi *dws = spi_controller_get_devdata(ctlr); + + /* Collect cmd and addr into a single buffer */ + dw_spi_init_enh_mem_buf(dws, op); + + return 0; +} + /* * Initialize the default memory operations if a glue layer hasn't specified * custom ones. Direct mapping operations will be preserved anyway since DW SPI @@ -812,11 +857,13 @@ static void dw_spi_init_mem_ops(struct dw_spi *dws) if (!dws->mem_ops.exec_op && !(dws->caps & DW_SPI_CAP_CS_OVERRIDE) && !dws->set_cs) { dws->mem_ops.adjust_op_size = dw_spi_adjust_mem_op_size; - if (dws->caps & DW_SPI_CAP_EMODE) + if (dws->caps & DW_SPI_CAP_EMODE) { + dws->mem_ops.exec_op = dw_spi_exec_enh_mem_op; dws->mem_ops.supports_op = dw_spi_supports_enh_mem_op; - else + } else { + dws->mem_ops.exec_op = dw_spi_exec_mem_op; dws->mem_ops.supports_op = dw_spi_supports_mem_op; - dws->mem_ops.exec_op = dw_spi_exec_mem_op; + } if (!dws->max_mem_freq) dws->max_mem_freq = dws->max_freq; } From patchwork Mon Dec 12 18:07:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 13071317 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8DB4C4332F for ; Mon, 12 Dec 2022 18:09:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233133AbiLLSJG (ORCPT ); Mon, 12 Dec 2022 13:09:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233286AbiLLSIS (ORCPT ); Mon, 12 Dec 2022 13:08:18 -0500 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7369F2728 for ; Mon, 12 Dec 2022 10:07:48 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id h8-20020a1c2108000000b003d1efd60b65so5945836wmh.0 for ; Mon, 12 Dec 2022 10:07:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7rbzmysLo8UW53GKP6EF+15VfNqhz3A+mC6FctnQIOA=; b=gI2UE7AismxqoIKynMFVv4fJQTIarPf1JhZ2jt3s+S8eY2SboNYAkPEtv5xZM/hLMp RT2hjAWlFKl8SmBbkImJgUalzAdDnu6Ygzwaw2KLTqgi7O5NzRbiVWsnrl2NkAKeo94D Z2fG4eKLJsBeJ5U3DZWrEgs+rmvVmKQ8yMnvtVIpCeR/vMZA7afzxpBis/mm0DyLJH/5 hivFHl/yLjHdKuOxOh8TpFBCj++NcXwWo9IqFc9Ovcvi4uSt1JuHq5L1/5/hrY/9j5wK 4Po4rJKbT6vvANrzNQ5SvcapGFVLVK72tooGeoEL/+Uk+szlAfvd/5YYesICfsc1j0fu Wt9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7rbzmysLo8UW53GKP6EF+15VfNqhz3A+mC6FctnQIOA=; b=YA28uXSVWjuI2Y+8DwShwq6r1DY/Q0XZTCytAhvKWYwGlZsgbGqw3JU+tGqnD5sFRA KcPCIKgRI6m15ong6u7OEj8+v+JLmQf2z4ufnp76ipK6oxdRakGvTBest4pNHBGy3DMy JOyXpi0fu7Y1vLsOp6aQsJMNI8U1il736Nx5YeeoS16E8Lhh+3mOhaTgY1G5LObeiYAX dhRXAbHArRGRJ2vwNNRukmVCApK094xRsfUuLmcjYG54Q3QrR23idqbPF0zCXqS/nmo+ 3cF1Xi+yJdcrRXuWRRW7SoavB5ziTFZqsPWOBKq2Wd+4UkqMuPcl5kDZYf69XPB4xGfr 8Chg== X-Gm-Message-State: ANoB5pnux3+jZ6i5CNkKMXDP97l7f1Rdc8/6zQC97cVrqITwcCyRcquo VfMXnECW5TDntHFSsJzChPgtbA== X-Google-Smtp-Source: AA0mqf69G02dnbEggUXKEcvznXMXC3hHUQQD/NllSrd1eNaagBS4QYElw7nwJkrsHdJNx/3L8eo+fw== X-Received: by 2002:a05:600c:5386:b0:3c6:e63d:b893 with SMTP id hg6-20020a05600c538600b003c6e63db893mr13164832wmb.2.1670868467143; Mon, 12 Dec 2022 10:07:47 -0800 (PST) Received: from localhost.localdomain (host-78-150-37-98.as13285.net. [78.150.37.98]) by smtp.gmail.com with ESMTPSA id t123-20020a1c4681000000b003a3170a7af9sm10156808wma.4.2022.12.12.10.07.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 10:07:46 -0800 (PST) From: Sudip Mukherjee To: Serge Semin , Mark Brown , Rob Herring , Krzysztof Kozlowski Cc: jude.onyenegecha@sifive.com, ben.dooks@sifive.com, jeegar.lakhani@sifive.com, linux-spi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Sudip Mukherjee Subject: [PATCH v2 06/15] spi: dw: Introduce dual/quad/octal spi Date: Mon, 12 Dec 2022 18:07:23 +0000 Message-Id: <20221212180732.79167-7-sudip.mukherjee@sifive.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221212180732.79167-1-sudip.mukherjee@sifive.com> References: <20221212180732.79167-1-sudip.mukherjee@sifive.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org If the spi transfer is using dual/quad/octal spi mode, then we need to update the SPI_CTRLR0 register. The SPI_CTRLR0 register will be updated in dw_spi_update_config() via the values in dw_spi_cfg. Signed-off-by: Sudip Mukherjee --- Note: DW_SPI_SPI_CTRLR0_INST_L_INST_L16 will not work yet as spi_mem_default_supports_op() checks for op->cmd.nbytes != 1. drivers/spi/spi-dw-core.c | 46 +++++++++++++++++++++++++++++++++++++++ drivers/spi/spi-dw.h | 9 ++++++++ 2 files changed, 55 insertions(+) diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c index 89438ae2df17d..06169aa3f37bf 100644 --- a/drivers/spi/spi-dw-core.c +++ b/drivers/spi/spi-dw-core.c @@ -836,10 +836,56 @@ static int dw_spi_exec_enh_mem_op(struct spi_mem *mem, const struct spi_mem_op * { struct spi_controller *ctlr = mem->spi->controller; struct dw_spi *dws = spi_controller_get_devdata(ctlr); + struct dw_spi_cfg cfg; + + switch (op->data.buswidth) { + case 2: + cfg.spi_frf = DW_SPI_CTRLR0_SPI_FRF_DUAL_SPI; + break; + case 4: + cfg.spi_frf = DW_SPI_CTRLR0_SPI_FRF_QUAD_SPI; + break; + case 8: + cfg.spi_frf = DW_SPI_CTRLR0_SPI_FRF_OCT_SPI; + break; + default: + return dw_spi_exec_mem_op(mem, op); + } /* Collect cmd and addr into a single buffer */ dw_spi_init_enh_mem_buf(dws, op); + cfg.dfs = 8; + cfg.freq = clamp(mem->spi->max_speed_hz, 0U, dws->max_mem_freq); + cfg.ndf = op->data.nbytes; + if (op->data.dir == SPI_MEM_DATA_IN) + cfg.tmode = DW_SPI_CTRLR0_TMOD_RO; + else + cfg.tmode = DW_SPI_CTRLR0_TMOD_TO; + if (op->data.buswidth == op->addr.buswidth && + op->data.buswidth == op->cmd.buswidth) + cfg.trans_t = DW_SPI_SPI_CTRLR0_TRANS_TYPE_TT2; + else if (op->data.buswidth == op->addr.buswidth) + cfg.trans_t = DW_SPI_SPI_CTRLR0_TRANS_TYPE_TT1; + else + cfg.trans_t = DW_SPI_SPI_CTRLR0_TRANS_TYPE_TT0; + + cfg.addr_l = clamp(op->addr.nbytes * 2, 0, 0xf); + if (op->cmd.nbytes > 1) + cfg.inst_l = DW_SPI_SPI_CTRLR0_INST_L_INST_L16; + else if (op->cmd.nbytes == 1) + cfg.inst_l = DW_SPI_SPI_CTRLR0_INST_L_INST_L8; + else + cfg.inst_l = DW_SPI_SPI_CTRLR0_INST_L_INST_L0; + + cfg.wait_c = (op->dummy.nbytes * (BITS_PER_BYTE / op->dummy.buswidth)); + + dw_spi_enable_chip(dws, 0); + + dw_spi_update_config(dws, mem->spi, &cfg); + + dw_spi_enable_chip(dws, 1); + return 0; } diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h index 327d037bdb10e..494b830ad1026 100644 --- a/drivers/spi/spi-dw.h +++ b/drivers/spi/spi-dw.h @@ -101,6 +101,9 @@ #define DW_HSSI_CTRLR0_SPI_FRF_MASK GENMASK(23, 22) #define DW_PSSI_CTRLR0_SPI_FRF_MASK GENMASK(22, 21) #define DW_SPI_CTRLR0_SPI_FRF_STD_SPI 0x0 +#define DW_SPI_CTRLR0_SPI_FRF_DUAL_SPI 0x1 +#define DW_SPI_CTRLR0_SPI_FRF_QUAD_SPI 0x2 +#define DW_SPI_CTRLR0_SPI_FRF_OCT_SPI 0x3 /* Bit fields in CTRLR1 */ #define DW_SPI_NDF_MASK GENMASK(15, 0) @@ -132,7 +135,13 @@ #define DW_SPI_SPI_CTRLR0_CLK_STRETCH_EN BIT(30) #define DW_SPI_SPI_CTRLR0_WAIT_CYCLE_MASK GENMASK(15, 11) #define DW_SPI_SPI_CTRLR0_INST_L_MASK GENMASK(9, 8) +#define DW_SPI_SPI_CTRLR0_INST_L_INST_L0 0x0 +#define DW_SPI_SPI_CTRLR0_INST_L_INST_L8 0x2 +#define DW_SPI_SPI_CTRLR0_INST_L_INST_L16 0x3 #define DW_SPI_SPI_CTRLR0_ADDR_L_MASK GENMASK(5, 2) +#define DW_SPI_SPI_CTRLR0_TRANS_TYPE_TT0 0x0 +#define DW_SPI_SPI_CTRLR0_TRANS_TYPE_TT1 0x1 +#define DW_SPI_SPI_CTRLR0_TRANS_TYPE_TT2 0x2 /* Mem/DMA operations helpers */ #define DW_SPI_WAIT_RETRIES 5 From patchwork Mon Dec 12 18:07:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 13071314 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 140BBC4332F for ; Mon, 12 Dec 2022 18:09:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233408AbiLLSJD (ORCPT ); Mon, 12 Dec 2022 13:09:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233284AbiLLSIR (ORCPT ); Mon, 12 Dec 2022 13:08:17 -0500 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73164FC5 for ; Mon, 12 Dec 2022 10:07:49 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id r7-20020a1c4407000000b003d1e906ca23so4745825wma.3 for ; Mon, 12 Dec 2022 10:07:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kO55louo2HU6Sz7zwFvdEDjc7T0J+jmAh9v7bF4ReTE=; b=nU9H0esTBqDujvdLtNHyu/dMXGGMrSAn3OF57Layi0xTvRNyVA22Hy5ZCKvHE+oZEh 5hTu9CilC7hGUBqb8qEyU510YD8ghPDvFvHSAJ4NfmhN5Ucb7DdR6RYtz7h6p83j8Bg5 CW22vgN/WIZz8gAmG9WW8eBQKa9Km4zUzyLX+6tSNoyo1pd+0VZxlRt3ETB+dVvCvQgz XuijsrsipVnfKfuYO4vYBlx3L5xoe5pXV7nSOyO9QzMWC26wTCkWXOJkg6eLxOWlWja6 TjpakmpAtCqlSyG2HWUI4k8bkcpPVjB4nRA9qVV41qKXcC4ijX4HG8zjRdwS9asF2jRu Iorg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kO55louo2HU6Sz7zwFvdEDjc7T0J+jmAh9v7bF4ReTE=; b=rLjOxOa4V4ys91l1hpO2mypFISSn4mKp1l852GQfTXtB/i4hqNWpssmt8SMNCP/7HZ wMqkGWxqp5kDLqIrAo/FxqxpfFq4ADaYOFrhlFHoqZjA4pkLI7Z8Db4yhALiMCH5QXRX nEfCA68lPfrG5yWpc/zhBaFO9V7WMLBl3JQLmvJoOUroCERbGo7F1pJJcIF5sooqh5kZ xhDyrHvJBEFZVd0KVLY15l93fnvY/jmf7f94RcnRbX8OLAwtMx+40fCFQSOIbnrqcHat W7vURUsF3vJRwygWm7uUrSEWjTF2kMyBrK2ggKrgoz3TXx17P6oaGxHtSYZCCDqS+kVM apEg== X-Gm-Message-State: ANoB5pndSW/ZVZ/xPPWXLBoY86gJ7ZqdAMFTS8Wa0V9pt6qnQlg3/RFN RfwqRRJt61Lm9i1yjCweXPbP6w== X-Google-Smtp-Source: AA0mqf576dfQVybxuLIfbCOlA5k+I0iAUAm+7frqEKemXUaCX04SdUwv/iSXFNwFmmufYzP3aoyNxA== X-Received: by 2002:a05:600c:350a:b0:3cf:fc0b:335a with SMTP id h10-20020a05600c350a00b003cffc0b335amr12998821wmq.40.1670868468043; Mon, 12 Dec 2022 10:07:48 -0800 (PST) Received: from localhost.localdomain (host-78-150-37-98.as13285.net. [78.150.37.98]) by smtp.gmail.com with ESMTPSA id t123-20020a1c4681000000b003a3170a7af9sm10156808wma.4.2022.12.12.10.07.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 10:07:47 -0800 (PST) From: Sudip Mukherjee To: Serge Semin , Mark Brown , Rob Herring , Krzysztof Kozlowski Cc: jude.onyenegecha@sifive.com, ben.dooks@sifive.com, jeegar.lakhani@sifive.com, linux-spi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Sudip Mukherjee Subject: [PATCH v2 07/15] spi: dw: send cmd and addr to start the spi transfer Date: Mon, 12 Dec 2022 18:07:24 +0000 Message-Id: <20221212180732.79167-8-sudip.mukherjee@sifive.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221212180732.79167-1-sudip.mukherjee@sifive.com> References: <20221212180732.79167-1-sudip.mukherjee@sifive.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org In enhanced spi mode, read or write will start by sending the cmd and address (if present). Signed-off-by: Sudip Mukherjee --- drivers/spi/spi-dw-core.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c index 06169aa3f37bf..ecab0fbc847c7 100644 --- a/drivers/spi/spi-dw-core.c +++ b/drivers/spi/spi-dw-core.c @@ -832,6 +832,29 @@ static void dw_spi_init_enh_mem_buf(struct dw_spi *dws, const struct spi_mem_op } } +static void dw_spi_enh_write_cmd_addr(struct dw_spi *dws, const struct spi_mem_op *op) +{ + void *buf = dws->buf; + u32 txw; + + /* Send cmd as 32 bit value */ + if (buf) { + txw = *(u32 *)(buf); + dw_write_io_reg(dws, DW_SPI_DR, txw); + buf += dws->reg_io_width; + if (op->addr.nbytes) { + txw = *(u32 *)(buf); + dw_write_io_reg(dws, DW_SPI_DR, txw); + if (op->addr.nbytes > 4) { + /* address more than 32bit */ + buf += dws->reg_io_width; + txw = *(u32 *)(buf); + dw_write_io_reg(dws, DW_SPI_DR, txw); + } + } + } +} + static int dw_spi_exec_enh_mem_op(struct spi_mem *mem, const struct spi_mem_op *op) { struct spi_controller *ctlr = mem->spi->controller; @@ -886,6 +909,8 @@ static int dw_spi_exec_enh_mem_op(struct spi_mem *mem, const struct spi_mem_op * dw_spi_enable_chip(dws, 1); + dw_spi_enh_write_cmd_addr(dws, op); + return 0; } From patchwork Mon Dec 12 18:07:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 13071318 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5FBDC00145 for ; Mon, 12 Dec 2022 18:09:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233045AbiLLSJU (ORCPT ); Mon, 12 Dec 2022 13:09:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233041AbiLLSIW (ORCPT ); Mon, 12 Dec 2022 13:08:22 -0500 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3452A6369 for ; Mon, 12 Dec 2022 10:07:50 -0800 (PST) Received: by mail-wm1-x32c.google.com with SMTP id p13-20020a05600c468d00b003cf8859ed1bso5949379wmo.1 for ; Mon, 12 Dec 2022 10:07:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=d24laJpjlPXsikI4gRgK9kB14hlb2fbIBw6BPSu32y0=; b=S/NpoBGjfN26KWhKFia2yEWVXzcCGLKl3iPvRqG6nMr/HeB28cb7p17Tl2Pfwe2NgI A49T3jsjMZClY95HnDiYC2cu9DbbHtPz2gSQAanBFThW4w+6s1IaveRwGToG+tv/OwUe XvwFZA7vrjpAnTPKLpwa8aJYCniJwReC5tU417cjsD4PXI8C1j0NlwQeOJyb93436odr gneCb8V857iG4FhAR6x2Gr1wS9kwFeK4NeqvjGBohg8TKQbBKkfTHzh2wQmUHV+oQd/c 7knMzk+ZxQ6YxdwUUg6yVlqG77VS2pMBe8mttWMWteGvpjbDGdmBQOlWRenLOXLCiQ5/ X/QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=d24laJpjlPXsikI4gRgK9kB14hlb2fbIBw6BPSu32y0=; b=cDA8DtbCakWQdKKU7tfJj+dqqdv9+Gcgu57yy5Wx7W943dVMlA+kUrSBT/Df8jakrz Fka/YZH6tt7RbSKYg78GwDQrKgfp5hckyUTNXToTd3u3o/X/6PV9AE6fonaBPYA08mep a4hmdM353osYaVeqbrEZDfgqFAgyc527U3upcy2pUP1SodIQ/ftQ6zJJdkDctJ+0tY5K fmmvCBdnY39AeppXgz74X4ENsCxghp5fdx2O+M8IX8A+wE6Wk2AXcGOtMfYEefR8F3mi oC2uQvsQWolr+tsaKUggYv4COYHyrpKMjYfgTuJuiH6nx87FCcpDoBt3tAbHvuSuSFon RbiQ== X-Gm-Message-State: ANoB5pn4BN6KIuqCPTis3HMxUlhax2SU1S4pSQDJlj/OSbB1S7KJ2TPc WdoEKW0bSIcqBg8aciJ1evrJDA== X-Google-Smtp-Source: AA0mqf6Dwf6Ne2EGgBeVcKwYXluX5/3fmaGwz3tWfp8OG+Nmq2rXNCgTg9HSsNihd2RM2lA+MDStmw== X-Received: by 2002:a05:600c:17d5:b0:3d1:f2de:195a with SMTP id y21-20020a05600c17d500b003d1f2de195amr12809656wmo.32.1670868468901; Mon, 12 Dec 2022 10:07:48 -0800 (PST) Received: from localhost.localdomain (host-78-150-37-98.as13285.net. [78.150.37.98]) by smtp.gmail.com with ESMTPSA id t123-20020a1c4681000000b003a3170a7af9sm10156808wma.4.2022.12.12.10.07.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 10:07:48 -0800 (PST) From: Sudip Mukherjee To: Serge Semin , Mark Brown , Rob Herring , Krzysztof Kozlowski Cc: jude.onyenegecha@sifive.com, ben.dooks@sifive.com, jeegar.lakhani@sifive.com, linux-spi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Sudip Mukherjee Subject: [PATCH v2 08/15] spi: dw: update irq setup to use multiple handler Date: Mon, 12 Dec 2022 18:07:25 +0000 Message-Id: <20221212180732.79167-9-sudip.mukherjee@sifive.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221212180732.79167-1-sudip.mukherjee@sifive.com> References: <20221212180732.79167-1-sudip.mukherjee@sifive.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org The current mem_ops is not using interrupt based transfer so dw_spi_irq_setup() only has one interrput handler to handle the non mem_ops transfers. We will use interrupt based transfers in enhanced spi and so we need a way to specify which irq handler to use. Signed-off-by: Sudip Mukherjee --- drivers/spi/spi-dw-core.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c index ecab0fbc847c7..f540165245a89 100644 --- a/drivers/spi/spi-dw-core.c +++ b/drivers/spi/spi-dw-core.c @@ -260,7 +260,8 @@ static irqreturn_t dw_spi_irq(int irq, void *dev_id) if (!irq_status) return IRQ_NONE; - if (!master->cur_msg) { + if (!master->cur_msg && dws->transfer_handler == + dw_spi_transfer_handler) { dw_spi_mask_intr(dws, 0xff); return IRQ_HANDLED; } @@ -380,7 +381,8 @@ void dw_spi_update_config(struct dw_spi *dws, struct spi_device *spi, } EXPORT_SYMBOL_NS_GPL(dw_spi_update_config, SPI_DW_CORE); -static void dw_spi_irq_setup(struct dw_spi *dws) +static void dw_spi_irq_setup(struct dw_spi *dws, + irqreturn_t (*t_handler)(struct dw_spi *)) { u16 level; u8 imask; @@ -394,7 +396,7 @@ static void dw_spi_irq_setup(struct dw_spi *dws) dw_writel(dws, DW_SPI_TXFTLR, level); dw_writel(dws, DW_SPI_RXFTLR, level - 1); - dws->transfer_handler = dw_spi_transfer_handler; + dws->transfer_handler = t_handler; imask = DW_SPI_INT_TXEI | DW_SPI_INT_TXOI | DW_SPI_INT_RXUI | DW_SPI_INT_RXOI | DW_SPI_INT_RXFI; @@ -486,7 +488,7 @@ static int dw_spi_transfer_one(struct spi_controller *master, else if (dws->irq == IRQ_NOTCONNECTED) return dw_spi_poll_transfer(dws, transfer); - dw_spi_irq_setup(dws); + dw_spi_irq_setup(dws, dw_spi_transfer_handler); return 1; } From patchwork Mon Dec 12 18:07:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 13071315 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F46AC00145 for ; Mon, 12 Dec 2022 18:09:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233085AbiLLSJF (ORCPT ); Mon, 12 Dec 2022 13:09:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233291AbiLLSIT (ORCPT ); Mon, 12 Dec 2022 13:08:19 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 347D838AF for ; Mon, 12 Dec 2022 10:07:51 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id c65-20020a1c3544000000b003cfffd00fc0so5927099wma.1 for ; Mon, 12 Dec 2022 10:07:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=U8uXFQDQkqLQIMCCxoCS+6jURPh07ZY2kozA9MFfN3M=; b=WyMYo3JOmKqR6l1OTjzSAVzd/O6pzzj38Z8131LC916E6Bjpk6YUmO/UGsza5Qfu/N WF1eGeJubEX7OWJu1Buj8ONi3vtB//zq+MFRrmPjPhCw9sHj2Q+2xIqp0gS8pX6x9CgW 2FM/3QzPb1B8BgDFwRJ6Dia2koBzZQv8rBROfQ+sQcUHs1we2jAzhrSL0AEb9QgBZ0eJ jmWs2mG13FYebAS3JQ043Vl6lqRmadTWurytHmlopBV/HKJpcsilZxFMxbRwLzfduc2l 3s319UftBuIDMk6mAFewnSLQyMtZ2tr4WC3o9Tm3bbbRm0y12EBQ8ryJwxrWgrbtlueF KRkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=U8uXFQDQkqLQIMCCxoCS+6jURPh07ZY2kozA9MFfN3M=; b=wPWXAsFDKW8lV4F2roLW/7EBmRjw6gf3dN9Z/atyj4UPFHRTJ9bK8okIXuXdVYFm11 L17zvG80G9YJJynaMNSVIhxRhdNXP7cX+SrZ9xC9j5JP6fhhxOYAOFO4VuZc7jGEwRUu yjvX9/0BLwG8MkVJo6SoTaKeh7NQflPM6FJfcvV3ac/8kQXCFEs0RJRqxn3ifFNcHWd7 LYP0b/YOhpD1H7WU1+zJ3SaQnVVxHfHGPl8YIb09UDla8fKED6SDJZQPvk1/8Q05TBCI okh/mt4K/ENv478t6STHTf0HO5Ca1DrqFTggSOPHutnzeFwHNa+Om2Yciq7GdUxYBDa/ ojeQ== X-Gm-Message-State: ANoB5plbGVg08nAMjhcCGHZJ+2XM79nPiQS2/2s0oHvreCUh7/Hf0JPF tCxBRXvIE9zPexFryb/XvXdB6A== X-Google-Smtp-Source: AA0mqf6b79xT/oO0cekZ5BaCDQCbXRdsCcbTP9RoWft1JiWLKKW8AR/nkgvIL2DzS5OU8fjYcZsWbA== X-Received: by 2002:a05:600c:4fd0:b0:3d1:c0a1:4804 with SMTP id o16-20020a05600c4fd000b003d1c0a14804mr13434541wmq.17.1670868469792; Mon, 12 Dec 2022 10:07:49 -0800 (PST) Received: from localhost.localdomain (host-78-150-37-98.as13285.net. [78.150.37.98]) by smtp.gmail.com with ESMTPSA id t123-20020a1c4681000000b003a3170a7af9sm10156808wma.4.2022.12.12.10.07.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 10:07:49 -0800 (PST) From: Sudip Mukherjee To: Serge Semin , Mark Brown , Rob Herring , Krzysztof Kozlowski Cc: jude.onyenegecha@sifive.com, ben.dooks@sifive.com, jeegar.lakhani@sifive.com, linux-spi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Sudip Mukherjee Subject: [PATCH v2 09/15] spi: dw: use irq handler for enhanced spi Date: Mon, 12 Dec 2022 18:07:26 +0000 Message-Id: <20221212180732.79167-10-sudip.mukherjee@sifive.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221212180732.79167-1-sudip.mukherjee@sifive.com> References: <20221212180732.79167-1-sudip.mukherjee@sifive.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Introduce the interrupt handler for enhanced spi to read or write based on the generated irq. Also, use the xfer_completion from spi_controller to wait for a timeout or completion from irq handler. Signed-off-by: Sudip Mukherjee --- drivers/spi/spi-dw-core.c | 62 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c index f540165245a89..10d453228368f 100644 --- a/drivers/spi/spi-dw-core.c +++ b/drivers/spi/spi-dw-core.c @@ -251,6 +251,34 @@ static irqreturn_t dw_spi_transfer_handler(struct dw_spi *dws) return IRQ_HANDLED; } +static irqreturn_t dw_spi_enh_handler(struct dw_spi *dws) +{ + u16 irq_status = dw_readl(dws, DW_SPI_ISR); + + if (dw_spi_check_status(dws, false)) { + spi_finalize_current_transfer(dws->master); + return IRQ_HANDLED; + } + + if (irq_status & DW_SPI_INT_RXFI) { + dw_reader(dws); + if (dws->rx_len <= dw_readl(dws, DW_SPI_RXFTLR)) + dw_writel(dws, DW_SPI_RXFTLR, dws->rx_len - 1); + } + + if (irq_status & DW_SPI_INT_TXEI) + dw_writer(dws); + + if (!dws->tx_len && dws->rx_len) { + dw_spi_mask_intr(dws, DW_SPI_INT_TXEI); + } else if (!dws->rx_len && !dws->tx_len) { + dw_spi_mask_intr(dws, 0xff); + spi_finalize_current_transfer(dws->master); + } + + return IRQ_HANDLED; +} + static irqreturn_t dw_spi_irq(int irq, void *dev_id) { struct spi_controller *master = dev_id; @@ -265,6 +293,12 @@ static irqreturn_t dw_spi_irq(int irq, void *dev_id) dw_spi_mask_intr(dws, 0xff); return IRQ_HANDLED; } + if ((dws->transfer_handler == dw_spi_enh_handler && + !dws->rx_len && !dws->tx_len)) { + dw_spi_mask_intr(dws, 0xff); + spi_finalize_current_transfer(master); + return IRQ_HANDLED; + } return dws->transfer_handler(dws); } @@ -862,6 +896,8 @@ static int dw_spi_exec_enh_mem_op(struct spi_mem *mem, const struct spi_mem_op * struct spi_controller *ctlr = mem->spi->controller; struct dw_spi *dws = spi_controller_get_devdata(ctlr); struct dw_spi_cfg cfg; + int ret = 0; + unsigned long long ms; switch (op->data.buswidth) { case 2: @@ -909,11 +945,35 @@ static int dw_spi_exec_enh_mem_op(struct spi_mem *mem, const struct spi_mem_op * dw_spi_update_config(dws, mem->spi, &cfg); + dw_spi_mask_intr(dws, 0xff); + reinit_completion(&ctlr->xfer_completion); dw_spi_enable_chip(dws, 1); dw_spi_enh_write_cmd_addr(dws, op); + dw_spi_set_cs(mem->spi, false); + dw_spi_irq_setup(dws, dw_spi_enh_handler); - return 0; + /* Use timeout calculation from spi_transfer_wait() */ + ms = 8LL * MSEC_PER_SEC * (dws->rx_len ? dws->rx_len : dws->tx_len); + do_div(ms, dws->current_freq); + + /* + * Increase it twice and add 200 ms tolerance, use + * predefined maximum in case of overflow. + */ + ms += ms + 200; + if (ms > UINT_MAX) + ms = UINT_MAX; + + ms = wait_for_completion_timeout(&ctlr->xfer_completion, + msecs_to_jiffies(ms)); + + dw_spi_stop_mem_op(dws, mem->spi); + + if (ms == 0) + ret = -EIO; + + return ret; } /* From patchwork Mon Dec 12 18:07:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 13071316 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B134CC10F1D for ; Mon, 12 Dec 2022 18:09:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233411AbiLLSJE (ORCPT ); Mon, 12 Dec 2022 13:09:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233290AbiLLSIT (ORCPT ); Mon, 12 Dec 2022 13:08:19 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 346FB273B for ; Mon, 12 Dec 2022 10:07:51 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id r7-20020a1c4407000000b003d1e906ca23so4745944wma.3 for ; Mon, 12 Dec 2022 10:07:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pQuE2K78uUlvCMGWFDZZHN9GOwoDWtlsbedBiWwRDfg=; b=jaHLnsIYEZXfnaU6a2ldMiE275sZuX9Wbq117I2Jw43JPyMxu5yo68Uj7Yy4ycmJYq PUU+LkMNy+SF81zAOHaS+BQhLkjgH+f+SfO+9q8ueaaMTUl1GJqJBJ3NhM8qojWlSrp7 MVoQtDGxSPWSWS30rW5bo4HsLRBgFJySBBdN/m9tNI/rX8f81dhAYmXSAh0rVY9wIwzY eil7uJupKi3DZb/is/7NEAJhn3eHqL9jQEutvZ9PBfwjzd2XQlpQTLCJmCgZlvsCwhZ1 v71KA5thTpBdW0xq+yO5YvO+xAuZR9nkEFA+djLJjQXonSxzmxygnS//vyON6nsl62Vp 298g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pQuE2K78uUlvCMGWFDZZHN9GOwoDWtlsbedBiWwRDfg=; b=XBSW7093zZFeJsUWCmrCuFPDqDMsGqWahImEuMo06ON52qwUDj8CgaVziz5HJjG8yz VTMgztvq9Nv1y8EyJALtVt+vZAYwALnK0ptCZW+dPnskpb6Ik+eygsk57DBmYOTPBgrr S8ds3oJTyceGLBOSJwe1zQVZAj/xJCWz1ULNxt9pJHP3kofpB3cak08OafyVPKEp/La2 UDgjodt8AYwHe8EnSyVf8Nq6we5oFaoBRRvJB6BjOLF6PLj2GLQIZKSLznjZrpl/1moR Ic7PSWxtYnBj/QFd1ikDXItI7o9PrvMuDm1UxY71Y3y4UjlUeWt71iEuQ38WPf+VGcao +NZA== X-Gm-Message-State: ANoB5pn37UuK1Yt0mQlrg4x43yjIa7JzYGCPPHeYvb3zM2qLPRg93wdg 6cGpm09ZwvrQz36EpnZELqbwGg== X-Google-Smtp-Source: AA0mqf4YkjQSyvUPzCW5WFKTMeX06dUxr3FM0c1i93DR0EFe1wd0BuRBczuZcAm/hzFgM0p3opDFWg== X-Received: by 2002:a05:600c:1c90:b0:3d2:274d:be7c with SMTP id k16-20020a05600c1c9000b003d2274dbe7cmr3040697wms.19.1670868470682; Mon, 12 Dec 2022 10:07:50 -0800 (PST) Received: from localhost.localdomain (host-78-150-37-98.as13285.net. [78.150.37.98]) by smtp.gmail.com with ESMTPSA id t123-20020a1c4681000000b003a3170a7af9sm10156808wma.4.2022.12.12.10.07.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 10:07:50 -0800 (PST) From: Sudip Mukherjee To: Serge Semin , Mark Brown , Rob Herring , Krzysztof Kozlowski Cc: jude.onyenegecha@sifive.com, ben.dooks@sifive.com, jeegar.lakhani@sifive.com, linux-spi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Sudip Mukherjee Subject: [PATCH v2 10/15] spi: dw: Calculate Receive FIFO Threshold Level Date: Mon, 12 Dec 2022 18:07:27 +0000 Message-Id: <20221212180732.79167-11-sudip.mukherjee@sifive.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221212180732.79167-1-sudip.mukherjee@sifive.com> References: <20221212180732.79167-1-sudip.mukherjee@sifive.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org In enhanced mode we need to calculate RXFTLR based on the length of data we are expecting to receive or the fifo length. Signed-off-by: Sudip Mukherjee --- drivers/spi/spi-dw-core.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c index 10d453228368f..75f5ce5f377ca 100644 --- a/drivers/spi/spi-dw-core.c +++ b/drivers/spi/spi-dw-core.c @@ -428,6 +428,14 @@ static void dw_spi_irq_setup(struct dw_spi *dws, */ level = min_t(u16, dws->fifo_len / 2, dws->tx_len); dw_writel(dws, DW_SPI_TXFTLR, level); + + /* + * In enhanced mode if we are reading then tx_len is 0 as we + * have nothing to transmit. Calculate DW_SPI_RXFTLR with + * rx_len. + */ + if (t_handler == dw_spi_enh_handler) + level = min_t(u16, dws->fifo_len / 2, dws->rx_len); dw_writel(dws, DW_SPI_RXFTLR, level - 1); dws->transfer_handler = t_handler; From patchwork Mon Dec 12 18:07:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 13071320 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D7A8C00145 for ; Mon, 12 Dec 2022 18:09:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233064AbiLLSJ3 (ORCPT ); Mon, 12 Dec 2022 13:09:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233304AbiLLSIX (ORCPT ); Mon, 12 Dec 2022 13:08:23 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2566063B1 for ; Mon, 12 Dec 2022 10:07:52 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id k22-20020a05600c1c9600b003d1ee3a6289so5940943wms.2 for ; Mon, 12 Dec 2022 10:07:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mtPRqcnGnMJu3Lhjzyyt2cKQspWuIhSj33OJnrwCIF0=; b=dic+olsWhbv9Bdud+svAQHzZHug2lLj+vz7hVn19EyP7/8WryNdN+/Ac8gMCuGBZkU uYZwRo2TdqRr2c8T+9GTVOsdjr0TIK2krifSwPPBfojcXy38wrxCPtFgvLg/NfY76g7t 8e/XIrRELDolos2n0GIeUN65WLoTfz2BkcpPlxs4fH3aWc+6fg+1UfhgDt9k/sQzXX/3 qDcadSlnFCH7ygbGyjKNYFi0sxiqgIedHIgUjC5yA/Lw30AVOO8CAwWFHHIdo+IZigWT xbofJbDupAmmm8nls29Ol+1RZQDApqRklwcZZfKdp63b9my0f4ojm9npEEgof4KOHjHi lwzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mtPRqcnGnMJu3Lhjzyyt2cKQspWuIhSj33OJnrwCIF0=; b=3fG1O/A3Rig7/NIrqXWghDYW+B0k/duJxIEdFf7JlLmnnC7/U5Bv8aihX3zdcfWni7 aAGRnBtLoq8OzSHx6HEjomLdoIcV/JOYDzrZ+2dvlOZyVT2Sc2usAtDNrOaVBYuNiEf3 UHKHFkioHPSbOgTnFEHwKiITfotpcYyQCKo8NOqucdfwD9HkXK0HMxg/BilEY9KTE9EX PlWEksVUlVQ0gLi0C/azeJUC2az47/WSJI54zQrxLHE4qJRV9O9ewsXaK0Dq7OBORyQs fgoe75YXrc5jgC6WS3oAI74ysmhr6VuM+jYMPI+eFbmy1G9lyNnSgu6TV7r4W98i+g0A WF9w== X-Gm-Message-State: ANoB5plG8rgdarpc6RBSEDxvPub06gfTHV5rsv83SKguyztmDnPwLSwa wd9++bAIA1h+mKYHFDLUWEXEMA== X-Google-Smtp-Source: AA0mqf6hJ3IGjFjKWW73Q+nkmeBNJDk+Q5JFDed1oLgVWBz52c2xQhXA5zTJWbzF7FiPmgqIn8pC9w== X-Received: by 2002:a05:600c:4147:b0:3d2:2904:dfe9 with SMTP id h7-20020a05600c414700b003d22904dfe9mr2396260wmm.21.1670868471634; Mon, 12 Dec 2022 10:07:51 -0800 (PST) Received: from localhost.localdomain (host-78-150-37-98.as13285.net. [78.150.37.98]) by smtp.gmail.com with ESMTPSA id t123-20020a1c4681000000b003a3170a7af9sm10156808wma.4.2022.12.12.10.07.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 10:07:51 -0800 (PST) From: Sudip Mukherjee To: Serge Semin , Mark Brown , Rob Herring , Krzysztof Kozlowski Cc: jude.onyenegecha@sifive.com, ben.dooks@sifive.com, jeegar.lakhani@sifive.com, linux-spi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Sudip Mukherjee Subject: [PATCH v2 11/15] spi: dw: adjust size of mem_op Date: Mon, 12 Dec 2022 18:07:28 +0000 Message-Id: <20221212180732.79167-12-sudip.mukherjee@sifive.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221212180732.79167-1-sudip.mukherjee@sifive.com> References: <20221212180732.79167-1-sudip.mukherjee@sifive.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org In enhanced mode adjust the size of the data that can be sent or received as this will then be used to set the NDF. Signed-off-by: Sudip Mukherjee --- drivers/spi/spi-dw-core.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c index 75f5ce5f377ca..dff7b419af304 100644 --- a/drivers/spi/spi-dw-core.c +++ b/drivers/spi/spi-dw-core.c @@ -546,6 +546,13 @@ static void dw_spi_handle_err(struct spi_controller *master, dw_spi_reset_chip(dws); } +static int dw_spi_adjust_enh_mem_op_size(struct spi_mem *mem, struct spi_mem_op *op) +{ + op->data.nbytes = clamp_val(op->data.nbytes, 0, DW_SPI_NDF_MASK + 1); + + return 0; +} + static int dw_spi_adjust_mem_op_size(struct spi_mem *mem, struct spi_mem_op *op) { if (op->data.dir == SPI_MEM_DATA_IN) @@ -997,13 +1004,14 @@ static void dw_spi_init_mem_ops(struct dw_spi *dws) { if (!dws->mem_ops.exec_op && !(dws->caps & DW_SPI_CAP_CS_OVERRIDE) && !dws->set_cs) { - dws->mem_ops.adjust_op_size = dw_spi_adjust_mem_op_size; if (dws->caps & DW_SPI_CAP_EMODE) { dws->mem_ops.exec_op = dw_spi_exec_enh_mem_op; dws->mem_ops.supports_op = dw_spi_supports_enh_mem_op; + dws->mem_ops.adjust_op_size = dw_spi_adjust_enh_mem_op_size; } else { dws->mem_ops.exec_op = dw_spi_exec_mem_op; dws->mem_ops.supports_op = dw_spi_supports_mem_op; + dws->mem_ops.adjust_op_size = dw_spi_adjust_mem_op_size; } if (!dws->max_mem_freq) dws->max_mem_freq = dws->max_freq; From patchwork Mon Dec 12 18:07:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 13071319 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D6BCC00145 for ; Mon, 12 Dec 2022 18:09:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233434AbiLLSJ0 (ORCPT ); Mon, 12 Dec 2022 13:09:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233080AbiLLSIW (ORCPT ); Mon, 12 Dec 2022 13:08:22 -0500 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAAAC639B for ; Mon, 12 Dec 2022 10:07:52 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id v124-20020a1cac82000000b003cf7a4ea2caso5904406wme.5 for ; Mon, 12 Dec 2022 10:07:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1PouWW9hJEcBYWxPnr69aXYCEVweHPkB0XRBnvDzgi8=; b=hJkN3oUoHsJGYB6mkIx6Fb/Ziw+PnIzJMRXqveDSUGoW4Qe88FEqNgv8X4Sumt2D8X zNo5iEI6lcKh7/8fV3Ljs5yOEudvyH0YLhMMDK6bk4wPRwuUvrIcRBnZHyXnHt0iydtl dY3FDCnzxyxHe48B6rAFV72pFRR1b+EkqInEEukRfTuqs8+vR0kZHxxFGGaBgIIUsSzp sYemv3inoKIZOS/+fwqnXQdZyP+ndDxc2aRYzvls7+GHBt5ZBxDGgTobD9Y1bLGrAE7h LeyV5W6jyvKVHlF5T/bgFltIAD4sRHeJpChBwcwKPSlkkpVPEk8ocTjQnsu/gzlXaA7h at9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1PouWW9hJEcBYWxPnr69aXYCEVweHPkB0XRBnvDzgi8=; b=tOFpk2ABEdzET7d+9b40t3Ysrv8T81MsOJt1ub0UYNTeA/tWAldBt2jqlVo4o+tug3 uZX248vsR8d3TbMHibcMmgPZTnXU4qLqDnwi7GeYhbhfkNRJT3KKleHhzmYAcEEHp4lU 1UM7LSbnwYiKlSzIYl+7FWAF/HTA9G+VEMK3rFZm4rhI5yPys3JWAz/4U/wSLloziwUu /vtifr68zYdTueIAMHbINzFuoGKHyjfcRU4YK6kWhMsheeJ61JC21s6mWDUg7CYkth9b W9bfrJ8DRw7CgoGH8lAIMleyn4NSVKt+r19G2t+JVMg/MK/H0fh0WfEoBJ2acG6gTy3p XKPg== X-Gm-Message-State: ANoB5pm12A4loWjbtru1XTwEDMFaXpqYcvTfL89AwNUsZ/orF8RKgfiE XTTVYxIR6dD2O8RhPJcEDYntKg== X-Google-Smtp-Source: AA0mqf6KuqKuwKMEwSFXB8pvf+HvVTEihfH4JWO5hjhU1Jcfgqd81BUXqa0E90oL+N7afvvLGkNRZw== X-Received: by 2002:a05:600c:2215:b0:3cf:6d5b:875e with SMTP id z21-20020a05600c221500b003cf6d5b875emr13385573wml.12.1670868472465; Mon, 12 Dec 2022 10:07:52 -0800 (PST) Received: from localhost.localdomain (host-78-150-37-98.as13285.net. [78.150.37.98]) by smtp.gmail.com with ESMTPSA id t123-20020a1c4681000000b003a3170a7af9sm10156808wma.4.2022.12.12.10.07.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 10:07:52 -0800 (PST) From: Sudip Mukherjee To: Serge Semin , Mark Brown , Rob Herring , Krzysztof Kozlowski Cc: jude.onyenegecha@sifive.com, ben.dooks@sifive.com, jeegar.lakhani@sifive.com, linux-spi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Sudip Mukherjee Subject: [PATCH v2 12/15] spi: dw: Add retry for enhanced spi mode Date: Mon, 12 Dec 2022 18:07:29 +0000 Message-Id: <20221212180732.79167-13-sudip.mukherjee@sifive.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221212180732.79167-1-sudip.mukherjee@sifive.com> References: <20221212180732.79167-1-sudip.mukherjee@sifive.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org If the connection to the spi device is not stable then the transfer can fail. Add retry for DW_SPI_WAIT_RETRIES times and print error if it still fails. Signed-off-by: Sudip Mukherjee --- drivers/spi/spi-dw-core.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c index dff7b419af304..cef56acd8d8fd 100644 --- a/drivers/spi/spi-dw-core.c +++ b/drivers/spi/spi-dw-core.c @@ -906,7 +906,7 @@ static void dw_spi_enh_write_cmd_addr(struct dw_spi *dws, const struct spi_mem_o } } -static int dw_spi_exec_enh_mem_op(struct spi_mem *mem, const struct spi_mem_op *op) +static int dw_spi_try_enh_mem_op(struct spi_mem *mem, const struct spi_mem_op *op) { struct spi_controller *ctlr = mem->spi->controller; struct dw_spi *dws = spi_controller_get_devdata(ctlr); @@ -991,6 +991,21 @@ static int dw_spi_exec_enh_mem_op(struct spi_mem *mem, const struct spi_mem_op * return ret; } +static int dw_spi_exec_enh_mem_op(struct spi_mem *mem, const struct spi_mem_op *op) +{ + struct spi_controller *ctlr = mem->spi->controller; + struct dw_spi *dws = spi_controller_get_devdata(ctlr); + int retry, ret = -EIO; + + for (retry = 0; retry < DW_SPI_WAIT_RETRIES && ret != 0; retry++) + ret = dw_spi_try_enh_mem_op(mem, op); + + if (retry == DW_SPI_WAIT_RETRIES) + dev_err(&dws->master->dev, "Retry of enh_mem_op failed\n"); + + return ret; +} + /* * Initialize the default memory operations if a glue layer hasn't specified * custom ones. Direct mapping operations will be preserved anyway since DW SPI From patchwork Mon Dec 12 18:07:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 13071321 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 806A7C4332F for ; Mon, 12 Dec 2022 18:09:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233149AbiLLSJf (ORCPT ); Mon, 12 Dec 2022 13:09:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233308AbiLLSIY (ORCPT ); Mon, 12 Dec 2022 13:08:24 -0500 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4F0663E7 for ; Mon, 12 Dec 2022 10:07:53 -0800 (PST) Received: by mail-wm1-x32c.google.com with SMTP id p13-20020a05600c468d00b003cf8859ed1bso5949515wmo.1 for ; Mon, 12 Dec 2022 10:07:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yV6+oiSdPjciFRPPCXlaaf05DYc0wxneaaODGSgK2uE=; b=Y22bKRAfcHnmzs2KZUi6jIstXPxhHBZWZQH5o5L6ddrFcZLMEHUAdwjRJytIKvwvf0 3juKw7qaULaSH9BmLJJzWklC1rQP1dNXnzyCResSGkYz1io1zyQiBiUZDJCCoC4b4V1e BReayyJGtxjvP7ykcbjzzl1x33zjDHl1nfqybysn2Bi8Qfrr4kLnZoTp+8yb++Y28ONd MsJ9YW3nKTUTKr8llNSNoR4EhT8sUUhuOAmH+9U8CxFxH8oY/99G6qsORDUUfXtAAVQt WT6ZZS8CnZv4V5NHWb3atkwBsW7sbnLR8H3LqZLOOF1NDmSvcDR3tBRUVtDp2xLcGyKh FBcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yV6+oiSdPjciFRPPCXlaaf05DYc0wxneaaODGSgK2uE=; b=Hp1BMZuiB8hbEtYBvICJ0vbcaQ4G6bC/egac2/A4hlI1m6kFtfy6fO/cD/QlWX+szr RvCXkv51qJ9ZxXiC2rzMCdKLil1MZXnns7KN4wgSQcbDEKxbIX7BN6cUWq5wQBFEAJ+C izvneiO1HHEGfKrIXQAy1L96bq1sNBidkX/kffqty2eh+V85aYEvDLtspuu8YE9lIWJC 68K+oyMeoHC5g5p3WgOT861LUF65ssFzc/wpb35RZiBmot9s/j8INTfZ3rxTI3pCX8gx 3oiKT3hqIOqI7tbbVCJJgb6stq/fUuPF5Oq0hy3oZWdSCyHVxASYFbHKhehmYdVGbVyw YrLw== X-Gm-Message-State: ANoB5pmExh8IuzwkC9E07ZP7O5oyEUIzOKOGnwAHH3xog6jjnSWURvNN Z2qickBCdzHpU7ATWB6CKR7CQA== X-Google-Smtp-Source: AA0mqf63xZP9eTl0bysLtgyG3g0nG0GhxM23IddzbnhHOhlvfVKIYf4FEI66D1D0svRZXgN1mXFdcg== X-Received: by 2002:a05:600c:3508:b0:3cf:b73f:bf8f with SMTP id h8-20020a05600c350800b003cfb73fbf8fmr13614720wmq.7.1670868473356; Mon, 12 Dec 2022 10:07:53 -0800 (PST) Received: from localhost.localdomain (host-78-150-37-98.as13285.net. [78.150.37.98]) by smtp.gmail.com with ESMTPSA id t123-20020a1c4681000000b003a3170a7af9sm10156808wma.4.2022.12.12.10.07.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 10:07:53 -0800 (PST) From: Sudip Mukherjee To: Serge Semin , Mark Brown , Rob Herring , Krzysztof Kozlowski Cc: jude.onyenegecha@sifive.com, ben.dooks@sifive.com, jeegar.lakhani@sifive.com, linux-spi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Sudip Mukherjee Subject: [PATCH v2 13/15] spi: dw: detect enhanced spi mode Date: Mon, 12 Dec 2022 18:07:30 +0000 Message-Id: <20221212180732.79167-14-sudip.mukherjee@sifive.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221212180732.79167-1-sudip.mukherjee@sifive.com> References: <20221212180732.79167-1-sudip.mukherjee@sifive.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org All the SSI controllers supporting enhanced spi modes might not support all the three dual or quad or octal modes. Detect the modes that are supported and finally enable the DW_SPI_CAP_EMODE capability which will start using all the enhanced spi functions that has been added. Signed-off-by: Sudip Mukherjee --- drivers/spi/spi-dw-core.c | 68 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c index cef56acd8d8fd..9e806d5878beb 100644 --- a/drivers/spi/spi-dw-core.c +++ b/drivers/spi/spi-dw-core.c @@ -1143,6 +1143,69 @@ static void dw_spi_hw_init(struct device *dev, struct dw_spi *dws) dw_writel(dws, DW_SPI_CS_OVERRIDE, 0xF); } +static u16 detect_enh_mode(struct dw_spi *dws) +{ + u16 mode = 0; + u32 tmp_spi_ctrlr0, tmp_ctrlr0, tmpdual, tmpquad, tmpoct; + + if (dw_spi_ver_is_ge(dws, HSSI, 103A)) { + tmpdual = FIELD_PREP(DW_HSSI_CTRLR0_SPI_FRF_MASK, + DW_SPI_CTRLR0_SPI_FRF_DUAL_SPI); + tmpquad = FIELD_PREP(DW_HSSI_CTRLR0_SPI_FRF_MASK, + DW_SPI_CTRLR0_SPI_FRF_QUAD_SPI); + tmpoct = FIELD_PREP(DW_HSSI_CTRLR0_SPI_FRF_MASK, + DW_SPI_CTRLR0_SPI_FRF_OCT_SPI); + } else if (dw_spi_ver_is_ge(dws, PSSI, 400A)) { + tmpdual = FIELD_PREP(DW_PSSI_CTRLR0_SPI_FRF_MASK, + DW_SPI_CTRLR0_SPI_FRF_DUAL_SPI); + tmpquad = FIELD_PREP(DW_PSSI_CTRLR0_SPI_FRF_MASK, + DW_SPI_CTRLR0_SPI_FRF_QUAD_SPI); + tmpoct = FIELD_PREP(DW_PSSI_CTRLR0_SPI_FRF_MASK, + DW_SPI_CTRLR0_SPI_FRF_OCT_SPI); + } else { + return DW_SPI_CTRLR0_SPI_FRF_STD_SPI; + } + + tmp_ctrlr0 = dw_readl(dws, DW_SPI_CTRLR0); + tmp_spi_ctrlr0 = dw_readl(dws, DW_SPI_SPI_CTRLR0); + dw_spi_enable_chip(dws, 0); + + /* test clock stretching */ + dw_writel(dws, DW_SPI_SPI_CTRLR0, DW_SPI_SPI_CTRLR0_CLK_STRETCH_EN); + if ((DW_SPI_SPI_CTRLR0_CLK_STRETCH_EN & dw_readl(dws, DW_SPI_SPI_CTRLR0)) != + DW_SPI_SPI_CTRLR0_CLK_STRETCH_EN) + /* + * If clock stretching is not enabled then do not use + * enhanced mode. + */ + goto disable_enh; + + /* test dual mode */ + dw_writel(dws, DW_SPI_CTRLR0, tmpdual); + if ((tmpdual & dw_readl(dws, DW_SPI_CTRLR0)) == tmpdual) + mode |= SPI_TX_DUAL | SPI_RX_DUAL; + + /* test quad mode */ + dw_writel(dws, DW_SPI_CTRLR0, tmpquad); + if ((tmpquad & dw_readl(dws, DW_SPI_CTRLR0)) == tmpquad) + mode |= SPI_TX_QUAD | SPI_RX_QUAD; + + /* test octal mode */ + dw_writel(dws, DW_SPI_CTRLR0, tmpoct); + if ((tmpoct & dw_readl(dws, DW_SPI_CTRLR0)) == tmpoct) + mode |= SPI_TX_OCTAL | SPI_RX_OCTAL; + + if (mode) + dws->caps |= DW_SPI_CAP_EMODE; + +disable_enh: + dw_writel(dws, DW_SPI_CTRLR0, tmp_ctrlr0); + dw_writel(dws, DW_SPI_SPI_CTRLR0, tmp_spi_ctrlr0); + dw_spi_enable_chip(dws, 1); + + return mode; +} + int dw_spi_add_host(struct device *dev, struct dw_spi *dws) { struct spi_controller *master; @@ -1172,10 +1235,11 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws) goto err_free_master; } - dw_spi_init_mem_ops(dws); - master->use_gpio_descriptors = true; master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LOOP; + master->mode_bits |= detect_enh_mode(dws); + dw_spi_init_mem_ops(dws); + if (dws->caps & DW_SPI_CAP_DFS32) master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 32); else From patchwork Mon Dec 12 18:07:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 13071322 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42BA0C4167B for ; Mon, 12 Dec 2022 18:09:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233259AbiLLSJh (ORCPT ); Mon, 12 Dec 2022 13:09:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233311AbiLLSIZ (ORCPT ); Mon, 12 Dec 2022 13:08:25 -0500 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E25B6432 for ; Mon, 12 Dec 2022 10:07:54 -0800 (PST) Received: by mail-wm1-x32c.google.com with SMTP id i187-20020a1c3bc4000000b003d21f02fbaaso443887wma.4 for ; Mon, 12 Dec 2022 10:07:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uKSt+dINanbC1i1CDPthK0t2BzwjJSENh1jILj1VWeU=; b=CP/vwL6A8mXTwGXYJ+BqrDO8jqPY0gc5EsrtR8UU4Xr/Yey/xzG/fAboGAfEJ8w3ZO kVAYje+2MI++GBQLVnMSaIDRenA0MD1T7zBVI2fUOHafowAARsd/MvtEM+/QNE7McZgz WpEIKw2FeZx1GMPWPPq3+3vKMFihI61yG0x1BUAGhUcXifoIbHFVc3ubnL9n9zSOx2c3 PEl0fp16ZGL5e1UjUf7R9idaOmEYisVtToSGPqp8H1aeS3k6z4JXSaJKNTVmlikqMRSS yC2i51PO81Ovcevvk30tsXhxcKJ9WEZ/1MrZpq6ycvy+RFUouyB9Ncqu87aHxD1Q9KHB qhlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uKSt+dINanbC1i1CDPthK0t2BzwjJSENh1jILj1VWeU=; b=Mskhb07FNZPPk5SE59HVmjtX0aomCfx72lbTrbdiV7jWx/ujBTK/B1CmzjNiV3JlIW TKSEAFxctlPyxxrpif8s3KOZYfqTEELj0JBA3zMIRwOtEKNDdlcGu9kTrIjPcqWYTVoa 1Gt8Fwm3ha/k+c4zTSk7gSDlfXtMPlQp7L7RQZuXNbcSrYh1iTkVL94fOq2BRk66WIa2 uWBDDl4+GOaZie+GR7yG7yaZDNOpXckQSxw24f5PQeeBQ0PFHpmu6kVMicb26KP/maeS MVqHgZqLBUKHaJCL7tTy91CSxgyev8KWz+5wA6F5utoAmh/R9g305LL3ev60hymmyEfs F8UA== X-Gm-Message-State: ANoB5plgsILF6hDXjJ2oIK8XLuqyldzXdY0nqiX1q4x8gDTiuuo8tTWl //6BhnQSDvNuDdoVY9XLOb7O3A== X-Google-Smtp-Source: AA0mqf6MtJYNqYIN7i7b4qA53PDk44gOFQd0bWYqjVROn+LQhKwkZFbxs8ZDoLJ2HCrnxrAPAwf76A== X-Received: by 2002:a05:600c:a11:b0:3d2:2a74:3a90 with SMTP id z17-20020a05600c0a1100b003d22a743a90mr2399695wmp.22.1670868474288; Mon, 12 Dec 2022 10:07:54 -0800 (PST) Received: from localhost.localdomain (host-78-150-37-98.as13285.net. [78.150.37.98]) by smtp.gmail.com with ESMTPSA id t123-20020a1c4681000000b003a3170a7af9sm10156808wma.4.2022.12.12.10.07.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 10:07:53 -0800 (PST) From: Sudip Mukherjee To: Serge Semin , Mark Brown , Rob Herring , Krzysztof Kozlowski Cc: jude.onyenegecha@sifive.com, ben.dooks@sifive.com, jeegar.lakhani@sifive.com, linux-spi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Sudip Mukherjee Subject: [PATCH v2 14/15] spi: dt-bindings: snps,dw-ahb-ssi: Add generic dw-ahb-ssi version Date: Mon, 12 Dec 2022 18:07:31 +0000 Message-Id: <20221212180732.79167-15-sudip.mukherjee@sifive.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221212180732.79167-1-sudip.mukherjee@sifive.com> References: <20221212180732.79167-1-sudip.mukherjee@sifive.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Add new snps,dw-ahb-ssi version to the bindings. Signed-off-by: Sudip Mukherjee --- Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml b/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml index d33b72fabc5d8..af36df67a4c0e 100644 --- a/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml +++ b/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml @@ -45,6 +45,7 @@ properties: enum: - snps,dw-apb-ssi - snps,dwc-ssi-1.01a + - snps,dw-ahb-ssi - description: Microsemi Ocelot/Jaguar2 SoC SPI Controller items: - enum: From patchwork Mon Dec 12 18:07:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 13071323 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B4FAC00145 for ; Mon, 12 Dec 2022 18:09:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233369AbiLLSJt (ORCPT ); Mon, 12 Dec 2022 13:09:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233098AbiLLSIa (ORCPT ); Mon, 12 Dec 2022 13:08:30 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB2B865D7 for ; Mon, 12 Dec 2022 10:07:56 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id o15so6208409wmr.4 for ; Mon, 12 Dec 2022 10:07:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vxcMgepI8oVEM9TqV5Jw/8Ls56KCQWpTpg2XQ851Vyo=; b=ihIo87o/eW0m0yNdwDPZYK+DwBvApOUgbohqKB5uvxZomOsA7v/sIVscW3U7MU40Vn oZvjCKLwi7XnZlTbhTAM1iefFfkNbcmzhaR1hWInKHbCO53Z6NJ71yKW4uCjdXX1pLmU gbSbXVkBRmwf9k4nutNA9DDRLRSrKqyzVdDdGCmiepNlB69wP5ysyD+gWqC8MZHrLY1n 4FvDcYZA79H8FOQDnSK0i1wZCxfE9qBsG5n/6f8lwx4DQOqWyt2kbjuHOZr+KNYh8Uxa 4NSYJlsDKN0EKzCbH5oc29wuirYwZMkFKgoHGTbpd83LA+sXtN/jMMb0K6Aj43CL6ZXq ygsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vxcMgepI8oVEM9TqV5Jw/8Ls56KCQWpTpg2XQ851Vyo=; b=KqoaiPj0xEjv/kBpDlpQ61nFfxyUGZQcaVotRoHN4nodjtPK11EKOLaVB7pqtqbNRT yt+5Pg6tjU+T5wxQI2z/cWcncu9yH+iAKvsL0qOkSLVZn76emqrGyoSbZnf77/zz9IB8 NcOB10TW3hO6LvdeEcp4bftGFE6lenxvd/3bo+c9djKvWHdp1Jkxvzj/QWBknSviuDmv Mq+9bGSpmteSqpMs8vPp3/2J3HdXNWhvFRByzDExtMtHNuwdUa1SHo8kcCjtf+TSUhh7 i/AirP+A4MjUq5cqyRV5yPBF6hUUTxxufpGOnF+NTSTibmxPRtpHv+gsolmZymG8Bffc jx8Q== X-Gm-Message-State: ANoB5pmRpTcrVql1iIE5gm2+5L/uW3ZPs161PmlZEPm5lSfFYtcEV4VN 1SXo9AMqcVQ6SFYbC5TWJh4R5w== X-Google-Smtp-Source: AA0mqf5WAwhv7CN65oqrRHJ56WnHd0r1iLiZBzcHbxlqTDYQ/i3lCLb42boTqKHrJxh0Z2TfH+O25Q== X-Received: by 2002:a1c:4c06:0:b0:3cf:88c3:d008 with SMTP id z6-20020a1c4c06000000b003cf88c3d008mr13028681wmf.28.1670868475158; Mon, 12 Dec 2022 10:07:55 -0800 (PST) Received: from localhost.localdomain (host-78-150-37-98.as13285.net. [78.150.37.98]) by smtp.gmail.com with ESMTPSA id t123-20020a1c4681000000b003a3170a7af9sm10156808wma.4.2022.12.12.10.07.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 10:07:54 -0800 (PST) From: Sudip Mukherjee To: Serge Semin , Mark Brown , Rob Herring , Krzysztof Kozlowski Cc: jude.onyenegecha@sifive.com, ben.dooks@sifive.com, jeegar.lakhani@sifive.com, linux-spi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Sudip Mukherjee Subject: [PATCH v2 15/15] spi: dw: initialize dwc-ssi controller Date: Mon, 12 Dec 2022 18:07:32 +0000 Message-Id: <20221212180732.79167-16-sudip.mukherjee@sifive.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221212180732.79167-1-sudip.mukherjee@sifive.com> References: <20221212180732.79167-1-sudip.mukherjee@sifive.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Use the generic snps,dw-ahb-ssi version to initialize the controller. Signed-off-by: Sudip Mukherjee --- drivers/spi/spi-dw-mmio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c index 26c40ea6dd129..431ba768ea861 100644 --- a/drivers/spi/spi-dw-mmio.c +++ b/drivers/spi/spi-dw-mmio.c @@ -352,6 +352,7 @@ static const struct of_device_id dw_spi_mmio_of_match[] = { { .compatible = "intel,thunderbay-ssi", .data = dw_spi_intel_init}, { .compatible = "microchip,sparx5-spi", dw_spi_mscc_sparx5_init}, { .compatible = "canaan,k210-spi", dw_spi_canaan_k210_init}, + { .compatible = "snps,dw-ahb-ssi", .data = dw_spi_hssi_init}, { /* end of table */} }; MODULE_DEVICE_TABLE(of, dw_spi_mmio_of_match);