From patchwork Fri Feb 16 07:05:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 13559615 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A2E73C48BEF for ; Fri, 16 Feb 2024 07:06:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hjZ2Q6iIQF/epm4zIP4eTwRZ6d86sU7IlFtvVr3Eay0=; b=sEK+ireOUT2RS5 znysAJZMGa0f8XoorZFOEFVZsuNjl+vm872uqIToVGHk/3yXWcqXJdHfyKFG8/JH0cjNCmuDIlrSj MrBl83n9rfvucp66r3n+UPSkaM8po8T9B/sqC+nNYJaMsAd7SG79t4FfxnuMahdSiLgC4HcR89+BD nIlkQ9ekl44tBMiTV9DNXlcr2B9qvXPI4GITM0eT+M8a6vxhFdg6auOm+0zJ1+mnLBj6ffe3S7dTB CuaVrSmAP0Rq1u+Nbm4kPrVWC8PoQfEixE+7RHlXOqA14d6k+Pi+D979b6TJc4dy1YFfLvqHRief6 MBo+kPR7ErQe97cy//YQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rasIe-00000001JGz-3yZM; Fri, 16 Feb 2024 07:06:20 +0000 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rasIP-00000001J8s-2cSQ for linux-arm-kernel@lists.infradead.org; Fri, 16 Feb 2024 07:06:07 +0000 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-33d066f8239so702548f8f.1 for ; Thu, 15 Feb 2024 23:06:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708067164; x=1708671964; darn=lists.infradead.org; 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=i5dQGEaVcg4JepfFOKvtsOuZxWCp+j5PzKY/bMFyTSc=; b=EF3cWcVGsIhU2p6h/4cJUCZvkBFE5o0jes3ITH7IoPtiFq4+AxNHkEvYxNTc5gh0BV P6PiEUxacPIsNV4+Trv3fyzvl+udoN1T9irWhNv5UJBsaXNbJcjx0x7h/ogEWq35d6HP 1+rNQwhOmQCw2uqqOTFGUWFgUzB2VCzjcY32hZiA8iMyUdb0GMFqOKgLFj1faQmZqthX HrwH6Tf53KRBod9wYR0yGwmNxsHilVNo2j/e99Uo9slRZ8Qx5WAsfTlbnAG0y+jG5YCc xA3uwQv5YDq7nHwrmgOwVhxJm1j0w97PT1ylHOddA4px7vSRMnERh7NLq0OV1FM9icRr 6h6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708067164; x=1708671964; 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=i5dQGEaVcg4JepfFOKvtsOuZxWCp+j5PzKY/bMFyTSc=; b=Yy9VAHBSsMa2yWGXTY678DyRpzGIkZILNWI4AQTIo9VTjMwNaa0ZWvRvy4YMzdzScx rj9S7Js1CBnnfoJfk8mhPk+Y8JT843VpIw8U6xCOAIvxInWZ7Gmd4NKke+pksD95CqWV G027gH8MRRCJPS5P6z8Vd/lz8r8e1TDM9NyB/ek9L+PhbvVEG4FdvAdtZWqNfcGvgJyt dj2rfSZs2sBUYjLF61HlghR8LCLOMf8WSXncKjUTWTWYg426Bq2pVmlYkbYGfTgR/Rhj Or1IzRwORNnsVWE0bOX6WaCmYUDR4wy6ugtjcRVfTAfW42PC/61uiF64rP1ick8L5B2O 5+Jg== X-Forwarded-Encrypted: i=1; AJvYcCWzFQVpFrFsrlm+D1HQKqHsTSPf8SR7a+nHweZT+tIIPAxb8oqnafayDd6ln10pnguYMCLrzJxkUy11LGpIhvPVnDuVVIR5KGU3PXneHfyK/a4pwkk= X-Gm-Message-State: AOJu0YzVAdjWoMqB1IcPIyGQYBGFICDkDkULDJnsF62ZegGOog5heTMl k0nhngmq8h6PoH3lNLG5MeQA+YbNCFacWOnLjfJjSKjO/W+g6e4/WZ2kk6J5Awk= X-Google-Smtp-Source: AGHT+IH6bFjx6yR3OvU6ZSmZOFBSxOePtQ+8XuRp+3vDK/eGrsS4HlTKbLEgx6BW8cjReGID82PX2A== X-Received: by 2002:adf:979a:0:b0:33d:f4b:d484 with SMTP id s26-20020adf979a000000b0033d0f4bd484mr2368352wrb.16.1708067163870; Thu, 15 Feb 2024 23:06:03 -0800 (PST) Received: from ta2.c.googlers.com.com (105.168.195.35.bc.googleusercontent.com. [35.195.168.105]) by smtp.gmail.com with ESMTPSA id k18-20020a5d66d2000000b0033940016d6esm1298839wrw.93.2024.02.15.23.06.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 23:06:02 -0800 (PST) From: Tudor Ambarus To: broonie@kernel.org, robh@kernel.org, andi.shyti@kernel.org, krzysztof.kozlowski@linaro.org, semen.protsenko@linaro.org, conor+dt@kernel.org Cc: alim.akhtar@samsung.com, linux-spi@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, andre.draszik@linaro.org, peter.griffin@linaro.org, kernel-team@android.com, willmcvicker@google.com, devicetree@vger.kernel.org, Tudor Ambarus Subject: [PATCH v3 04/12] spi: s3c64xx: determine the fifo depth only once Date: Fri, 16 Feb 2024 07:05:47 +0000 Message-ID: <20240216070555.2483977-5-tudor.ambarus@linaro.org> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog In-Reply-To: <20240216070555.2483977-1-tudor.ambarus@linaro.org> References: <20240216070555.2483977-1-tudor.ambarus@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240215_230605_720221_2828409C X-CRM114-Status: GOOD ( 15.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Determine the FIFO depth only once, at probe time. ``sdd->fifo_depth`` can be set later on with the FIFO depth specified in the device tree. Signed-off-by: Tudor Ambarus --- drivers/spi/spi-s3c64xx.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index 338ca3f03ea5..72572e23cde5 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -191,6 +191,7 @@ struct s3c64xx_spi_port_config { * @tx_dma: Local transmit DMA data (e.g. chan and direction) * @port_conf: Local SPI port configuration data * @port_id: Port identification number + * @fifo_depth: depth of the FIFO. * @rx_fifomask: SPI_STATUS.RX_FIFO_LVL mask. Shifted mask defining the field's * length and position. * @tx_fifomask: SPI_STATUS.TX_FIFO_LVL mask. Shifted mask defining the field's @@ -214,6 +215,7 @@ struct s3c64xx_spi_driver_data { struct s3c64xx_spi_dma_data tx_dma; const struct s3c64xx_spi_port_config *port_conf; unsigned int port_id; + unsigned int fifo_depth; u32 rx_fifomask; u32 tx_fifomask; }; @@ -424,7 +426,7 @@ static bool s3c64xx_spi_can_dma(struct spi_controller *host, struct s3c64xx_spi_driver_data *sdd = spi_controller_get_devdata(host); if (sdd->rx_dma.ch && sdd->tx_dma.ch) - return xfer->len > FIFO_DEPTH(sdd); + return xfer->len > sdd->fifo_depth; return false; } @@ -548,7 +550,7 @@ static u32 s3c64xx_spi_wait_for_timeout(struct s3c64xx_spi_driver_data *sdd, void __iomem *regs = sdd->regs; unsigned long val = 1; u32 status; - u32 max_fifo = FIFO_DEPTH(sdd); + u32 max_fifo = sdd->fifo_depth; if (timeout_ms) val = msecs_to_loops(timeout_ms); @@ -655,7 +657,7 @@ static int s3c64xx_wait_for_pio(struct s3c64xx_spi_driver_data *sdd, * For any size less than the fifo size the below code is * executed atleast once. */ - loops = xfer->len / FIFO_DEPTH(sdd); + loops = xfer->len / sdd->fifo_depth; buf = xfer->rx_buf; do { /* wait for data to be received in the fifo */ @@ -792,7 +794,7 @@ static int s3c64xx_spi_transfer_one(struct spi_controller *host, struct spi_transfer *xfer) { struct s3c64xx_spi_driver_data *sdd = spi_controller_get_devdata(host); - const unsigned int fifo_len = FIFO_DEPTH(sdd); + const unsigned int fifo_len = sdd->fifo_depth; const void *tx_buf = NULL; void *rx_buf = NULL; int target_len = 0, origin_len = 0; @@ -1261,6 +1263,8 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) sdd->port_id = pdev->id; } + sdd->fifo_depth = FIFO_DEPTH(sdd); + s3c64xx_spi_set_fifomask(sdd); sdd->cur_bpw = 8; @@ -1352,7 +1356,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) dev_dbg(&pdev->dev, "Samsung SoC SPI Driver loaded for Bus SPI-%d with %d Targets attached\n", sdd->port_id, host->num_chipselect); dev_dbg(&pdev->dev, "\tIOmem=[%pR]\tFIFO %dbytes\n", - mem_res, FIFO_DEPTH(sdd)); + mem_res, sdd->fifo_depth); pm_runtime_mark_last_busy(&pdev->dev); pm_runtime_put_autosuspend(&pdev->dev);