From patchwork Fri Aug 19 21:55:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 9291219 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0B29E600CB for ; Fri, 19 Aug 2016 21:58:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE924295B4 for ; Fri, 19 Aug 2016 21:58:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D3895295BA; Fri, 19 Aug 2016 21:58:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 918EF295B4 for ; Fri, 19 Aug 2016 21:58:19 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1barno-0001I9-7m; Fri, 19 Aug 2016 21:58:12 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1barm9-0000Rx-Nv; Fri, 19 Aug 2016 21:56:32 +0000 Received: by mail-wm0-x243.google.com with SMTP id i5so4928507wmg.2; Fri, 19 Aug 2016 14:56:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FG4vy6hKbEZafUQ5URjp0iFGHVCIMGQpSvBMtUyViyc=; b=unkN0MoUfeQO9ZHUn+KQaL6INdOlP+oIx1j6zqg7TMGjs+C2EHaKguVGa0Qzvxi14e SooaXvtQ6+XpIbJlF0D/cjxiWB3Aew7gkayAgPoJQpscAguRsQPb4sFGJfhz0XaEFQmp 46FVfXpwL5pOeSfrF45HAx4HW1optT3ICryTqxxI1iSAWKs2GrBYQxAUH/q5rD4EAjRf zK6aRnRKDMJ7l6O4YNY+3ab6Q4LowNUKNCNaYJGjlloJyliqemg4uO+qPGqsO6jetWdK FBbUOKAWy+ehV5TLf2W9WH8YAGemUeM59ZNeZTgylhmMRk6doYN9efyw3c39hiFqB5UM qqBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FG4vy6hKbEZafUQ5URjp0iFGHVCIMGQpSvBMtUyViyc=; b=dQbC79dIGcY4hwH+64p6BrnxDeB2WOyt62tadJeyxdsyfxVYOYoel+XECRBOt/FCWM WaV61+pvQbeFD9mEaz4tGJ6/VGuBmTLQCgzc7T7ftkAg2tHMx9wAjjsUegQ3wyGqoWmA BcTK99m04oUYSe/plrCTQz2lBm2hhLeZTxAxnMUFZ36TE0iY57hCxoBlbdFys1RmQK5q y0Qi2tYLZmyBEG1/W9zB0hTuBSIM8TsyEW5GoQifq/5rZZqzcDPQzWQ8JZwCZosbkb7E 1rZzMgSpGHiL9+l/oxgOmSPGn/dazpemEwAOwJD5GP1stjIu/5ktKbg6PSuAQsEJ138c vBlg== X-Gm-Message-State: AEkoouvpvICOndgghUhFCZjWJXLC4AKFSw2iZm+czeIGVmpC/LMwjgF51U7SMg1meW2Ljw== X-Received: by 10.194.120.129 with SMTP id lc1mr7957563wjb.131.1471643769342; Fri, 19 Aug 2016 14:56:09 -0700 (PDT) Received: from blackbox.darklights.net (p5DE388BA.dip0.t-ipconnect.de. [93.227.136.186]) by smtp.googlemail.com with ESMTPSA id i3sm8841702wjd.31.2016.08.19.14.56.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Aug 2016 14:56:08 -0700 (PDT) From: Martin Blumenstingl To: linux-media@vger.kernel.org, linux-gpio@vger.kernel.org, linux-amlogic@lists.infradead.org, devicetree@vger.kernel.org, narmstrong@baylibre.com, khilman@baylibre.com, carlo@caione.org Subject: [PATCH v4 4/6] media: rc: meson-ir: Add support for newer versions of the IR decoder Date: Fri, 19 Aug 2016 23:55:45 +0200 Message-Id: <20160819215547.20063-5-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20160819215547.20063-1-martin.blumenstingl@googlemail.com> References: <20160628191802.21227-1-martin.blumenstingl@googlemail.com> <20160819215547.20063-1-martin.blumenstingl@googlemail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160819_145630_155130_D2E8DD66 X-CRM114-Status: GOOD ( 13.00 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, Martin Blumenstingl , catalin.marinas@arm.com, linus.walleij@linaro.org, will.deacon@arm.com, robh+dt@kernel.org, mchehab@kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Neil Armstrong Newer SoCs (Meson 8b and GXBB) are using REG2 (offset 0x20) instead of REG1 to configure the decoder mode. This makes it necessary to introduce new bindings so the driver knows which register has to be used. Signed-off-by: Neil Armstrong Signed-off-by: Martin Blumenstingl Acked-by: Kevin Hilman Acked-by: Mauro Carvalho Chehab --- drivers/media/rc/meson-ir.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/drivers/media/rc/meson-ir.c b/drivers/media/rc/meson-ir.c index fcc3b82..003fff0 100644 --- a/drivers/media/rc/meson-ir.c +++ b/drivers/media/rc/meson-ir.c @@ -24,6 +24,7 @@ #define DRIVER_NAME "meson-ir" +/* valid on all Meson platforms */ #define IR_DEC_LDR_ACTIVE 0x00 #define IR_DEC_LDR_IDLE 0x04 #define IR_DEC_LDR_REPEAT 0x08 @@ -32,12 +33,21 @@ #define IR_DEC_FRAME 0x14 #define IR_DEC_STATUS 0x18 #define IR_DEC_REG1 0x1c +/* only available on Meson 8b and newer */ +#define IR_DEC_REG2 0x20 #define REG0_RATE_MASK (BIT(11) - 1) -#define REG1_MODE_MASK (BIT(7) | BIT(8)) -#define REG1_MODE_NEC (0 << 7) -#define REG1_MODE_GENERAL (2 << 7) +#define DECODE_MODE_NEC 0x0 +#define DECODE_MODE_RAW 0x2 + +/* Meson 6b uses REG1 to configure the mode */ +#define REG1_MODE_MASK GENMASK(8, 7) +#define REG1_MODE_SHIFT 7 + +/* Meson 8b / GXBB use REG2 to configure the mode */ +#define REG2_MODE_MASK GENMASK(3, 0) +#define REG2_MODE_SHIFT 0 #define REG1_TIME_IV_SHIFT 16 #define REG1_TIME_IV_MASK ((BIT(13) - 1) << REG1_TIME_IV_SHIFT) @@ -158,8 +168,15 @@ static int meson_ir_probe(struct platform_device *pdev) /* Reset the decoder */ meson_ir_set_mask(ir, IR_DEC_REG1, REG1_RESET, REG1_RESET); meson_ir_set_mask(ir, IR_DEC_REG1, REG1_RESET, 0); - /* Set general operation mode */ - meson_ir_set_mask(ir, IR_DEC_REG1, REG1_MODE_MASK, REG1_MODE_GENERAL); + + /* Set general operation mode (= raw/software decoding) */ + if (of_device_is_compatible(node, "amlogic,meson6-ir")) + meson_ir_set_mask(ir, IR_DEC_REG1, REG1_MODE_MASK, + DECODE_MODE_RAW << REG1_MODE_SHIFT); + else + meson_ir_set_mask(ir, IR_DEC_REG2, REG2_MODE_MASK, + DECODE_MODE_RAW << REG2_MODE_SHIFT); + /* Set rate */ meson_ir_set_mask(ir, IR_DEC_REG0, REG0_RATE_MASK, MESON_TRATE - 1); /* IRQ on rising and falling edges */ @@ -197,6 +214,8 @@ static int meson_ir_remove(struct platform_device *pdev) static const struct of_device_id meson_ir_match[] = { { .compatible = "amlogic,meson6-ir" }, + { .compatible = "amlogic,meson8b-ir" }, + { .compatible = "amlogic,meson-gxbb-ir" }, { }, };