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: 9291677 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 5B21B600CB for ; Sat, 20 Aug 2016 09:55:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A53E2916A for ; Sat, 20 Aug 2016 09:55:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5EB2229179; Sat, 20 Aug 2016 09:55:46 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F2B682916A for ; Sat, 20 Aug 2016 09:55:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753736AbcHTJzj (ORCPT ); Sat, 20 Aug 2016 05:55:39 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:35996 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752963AbcHTJzf (ORCPT ); Sat, 20 Aug 2016 05:55:35 -0400 Received: by mail-wm0-f66.google.com with SMTP id i138so6261542wmf.3; 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=l/HQx/vbQT8Yvs/qVJVdH7YG16lq2B92cfpLDevjerQf7C01Ue8Fn3HX0v1bfvoVoo ikSQgB51DVSH4sefbLi1+nijYzelmEh+P/JdQ2BntD4giVrN8oumKjCG/ho5xE/oKRNl Jqc4ysqApRmH5TRQmAD8bZKJrlmcZSIu7TpcWEebL/1tIa61nSUSTs9ixL/qMEkt4IrZ YZGg17tfo5xshUzxNvMi9XbRdDtvY8etHQVBX2fUGc7S0JnjJiC/9YIDCM+ACWIyqKLc bbIs45tefuNfXd8rga6/HdHcA75jTsZt+F2fspoJlwvuzXjCDDxcFNstv6n24Ylao+yO 0Z0w== X-Gm-Message-State: AEkooutYvGQ1RLrhJfFNIjibv2Q6UKSsMyBJL5YEPOcoHCXdskhMPWPz1tAKDqFpEaJtmw== 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 Cc: linux-arm-kernel@lists.infradead.org, mchehab@kernel.org, will.deacon@arm.com, catalin.marinas@arm.com, mark.rutland@arm.com, robh+dt@kernel.org, b.galvani@gmail.com, Martin Blumenstingl 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> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.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" }, { }, };