Lines Matching +full:static +full:- +full:enable
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2015-2016 Free Electrons
4 * Copyright (C) 2015-2016 NextThing Co
6 * Maxime Ripard <maxime.ripard@free-electrons.com>
34 struct gpio_desc *enable; member
37 static inline struct simple_bridge *
43 static inline struct simple_bridge *
49 static int simple_bridge_get_modes(struct drm_connector *connector) in simple_bridge_get_modes()
55 if (sbridge->next_bridge->ops & DRM_BRIDGE_OP_EDID) { in simple_bridge_get_modes()
56 edid = drm_bridge_get_edid(sbridge->next_bridge, connector); in simple_bridge_get_modes()
81 static const struct drm_connector_helper_funcs simple_bridge_con_helper_funcs = {
85 static enum drm_connector_status
90 return drm_bridge_detect(sbridge->next_bridge); in simple_bridge_connector_detect()
93 static const struct drm_connector_funcs simple_bridge_con_funcs = {
102 static int simple_bridge_attach(struct drm_bridge *bridge, in simple_bridge_attach()
108 ret = drm_bridge_attach(bridge->encoder, sbridge->next_bridge, bridge, in simple_bridge_attach()
116 if (!bridge->encoder) { in simple_bridge_attach()
118 return -ENODEV; in simple_bridge_attach()
121 drm_connector_helper_add(&sbridge->connector, in simple_bridge_attach()
123 ret = drm_connector_init_with_ddc(bridge->dev, &sbridge->connector, in simple_bridge_attach()
125 sbridge->info->connector_type, in simple_bridge_attach()
126 sbridge->next_bridge->ddc); in simple_bridge_attach()
132 drm_connector_attach_encoder(&sbridge->connector, bridge->encoder); in simple_bridge_attach()
137 static void simple_bridge_enable(struct drm_bridge *bridge) in simple_bridge_enable()
142 if (sbridge->vdd) { in simple_bridge_enable()
143 ret = regulator_enable(sbridge->vdd); in simple_bridge_enable()
145 DRM_ERROR("Failed to enable vdd regulator: %d\n", ret); in simple_bridge_enable()
148 gpiod_set_value_cansleep(sbridge->enable, 1); in simple_bridge_enable()
151 static void simple_bridge_disable(struct drm_bridge *bridge) in simple_bridge_disable()
155 gpiod_set_value_cansleep(sbridge->enable, 0); in simple_bridge_disable()
157 if (sbridge->vdd) in simple_bridge_disable()
158 regulator_disable(sbridge->vdd); in simple_bridge_disable()
161 static const struct drm_bridge_funcs simple_bridge_bridge_funcs = {
163 .enable = simple_bridge_enable,
167 static int simple_bridge_probe(struct platform_device *pdev) in simple_bridge_probe()
172 sbridge = devm_kzalloc(&pdev->dev, sizeof(*sbridge), GFP_KERNEL); in simple_bridge_probe()
174 return -ENOMEM; in simple_bridge_probe()
177 sbridge->info = of_device_get_match_data(&pdev->dev); in simple_bridge_probe()
180 remote = of_graph_get_remote_node(pdev->dev.of_node, 1, -1); in simple_bridge_probe()
182 return -EINVAL; in simple_bridge_probe()
184 sbridge->next_bridge = of_drm_find_bridge(remote); in simple_bridge_probe()
187 if (!sbridge->next_bridge) { in simple_bridge_probe()
188 dev_dbg(&pdev->dev, "Next bridge not found, deferring probe\n"); in simple_bridge_probe()
189 return -EPROBE_DEFER; in simple_bridge_probe()
193 sbridge->vdd = devm_regulator_get_optional(&pdev->dev, "vdd"); in simple_bridge_probe()
194 if (IS_ERR(sbridge->vdd)) { in simple_bridge_probe()
195 int ret = PTR_ERR(sbridge->vdd); in simple_bridge_probe()
196 if (ret == -EPROBE_DEFER) in simple_bridge_probe()
197 return -EPROBE_DEFER; in simple_bridge_probe()
198 sbridge->vdd = NULL; in simple_bridge_probe()
199 dev_dbg(&pdev->dev, "No vdd regulator found: %d\n", ret); in simple_bridge_probe()
202 sbridge->enable = devm_gpiod_get_optional(&pdev->dev, "enable", in simple_bridge_probe()
204 if (IS_ERR(sbridge->enable)) { in simple_bridge_probe()
205 if (PTR_ERR(sbridge->enable) != -EPROBE_DEFER) in simple_bridge_probe()
206 dev_err(&pdev->dev, "Unable to retrieve enable GPIO\n"); in simple_bridge_probe()
207 return PTR_ERR(sbridge->enable); in simple_bridge_probe()
211 sbridge->bridge.funcs = &simple_bridge_bridge_funcs; in simple_bridge_probe()
212 sbridge->bridge.of_node = pdev->dev.of_node; in simple_bridge_probe()
213 sbridge->bridge.timings = sbridge->info->timings; in simple_bridge_probe()
215 drm_bridge_add(&sbridge->bridge); in simple_bridge_probe()
220 static int simple_bridge_remove(struct platform_device *pdev) in simple_bridge_remove()
224 drm_bridge_remove(&sbridge->bridge); in simple_bridge_remove()
235 static const struct drm_bridge_timings default_bridge_timings = {
246 static const struct drm_bridge_timings ti_ths8134_bridge_timings = {
259 static const struct drm_bridge_timings ti_ths8135_bridge_timings = {
267 static const struct of_device_id simple_bridge_match[] = {
269 .compatible = "dumb-vga-dac",
301 static struct platform_driver simple_bridge_driver = {
305 .name = "simple-bridge",
311 MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com>");