From mboxrd@z Thu Jan 1 00:00:00 1970 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 2AF06C433FE for ; Tue, 12 Apr 2022 07:31:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5C11110E78E; Tue, 12 Apr 2022 07:31:23 +0000 (UTC) Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) by gabe.freedesktop.org (Postfix) with ESMTPS id A162B10E78E for ; Tue, 12 Apr 2022 07:31:22 +0000 (UTC) Received: by mail-qt1-f178.google.com with SMTP id z19so18527509qtw.2 for ; Tue, 12 Apr 2022 00:31:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vPZwLQHFGbE+YddKPiwbAMBD+8+olRhnFPT9yzLHixE=; b=IgmFf5jVWjM4pSz5t2GAJJkA81SHpSHf94lmR0DncoyPIzkbni+JlQTNtgT/RnYHzc j+w9lmSvJucJ3MwE2l8QWL5zDmdsh1BlkNk8Ts3AOP+DWR3HhO8Uieuc1REXe+w2fsOC cUfFlrMjxUPsmks0orWZ0h0KRP51OhfuiQlcc237jTDDWWxh9xTvhbwN/lt/L8CBRyXz igDBxY+9En3qvkLlUSzZz5p5YnxoAgq22i1UrYDcJJTlFWrombJJhDp93objnTryKc4i /kZ5cHc6DIOovlegNK0zwBowhVaA+/0PmF9GH1zQndDVlXO66o+jcP1dkAVI3x939bBW blGw== X-Gm-Message-State: AOAM533sbzenMJJFpypJ3og8kYn0+ZgfWmmIOa+uSFo38OPXIZvjYtH7 pipfpC4tR7M2tI1EUn/i8iuvBmVyD/jcMWP5 X-Google-Smtp-Source: ABdhPJznQQZGuBTFsCX5uNuDJAW6LoVuI+Awk0nfsJZgUsn7e9Z5Jt4suelUICkP4y2kU6BAj0oV7A== X-Received: by 2002:ac8:7c55:0:b0:2e1:d535:d881 with SMTP id o21-20020ac87c55000000b002e1d535d881mr2307373qtv.188.1649748681602; Tue, 12 Apr 2022 00:31:21 -0700 (PDT) Received: from mail-yw1-f178.google.com (mail-yw1-f178.google.com. [209.85.128.178]) by smtp.gmail.com with ESMTPSA id c3-20020ac87d83000000b002e1d1b3df15sm28020958qtd.44.2022.04.12.00.31.21 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 Apr 2022 00:31:21 -0700 (PDT) Received: by mail-yw1-f178.google.com with SMTP id 00721157ae682-2ebd70a4cf5so132986177b3.3 for ; Tue, 12 Apr 2022 00:31:21 -0700 (PDT) X-Received: by 2002:a81:4f0d:0:b0:2ec:1556:815 with SMTP id d13-20020a814f0d000000b002ec15560815mr8100148ywb.256.1649748680829; Tue, 12 Apr 2022 00:31:20 -0700 (PDT) MIME-Version: 1.0 References: <20220411211243.11121-1-javierm@redhat.com> <20220411211243.11121-6-javierm@redhat.com> In-Reply-To: <20220411211243.11121-6-javierm@redhat.com> From: Geert Uytterhoeven Date: Tue, 12 Apr 2022 09:31:09 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 5/5] drm/solomon: Add SSD130x OLED displays SPI support To: Javier Martinez Canillas Content-Type: text/plain; charset="UTF-8" X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chen-Yu Tsai , Neil Armstrong , David Airlie , YueHaibing , Linux Kernel Mailing List , DRI Development , Chen-Yu Tsai , Mark Brown , Maxime Ripard , Andy Shevchenko Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Hi Javier, On Mon, Apr 11, 2022 at 11:12 PM Javier Martinez Canillas wrote: > The ssd130x driver only provides the core support for these devices but it > does not have any bus transport logic. Add a driver to interface over SPI. > > There is a difference in the communication protocol when using 4-wire SPI > instead of I2C. For the latter, a control byte that contains a D/C# field > has to be sent. This field tells the controller whether the data has to be > written to the command register or to the graphics display data memory. > > But for 4-wire SPI that control byte is not used, instead a real D/C# line > must be pulled HIGH for commands data and LOW for graphics display data. > > For this reason the standard SPI regmap can't be used and a custom .write > bus handler is needed. > > Signed-off-by: Javier Martinez Canillas > Acked-by: Mark Brown Thanks for your patch! > --- /dev/null > +++ b/drivers/gpu/drm/solomon/ssd130x-spi.c > +static struct gpio_desc *ssd130x_spi_get_dc(struct device *dev) > +{ > + struct gpio_desc *dc = devm_gpiod_get(dev, "dc", GPIOD_OUT_LOW); > + > + if (IS_ERR(dc)) > + return ERR_PTR(dev_err_probe(dev, PTR_ERR(dc), "Failed to get dc gpio\n")); > + > + return dc; > +} > + > +static int ssd130x_spi_probe(struct spi_device *spi) > +{ > + struct ssd130x_spi_transport *t; > + struct ssd130x_device *ssd130x; > + struct regmap *regmap; > + struct device *dev = &spi->dev; > + > + t = devm_kzalloc(dev, sizeof(*t), GFP_KERNEL); > + if (!t) > + return dev_err_probe(dev, -ENOMEM, > + "Failed to allocate SPI transport data\n"); > + > + t->spi = spi; > + > + t->dc = ssd130x_spi_get_dc(&spi->dev); > + if (IS_ERR(t->dc)) > + return PTR_ERR(t->dc); This can be simplified (no need for the PTR_ERR(ERR_PTR(...) dance) by open-coding ssd130x_spi_get_dc() here. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1DB20C4321E for ; Tue, 12 Apr 2022 09:28:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389689AbiDLJYD (ORCPT ); Tue, 12 Apr 2022 05:24:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377707AbiDLHxN (ORCPT ); Tue, 12 Apr 2022 03:53:13 -0400 Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF83A50057 for ; Tue, 12 Apr 2022 00:31:22 -0700 (PDT) Received: by mail-qk1-f172.google.com with SMTP id b189so13076065qkf.11 for ; Tue, 12 Apr 2022 00:31:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vPZwLQHFGbE+YddKPiwbAMBD+8+olRhnFPT9yzLHixE=; b=M2WEwWhsS5LUsL7JxqIMgLVWkxTd3CZbXf9y7CpyZ4uG0vD8865/ENv6Q1yBk619M9 pfNgXIYH+Ob8Uve6sjvq7OLZqyOdUC1/AhXOkZ0EcKc583c/TO3gM4hUqqOFkxiBLgGx BXwdkKyyqgPnTZXQNkvouqe9FQZNMIKris5r1kfjxlRn0Oa3McUKzyQao6pl+gOTk9zp 5YvQ5EohAPQOJPlulwAzLNTc2z/rawfx1PbfGfkDNfkSYboNee4Fnrhbj9EJd/Af5i10 yjN6dCRxlm3GLk5MBahon+DuDdnqi4T7xnDf1APOY5/OVnEawrAwKqjMP35FXkIoe3oQ 1r9A== X-Gm-Message-State: AOAM531dttITz2aZpz6qU1kIvLV8HQfJAxksSAwhkzjPYWQZvZ4zbl1v 2bg5c88Enf2ryD9ChcUm87++R4u/OFRxIzzO X-Google-Smtp-Source: ABdhPJxdI6CnhoDqXHFEF6pMKo5b1kU2hJN1EbOPLOACfXGqo55I0QCiXPjvFHdq4Dw1nLU9MmEHMw== X-Received: by 2002:a37:4349:0:b0:680:f1f5:23b0 with SMTP id q70-20020a374349000000b00680f1f523b0mr2096137qka.530.1649748681853; Tue, 12 Apr 2022 00:31:21 -0700 (PDT) Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com. [209.85.128.179]) by smtp.gmail.com with ESMTPSA id j21-20020ac85f95000000b002e1cde99863sm26257166qta.83.2022.04.12.00.31.21 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 Apr 2022 00:31:21 -0700 (PDT) Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-2edbd522c21so30953057b3.13 for ; Tue, 12 Apr 2022 00:31:21 -0700 (PDT) X-Received: by 2002:a81:4f0d:0:b0:2ec:1556:815 with SMTP id d13-20020a814f0d000000b002ec15560815mr8100148ywb.256.1649748680829; Tue, 12 Apr 2022 00:31:20 -0700 (PDT) MIME-Version: 1.0 References: <20220411211243.11121-1-javierm@redhat.com> <20220411211243.11121-6-javierm@redhat.com> In-Reply-To: <20220411211243.11121-6-javierm@redhat.com> From: Geert Uytterhoeven Date: Tue, 12 Apr 2022 09:31:09 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 5/5] drm/solomon: Add SSD130x OLED displays SPI support To: Javier Martinez Canillas Cc: Linux Kernel Mailing List , Rob Herring , DRI Development , Neil Armstrong , Mark Brown , Andy Shevchenko , Chen-Yu Tsai , Chen-Yu Tsai , Daniel Vetter , David Airlie , Maxime Ripard , YueHaibing Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Javier, On Mon, Apr 11, 2022 at 11:12 PM Javier Martinez Canillas wrote: > The ssd130x driver only provides the core support for these devices but it > does not have any bus transport logic. Add a driver to interface over SPI. > > There is a difference in the communication protocol when using 4-wire SPI > instead of I2C. For the latter, a control byte that contains a D/C# field > has to be sent. This field tells the controller whether the data has to be > written to the command register or to the graphics display data memory. > > But for 4-wire SPI that control byte is not used, instead a real D/C# line > must be pulled HIGH for commands data and LOW for graphics display data. > > For this reason the standard SPI regmap can't be used and a custom .write > bus handler is needed. > > Signed-off-by: Javier Martinez Canillas > Acked-by: Mark Brown Thanks for your patch! > --- /dev/null > +++ b/drivers/gpu/drm/solomon/ssd130x-spi.c > +static struct gpio_desc *ssd130x_spi_get_dc(struct device *dev) > +{ > + struct gpio_desc *dc = devm_gpiod_get(dev, "dc", GPIOD_OUT_LOW); > + > + if (IS_ERR(dc)) > + return ERR_PTR(dev_err_probe(dev, PTR_ERR(dc), "Failed to get dc gpio\n")); > + > + return dc; > +} > + > +static int ssd130x_spi_probe(struct spi_device *spi) > +{ > + struct ssd130x_spi_transport *t; > + struct ssd130x_device *ssd130x; > + struct regmap *regmap; > + struct device *dev = &spi->dev; > + > + t = devm_kzalloc(dev, sizeof(*t), GFP_KERNEL); > + if (!t) > + return dev_err_probe(dev, -ENOMEM, > + "Failed to allocate SPI transport data\n"); > + > + t->spi = spi; > + > + t->dc = ssd130x_spi_get_dc(&spi->dev); > + if (IS_ERR(t->dc)) > + return PTR_ERR(t->dc); This can be simplified (no need for the PTR_ERR(ERR_PTR(...) dance) by open-coding ssd130x_spi_get_dc() here. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds