From patchwork Tue Dec 1 01:15:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?J=2E_Neusch=C3=A4fer?= X-Patchwork-Id: 335285 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7F2DC63777 for ; Tue, 1 Dec 2020 02:19:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 31AC720857 for ; Tue, 1 Dec 2020 02:19:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=gmx.net header.i=@gmx.net header.b="hGMyhd+X" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726646AbgLACSw (ORCPT ); Mon, 30 Nov 2020 21:18:52 -0500 Received: from mout.gmx.net ([212.227.17.21]:48665 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726630AbgLACSw (ORCPT ); Mon, 30 Nov 2020 21:18:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1606788972; bh=8cmA5+575w3kIUQc3qXvROhNutCWPpMSRH/kfain2W0=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=hGMyhd+XtmP+GM9R7TS52XclLKeqwEkivy2O7PwaE4E9TOymjTMoCBYCPDFgjf5j1 LtipnREP3YC30EkhkV5/I5oROkqG9NJofY4Vd0MZxIUxpdgdDY04ojnO210YH7/sx/ Zrs3ZbOcR+bxXN1MK7x3WyqaUe/6PFtAbjOSbIpI= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from longitude ([37.201.214.162]) by mail.gmx.com (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MxlzC-1jz7qv3REc-00zJ9R; Tue, 01 Dec 2020 03:16:11 +0100 From: =?utf-8?q?Jonathan_Neusch=C3=A4fer?= To: linux-kernel@vger.kernel.org Cc: Lee Jones , Rob Herring , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Thierry Reding , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?b?w7ZuaWc=?= , Alessandro Zummo , Alexandre Belloni , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Sam Ravnborg , Linus Walleij , Heiko Stuebner , Stephan Gerhold , Lubomir Rintel , Mark Brown , allen , Mauro Carvalho Chehab , "David S. Miller" , devicetree@vger.kernel.org, linux-pwm@vger.kernel.org, linux-rtc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Heiko Stuebner , Josua Mayer , Andreas Kemnade , Arnd Bergmann , Daniel Palmer , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Geert Uytterhoeven , Kuninori Morimoto Subject: [PATCH v5 1/7] dt-bindings: Add vendor prefix for Netronix, Inc. Date: Tue, 1 Dec 2020 02:15:07 +0100 Message-Id: <20201201011513.1627028-2-j.neuschaefer@gmx.net> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201011513.1627028-1-j.neuschaefer@gmx.net> References: <20201201011513.1627028-1-j.neuschaefer@gmx.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:FyMg03WbZYrN6o5UWchWZJEKNCGTDCfkSp/27SBR7cFGJC8SORp IBE5E2Gyp78ZTRYBNUSBAqmgGFEluAVNiWoFkVT+iUiof2Qjzp5JzYp9Oqo18BspG+mJV1s i8iDtW7ka6pcjlV8bg9qwDGnQ5aIGOSjCEbb/fs8NKQZfGCjw5mW4BD2yWM7PuAGqHpqYNn z+T2+vmxpdMTGQMsEPvOQ== X-UI-Out-Filterresults: notjunk:1; V03:K0:gqmnMUIVyf8=:HHqzUP80JNa5jQucQSmXMX 61vPKxGzQoq8PbfTLaSAmDfdnrjlwAGPZBM1aeYHE+iEtETuqjSTilPrPAE0e9zk+iJ6PjL7S jkRfiEPsA0heclhSHpLl0EKC0Nta+z+29tP1X1/JnauKS42ic033Ki0BpgKoGgiR7hXrmZX9l JzIrGRkyYFZMVvfi6D3Krwe1Z8+f38ydd3rNPCjsR/poQzKwBalbvN31dY9Ig/pYBNIymOexn RiOn5BQlZl22QXSX8mLi8vQ/4BqzFWq30DpwNRBgZv6ERNkpPMF9BD7n0zNeaY3SRjRfSFHgC ju+c95tl3vC1lPKwZ/Rlm8/8i256DhohfOns2kqsQX5gnC041BfV1SS5ooKM06afXyLvQ8B0G OYBsPGNxtU0zCP8ER/QTHqQP+8VRZEy2jwRP4U9lDH/tb5Dp8M4eYKSH/+FukWYMhq3vGBr5F THblPmGB2SFinz/YnLXXzKLSUXjRP+fltgVCOmTFmtJYFsSHctsriJ1XMi5LEry4AvXXP3pb5 0jaMPeH6dvUg2zElwDiLogb7QvXWCbMFAs5LjtRdveapHkQMZCsKQuUhvyXX9XZeDwdapW1dR JMPVdOuNyt8bG06Ae9vrIjhY+7W/iEBml+Mxq2MzHWUhkyb0GIw4z4lcztN/fS4m7y0+6Elgl Ib5pXaukX7QPlrRtCLqg5GBaK/9g208uIClOf7zbs3ra3kUymt1R/ffJx1K4Am2k4QTOB5WtX 6wcFY5wHVqcP28EsEeZS+WHwVuN0UWde+9WSHz3aTTTYqdBZQcmIX2e8dl1DUps+DdLpdPZxC hMqRxEOu10V2ctRiF9TYQ7SgWZ+iVgBaUQw+aQmW3tMIv4J9K/bwgYA9PTL4iPmdtLN1hZIcC gZ17LKy76qejSQlg8EEw== Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Netronix, Inc. (http://www.netronixinc.com/) makes ebook reader board designs, which are for example used in Kobo and Tolino devices. An alternative prefix for Netronix would be "ntx", which is already used in code released by Netronix. It is shorter, but perhaps less clear. Signed-off-by: Jonathan Neuschäfer Acked-by: Rob Herring --- v4, v5: - No changes v3: - https://lore.kernel.org/lkml/20200924192455.2484005-2-j.neuschaefer@gmx.net/ - Add Acked-by tag v2: - No changes --- Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 1 file changed, 2 insertions(+) -- 2.29.2 diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml index 2735be1a84709..cbf28f992b71e 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml @@ -726,6 +726,8 @@ patternProperties: description: Broadcom Corporation (formerly NetLogic Microsystems) "^netron-dy,.*": description: Netron DY + "^netronix,.*": + description: Netronix, Inc. "^netxeon,.*": description: Shenzhen Netxeon Technology CO., LTD "^neweast,.*": From patchwork Tue Dec 1 01:15:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?J=2E_Neusch=C3=A4fer?= X-Patchwork-Id: 336231 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81BC8C71156 for ; Tue, 1 Dec 2020 03:19:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2B2AF20725 for ; Tue, 1 Dec 2020 03:19:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=gmx.net header.i=@gmx.net header.b="FSlC2zyl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727612AbgLADSt (ORCPT ); Mon, 30 Nov 2020 22:18:49 -0500 Received: from mout.gmx.net ([212.227.17.20]:45867 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725859AbgLADSs (ORCPT ); Mon, 30 Nov 2020 22:18:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1606792583; bh=oMV1BsE+zyZdphaHIIA7I4yA5HiRt24ClTAmEH7qgi0=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=FSlC2zyl4E9+Oh6GYRbIopFfsFjQ04dd7R4VGLqCIeMzxder+iELESfFECrhgpBlo hVxPYtJK1pFtnywtp7qbxaVyMMrp8DqrJ2D5shTdOrzwgHFvBxH3h6oseY45tvn6EY EU1zhK06FhWuVl2Y2kEYv6Y4+BRZx7wjDpQ6j5Go= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from longitude ([37.201.214.162]) by mail.gmx.com (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MacOQ-1kDMUP2AYs-00c7ur; Tue, 01 Dec 2020 04:16:23 +0100 From: =?utf-8?q?Jonathan_Neusch=C3=A4fer?= To: linux-kernel@vger.kernel.org Cc: Lee Jones , Rob Herring , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Thierry Reding , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?b?w7ZuaWc=?= , Alessandro Zummo , Alexandre Belloni , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Sam Ravnborg , Linus Walleij , Heiko Stuebner , Stephan Gerhold , Lubomir Rintel , Mark Brown , allen , Mauro Carvalho Chehab , "David S. Miller" , devicetree@vger.kernel.org, linux-pwm@vger.kernel.org, linux-rtc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Heiko Stuebner , Josua Mayer , Andreas Kemnade , Arnd Bergmann , Daniel Palmer , Andy Shevchenko , Rob Herring Subject: [PATCH v5 2/7] dt-bindings: mfd: Add binding for Netronix embedded controller Date: Tue, 1 Dec 2020 02:15:08 +0100 Message-Id: <20201201011513.1627028-3-j.neuschaefer@gmx.net> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201011513.1627028-1-j.neuschaefer@gmx.net> References: <20201201011513.1627028-1-j.neuschaefer@gmx.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:Vz3vJigvuTH3GzmHI6h4VbmnOp32aE5QRt0GwXcvdVOzIzllyWS i8BVZm0ZfXdpS+MZsTHTJIF8KmT59/cOCJpyhN8zJJp2BnJcDy6bls40rSuAlntjAyXQi8u jUQ3RMxz2WtfSS9a/XLotrBYWsQp6Zv8uCEBMn1rGB7UyIecwwbeIGN5+Xp1EzinOPsO+GA +W7oFQX9jiIxQyb2t+3mw== X-UI-Out-Filterresults: notjunk:1; V03:K0:QQq6oDqUxps=:6T85xH+8S1ysT0AdqBKdwb nXmG6NCoxCSbF1c1dIQDo3gGyPzoiAZXMTppcsdD8eFzmnJoOuSaUrn5hYLSm3O/nfglFO69Q 6bXObsFyagScL01w/nbxYqf9gcto8myDVKxoMxaU6QAFchz746ubYR5PqsapaLQ2YRc/RpgiY LurIj3IyNEBNG0IvB3fmJ1tOD8DBsun5CZrKSAmcAvt61a+1Ji1ktJVKcBR+3By9+a1pKeWAQ UV/HX3GMDWrU1J9dJGd5wz0JVWOVx2ijOix9Bw8XJCUG538sheMEH82nX7DUT8Ul/zSdnV+8Q D4ltVBtFE54LcKULOMYeFuF6XoVxxU6RRp6ONH3mCTpyZSrVq0CdGOIdtDrTgDC7NA+ub9hO/ CsGp6QVsbBqcutezZe8usyo/0p5+aoEVLAOTJzOGEKMvhurY3Bt7+fDxJF13CxV1DlhhhzJXt n4+NWlG1XAZIejiH4VQlJ/NRsflU4YbHVIG6X6O6kAB4r8VdadrXl3GWGoHxjYbyOjJaJbEs1 gFP6PqL8KQPtAWpZCRaiXnWntjcTKCRNf26bQw7UsivGD8SLpGT9Vv2PSsJwT3XqAO5DRF4Ws 2AA+qCnoAeV9n8/egeO29BO6NXjh+HJNq/drbb9WcVgHEz5g6PcFmNoEimH4c4CRZJS6mCsKK fOUYPfa/9Py2ufiT23VxK474NWUZQgoiOU5l3/FmOBZnYVTGvWCIqU+2if2erW0dblh2yPOPT OjfoUHoBh9cC2rU0oCIokRZgaTLkWZV3XnNhhgciOkFqTp7H8g60X8C+/LaGd1OvetML7DZyL a+EKc7+e8+AMd9yLPLxLLu4Kfb9S44uEsopMVMFIGA1EQWYI/Zi8Eya0Y8r8oJRoLp+BnVKvZ Z/wyAbEJUaBLju9+NJlw== Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org This EC is found in e-book readers of multiple brands (e.g. Kobo, Tolino), and is typically implemented as a TI MSP430 microcontroller. It controls different functions of the system, such as power on/off, RTC, PWM for the backlight. The exact functionality provided can vary between boards. Signed-off-by: Jonathan Neuschäfer Reviewed-by: Rob Herring --- v5: - no changes v4: - Add R-b tag v3: - https://lore.kernel.org/lkml/20200924192455.2484005-3-j.neuschaefer@gmx.net/ - Remove binding in text form patch description again - Add additionalProperties: false - Remove interrupt-controller property from example - Merge pwm/rtc nodes into main node v2: - https://lore.kernel.org/lkml/20200905133230.1014581-3-j.neuschaefer@gmx.net/ - Add the plaintext DT binding for comparison --- .../bindings/mfd/netronix,ntxec.yaml | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/netronix,ntxec.yaml -- 2.29.2 diff --git a/Documentation/devicetree/bindings/mfd/netronix,ntxec.yaml b/Documentation/devicetree/bindings/mfd/netronix,ntxec.yaml new file mode 100644 index 0000000000000..59a630025f52f --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/netronix,ntxec.yaml @@ -0,0 +1,76 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/netronix,ntxec.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Netronix Embedded Controller + +maintainers: + - Jonathan Neuschäfer + +description: | + This EC is found in e-book readers of multiple brands (e.g. Kobo, Tolino), and + is typically implemented as a TI MSP430 microcontroller. + +properties: + compatible: + const: netronix,ntxec + + reg: + items: + - description: The I2C address of the EC + + system-power-controller: + type: boolean + description: See Documentation/devicetree/bindings/power/power-controller.txt + + interrupts: + minItems: 1 + description: + The EC can signal interrupts via a GPIO line + + "#pwm-cells": + const: 2 + description: | + Number of cells in a PWM specifier. + + The following PWM channels are supported: + - 0: The PWM channel controlled by registers 0xa1-0xa7 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + + ec: embedded-controller@43 { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_ntxec>; + + compatible = "netronix,ntxec"; + reg = <0x43>; + system-power-controller; + interrupt-parent = <&gpio4>; + interrupts = <11 IRQ_TYPE_EDGE_FALLING>; + #pwm-cells = <2>; + }; + }; + + backlight { + compatible = "pwm-backlight"; + pwms = <&ec 0 50000>; + power-supply = <&backlight_regulator>; + }; + + backlight_regulator: regulator-dummy { + compatible = "regulator-fixed"; + regulator-name = "backlight"; + }; From patchwork Tue Dec 1 01:15:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?J=2E_Neusch=C3=A4fer?= X-Patchwork-Id: 335284 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00, DATE_IN_PAST_03_06, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD170C64E7A for ; Tue, 1 Dec 2020 04:19:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 53CC1206C1 for ; Tue, 1 Dec 2020 04:19:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=gmx.net header.i=@gmx.net header.b="IhqYATjL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728162AbgLAESz (ORCPT ); Mon, 30 Nov 2020 23:18:55 -0500 Received: from mout.gmx.net ([212.227.17.20]:32837 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728157AbgLAESz (ORCPT ); Mon, 30 Nov 2020 23:18:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1606796195; bh=0T3UEocwsPn/hPlwviHgNjuCGpncWvUMjQ4Tlsxzh80=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=IhqYATjLL7QsiJjwL4ngR/QmDAFEX3VitoYbAo6MQTI3VpSFJBHabpyrxQvU+gYfD ahf7UgY89hVjItqaWh8EmaClcGVMcfGiiFSf6HANJ++F1umh0GTIQ/dj5jKE96Joq8 2vGahUvwHgXP9pm3LE0ZAEgHPgTXUrLhli6GD4w4= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from longitude ([37.201.214.162]) by mail.gmx.com (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Ma24y-1keRKJ2Q0S-00W0IV; Tue, 01 Dec 2020 05:16:35 +0100 From: =?utf-8?q?Jonathan_Neusch=C3=A4fer?= To: linux-kernel@vger.kernel.org Cc: Lee Jones , Rob Herring , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Thierry Reding , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?b?w7ZuaWc=?= , Alessandro Zummo , Alexandre Belloni , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Sam Ravnborg , Linus Walleij , Heiko Stuebner , Stephan Gerhold , Lubomir Rintel , Mark Brown , allen , Mauro Carvalho Chehab , "David S. Miller" , devicetree@vger.kernel.org, linux-pwm@vger.kernel.org, linux-rtc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Heiko Stuebner , Josua Mayer , Andreas Kemnade , Arnd Bergmann , Daniel Palmer , Andy Shevchenko Subject: [PATCH v5 3/7] mfd: Add base driver for Netronix embedded controller Date: Tue, 1 Dec 2020 02:15:09 +0100 Message-Id: <20201201011513.1627028-4-j.neuschaefer@gmx.net> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201011513.1627028-1-j.neuschaefer@gmx.net> References: <20201201011513.1627028-1-j.neuschaefer@gmx.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:KyjRfObjupaPBprNCa1SDzjAVtXseholwWLxTGq/p3HUSrrjt8v q9VE0NKgz7hIHZcqYHbxMsCSEvF+AA63pM81hozrtyOOVTJA23RKY723m22Izt/6/rC50q/ U7+UsQuFLDNbsrNl1KiqfR3Q+MPXbg8z/q7i+vX8Z7NsBFgdjeussdB6yy5/J6/tXms8o8q +gAm0n8b/v5TJV7jbGmVA== X-UI-Out-Filterresults: notjunk:1; V03:K0:oKUnGke6Oqw=:fpCTYWXTyYtrD5icjlHPQp /6A3AuflyXSkno0Tn3ROEgikVt77TltrmUhzsgXzumDMJg5o0hetJW786wBqcWrW0P6HHiPym gcrUEh5ebqFiAhVYSivicmrylFc7AW6ia6wnlyp5Zl4BkHLokpU8POA5JQQ6S6Dns3GVkia47 dWV9/Y8jL2fstDD48/ZUdTQk9TN7HEic/c5Pm+Rk7XFPWNp3JewfYHCcm+7iGCZvDakiEDSFu jXDRL62oZKl4H8Xif7ICBQw+dXfPlJIzwKwU/9eximFgyOdT98SyohTm7MnPzi1SCxJhy8Zvs flw7YRTi3XTVhgOCd9cwxfOxzEpVSBGT1Zc6GDOuBM66XYQnebDVQELn1qrHJ123p0wWcgVur Oyi1UUPz0XTy1KWau+2cRvRDK3DDxT4eI/BKukZcnao/3n0Vt/39QobAwIJ4NdzgU6wrgFSog 7BwcaJJUev3JvSVZ3X/93S/Kx56x5E33A9fPpX6c/qWJlu91/4fnmjKzx+u4/NH2qFU3wOdh0 mXOfFoAwU0a77/9Vgj/aLeH5olEITslE07+U7Hbd0feeoBHWMWtlxQ6jXgOQistTuxsnzNtyd e5UhJktXNAERGZsBIaqbCXr8Oe//BZNbJZ0pY2/n2leribNsvdj0miMjHESiinaNU4i0ZEa7F 6ORj2HqMtI3KN7fPhoKqazfvgudgxOUrPOhmsB14hjcSWNnlUhBCC4vi2cRoA7fxEAn00aFzK /loWXeLWCNLxXfbZq6Cj1SDJE2kmtOl+YZemo35qW3Z8e2lWHLbJj7p3oTCwoUzKUoIef6hrt 5nvY2cf1blfLBTLYqxU2W78qlgYNDfyMoTAOBeMvlc5Nx4tHrJCua+2fmuvb+Zw51SUf72kty Cvu3nyHaIDsjtepPFJrg== Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The Netronix embedded controller is a microcontroller found in some e-book readers designed by the original design manufacturer Netronix, Inc. It contains RTC, battery monitoring, system power management, and PWM functionality. This driver implements register access and version detection. Third-party hardware documentation is available at: https://github.com/neuschaefer/linux/wiki/Netronix-MSP430-embedded-controller The EC supports interrupts, but the driver doesn't make use of them so far. Signed-off-by: Jonathan Neuschäfer --- v5: - no changes v4: - https://lore.kernel.org/lkml/20201122222739.1455132-4-j.neuschaefer@gmx.net/ - include asm/unaligned.h after linux/* - Use put_unaligned_be16 instead of open-coded big-endian packing - Clarify that 0x90=0xff00 causes an error in downstream kernel too - Add commas after non-sentinel positions - ntxec.h: declare structs device and regmap - Replace WARN_ON usage and add comments to explain errors - Replace dev_alert with dev_warn when the result isn't handled - Change subdevice registration error message to dev_err - Declare ntxec_reg8 as returning __be16 - Restructure version detection code - Spell out ODM v3: - https://lore.kernel.org/lkml/20200924192455.2484005-4-j.neuschaefer@gmx.net/ - Add (EC) to CONFIG_MFD_NTXEC prompt - Relicense as GPLv2 or later - Add email address to copyright line - remove empty lines in ntxec_poweroff and ntxec_restart functions - Split long lines - Remove 'Install ... handler' comments - Make naming of struct i2c_client parameter consistent - Remove struct ntxec_info - Rework 'depends on' lines in Kconfig, hard-depend on I2C, select REGMAP_I2C and MFD_CORE - Register subdevices via mfd_cells - Move 8-bit register conversion to ntxec.h v2: - https://lore.kernel.org/lkml/20200905133230.1014581-4-j.neuschaefer@gmx.net/ - Add a description of the device to the patch text - Unify spelling as 'Netronix embedded controller'. 'Netronix' is the proper name of the manufacturer, but 'embedded controller' is just a label that I have assigned to the device. - Switch to regmap, avoid regmap use in poweroff and reboot handlers. Inspired by cf84dc0bb40f4 ("mfd: rn5t618: Make restart handler atomic safe") - Use a list of known-working firmware versions instead of checking for a known-incompatible version - Prefix registers with NTXEC_REG_ - Define register values as constants - Various style cleanups as suggested by Lee Jones - Don't align = signs in struct initializers [Uwe Kleine-König] - Don't use dev_dbg for an error message - Explain sleep in poweroff handler - Remove (struct ntxec).client - Switch to .probe_new in i2c driver - Add .remove callback - Make CONFIG_MFD_NTXEC a tristate option --- drivers/mfd/Kconfig | 11 ++ drivers/mfd/Makefile | 1 + drivers/mfd/ntxec.c | 216 ++++++++++++++++++++++++++++++++++++++ include/linux/mfd/ntxec.h | 34 ++++++ 4 files changed, 262 insertions(+) create mode 100644 drivers/mfd/ntxec.c create mode 100644 include/linux/mfd/ntxec.h -- 2.29.2 diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 8b99a13669bfc..d96751f884dc6 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -990,6 +990,17 @@ config MFD_VIPERBOARD You need to select the mfd cell drivers separately. The drivers do not support all features the board exposes. +config MFD_NTXEC + tristate "Netronix embedded controller (EC)" + depends on OF || COMPILE_TEST + depends on I2C + select REGMAP_I2C + select MFD_CORE + help + Say yes here if you want to support the embedded controller found in + certain e-book readers designed by the original design manufacturer + Netronix. + config MFD_RETU tristate "Nokia Retu and Tahvo multi-function device" select MFD_CORE diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 1780019d24748..815c99b84019e 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -218,6 +218,7 @@ obj-$(CONFIG_MFD_INTEL_MSIC) += intel_msic.o obj-$(CONFIG_MFD_INTEL_PMC_BXT) += intel_pmc_bxt.o obj-$(CONFIG_MFD_PALMAS) += palmas.o obj-$(CONFIG_MFD_VIPERBOARD) += viperboard.o +obj-$(CONFIG_MFD_NTXEC) += ntxec.o obj-$(CONFIG_MFD_RC5T583) += rc5t583.o rc5t583-irq.o obj-$(CONFIG_MFD_RK808) += rk808.o obj-$(CONFIG_MFD_RN5T618) += rn5t618.o diff --git a/drivers/mfd/ntxec.c b/drivers/mfd/ntxec.c new file mode 100644 index 0000000000000..c1510711d7363 --- /dev/null +++ b/drivers/mfd/ntxec.c @@ -0,0 +1,216 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * The Netronix embedded controller is a microcontroller found in some + * e-book readers designed by the original design manufacturer Netronix, Inc. + * It contains RTC, battery monitoring, system power management, and PWM + * functionality. + * + * This driver implements register access, version detection, and system + * power-off/reset. + * + * Copyright 2020 Jonathan Neuschäfer + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define NTXEC_REG_VERSION 0x00 +#define NTXEC_REG_POWEROFF 0x50 +#define NTXEC_REG_POWERKEEP 0x70 +#define NTXEC_REG_RESET 0x90 + +#define NTXEC_POWEROFF_VALUE 0x0100 +#define NTXEC_POWERKEEP_VALUE 0x0800 +#define NTXEC_RESET_VALUE 0xff00 + +static struct i2c_client *poweroff_restart_client; + +static void ntxec_poweroff(void) +{ + int res; + u8 buf[3] = { NTXEC_REG_POWEROFF }; + struct i2c_msg msgs[] = { + { + .addr = poweroff_restart_client->addr, + .flags = 0, + .len = sizeof(buf), + .buf = buf, + }, + }; + + put_unaligned_be16(NTXEC_POWEROFF_VALUE, buf + 1); + + res = i2c_transfer(poweroff_restart_client->adapter, msgs, ARRAY_SIZE(msgs)); + if (res < 0) + dev_warn(&poweroff_restart_client->dev, + "Failed to power off (err = %d)\n", res); + + /* + * The time from the register write until the host CPU is powered off + * has been observed to be about 2.5 to 3 seconds. Sleep long enough to + * safely avoid returning from the poweroff handler. + */ + msleep(5000); +} + +static int ntxec_restart(struct notifier_block *nb, + unsigned long action, void *data) +{ + int res; + u8 buf[3] = { NTXEC_REG_RESET }; + /* + * NOTE: The lower half of the reset value is not sent, because sending + * it causes an I2C error. (The reset handler in the downstream driver + * does send the full two-byte value, but doesn't check the result). + */ + struct i2c_msg msgs[] = { + { + .addr = poweroff_restart_client->addr, + .flags = 0, + .len = sizeof(buf) - 1, + .buf = buf, + }, + }; + + put_unaligned_be16(NTXEC_RESET_VALUE, buf + 1); + + res = i2c_transfer(poweroff_restart_client->adapter, msgs, ARRAY_SIZE(msgs)); + if (res < 0) + dev_warn(&poweroff_restart_client->dev, + "Failed to restart (err = %d)\n", res); + + return NOTIFY_DONE; +} + +static struct notifier_block ntxec_restart_handler = { + .notifier_call = ntxec_restart, + .priority = 128, +}; + +static const struct regmap_config regmap_config = { + .name = "ntxec", + .reg_bits = 8, + .val_bits = 16, + .cache_type = REGCACHE_NONE, + .val_format_endian = REGMAP_ENDIAN_BIG, +}; + +static const struct mfd_cell ntxec_subdevices[] = { + { .name = "ntxec-rtc" }, + { .name = "ntxec-pwm" }, +}; + +static int ntxec_probe(struct i2c_client *client) +{ + struct ntxec *ec; + unsigned int version; + int res; + + ec = devm_kmalloc(&client->dev, sizeof(*ec), GFP_KERNEL); + if (!ec) + return -ENOMEM; + + ec->dev = &client->dev; + + ec->regmap = devm_regmap_init_i2c(client, ®map_config); + if (IS_ERR(ec->regmap)) { + dev_err(ec->dev, "Failed to set up regmap for device\n"); + return res; + } + + /* Determine the firmware version */ + res = regmap_read(ec->regmap, NTXEC_REG_VERSION, &version); + if (res < 0) { + dev_err(ec->dev, "Failed to read firmware version number\n"); + return res; + } + + /* Bail out if we encounter an unknown firmware version */ + switch (version) { + case 0xd726: /* found in Kobo Aura */ + break; + default: + dev_err(ec->dev, + "Netronix embedded controller version %04x is not supported.\n", + version); + return -ENODEV; + } + + dev_info(ec->dev, + "Netronix embedded controller version %04x detected.\n", version); + + if (of_device_is_system_power_controller(ec->dev->of_node)) { + /* + * Set the 'powerkeep' bit. This is necessary on some boards + * in order to keep the system running. + */ + res = regmap_write(ec->regmap, NTXEC_REG_POWERKEEP, + NTXEC_POWERKEEP_VALUE); + if (res < 0) + return res; + + if (poweroff_restart_client) + /* + * Another instance of the driver already took + * poweroff/restart duties. + */ + dev_err(ec->dev, "poweroff_restart_client already assigned\n"); + else + poweroff_restart_client = client; + + if (pm_power_off) + /* Another driver already registered a poweroff handler. */ + dev_err(ec->dev, "pm_power_off already assigned\n"); + else + pm_power_off = ntxec_poweroff; + + res = register_restart_handler(&ntxec_restart_handler); + if (res) + dev_err(ec->dev, + "Failed to register restart handler: %d\n", res); + } + + i2c_set_clientdata(client, ec); + + res = devm_mfd_add_devices(ec->dev, PLATFORM_DEVID_NONE, ntxec_subdevices, + ARRAY_SIZE(ntxec_subdevices), NULL, 0, NULL); + if (res) + dev_err(ec->dev, "Failed to add subdevices: %d\n", res); + + return res; +} + +static int ntxec_remove(struct i2c_client *client) +{ + if (client == poweroff_restart_client) { + poweroff_restart_client = NULL; + pm_power_off = NULL; + unregister_restart_handler(&ntxec_restart_handler); + } + + return 0; +} + +static const struct of_device_id of_ntxec_match_table[] = { + { .compatible = "netronix,ntxec", }, + {} +}; + +static struct i2c_driver ntxec_driver = { + .driver = { + .name = "ntxec", + .of_match_table = of_ntxec_match_table, + }, + .probe_new = ntxec_probe, + .remove = ntxec_remove, +}; +module_i2c_driver(ntxec_driver); diff --git a/include/linux/mfd/ntxec.h b/include/linux/mfd/ntxec.h new file mode 100644 index 0000000000000..b1de91f4fdcad --- /dev/null +++ b/include/linux/mfd/ntxec.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright 2020 Jonathan Neuschäfer + * + * Register access and version information for the Netronix embedded + * controller. + */ + +#ifndef NTXEC_H +#define NTXEC_H + +#include + +struct device; +struct regmap; + +struct ntxec { + struct device *dev; + struct regmap *regmap; +}; + +/* + * Some registers, such as the battery status register (0x41), are in + * big-endian, but others only have eight significant bits, which are in the + * first byte transmitted over I2C (the MSB of the big-endian value). + * This convenience function converts an 8-bit value to 16-bit for use in the + * second kind of register. + */ +static inline __be16 ntxec_reg8(u8 value) +{ + return value << 8; +} + +#endif From patchwork Tue Dec 1 01:15:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?J=2E_Neusch=C3=A4fer?= X-Patchwork-Id: 335282 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00, DATE_IN_PAST_03_06, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16432C64E8A for ; Tue, 1 Dec 2020 05:19:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BBC9A2168B for ; Tue, 1 Dec 2020 05:19:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=gmx.net header.i=@gmx.net header.b="jzFWy995" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726560AbgLAFTE (ORCPT ); Tue, 1 Dec 2020 00:19:04 -0500 Received: from mout.gmx.net ([212.227.17.20]:46511 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725902AbgLAFTE (ORCPT ); Tue, 1 Dec 2020 00:19:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1606799806; bh=rPRdtpWM0wkMSizwG2+RY2+Q923cBhHJhfRb9IexAnY=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=jzFWy995Y61nuOYwp9YyhrZOx2+zhdBFSCseZfeOF1rd+BKRQwPpsy6F087vIODzE ywhJYthsJ4ZbNilGNfQjPNpnMYYl9v46lJKXQlJRZjtkVBBwyskJI8/Em6wxX615AQ ySyC/73nS+Ahv0rY+3xxsyfWHhCYFwcDmya0tf/0= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from longitude ([37.201.214.162]) by mail.gmx.com (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MXXuB-1kguA51Akx-00Z2Ei; Tue, 01 Dec 2020 06:16:46 +0100 From: =?utf-8?q?Jonathan_Neusch=C3=A4fer?= To: linux-kernel@vger.kernel.org Cc: Lee Jones , Rob Herring , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Thierry Reding , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?b?w7ZuaWc=?= , Alessandro Zummo , Alexandre Belloni , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Sam Ravnborg , Linus Walleij , Heiko Stuebner , Stephan Gerhold , Lubomir Rintel , Mark Brown , allen , Mauro Carvalho Chehab , "David S. Miller" , devicetree@vger.kernel.org, linux-pwm@vger.kernel.org, linux-rtc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Heiko Stuebner , Josua Mayer , Andreas Kemnade , Arnd Bergmann , Daniel Palmer , Andy Shevchenko Subject: [PATCH v5 4/7] pwm: ntxec: Add driver for PWM function in Netronix EC Date: Tue, 1 Dec 2020 02:15:10 +0100 Message-Id: <20201201011513.1627028-5-j.neuschaefer@gmx.net> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201011513.1627028-1-j.neuschaefer@gmx.net> References: <20201201011513.1627028-1-j.neuschaefer@gmx.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:ca9Z38lTTxyARgHEHV/TktM9KWbcJaj4CY+vU2TiPpIJwGSunTb 55PpShIGhQFE0ZR0tNe5vZKaeJSdMBc04PI/nj/IAvHliRKtAw/6YyxHPGsGS/J+Gt8FSeu xGwCiX0VzpeuvquQm9bDK+dIJDdsDk1Uu34lP1oPCvwmUu+w4hTmG7zZ8vwNJyRSh+PMktb +VAXcSElqilddkKXoaDTg== X-UI-Out-Filterresults: notjunk:1; V03:K0:Qc0L3ZXK+CA=:BdRXXwDu8Gz9j8B/JfK7Xl PRT9PnCT+ybLIlKh9Bij3I/N2unthD7Wm8miRR1+KgjufX7ZNUpnezjJyglrisUccrd+4sfe+ vCxY2IMC3+t5BaUwSFgxp8wrC27RnoLbBdqZFg1T3e2C7XDk+KqFEmKO5A5VUzTJ55JvVcb6A /wwZWxtf2osIMiHhlPf3+DBihyIBdbrCvmEKFjeYpcsOcKvNB4Pztq37tH0QP1xzr2bKikXSg pGQrSx3vIA7iAKcgV6833mO37myN/wMgFseMWnlZwiO9G5/yXUEwUgM1w36MrxF0u6AFIK4zf OtXOoATyx0agzH8RjG+tux+gHeVP0e/aX4mfNviDis0lHA8QRTzSToggHzh3rGOjfVSZp9Y9s y0AKornW3xgGZqdTWdH/fRlDw0e8FyBjA4JzvIy6DRDKFFfdHx+KjS9RQ3mNDhO3zLIK7+6PM WcQGa46xRf8QkwBP+Fdl2z9pPNO/9pp+VXbPo+ZgFEsnhjtxky1zLfKFFgJMDrKXgWsTj3Dm3 G8mtXFSH32bXDfxyrel3qxVNXdmFQC3h/BmZI2jqy9j24yEyCI9u0Tzm0EYLxJNsGTNY/7lPX QdVRDMBXy7zDMXuKY5au1fqTzfousduQIcA7NwKDDq1ejqSIeeEidASn/dZOUnJV++tTrWHzk 3m8x9Kd0+QsKyYlb8nNKO8ryO9kcxssCiBl4ei5FWw+dHA9GEh1dTg6SfXef3BoCJcmrmGbY5 lFOqQuRToVW+yiVgYdP0tdTiHgQdFSLAdHC3SRTN+guUK2vQjNSErDoZLoElsC0YbIuMeFIrn EAE8B8lJmgSiIlOl1BitgjS9MWJjE4Gy8WBbaRwgzPGxvf+AziW2+XjHReuKIoXfsNazu0o6w qGNVa6hyPrYPvjfyzlng== Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The Netronix EC provides a PWM output which is used for the backlight on some ebook readers. This patches adds a driver for the PWM output. The .get_state callback is not implemented, because the PWM state can't be read back from the hardware. Signed-off-by: Jonathan Neuschäfer --- v5: - Avoid truncation of period and duty cycle to 32 bits - Make ntxec_pwm_ops const - Use regmap_multi_reg_write - Add comment about get_state to ntxec_pwm_ops - Add comments about non-atomicity of (period, duty cycle) update v4: - https://lore.kernel.org/lkml/20201122222739.1455132-5-j.neuschaefer@gmx.net/ - Document hardware/driver limitations - Only accept normal polarity - Fix a typo ("zone" -> "zero") - change MAX_PERIOD_NS to 0xffff * 125 - Clamp period to the maximum rather than returning an error - Rename private struct pointer to priv - Rearrage control flow in _probe to save a few lines and a temporary variable - Add missing MODULE_ALIAS line - Spell out ODM v3: - https://lore.kernel.org/lkml/20200924192455.2484005-5-j.neuschaefer@gmx.net/ - Relicense as GPLv2 or later - Add email address to copyright line - Remove OF compatible string and don't include linux/of_device.h - Fix bogus ?: in return line - Don't use a comma after sentinels - Avoid ret |= ... pattern - Move 8-bit register conversion to ntxec.h v2: - https://lore.kernel.org/lkml/20200905133230.1014581-6-j.neuschaefer@gmx.net/ - Various grammar and style improvements, as suggested by Uwe Kleine-König, Lee Jones, and Alexandre Belloni - Switch to regmap - Prefix registers with NTXEC_REG_ - Add help text to the Kconfig option - Use the .apply callback instead of the old API - Add a #define for the time base (125ns) - Don't change device state in .probe; this avoids multiple problems - Rework division and overflow check logic to perform divisions in 32 bits - Avoid setting duty cycle to zero, to work around a hardware quirk --- drivers/pwm/Kconfig | 8 ++ drivers/pwm/Makefile | 1 + drivers/pwm/pwm-ntxec.c | 173 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 182 insertions(+) create mode 100644 drivers/pwm/pwm-ntxec.c -- 2.29.2 diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index 63be5362fd3a5..815f329ed5b46 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig @@ -350,6 +350,14 @@ config PWM_MXS To compile this driver as a module, choose M here: the module will be called pwm-mxs. +config PWM_NTXEC + tristate "Netronix embedded controller PWM support" + depends on MFD_NTXEC + help + Say yes here if you want to support the PWM output of the embedded + controller found in certain e-book readers designed by the original + design manufacturer Netronix. + config PWM_OMAP_DMTIMER tristate "OMAP Dual-Mode Timer PWM support" depends on OF diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile index cbdcd55d69eef..1deb29e6ae8e5 100644 --- a/drivers/pwm/Makefile +++ b/drivers/pwm/Makefile @@ -32,6 +32,7 @@ obj-$(CONFIG_PWM_MESON) += pwm-meson.o obj-$(CONFIG_PWM_MEDIATEK) += pwm-mediatek.o obj-$(CONFIG_PWM_MTK_DISP) += pwm-mtk-disp.o obj-$(CONFIG_PWM_MXS) += pwm-mxs.o +obj-$(CONFIG_PWM_NTXEC) += pwm-ntxec.o obj-$(CONFIG_PWM_OMAP_DMTIMER) += pwm-omap-dmtimer.o obj-$(CONFIG_PWM_PCA9685) += pwm-pca9685.o obj-$(CONFIG_PWM_PXA) += pwm-pxa.o diff --git a/drivers/pwm/pwm-ntxec.c b/drivers/pwm/pwm-ntxec.c new file mode 100644 index 0000000000000..d36c8f8c0a958 --- /dev/null +++ b/drivers/pwm/pwm-ntxec.c @@ -0,0 +1,173 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * The Netronix embedded controller is a microcontroller found in some + * e-book readers designed by the original design manufacturer Netronix, Inc. + * It contains RTC, battery monitoring, system power management, and PWM + * functionality. + * + * This driver implements PWM output. + * + * Copyright 2020 Jonathan Neuschäfer + * + * Limitations: + * - The get_state callback is not implemented, because the current state of + * the PWM output can't be read back from the hardware. + * - The hardware can only generate normal polarity output. + * - The period and duty cycle can't be changed together in one atomic action. + */ + +#include +#include +#include +#include +#include +#include + +struct ntxec_pwm { + struct device *dev; + struct ntxec *ec; + struct pwm_chip chip; +}; + +static struct ntxec_pwm *pwmchip_to_priv(struct pwm_chip *chip) +{ + return container_of(chip, struct ntxec_pwm, chip); +} + +#define NTXEC_REG_AUTO_OFF_HI 0xa1 +#define NTXEC_REG_AUTO_OFF_LO 0xa2 +#define NTXEC_REG_ENABLE 0xa3 +#define NTXEC_REG_PERIOD_LOW 0xa4 +#define NTXEC_REG_PERIOD_HIGH 0xa5 +#define NTXEC_REG_DUTY_LOW 0xa6 +#define NTXEC_REG_DUTY_HIGH 0xa7 + +/* + * The time base used in the EC is 8MHz, or 125ns. Period and duty cycle are + * measured in this unit. + */ +#define TIME_BASE_NS 125 + +/* + * The maximum input value (in nanoseconds) is determined by the time base and + * the range of the hardware registers that hold the converted value. + * It fits into 32 bits, so we can do our calculations in 32 bits as well. + */ +#define MAX_PERIOD_NS (TIME_BASE_NS * 0xffff) + +static int ntxec_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm_dev, + const struct pwm_state *state) +{ + struct ntxec_pwm *priv = pwmchip_to_priv(pwm_dev->chip); + unsigned int period, duty; + struct reg_sequence regs[] = { + { NTXEC_REG_PERIOD_HIGH }, + { NTXEC_REG_PERIOD_LOW }, + { NTXEC_REG_DUTY_HIGH }, + { NTXEC_REG_DUTY_LOW } + }; + int res; + + if (state->polarity != PWM_POLARITY_NORMAL) + return -EINVAL; + + period = min_t(u64, state->period, MAX_PERIOD_NS); + duty = min_t(u64, state->duty_cycle, period); + + period /= TIME_BASE_NS; + duty /= TIME_BASE_NS; + + /* + * Changes to the period and duty cycle take effect as soon as the + * corresponding low byte is written, so the hardware may be configured + * to an inconsistent state after the period is written and before the + * duty cycle is fully written. If, in such a case, the old duty cycle + * is longer than the new period, the EC may output 100% for a moment. + */ + + regs[0].def = ntxec_reg8(period >> 8); + regs[1].def = ntxec_reg8(period); + regs[2].def = ntxec_reg8(duty >> 8); + regs[3].def = ntxec_reg8(duty); + + res = regmap_multi_reg_write(priv->ec->regmap, regs, ARRAY_SIZE(regs)); + if (res) + return res; + + /* + * Writing a duty cycle of zero puts the device into a state where + * writing a higher duty cycle doesn't result in the brightness that it + * usually results in. This can be fixed by cycling the ENABLE register. + * + * As a workaround, write ENABLE=0 when the duty cycle is zero. + */ + if (state->enabled && duty != 0) { + res = regmap_write(priv->ec->regmap, NTXEC_REG_ENABLE, ntxec_reg8(1)); + if (res) + return res; + + /* Disable the auto-off timer */ + res = regmap_write(priv->ec->regmap, NTXEC_REG_AUTO_OFF_HI, ntxec_reg8(0xff)); + if (res) + return res; + + return regmap_write(priv->ec->regmap, NTXEC_REG_AUTO_OFF_LO, ntxec_reg8(0xff)); + } else { + return regmap_write(priv->ec->regmap, NTXEC_REG_ENABLE, ntxec_reg8(0)); + } +} + +static const struct pwm_ops ntxec_pwm_ops = { + .owner = THIS_MODULE, + .apply = ntxec_pwm_apply, + /* + * No .get_state callback, because the current state cannot be read + * back from the hardware. + */ +}; + +static int ntxec_pwm_probe(struct platform_device *pdev) +{ + struct ntxec *ec = dev_get_drvdata(pdev->dev.parent); + struct ntxec_pwm *priv; + struct pwm_chip *chip; + + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv->ec = ec; + priv->dev = &pdev->dev; + + platform_set_drvdata(pdev, priv); + + chip = &priv->chip; + chip->dev = &pdev->dev; + chip->ops = &ntxec_pwm_ops; + chip->base = -1; + chip->npwm = 1; + + return pwmchip_add(chip); +} + +static int ntxec_pwm_remove(struct platform_device *pdev) +{ + struct ntxec_pwm *priv = platform_get_drvdata(pdev); + struct pwm_chip *chip = &priv->chip; + + return pwmchip_remove(chip); +} + +static struct platform_driver ntxec_pwm_driver = { + .driver = { + .name = "ntxec-pwm", + }, + .probe = ntxec_pwm_probe, + .remove = ntxec_pwm_remove, +}; +module_platform_driver(ntxec_pwm_driver); + +MODULE_AUTHOR("Jonathan Neuschäfer "); +MODULE_DESCRIPTION("PWM driver for Netronix EC"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:ntxec-pwm"); From patchwork Tue Dec 1 01:15:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?J=2E_Neusch=C3=A4fer?= X-Patchwork-Id: 335280 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00, DATE_IN_PAST_03_06, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CEF3BC64E7A for ; Tue, 1 Dec 2020 06:19:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 61AE62087D for ; Tue, 1 Dec 2020 06:19:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=gmx.net header.i=@gmx.net header.b="UNvuRN3k" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725962AbgLAGTZ (ORCPT ); Tue, 1 Dec 2020 01:19:25 -0500 Received: from mout.gmx.net ([212.227.15.15]:46605 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725916AbgLAGTZ (ORCPT ); Tue, 1 Dec 2020 01:19:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1606803416; bh=VMPvoAHYxmMDRj16a7w6y8QFmIsE7CM4wC3v0+745VI=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=UNvuRN3kxgfErz8FEqmM8DRWoF+Byr7eEVqkOMqMTkELQKccaLaCo+daNw1q/ckLY 2tycyJumEaBWR9U7ZUbi82e7/Zsc5Hp/Wya998sQnw9TEc0cY12YoS/xltR+7xHYW9 8o0aE2Xj76UfDoNYSYSUVprqs2xnpVY4IZ+08J8s= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from longitude ([37.201.214.162]) by mail.gmx.com (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MJE2D-1kUmGZ1Wih-00Kcsh; Tue, 01 Dec 2020 07:16:56 +0100 From: =?utf-8?q?Jonathan_Neusch=C3=A4fer?= To: linux-kernel@vger.kernel.org Cc: Lee Jones , Rob Herring , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Thierry Reding , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?b?w7ZuaWc=?= , Alessandro Zummo , Alexandre Belloni , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Sam Ravnborg , Linus Walleij , Heiko Stuebner , Stephan Gerhold , Lubomir Rintel , Mark Brown , allen , Mauro Carvalho Chehab , "David S. Miller" , devicetree@vger.kernel.org, linux-pwm@vger.kernel.org, linux-rtc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Heiko Stuebner , Josua Mayer , Andreas Kemnade , Arnd Bergmann , Daniel Palmer , Andy Shevchenko Subject: [PATCH v5 5/7] rtc: New driver for RTC in Netronix embedded controller Date: Tue, 1 Dec 2020 02:15:11 +0100 Message-Id: <20201201011513.1627028-6-j.neuschaefer@gmx.net> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201011513.1627028-1-j.neuschaefer@gmx.net> References: <20201201011513.1627028-1-j.neuschaefer@gmx.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:/vWLyRziBMYITZyheOSqHmiaF6RCH+TYOX+X/GMCIlBeY/rZZJU PUSz77dtX23p4Z7f1nMURNpe9z3mZvpn3jTNWTTPFmoiVW/aaNGckIXU6z4RuGP56HhcPRq cd3g7Q8gVfmqxLAqNDWV11QxZuvhDCjcVktf4vf2zsLvNAAUBDKUlfqijs1U6VkIg8QKZpE GUG+iRnYR3COFGNXpaTVg== X-UI-Out-Filterresults: notjunk:1; V03:K0:dzt7iPwBz3c=:6s0zoM/ez4jfPyYgCjZbYE xHsAbOJA2aiPk1ASYNj9rOReO3YgJ/CYnATxql7wq6PcMTHToVJF5SB1TTG25cTFyNUOwxezH Kd2f4xAPMOcw2ZUyJf7Ip1uvrW53i4+JHED+9iDDanwXmdB3igrvTK7ynwEpmleFOnmIQ4wZ2 Uvii8b7PuV1Vx8IH2G1spHq1C5k0EVj8Ni6gqvUk+KPpjikn1iF5+5OMzve2NpS7BCFjkQ7+g tB1LPWB0rUSFcDtm9Zheq7j6KQsJM+PAE1dzftTfsc+tY7UtBejrACRc39zF5lNkLIqIuU/rz Jn8zpf86xfpSzMu+VPH6Lq02pTxvBEKpZzPsT5VtChWEc5UQip6bBjP+rxoG/X/FWzM4bDphj fr75QF6yoxohaAzox/zPEn97ql3o6TUmN4VFkJfk7mCFnBpxSmW62jI7qsNwS6By/nuvopUl9 VZJamELtqEvjTX3T6zLrNS1v5bJyn80TlgS4CRU+Yt54Ube7PlLloLzId2aqpJnYkrElo9h4M Ax2yPMBEw5gR3CuTv71Q110nB/aqlLGI0maHsyqNIunKwc+Wz5T3xADd9JTsBIhnlRHIMSUe1 sAgG+kFMbluLtjZpMJ7K3cWKoJ6LWfl8PS8XqTsNpggGrlBc3ejNUBdLGwaPNSM3VDSFrekQC +PK7WzRmOmNEzjO/4cTzgtXVf9Delru4n5siu0zWpGGVREnN5gQzhsp1ZvsqSCp8BFlmjy1Pz aLf7ROTgouKpjXt9oZIuecCk/ZmmdMBboBgezB5CiQIhZJc7ouNnIq1dXF8Bzr0wFelTJ0RrN E+FM+L0gr7Vcr88YAugi/l6Ec5zuVB4XEZ1DQb09uNccwuX+O8coSTrkkmT9j7F4dzP7iC2Yk sLhxCfTjFU8+Wocaocew== Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org With this driver, mainline Linux can keep its time and date in sync with the vendor kernel. Advanced functionality like alarm and automatic power-on is not yet supported. Signed-off-by: Jonathan Neuschäfer Acked-by: Alexandre Belloni --- v5: - Add Alexandre Belloni's A-b - Use regmap_multi_reg_write v4: - https://lore.kernel.org/lkml/20201122222739.1455132-6-j.neuschaefer@gmx.net/ - Remove "driver" from Kconfig entry for consistency with most other entries - Add missing MODULE_ALIAS line - Give NTXEC_REG_READ_ macros longer names - Solve the read tearing issue using Alexandre Belloni's algorithm - Solve the write tearing issue using Uwe Kleine-König's algorithm - Spell out ODM v3: - https://lore.kernel.org/lkml/20200924192455.2484005-6-j.neuschaefer@gmx.net/ - Add email address to copyright line - Remove OF compatible string and don't include linux/of_device.h - Don't use a comma after sentinels - Avoid ret |= ... pattern - Move 8-bit register conversion to ntxec.h - Relicense as GPLv2 or later v2: - https://lore.kernel.org/lkml/20200905133230.1014581-7-j.neuschaefer@gmx.net/ - Rework top-of-file comment [Lee Jones] - Sort the #include lines [Alexandre Belloni] - don't align = signs in struct initializers [Uwe Kleine-König] - Switch to regmap - Fix register number used to read minutes and seconds - Prefix registers with NTXEC_REG_ - Add help text to the Kconfig option - Use devm_rtc_allocate_device and rtc_register_device, set ->range_min and ->range_max --- drivers/rtc/Kconfig | 8 +++ drivers/rtc/Makefile | 1 + drivers/rtc/rtc-ntxec.c | 143 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 152 insertions(+) create mode 100644 drivers/rtc/rtc-ntxec.c -- 2.29.2 diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 65ad9d0b47ab1..fe009949728b3 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig @@ -1311,6 +1311,14 @@ config RTC_DRV_CROS_EC This driver can also be built as a module. If so, the module will be called rtc-cros-ec. +config RTC_DRV_NTXEC + tristate "Netronix embedded controller RTC" + depends on MFD_NTXEC + help + Say yes here if you want to support the RTC functionality of the + embedded controller found in certain e-book readers designed by the + original design manufacturer Netronix. + comment "on-CPU RTC drivers" config RTC_DRV_ASM9260 diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index bfb57464118d0..5f2a7582b2780 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile @@ -111,6 +111,7 @@ obj-$(CONFIG_RTC_DRV_MT7622) += rtc-mt7622.o obj-$(CONFIG_RTC_DRV_MV) += rtc-mv.o obj-$(CONFIG_RTC_DRV_MXC) += rtc-mxc.o obj-$(CONFIG_RTC_DRV_MXC_V2) += rtc-mxc_v2.o +obj-$(CONFIG_RTC_DRV_NTXEC) += rtc-ntxec.o obj-$(CONFIG_RTC_DRV_OMAP) += rtc-omap.o obj-$(CONFIG_RTC_DRV_OPAL) += rtc-opal.o obj-$(CONFIG_RTC_DRV_PALMAS) += rtc-palmas.o diff --git a/drivers/rtc/rtc-ntxec.c b/drivers/rtc/rtc-ntxec.c new file mode 100644 index 0000000000000..c7cff7802895b --- /dev/null +++ b/drivers/rtc/rtc-ntxec.c @@ -0,0 +1,143 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * The Netronix embedded controller is a microcontroller found in some + * e-book readers designed by the original design manufacturer Netronix, Inc. + * It contains RTC, battery monitoring, system power management, and PWM + * functionality. + * + * This driver implements access to the RTC time and date. + * + * Copyright 2020 Jonathan Neuschäfer + */ + +#include +#include +#include +#include +#include +#include + +struct ntxec_rtc { + struct device *dev; + struct ntxec *ec; +}; + +#define NTXEC_REG_WRITE_YEAR 0x10 +#define NTXEC_REG_WRITE_MONTH 0x11 +#define NTXEC_REG_WRITE_DAY 0x12 +#define NTXEC_REG_WRITE_HOUR 0x13 +#define NTXEC_REG_WRITE_MINUTE 0x14 +#define NTXEC_REG_WRITE_SECOND 0x15 + +#define NTXEC_REG_READ_YEAR_MONTH 0x20 +#define NTXEC_REG_READ_MDAY_HOUR 0x21 +#define NTXEC_REG_READ_MINUTE_SECOND 0x23 + +static int ntxec_read_time(struct device *dev, struct rtc_time *tm) +{ + struct ntxec_rtc *rtc = dev_get_drvdata(dev); + unsigned int value; + int res; + +retry: + res = regmap_read(rtc->ec->regmap, NTXEC_REG_READ_MINUTE_SECOND, &value); + if (res < 0) + return res; + + tm->tm_min = value >> 8; + tm->tm_sec = value & 0xff; + + res = regmap_read(rtc->ec->regmap, NTXEC_REG_READ_MDAY_HOUR, &value); + if (res < 0) + return res; + + tm->tm_mday = value >> 8; + tm->tm_hour = value & 0xff; + + res = regmap_read(rtc->ec->regmap, NTXEC_REG_READ_YEAR_MONTH, &value); + if (res < 0) + return res; + + tm->tm_year = (value >> 8) + 100; + tm->tm_mon = (value & 0xff) - 1; + + /* + * Read the minutes/seconds field again. If it changed since the first + * read, we can't assume that the values read so far are consistent, + * and should start from the beginning. + */ + res = regmap_read(rtc->ec->regmap, NTXEC_REG_READ_MINUTE_SECOND, &value); + if (res < 0) + return res; + + if (tm->tm_min != value >> 8 || tm->tm_sec != (value & 0xff)) + goto retry; + + return 0; +} + +static int ntxec_set_time(struct device *dev, struct rtc_time *tm) +{ + struct ntxec_rtc *rtc = dev_get_drvdata(dev); + + /* + * To avoid time overflows while we're writing the full date/time, + * set the seconds field to zero before doing anything else. For the + * next 59 seconds (plus however long it takes until the RTC's next + * update of the second field), the seconds field will not overflow + * into the other fields. + */ + struct reg_sequence regs[] = { + { NTXEC_REG_WRITE_SECOND, ntxec_reg8(0) }, + { NTXEC_REG_WRITE_YEAR, ntxec_reg8(tm->tm_year - 100) }, + { NTXEC_REG_WRITE_MONTH, ntxec_reg8(tm->tm_mon + 1) }, + { NTXEC_REG_WRITE_DAY, ntxec_reg8(tm->tm_mday) }, + { NTXEC_REG_WRITE_HOUR, ntxec_reg8(tm->tm_hour) }, + { NTXEC_REG_WRITE_MINUTE, ntxec_reg8(tm->tm_min) }, + { NTXEC_REG_WRITE_SECOND, ntxec_reg8(tm->tm_sec) }, + }; + + return regmap_multi_reg_write(rtc->ec->regmap, regs, ARRAY_SIZE(regs)); +} + +static const struct rtc_class_ops ntxec_rtc_ops = { + .read_time = ntxec_read_time, + .set_time = ntxec_set_time, +}; + +static int ntxec_rtc_probe(struct platform_device *pdev) +{ + struct rtc_device *dev; + struct ntxec_rtc *rtc; + + rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL); + if (!rtc) + return -ENOMEM; + + rtc->dev = &pdev->dev; + rtc->ec = dev_get_drvdata(pdev->dev.parent); + platform_set_drvdata(pdev, rtc); + + dev = devm_rtc_allocate_device(&pdev->dev); + if (IS_ERR(dev)) + return PTR_ERR(dev); + + dev->ops = &ntxec_rtc_ops; + dev->range_min = RTC_TIMESTAMP_BEGIN_2000; + dev->range_max = 9025257599LL; /* 2255-12-31 23:59:59 */ + + return rtc_register_device(dev); +} + +static struct platform_driver ntxec_rtc_driver = { + .driver = { + .name = "ntxec-rtc", + }, + .probe = ntxec_rtc_probe, +}; +module_platform_driver(ntxec_rtc_driver); + +MODULE_AUTHOR("Jonathan Neuschäfer "); +MODULE_DESCRIPTION("RTC driver for Netronix EC"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:ntxec-rtc"); From patchwork Tue Dec 1 01:15:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?J=2E_Neusch=C3=A4fer?= X-Patchwork-Id: 336228 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00, DATE_IN_PAST_06_12, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1EDCC71156 for ; Tue, 1 Dec 2020 07:19:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 655842087D for ; Tue, 1 Dec 2020 07:19:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=gmx.net header.i=@gmx.net header.b="dg6UYBrR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727791AbgLAHTe (ORCPT ); Tue, 1 Dec 2020 02:19:34 -0500 Received: from mout.gmx.net ([212.227.15.19]:43011 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727102AbgLAHTd (ORCPT ); Tue, 1 Dec 2020 02:19:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1606807025; bh=5CW4HOQArD0ga03PAufrXrrqr/PGZhg5w5QyN9LY5+w=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=dg6UYBrRE4m7GWZcAN2j1qNMHWUO0AYCJiSafjFy9jcQbH/SIOebw5Ds5kyt7OXO1 BdBYum4+sqr0YFVnqrCKym+4YGVZzihT+nnTngUyhKShWC/E1WiiAuepb1FbZsHa/a PD6+MQL1hRaxiRDSRjVnFsufu9H0x1HB+ZXhCpfM= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from longitude ([37.201.214.162]) by mail.gmx.com (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MuUnA-1jtXud0Y9C-00rUKI; Tue, 01 Dec 2020 08:17:05 +0100 From: =?utf-8?q?Jonathan_Neusch=C3=A4fer?= To: linux-kernel@vger.kernel.org Cc: Lee Jones , Rob Herring , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Thierry Reding , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?b?w7ZuaWc=?= , Alessandro Zummo , Alexandre Belloni , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Sam Ravnborg , Linus Walleij , Heiko Stuebner , Stephan Gerhold , Lubomir Rintel , Mark Brown , allen , Mauro Carvalho Chehab , "David S. Miller" , devicetree@vger.kernel.org, linux-pwm@vger.kernel.org, linux-rtc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Heiko Stuebner , Josua Mayer , Andreas Kemnade , Arnd Bergmann , Daniel Palmer , Andy Shevchenko Subject: [PATCH v5 6/7] MAINTAINERS: Add entry for Netronix embedded controller Date: Tue, 1 Dec 2020 02:15:12 +0100 Message-Id: <20201201011513.1627028-7-j.neuschaefer@gmx.net> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201011513.1627028-1-j.neuschaefer@gmx.net> References: <20201201011513.1627028-1-j.neuschaefer@gmx.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:0jQyFfee5jYVyk0F/4yqqagvTFNbSZgQo8QuIW7MRTI/7zgyN7O NUPnrSUmpRGSqdeGOZoszPfCMlM6oNVN7LlIDRyjrTDO/h2Qn2gaIC8vA5IhmuJ39Pooz36 nlM/3P1J61T/bKwoiQ9XGdmXuOgBPWty5Tp896ty8u15ZklcEffVY4tHUDmyeiTygJUFOMa 1jTKwKhGfkQhxC+YQ07JQ== X-UI-Out-Filterresults: notjunk:1; V03:K0:vBQhdFPsBIU=:sBSq7NRSzSOvrGYzREJRwQ JAUmJhJCCo2QWEY4ELIVfJ5db0D5qCziYoafcpbVi9eXgeGKsz9ly1m7kP9psevyA0CRzTaZk mx5ITA0z3I4XAI8elaakBesiuQ+olW0TtfQi6znOdrAF+NO9bBJl9T89X5RL3yA7JG5KV8/KJ 9nbLmVF7m9V8FRrZ38J4cavpIgH28qHVltqbnBaemvtcf+YwRnmNCmvQWer160oJmncM3WrKj LTnJZpfq4/dZv5OulQuNSWF/1c8KnSK7xvGPu02lRhFvLYsxDipAwcQ1ClynpJ1guu5JwfhK9 7d1n578hVnlwwfo2J1QM4HnCCT+uNNABew925vgnMJ5NESnLFoz0+7EGR31eMxUDtfzZLhnLQ ///6pfpoHKaJzyrJoqEWliVBJnmJa87kfP6L+x8YSuw7mpCGbNdFc6fDwOtoRdgJmNVgkOgQ5 eOq9bJqF+8AQOlHzCike98dTFbxR0iGQubXTmLV8MP1ascXtQgFHR5N2zwSCXIjURYKKUPbHm 3rTqYmp3jbMR8DujI1j/2VLzotzg/e72fGtYcRKQU+BbvbN8I/QWB/YFnlG8TER6TvTBMiKFT gR7XPxcXpnRlLNYrT1ovBNDA6YHoyL53yDlykYVZPGCnTnocnA5kb165snzA0lsxVemf6K8hn CAx81MvqazviJkZVLK4H+24IUmt4gHaXtZpMiGBDVM0bWbF0PzImjfhxNK1Dco1ck148nU7/z oQBOXXg3a2LArpzN/mKHYgaAwaVzDl8ZabZ+VIOymqwaXD/TJgvtUSi+bNBZOo/Ij9Ld7yABE nesgWiqzwgvsfPlj6OU0dJDO/0546Ey1TL91HlyI+zt+ilon/zM04bLCqqTRu4IJjrV8L+9P3 FkkPw9ub4bekq1pu3bAw== Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Let's make sure I'll notice when there are patches for the NTXEC drivers. Signed-off-by: Jonathan Neuschäfer --- v4, v5: - no changes v3: - https://lore.kernel.org/lkml/20200924192455.2484005-7-j.neuschaefer@gmx.net/ - Remove pwm and rtc bindings v2: - https://lore.kernel.org/lkml/20200905144503.1067124-2-j.neuschaefer@gmx.net/ - No changes --- MAINTAINERS | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.29.2 diff --git a/MAINTAINERS b/MAINTAINERS index 2daa6ee673f7f..9eedf3c1e1e09 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -12087,6 +12087,15 @@ F: include/net/netrom.h F: include/uapi/linux/netrom.h F: net/netrom/ +NETRONIX EMBEDDED CONTROLLER +M: Jonathan Neuschäfer +S: Maintained +F: Documentation/devicetree/bindings/mfd/netronix,ntxec.yaml +F: drivers/mfd/ntxec.c +F: drivers/pwm/pwm-ntxec.c +F: drivers/rtc/rtc-ntxec.c +F: include/linux/mfd/ntxec.h + NETRONOME ETHERNET DRIVERS M: Simon Horman R: Jakub Kicinski From patchwork Tue Dec 1 01:15:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?J=2E_Neusch=C3=A4fer?= X-Patchwork-Id: 336222 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00, DATE_IN_PAST_06_12, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 198A7C64E7A for ; Tue, 1 Dec 2020 08:19:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A4C702087D for ; Tue, 1 Dec 2020 08:19:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=gmx.net header.i=@gmx.net header.b="IQJ3KKLu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726619AbgLAITi (ORCPT ); Tue, 1 Dec 2020 03:19:38 -0500 Received: from mout.gmx.net ([212.227.15.15]:58495 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726343AbgLAITi (ORCPT ); Tue, 1 Dec 2020 03:19:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1606810636; bh=mRSwhYo5MyWsCdHB5+e3Gx83UCUE0iBfViL+Q4vEyKM=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=IQJ3KKLuzJx7kX5OrkJhcmO59yN+1029w67QhfziVUyejA6/N5+FWQsA8CWc3mp8a l4hj4FZJgRqazCFym3IK2TfjeO2hpd0x4+hGjr9fR466GiQkNYj1qg1Xgi3Fcdk76y G1ZSa8T9giammzKjrSLPqURBY3AUGINuycdXe8pc= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from longitude ([37.201.214.162]) by mail.gmx.com (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MlNtP-1kKFx03OI9-00liNG; Tue, 01 Dec 2020 09:17:15 +0100 From: =?utf-8?q?Jonathan_Neusch=C3=A4fer?= To: linux-kernel@vger.kernel.org Cc: Lee Jones , Rob Herring , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Thierry Reding , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?b?w7ZuaWc=?= , Alessandro Zummo , Alexandre Belloni , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Sam Ravnborg , Linus Walleij , Heiko Stuebner , Stephan Gerhold , Lubomir Rintel , Mark Brown , allen , Mauro Carvalho Chehab , "David S. Miller" , devicetree@vger.kernel.org, linux-pwm@vger.kernel.org, linux-rtc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Heiko Stuebner , Josua Mayer , Andreas Kemnade , Arnd Bergmann , Daniel Palmer , Andy Shevchenko Subject: [PATCH v5 7/7] ARM: dts: imx50-kobo-aura: Add Netronix embedded controller Date: Tue, 1 Dec 2020 02:15:13 +0100 Message-Id: <20201201011513.1627028-8-j.neuschaefer@gmx.net> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201011513.1627028-1-j.neuschaefer@gmx.net> References: <20201201011513.1627028-1-j.neuschaefer@gmx.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:Cbp+ZxxFLt6uSqgwaiNybHmSG/zGeL63zhvHt9F5lx2AbHxq2sV 7lnQCNZlo22TyRxqdG8DRtu+oHo7PHLfysY3ZlpI1Qxbvx+43oTMI4KAPoJYYc9GmrZSiTN EU22/wwVBQZhYr8cDz5lwqP6IAWBwCsNvsiuE8IVBYtt8azDWItv+rlXyZnZ3wtSnHBpzle 7YTzlkIDJjfEll2nL9flQ== X-UI-Out-Filterresults: notjunk:1; V03:K0:sCKVuFCAFfU=:+2W6b2deI1jF9uW9a7VSpM 2XjWtm5y38Yk+zrLFekMLK2VvP3KyaGRahTYEXDwrqFpj0m7oyUJFqf/wpHrcwFSzC+Q5xwnN KO/4EeE54BTAITBu4PvRQaZPuzBhM/aJWiRpV8P3i1FKc0ijJOwMVH0DoGAQppGlsndFJi4Yw R3S7Lcjicoo2ySHHubGIKpsVYOuQSeuwyS8s88H4sQKEv9gngxEdbmrz0rGDhxPnPnvK1Uxgj rUFe0nviA0OPziNC1ibAe9RTs2DBIF7WjBNYQdVFfbGSRh32LJ7kFjBsaUnPb59rgKG7Tdw4r 7d2UEIOe5284ZmDhuBJVOmHZo0fzt5++lnXGzkM80Dh7/p3Shn66629MFw/V4IJBJLzX0fu5y gTJutRqD2SylS2dVvofjMuSRZ9PHXuUy502HmFZhM5ve1fLgU+HtHpjqNjF3vhhKwI+Xhz1gv NnbgFPc9kcICepn/JfiT6WBMbJPbxsSKHetaM7dyDoVAgIQK80CPrJX3WX+cpE0KZBvDYq0as y0TRwrAW2WeUxLWmNoSMX4YKy5eJ2+Twynl8JtR2SpoLJVKSGPIqHL4+em8Up+sgL0gVla1/8 F2sqkAqWjgD08U+JBZ49sbRRYqYl7KZL7XLfK4TVl+iiF6+ksN4VB6k/B0hnjFdK9bMUbgtNU MZvy3VDIk7dbMTX+7JAW2sbWe5kGsh5jKVff6MGZpkIZXXGXmN77aAn+hDvpXXIGOAbDhtreD ep3XmWcLcKpFkY4ji5C4cWstFb0fCd7Hmw21sRS5AhS8+g1HneFPXujIwGSR5DdlmQg3HWnG8 e/Gw4/hS6t9Gqx0i1IGlqH0jcUiEn1KHbE1B7kPlM+t4hZcUPK6EIdweTnuz4isN/HTFEA6Ce 5DjO77E+J1qkcvmzM23g== Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Enable the Netronix EC on the Kobo Aura ebook reader. Several features are still missing: - Frontlight/backlight. The vendor kernel drives the frontlight LED using the PWM output of the EC and an additional boost pin that increases the brightness. - Battery monitoring - Interrupts for RTC alarm and low-battery events Signed-off-by: Jonathan Neuschäfer --- v5: - no changes v4: - Add 'grp' suffix to pinctrl node v3: - https://lore.kernel.org/lkml/20200925050818.2512375-1-j.neuschaefer@gmx.net/ - Remove interrupt-controller property from embedded-controller node - subnodes of embedded-controller node in to the main node v2: - https://lore.kernel.org/lkml/20200905144503.1067124-3-j.neuschaefer@gmx.net/ - Fix pwm-cells property (should be 2, not 1) --- arch/arm/boot/dts/imx50-kobo-aura.dts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) -- 2.29.2 diff --git a/arch/arm/boot/dts/imx50-kobo-aura.dts b/arch/arm/boot/dts/imx50-kobo-aura.dts index 97cfd970fe742..82ce8c43be867 100644 --- a/arch/arm/boot/dts/imx50-kobo-aura.dts +++ b/arch/arm/boot/dts/imx50-kobo-aura.dts @@ -143,10 +143,24 @@ &i2c3 { pinctrl-0 = <&pinctrl_i2c3>; status = "okay"; - /* TODO: embedded controller at 0x43 */ + embedded-controller@43 { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_ec>; + compatible = "netronix,ntxec"; + reg = <0x43>; + system-power-controller; + interrupts-extended = <&gpio4 11 IRQ_TYPE_EDGE_FALLING>; + #pwm-cells = <2>; + }; }; &iomuxc { + pinctrl_ec: ecgrp { + fsl,pins = < + MX50_PAD_CSPI_SS0__GPIO4_11 0x0 /* INT */ + >; + }; + pinctrl_gpiokeys: gpiokeysgrp { fsl,pins = < MX50_PAD_CSPI_MISO__GPIO4_10 0x0