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 X-Spam-Level: X-Spam-Status: No, score=-15.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78F95C47094 for ; Thu, 10 Jun 2021 16:15:16 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id E0DCE613D8 for ; Thu, 10 Jun 2021 16:15:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E0DCE613D8 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=tronnes.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3AD4B6E4C7; Thu, 10 Jun 2021 16:15:15 +0000 (UTC) Received: from smtp.domeneshop.no (smtp.domeneshop.no [IPv6:2a01:5b40:0:3005::1]) by gabe.freedesktop.org (Postfix) with ESMTPS id B0EF46E4AB for ; Thu, 10 Jun 2021 16:15:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tronnes.org ; s=ds202012; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=DsuXOYEpStmYHjHet2t4PBPL/C0QMO3rH0jmj3qa7v4=; b=CMQOHZUia4vYZrIAkshYrczXQ3 zU+nxVva1j8Gom9Tjk3AC8Qa+w1wU/NuT8pmHZ6G95p6eQ4jGRvOlH3Iak0Uj4YrB+DA0CIO5pntq Z2LauMjwuvUfADWUlTYa+aT0Bi9K1YFzSLwAblp1bx4OswUmKVgaw6H83THW2LuxhnWlLqVy3mP2a xS2xEM6lUbLA229Qh3yNGy4gDXj9wbDhyGKeAMPkZGOkcXTv5B+6AnnehchoOGg/pu7ouUSI/VTr6 z3M+VpvpRNYDg/9PJI4Kjsb9iT31IHnw03aB9QPRvuTnMazooDgYC4l2goXam9zoL1TVhgnYkNjJM 9pM/ZdSQ==; Received: from [2a01:799:95f:4600:1d9c:bc7e:a70c:463] (port=50924) by smtp.domeneshop.no with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lrNKp-0006dG-8i; Thu, 10 Jun 2021 18:15:11 +0200 Subject: Re: [PATCH v4] drm/panel: db7430: Add driver for Samsung DB7430 To: Linus Walleij , Thierry Reding , Sam Ravnborg , dri-devel@lists.freedesktop.org References: <20210610132501.315086-1-linus.walleij@linaro.org> From: =?UTF-8?Q?Noralf_Tr=c3=b8nnes?= Message-ID: <61750bfe-74f4-b425-f312-4bf791ad18c6@tronnes.org> Date: Thu, 10 Jun 2021 18:15:08 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 In-Reply-To: <20210610132501.315086-1-linus.walleij@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit 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: Paul Cercueil , Doug Anderson Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Den 10.06.2021 15.25, skrev Linus Walleij: > This adds a new driver for the Samsung DB7430 DPI display > controller as controlled over SPI. > > Right now the only panel product we know that is using this > display controller is the LMS397KF04 but there may be more. > > This is the first regular panel driver making use of the > MIPI DBI helper library. The DBI "device" portions can not > be used because that code assumes the use of a single > regulator and specific timings around the reset pulse that > do not match the DB7430 datasheet. > > Cc: Noralf Trønnes > Cc: Paul Cercueil > Cc: Doug Anderson > Signed-off-by: Linus Walleij > --- > ChangeLog v3->v4: > - Managed to make use of the in-kernel DBI support to > conjure and send 9bit DBI SPI messages. When I moved the DBI code out of tinydrm I split it up into an interface part and a framebuffer part so panel drivers could use the interface part like you have done here. > - This cuts out a bit of overhead. > - Deeper integration with the DBI library is not done, as > assumes too much about the device, such as being used > as a stand-alone framebuffer (this device is not). > diff --git a/drivers/gpu/drm/panel/panel-samsung-db7430.c b/drivers/gpu/drm/panel/panel-samsung-db7430.c > new file mode 100644 > index 000000000000..c11b3da65896 > --- /dev/null > +++ b/drivers/gpu/drm/panel/panel-samsung-db7430.c > +/** > + * struct db7430 - state container for a panel controlled by the DB7430 > + * controller > + */ > +struct db7430 { > + /** @dev: the container device */ > + struct device *dev; > + /** @dbi: the DBI bus abstraction handle */ > + struct mipi_dbi dbi; > + /** @panel: the DRM panel instance for this device */ > + struct drm_panel panel; > + /** @width: the width of this panel in mm */ > + u32 width; > + /** @height: the height of this panel in mm */ > + u32 height; > + /** @reset: reset GPIO line */ > + struct gpio_desc *reset; You can use dbi->reset. > + /** @regulators: VCCIO and VIO supply regulators */ > + struct regulator_bulk_data regulators[2]; > +}; > +static int db7430_probe(struct spi_device *spi) > +{ > + struct device *dev = &spi->dev; > + struct db7430 *db; > + int ret; > + > + db = devm_kzalloc(dev, sizeof(*db), GFP_KERNEL); > + if (!db) > + return -ENOMEM; > + db->dev = dev; > + > + /* > + * VCI is the analog voltage supply > + * VCCIO is the digital I/O voltage supply > + */ > + db->regulators[0].supply = "vci"; > + db->regulators[1].supply = "vccio"; > + ret = devm_regulator_bulk_get(dev, > + ARRAY_SIZE(db->regulators), > + db->regulators); > + if (ret) > + return dev_err_probe(dev, ret, "failed to get regulators\n"); > + > + db->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); > + if (IS_ERR(db->reset)) { > + ret = PTR_ERR(db->reset); > + return dev_err_probe(dev, ret, "no RESET GPIO\n"); > + } > + > + spi->bits_per_word = 9; Do you need to set this? The DBI helper sets it on the SPI transfer if the SPI controller supports 9-bit or uses emulation code if not. > + /* Preserve e.g. SPI_3WIRE setting */ > + spi->mode |= SPI_MODE_3; You can use the DT properties 'spi-cpha' and 'spi-cpol' to set this. > + ret = spi_setup(spi); So I don't think you need to call spi_setup() here. This code as-is will fail on a SPI controller that doesn't support 9 bits per word, and the emulation code in the DBI helper won't be utilised. With the comments considered: Acked-by: Noralf Trønnes Noralf. > + if (ret < 0) > + return dev_err_probe(dev, ret, "spi setup failed\n"); > + > + ret = mipi_dbi_spi_init(spi, &db->dbi, NULL); > + if (ret) > + return dev_err_probe(dev, ret, "MIPI DBI init failed\n"); > + > + drm_panel_init(&db->panel, dev, &db7430_drm_funcs, > + DRM_MODE_CONNECTOR_DPI); > + > + /* FIXME: if no external backlight, use internal backlight */ > + ret = drm_panel_of_backlight(&db->panel); > + if (ret) > + return dev_err_probe(dev, ret, "failed to add backlight\n"); > + > + spi_set_drvdata(spi, db); > + > + drm_panel_add(&db->panel); > + dev_dbg(dev, "added panel\n"); > + > + return 0; > +}