2019-06-25 19:26:54

by Bartosz Golaszewski

[permalink] [raw]
Subject: [PATCH 00/12] ARM: davinci: da850-evm: remove more legacy GPIO calls

From: Bartosz Golaszewski <[email protected]>

This is another small step on the path to liberating davinci from legacy
GPIO API calls and shrinking the davinci GPIO driver by not having to
support the base GPIO number anymore.

This time we're removing the legacy calls used indirectly by the LCDC
fbdev driver.

The first three patches modify the GPIO backlight driver. The first
of them adds the necessary functionality, the other two are just
tweaks and cleanups.

Next two patches enable the GPIO backlight driver in
davinci_all_defconfig.

Patch 6/12 models the backlight GPIO as an actual GPIO backlight device.

Patches 7-9 extend the fbdev driver with regulator support and convert
the da850-evm board file to using it.

Last three patches are improvements to the da8xx fbdev driver since
we're already touching it in this series.

Bartosz Golaszewski (12):
backlight: gpio: allow to probe non-pdata devices from board files
backlight: gpio: use a helper variable for &pdev->dev
backlight: gpio: pull the non-pdata device probing code into probe()
ARM: davinci: refresh davinci_all_defconfig
ARM: davinci_all_defconfig: enable GPIO backlight
ARM: davinci: da850-evm: model the backlight GPIO as an actual device
fbdev: da8xx: add support for a regulator
ARM: davinci: da850-evm: switch to using a fixed regulator for lcdc
fbdev: da8xx: remove panel_power_ctrl() callback from platform data
fbdev: da8xx-fb: use devm_platform_ioremap_resource()
fbdev: da8xx-fb: drop a redundant if
fbdev: da8xx: use resource management for dma

arch/arm/configs/davinci_all_defconfig | 28 +++---
arch/arm/mach-davinci/board-da850-evm.c | 90 ++++++++++++-----
drivers/video/backlight/gpio_backlight.c | 67 +++++--------
drivers/video/fbdev/da8xx-fb.c | 118 +++++++++++++----------
include/video/da8xx-fb.h | 1 -
5 files changed, 165 insertions(+), 139 deletions(-)

--
2.21.0


2019-06-25 19:27:02

by Bartosz Golaszewski

[permalink] [raw]
Subject: [PATCH 05/12] ARM: davinci_all_defconfig: enable GPIO backlight

From: Bartosz Golaszewski <[email protected]>

Enable the GPIO backlight module in davinci_all_defconfig.

Signed-off-by: Bartosz Golaszewski <[email protected]>
---
arch/arm/configs/davinci_all_defconfig | 1 +
1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/davinci_all_defconfig b/arch/arm/configs/davinci_all_defconfig
index 13d7846c613d..06855b2bce7e 100644
--- a/arch/arm/configs/davinci_all_defconfig
+++ b/arch/arm/configs/davinci_all_defconfig
@@ -158,6 +158,7 @@ CONFIG_FB=y
CONFIG_FIRMWARE_EDID=y
CONFIG_FB_DA8XX=y
CONFIG_BACKLIGHT_PWM=m
+CONFIG_BACKLIGHT_GPIO=m
CONFIG_FRAMEBUFFER_CONSOLE=y
CONFIG_LOGO=y
CONFIG_SOUND=m
--
2.21.0

2019-06-25 19:27:21

by Bartosz Golaszewski

[permalink] [raw]
Subject: [PATCH 01/12] backlight: gpio: allow to probe non-pdata devices from board files

From: Bartosz Golaszewski <[email protected]>

Currently we can only probe devices that either use device tree or pass
platform data to probe(). Rename gpio_backlight_probe_dt() to
gpio_backlight_probe_prop() and use generic device properties instead
of OF specific helpers. Reverse the logic checking the presence of
platform data in probe(). This way we can probe devices() registered
from machine code that neither have a DT node nor use platform data.

Signed-off-by: Bartosz Golaszewski <[email protected]>
---
drivers/video/backlight/gpio_backlight.c | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c
index b9300f3e1ee6..654c19d3a81d 100644
--- a/drivers/video/backlight/gpio_backlight.c
+++ b/drivers/video/backlight/gpio_backlight.c
@@ -54,15 +54,14 @@ static const struct backlight_ops gpio_backlight_ops = {
.check_fb = gpio_backlight_check_fb,
};

