mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 19:08:57 +09:00
drm/bridge: maxim-max96745: Add extcon support
Signed-off-by: Wyon Bi <bivvy.bi@rock-chips.com> Change-Id: I3efe31517b2da16531b4afa7884247d6ce54504e
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/extcon-provider.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/regmap.h>
|
||||
#include <linux/gpio/consumer.h>
|
||||
@@ -36,10 +37,16 @@ struct max96745_bridge {
|
||||
int irq;
|
||||
atomic_t triggered;
|
||||
} lock;
|
||||
struct extcon_dev *extcon;
|
||||
};
|
||||
|
||||
#define to_max96745_bridge(x) container_of(x, struct max96745_bridge, x)
|
||||
|
||||
static const unsigned int max96745_bridge_cable[] = {
|
||||
EXTCON_JACK_VIDEO_OUT,
|
||||
EXTCON_NONE,
|
||||
};
|
||||
|
||||
static int max96745_bridge_connector_get_modes(struct drm_connector *connector)
|
||||
{
|
||||
struct max96745_bridge *ser = to_max96745_bridge(connector);
|
||||
@@ -128,9 +135,11 @@ static int max96745_bridge_attach(struct drm_bridge *bridge,
|
||||
|
||||
if (max96745_bridge_link_locked(ser)) {
|
||||
connector->status = connector_status_connected;
|
||||
extcon_set_state(ser->extcon, EXTCON_JACK_VIDEO_OUT, true);
|
||||
enable_irq(ser->lock.irq);
|
||||
} else {
|
||||
connector->status = connector_status_disconnected;
|
||||
extcon_set_state(ser->extcon, EXTCON_JACK_VIDEO_OUT, false);
|
||||
}
|
||||
|
||||
drm_connector_attach_encoder(connector, bridge->encoder);
|
||||
@@ -156,6 +165,8 @@ static void max96745_bridge_enable(struct drm_bridge *bridge)
|
||||
if (ser->panel)
|
||||
drm_panel_enable(ser->panel);
|
||||
|
||||
extcon_set_state_sync(ser->extcon, EXTCON_JACK_VIDEO_OUT, true);
|
||||
|
||||
enable_irq(ser->lock.irq);
|
||||
}
|
||||
|
||||
@@ -165,6 +176,8 @@ static void max96745_bridge_disable(struct drm_bridge *bridge)
|
||||
|
||||
disable_irq(ser->lock.irq);
|
||||
|
||||
extcon_set_state_sync(ser->extcon, EXTCON_JACK_VIDEO_OUT, false);
|
||||
|
||||
if (ser->panel)
|
||||
drm_panel_disable(ser->panel);
|
||||
|
||||
@@ -246,6 +259,16 @@ static int max96745_bridge_probe(struct platform_device *pdev)
|
||||
return dev_err_probe(dev, PTR_ERR(ser->lock.gpio),
|
||||
"failed to get lock GPIO\n");
|
||||
|
||||
ser->extcon = devm_extcon_dev_allocate(dev, max96745_bridge_cable);
|
||||
if (IS_ERR(ser->extcon))
|
||||
return dev_err_probe(dev, PTR_ERR(ser->extcon),
|
||||
"failed to allocate extcon device\n");
|
||||
|
||||
ret = devm_extcon_dev_register(dev, ser->extcon);
|
||||
if (ret)
|
||||
return dev_err_probe(dev, ret,
|
||||
"failed to register extcon device\n");
|
||||
|
||||
regmap_update_bits(ser->regmap, 0x7070, MAX_LANE_COUNT,
|
||||
FIELD_PREP(MAX_LANE_COUNT, 0x04));
|
||||
regmap_update_bits(ser->regmap, 0x7074, MAX_LINK_RATE,
|
||||
|
||||
Reference in New Issue
Block a user