From patchwork Tue Feb 9 16:40:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Hecht X-Patchwork-Id: 8263841 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-renesas-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AE381BEEE5 for ; Tue, 9 Feb 2016 16:40:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D22A820221 for ; Tue, 9 Feb 2016 16:40:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 057092014A for ; Tue, 9 Feb 2016 16:40:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932804AbcBIQkb (ORCPT ); Tue, 9 Feb 2016 11:40:31 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:32872 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932197AbcBIQk3 (ORCPT ); Tue, 9 Feb 2016 11:40:29 -0500 Received: by mail-wm0-f66.google.com with SMTP id c200so4477281wme.0; Tue, 09 Feb 2016 08:40:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=i4su9W5RqMkXaQcniwbbWAbxez2+mdeXjE3ELsCczvM=; b=gRl6VgysBGFP1g8oWOPUWLVgqYmSKaZFCxVwlI5KdsoVglQgoM2KyQ98a7+pzh7pmJ FdoKvI/sKEXw4fktqvbobRHCHa0da6iT3ggAwE4UCEUwIH4+SUYZMJJA//viG8bfY4/b WG7nBFNg75196fkxByS+sLimJiaa7LpCpr92KbJLlzy8ZAYPHc0QuvWyYhH2XEW9euHk FfVfl7B9BEJFLwdwGOurWfuBFaJVtmBjx6gNbJeO6WpZ0eZ8iYAP6IJuteDekSDO63fG Gac+sRrwV5Vqqj971nQYFO+BHcMVSeyKAC6yN3e6xlmf265fZooa1ZG5/g3iQkWCaxwU 8toQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=i4su9W5RqMkXaQcniwbbWAbxez2+mdeXjE3ELsCczvM=; b=RC6mVEhs7tKyHtkDAs41NVHvolXOrIgWpLgVjwSPAS8nwCD8w2ndCwlYfebnoX89nk euQUTqsnONsAMSbo3OdiQJnYUVbD4tcwNdxl4XxRryCUPfakddeza1cfFfNC8PrIMe3u nzkkIJ9pl5ugzv0MBrX5upZ3Q0CpDM1RrK7fi9iMOrUf8qWdBmX8SofD3KQl24oaZImL it1z5SJ4gYCGR4SRtm4BtTmxd4K0P7tU37hcO3IyFtFeOI9x3YWvm1EFnBV8tdEJwjB2 qB5ccCN6897656deJYkH3JLcXI91iCJmr78dQZxpDM2x+3L82fn0zri8t6I9RShI+ACY eBEw== X-Gm-Message-State: AG10YOTmA/1NQOiefPTuedDx8S8nA9REcfIJH9mjytXBPpo1u4DJRa7Vd/m2E2hCR0y3Hg== X-Received: by 10.28.50.137 with SMTP id y131mr6277253wmy.102.1455036027761; Tue, 09 Feb 2016 08:40:27 -0800 (PST) Received: from groucho.site (ip9234e209.dynamic.kabel-deutschland.de. [146.52.226.9]) by smtp.gmail.com with ESMTPSA id b203sm18309025wmh.8.2016.02.09.08.40.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Feb 2016 08:40:24 -0800 (PST) From: Ulrich Hecht To: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org Cc: magnus.damm@gmail.com, laurent.pinchart@ideasonboard.com, hans.verkuil@cisco.com, ian.molton@codethink.co.uk, lars@metafoo.de, william.towle@codethink.co.uk, sergei.shtylyov@cogentembedded.com, Ulrich Hecht Subject: [PATCH v4] adv7604: add direct interrupt handling Date: Tue, 9 Feb 2016 17:40:19 +0100 Message-Id: <1455036019-7066-1-git-send-email-ulrich.hecht+renesas@gmail.com> X-Mailer: git-send-email 2.6.4 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When probed from device tree, the i2c client driver can handle the interrupt on its own. Signed-off-by: Ulrich Hecht Reviewed-by: Laurent Pinchart --- v4: As suggested by Hans and Lars-Peter, this revision attempts to parse the interrupts node to determine polarity, and passes the appropriate flags to devm_request_threaded_irq(). v3: uses IRQ_RETVAL v2: implements the suggested style changes and drops the IRQF_TRIGGER_LOW flag, which is handled in the device tree. drivers/media/i2c/adv7604.c | 50 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c index 66dbe86..2a1ae6d 100644 --- a/drivers/media/i2c/adv7604.c +++ b/drivers/media/i2c/adv7604.c @@ -31,6 +31,8 @@ #include #include #include +#include +#include #include #include #include @@ -1971,6 +1973,16 @@ static int adv76xx_isr(struct v4l2_subdev *sd, u32 status, bool *handled) return 0; } +static irqreturn_t adv76xx_irq_handler(int irq, void *devid) +{ + struct adv76xx_state *state = devid; + bool handled; + + adv76xx_isr(&state->sd, 0, &handled); + + return IRQ_RETVAL(handled); +} + static int adv76xx_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid) { struct adv76xx_state *state = to_state(sd); @@ -2799,6 +2811,7 @@ static int adv76xx_parse_dt(struct adv76xx_state *state) struct device_node *endpoint; struct device_node *np; unsigned int flags; + u32 irq[2]; u32 v= -1; np = state->i2c_clients[ADV76XX_PAGE_IO]->dev.of_node; @@ -2844,8 +2857,20 @@ static int adv76xx_parse_dt(struct adv76xx_state *state) state->pdata.op_656_range = 1; } - /* Disable the interrupt for now as no DT-based board uses it. */ state->pdata.int1_config = ADV76XX_INT1_CONFIG_DISABLED; + if (!of_property_read_u32_array(np, "interrupts", irq, 2)) { + switch (irq[1]) { + case IRQ_TYPE_LEVEL_LOW: + state->pdata.int1_config = ADV76XX_INT1_CONFIG_ACTIVE_LOW; + break; + case IRQ_TYPE_LEVEL_HIGH: + state->pdata.int1_config = ADV76XX_INT1_CONFIG_ACTIVE_HIGH; + break; + default: + WARN(1, "Unsupported interrupt configuration."); + break; + } + } /* Use the default I2C addresses. */ state->pdata.i2c_addresses[ADV7604_PAGE_AVLINK] = 0x42; @@ -3235,6 +3260,29 @@ static int adv76xx_probe(struct i2c_client *client, v4l2_info(sd, "%s found @ 0x%x (%s)\n", client->name, client->addr << 1, client->adapter->name); + if (client->irq) { + unsigned long flags = IRQF_ONESHOT; + + switch (state->pdata.int1_config) { + case ADV76XX_INT1_CONFIG_ACTIVE_LOW: + flags |= IRQF_TRIGGER_LOW; + break; + case ADV76XX_INT1_CONFIG_ACTIVE_HIGH: + flags |= IRQF_TRIGGER_HIGH; + break; + default: + break; + } + + err = devm_request_threaded_irq(&client->dev, + client->irq, + NULL, adv76xx_irq_handler, + flags, + dev_name(&client->dev), state); + if (err) + goto err_entity; + } + err = v4l2_async_register_subdev(sd); if (err) goto err_entity;