-static int gpio_backlight_probe_dt(struct platform_device *pdev,
- struct gpio_backlight *gbl)
+static int gpio_backlight_probe_prop(struct platform_device *pdev,
+ struct gpio_backlight *gbl)
{
struct device *dev = &pdev->dev;
- struct device_node *np = dev->of_node;
enum gpiod_flags flags;
int ret;

- gbl->def_value = of_property_read_bool(np, "default-on");
+ gbl->def_value = device_property_read_bool(dev, "default-on");
flags = gbl->def_value ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW;

gbl->gpiod = devm_gpiod_get(dev, NULL, flags);
@@ -86,26 +85,15 @@ static int gpio_backlight_probe(struct platform_device *pdev)
struct backlight_properties props;
struct backlight_device *bl;
struct gpio_backlight *gbl;
- struct device_node *np = pdev->dev.of_node;
int ret;

- if (!pdata && !np) {
- dev_err(&pdev->dev,
- "failed to find platform data or device tree node.\n");
- return -ENODEV;
- }
-
gbl = devm_kzalloc(&pdev->dev, sizeof(*gbl), GFP_KERNEL);
if (gbl == NULL)
return -ENOMEM;

gbl->dev = &pdev->dev;

- if (np) {
- ret = gpio_backlight_probe_dt(pdev, gbl);
- if (ret)
- return ret;
- } else {
+ if (pdata) {
/*
* Legacy platform data GPIO retrieveal. Do not expand
* the use of this code path, currently only used by one
@@ -126,6 +114,10 @@ static int gpio_backlight_probe(struct platform_device *pdev)
gbl->gpiod = gpio_to_desc(pdata->gpio);
if (!gbl->gpiod)
return -EINVAL;
+ } else {
+ ret = gpio_backlight_probe_prop(pdev, gbl);
+ if (ret)
+ return ret;
}

memset(&props, 0, sizeof(props));
--
2.21.0

2019-06-25 19:28:10

by Bartosz Golaszewski

[permalink] [raw]
Subject: [PATCH 11/12] fbdev: da8xx-fb: drop a redundant if

From: Bartosz Golaszewski <[email protected]>

The driver data is always set in probe. The remove() callback won't be
called if probe failed which is the only way for it to be NULL. Remove
the redundant if.

Signed-off-by: Bartosz Golaszewski <[email protected]>
---
drivers/video/fbdev/da8xx-fb.c | 43 ++++++++++++++++------------------
1 file changed, 20 insertions(+), 23 deletions(-)

diff --git a/drivers/video/fbdev/da8xx-fb.c b/drivers/video/fbdev/da8xx-fb.c
index 4dda194d6b8f..6b11a8108108 100644
--- a/drivers/video/fbdev/da8xx-fb.c
+++ b/drivers/video/fbdev/da8xx-fb.c
@@ -1067,37 +1067,34 @@ 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);
+ struct da8xx_fb_par *par = info->par;
int ret;

- if (info) {
- struct da8xx_fb_par *par = info->par;
-
#ifdef CONFIG_CPU_FREQ
- lcd_da8xx_cpufreq_deregister(par);
+ lcd_da8xx_cpufreq_deregister(par);
#endif
- if (par->lcd_supply) {
- ret = regulator_disable(par->lcd_supply);
- if (ret)
- return ret;
- }
+ 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);
+ lcd_disable_raster(DA8XX_FRAME_WAIT);
+ lcdc_write(0, LCD_RASTER_CTRL_REG);

- /* disable DMA */
- lcdc_write(0, LCD_DMA_CTRL_REG);
+ /* disable DMA */
+ lcdc_write(0, LCD_DMA_CTRL_REG);

- unregister_framebuffer(info);
- fb_dealloc_cmap(&info->cmap);
- dma_free_coherent(par->dev, PALETTE_SIZE, par->v_palette_base,
- par->p_palette_base);
- dma_free_coherent(par->dev, par->vram_size, par->vram_virt,
- par->vram_phys);
- pm_runtime_put_sync(&dev->dev);
- pm_runtime_disable(&dev->dev);
- framebuffer_release(info);
+ unregister_framebuffer(info);
+ fb_dealloc_cmap(&info->cmap);
+ dma_free_coherent(par->dev, PALETTE_SIZE, par->v_palette_base,
+ par->p_palette_base);
+ dma_free_coherent(par->dev, par->vram_size, par->vram_virt,
+ par->vram_phys);
+ pm_runtime_put_sync(&dev->dev);
+ pm_runtime_disable(&dev->dev);
+ framebuffer_release(info);

- }
return 0;
}

--
2.21.0

2019-06-25 19:28:10

by Bartosz Golaszewski

[permalink] [raw]
Subject: [PATCH 10/12] fbdev: da8xx-fb: use devm_platform_ioremap_resource()

From: Bartosz Golaszewski <[email protected]>

Shrink the code a bit by using the new helper wrapping the calls to
platform_get_resource() and devm_ioremap_resource() together.

Signed-off-by: Bartosz Golaszewski <[email protected]>
---
drivers/video/fbdev/da8xx-fb.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/video/fbdev/da8xx-fb.c b/drivers/video/fbdev/da8xx-fb.c
index 328de29c4933..4dda194d6b8f 100644
--- a/drivers/video/fbdev/da8xx-fb.c
+++ b/drivers/video/fbdev/da8xx-fb.c
@@ -1339,7 +1339,6 @@ static int fb_probe(struct platform_device *device)
{
struct da8xx_lcdc_platform_data *fb_pdata =
dev_get_platdata(&device->dev);
- struct resource *lcdc_regs;
struct lcd_ctrl_config *lcd_cfg;
struct fb_videomode *lcdc_info;
struct fb_info *da8xx_fb_info;
@@ -1357,8 +1356,7 @@ static int fb_probe(struct platform_device *device)
if (lcdc_info == NULL)
return -ENODEV;

- lcdc_regs = platform_get_resource(device, IORESOURCE_MEM, 0);
- da8xx_fb_reg_base = devm_ioremap_resource(&device->dev, lcdc_regs);
+ da8xx_fb_reg_base = devm_platform_ioremap_resource(device, 0);
if (IS_ERR(da8xx_fb_reg_base))
return PTR_ERR(da8xx_fb_reg_base);

--
2.21.0

2019-06-25 19:28:39

by Bartosz Golaszewski

[permalink] [raw]
Subject: [PATCH 08/12] ARM: davinci: da850-evm: switch to using a fixed regulator for lcdc

From: Bartosz Golaszewski <[email protected]>

Now that the da8xx fbdev driver supports power control with an actual
regulator, switch to using a fixed power supply for da850-evm.

Signed-off-by: Bartosz Golaszewski <[email protected]>
---
arch/arm/mach-davinci/board-da850-evm.c | 62 ++++++++++++++++++-------
1 file changed, 44 insertions(+), 18 deletions(-)

diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c
index ffda623bb543..d26950f605f4 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -802,12 +802,6 @@ static const short da850_evm_mmcsd0_pins[] __initconst = {
-1
};

-static void da850_panel_power_ctrl(int val)
-{
- /* lcd power */
- gpio_set_value(DA850_LCD_PWR_PIN, val);
-}
-
static struct property_entry da850_lcd_backlight_props[] = {
PROPERTY_ENTRY_BOOL("default-on"),
{ }
@@ -827,28 +821,61 @@ static const struct platform_device_info da850_lcd_backlight_info = {
.properties = da850_lcd_backlight_props,
};

+static struct regulator_consumer_supply da850_lcd_supplies[] = {
+ REGULATOR_SUPPLY("lcd", NULL),
+};
+
+static struct regulator_init_data da850_lcd_supply_data = {
+ .consumer_supplies = da850_lcd_supplies,
+ .num_consumer_supplies = ARRAY_SIZE(da850_lcd_supplies),
+ .constraints = {
+ .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+ },
+};
+
+static struct fixed_voltage_config da850_lcd_supply = {
+ .supply_name = "lcd",
+ .microvolts = 33000000,
+ .init_data = &da850_lcd_supply_data,
+};
+
+static struct platform_device da850_lcd_supply_device = {
+ .name = "reg-fixed-voltage",
+ .id = 1, /* Dummy fixed regulator is 0 */
+ .dev = {
+ .platform_data = &da850_lcd_supply,
+ },
+};
+
+static struct gpiod_lookup_table da850_lcd_supply_gpio_table = {
+ .dev_id = "reg-fixed-voltage.1",
+ .table = {
+ GPIO_LOOKUP("davinci_gpio", DA850_LCD_PWR_PIN, NULL, 0),
+ { }
+ },
+};
+
+static struct gpiod_lookup_table *da850_lcd_gpio_lookups[] = {
+ &da850_lcd_backlight_gpio_table,
+ &da850_lcd_supply_gpio_table,
+};
+
static int da850_lcd_hw_init(void)
{
struct platform_device *backlight;
int status;

- gpiod_add_lookup_table(&da850_lcd_backlight_gpio_table);
+ gpiod_add_lookup_tables(da850_lcd_gpio_lookups,
+ ARRAY_SIZE(da850_lcd_gpio_lookups));
+
backlight = platform_device_register_full(&da850_lcd_backlight_info);
if (IS_ERR(backlight))
return PTR_ERR(backlight);

- status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr");
- if (status < 0)
+ status = platform_device_register(&da850_lcd_supply_device);
+ if (status)
return status;

- gpio_direction_output(DA850_LCD_PWR_PIN, 0);
-
- /* Switch off panel power */
- da850_panel_power_ctrl(0);
-
- /* Switch on panel power */
- da850_panel_power_ctrl(1);
-
return 0;
}

@@ -1458,7 +1485,6 @@ static __init void da850_evm_init(void)
if (ret)
pr_warn("%s: LCD initialization failed: %d\n", __func__, ret);

- sharp_lk043t1dg01_pdata.panel_power_ctrl = da850_panel_power_ctrl,
ret = da8xx_register_lcdc(&sharp_lk043t1dg01_pdata);
if (ret)
pr_warn("%s: LCDC registration failed: %d\n", __func__, ret);
--
2.21.0

2019-06-25 19:28:44

by Bartosz Golaszewski

[permalink] [raw]
Subject: [PATCH 09/12] fbdev: da8xx: remove panel_power_ctrl() callback from platform data

From: Bartosz Golaszewski <[email protected]>

There are no more users of panel_power_ctrl(). Remove it from the
driver.

Signed-off-by: Bartosz Golaszewski <[email protected]>
---
drivers/video/fbdev/da8xx-fb.c | 25 +++++--------------------
include/video/da8xx-fb.h | 1 -
2 files changed, 5 insertions(+), 21 deletions(-)

diff --git a/drivers/video/fbdev/da8xx-fb.c b/drivers/video/fbdev/da8xx-fb.c
index 4fa99ff79f3b..328de29c4933 100644
--- a/drivers/video/fbdev/da8xx-fb.c
+++ b/drivers/video/fbdev/da8xx-fb.c
@@ -165,7 +165,6 @@ struct da8xx_fb_par {
struct notifier_block freq_transition;
#endif
unsigned int lcdc_clk_rate;
- void (*panel_power_ctrl)(int);
struct regulator *lcd_supply;
u32 pseudo_palette[16];
struct fb_videomode mode;
@@ -1076,9 +1075,7 @@ static int fb_remove(struct platform_device *dev)
#ifdef CONFIG_CPU_FREQ
lcd_da8xx_cpufreq_deregister(par);
#endif
- if (par->panel_power_ctrl) {
- par->panel_power_ctrl(0);
- } else if (par->lcd_supply) {
+ if (par->lcd_supply) {
ret = regulator_disable(par->lcd_supply);
if (ret)
return ret;
@@ -1187,9 +1184,7 @@ static int cfb_blank(int blank, struct fb_info *info)
case FB_BLANK_UNBLANK:
lcd_enable_raster();

- if (par->panel_power_ctrl) {
- par->panel_power_ctrl(1);
- } else if (par->lcd_supply) {
+ if (par->lcd_supply) {
ret = regulator_enable(par->lcd_supply);
if (ret)
return ret;
@@ -1199,9 +1194,7 @@ static int cfb_blank(int blank, struct fb_info *info)
case FB_BLANK_VSYNC_SUSPEND:
case FB_BLANK_HSYNC_SUSPEND:
case FB_BLANK_POWERDOWN:
- if (par->panel_power_ctrl) {
- par->panel_power_ctrl(0);
- } else if (par->lcd_supply) {
+ if (par->lcd_supply) {
ret = regulator_disable(par->lcd_supply);
if (ret)
return ret;
@@ -1414,10 +1407,6 @@ static int fb_probe(struct platform_device *device)
par->dev = &device->dev;
par->lcdc_clk = tmp_lcdc_clk;
par->lcdc_clk_rate = clk_get_rate(par->lcdc_clk);
- if (fb_pdata->panel_power_ctrl) {
- par->panel_power_ctrl = fb_pdata->panel_power_ctrl;
- par->panel_power_ctrl(1);
- }

par->lcd_supply = devm_regulator_get_optional(&device->dev, "lcd");
if (IS_ERR(par->lcd_supply)) {
@@ -1639,9 +1628,7 @@ static int fb_suspend(struct device *dev)
int ret;

console_lock();
- if (par->panel_power_ctrl) {
- par->panel_power_ctrl(0);
- } else if (par->lcd_supply) {
+ if (par->lcd_supply) {
ret = regulator_disable(par->lcd_supply);
if (ret)
return ret;
@@ -1667,9 +1654,7 @@ static int fb_resume(struct device *dev)
if (par->blank == FB_BLANK_UNBLANK) {
lcd_enable_raster();

- if (par->panel_power_ctrl) {
- par->panel_power_ctrl(1);
- } else if (par->lcd_supply) {
+ if (par->lcd_supply) {
ret = regulator_enable(par->lcd_supply);
if (ret)
return ret;
diff --git a/include/video/da8xx-fb.h b/include/video/da8xx-fb.h
index efed3c3383d6..1d19ae62b844 100644
--- a/include/video/da8xx-fb.h
+++ b/include/video/da8xx-fb.h
@@ -32,7 +32,6 @@ struct da8xx_lcdc_platform_data {
const char manu_name[10];
void *controller_data;
const char type[25];
- void (*panel_power_ctrl)(int);
};

struct lcd_ctrl_config {
--
2.21.0

2019-06-25 19:28:58

by Bartosz Golaszewski

[permalink] [raw]
Subject: [PATCH 07/12] fbdev: da8xx: add support for a regulator

From: Bartosz Golaszewski <[email protected]>

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 <[email protected]>
---
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 9ea817ac1d81..4fa99ff79f3b 100644
--- a/drivers/video/fbdev/da8xx-fb.c
+++ b/drivers/video/fbdev/da8xx-fb.c
@@ -19,6 +19,7 @@
#include <linux/clk.h>
#include <linux/cpufreq.h>
#include <linux/console.h>
+#include <linux/regulator/consumer.h>
#include <linux/spinlock.h>
#include <linux/slab.h>
#include <linux/delay.h>
@@ -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;
@@ -1401,6 +1419,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;

@@ -1604,10 +1636,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);
@@ -1621,6 +1659,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);
@@ -1628,8 +1667,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

2019-06-25 19:28:59

by Bartosz Golaszewski

[permalink] [raw]
Subject: [PATCH 12/12] fbdev: da8xx: use resource management for dma

From: Bartosz Golaszewski <[email protected]>

Use managed variants of dma alloc functions in the da8xx fbdev driver.

Signed-off-by: Bartosz Golaszewski <[email protected]>
---
drivers/video/fbdev/da8xx-fb.c | 32 ++++++++++----------------------
1 file changed, 10 insertions(+), 22 deletions(-)

diff --git a/drivers/video/fbdev/da8xx-fb.c b/drivers/video/fbdev/da8xx-fb.c
index 6b11a8108108..22f79b3c2326 100644
--- a/drivers/video/fbdev/da8xx-fb.c
+++ b/drivers/video/fbdev/da8xx-fb.c
@@ -1087,10 +1087,6 @@ static int fb_remove(struct platform_device *dev)

unregister_framebuffer(info);
fb_dealloc_cmap(&info->cmap);
- dma_free_coherent(par->dev, PALETTE_SIZE, par->v_palette_base,
- par->p_palette_base);
- dma_free_coherent(par->dev, par->vram_size, par->vram_virt,
- par->vram_phys);
pm_runtime_put_sync(&dev->dev);
pm_runtime_disable(&dev->dev);
framebuffer_release(info);
@@ -1428,10 +1424,10 @@ static int fb_probe(struct platform_device *device)
par->vram_size = roundup(par->vram_size/8, ulcm);
par->vram_size = par->vram_size * LCD_NUM_BUFFERS;

- par->vram_virt = dma_alloc_coherent(par->dev,
- par->vram_size,
- &par->vram_phys,
- GFP_KERNEL | GFP_DMA);
+ par->vram_virt = dmam_alloc_coherent(par->dev,
+ par->vram_size,
+ &par->vram_phys,
+ GFP_KERNEL | GFP_DMA);
if (!par->vram_virt) {
dev_err(&device->dev,
"GLCD: kmalloc for frame buffer failed\n");
@@ -1449,20 +1445,20 @@ static int fb_probe(struct platform_device *device)
da8xx_fb_fix.line_length - 1;

/* allocate palette buffer */
- par->v_palette_base = dma_alloc_coherent(par->dev, PALETTE_SIZE,
- &par->p_palette_base,
- GFP_KERNEL | GFP_DMA);
+ par->v_palette_base = dmam_alloc_coherent(par->dev, PALETTE_SIZE,
+ &par->p_palette_base,
+ GFP_KERNEL | GFP_DMA);
if (!par->v_palette_base) {
dev_err(&device->dev,
"GLCD: kmalloc for palette buffer failed\n");
ret = -EINVAL;
- goto err_release_fb_mem;
+ goto err_release_fb;
}

par->irq = platform_get_irq(device, 0);
if (par->irq < 0) {
ret = -ENOENT;
- goto err_release_pl_mem;
+ goto err_release_fb;
}

da8xx_fb_var.grayscale =
@@ -1480,7 +1476,7 @@ static int fb_probe(struct platform_device *device)

ret = fb_alloc_cmap(&da8xx_fb_info->cmap, PALETTE_SIZE, 0);
if (ret)
- goto err_release_pl_mem;
+ goto err_release_fb;
da8xx_fb_info->cmap.len = par->palette_sz;

/* initialize var_screeninfo */
@@ -1534,14 +1530,6 @@ static int fb_probe(struct platform_device *device)
err_dealloc_cmap:
fb_dealloc_cmap(&da8xx_fb_info->cmap);

-err_release_pl_mem:
- dma_free_coherent(par->dev, PALETTE_SIZE, par->v_palette_base,
- par->p_palette_base);
-
-err_release_fb_mem:
- dma_free_coherent(par->dev, par->vram_size, par->vram_virt,
- par->vram_phys);
-
err_release_fb:
framebuffer_release(da8xx_fb_info);

--
2.21.0

2019-06-25 19:30:16

by Bartosz Golaszewski

[permalink] [raw]
Subject: [PATCH 03/12] backlight: gpio: pull the non-pdata device probing code into probe()

From: Bartosz Golaszewski <[email protected]>

There's no good reason to have the generic probing code in a separate
routine. This function is short and is inlined by the compiler anyway.
Move it into probe under the pdata-specific part.

Signed-off-by: Bartosz Golaszewski <[email protected]>
---
drivers/video/backlight/gpio_backlight.c | 39 ++++++++----------------
1 file changed, 13 insertions(+), 26 deletions(-)

diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c
index 8adbc8d75097..89e10bccfd3c 100644
--- a/drivers/video/backlight/gpio_backlight.c
+++ b/drivers/video/backlight/gpio_backlight.c
@@ -54,30 +54,6 @@ static const struct backlight_ops gpio_backlight_ops = {
.check_fb = gpio_backlight_check_fb,
};

-static int gpio_backlight_probe_prop(struct platform_device *pdev,
- struct gpio_backlight *gbl)
-{
- struct device *dev = &pdev->dev;
- enum gpiod_flags flags;
- int ret;
-
- gbl->def_value = device_property_read_bool(dev, "default-on");
- flags = gbl->def_value ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW;
-
- gbl->gpiod = devm_gpiod_get(dev, NULL, flags);
- if (IS_ERR(gbl->gpiod)) {
- ret = PTR_ERR(gbl->gpiod);
-
- if (ret != -EPROBE_DEFER) {
- dev_err(dev,
- "Error: The gpios parameter is missing or invalid.\n");
- }
- return ret;
- }
-
- return 0;
-}
-
static int gpio_backlight_probe(struct platform_device *pdev)
{
struct gpio_backlight_platform_data *pdata =
@@ -86,6 +62,7 @@ static int gpio_backlight_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct backlight_device *bl;
struct gpio_backlight *gbl;
+ enum gpiod_flags flags;
int ret;

gbl = devm_kzalloc(dev, sizeof(*gbl), GFP_KERNEL);
@@ -116,9 +93,19 @@ static int gpio_backlight_probe(struct platform_device *pdev)
if (!gbl->gpiod)
return -EINVAL;
} else {
- ret = gpio_backlight_probe_prop(pdev, gbl);
- if (ret)
+ gbl->def_value = device_property_read_bool(dev, "default-on");
+ flags = gbl->def_value ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW;
+
+ gbl->gpiod = devm_gpiod_get(dev, NULL, flags);
+ if (IS_ERR(gbl->gpiod)) {
+ ret = PTR_ERR(gbl->gpiod);
+
+ if (ret != -EPROBE_DEFER) {
+ dev_err(dev,
+ "Error: The gpios parameter is missing or invalid.\n");
+ }
return ret;
+ }
}

memset(&props, 0, sizeof(props));
--
2.21.0

2019-06-25 19:31:02

by Bartosz Golaszewski

[permalink] [raw]
Subject: [PATCH 06/12] ARM: davinci: da850-evm: model the backlight GPIO as an actual device

From: Bartosz Golaszewski <[email protected]>

Instead of enabling the panel backlight in a callback defined in board
file using deprecated legacy GPIO API calls, model the line as a GPIO
backlight device.

Signed-off-by: Bartosz Golaszewski <[email protected]>
---
arch/arm/mach-davinci/board-da850-evm.c | 40 +++++++++++++++++--------
1 file changed, 28 insertions(+), 12 deletions(-)

diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c
index 31ae3be5741d..ffda623bb543 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -36,6 +36,7 @@
#include <linux/platform_data/ti-aemif.h>
#include <linux/platform_data/spi-davinci.h>
#include <linux/platform_data/uio_pruss.h>
+#include <linux/property.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/tps6507x.h>
#include <linux/regulator/fixed.h>
@@ -803,34 +804,49 @@ static const short da850_evm_mmcsd0_pins[] __initconst = {

static void da850_panel_power_ctrl(int val)
{
- /* lcd backlight */
- gpio_set_value(DA850_LCD_BL_PIN, val);
-
/* lcd power */
gpio_set_value(DA850_LCD_PWR_PIN, val);
}

+static struct property_entry da850_lcd_backlight_props[] = {
+ PROPERTY_ENTRY_BOOL("default-on"),
+ { }
+};
+
+static struct gpiod_lookup_table da850_lcd_backlight_gpio_table = {
+ .dev_id = "gpio-backlight",
+ .table = {
+ GPIO_LOOKUP("davinci_gpio", DA850_LCD_BL_PIN, NULL, 0),
+ { }
+ },
+};
+
+static const struct platform_device_info da850_lcd_backlight_info = {
+ .name = "gpio-backlight",
+ .id = PLATFORM_DEVID_NONE,
+ .properties = da850_lcd_backlight_props,
+};
+
static int da850_lcd_hw_init(void)
{
+ struct platform_device *backlight;
int status;

- status = gpio_request(DA850_LCD_BL_PIN, "lcd bl");
- if (status < 0)
- return status;
+ gpiod_add_lookup_table(&da850_lcd_backlight_gpio_table);
+ backlight = platform_device_register_full(&da850_lcd_backlight_info);
+ if (IS_ERR(backlight))
+ return PTR_ERR(backlight);

status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr");
- if (status < 0) {
- gpio_free(DA850_LCD_BL_PIN);
+ if (status < 0)
return status;
- }

- gpio_direction_output(DA850_LCD_BL_PIN, 0);
gpio_direction_output(DA850_LCD_PWR_PIN, 0);

- /* Switch off panel power and backlight */
+ /* Switch off panel power */
da850_panel_power_ctrl(0);

- /* Switch on panel power and backlight */
+ /* Switch on panel power */
da850_panel_power_ctrl(1);

return 0;
--
2.21.0

2019-06-27 11:15:58

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH 03/12] backlight: gpio: pull the non-pdata device probing code into probe()

On Tue, Jun 25, 2019 at 5:34 PM Bartosz Golaszewski <[email protected]> wrote:

> From: Bartosz Golaszewski <[email protected]>
>
> There's no good reason to have the generic probing code in a separate
> routine. This function is short and is inlined by the compiler anyway.
> Move it into probe under the pdata-specific part.
>
> Signed-off-by: Bartosz Golaszewski <[email protected]>

Reviewed-by: Linus Walleij <[email protected]>

Yours,
Linus Walleij

2019-06-27 11:18:06

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH 06/12] ARM: davinci: da850-evm: model the backlight GPIO as an actual device

On Tue, Jun 25, 2019 at 5:34 PM Bartosz Golaszewski <[email protected]> wrote:

> From: Bartosz Golaszewski <[email protected]>
>
> Instead of enabling the panel backlight in a callback defined in board
> file using deprecated legacy GPIO API calls, model the line as a GPIO
> backlight device.
>
> Signed-off-by: Bartosz Golaszewski <[email protected]>

Reviewed-by: Linus Walleij <[email protected]>

Yours,
Linus Walleij

2019-06-27 11:19:33

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH 08/12] ARM: davinci: da850-evm: switch to using a fixed regulator for lcdc

On Tue, Jun 25, 2019 at 5:35 PM Bartosz Golaszewski <[email protected]> wrote:

> From: Bartosz Golaszewski <[email protected]>
>
> Now that the da8xx fbdev driver supports power control with an actual
> regulator, switch to using a fixed power supply for da850-evm.
>
> Signed-off-by: Bartosz Golaszewski <[email protected]>

Reviewed-by: Linus Walleij <[email protected]>

Yours,
Linus Walleij

Subject: Re: [PATCH 01/12] backlight: gpio: allow to probe non-pdata devices from board files


On 6/25/19 6:34 PM, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <[email protected]>
>
> Currently we can only probe devices that either use device tree or pass
> platform data to probe(). Rename gpio_backlight_probe_dt() to
> gpio_backlight_probe_prop() and use generic device properties instead
> of OF specific helpers. Reverse the logic checking the presence of
> platform data in probe(). This way we can probe devices() registered
> from machine code that neither have a DT node nor use platform data.
>
> Signed-off-by: Bartosz Golaszewski <[email protected]>

Reviewed-by: Bartlomiej Zolnierkiewicz <[email protected]>

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

Subject: Re: [PATCH 03/12] backlight: gpio: pull the non-pdata device probing code into probe()


On 6/25/19 6:34 PM, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <[email protected]>
>
> There's no good reason to have the generic probing code in a separate
> routine. This function is short and is inlined by the compiler anyway.
> Move it into probe under the pdata-specific part.
>
> Signed-off-by: Bartosz Golaszewski <[email protected]>

Reviewed-by: Bartlomiej Zolnierkiewicz <[email protected]>

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

Subject: Re: [PATCH 07/12] fbdev: da8xx: add support for a regulator


On 6/25/19 6:34 PM, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <[email protected]>
>
> 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 <[email protected]>

Acked-by: Bartlomiej Zolnierkiewicz <[email protected]>

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

Subject: Re: [PATCH 09/12] fbdev: da8xx: remove panel_power_ctrl() callback from platform data


On 6/25/19 6:34 PM, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <[email protected]>
>
> There are no more users of panel_power_ctrl(). Remove it from the
> driver.
>
> Signed-off-by: Bartosz Golaszewski <[email protected]>

Acked-by: Bartlomiej Zolnierkiewicz <[email protected]>

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

Subject: Re: [PATCH 10/12] fbdev: da8xx-fb: use devm_platform_ioremap_resource()


On 6/25/19 6:34 PM, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <[email protected]>
>
> Shrink the code a bit by using the new helper wrapping the calls to
> platform_get_resource() and devm_ioremap_resource() together.
>
> Signed-off-by: Bartosz Golaszewski <[email protected]>

Acked-by: Bartlomiej Zolnierkiewicz <[email protected]>

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

Subject: Re: [PATCH 12/12] fbdev: da8xx: use resource management for dma


On 6/25/19 6:34 PM, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <[email protected]>
>
> Use managed variants of dma alloc functions in the da8xx fbdev driver.
>
> Signed-off-by: Bartosz Golaszewski <[email protected]>

Acked-by: Bartlomiej Zolnierkiewicz <[email protected]>

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

Subject: Re: [PATCH 11/12] fbdev: da8xx-fb: drop a redundant if


On 6/25/19 6:34 PM, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <[email protected]>
>
> The driver data is always set in probe. The remove() callback won't be
> called if probe failed which is the only way for it to be NULL. Remove
> the redundant if.
>
> Signed-off-by: Bartosz Golaszewski <[email protected]>

Acked-by: Bartlomiej Zolnierkiewicz <[email protected]>

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

2019-07-01 15:34:45

by Sekhar Nori

[permalink] [raw]
Subject: Re: [PATCH 00/12] ARM: davinci: da850-evm: remove more legacy GPIO calls

Hi Lee, Daniel, Jingoo,

On 25/06/19 10:04 PM, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <[email protected]>
>
> This is another small step on the path to liberating davinci from legacy
> GPIO API calls and shrinking the davinci GPIO driver by not having to
> support the base GPIO number anymore.
>
> This time we're removing the legacy calls used indirectly by the LCDC
> fbdev driver.
>
> The first three patches modify the GPIO backlight driver. The first
> of them adds the necessary functionality, the other two are just
> tweaks and cleanups.

Can you take the first three patches for v5.3 - if its not too late? I
think that will make it easy for rest of patches to make into subsequent
kernel releases.

>
> Next two patches enable the GPIO backlight driver in
> davinci_all_defconfig.
>
> Patch 6/12 models the backlight GPIO as an actual GPIO backlight device.
>
> Patches 7-9 extend the fbdev driver with regulator support and convert
> the da850-evm board file to using it.
>
> Last three patches are improvements to the da8xx fbdev driver since
> we're already touching it in this series.

Thanks,
Sekhar

2019-07-02 06:37:32

by Lee Jones

[permalink] [raw]
Subject: Re: [PATCH 00/12] ARM: davinci: da850-evm: remove more legacy GPIO calls

On Mon, 01 Jul 2019, Sekhar Nori wrote:

> Hi Lee, Daniel, Jingoo,
>
> On 25/06/19 10:04 PM, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <[email protected]>
> >
> > This is another small step on the path to liberating davinci from legacy
> > GPIO API calls and shrinking the davinci GPIO driver by not having to
> > support the base GPIO number anymore.
> >
> > This time we're removing the legacy calls used indirectly by the LCDC
> > fbdev driver.
> >
> > The first three patches modify the GPIO backlight driver. The first
> > of them adds the necessary functionality, the other two are just
> > tweaks and cleanups.
>
> Can you take the first three patches for v5.3 - if its not too late? I
> think that will make it easy for rest of patches to make into subsequent
> kernel releases.

It's already too late in the cycle (-rc7) for that. I require patches
of this nature to have a good soak in -next before being merged. There
shouldn't be an issue with getting them into v5.4 though.

> > Next two patches enable the GPIO backlight driver in
> > davinci_all_defconfig.
> >
> > Patch 6/12 models the backlight GPIO as an actual GPIO backlight device.
> >
> > Patches 7-9 extend the fbdev driver with regulator support and convert
> > the da850-evm board file to using it.
> >
> > Last three patches are improvements to the da8xx fbdev driver since
> > we're already touching it in this series.
>
> Thanks,
> Sekhar
>

--
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

2019-07-02 09:02:45

by Daniel Thompson

[permalink] [raw]
Subject: Re: [PATCH 01/12] backlight: gpio: allow to probe non-pdata devices from board files

On 25/06/2019 17:34, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <[email protected]>
>
> Currently we can only probe devices that either use device tree or pass
> platform data to probe(). Rename gpio_backlight_probe_dt() to
> gpio_backlight_probe_prop() and use generic device properties instead
> of OF specific helpers.

This has already been done in (which IIRC did get queued for the next
release):
https://www.spinics.net/lists/dri-devel/msg215050.html

> Reverse the logic checking the presence of
> platform data in probe(). This way we can probe devices() registered
> from machine code that neither have a DT node nor use platform data.

Andy's patch did not reverse this logic... but it does check
pdev->dev.fwnode rather than of_node .


Daniel.


>
> Signed-off-by: Bartosz Golaszewski <[email protected]>
> ---
> drivers/video/backlight/gpio_backlight.c | 24 ++++++++----------------
> 1 file changed, 8 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c
> index b9300f3e1ee6..654c19d3a81d 100644
> --- a/drivers/video/backlight/gpio_backlight.c
> +++ b/drivers/video/backlight/gpio_backlight.c
> @@ -54,15 +54,14 @@ static const struct backlight_ops gpio_backlight_ops = {
> .check_fb = gpio_backlight_check_fb,
> };
>
> -static int gpio_backlight_probe_dt(struct platform_device *pdev,
> - struct gpio_backlight *gbl)
> +static int gpio_backlight_probe_prop(struct platform_device *pdev,
> + struct gpio_backlight *gbl)
> {
> struct device *dev = &pdev->dev;
> - struct device_node *np = dev->of_node;
> enum gpiod_flags flags;
> int ret;
>
> - gbl->def_value = of_property_read_bool(np, "default-on");
> + gbl->def_value = device_property_read_bool(dev, "default-on");
> flags = gbl->def_value ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW;
>
> gbl->gpiod = devm_gpiod_get(dev, NULL, flags);
> @@ -86,26 +85,15 @@ static int gpio_backlight_probe(struct platform_device *pdev)
> struct backlight_properties props;
> struct backlight_device *bl;
> struct gpio_backlight *gbl;
> - struct device_node *np = pdev->dev.of_node;
> int ret;
>
> - if (!pdata && !np) {
> - dev_err(&pdev->dev,
> - "failed to find platform data or device tree node.\n");
> - return -ENODEV;
> - }
> -
> gbl = devm_kzalloc(&pdev->dev, sizeof(*gbl), GFP_KERNEL);
> if (gbl == NULL)
> return -ENOMEM;
>
> gbl->dev = &pdev->dev;
>
> - if (np) {
> - ret = gpio_backlight_probe_dt(pdev, gbl);
> - if (ret)
> - return ret;
> - } else {
> + if (pdata) {
> /*
> * Legacy platform data GPIO retrieveal. Do not expand
> * the use of this code path, currently only used by one
> @@ -126,6 +114,10 @@ static int gpio_backlight_probe(struct platform_device *pdev)
> gbl->gpiod = gpio_to_desc(pdata->gpio);
> if (!gbl->gpiod)
> return -EINVAL;
> + } else {
> + ret = gpio_backlight_probe_prop(pdev, gbl);
> + if (ret)
> + return ret;
> }
>
> memset(&props, 0, sizeof(props));
>

2019-07-02 09:13:20

by Daniel Thompson

[permalink] [raw]
Subject: Re: [PATCH 03/12] backlight: gpio: pull the non-pdata device probing code into probe()

On 25/06/2019 17:34, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <[email protected]>
>
> There's no good reason to have the generic probing code in a separate
> routine. This function is short and is inlined by the compiler anyway.
> Move it into probe under the pdata-specific part.
>
> Signed-off-by: Bartosz Golaszewski <[email protected]>

Like the others, this will need to be respun to match latest code but
when it comes round again:
Acked-by: Daniel Thompson <[email protected]>


Daniel.


> ---
> drivers/video/backlight/gpio_backlight.c | 39 ++++++++----------------
> 1 file changed, 13 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c
> index 8adbc8d75097..89e10bccfd3c 100644
> --- a/drivers/video/backlight/gpio_backlight.c
> +++ b/drivers/video/backlight/gpio_backlight.c
> @@ -54,30 +54,6 @@ static const struct backlight_ops gpio_backlight_ops = {
> .check_fb = gpio_backlight_check_fb,
> };
>
> -static int gpio_backlight_probe_prop(struct platform_device *pdev,
> - struct gpio_backlight *gbl)
> -{
> - struct device *dev = &pdev->dev;
> - enum gpiod_flags flags;
> - int ret;
> -
> - gbl->def_value = device_property_read_bool(dev, "default-on");
> - flags = gbl->def_value ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW;
> -
> - gbl->gpiod = devm_gpiod_get(dev, NULL, flags);
> - if (IS_ERR(gbl->gpiod)) {
> - ret = PTR_ERR(gbl->gpiod);
> -
> - if (ret != -EPROBE_DEFER) {
> - dev_err(dev,
> - "Error: The gpios parameter is missing or invalid.\n");
> - }
> - return ret;
> - }
> -
> - return 0;
> -}
> -
> static int gpio_backlight_probe(struct platform_device *pdev)
> {
> struct gpio_backlight_platform_data *pdata =
> @@ -86,6 +62,7 @@ static int gpio_backlight_probe(struct platform_device *pdev)
> struct device *dev = &pdev->dev;
> struct backlight_device *bl;
> struct gpio_backlight *gbl;
> + enum gpiod_flags flags;
> int ret;
>
> gbl = devm_kzalloc(dev, sizeof(*gbl), GFP_KERNEL);
> @@ -116,9 +93,19 @@ static int gpio_backlight_probe(struct platform_device *pdev)
> if (!gbl->gpiod)
> return -EINVAL;
> } else {
> - ret = gpio_backlight_probe_prop(pdev, gbl);
> - if (ret)
> + gbl->def_value = device_property_read_bool(dev, "default-on");
> + flags = gbl->def_value ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW;
> +
> + gbl->gpiod = devm_gpiod_get(dev, NULL, flags);
> + if (IS_ERR(gbl->gpiod)) {
> + ret = PTR_ERR(gbl->gpiod);
> +
> + if (ret != -EPROBE_DEFER) {
> + dev_err(dev,
> + "Error: The gpios parameter is missing or invalid.\n");
> + }
> return ret;
> + }
> }
>
> memset(&props, 0, sizeof(props));
>

2019-07-02 10:07:46

by Daniel Thompson

[permalink] [raw]
Subject: Re: [PATCH 00/12] ARM: davinci: da850-evm: remove more legacy GPIO calls

On Tue, Jul 02, 2019 at 07:36:53AM +0100, Lee Jones wrote:
> On Mon, 01 Jul 2019, Sekhar Nori wrote:
>
> > Hi Lee, Daniel, Jingoo,
> >
> > On 25/06/19 10:04 PM, Bartosz Golaszewski wrote:
> > > From: Bartosz Golaszewski <[email protected]>
> > >
> > > This is another small step on the path to liberating davinci from legacy
> > > GPIO API calls and shrinking the davinci GPIO driver by not having to
> > > support the base GPIO number anymore.
> > >
> > > This time we're removing the legacy calls used indirectly by the LCDC
> > > fbdev driver.
> > >
> > > The first three patches modify the GPIO backlight driver. The first
> > > of them adds the necessary functionality, the other two are just
> > > tweaks and cleanups.
> >
> > Can you take the first three patches for v5.3 - if its not too late? I
> > think that will make it easy for rest of patches to make into subsequent
> > kernel releases.
>
> It's already too late in the cycle (-rc7) for that. I require patches
> of this nature to have a good soak in -next before being merged. There
> shouldn't be an issue with getting them into v5.4 though.

On the other hand I think we did take a patch that did much the same
thing as patch 1/12 in this series:
https://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight.git/commit/?h=for-backlight-next&id=98b7404eb7d64e55f8fdd419cb3965a8abf0e217

I'm not 100% sure but I think that might allow the patchset to be split
into two that are independent (one for Davinci and one for gpio
backlight improvements).


Daniel.

>
> > > Next two patches enable the GPIO backlight driver in
> > > davinci_all_defconfig.
> > >
> > > Patch 6/12 models the backlight GPIO as an actual GPIO backlight device.
> > >
> > > Patches 7-9 extend the fbdev driver with regulator support and convert
> > > the da850-evm board file to using it.
> > >
> > > Last three patches are improvements to the da8xx fbdev driver since
> > > we're already touching it in this series.
> >
> > Thanks,
> > Sekhar
> >
>
> --
> Lee Jones [李琼斯]
> Linaro Services Technical Lead
> Linaro.org │ Open source software for ARM SoCs
> Follow Linaro: Facebook | Twitter | Blog