CHROMIUM: drm/anx7808: Add cable detection IRQ.
authorJeremy Thorpe <jeremyt@chromium.org>
Thu, 2 May 2013 17:36:07 +0000 (10:36 -0700)
committerChromeBot <chrome-bot@google.com>
Tue, 14 May 2013 21:18:47 +0000 (14:18 -0700)
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 <jeremyt@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48757

drivers/gpu/drm/bridge/anx7808.c

index d994116..cd999ee 100644 (file)
@@ -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;