From patchwork Tue Jan 23 15:34:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 13527643 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 E9EDEC48260 for ; Tue, 23 Jan 2024 15:35:57 +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=kar1bdnQzd0qEgt4aQOszS06LAzFpmd7+DX8RaJLyYw=; b=xVw/wukqKD1Wtb Gd6iTvh/iawodehzV/VJE8A+87VdcMdhkd9w8OcY5ade0qM0I0tIXn5dEjk6ZhGmVk1D9z5g1S2Mh jH44eGZav34vE+QPcKGns5GFDM3jobcOQ2UgqLyIdgpATXfzBWk14Geb/2+NnQKd7mgbyOIYk7rZk blQWM+BfK8mjB7AAeV9184muS+Jc0f9BqSynWKu+F8vwhkLPe+LHPfFv6tQZ3uht2aUqzE6cHXTSf jfUyRk6mqF0AyDWvPzRY0dTPPwQofJ5At1rRgZrWWhsy/MWV5J2al7qaNPYb7u2C0a70yT2MosIxQ VsRUMp2KCv9eo/WoXUaA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rSIo9-00H41P-2n; Tue, 23 Jan 2024 15:35:25 +0000 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rSInV-00H3VJ-0q for linux-arm-kernel@lists.infradead.org; Tue, 23 Jan 2024 15:34:46 +0000 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-40e9d4ab5f3so48240545e9.2 for ; Tue, 23 Jan 2024 07:34:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706024084; x=1706628884; 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=spZW8S0GVeUeUaVNEXaPIDC8+SPXAmAjIvuVT5xHfKI=; b=PXP+R8DZhtd4R25HQiQAMciWPv+ttYbjpI3Itw6er3uIBbosxx+c7W27RslB+qGxZf M5vIwM+sSKkAJmAdH7pygWx2bBLMRmrSTqoE4JKnfEVTofjyOamDJ+QWUlXztVuyV3Ci H5QDW7FWflN5fQ9mxpHsrlv2X4Fgz585YuuykadesotUx2O1kt3W5lmo6OMUKyV/T8CY Ta3a0FnW25lLeLBDE/ghLKJVLns5U76VyHrRL++k4UIHqhocf//EVrGloePAHgwuIuYF p1N0rso4Qau6x0XvOWY2pTn2Oo7o5I2mnlrmmICTJuWsqq+8xqo6ljVNgnN7b8vReZoE /usw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706024084; x=1706628884; 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=spZW8S0GVeUeUaVNEXaPIDC8+SPXAmAjIvuVT5xHfKI=; b=nez2xhCboe6tC8LJnTeA/IED4oQ34bNLcagTZ+aYcSgX3Y3eRx9MUj5xb1TMuOzhT5 gsjNbrjTWa1Y2t1FIOINrwXSxHEJuldZwZuHB0Fzwg1m+zUGUPGHLf5RHaklvV3y9E6R AaBKAcNb0nEU6SRMxT2BX+U8yQflnXtxvO671axz7Nq7aRkr/bsvnUbPjVWMQW6PstE/ 607QNzHDyaDSmrui01coIEWIlYYb+M4BZAnp+jlUHxHvL48YUZ8l1VbKHgpCu8IdCiBw qnXs0H96SX1bd4LY13bl2RUs42UzRY9yhk5qU+8vyJolY35qWsmI5jEEtAonWlhVy324 oyhA== X-Gm-Message-State: AOJu0Yw7EbStSQ/t1yvmeBDeISk2tJ4z8WUOo1/sUQZW4gJREufJJoWo 3+CW1vQclGIg2hN/VVh7xFHipndWYS61ut9ZLrpE+5g0LtywkGq/HZwCBT9IT/s= X-Google-Smtp-Source: AGHT+IEwGHIZco2gJ7iHs+3ejOlkItskw5CNIOEGW9+nHZyAIdrwcgrVKi17dDetE+hV66X5PLQAKA== X-Received: by 2002:a05:600c:a46:b0:40e:5598:a6f3 with SMTP id c6-20020a05600c0a4600b0040e5598a6f3mr258341wmq.124.1706024084020; Tue, 23 Jan 2024 07:34:44 -0800 (PST) Received: from ta2.c.googlers.com.com (88.140.78.34.bc.googleusercontent.com. [34.78.140.88]) by smtp.gmail.com with ESMTPSA id p21-20020a05600c359500b0040e3488f16dsm42457536wmq.12.2024.01.23.07.34.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 07:34:42 -0800 (PST) From: Tudor Ambarus To: broonie@kernel.org, andi.shyti@kernel.org, arnd@arndb.de Cc: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, alim.akhtar@samsung.com, linux-spi@vger.kernel.org, linux-samsung-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org, andre.draszik@linaro.org, peter.griffin@linaro.org, semen.protsenko@linaro.org, kernel-team@android.com, willmcvicker@google.com, Tudor Ambarus Subject: [PATCH 19/21] spi: s3c64xx: add support for google,gs101-spi Date: Tue, 23 Jan 2024 15:34:18 +0000 Message-ID: <20240123153421.715951-20-tudor.ambarus@linaro.org> X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog In-Reply-To: <20240123153421.715951-1-tudor.ambarus@linaro.org> References: <20240123153421.715951-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-20240123_073445_330426_3A474976 X-CRM114-Status: GOOD ( 17.61 ) 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 Add support for GS101 SPI. All the SPI nodes on GS101 have 64 bytes FIFOs, infer the FIFO size from the compatible. GS101 allows just 32bit register accesses, otherwise a Serror Interrupt is raised. Do the write reg accesses in 32 bits. Signed-off-by: Tudor Ambarus --- drivers/spi/spi-s3c64xx.c | 50 +++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index 62671b2d594a..c4ddd2859ba4 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -20,6 +20,7 @@ #define MAX_SPI_PORTS 12 #define S3C64XX_SPI_QUIRK_CS_AUTO BIT(1) +#define S3C64XX_SPI_GS1O1_32BIT_REG_IO_WIDTH BIT(2) #define AUTOSUSPEND_TIMEOUT 2000 /* Registers and bit-fields */ @@ -131,6 +132,7 @@ struct s3c64xx_spi_dma_data { * @rx_lvl_offset: Bit offset of RX_FIFO_LVL bits in SPI_STATUS regiter. * @tx_st_done: Bit offset of TX_DONE bit in SPI_STATUS regiter. * @clk_div: Internal clock divider + * @fifosize: size of the FIFO * @quirks: Bitmask of known quirks * @high_speed: True, if the controller supports HIGH_SPEED_EN bit. * @clk_from_cmu: True, if the controller does not include a clock mux and @@ -149,6 +151,7 @@ struct s3c64xx_spi_port_config { int tx_st_done; int quirks; int clk_div; + unsigned int fifosize; bool high_speed; bool clk_from_cmu; bool clk_ioclk; @@ -175,6 +178,7 @@ struct s3c64xx_spi_port_config { * @tx_dma: Local transmit DMA data (e.g. chan and direction) * @port_conf: Local SPI port configuartion data * @port_id: Port identification number + * @fifosize: size of the FIFO for this port */ struct s3c64xx_spi_driver_data { void __iomem *regs; @@ -194,6 +198,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 fifosize; }; static void s3c64xx_flush_fifo(struct s3c64xx_spi_driver_data *sdd) @@ -403,7 +408,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->fifosize; return false; } @@ -447,12 +452,22 @@ static int s3c64xx_enable_datapath(struct s3c64xx_spi_driver_data *sdd, xfer->tx_buf, xfer->len / 4); break; case 16: - iowrite16_rep(regs + S3C64XX_SPI_TX_DATA, - xfer->tx_buf, xfer->len / 2); + if (sdd->port_conf->quirks & + S3C64XX_SPI_GS1O1_32BIT_REG_IO_WIDTH) + iowrite16_32_rep(regs + S3C64XX_SPI_TX_DATA, + xfer->tx_buf, xfer->len / 2); + else + iowrite16_rep(regs + S3C64XX_SPI_TX_DATA, + xfer->tx_buf, xfer->len / 2); break; default: - iowrite8_rep(regs + S3C64XX_SPI_TX_DATA, - xfer->tx_buf, xfer->len); + if (sdd->port_conf->quirks & + S3C64XX_SPI_GS1O1_32BIT_REG_IO_WIDTH) + iowrite8_32_rep(regs + S3C64XX_SPI_TX_DATA, + xfer->tx_buf, xfer->len); + else + iowrite8_rep(regs + S3C64XX_SPI_TX_DATA, + xfer->tx_buf, xfer->len); break; } } @@ -696,7 +711,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->fifosize; const void *tx_buf = NULL; void *rx_buf = NULL; int target_len = 0, origin_len = 0; @@ -1145,6 +1160,11 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) sdd->port_id = pdev->id; } + if (sdd->port_conf->fifosize) + sdd->fifosize = sdd->port_conf->fifosize; + else + sdd->fifosize = FIFO_DEPTH(sdd); + sdd->cur_bpw = 8; sdd->tx_dma.direction = DMA_MEM_TO_DEV; @@ -1234,7 +1254,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->fifosize); pm_runtime_mark_last_busy(&pdev->dev); pm_runtime_put_autosuspend(&pdev->dev); @@ -1362,6 +1382,18 @@ static const struct dev_pm_ops s3c64xx_spi_pm = { s3c64xx_spi_runtime_resume, NULL) }; +static const struct s3c64xx_spi_port_config gs101_spi_port_config = { + .fifosize = 64, + .rx_lvl_offset = 15, + .tx_st_done = 25, + .clk_div = 4, + .high_speed = true, + .clk_from_cmu = true, + .has_loopback = true, + .quirks = S3C64XX_SPI_QUIRK_CS_AUTO | + S3C64XX_SPI_GS1O1_32BIT_REG_IO_WIDTH, +}; + static const struct s3c64xx_spi_port_config s3c2443_spi_port_config = { .fifo_lvl_mask = { 0x7f }, .rx_lvl_offset = 13, @@ -1452,6 +1484,10 @@ static const struct platform_device_id s3c64xx_spi_driver_ids[] = { }; static const struct of_device_id s3c64xx_spi_dt_match[] = { + { + .compatible = "google,gs101-spi", + .data = &gs101_spi_port_config, + }, { .compatible = "samsung,s3c2443-spi", .data = &s3c2443_spi_port_config,