From patchwork Mon Dec 19 09:02:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlo Caione X-Patchwork-Id: 13076382 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 BFAECC4332F for ; Mon, 19 Dec 2022 09:05:20 +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=4LazGq98JFNu8meewTt/7YgyL1fiR56jkiixE79rBlw=; b=XAwoNcHyoBHdqi qQuDeOWthXAKWv717yxONnpby1CXafhNdtul7sxfNson6BIdzkNWWRDXkm/efQbxBKT5Zg5T6TPZA wxy1HErRh6yBVl+yYsuC46QRpdZ/Kjvb5HT4c8Ou7Aca0ReImQlaGh1REJ4P56V7Ui+CKnsruWJW3 jDX+l7icCoPItOB0U9F3dBeyjlyabxkJAkmxkGuOmh5tCAxLwF5X9HSExUQmDO4DEUXF+r6/QmNQK Riobm6SVSBf1z14OI5mgOgpBriVn1MtsI45hgyvntXs6j7XX6SqfxUYi85YLxua2bK/msJB1nLbj7 uD9agnEBu0oyjK4jKtdA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p7C3W-00AyRG-Ve; Mon, 19 Dec 2022 09:03:31 +0000 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p7C2x-00AxyL-6c for linux-arm-kernel@lists.infradead.org; Mon, 19 Dec 2022 09:02:56 +0000 Received: by mail-ed1-x52b.google.com with SMTP id r26so11861491edc.10 for ; Mon, 19 Dec 2022 01:02:51 -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=iaVNFQLQjvu/mR/33Qvn+CT5WA+rfSMQXLgBgZ4bdDM=; b=A1Zy6qoRVzqAGOFB96J1pF4ERIgoQXgHOFDmK4xgQnMA9IByu4kjh3dXqg9SDx0768 9eOIKZvrDVcu1Lr5SDz6I4UX/uAxyFhNWxM+FHxQkA2sCr6dltN3cwp60irQx8HJtWm7 1sGD1oV7eWyavHo4ijHytLcjchBuWv7EQj5AOSl3BmXFm10kcICy27AaZ+GL395V1wcD tRfxLexYrV9XfMDzIUGo6adh4OzxfZ9/V/EQJ+0QUZCnJ3A8IMvwPfAjiNdEh4Q7t6NK YxVD+9+UElauhoHi6RnNG91uqksaE0D+JEe1kGZBHjAFGJE/N3MFoTWOig+xWpIqZiXl c1SA== 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=iaVNFQLQjvu/mR/33Qvn+CT5WA+rfSMQXLgBgZ4bdDM=; b=hubhbVKwrai+g7poky7Eaobr5r+aaqWXLce6GE6rWHnYsrUbqIHcD6jMuQ1omzVhen H4L6nFZiEaY93B9moM1mIPY5oXZ2AOSIQ5Ckv8batAhd41Cqtxn/SqVzVhC+br1Xdg3n q9T3t00zc7gau7dbs82JtanKSqO7CPQ8efyJBebMB7zTOvDfLBcfhgf9oW/b3XxO/tLk i55JyNjnUaTC/FCkhrfwIB8I4hrg0eq+NnnsL4qeY8r48l8W+CkWgmtUqZzZFG+C0UzW qv46TKNeRHt6JrNv7skwyJUbCQCTRAXf9Iph91yFSdMY5iU3Kp/+Xb0mzzGItt1gSFtZ opzQ== X-Gm-Message-State: AFqh2kooXZFtqEYlHE+NV/NvRsU94D4qRFvEcEYyWXVZR2ZLoshpiGRX XxFZyBLBM5QD7iCIr1yUiGPeqQ== X-Google-Smtp-Source: AMrXdXvmKZdR1xqWjHm/Mr9GhLjb73U4gYdCZ+DsGSdF0LkhCf8Hqf8o1AVqcBklR1QtE2zrDB9YuA== X-Received: by 2002:a50:ed81:0:b0:477:ff25:867a with SMTP id h1-20020a50ed81000000b00477ff25867amr8453170edr.12.1671440569906; Mon, 19 Dec 2022 01:02:49 -0800 (PST) Received: from [127.0.1.1] ([2001:b07:5d39:f336:a0ba:cfa5:2107:c2c4]) by smtp.gmail.com with ESMTPSA id u11-20020a170906b10b00b00781dbdb292asm4082721ejy.155.2022.12.19.01.02.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Dec 2022 01:02:49 -0800 (PST) From: Carlo Caione Date: Mon, 19 Dec 2022 10:02:37 +0100 Subject: [PATCH v4 1/2] drm/tiny: ili9486: Enable driver module autoloading MIME-Version: 1.0 Message-Id: <20221116-s905x_spi_ili9486-v4-1-f86b4463b9e4@baylibre.com> References: <20221116-s905x_spi_ili9486-v4-0-f86b4463b9e4@baylibre.com> In-Reply-To: <20221116-s905x_spi_ili9486-v4-0-f86b4463b9e4@baylibre.com> To: Neil Armstrong , Kevin Hilman , Jerome Brunet , Mark Brown , Daniel Vetter , David Airlie , Kamlesh Gurudasani , Martin Blumenstingl Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, Carlo Caione , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org X-Mailer: b4 0.10.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221219_010255_355113_564EB790 X-CRM114-Status: GOOD ( 10.19 ) 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 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 and piscreen). Reviewed-by: Neil Armstrong Signed-off-by: Carlo Caione Reviewed-by: Thomas Zimmermann --- drivers/gpu/drm/tiny/ili9486.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/tiny/ili9486.c b/drivers/gpu/drm/tiny/ili9486.c index 1bb847466b10..8bf0dca0b05d 100644 --- a/drivers/gpu/drm/tiny/ili9486.c +++ b/drivers/gpu/drm/tiny/ili9486.c @@ -183,6 +183,8 @@ MODULE_DEVICE_TABLE(of, ili9486_of_match); static const struct spi_device_id ili9486_id[] = { { "ili9486", 0 }, + { "rpi-lcd-35", 0 }, + { "piscreen", 0 }, { } }; MODULE_DEVICE_TABLE(spi, ili9486_id); From patchwork Mon Dec 19 09:02:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlo Caione X-Patchwork-Id: 13076386 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 C2DA8C4332F for ; Mon, 19 Dec 2022 09:06:13 +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=hS+IkeGnNHWI9Qe1mhiqgT2pTJDzUCmbZOfRyQJX9OQ=; b=gtZemA5hAdLo2V oivU4vXd4BDHTozj9ulNnBGfXJILzDlel5TEYyQLlg0Lfs0TqYTKlrv425eFc32YQd/PqEKXIb0US sDtesieDFLPmdx9L712df1akX3PcrdI7URLi40pX3xnCBXESOfQIjG1lSwD+g/x9pICIopaxF54Bp 4LHKatFZpHiNXZh1pMHlyW1c+Q5iqrhX90JjleFEMe/tR+7sAzzVx2Gp09Ti9kiVhtI1C9Jj6Y1Lb n92R6odIObjE2ryLSnSYzGKR7MsUaNg/QFltI8i/92Na1dn7ccM0/HcU0Wspuuah473bDm+3hxZT0 2FmJxB+R18c4xYbU3elQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p7C4G-00Ayro-MY; Mon, 19 Dec 2022 09:04:17 +0000 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p7C2z-00Axyi-BP for linux-arm-kernel@lists.infradead.org; Mon, 19 Dec 2022 09:03:00 +0000 Received: by mail-ej1-x62b.google.com with SMTP id gh17so19859643ejb.6 for ; Mon, 19 Dec 2022 01:02:52 -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=lqYmIYoxTMMpoYQgw16ovQhh+oEOozpYMDvGaahlUYc=; b=TQKO3zLxYXBYDTiW46AltPoen3RSbIyB8k2VaIuFnkph0BiNvBuGnifXGOY+zKrLEI LO5sFtmIdDq2PxEMYgnOvt2kONxeu0CuvZRF7RG/Gb6oTqzzUuJb9rGcEoDCqV3AfH8D qAURFDAeigb5FUW7znBFd1NHo9RBqP5xErBkXZNwvBgtXINDIsMZb8RgnpocJwD+jkf2 VUdQamL9R5duw9muX5u3+cYEnVdypu8N/js/a0YoywML0zu71Y0/HOQnRBi/T3dGWZ2F Bj5NawWiidI5fAUlI1sNlIVVeHkSlVpIpZHKEllff2+QyHvAPo0tSDNC02X/hcvuvfUF NETA== 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=lqYmIYoxTMMpoYQgw16ovQhh+oEOozpYMDvGaahlUYc=; b=OpdS+kBelRwexqLJLIJzjdXlOgMAP8feKkCwmFyJ84iRwwcLXyOBnOkrdMLtwbFy14 GmQnH80ZZd61j2xBu/BMfv6FTKW9ZlFPFqOZCfZqmEs3XUe6LCmnslfw0z6ReOrFy9uI IBWiZItzzX+UAL3f0lUmqVRC6hATONN7MSGPmAlwAgTQfDmqKe9M3Vqwh7FruOAhO3iy 7fDCaeFu+w8Ssixh7+B9FwUB2MRGmw5817n2blhMuycPqHjKpt5uk81mJxtWjdnAUJPI uJOxamhXkaXiB9ISZYPu1+VXHoRGp+xnbGEYg6oraN8PkKNz1BX5WJ53Q8QEusdW4LsG meUw== X-Gm-Message-State: ANoB5pk/Nd3Su9bDaZ58MUWxUeO3C9BgKvct3rjB5CwtR1M/qdQKUbZp jKhB1nVKkNDkavIxVTrO3m74jl0C7MVCxHKGvYs= X-Google-Smtp-Source: AA0mqf4NSk7Yw/HcS1h8rMvyHtywLl/r5oAAdXCCDdnKAMEYPX1/1IxBA282Q7E2z2acv/RmzDLBFw== X-Received: by 2002:a17:907:910b:b0:7c1:1c5:c7cd with SMTP id p11-20020a170907910b00b007c101c5c7cdmr28846533ejq.5.1671440571173; Mon, 19 Dec 2022 01:02:51 -0800 (PST) Received: from [127.0.1.1] ([2001:b07:5d39:f336:a0ba:cfa5:2107:c2c4]) by smtp.gmail.com with ESMTPSA id u11-20020a170906b10b00b00781dbdb292asm4082721ejy.155.2022.12.19.01.02.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Dec 2022 01:02:50 -0800 (PST) From: Carlo Caione Date: Mon, 19 Dec 2022 10:02:38 +0100 Subject: [PATCH v4 2/2] drm/tiny: ili9486: Do not assume 8-bit only SPI controllers MIME-Version: 1.0 Message-Id: <20221116-s905x_spi_ili9486-v4-2-f86b4463b9e4@baylibre.com> References: <20221116-s905x_spi_ili9486-v4-0-f86b4463b9e4@baylibre.com> In-Reply-To: <20221116-s905x_spi_ili9486-v4-0-f86b4463b9e4@baylibre.com> To: Neil Armstrong , Kevin Hilman , Jerome Brunet , Mark Brown , Daniel Vetter , David Airlie , Kamlesh Gurudasani , Martin Blumenstingl Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, Carlo Caione , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org X-Mailer: b4 0.10.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221219_010257_530426_F0CDFBF7 X-CRM114-Status: GOOD ( 20.71 ) 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 The pixel data for the ILI9486 is always 16-bits wide and it must be sent over the SPI bus. When the controller is only able to deal with 8-bit transfers, this 16-bits data needs to be swapped before the sending to account for the big endian bus, this is on the contrary not needed when the SPI controller already supports 16-bits transfers. The decision about swapping the pixel data or not is taken in the MIPI DBI code by probing the controller capabilities: if the controller only suppors 8-bit transfers the data is swapped, otherwise it is not. This swapping/non-swapping is relying on the assumption that when the controller does support 16-bit transactions then the data is sent unswapped in 16-bits-per-word over SPI. The problem with the ILI9486 driver is that it is forcing 8-bit transactions also for controllers supporting 16-bits, violating the assumption and corrupting the pixel data. Align the driver to what is done in the MIPI DBI code by adjusting the transfer size to the maximum allowed by the SPI controller. Reviewed-by: Neil Armstrong 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 8bf0dca0b05d..6f03531175bd 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);