CHROMIUM: drm/anx7808: Add cable detection IRQ.
[cascardo/linux.git] / 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;