Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1359907pxa; Sat, 15 Aug 2020 17:35:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyhkj17Wiu4/zTLs7fyyvov1Q2eiYUQt8dywD9Gljw3ZQgHlOHgoIbQEfweVzwUVAhAFK2R X-Received: by 2002:a05:6402:22b3:: with SMTP id cx19mr8877230edb.248.1597538143201; Sat, 15 Aug 2020 17:35:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597538143; cv=none; d=google.com; s=arc-20160816; b=s1zluLPJflB61D86KdKZyZqUndCPa+ckl3KFMgCUE4+N0nqQT2kdh/IYKhROTOYkxN 769E+bzZsQAJq2PbnrZo8S7zqhXEiFdAZWINWNAWEu40OvKL6puyWf6SZaDiZwq7criu GohmoQ1LhONd77jEDW6XmPBnxPoysdLBhG9YG53fMHEvhqBS0a7bdAjWMQg/i7LYlsza icwXmrF6eOmxiY0Wb2qzuL/gZIqJw9I7am7+X4/wI5Kt/hChTZDwUSTFxlaHIK8rAMeH rpJQjM/YQrL6iazqIgd0VovBPZYNJtEdMjxCP3S2FXLFl0Wr0GGlG6+bnXlmx99a/Nxh HS1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=1e1FEh2vybB+1uG+T5FphJmG2pNY4PP6no1OHk+SDh0=; b=PhkmvTL/RGWt8GX5FztJc8B0FF1q4+VrJK1iUVMQaGEgYj9Tq6iEmiuMpGZmc1y2GN 3ZfsORpchX1VEXLAcoRSnJIE2uBLOimld11T+lziXQbfRKa0Eo4fxjd6IBqU3OKu6aQe emHLK/p9eKe8l6QoC3WKZvsAsUyhYIo9zKWbQsYpDKzWm6NXZIN2koultpENBSgn3sXt w+kl2Cbwm78CyXnb1Kra+hRz/AsB/V2diXSecTuDAD8ifKv4Fh3WlGiVmi6sDu9lVeR/ LtWxkCboSq5L6wkgZQinRfLn6cpUqt3rhF/G7HTtq1DhSJeqLdPP0tBNWsVSuNJN02DV 9YaA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w6si8208956edv.360.2020.08.15.17.35.18; Sat, 15 Aug 2020 17:35:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726582AbgHOVt5 (ORCPT + 99 others); Sat, 15 Aug 2020 17:49:57 -0400 Received: from asavdk4.altibox.net ([109.247.116.15]:48008 "EHLO asavdk4.altibox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726135AbgHOVt4 (ORCPT ); Sat, 15 Aug 2020 17:49:56 -0400 Received: from ravnborg.org (unknown [188.228.123.71]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by asavdk4.altibox.net (Postfix) with ESMTPS id 86FA780539; Sat, 15 Aug 2020 12:02:31 +0200 (CEST) Date: Sat, 15 Aug 2020 12:02:30 +0200 From: Sam Ravnborg To: Guido =?iso-8859-1?Q?G=FCnther?= Cc: Thierry Reding , David Airlie , Daniel Vetter , Rob Herring , Arnd Bergmann , Linus Walleij , Heiko Stuebner , Daniel Palmer , Lubomir Rintel , Mark Brown , Kuninori Morimoto , allen , Mauro Carvalho Chehab , "David S. Miller" , dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/3] drm/panel: Add panel driver for the Mantix MLAF057WE51-X DSI panel Message-ID: <20200815100230.GA1002374@ravnborg.org> References: <0a7539135cc46eec5636ca89f52695f4a1197841.1597412076.git.agx@sigxcpu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <0a7539135cc46eec5636ca89f52695f4a1197841.1597412076.git.agx@sigxcpu.org> X-CMAE-Score: 0 X-CMAE-Analysis: v=2.3 cv=aP3eV41m c=1 sm=1 tr=0 a=S6zTFyMACwkrwXSdXUNehg==:117 a=S6zTFyMACwkrwXSdXUNehg==:17 a=8nJEP1OIZ-IA:10 a=ze386MxoAAAA:8 a=e5mUnYsNAAAA:8 a=2VR2e5HfQ1QhP8mth8gA:9 a=wPNLvfGTeEIA:10 a=iBZjaW-pnkserzjvUTHh:22 a=Vxmtnl_E_bksehYqCbjh:22 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Guido. > +static int mantix_probe(struct mipi_dsi_device *dsi) > +{ > + struct device *dev = &dsi->dev; > + struct mantix *ctx; > + int ret; > + > + ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); > + if (!ctx) > + return -ENOMEM; > + > + ctx->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); > + if (IS_ERR(ctx->reset_gpio)) { > + DRM_DEV_ERROR(dev, "cannot get reset gpio\n"); > + return PTR_ERR(ctx->reset_gpio); > + } > + > + mipi_dsi_set_drvdata(dsi, ctx); > + ctx->dev = dev; > + > + dsi->lanes = 4; > + dsi->format = MIPI_DSI_FMT_RGB888; > + dsi->mode_flags = MIPI_DSI_MODE_VIDEO | > + MIPI_DSI_MODE_VIDEO_BURST | MIPI_DSI_MODE_VIDEO_SYNC_PULSE; > + > + ctx->avdd = devm_regulator_get(dev, "avdd"); > + if (IS_ERR(ctx->avdd)) { > + ret = PTR_ERR(ctx->avdd); > + if (ret != -EPROBE_DEFER) > + DRM_DEV_ERROR(dev, > + "Failed to request avdd regulator: %d\n", > + ret); > + return ret; > + } Consider to use the recently added dev_err_probe() here and below. Note: Not part of drm-misc-next yet - but hopefully after -rc1 when a backmerge is done. Sam > + ctx->avee = devm_regulator_get(dev, "avee"); > + if (IS_ERR(ctx->avee)) { > + ret = PTR_ERR(ctx->avee); > + if (ret != -EPROBE_DEFER) > + DRM_DEV_ERROR(dev, > + "Failed to request avee regulator: %d\n", > + ret); > + return ret; > + } > + ctx->vddi = devm_regulator_get(dev, "vddi"); > + if (IS_ERR(ctx->vddi)) { > + ret = PTR_ERR(ctx->vddi); > + if (ret != -EPROBE_DEFER) > + DRM_DEV_ERROR(dev, > + "Failed to request vddi regulator: %d\n", > + ret); > + return ret; > + } > + > + drm_panel_init(&ctx->panel, dev, &mantix_drm_funcs, > + DRM_MODE_CONNECTOR_DSI); > + > + ret = drm_panel_of_backlight(&ctx->panel); > + if (ret) > + return ret; > + drm_panel_add(&ctx->panel); > + > + ret = mipi_dsi_attach(dsi); > + if (ret < 0) { > + DRM_DEV_ERROR(dev, > + "mipi_dsi_attach failed (%d). Is host ready?\n", > + ret); > + drm_panel_remove(&ctx->panel); > + return ret; > + } > + > + DRM_DEV_INFO(dev, "%ux%u@%u %ubpp dsi %udl - ready\n", > + default_mode.hdisplay, default_mode.vdisplay, > + drm_mode_vrefresh(&default_mode), > + mipi_dsi_pixel_format_to_bpp(dsi->format), dsi->lanes); > + > + return 0; > +} > + > +static void mantix_shutdown(struct mipi_dsi_device *dsi) > +{ > + struct mantix *ctx = mipi_dsi_get_drvdata(dsi); > + int ret; > + > + ret = drm_panel_unprepare(&ctx->panel); > + if (ret < 0) > + DRM_DEV_ERROR(&dsi->dev, "Failed to unprepare panel: %d\n", > + ret); > + > + ret = drm_panel_disable(&ctx->panel); > + if (ret < 0) > + DRM_DEV_ERROR(&dsi->dev, "Failed to disable panel: %d\n", > + ret); > +} > + > +static int mantix_remove(struct mipi_dsi_device *dsi) > +{ > + struct mantix *ctx = mipi_dsi_get_drvdata(dsi); > + int ret; > + > + mantix_shutdown(dsi); > + > + ret = mipi_dsi_detach(dsi); > + if (ret < 0) > + DRM_DEV_ERROR(&dsi->dev, "Failed to detach from DSI host: %d\n", > + ret); > + > + drm_panel_remove(&ctx->panel); > + > + return 0; > +} > + > +static const struct of_device_id mantix_of_match[] = { > + { .compatible = "mantix,mlaf057we51-x" }, > + { /* sentinel */ } > +}; > +MODULE_DEVICE_TABLE(of, mantix_of_match); > + > +static struct mipi_dsi_driver mantix_driver = { > + .probe = mantix_probe, > + .remove = mantix_remove, > + .shutdown = mantix_shutdown, > + .driver = { > + .name = DRV_NAME, > + .of_match_table = mantix_of_match, > + }, > +}; > +module_mipi_dsi_driver(mantix_driver); > + > +MODULE_AUTHOR("Guido G?nther "); > +MODULE_DESCRIPTION("DRM driver for Mantix MLAF057WE51-X MIPI DSI panel"); > +MODULE_LICENSE("GPL v2"); > -- > 2.26.2 > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel