From patchwork Wed Nov 7 12:10:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Dodge X-Patchwork-Id: 10675451 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0868014BD for ; Fri, 9 Nov 2018 08:04:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0E2B2E367 for ; Fri, 9 Nov 2018 08:04:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E25762E376; Fri, 9 Nov 2018 08:04:38 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 96F022E367 for ; Fri, 9 Nov 2018 08:04:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F33AD6E760; Fri, 9 Nov 2018 08:04:14 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by gabe.freedesktop.org (Postfix) with ESMTPS id C5CD26E07F for ; Wed, 7 Nov 2018 12:10:59 +0000 (UTC) Received: by mail-qk1-x742.google.com with SMTP id y16so19182240qki.7 for ; Wed, 07 Nov 2018 04:10:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CWbrCf9ShPYRJNm/AitUWiYzz0VasTdPEFS/69hzoFQ=; b=jaqxu2fOHLKpL+IZnlBsyqKnSgUslEmQ2+sYOFAHBeYut4x6Fh3FlC/udqIh84Kb4M 4QjHsuHbCIr1MrpRYkUrv/4pkUkSeHHvkDl/dIHvwuaS4F7Mt7+z50eWwGRchL2qrxYY UmhoMSWvciazIt5iWF3dzOzuC6X7FEIpuDcXUAQiTvP3n4bXYLUstTV3qJdqfW472o9C PbWucLMeeBnfdHPmvL62WTzdgGDrgJ/wzmNEmJZ6zRvgAR1/byVmOmP+E7Sfg+u8+O5W /F418cQfEsXOy+bhU42Cn2nzqebx1lalEpxJcJI7C68yYXUczioUZ9MqO6oLzw4NFJCz 0JSQ== X-Gm-Message-State: AGRZ1gLiAD0olW6Vc114xrXqhID0y3a4aU3H60nz1EbxL6QIRTy0PIHF 9tCkLDS35TMvFZ98QCJJMFydQqoH20A= X-Google-Smtp-Source: AJdET5fowD7pMHAKQG33J0I+DrpVnrr5XARpxqRjZf6JHYqM/i3GcA0PFE5nMGElo0Whk/U0next5g== X-Received: by 2002:a37:2d82:: with SMTP id t124mr1296791qkh.122.1541592658903; Wed, 07 Nov 2018 04:10:58 -0800 (PST) Received: from bdodge-linux-ub.fios-router.home (pool-108-49-248-83.bstnma.fios.verizon.net. [108.49.248.83]) by smtp.gmail.com with ESMTPSA id 53-v6sm257490qtw.52.2018.11.07.04.10.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Nov 2018 04:10:58 -0800 (PST) From: Brian Dodge To: lee.jones@linaro.org, daniel.thompson@linaro.org, jingoohan1@gmail.com, jacek.anaszewski@gmail.com, pavel@ucw.cz, robh+dt@kernel.org, mark.rutland@arm.com, dri-devel@lists.freedesktop.org, linux-leds@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 1/3] dt-bindings: backlight: fix vendor prefix for ArcticSand arcxcnn driver bindings Date: Wed, 7 Nov 2018 07:10:38 -0500 Message-Id: <1541592640-18478-2-git-send-email-bdodge09@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1541592640-18478-1-git-send-email-bdodge09@gmail.com> References: <1541592640-18478-1-git-send-email-bdodge09@gmail.com> X-Mailman-Approved-At: Fri, 09 Nov 2018 08:04:14 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Brian Dodge MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP The vendor-prefixes.txt file properly refers to ArcticSand as arctic but the driver bindings improperly abbreviated the prefix to arc. This was a mistake in the original patch Signed-off-by: Brian Dodge --- .../bindings/leds/backlight/arcxcnn_bl.txt | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) -- 2.7.4 diff --git a/Documentation/devicetree/bindings/leds/backlight/arcxcnn_bl.txt b/Documentation/devicetree/bindings/leds/backlight/arcxcnn_bl.txt index 230abde..dcaa239 100644 --- a/Documentation/devicetree/bindings/leds/backlight/arcxcnn_bl.txt +++ b/Documentation/devicetree/bindings/leds/backlight/arcxcnn_bl.txt @@ -1,8 +1,8 @@ -Binding for ArcticSand arc2c0608 LED driver +Binding for ArcticSand arc family LED drivers Required properties: -- compatible: should be "arc,arc2c0608" -- reg: slave address +- compatible: "arctic,arc1c0608", "arctic,arc2c0608", "arctic,arc3c0845" +- reg: slave address Optional properties: - default-brightness: brightness value on boot, value from: 0-4095 @@ -11,19 +11,19 @@ Optional properties: - led-sources: List of enabled channels from 0 to 5. See Documentation/devicetree/bindings/leds/common.txt -- arc,led-config-0: setting for register ILED_CONFIG_0 -- arc,led-config-1: setting for register ILED_CONFIG_1 -- arc,dim-freq: PWM mode frequence setting (bits [3:0] used) -- arc,comp-config: setting for register CONFIG_COMP -- arc,filter-config: setting for register FILTER_CONFIG -- arc,trim-config: setting for register IMAXTUNE +- arctic,led-config-0: setting for register ILED_CONFIG_0 +- arctic,led-config-1: setting for register ILED_CONFIG_1 +- arctic,dim-freq: PWM mode frequence setting (bits [3:0] used) +- arctic,comp-config: setting for register CONFIG_COMP +- arctic,filter-config: setting for register FILTER_CONFIG +- arctic,trim-config: setting for register IMAXTUNE Note: Optional properties not specified will default to values in IC EPROM Example: arc2c0608@30 { - compatible = "arc,arc2c0608"; + compatible = "arctic,arc2c0608"; reg = <0x30>; default-brightness = <500>; label = "lcd-backlight"; From patchwork Wed Nov 7 12:10:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Dodge X-Patchwork-Id: 10675457 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 852D2175A for ; Fri, 9 Nov 2018 08:04:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 786302E367 for ; Fri, 9 Nov 2018 08:04:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C55A2E36F; Fri, 9 Nov 2018 08:04:43 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1E2E22E367 for ; Fri, 9 Nov 2018 08:04:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C65286E77D; Fri, 9 Nov 2018 08:04:16 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by gabe.freedesktop.org (Postfix) with ESMTPS id 110C46E154 for ; Wed, 7 Nov 2018 12:11:01 +0000 (UTC) Received: by mail-qt1-x843.google.com with SMTP id p17so6265558qtl.5 for ; Wed, 07 Nov 2018 04:11:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=F5Xj40w4kHbnMqUigFmhWslpGRkJ+e4z3lXmNJrIyww=; b=bGAJV2OuZ/yfqSfbN1KVFuRI2K2WPVgQT4I3qxzJjQByOhaCMJL0xPp4sCvRCSSHJB 9Zggn+Vm7zlJKfSjy4WoXiFFpFk5OpYrDpXTlQqz9I3vC3Nzy9hr3p6I4TtsWCO3H6he 1pVK0OXjNVUsEWUphzE4DC0A5iK4HVjS2ECdCtDhBTTEJ7Xuw8v7EOHQCUBJ1Ppk3lMg QUJQjOO9l3gVzacOWO7Jy+hHqHWW35BFbVd2BZLzgI6cEpMoDqGXXEfvtZYY6KOEqgPa msO4vXXXnR5RuiDjSnJYzMeC7QkFq2s5TUrFlecvNfVwN+4FRWwE1U7FGiBwIIN9W3AI rusw== X-Gm-Message-State: AGRZ1gLkkLHxVQif9ILL2P3YdUyz27zzTY4ROf5x9KtVjoq0Zrrl6uvP 6Suwem8SAZgxVrU1c5UQGUU= X-Google-Smtp-Source: AJdET5dE8bEIlvFysBocrr6NABhok6GzOHK/Q17RNsMXe5fJbFNJ1AW7Kyk4x0RuLdDdrKq2vwatvw== X-Received: by 2002:aed:3622:: with SMTP id e31mr1343180qtb.5.1541592660188; Wed, 07 Nov 2018 04:11:00 -0800 (PST) Received: from bdodge-linux-ub.fios-router.home (pool-108-49-248-83.bstnma.fios.verizon.net. [108.49.248.83]) by smtp.gmail.com with ESMTPSA id 53-v6sm257490qtw.52.2018.11.07.04.10.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Nov 2018 04:10:59 -0800 (PST) From: Brian Dodge To: lee.jones@linaro.org, daniel.thompson@linaro.org, jingoohan1@gmail.com, jacek.anaszewski@gmail.com, pavel@ucw.cz, robh+dt@kernel.org, mark.rutland@arm.com, dri-devel@lists.freedesktop.org, linux-leds@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 2/3] backlight/arcxcnn fix vendor prefix Date: Wed, 7 Nov 2018 07:10:39 -0500 Message-Id: <1541592640-18478-3-git-send-email-bdodge09@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1541592640-18478-1-git-send-email-bdodge09@gmail.com> References: <1541592640-18478-1-git-send-email-bdodge09@gmail.com> X-Mailman-Approved-At: Fri, 09 Nov 2018 08:04:14 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Brian Dodge MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP The vendor-prefixes.txt file properly refers to ArcticSand as arctic but the driver improperly abbreviated the prefix to arc. This was a mistake in the original patch Signed-off-by: Brian Dodge --- drivers/video/backlight/arcxcnn_bl.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) -- 2.7.4 diff --git a/drivers/video/backlight/arcxcnn_bl.c b/drivers/video/backlight/arcxcnn_bl.c index dec790d..bebefc6 100644 --- a/drivers/video/backlight/arcxcnn_bl.c +++ b/drivers/video/backlight/arcxcnn_bl.c @@ -1,8 +1,8 @@ /* - * Backlight driver for ArcticSand ARC_X_C_0N_0N Devices + * Backlight driver for pSemi (formerly ArcticSand) ARC_X_C_0N_0N Devices * - * Copyright 2016 ArcticSand, Inc. - * Author : Brian Dodge + * Copyright 2018 pSemi, Inc. + * Author : Brian Dodge * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 @@ -202,27 +202,27 @@ static void arcxcnn_parse_dt(struct arcxcnn *lp) if (ret == 0) lp->pdata->initial_brightness = prog_val; - ret = of_property_read_u32(node, "arc,led-config-0", &prog_val); + ret = of_property_read_u32(node, "arctic,led-config-0", &prog_val); if (ret == 0) lp->pdata->led_config_0 = (u8)prog_val; - ret = of_property_read_u32(node, "arc,led-config-1", &prog_val); + ret = of_property_read_u32(node, "arctic,led-config-1", &prog_val); if (ret == 0) lp->pdata->led_config_1 = (u8)prog_val; - ret = of_property_read_u32(node, "arc,dim-freq", &prog_val); + ret = of_property_read_u32(node, "arctic,dim-freq", &prog_val); if (ret == 0) lp->pdata->dim_freq = (u8)prog_val; - ret = of_property_read_u32(node, "arc,comp-config", &prog_val); + ret = of_property_read_u32(node, "arctic,comp-config", &prog_val); if (ret == 0) lp->pdata->comp_config = (u8)prog_val; - ret = of_property_read_u32(node, "arc,filter-config", &prog_val); + ret = of_property_read_u32(node, "arctic,filter-config", &prog_val); if (ret == 0) lp->pdata->filter_config = (u8)prog_val; - ret = of_property_read_u32(node, "arc,trim-config", &prog_val); + ret = of_property_read_u32(node, "arctic,trim-config", &prog_val); if (ret == 0) lp->pdata->trim_config = (u8)prog_val; @@ -392,7 +392,7 @@ static int arcxcnn_remove(struct i2c_client *cl) } static const struct of_device_id arcxcnn_dt_ids[] = { - { .compatible = "arc,arc2c0608" }, + { .compatible = "arctic,arc2c0608" }, { } }; MODULE_DEVICE_TABLE(of, arcxcnn_dt_ids); @@ -415,5 +415,5 @@ static struct i2c_driver arcxcnn_driver = { module_i2c_driver(arcxcnn_driver); MODULE_LICENSE("GPL v2"); -MODULE_AUTHOR("Brian Dodge "); +MODULE_AUTHOR("Brian Dodge "); MODULE_DESCRIPTION("ARCXCNN Backlight driver"); From patchwork Wed Nov 7 12:10:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Dodge X-Patchwork-Id: 10675447 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7DDB414D6 for ; Fri, 9 Nov 2018 08:04:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F1582E367 for ; Fri, 9 Nov 2018 08:04:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6339B2E36F; Fri, 9 Nov 2018 08:04:28 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8EB0F2E367 for ; Fri, 9 Nov 2018 08:04:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8CA056E0B3; Fri, 9 Nov 2018 08:04:15 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by gabe.freedesktop.org (Postfix) with ESMTPS id F3C696E1B3 for ; Wed, 7 Nov 2018 12:11:02 +0000 (UTC) Received: by mail-qk1-x742.google.com with SMTP id d135so20326253qkc.12 for ; Wed, 07 Nov 2018 04:11:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2Otrk7dctfan4jx9C2Mm9I6DeNsOmqrEvTzVDGCh/a8=; b=gqcN+q+eFvx43Upx64l+BllH2bJT9rzTeCeZD1qJZza5RkCeHsMFKdV4x3BIX0P4Ui +YaFnQkiq9dEcwLFPDUI3w322G9GxFbbPqLp5nbAezIkqN3s7mgfafjW7wyHs323w2uO BT3F3ELTjpoO3cnDFauUqOb9XeZI9n9BhQ4b7TuYYITEMsohRlnjupxDbsfjKo0u61YD ASBm3hFPQ3kKFjMnZfSDzjM8fvqvEYQUW0h9HSvfv46PIiFxWRVQFz+eD0Gh9luTIcLQ MEQmeDwFHQ4iP1p/C8GPHxyu+eZbTXZYj5bWBXHTBh8q/7z0Zy3TV16m7F0m644bT0+r ImoQ== X-Gm-Message-State: AGRZ1gKK2YEd1VxWU/LT/pk0Hw30QdpGC3Pj3nucY7agaI6YqhtxfRu1 GpUdw6TPmmRSwHrBtnLbuNfkLYCljbM= X-Google-Smtp-Source: AJdET5e9T4NxNdwULPKbLaai3LrsHmkHni5B/uANiLIW0uQiqrg7iAn+jcwtRg7+M7DexGjHx5GCsQ== X-Received: by 2002:a37:8006:: with SMTP id b6-v6mr1247717qkd.178.1541592661965; Wed, 07 Nov 2018 04:11:01 -0800 (PST) Received: from bdodge-linux-ub.fios-router.home (pool-108-49-248-83.bstnma.fios.verizon.net. [108.49.248.83]) by smtp.gmail.com with ESMTPSA id 53-v6sm257490qtw.52.2018.11.07.04.11.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Nov 2018 04:11:01 -0800 (PST) From: Brian Dodge To: lee.jones@linaro.org, daniel.thompson@linaro.org, jingoohan1@gmail.com, jacek.anaszewski@gmail.com, pavel@ucw.cz, robh+dt@kernel.org, mark.rutland@arm.com, dri-devel@lists.freedesktop.org, linux-leds@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 3/3] backlight/arcxcnn add support for arc1 an arc3 chip families Date: Wed, 7 Nov 2018 07:10:40 -0500 Message-Id: <1541592640-18478-4-git-send-email-bdodge09@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1541592640-18478-1-git-send-email-bdodge09@gmail.com> References: <1541592640-18478-1-git-send-email-bdodge09@gmail.com> X-Mailman-Approved-At: Fri, 09 Nov 2018 08:04:14 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Brian Dodge MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Support for newer ArcticSand LED drivers is added. The i2c device id is used to modify some limits and set some device specific register addresses Signed-off-by: Brian Dodge --- drivers/video/backlight/arcxcnn_bl.c | 261 +++++++++++++++++++++++++---------- 1 file changed, 190 insertions(+), 71 deletions(-) -- 2.7.4 diff --git a/drivers/video/backlight/arcxcnn_bl.c b/drivers/video/backlight/arcxcnn_bl.c index bebefc6..30c07cb 100644 --- a/drivers/video/backlight/arcxcnn_bl.c +++ b/drivers/video/backlight/arcxcnn_bl.c @@ -25,7 +25,9 @@ #include enum arcxcnn_chip_id { - ARC2C0608 + ARC1C0608, + ARC2C0608, + ARC3C0845 }; /** @@ -64,42 +66,77 @@ struct arcxcnn_platform_data { #define ARCXCNN_CMD_EXT_COMP 0x01 /* part (0) or full (1) ext. comp */ #define ARCXCNN_CONFIG 0x01 /* Configuration */ -#define ARCXCNN_STATUS1 0x02 /* Status 1 */ -#define ARCXCNN_STATUS2 0x03 /* Status 2 */ + +#define ARCXCNN_STATUS1 0x02 /* Status 1 (6 str) */ +#define ARCXCNN_STATUS2 0x03 /* Status 2 (6 str)*/ #define ARCXCNN_FADECTRL 0x04 /* Fading Control */ +#define ARC3CNN_FADECTRL 0x02 /* Fading Control */ #define ARCXCNN_ILED_CONFIG 0x05 /* ILED Configuration */ +#define ARC3CNN_ILED_CONFIG 0x03 /* ILED Configuration */ #define ARCXCNN_ILED_DIM_PWM 0x00 /* config dim mode pwm */ -#define ARCXCNN_ILED_DIM_INT 0x04 /* config dim mode internal */ -#define ARCXCNN_LEDEN 0x06 /* LED Enable Register */ +#define ARCXCNN_ILED_DIM_INT 0x44 /* config dim mode int+iset (6 str) */ +#define ARC3CNN_ILED_DIM_INT 0x20 /* config dim mode internal (8 str) */ +#define ARCXCNN_LEDEN 0x06 /* LED Enable Register (6 str) */ +#define ARC3CNN_LEDEN 0x04 /* LED Enable Register (8 str) */ + #define ARCXCNN_LEDEN_ISETEXT 0x80 /* Full-scale current set extern */ -#define ARCXCNN_LEDEN_MASK 0x3F /* LED string enables mask */ -#define ARCXCNN_LEDEN_BITS 0x06 /* Bits of LED string enables */ + +#define ARCXCNN_LEDEN_MASK 0x3F /* LED string enables mask (6 str) */ +#define ARCXCNN_LEDEN_BITS 0x06 /* Bits of string enables (6 str) */ +#define ARC3CNN_LEDEN_MASK 0xFF /* LED string enables mask (8 str) */ +#define ARC3CNN_LEDEN_BITS 0x08 /* Bits of string enables (8 str) */ #define ARCXCNN_LEDEN_LED1 0x01 #define ARCXCNN_LEDEN_LED2 0x02 #define ARCXCNN_LEDEN_LED3 0x04 #define ARCXCNN_LEDEN_LED4 0x08 #define ARCXCNN_LEDEN_LED5 0x10 #define ARCXCNN_LEDEN_LED6 0x20 +#define ARCXCNN_LEDEN_LED7 0x40 +#define ARCXCNN_LEDEN_LED8 0x80 + +#define ARCXCNN_WLED_ISET_LSB 0x07 /* LED ISET LSB */ +#define ARCXCNN_WLED_ISET_LSB_SHIFT 0x04 /* ISET LSB Left Shift */ +#define ARCXCNN_WLED_ISET_MSB 0x08 /* LED ISET MSB (8 bits) */ +#define ARC3CNN_WLED_ISET_LSB 0x05 /* LED ISET LSB */ +#define ARC3CNN_WLED_ISET_LSB_SHIFT 0x01 /* ISET LSB Left Shift */ +#define ARC3CNN_WLED_ISET_MSB 0x06 /* LED ISET MSB (8 bits) */ -#define ARCXCNN_WLED_ISET_LSB 0x07 /* LED ISET LSB (in upper nibble) */ -#define ARCXCNN_WLED_ISET_LSB_SHIFT 0x04 /* ISET LSB Left Shift */ -#define ARCXCNN_WLED_ISET_MSB 0x08 /* LED ISET MSB (8 bits) */ +#define ARC2CNN_DIMFREQ 0x09 + +/* NO COMP CONFIG OR FILT CONFIG IN ARC1CNN */ +#define ARC2CNN_COMP_CONFIG 0x0A +#define ARC3CNN_COMP_CONFIG 0x08 +#define ARC2CNN_FILT_CONFIG 0x0B +#define ARC3CNN_FILT_CONFIG 0x09 + +#define ARC3CNN_FILT_DIMCODE 0x60 /* Force DITHER_ENABLE and code 01 */ + +#define ARC2CNN_IMAXTUNE 0x0C +#define ARC3CNN_IMAXTUNE 0x0A -#define ARCXCNN_DIMFREQ 0x09 -#define ARCXCNN_COMP_CONFIG 0x0A -#define ARCXCNN_FILT_CONFIG 0x0B -#define ARCXCNN_IMAXTUNE 0x0C #define ARCXCNN_ID_MSB 0x1E #define ARCXCNN_ID_LSB 0x1F +#define ARC3CNN_ID_MSB 0xFE +#define ARC3CNN_ID_LSB 0xFF -#define MAX_BRIGHTNESS 4095 -#define INIT_BRIGHT 60 +#define ARC_MAX_BRIGHTNESS_1 4095 +#define ARC_MAX_BRIGHTNESS_2 4095 +#define ARC_MAX_BRIGHTNESS_3 32767 +#define ARC_INIT_BRIGHT 60 struct arcxcnn { struct i2c_client *client; struct backlight_device *bl; struct device *dev; struct arcxcnn_platform_data *pdata; + u8 chipid; + u16 max_brightness; + u8 rst_reg; + u8 fade_reg; + u8 iled_config_reg, dim_mode_bits; + u8 iset_lsb_reg, iset_msb_reg, iset_shift; + u8 leden_reg, leden_mask, leden_bits; + u8 comp_config_reg, filter_reg, maxtune_reg; }; static int arcxcnn_update_field(struct arcxcnn *lp, u8 reg, u8 mask, u8 data) @@ -125,17 +162,16 @@ static int arcxcnn_set_brightness(struct arcxcnn *lp, u32 brightness) int ret; u8 val; - /* lower nibble of brightness goes in upper nibble of LSB register */ - val = (brightness & 0xF) << ARCXCNN_WLED_ISET_LSB_SHIFT; + /* brightness is split across two registers */ + val = brightness << lp->iset_shift; ret = i2c_smbus_write_byte_data(lp->client, - ARCXCNN_WLED_ISET_LSB, val); + lp->iset_lsb_reg, val); if (ret < 0) return ret; - /* remaining 8 bits of brightness go in MSB register */ - val = (brightness >> 4); + val = (u8)(brightness >> (8 - lp->iset_shift)); return i2c_smbus_write_byte_data(lp->client, - ARCXCNN_WLED_ISET_MSB, val); + lp->iset_msb_reg, val); } static int arcxcnn_bl_update_status(struct backlight_device *bl) @@ -152,7 +188,7 @@ static int arcxcnn_bl_update_status(struct backlight_device *bl) return ret; /* set power-on/off/save modes */ - return arcxcnn_update_field(lp, ARCXCNN_CMD, ARCXCNN_CMD_STDBY, + return arcxcnn_update_field(lp, lp->rst_reg, ARCXCNN_CMD_STDBY, (bl->props.power == 0) ? 0 : ARCXCNN_CMD_STDBY); } @@ -171,7 +207,7 @@ static int arcxcnn_backlight_register(struct arcxcnn *lp) return -ENOMEM; props->type = BACKLIGHT_PLATFORM; - props->max_brightness = MAX_BRIGHTNESS; + props->max_brightness = lp->max_brightness; if (lp->pdata->initial_brightness > props->max_brightness) lp->pdata->initial_brightness = props->max_brightness; @@ -187,7 +223,7 @@ static void arcxcnn_parse_dt(struct arcxcnn *lp) { struct device *dev = lp->dev; struct device_node *node = dev->of_node; - u32 prog_val, num_entry, entry, sources[ARCXCNN_LEDEN_BITS]; + u32 prog_val, num_entry, entry, sources[ARC3CNN_LEDEN_BITS]; int ret; /* device tree entry isn't required, defaults are OK */ @@ -228,11 +264,11 @@ static void arcxcnn_parse_dt(struct arcxcnn *lp) ret = of_property_count_u32_elems(node, "led-sources"); if (ret < 0) { - lp->pdata->leden = ARCXCNN_LEDEN_MASK; /* all on is default */ + lp->pdata->leden = lp->leden_mask; /* all on is default */ } else { num_entry = ret; - if (num_entry > ARCXCNN_LEDEN_BITS) - num_entry = ARCXCNN_LEDEN_BITS; + if (num_entry > lp->leden_bits) + num_entry = lp->leden_bits; ret = of_property_read_u32_array(node, "led-sources", sources, num_entry); @@ -266,14 +302,84 @@ static int arcxcnn_probe(struct i2c_client *cl, const struct i2c_device_id *id) lp->client = cl; lp->dev = &cl->dev; - lp->pdata = dev_get_platdata(&cl->dev); + + /* read device id (class) */ + lp->chipid = i2c_smbus_read_byte_data(cl, ARCXCNN_ID_MSB); + if (lp->chipid > 2) { + lp->chipid = i2c_smbus_read_byte_data(cl, ARC3CNN_ID_MSB); + if (lp->chipid != 3) { + dev_err(lp->dev, + "Unknown device Id %02X\n", lp->chipid); + ret = -ENODEV; + goto probe_err; + } + } + + if (lp->chipid == 0) { + /* treat id 0 as older class 1 chips */ + lp->chipid = 1; + } + + switch (lp->chipid) { + case 3: + /* class 3 device, 8 strings */ + lp->max_brightness = ARC_MAX_BRIGHTNESS_3; + lp->rst_reg = ARC3CNN_COMP_CONFIG; + lp->fade_reg = ARC3CNN_FADECTRL; + lp->iled_config_reg = ARC3CNN_ILED_CONFIG; + lp->dim_mode_bits = ARC3CNN_ILED_DIM_INT; + lp->leden_reg = ARC3CNN_LEDEN; + lp->leden_mask = ARC3CNN_LEDEN_MASK; + lp->leden_bits = ARC3CNN_LEDEN_BITS; + lp->iset_lsb_reg = ARC3CNN_WLED_ISET_LSB; + lp->iset_msb_reg = ARC3CNN_WLED_ISET_MSB; + lp->iset_shift = ARC3CNN_WLED_ISET_LSB_SHIFT; + lp->comp_config_reg = ARC3CNN_COMP_CONFIG; + lp->filter_reg = ARC3CNN_FILT_CONFIG; + lp->maxtune_reg = ARC3CNN_IMAXTUNE; + break; + case 2: + /* class 2 device, 6 strings */ + lp->max_brightness = ARC_MAX_BRIGHTNESS_2; + lp->rst_reg = ARCXCNN_CMD; + lp->fade_reg = ARCXCNN_FADECTRL; + lp->iled_config_reg = ARCXCNN_ILED_CONFIG; + lp->dim_mode_bits = ARCXCNN_ILED_DIM_INT; + lp->leden_reg = ARCXCNN_LEDEN; + lp->leden_mask = ARCXCNN_LEDEN_MASK; + lp->leden_bits = ARCXCNN_LEDEN_BITS; + lp->iset_lsb_reg = ARCXCNN_WLED_ISET_LSB; + lp->iset_msb_reg = ARCXCNN_WLED_ISET_MSB; + lp->iset_shift = ARCXCNN_WLED_ISET_LSB_SHIFT; + lp->comp_config_reg = ARC2CNN_COMP_CONFIG; + lp->filter_reg = ARC2CNN_FILT_CONFIG; + lp->maxtune_reg = ARC2CNN_IMAXTUNE; + break; + case 1: + default: + /* class 1 device, 6 strings */ + lp->max_brightness = ARC_MAX_BRIGHTNESS_1; + lp->rst_reg = ARCXCNN_CMD; + lp->fade_reg = ARCXCNN_FADECTRL; + lp->iled_config_reg = ARCXCNN_ILED_CONFIG; + lp->dim_mode_bits = ARCXCNN_ILED_DIM_INT; + lp->leden_reg = ARCXCNN_LEDEN; + lp->leden_mask = ARCXCNN_LEDEN_MASK; + lp->leden_bits = ARCXCNN_LEDEN_BITS; + lp->iset_lsb_reg = ARCXCNN_WLED_ISET_LSB; + lp->iset_msb_reg = ARCXCNN_WLED_ISET_MSB; + lp->iset_shift = ARCXCNN_WLED_ISET_LSB_SHIFT; + break; + } /* reset the device */ ret = i2c_smbus_write_byte_data(lp->client, - ARCXCNN_CMD, ARCXCNN_CMD_RESET); + lp->rst_reg, ARCXCNN_CMD_RESET); if (ret) goto probe_err; + lp->pdata = dev_get_platdata(&cl->dev); + if (!lp->pdata) { lp->pdata = devm_kzalloc(lp->dev, sizeof(*lp->pdata), GFP_KERNEL); @@ -282,29 +388,31 @@ static int arcxcnn_probe(struct i2c_client *cl, const struct i2c_device_id *id) /* Setup defaults based on power-on defaults */ lp->pdata->name = NULL; - lp->pdata->initial_brightness = INIT_BRIGHT; - lp->pdata->leden = ARCXCNN_LEDEN_MASK; + lp->pdata->initial_brightness = ARC_INIT_BRIGHT; + lp->pdata->leden = lp->leden_mask; lp->pdata->led_config_0 = i2c_smbus_read_byte_data( - lp->client, ARCXCNN_FADECTRL); + lp->client, lp->fade_reg); lp->pdata->led_config_1 = i2c_smbus_read_byte_data( - lp->client, ARCXCNN_ILED_CONFIG); + lp->client, lp->iled_config_reg); /* insure dim mode is not default pwm */ - lp->pdata->led_config_1 |= ARCXCNN_ILED_DIM_INT; - - lp->pdata->dim_freq = i2c_smbus_read_byte_data( - lp->client, ARCXCNN_DIMFREQ); + lp->pdata->led_config_1 |= lp->dim_mode_bits; - lp->pdata->comp_config = i2c_smbus_read_byte_data( - lp->client, ARCXCNN_COMP_CONFIG); + if (lp->chipid == 2) + lp->pdata->dim_freq = i2c_smbus_read_byte_data( + lp->client, ARC2CNN_DIMFREQ); - lp->pdata->filter_config = i2c_smbus_read_byte_data( - lp->client, ARCXCNN_FILT_CONFIG); + if (lp->chipid > 1) { + lp->pdata->comp_config = i2c_smbus_read_byte_data( + lp->client, lp->comp_config_reg); - lp->pdata->trim_config = i2c_smbus_read_byte_data( - lp->client, ARCXCNN_IMAXTUNE); + lp->pdata->filter_config = i2c_smbus_read_byte_data( + lp->client, lp->filter_reg); + lp->pdata->trim_config = i2c_smbus_read_byte_data( + lp->client, lp->maxtune_reg); + } if (IS_ENABLED(CONFIG_OF)) arcxcnn_parse_dt(lp); } @@ -312,48 +420,55 @@ static int arcxcnn_probe(struct i2c_client *cl, const struct i2c_device_id *id) i2c_set_clientdata(cl, lp); /* constrain settings to what is possible */ - if (lp->pdata->initial_brightness > MAX_BRIGHTNESS) - lp->pdata->initial_brightness = MAX_BRIGHTNESS; + if (lp->pdata->initial_brightness > lp->max_brightness) + lp->pdata->initial_brightness = lp->max_brightness; /* set initial brightness */ ret = arcxcnn_set_brightness(lp, lp->pdata->initial_brightness); if (ret) goto probe_err; - /* set other register values directly */ - ret = i2c_smbus_write_byte_data(lp->client, ARCXCNN_FADECTRL, - lp->pdata->led_config_0); + /* set other register values directly from platform data */ + ret = i2c_smbus_write_byte_data(lp->client, + lp->fade_reg, lp->pdata->led_config_0); if (ret) goto probe_err; - ret = i2c_smbus_write_byte_data(lp->client, ARCXCNN_ILED_CONFIG, - lp->pdata->led_config_1); + ret = i2c_smbus_write_byte_data(lp->client, + lp->iled_config_reg, lp->pdata->led_config_1); if (ret) goto probe_err; - ret = i2c_smbus_write_byte_data(lp->client, ARCXCNN_DIMFREQ, - lp->pdata->dim_freq); - if (ret) - goto probe_err; + if (lp->chipid == 2) { + ret = i2c_smbus_write_byte_data(lp->client, ARC2CNN_DIMFREQ, + lp->pdata->dim_freq); + if (ret) + goto probe_err; + } - ret = i2c_smbus_write_byte_data(lp->client, ARCXCNN_COMP_CONFIG, - lp->pdata->comp_config); - if (ret) - goto probe_err; + if (lp->chipid > 1) { + ret = i2c_smbus_write_byte_data(lp->client, + lp->comp_config_reg, lp->pdata->comp_config); + if (ret) + goto probe_err; - ret = i2c_smbus_write_byte_data(lp->client, ARCXCNN_FILT_CONFIG, - lp->pdata->filter_config); - if (ret) - goto probe_err; + if (lp->chipid == 3) + lp->pdata->filter_config = ARC3CNN_FILT_DIMCODE; - ret = i2c_smbus_write_byte_data(lp->client, ARCXCNN_IMAXTUNE, - lp->pdata->trim_config); - if (ret) - goto probe_err; + ret = i2c_smbus_write_byte_data(lp->client, + lp->filter_reg, lp->pdata->filter_config); + if (ret) + goto probe_err; + + ret = i2c_smbus_write_byte_data(lp->client, + lp->maxtune_reg, lp->pdata->trim_config); + if (ret) + goto probe_err; + } /* set initial LED Enables */ - arcxcnn_update_field(lp, ARCXCNN_LEDEN, - ARCXCNN_LEDEN_MASK, lp->pdata->leden); + arcxcnn_update_field(lp, lp->leden_reg, + lp->leden_mask, lp->pdata->leden); ret = arcxcnn_backlight_register(lp); if (ret) @@ -379,10 +494,10 @@ static int arcxcnn_remove(struct i2c_client *cl) /* disable all strings (ignore errors) */ i2c_smbus_write_byte_data(lp->client, - ARCXCNN_LEDEN, 0x00); + lp->leden_reg, 0x00); /* reset the device (ignore errors) */ i2c_smbus_write_byte_data(lp->client, - ARCXCNN_CMD, ARCXCNN_CMD_RESET); + lp->rst_reg, ARCXCNN_CMD_RESET); lp->bl->props.brightness = 0; @@ -392,13 +507,17 @@ static int arcxcnn_remove(struct i2c_client *cl) } static const struct of_device_id arcxcnn_dt_ids[] = { + { .compatible = "arctic,arc1c0608" }, { .compatible = "arctic,arc2c0608" }, + { .compatible = "arctic,arc3c0845" }, { } }; MODULE_DEVICE_TABLE(of, arcxcnn_dt_ids); static const struct i2c_device_id arcxcnn_ids[] = { + {"arc1c0608", ARC1C0608}, {"arc2c0608", ARC2C0608}, + {"arc3c0845", ARC3C0845}, { } }; MODULE_DEVICE_TABLE(i2c, arcxcnn_ids);