1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2015 Google, Inc
4 * Written by Simon Glass <sjg@chromium.org>
11 #include <video_bridge.h>
13 int video_bridge_set_backlight(struct udevice
*dev
, int percent
)
15 struct video_bridge_ops
*ops
= video_bridge_get_ops(dev
);
17 if (!ops
->set_backlight
)
20 return ops
->set_backlight(dev
, percent
);
23 int video_bridge_attach(struct udevice
*dev
)
25 struct video_bridge_ops
*ops
= video_bridge_get_ops(dev
);
30 return ops
->attach(dev
);
33 int video_bridge_check_attached(struct udevice
*dev
)
35 struct video_bridge_priv
*uc_priv
= dev_get_uclass_priv(dev
);
36 struct video_bridge_ops
*ops
= video_bridge_get_ops(dev
);
39 if (!ops
->check_attached
) {
40 ret
= dm_gpio_get_value(&uc_priv
->hotplug
);
42 return ret
> 0 ? 0 : ret
== 0 ? -ENOTCONN
: ret
;
45 return ops
->check_attached(dev
);
48 int video_bridge_read_edid(struct udevice
*dev
, u8
*buf
, int buf_size
)
50 struct video_bridge_ops
*ops
= video_bridge_get_ops(dev
);
52 if (!ops
|| !ops
->read_edid
)
54 return ops
->read_edid(dev
, buf
, buf_size
);
57 static int video_bridge_pre_probe(struct udevice
*dev
)
59 struct video_bridge_priv
*uc_priv
= dev_get_uclass_priv(dev
);
62 debug("%s\n", __func__
);
63 ret
= gpio_request_by_name(dev
, "sleep-gpios", 0,
64 &uc_priv
->sleep
, GPIOD_IS_OUT
);
66 debug("%s: Could not decode sleep-gpios (%d)\n", __func__
, ret
);
71 * Drop this for now as we do not have driver model pinctrl support
73 * ret = dm_gpio_set_pull(&uc_priv->sleep, GPIO_PULL_NONE);
75 * debug("%s: Could not set sleep pull value\n", __func__);
79 ret
= gpio_request_by_name(dev
, "reset-gpios", 0, &uc_priv
->reset
,
82 debug("%s: Could not decode reset-gpios (%d)\n", __func__
, ret
);
87 * Drop this for now as we do not have driver model pinctrl support
89 * ret = dm_gpio_set_pull(&uc_priv->reset, GPIO_PULL_NONE);
91 * debug("%s: Could not set reset pull value\n", __func__);
95 ret
= gpio_request_by_name(dev
, "hotplug-gpios", 0, &uc_priv
->hotplug
,
98 debug("%s: Could not decode hotplug (%d)\n", __func__
, ret
);
106 int video_bridge_set_active(struct udevice
*dev
, bool active
)
108 struct video_bridge_priv
*uc_priv
= dev_get_uclass_priv(dev
);
111 debug("%s: %d\n", __func__
, active
);
112 ret
= dm_gpio_set_value(&uc_priv
->sleep
, !active
);
116 ret
= dm_gpio_set_value(&uc_priv
->reset
, true);
120 ret
= dm_gpio_set_value(&uc_priv
->reset
, false);
126 UCLASS_DRIVER(video_bridge
) = {
127 .id
= UCLASS_VIDEO_BRIDGE
,
128 .name
= "video_bridge",
129 .per_device_auto_alloc_size
= sizeof(struct video_bridge_priv
),
130 .pre_probe
= video_bridge_pre_probe
,