From patchwork Thu Nov 17 08:47:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlo Caione X-Patchwork-Id: 13046330 X-Patchwork-Delegate: neil.armstrong@linaro.org 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 050F6C4332F for ; Thu, 17 Nov 2022 08:48:47 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tztbwfmxPgPNdVX+gAVouDv73K2+f108Q68ZvB1Gbh4=; b=RCOtj3EoMhXzug dEyWU6qkEmZw+3ZJ3xxoDf1sj5kPfMhjJenEfRTI+svBzSwgF6g+bqDPLZsn1moW0Mf/V2AmyLqRZ G3RQ++3paUu1Fs/yafy8ubjhOvVj5RkcJIfYG1POcQW9EaUOs15G0Xm3PRtQso+6YioL9p/eg56jP fXgtVvFKtVOapMSrhSggp+S56w6tU9zny3ON7vaVYk97+rtDVvjt9PNsyVuAhLWOQV0Iyj0LAIiz+ GALkcvmGyiVg6U1UkxqyQmHZEQKgTvQmbPp50cxgSXxFSdk9v662BXmFGIl+qW9dAad8jjabsc378 fwWRSdL6wczmbHcqjLiw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ovaZZ-00BoZf-GS; Thu, 17 Nov 2022 08:48:37 +0000 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ovaYw-00BoD4-Jt for linux-amlogic@lists.infradead.org; Thu, 17 Nov 2022 08:48:00 +0000 Received: by mail-ed1-x52e.google.com with SMTP id v27so1561617eda.1 for ; Thu, 17 Nov 2022 00:47:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=kplxU2lR5aG0mBiBv43tp2KK14DvgQ3747TCEeV3JMg=; b=JJZviyNTe3aoLaHC8gnS2B6ZcTQTNzqCo1CNL5fhLhh/Q21pISItv3OuImIZPearuW bcPv8/v3zDuo0hQF1Lxl2dF61VnCzkP4spsZMx9z8F5hpwlR6u9zM/SndG3dLHBBLnY0 k6htMUas9GgLlqwNVv8haDJ1k1sKtjozX77I+aljOtKJKGPtB+BuHZSWCo+mN29Ll9Qi CRzV4Z8IPLuKuq3E4NgPh9PssxWg2C/4fGnvj7vEgj1k5ujzzy4ewWa9SM19CUNImdn/ LvG4iiIh9BzZTOLPVDG0udI2RexERIauevvSdRle0EGIrUaKj+OeJ5HOXjqL5Qsc/vat CR4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kplxU2lR5aG0mBiBv43tp2KK14DvgQ3747TCEeV3JMg=; b=O+q9uYi5onfA74C2Qgi+3e0txd+I/JrfxtM5m+x+BzzWQYwYdlkbboLpCg0FEEQ8S9 TjlwFmlmmzL51q74F76HRtXZtPjfhCWjbXm8/BXoFTmYU5yYn2pkeO/7yvZuBFFeMmMM UmFxW2bNp/wVuQRkn1EXfGqCZ8OARfMTlSpshwchOe4NM98bdf6Vn1XQKJ9FMHnftSRM cZzkjHIGn5vMehmlDNZgGx4oGS3dCob49OYbR+LFDYHFizA+raPb+ayDHEH/zrH78fbW UlOwuVc/EhTYf3cyL/cySoXQb85JhdsAZB9/I5tAbdo16nb9amRhH77ijt/O6yrF4Wr1 0BYw== X-Gm-Message-State: ANoB5pnc8ldq2f2PPa28zpZ50S5Zn3YW7FdlqdWJbRtTp8SC9Np9zEyA Nw+3TwbVI4iVo+ISKKVHVz6KUw== X-Google-Smtp-Source: AA0mqf6g15i8zsDuyqA55ZoKaief9KDXNvdMbq3LIDvKdQEDkFEbkFvIVViVnfvYrya19LRO4KeNXQ== X-Received: by 2002:a05:6402:4d6:b0:458:789b:c1b0 with SMTP id n22-20020a05640204d600b00458789bc1b0mr1277535edw.89.1668674872601; Thu, 17 Nov 2022 00:47:52 -0800 (PST) Received: from [127.0.1.1] ([2a0e:41a:894f:0:7a60:27eb:954c:5ab1]) by smtp.gmail.com with ESMTPSA id s22-20020a1709067b9600b0077205dd15basm77332ejo.66.2022.11.17.00.47.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 00:47:52 -0800 (PST) From: Carlo Caione Date: Thu, 17 Nov 2022 09:47:39 +0100 Subject: [PATCH 1/3] drm/tiny: rpi-lcd-35: Enable driver module autoloading MIME-Version: 1.0 Message-Id: <20221116-s905x_spi_ili9486-v1-1-630401cb62d5@baylibre.com> References: <20221116-s905x_spi_ili9486-v1-0-630401cb62d5@baylibre.com> In-Reply-To: <20221116-s905x_spi_ili9486-v1-0-630401cb62d5@baylibre.com> To: Kamlesh Gurudasani , Mark Brown , Neil Armstrong , Jerome Brunet , David Airlie , Martin Blumenstingl , Kevin Hilman , Daniel Vetter Cc: linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, dri-devel@lists.freedesktop.org, Carlo Caione X-Mailer: b4 0.10.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221117_004758_691290_20B56DCD X-CRM114-Status: UNSURE ( 8.67 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-amlogic@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-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org SPI devices use the spi_device_id for module autoloading even on systems using device tree. Add the spi_device_id entry to enable autoloading for the 3.5inch RPi Display (rpi-lcd-35). Signed-off-by: Carlo Caione --- drivers/gpu/drm/tiny/ili9486.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/tiny/ili9486.c b/drivers/gpu/drm/tiny/ili9486.c index 1bb847466b10..bd37dfe8dd05 100644 --- a/drivers/gpu/drm/tiny/ili9486.c +++ b/drivers/gpu/drm/tiny/ili9486.c @@ -183,6 +183,7 @@ MODULE_DEVICE_TABLE(of, ili9486_of_match); static const struct spi_device_id ili9486_id[] = { { "ili9486", 0 }, + { "rpi-lcd-35", 0 }, { } }; MODULE_DEVICE_TABLE(spi, ili9486_id); From patchwork Thu Nov 17 08:47:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlo Caione X-Patchwork-Id: 13046332 X-Patchwork-Delegate: neil.armstrong@linaro.org 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 0755BC43219 for ; Thu, 17 Nov 2022 08:50:49 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jAWZ5Lv75jKQdPeve4gtT5LhI6IdzNNxdqHxxk6RFuI=; b=B3UNWMFYTnpEsQ cMCfNh3XEvRSX+VcPMs70iIZEyEqbezd9VntrboSMATyz/xYrkLqUoBihuf9ihtYtqWCXcDdP1E+U 052NCCwDY2VyMKCZhCwd7+LnDsRSGUDW45zhsNMTImwRzOr7J/ZPV3g6hAL6iDm+CzI867TVssN9N +DuE6+LiDNmgg4MZRn8eCvbh7EZcRuEN/1Ke7o9wb85o2DvcMvUM0JSZObTF6ewNr7qhG7UQIPaFk +oVh+wzIH1RB+iO99umDikupTJToabANgnd5sSSWOI+fDjeWC3db2FPJaD1RubwL24f8o/sffJE4j wqWly+5Dqz+jZPp9GWsA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ovabU-00BpWt-Df; Thu, 17 Nov 2022 08:50:36 +0000 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ovaYz-00BoDa-2X for linux-amlogic@lists.infradead.org; Thu, 17 Nov 2022 08:48:02 +0000 Received: by mail-ed1-x535.google.com with SMTP id z20so54189edc.13 for ; Thu, 17 Nov 2022 00:47:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=90zm8/9EgVKMcm+GcVTwlECGEPSG+I41CMXM1RTutaE=; b=UnkavLeF63kWpP4dt3DH3oo2hhLFs7VsnslG4t92oUQapu5uMsW0U6XFO9MEi+swRX /ohsTvFbJwQ0scQ1IYNcwQ/z036JyCSL0TqusFH7ceidILUrvk9jSNNs0P9hFMLeNW+V FGnwjC0/0OhODR4CMHeGQJEp+HL0G5XlSqf8wbQ4bMqMUukKA+CgfLE/W1wbO98Xf7iN k06oxVsEINbbzZzifkn9cqEmMGs7wwacRRZd+8Ve+L2FKO7hiz1X87dxyTl4uoSBMU72 YNLwzVDpkjjxtc3OOUB8AyHI7mAPRzIMpufnKutmnF3+8449KHQfp5KX81vW6GMUPufg IU7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=90zm8/9EgVKMcm+GcVTwlECGEPSG+I41CMXM1RTutaE=; b=vXjYMqMc60LxWC+xGL5ObZ5C7iDJkvlnQbfVHAmN7f8wpzUUuk8+Bk9RRlEdU1hZSg El6W1bAVE6CEZMev8DNNl+Q7+LyTAqX9p39ulGns/I3iuE/RAjJeQZC253IzlRKcgoJS cgKCK5IjLMZL2Ec4jFQw87SK/lULwnIadmBTxs0Kun/tCREOngs5Jsfm1ROEF7hsfMnn LthTdV0YT+RZOi1kn9s/5OCsi+9DSR9q9KCXy+WsRk6UfAsFaMTpYVcuSigYcPvjT4Yv sgVu/5vn2+bw3v5UusxUbv4Hfr2lQ37ghboZIYjmFCSB/HMq/m250Ws7f1kTyZ7jiZmM GfKg== X-Gm-Message-State: ANoB5pnakQp1ohfsHEIH4fmwRa7IuPIo8ZfXeZlO9mFwPk2aFsBvqv+E VXjfsg0DMcQOGfBaIHjQ2Vsf+w== X-Google-Smtp-Source: AA0mqf62OFgXu+YnjTocaXwjywIf8zuYGwGTL2hEIk6+Tn1N0UikQX9Em/Xzv0xyvJ8QZXrsGxenHw== X-Received: by 2002:aa7:d1c5:0:b0:461:dd11:c1bd with SMTP id g5-20020aa7d1c5000000b00461dd11c1bdmr1207044edp.406.1668674873463; Thu, 17 Nov 2022 00:47:53 -0800 (PST) Received: from [127.0.1.1] ([2a0e:41a:894f:0:7a60:27eb:954c:5ab1]) by smtp.gmail.com with ESMTPSA id s22-20020a1709067b9600b0077205dd15basm77332ejo.66.2022.11.17.00.47.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 00:47:53 -0800 (PST) From: Carlo Caione Date: Thu, 17 Nov 2022 09:47:40 +0100 Subject: [PATCH 2/3] drm/tiny: ili9486: Do not assume 8-bit only SPI controllers MIME-Version: 1.0 Message-Id: <20221116-s905x_spi_ili9486-v1-2-630401cb62d5@baylibre.com> References: <20221116-s905x_spi_ili9486-v1-0-630401cb62d5@baylibre.com> In-Reply-To: <20221116-s905x_spi_ili9486-v1-0-630401cb62d5@baylibre.com> To: Kamlesh Gurudasani , Mark Brown , Neil Armstrong , Jerome Brunet , David Airlie , Martin Blumenstingl , Kevin Hilman , Daniel Vetter Cc: linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, dri-devel@lists.freedesktop.org, Carlo Caione X-Mailer: b4 0.10.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221117_004801_174001_CDB67D26 X-CRM114-Status: GOOD ( 16.13 ) X-BeenThere: linux-amlogic@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-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org The ILI9486 driver is wrongly assuming that the SPI panel is interfaced only with 8-bit SPI controllers and consequently that the pixel data passed by the MIPI DBI subsystem are already swapped before being sent over SPI using 8 bits-per-word. This is not always true for all the SPI controllers. Make the command function more general to not only support 8-bit only SPI controllers and support sending un-swapped data over SPI using 16 bits-per-word when dealing with pixel data. Signed-off-by: Carlo Caione --- drivers/gpu/drm/tiny/ili9486.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/tiny/ili9486.c b/drivers/gpu/drm/tiny/ili9486.c index bd37dfe8dd05..4d80a413338f 100644 --- a/drivers/gpu/drm/tiny/ili9486.c +++ b/drivers/gpu/drm/tiny/ili9486.c @@ -43,6 +43,7 @@ static int waveshare_command(struct mipi_dbi *mipi, u8 *cmd, u8 *par, size_t num) { struct spi_device *spi = mipi->spi; + unsigned int bpw = 8; void *data = par; u32 speed_hz; int i, ret; @@ -56,8 +57,6 @@ static int waveshare_command(struct mipi_dbi *mipi, u8 *cmd, u8 *par, * The displays are Raspberry Pi HATs and connected to the 8-bit only * SPI controller, so 16-bit command and parameters need byte swapping * before being transferred as 8-bit on the big endian SPI bus. - * Pixel data bytes have already been swapped before this function is - * called. */ buf[0] = cpu_to_be16(*cmd); gpiod_set_value_cansleep(mipi->dc, 0); @@ -71,12 +70,18 @@ static int waveshare_command(struct mipi_dbi *mipi, u8 *cmd, u8 *par, for (i = 0; i < num; i++) buf[i] = cpu_to_be16(par[i]); num *= 2; - speed_hz = mipi_dbi_spi_cmd_max_speed(spi, num); data = buf; } + /* + * Check whether pixel data bytes needs to be swapped or not + */ + if (*cmd == MIPI_DCS_WRITE_MEMORY_START && !mipi->swap_bytes) + bpw = 16; + gpiod_set_value_cansleep(mipi->dc, 1); - ret = mipi_dbi_spi_transfer(spi, speed_hz, 8, data, num); + speed_hz = mipi_dbi_spi_cmd_max_speed(spi, num); + ret = mipi_dbi_spi_transfer(spi, speed_hz, bpw, data, num); free: kfree(buf); From patchwork Thu Nov 17 08:47:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlo Caione X-Patchwork-Id: 13046331 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 6B430C4332F for ; Thu, 17 Nov 2022 08:50:47 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tFY49xSlvjpqJDPqaBQDs0etlsnIg0pKKCebYvDC4zQ=; b=saS0NEn6tBh9me xg4VmERIYZUkOcUMJhtc0qcVbAxBnG+TYcL8PVNmxvJawqAqBnhv5/gbx0nL+jvVKUD5CIDJ4NBKf vbD5tpBjePn6oGt3JosNTN1lAr6XIHj9Q/9V7G7STewY/KNcZRnRfgFpS3NYNBXQW5QHb3Dm2abQl zS9Tw4Cbvc1FqLY7fv6YxYLybapHsTgut1IbmhTXqvzDoDr6VjHl5JVEN/smidu3H10iPmAWdE0VN x56vuXjjZJECBR7xVdjIEv5TVmTIJzYMJAl17DfRcauogHT8dYDM7GApCNjilBEwJQfTUnsbaPtUV mU53UR8tojwAZcpLCvtg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ovabU-00BpXI-RI; Thu, 17 Nov 2022 08:50:36 +0000 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ovaYz-00BoED-4e for linux-amlogic@lists.infradead.org; Thu, 17 Nov 2022 08:48:04 +0000 Received: by mail-ed1-x535.google.com with SMTP id i21so1509647edj.10 for ; Thu, 17 Nov 2022 00:47:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=idox2DWf9CfxY6np+xVajajSNgisazAtYo+m3/oXIzQ=; b=YJtoDwNevsDYE56TfvpY13pJKKdr1ptUtkThXpzJvzyqFNfQ0lQAYsHeD/G6ijoQb9 FzNX3VDp0JST+f3q3q97kt/nU09VpZOu7LMruQ2aOWiPdjy515rP0ho3XAzk1xer9fUN oo8Xij8p06FD8ZWJk/LZaY9rS8uvkmH0Z1QGAUQbauZoRhXRKl8mkUxO/VfQ94d/bxDO 0PA707ZmvAL0b7U1IDRpV2graHjHktcAA/oqFa82GZMPJbLgLQQ8+eIAE7kVfLldaMqZ ih7RbpltfyVp99rBOpxzOCYnMi64Up3c/VX8yVq0MmjyQIqG90pWGWBylHcJm+0gLN/P +P2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=idox2DWf9CfxY6np+xVajajSNgisazAtYo+m3/oXIzQ=; b=iS1ad8avS+zOx6MUWgEJMeIMcBK+Q35/dopczVpxkGFcM2+rthAMLf8wlZuAy7Ys52 CAhSfIhQ5LuIVfZQuJuYuPm3usPod/haQSGLapV8s4e6i1CSFAGdpGuYpA1YVtAVmtJC Grptf3OgH3aS0SOKbdPaSFLg/DZEk/50VthbiBWQeERDIPwiD1kBvNWaS8ywxMDpxuSV ETCJowsRO8olN9WeBlJ/Mebra4aFZRgZro1Fg9IZvPce39pkD3cqFAJT2oQofTQTEFA6 dFKs9rN+VlqiKdjiZqxVQa5EmrRKupvg0SP3H015SHpX9BRGElH9wvcO8Rk+5hOikq74 KwHg== X-Gm-Message-State: ANoB5plWSiIwqq88SOgGiDZrwME7/fuool6HHz8dEKKria7NNxmqQCnC XOgnm/UnMzq5l3zXIVgcOrh8hQ== X-Google-Smtp-Source: AA0mqf4yWjrqIlKEjUvVEQZBYNp9Cyg1fui9YTk3qSoXBiIO38liYCs7aLKXOQNddd4uvH2WBxvUEA== X-Received: by 2002:a05:6402:3707:b0:467:6847:83d3 with SMTP id ek7-20020a056402370700b00467684783d3mr1257987edb.247.1668674874355; Thu, 17 Nov 2022 00:47:54 -0800 (PST) Received: from [127.0.1.1] ([2a0e:41a:894f:0:7a60:27eb:954c:5ab1]) by smtp.gmail.com with ESMTPSA id s22-20020a1709067b9600b0077205dd15basm77332ejo.66.2022.11.17.00.47.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 00:47:54 -0800 (PST) From: Carlo Caione Date: Thu, 17 Nov 2022 09:47:41 +0100 Subject: [PATCH 3/3] spi: meson-spicc: Lower CS between bursts MIME-Version: 1.0 Message-Id: <20221116-s905x_spi_ili9486-v1-3-630401cb62d5@baylibre.com> References: <20221116-s905x_spi_ili9486-v1-0-630401cb62d5@baylibre.com> In-Reply-To: <20221116-s905x_spi_ili9486-v1-0-630401cb62d5@baylibre.com> To: Kamlesh Gurudasani , Mark Brown , Neil Armstrong , Jerome Brunet , David Airlie , Martin Blumenstingl , Kevin Hilman , Daniel Vetter Cc: linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, dri-devel@lists.freedesktop.org, Carlo Caione X-Mailer: b4 0.10.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221117_004801_246787_6AFB2CAD X-CRM114-Status: GOOD ( 11.58 ) X-BeenThere: linux-amlogic@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-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org On some hardware (reproduced on S905X) when a large payload is transmitted over SPI in bursts at the end of each burst, the clock line briefly fluctuates creating spurious clock transitions that are being recognised by the connected device as a genuine pulses, creating an offset in the data being transmitted. Lower the GPIO CS between bursts to avoid the clock being interpreted as valid. Signed-off-by: Carlo Caione --- drivers/spi/spi-meson-spicc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/spi/spi-meson-spicc.c b/drivers/spi/spi-meson-spicc.c index d47f2623a60f..af8d74b53519 100644 --- a/drivers/spi/spi-meson-spicc.c +++ b/drivers/spi/spi-meson-spicc.c @@ -291,6 +291,10 @@ static inline void meson_spicc_setup_burst(struct meson_spicc_device *spicc) static irqreturn_t meson_spicc_irq(int irq, void *data) { struct meson_spicc_device *spicc = (void *) data; + struct spi_device *spi_dev; + + spi_dev = spicc->message->spi; + gpiod_set_value(spi_dev->cs_gpiod, 0); writel_bits_relaxed(SPICC_TC, SPICC_TC, spicc->base + SPICC_STATREG); @@ -309,6 +313,8 @@ static irqreturn_t meson_spicc_irq(int irq, void *data) /* Setup burst */ meson_spicc_setup_burst(spicc); + gpiod_set_value(spi_dev->cs_gpiod, 1); + /* Start burst */ writel_bits_relaxed(SPICC_XCH, SPICC_XCH, spicc->base + SPICC_CONREG);