From patchwork Mon Nov 21 09:42:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlo Caione X-Patchwork-Id: 13050545 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 E5CF6C4332F for ; Mon, 21 Nov 2022 09:43:58 +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=v7OTtePP1WwaOnLXYjaevpfV+nUWdHpARXwgBweTkdM=; b=M+LEHL+jC84VdX 1k7ykkYIRyNuXp05ggIJVIQSvXQth3KVREL679h9nWvCtyq+KSXxBEO++dWRrGQIyWyFiSitrnJei PTgbiJi7xgWsJz2Gh6f09P6Hd2PKli9nd7tNKAGLpGx4Xgw0d9Q7BDVGtgdezZXw8IbX/fBJLafNn VCFx5dPlkzL5U+Q4b3fgUFQipioX8eoQ+pwWTjs4UoJSIklOPcr26ldRECTkJ2nluBD/aYoFkV+Ov sql4H+54qXI7f4iVkHIxIl4pS3mzWKY77wYMPT43aTq+93yr3VdEyO8zBurjrQvEE/jg9E6YfeWHM NwPVvyXbtVQyTgVggrEw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ox3KI-00Bufd-90; Mon, 21 Nov 2022 09:42:54 +0000 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ox3K6-00BuVc-NF for linux-arm-kernel@lists.infradead.org; Mon, 21 Nov 2022 09:42:45 +0000 Received: by mail-ej1-x633.google.com with SMTP id kt23so27126588ejc.7 for ; Mon, 21 Nov 2022 01:42:41 -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=cq8m6/mJPVrF19T4WTdu7gvq/nVLWRDjsh13J+Xr+Nn2iF4Hy9OD9nI54bY967FWG/ 3UOVhClJW4x4n2d97tfeDtKj/uthmhp699BqkgzMipcAj7tJSDny5vG9BdCLomnktnEj JLHLZjM0+76mx9DOq+ZPhDpQbUs1EjdA5A8QskH4ttK1DQdid4KKDe5WnlGyued2Rstr Jr5nh/9uT/4QkkPRzvI8bD+mOl9SVJHzqYG1WEKJvRVndpiMXm7cxc7b5miDOmV6Uxx4 nj86LC1IOU+6NmDxVUZhIhYSv6YkCgpUu0klxQEKrS1S9MHECaNaSDIhEyK/W8FZe9Tk t+cg== 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=HvVyfSMUN1toEnqz0j28X1LGaAsorwt9LJZc9CjncXUEXQTQRnAq8WWWitlUv6f/1Y K/XbmJIusGcf7SwNCKOTcMCIPAs8RGcxa5/brRIIcR0ZmDoTN1dQRmlmztKULjzrUDqA xL8nHecQ3qbp89p2Z9CsTf66zFlwd/gY8ApvrsD3oieGH/Pcsabw5iBABJkpUsA+QFC3 lM5W2wsyXNGru9BVYa6dHcor8pyeHggeonuMfe4YO2Udd1V94hpmDtLR00cbcaqJ1K5G mV0/7JPv348oja/9smz9XmfL811RFb0h+O48HYJqtYyUu2cOb7R5qKgtS0MdBSqVGtwt LdXQ== X-Gm-Message-State: ANoB5pntbzBhYjH1i9xvnJUFYJqnyOeUiqLqEnaM8WkmbVW31wdTiSgF yI4QoAKuJxSmfyQRQsgQK6b4Zw== X-Google-Smtp-Source: AA0mqf4iGDXMlAJ1h8pqCDx2Am2EQUjsXM5qy6Z6ikSWJyeR7/x1T5VoUQJXLLJdiXSkQzAYW6nAog== X-Received: by 2002:a17:906:a259:b0:7ad:ccae:a30d with SMTP id bi25-20020a170906a25900b007adccaea30dmr15189830ejb.704.1669023760591; Mon, 21 Nov 2022 01:42:40 -0800 (PST) Received: from [127.0.1.1] ([2a0e:41a:894f:0:c97f:bc5d:82d3:1a3b]) by smtp.gmail.com with ESMTPSA id k11-20020a17090632cb00b0078d3f96d293sm4822240ejk.30.2022.11.21.01.42.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Nov 2022 01:42:39 -0800 (PST) From: Carlo Caione Date: Mon, 21 Nov 2022 10:42:30 +0100 Subject: [PATCH v2 1/2] drm/tiny: rpi-lcd-35: Enable driver module autoloading MIME-Version: 1.0 Message-Id: <20221116-s905x_spi_ili9486-v2-1-084c6e3cd930@baylibre.com> References: <20221116-s905x_spi_ili9486-v2-0-084c6e3cd930@baylibre.com> In-Reply-To: <20221116-s905x_spi_ili9486-v2-0-084c6e3cd930@baylibre.com> To: Mark Brown , Daniel Vetter , David Airlie , Martin Blumenstingl , Kevin Hilman , Kamlesh Gurudasani , Jerome Brunet , Neil Armstrong Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.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-20221121_014242_762035_F5A35C63 X-CRM114-Status: GOOD ( 10.10 ) 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). Signed-off-by: Carlo Caione Reviewed-by: Neil Armstrong --- 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 Mon Nov 21 09:42:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlo Caione X-Patchwork-Id: 13050546 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 1CEB0C43219 for ; Mon, 21 Nov 2022 09:44:12 +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=emmx3EnqGrtYkDaBwwFpZgzGTgi0j2CMo67J8uor4as=; b=BpEv6/6y9HRkXW I3P1DY9erRtd7kCMpaZElyg+1mn28znMS8jdGLzZcOPBoQT7TV2zeRVqQ0CbXo714EOwnvUl1R40n 5j6mWKyBHoWPaie2shP8Egf2BvNbKhZqNB3/8ZdUUwR3lR9HPIc+O3d3iFEMRbTW5ycxx3Wqnw50m QrDX5TmEYyRrGiFRQ5r1OXJIJbM6OeM8zfJi/TASt1d13iCIMEWT6tYqbeIpZAVeOc13y6apIbJZJ Msyll8sg1X/H2LnUB3U7ZheHUKM1iFhMWUfABwxNKINly9x6sqdgia+8b+nGk8DjpNqh/j9Vkmw3b k8tFCtdgbJQVZHFUOrKQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ox3KR-00Bul1-UL; Mon, 21 Nov 2022 09:43:04 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ox3KC-00BuZg-Fo for linux-arm-kernel@bombadil.infradead.org; Mon, 21 Nov 2022 09:42:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Sender:Reply-To:Content-ID:Content-Description; bh=Hu5U86ige5HyMDl6UUjo7RBdCuH6co9yADRt72Y/8MY=; b=K6GB7OoHleuF3HJwSU7MCpG3YR 1pde+JjeNFGJ/LiLFODqY3mRpeY/POIksxzJ8OIm6tQVMdwyC5lxckdMEltHceTQmL0SRqO0QNFnf yT1skxQz1GbMcjipwpzSWDXnj0OhiTSTaZT7SmEO80z1aeyErd+OEahZ++4FmU5SrF2TCar6hRa/t lMumJbGMEOzGlSH2koESet7mcwbcC+ZvM6CDdAtmEgFoXOTYbl8hHdRazDndjJDuf3CrLFR5TbPOq ZNQRlS7vGUE7J7wSujZW8AX+4LKIlnGmLPpezv3hKFOusI5p5pemEnyi+MwqFsTpXYeSfNMEfhm2J XqFmlNiQ==; Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ox3K8-00347p-3w for linux-arm-kernel@lists.infradead.org; Mon, 21 Nov 2022 09:42:46 +0000 Received: by mail-ej1-x62f.google.com with SMTP id n21so27102476ejb.9 for ; Mon, 21 Nov 2022 01:42:42 -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=Hu5U86ige5HyMDl6UUjo7RBdCuH6co9yADRt72Y/8MY=; b=hA9fcWmto4ybP9K5GSKv+Pfqt4s/xOpxBEdTWZGxoXk6kt2zLckX/Yk82YP6m+DRQH sIF9hMmmAMqBUceUi3M1Z/0jgaKEQAGWC0QiBrGojCm9mqwLy8C3CThNtvEkPyHQJcjW 4xKF6ACJiKqPomEiYRKmMCyDNJSNXrdq9bFaNJbmXHgXIeBGD5jZ5z4ORQ7jgp1Kw6VI /b19SKnEYkxN5X1LFi3izAJW23uJ9NO5iJuVGGA2PTfj9oAlSXXN9j4ewaG37Vjeic6s 99UtizGD47CZl7b9UFTfW2JeHkMp208v3pRhlTmm6YlX3PeDAT60zsSPk5xRzaFPIcHj d3cQ== 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=Hu5U86ige5HyMDl6UUjo7RBdCuH6co9yADRt72Y/8MY=; b=dPS8j+aRDhFzFDquJcblKJIFNcQKAEPqB/ROVpgjb8MMo3iGKSSNvayBazZIKimgfI JFcObgsHl1eeDHt5Y2zlXu/uveA9aNXVXYLlwu9P9rZKjgkeJG3qjTMsZQVhswh/jgDG 2sxwNQFpYD1OZ6OsHNdYO6stc/ay/pNDZuOYouFnFxKDAwFAM0qNdjnBzswQMzFAp2WE O2tdmGoyzVAAYcFIwXTJ23QGqy/0g6sH5HVFCHJdcCcwYAVfZoRTpxoDqHPF8cmHFdvf /Z1qaJGicZeAmIh22I9pZ4HTkEYCRPfWt3sGx+TA0wxGi99Awj8fap6vGzaed/v9sfyC CqCg== X-Gm-Message-State: ANoB5pmAZQrteCCSyOd3Fh86aLslwZkYif+9GaGEA1gn1ztOc9a7RrTX 0xfuzuq6U3tNTM45pNdgJPpzcw== X-Google-Smtp-Source: AA0mqf7R80CBcgut7WKoqa2UyoJjTe+iSCNXbGx9E8tOfUa5mUdWN2uLlo6XvJ+69OMC/vUzYl5ZwQ== X-Received: by 2002:a17:907:986b:b0:7ad:b7c2:a2f7 with SMTP id ko11-20020a170907986b00b007adb7c2a2f7mr14848367ejc.227.1669023761673; Mon, 21 Nov 2022 01:42:41 -0800 (PST) Received: from [127.0.1.1] ([2a0e:41a:894f:0:c97f:bc5d:82d3:1a3b]) by smtp.gmail.com with ESMTPSA id k11-20020a17090632cb00b0078d3f96d293sm4822240ejk.30.2022.11.21.01.42.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Nov 2022 01:42:41 -0800 (PST) From: Carlo Caione Date: Mon, 21 Nov 2022 10:42:31 +0100 Subject: [PATCH v2 2/2] drm/tiny: ili9486: Do not assume 8-bit only SPI controllers MIME-Version: 1.0 Message-Id: <20221116-s905x_spi_ili9486-v2-2-084c6e3cd930@baylibre.com> References: <20221116-s905x_spi_ili9486-v2-0-084c6e3cd930@baylibre.com> In-Reply-To: <20221116-s905x_spi_ili9486-v2-0-084c6e3cd930@baylibre.com> To: Mark Brown , Daniel Vetter , David Airlie , Martin Blumenstingl , Kevin Hilman , Kamlesh Gurudasani , Jerome Brunet , Neil Armstrong Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.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-20221121_094244_455153_600ECAD7 X-CRM114-Status: GOOD ( 21.13 ) 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 tranfer size to the maximum allowed by the SPI controller. Signed-off-by: Carlo Caione Reviewed-by: Neil Armstrong --- 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);