From: Jeremy Thorpe Date: Thu, 2 May 2013 17:36:07 +0000 (-0700) Subject: CHROMIUM: drm/anx7808: Add cable detection IRQ. X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Flinux.git;a=commitdiff_plain;h=0674b271e938c07e793123df65f4f99f1226f413 CHROMIUM: drm/anx7808: Add cable detection IRQ. Adds a function that detects when the cable is inserted. BUG=chrome-os-partner:16196 TEST=Run on spring with verbose logging, plug in cable, and observe "Detected cable insertion." in the logs. Change-Id: I9a79e8755b6d4e402bf90d0f355b83762c270969 Signed-off-by: Jeremy Thorpe Reviewed-on: https://gerrit.chromium.org/gerrit/48757 --- diff --git a/drivers/gpu/drm/bridge/anx7808.c b/drivers/gpu/drm/bridge/anx7808.c index d994116dc0e4..cd999eeed218 100644 --- a/drivers/gpu/drm/bridge/anx7808.c +++ b/drivers/gpu/drm/bridge/anx7808.c @@ -32,6 +32,7 @@ struct anx7808_data { int reset_gpio; int intp_gpio; int cable_det_gpio; + int cable_det_irq; struct regulator *vdd_mydp; struct i2c_client *tx_p0; struct i2c_client *tx_p1; @@ -139,6 +140,13 @@ static int anx7808_chip_located(struct anx7808_data *anx7808) return 0; } +static irqreturn_t anx7808_cable_det_isr(int irq, void *data) +{ + DRM_INFO("Detected cable insertion.\n"); + + return IRQ_HANDLED; +} + static void anx7808_free_gpios(struct anx7808_data *anx7808) { gpio_free(anx7808->cable_det_gpio); @@ -273,6 +281,23 @@ static int anx7808_probe(struct i2c_client *client, if (ret) goto err_i2c; + anx7808->cable_det_irq = gpio_to_irq(anx7808->cable_det_gpio); + if (anx7808->cable_det_irq < 0) { + DRM_ERROR("Failed to get irq: %d\n", anx7808->cable_det_irq); + goto err_i2c; + } + + ret = devm_request_irq(&client->dev, + anx7808->cable_det_irq, + anx7808_cable_det_isr, + IRQF_TRIGGER_RISING, + "anx7808_cable_det", + anx7808); + if (ret < 0) { + DRM_ERROR("Failed to request irq: %d\n", ret); + goto err_i2c; + } + DRM_INFO("ANX7808 initialization successful.\n"); return 0;