Commit 2e120abc authored by Liu Ying's avatar Liu Ying Committed by Jason Liu

MLK-16207-1 drm/bridge: it6263: Add gpio reset support

A low pulse whose width is at least 40ms on pin SYSRSTN
may reset the bridge, according to the chip maker.
This patch adds gpio reset support for the bridge.
Signed-off-by: default avatarLiu Ying <victor.liu@nxp.com>
parent c4b13cdc
......@@ -10,6 +10,7 @@ Required properties:
Optional properties:
- split-mode: boolean. if this exists, split mode is enabled,
otherwise, single mode is enabled.
- reset-gpios: OF device-tree gpio specification for SYSRSTN pin.
[1]: Documentation/devicetree/bindings/media/video-interfaces.txt
......
......@@ -16,6 +16,7 @@
#include <drm/drm_atomic_helper.h>
#include <drm/drm_crtc_helper.h>
#include <drm/drm_edid.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/regmap.h>
......@@ -314,6 +315,7 @@ struct it6263 {
struct regmap *lvds_regmap;
struct drm_bridge bridge;
struct drm_connector connector;
struct gpio_desc *reset_gpio;
bool is_hdmi;
bool split_mode;
};
......@@ -340,6 +342,29 @@ static inline void hdmi_update_bits(struct it6263 *it6263, unsigned int reg,
regmap_update_bits(it6263->hdmi_regmap, reg, mask, val);
}
static void it6263_reset(struct it6263 *it6263)
{
if (!it6263->reset_gpio)
return;
gpiod_set_value_cansleep(it6263->reset_gpio, 0);
usleep_range(1000, 2000);
gpiod_set_value_cansleep(it6263->reset_gpio, 1);
/*
* The chip maker says the low pulse should be at least 40ms,
* so 41ms is sure to be enough.
*/
usleep_range(41000, 45000);
gpiod_set_value_cansleep(it6263->reset_gpio, 0);
/* somehow, addtional time to wait the high voltage to be stable */
usleep_range(5000, 6000);
}
static enum drm_connector_status
it6263_connector_detect(struct drm_connector *connector, bool force)
{
......@@ -782,6 +807,19 @@ static int it6263_probe(struct i2c_client *client,
goto unregister_lvds_i2c;
}
it6263->reset_gpio = devm_gpiod_get_optional(dev, "reset",
GPIOD_OUT_LOW);
if (IS_ERR(it6263->reset_gpio)) {
ret = PTR_ERR(it6263->reset_gpio);
if (ret != -EPROBE_DEFER)
dev_err(dev, "Failed to get reset gpio: %d\n", ret);
goto unregister_lvds_i2c;
}
it6263_reset(it6263);
ret = regmap_write(it6263->hdmi_regmap, HDMI_REG_SW_RST, HDMI_RST_ALL);
if (ret)
goto unregister_lvds_i2c;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment