2 * Copyright (c) 2016 Google, Inc
3 * Written by Simon Glass <sjg@chromium.org>
5 * SPDX-License-Identifier: GPL-2.0+
13 #include <power/regulator.h>
15 DECLARE_GLOBAL_DATA_PTR
;
17 struct simple_panel_priv
{
19 struct udevice
*backlight
;
20 struct gpio_desc enable
;
23 static int simple_panel_enable_backlight(struct udevice
*dev
)
25 struct simple_panel_priv
*priv
= dev_get_priv(dev
);
28 dm_gpio_set_value(&priv
->enable
, 1);
29 ret
= backlight_enable(priv
->backlight
);
36 static int simple_panel_ofdata_to_platdata(struct udevice
*dev
)
38 struct simple_panel_priv
*priv
= dev_get_priv(dev
);
41 ret
= uclass_get_device_by_phandle(UCLASS_REGULATOR
, dev
,
42 "power-supply", &priv
->reg
);
44 debug("%s: Warning: cnnot get power supply: ret=%d\n",
49 ret
= uclass_get_device_by_phandle(UCLASS_PANEL_BACKLIGHT
, dev
,
50 "backlight", &priv
->backlight
);
52 debug("%s: Cannot get backlight: ret=%d\n", __func__
, ret
);
55 ret
= gpio_request_by_name(dev
, "enable-gpios", 0, &priv
->enable
,
58 debug("%s: Warning: cannot get enable GPIO: ret=%d\n",
67 static int simple_panel_probe(struct udevice
*dev
)
69 struct simple_panel_priv
*priv
= dev_get_priv(dev
);
73 debug("%s: Enable regulator '%s'\n", __func__
, priv
->reg
->name
);
74 ret
= regulator_set_enable(priv
->reg
, true);
82 static const struct panel_ops simple_panel_ops
= {
83 .enable_backlight
= simple_panel_enable_backlight
,
86 static const struct udevice_id simple_panel_ids
[] = {
87 { .compatible
= "simple-panel" },
91 U_BOOT_DRIVER(simple_panel
) = {
92 .name
= "simple_panel",
94 .of_match
= simple_panel_ids
,
95 .ops
= &simple_panel_ops
,
96 .ofdata_to_platdata
= simple_panel_ofdata_to_platdata
,
97 .probe
= simple_panel_probe
,
98 .priv_auto_alloc_size
= sizeof(struct simple_panel_priv
),