From patchwork Sat Aug 20 09:54:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 9291687 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 91D716086A for ; Sat, 20 Aug 2016 09:56:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A309C2916A for ; Sat, 20 Aug 2016 09:56:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 973832916D; Sat, 20 Aug 2016 09:56:14 +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 4995429179 for ; Sat, 20 Aug 2016 09:56:14 +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 1bb30Z-0005ry-SU; Sat, 20 Aug 2016 09:56:07 +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 1bb2zQ-0003yt-6C; Sat, 20 Aug 2016 09:55:00 +0000 Received: by mail-wm0-x243.google.com with SMTP id i5so6280572wmg.2; Sat, 20 Aug 2016 02:54:39 -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=ZCj/PrLdmM15GKM8QavC9PSh4BsAk6eh1RvkorSdarI=; b=W/U3oJ7rnnrt9lVuX37ma5MgBH6V2a9x1ApmsXAQvP3gkR06oBRZb8DOFOT3ytfj0B dlRrMxTulvGpvKI4Qkts8MMl4PhK61LjL4T9kZf2vzHToRyrwgl4irWkr4wLf3+6K8Cf el45I37z63O14iGE9UxqIfuaBNgcX4eINJU+6BwdcSYX6X1pZiihES91NvtQQnXlxOlD te0FC8ebROgOE7kUR0DEMsCJp9yg8a21Zs/45qxmbGdAtkJVFhWqk20n0CXvbwjbLfSC bA02MB+dmpPw/b4+fqZE5oqj9acGIHbxUPZyrZJn4cDnmUNqJKT51rAuS112Iqdr8XQM kXRA== 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=ZCj/PrLdmM15GKM8QavC9PSh4BsAk6eh1RvkorSdarI=; b=SjPL7/VVk4whl8Pk3wHpnlMlgv1FfYVAM8ZdnsBOFi5kMqcgcjx0ON+0fMxfrX2f+Q pbM6WdRk1ktgia49k1Hk+G8D/DdDJ8ZAaYwr+N0mClWsaLm2f49zi6cSiGwt1Mmk5Bt4 p4i31+DcPhfOWZdReDDYTikms/6SUGjeCQIZxK4HpaEAYdy7GuyDN6pf3CHnrvlH3Yef gCBJwcVATS9W8wKp56kLyxek1W3W69pt5Vz0wWeP/wqTjgKWSyOM4bqP6k5jTmbO5ffQ VY17YkTZAqEwRE/U1pjm/hCGCuF+l64eK+05w7/DGNdgRMqQoxyNJ14j97fCPrTBbi76 lJuQ== X-Gm-Message-State: AEkoouu3LTeaaai0eU21qnLehRN+a+osMUniBBEw6+0JvXPxr4WUk7vnvUV8OJ/shBqQhw== X-Received: by 10.194.47.7 with SMTP id z7mr9984495wjm.63.1471686878248; Sat, 20 Aug 2016 02:54:38 -0700 (PDT) Received: from blackbox.darklights.net (p5DE388BA.dip0.t-ipconnect.de. [93.227.136.186]) by smtp.googlemail.com with ESMTPSA id 142sm8478777wmh.12.2016.08.20.02.54.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 20 Aug 2016 02:54:37 -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, linus.walleij@linaro.org, khilman@baylibre.com, carlo@caione.org Subject: [PATCH v5 4/6] media: rc: meson-ir: Add support for newer versions of the IR decoder Date: Sat, 20 Aug 2016 11:54:22 +0200 Message-Id: <20160820095424.636-5-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20160820095424.636-1-martin.blumenstingl@googlemail.com> References: <20160819215547.20063-1-martin.blumenstingl@googlemail.com> <20160820095424.636-1-martin.blumenstingl@googlemail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160820_025456_656284_D8D72962 X-CRM114-Status: GOOD ( 12.24 ) 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, will.deacon@arm.com, b.galvani@gmail.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 --- 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" }, { }, };