Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7078168ybi; Mon, 22 Jul 2019 06:47:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqw7fzrecGw4BZHT9lGtbL/DQ3wZQMsRHg3Wjp17pVI1IoM7yvmkjHGSbG8GQXMunF7qwBbm X-Received: by 2002:a17:902:4401:: with SMTP id k1mr51879407pld.193.1563803235186; Mon, 22 Jul 2019 06:47:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563803235; cv=none; d=google.com; s=arc-20160816; b=Yw2N36TO+fsaFB85fFHWYy8rXbFt66QTvyo4h2Ir5PptrSfs5gNc58nRLS8xQg7J7x ZldTul7q2NG3Jpb02XkZlkjte2rbVPlxvDeWWkO72rVqEfk3xdN7o8Mhr/CHSEeJhL7H jdr9Ix1abWAxkHQPwc7dozRq9rOawpcLwH4BGcld2AJfXicmR09vytCkAnWqPGPWTVU8 9aPterjKGcreFy233qW1Uha4vExlY0WRXBPfT+3sEEXppHUkj0O38MHWUb6mtKRxn4Ov gtWtS7WmbUnUy8g5Ln6lsTwQP1yo2SEksXjGlFbSTNf27xyiz24Fs4Itdn2fnYrocBFL GY2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cl5zg39Cl4/S2kfGv0jRvRdfNEoBv9uo7wZVLIOvXqk=; b=f49OTdbBvxThjTSX1LUfWHbcUMn29gjYc9kZvAMHFoQT8hvcINxvIgUn88sHYnhrEB s60tqD6J73vxMlElQ8BIcTNLwAj/1qInKk3tFEvww9/JIpCS5ivhqbaWqEMiFFcoWT7S QasKBagQSEX3eyKecjHvO1Gmt72lTJD/RuAz2olsb/73l+qPu3qRfueSiuvgvuvNVoxW 1bab7QQ3Ie/tHZJ53kUxtjxupNCUk6KejVAGP35Y9s2qpija25SJwnLY3KnSCh9qzGV5 XIsi3Qe8sHf+V/SAzeN8Io8X84RohdjFyFHsH7P3jATzNaoTd6y0VpRbQVFmyEzxuaQw XuMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b="y+M/5Cbc"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c13si9591716pjo.75.2019.07.22.06.46.59; Mon, 22 Jul 2019 06:47:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b="y+M/5Cbc"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730721AbfGVNor (ORCPT + 99 others); Mon, 22 Jul 2019 09:44:47 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:40672 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730691AbfGVNoq (ORCPT ); Mon, 22 Jul 2019 09:44:46 -0400 Received: by mail-wm1-f65.google.com with SMTP id v19so35418103wmj.5 for ; Mon, 22 Jul 2019 06:44:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cl5zg39Cl4/S2kfGv0jRvRdfNEoBv9uo7wZVLIOvXqk=; b=y+M/5CbcGEIcdNqV/egICb8FrMGtXtBlVWgihxudOjk7jXnywoD0EJ7gf1ju1xOY5z BZ/InXQHyjacAMLVMndKUElyjiV/6aC5yi5/fAMI2Ol1F9LCRflw6BCKS5NiyKOXbQhW qPdSpM8wzu6+VaUwrYZD/0FLn9SkrGgAJRvXQ+I4Fr94EOGmKZn2xWqF5UiMHuouyDGk P2/CV86gu8IkCxYLgkutWOZuAwWlHvwIgF1UcIhVvLQD4FySvHqClk7D4IMQohdyK9Hk 5sSuBJ7k8eplpR26QtX+rE+c3SugRg55Ru+rAvcY7e06KJ7mTpLn4Z+gWgw67ELmM52D 2j1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cl5zg39Cl4/S2kfGv0jRvRdfNEoBv9uo7wZVLIOvXqk=; b=KXX+jmSQtCLLv4AwlHh8mHvgzooAMZk282NCaAhtAM1aCVU85dbIAoT8cNwycvln49 sOUtiARMJ+0AmsCAlDgWFTQBiz6tRByFFXW6a/0rmwTwMZbRE5Cz+XAN0u6f2Me+vqhw w6Ch3xDwmBs2HTKQZZf5CX7ea44U0pphjPDR00SU720mw6qmup9xCIl+eoYF8kUQ/r6F v0PHah4Vyhzz8eXluaFUw6crpcsZJxPMQEZVGOQt0uFI+1ws4srmU/k+y0k2219G6sr5 PPdBZIJWmlwqBljJq//UysAY6Vv92k+6dwWJPXs5TyHII9kJdN+ltoPjwS5QrtNxZfwj dseA== X-Gm-Message-State: APjAAAXMU9Kim4eqnZJ0ELKjH+syssNs/gWkJN0oChgsblZbgwY4u5nV FtqZrafj8wbRir1AXiYEEBs= X-Received: by 2002:a7b:c212:: with SMTP id x18mr62608436wmi.77.1563803083203; Mon, 22 Jul 2019 06:44:43 -0700 (PDT) Received: from localhost.localdomain (amontpellier-652-1-281-69.w109-210.abo.wanadoo.fr. [109.210.96.69]) by smtp.gmail.com with ESMTPSA id p6sm40652484wrq.97.2019.07.22.06.44.42 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 22 Jul 2019 06:44:42 -0700 (PDT) From: Bartosz Golaszewski To: Sekhar Nori , Kevin Hilman , Bartlomiej Zolnierkiewicz , David Lechner , Linus Walleij Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-fbdev@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 4/9] fbdev: da8xx: add support for a regulator Date: Mon, 22 Jul 2019 15:44:18 +0200 Message-Id: <20190722134423.26555-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190722134423.26555-1-brgl@bgdev.pl> References: <20190722134423.26555-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bartosz Golaszewski We want to remove the hacky platform data callback for power control. Add a regulator to the driver data and enable/disable it next to the current panel_power_ctrl() calls. We will use it in subsequent patch on da850-evm. Signed-off-by: Bartosz Golaszewski Acked-by: Bartlomiej Zolnierkiewicz --- drivers/video/fbdev/da8xx-fb.c | 54 ++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 5 deletions(-) diff --git a/drivers/video/fbdev/da8xx-fb.c b/drivers/video/fbdev/da8xx-fb.c index b1cf248f3291..02dfe9e32eed 100644 --- a/drivers/video/fbdev/da8xx-fb.c +++ b/drivers/video/fbdev/da8xx-fb.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -165,6 +166,7 @@ struct da8xx_fb_par { #endif unsigned int lcdc_clk_rate; void (*panel_power_ctrl)(int); + struct regulator *lcd_supply; u32 pseudo_palette[16]; struct fb_videomode mode; struct lcd_ctrl_config cfg; @@ -1066,6 +1068,7 @@ static void lcd_da8xx_cpufreq_deregister(struct da8xx_fb_par *par) static int fb_remove(struct platform_device *dev) { struct fb_info *info = dev_get_drvdata(&dev->dev); + int ret; if (info) { struct da8xx_fb_par *par = info->par; @@ -1073,8 +1076,13 @@ static int fb_remove(struct platform_device *dev) #ifdef CONFIG_CPU_FREQ lcd_da8xx_cpufreq_deregister(par); #endif - if (par->panel_power_ctrl) + if (par->panel_power_ctrl) { par->panel_power_ctrl(0); + } else if (par->lcd_supply) { + ret = regulator_disable(par->lcd_supply); + if (ret) + return ret; + } lcd_disable_raster(DA8XX_FRAME_WAIT); lcdc_write(0, LCD_RASTER_CTRL_REG); @@ -1179,15 +1187,25 @@ static int cfb_blank(int blank, struct fb_info *info) case FB_BLANK_UNBLANK: lcd_enable_raster(); - if (par->panel_power_ctrl) + if (par->panel_power_ctrl) { par->panel_power_ctrl(1); + } else if (par->lcd_supply) { + ret = regulator_enable(par->lcd_supply); + if (ret) + return ret; + } break; case FB_BLANK_NORMAL: case FB_BLANK_VSYNC_SUSPEND: case FB_BLANK_HSYNC_SUSPEND: case FB_BLANK_POWERDOWN: - if (par->panel_power_ctrl) + if (par->panel_power_ctrl) { par->panel_power_ctrl(0); + } else if (par->lcd_supply) { + ret = regulator_disable(par->lcd_supply); + if (ret) + return ret; + } lcd_disable_raster(DA8XX_FRAME_WAIT); break; @@ -1400,6 +1418,20 @@ static int fb_probe(struct platform_device *device) par->panel_power_ctrl(1); } + par->lcd_supply = devm_regulator_get_optional(&device->dev, "lcd"); + if (IS_ERR(par->lcd_supply)) { + if (PTR_ERR(par->lcd_supply) == -EPROBE_DEFER) { + ret = -EPROBE_DEFER; + goto err_pm_runtime_disable; + } + + par->lcd_supply = NULL; + } else { + ret = regulator_enable(par->lcd_supply); + if (ret) + goto err_pm_runtime_disable; + } + fb_videomode_to_var(&da8xx_fb_var, lcdc_info); par->cfg = *lcd_cfg; @@ -1603,10 +1635,16 @@ static int fb_suspend(struct device *dev) { struct fb_info *info = dev_get_drvdata(dev); struct da8xx_fb_par *par = info->par; + int ret; console_lock(); - if (par->panel_power_ctrl) + if (par->panel_power_ctrl) { par->panel_power_ctrl(0); + } else if (par->lcd_supply) { + ret = regulator_disable(par->lcd_supply); + if (ret) + return ret; + } fb_set_suspend(info, 1); lcd_disable_raster(DA8XX_FRAME_WAIT); @@ -1620,6 +1658,7 @@ static int fb_resume(struct device *dev) { struct fb_info *info = dev_get_drvdata(dev); struct da8xx_fb_par *par = info->par; + int ret; console_lock(); pm_runtime_get_sync(dev); @@ -1627,8 +1666,13 @@ static int fb_resume(struct device *dev) if (par->blank == FB_BLANK_UNBLANK) { lcd_enable_raster(); - if (par->panel_power_ctrl) + if (par->panel_power_ctrl) { par->panel_power_ctrl(1); + } else if (par->lcd_supply) { + ret = regulator_enable(par->lcd_supply); + if (ret) + return ret; + } } fb_set_suspend(info, 0); -- 2.21.0