From patchwork Sat Jan 16 19:48:20 2021 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: 12025013 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=-13.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 C26BFC433DB for ; Sat, 16 Jan 2021 19:56:48 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7EEC822DBF for ; Sat, 16 Jan 2021 19:56:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7EEC822DBF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmx.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=BwCQUmUhGYX35lBapJ57Cgm0X8yy0qewxHv0VejZBWM=; b=Xb5OQbKx4+2ZadaSYPjMuPl2E nYW8qzLwKjI3Pu6HGXXpgriwFF5epQIDcxMhO0NXW2cvMiU61VhnAR2ebmmlqTeFXgSQKWY5jAVc9 ZV5uzknHS+CCTB3+XEyWbNTSgFI+DbZLtFkX1COamSp94yZCF3UCecGzcQJ2rZSSRFU2//tKwSGCI niAIxS6Pbj0cyLZ+MeW+jjJ5ztLQG1MxCxQZP+/bEpMRHb1k+De//8/DaeKDMR5L8NWdvjiaiQ4rp h2NURG/Kqy5In1ISQuZ9rV3fJbVOKgZ8N9G67oKO+IhMAVXZqCYjJYRe7pJiew9ym5nVGkS2Dox5G e+83rDtug==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l0reM-0000br-OV; Sat, 16 Jan 2021 19:54:18 +0000 Received: from mout.gmx.net ([212.227.17.21]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l0reH-0000ar-La for linux-arm-kernel@lists.infradead.org; Sat, 16 Jan 2021 19:54:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1610826814; bh=Zrew4jwwEazJ7Dllk9MHmtO8jaMlk/hT5Dw6YvClR/4=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=c7jRuPn01ckk9k+eJRktFYOEczckucrXxCjTSECDS9kwi1KhPWUyHDRGFmfsS9+Cc t96MPJWB+HHvzGEgPX3NOfURVTK/oIWw4IZaBHDnuDeruQ0GcqRj2SqMpR2RGBESN3 hQ+5F+GOAgPQ1H56hOERFYu5ZCY+DI54Lu//2z/c= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from longitude ([37.201.215.209]) by mail.gmx.com (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MUosT-1lQxEF1PCT-00Qkwr; Sat, 16 Jan 2021 20:53:34 +0100 From: =?utf-8?q?Jonathan_Neusch=C3=A4fer?= To: linux-kernel@vger.kernel.org Subject: [PATCH v8 1/7] dt-bindings: Add vendor prefix for Netronix, Inc. Date: Sat, 16 Jan 2021 20:48:20 +0100 Message-Id: <20210116194826.3866540-2-j.neuschaefer@gmx.net> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210116194826.3866540-1-j.neuschaefer@gmx.net> References: <20210116194826.3866540-1-j.neuschaefer@gmx.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:HiynVg2n95mfhAnnA27gk7aAmI+Xvc5cJw8uxHU4v/ZTZeJq7QV NjErQno/qIhdQd2mn90PYk2P0D2HQ0gp9Bn0Gom6broecvapn+CzCygTG1rPQtCUPEsOJDr ern+oFnjM68n7DQ+UtLl9RejoXaaOqs8D8tUk2Ly3OXPctaOEICJHR3Zq5XiRZZnpyoifMq 9mOzhZMr2VBgGispTGCgQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:R8/y07E7piA=:lCh+scgNUbPKofgJdS7Itg e8/DPShqjqGlYPfy7avUFHjR53/G/5c7CYN/DGgBMMmQuouTLAbGz20pHmbRtjcdu4KXF+Bdv ALu5AOojEHD9ZfBimt5zvrVRbwuz6PLY1vRR5q0szr8Ig+Sd+Vzhr4wG01N2L6OrUCV6KKsSm MCU8cK96Iqj8KSODfXgBqMxaLDYUwontU/Fds3CnmdU6rmjFsJP2lUy8ene8TA6O1esaMxy3N 5F/pksoQVEvXQch060lRvjTvnW1aupP2l1ixcDDT5Z0BYzriE+n12gEKX06ZRDB3d2HkxaTcv QHEbQBOS7fv4y85ap/BEisNjVUN4hzrHcrKuHGf7aB4vl/Vhu3sEHdSSNdhzUto/asGuPw63L cwyEiYA2jM5UplFyPlQfsxiqBNPDDqDcWtOT064CPhNGMAnpMAO2HNCUjUZXQg8ZB/k9iTEQi PukDCAySHbOk69BaYGpXVTuGHdNPckAGsfqH8/RELRapDQ5r8gIl8UW5BAZkofdxFx0+bfQvl HOk4SWu9f4wbO5jVoQjyQNaj7iQv/zLEkiQycpU8L1V6J0OGwULeYqnEuhqbP6/73NJUpG542 PAU8tANbvpHHYTvXffYyew1CMyzT0wFYVbxi7eIHRyhFpO/+m7JCaum8kjzymjkaIKo5dGJun nub+3kLyYDu+jQqEjSfLaa24uw7fkp63Vr+YVM2p+JKRzE7UcFZcACnT8WiP3bseBj3vajuSu qdqF/bsUJV9pLRVtTEB9ynUDLLpdcfRA56T6VF2eD9cV6QXyxIqKPZCTsA+KHmVOFzQZclVam mc+I8Izs755ougGc3MV3keU9XwiuLLMaJDqdQbpsSivfYMTLnXMlO+SpT277jdjLhce5V6zms l2XYuD6gga/wJJmWn9VA== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210116_145414_399555_FD1ADFE4 X-CRM114-Status: GOOD ( 13.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Belloni , Heiko Stuebner , Kuninori Morimoto , linux-pwm@vger.kernel.org, Linus Walleij , Thierry Reding , Fabio Estevam , linux-rtc@vger.kernel.org, Arnd Bergmann , Mauro Carvalho Chehab , Sam Ravnborg , Daniel Palmer , Krzysztof Kozlowski , Andy Shevchenko , Andreas Kemnade , NXP Linux Team , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Geert Uytterhoeven , devicetree@vger.kernel.org, Stephan Gerhold , allen , Sascha Hauer , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Lubomir Rintel , Rob Herring , Lee Jones , linux-arm-kernel@lists.infradead.org, Alessandro Zummo , Mark Brown , Pengutronix Kernel Team , Heiko Stuebner , Max Merchel , Josua Mayer , Shawn Guo , "David S. Miller" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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-v8: - 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 041ae90b0d8fd..4d36b8173b568 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml @@ -756,6 +756,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 Sat Jan 16 19:48:21 2021 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: 12025019 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=-13.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 A15FBC433DB for ; Sat, 16 Jan 2021 20:04:29 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5D7302078B for ; Sat, 16 Jan 2021 20:04:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5D7302078B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmx.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=pS8Wkhi2IDdmKmsSzy/umJJPJUM5x19QISCRSW7TbzU=; b=Gn1JD6///00D2cNVb8zogWf14 oEGfgOsddpPpvdWyLxeLvdpIWCfeHwCYxYaYE1cL4GtJfz/e02Z7zraaHR5MzYAwKhFCj6TMfpmrT bz9YS8N13+JNSjfqND8dgp4gKil1BzIrlRgdycWt2GH9yF6e5+NeN3IleFHUDQHa0osq0vzk8FcTJ xOq46C/p1YBDZx2/RZJSjmdEtcl40mhbwE27AvSA/rLNpAGtviutJvY+DaJuS+mdUAE1mOGpgUdGa kIVp+Wvemajfnv3NIb9VNZViLjerSpCJF3TfAM5dVUoR9V7Cc4hPPXSQnwPrOu7Anva+L84rcn4OX 8SMZZrWzg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l0rmM-0001sn-JX; Sat, 16 Jan 2021 20:02:34 +0000 Received: from mout.gmx.net ([212.227.17.22]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l0rmH-0001sH-Ev for linux-arm-kernel@lists.infradead.org; Sat, 16 Jan 2021 20:02:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1610827339; bh=qu0Nv0k8UIi/GWgWvwmLRmyI5GZIM8QL8R88849zarE=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=Mjdc0p6devemZE0NU4r9xg3jpnKSXechRofesiUv7DFyb+A7h1zvlwkhzkm2UWqJq EaPnXJe/82gr5l/B5u9u3STaY8ktMrKE/ieTFWAFTn11SiXzNVnOx7932mo0zoBOjJ e7lvQaFNxyHiwpaNa7nlmlWiAVAzRrWRTqeRUAFw= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from longitude ([37.201.215.209]) by mail.gmx.com (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MStCY-1lTz5S2vq2-00UJe0; Sat, 16 Jan 2021 20:53:36 +0100 From: =?utf-8?q?Jonathan_Neusch=C3=A4fer?= To: linux-kernel@vger.kernel.org Subject: [PATCH v8 2/7] dt-bindings: mfd: Add binding for Netronix embedded controller Date: Sat, 16 Jan 2021 20:48:21 +0100 Message-Id: <20210116194826.3866540-3-j.neuschaefer@gmx.net> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210116194826.3866540-1-j.neuschaefer@gmx.net> References: <20210116194826.3866540-1-j.neuschaefer@gmx.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:9HvTZzmITnHdkKjxY+6LjIGBOUZXAFxxNbfTkOacLyWIUqGwcNi nejIXml6JblxkoT4lz8IWr5m1+oJ5Av92Ql7/iolimuoFJyabY2Tlb8H/2s+bffl7Ei1C3O 11M6UIJVcHHAcCxftzndk3B58K9EwDoDEZ0vVEv9Pkf72BVDyMSkVkLd1aBfjCfCVNAhYYf VX4tVoNPRlGvTOmMJCIgw== X-UI-Out-Filterresults: notjunk:1;V03:K0:41X/LMvvQJw=:zfJzEA6dvsjG3H2XiplRUX rQ4Z7wEfF1AGaMBRtAA2NR0I4ixqO7Cmjbz/8tlLiHbkQieRRAwcNENTSBYS75ugVnwNhjIY8 9I4Zys3SCMmZ1YR7tap0pOWm8zgFxClPeNDb8JO8Tjh/kI03RCgfMjfCgcu9ibikIlAznw7gv 8Uje9djCh/HzWbVdrO7VRpnfBgmn3VxSOtjA1bv3QVN6ruxWv9IJBM7bjcFQOtDPfVWNfzVGp +cnkrJXwnioDVugP1zM85P/O4NnXxbNCEskjkUWQdblfDG1oZ4SD3zfyvaQs2pMJiwwsd5Pyo liIeuWAqBETf5mnBoV3wxrzhVeQijyywaamO7O4vm2D/dpQCpMiIQj4reSEBekFKNdBKwDP7E sE/gVzQfoRzsVKisW3oVtt0p1gAZzzY5wwBO5ZyKviP9oK5hr/TeWhXiTqImkNqvpD96i3FGY tkAFhjcDolbwXMuAO2DPo64Z9xdqyixd6oiAnXUvfC6pqHHb+c9e0HleYy21x00GgmUvpULLq LMyEIC8qPHEkrtg48DsEZYg5Fk41IiAe+Iki45JeKydZMx94hQqNhWa/UpJmOBSjc5y1jVv9w lZb2IyNUhGwR364Wg4ieDaBJj6LGR3X3Y0/yxZhAN6OZt4kABn2MxhB/uB+NvlmkYcGE+teWp M6/i3bsEqaN8rsAvpeYPIHiz1nRTuiNQoCPHBmP+7EflLCT00gaccHrDTmSh/WJaulCavsfUW K+rC0xFIuY5LiQF82XLQq0EjjB3H8Doi6Et7xYX2qvXqPsCy1174UVtHEJiqjPfYNyX7nJpGl Pd7L+6Cjr1Ooy0pytA6WMwiMkRONPySVq2Ifbf07SvhRElZS13ZwC6lEnDIS340NBbvmYTsUY rNVcJ0QYADDnhlF+/Ccg== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210116_150229_814347_338019D4 X-CRM114-Status: GOOD ( 17.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Belloni , Heiko Stuebner , linux-pwm@vger.kernel.org, Linus Walleij , Thierry Reding , Fabio Estevam , linux-rtc@vger.kernel.org, Arnd Bergmann , Mauro Carvalho Chehab , Sam Ravnborg , Daniel Palmer , Andy Shevchenko , Andreas Kemnade , NXP Linux Team , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , devicetree@vger.kernel.org, Stephan Gerhold , allen , Sascha Hauer , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Lubomir Rintel , Rob Herring , Lee Jones , linux-arm-kernel@lists.infradead.org, Alessandro Zummo , Mark Brown , Pengutronix Kernel Team , Heiko Stuebner , Josua Mayer , Shawn Guo , "David S. Miller" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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-v8: - 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 Sat Jan 16 19:48:22 2021 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: 12025017 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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,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 0B99EC433DB for ; Sat, 16 Jan 2021 19:57:01 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B116422DBF for ; Sat, 16 Jan 2021 19:57:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B116422DBF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmx.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=VyPxYBYju+NomZsS4jnJ9+HDJYXPuqGJNFIWjLwKwIY=; b=VqLOlMN6s/mmMotK6wWO0vW14 Q4l2tfW6x99pUbI8A0yMagcd+WD1nanb79V1iEJMWfa8xA2hRdkL8vnwV6CcL+anGk8jD/1oLpaeu SsNwNnalrUnEk2zoRIt4JdkMyXVNzM2E+cgNoh4l/8VrD9fxrf/ke948mNLeHe5Sp7x1sVw1z4fz+ wF9FGvqmCPdZt8/ezE3AaJ0/3dJLhmoyaUtwnzNA4vSpRhRrlVf4yaHoc7rMnjxWAROQoB50MXvOT /FKeXd/phUW7GaHLR7oA9JSxZ3u+Z0ZRRpJwUP4F8MxvtZi5Ef6N+9HP7nIutT5EFH5MXKtsF+Hpk WtMYW0tJg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l0reZ-0000dV-Cs; Sat, 16 Jan 2021 19:54:31 +0000 Received: from mout.gmx.net ([212.227.15.18]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l0reW-0000d6-H9 for linux-arm-kernel@lists.infradead.org; Sat, 16 Jan 2021 19:54:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1610826825; bh=yqay8au2NQbusO7OLfRS71680dKdjQTt4LqNh7KMh4g=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=gVBGN9qACEP3BhkhH5ZuhWRR7fZS+Wcy+8AEg5kNCQWe9iQSoTWHCpDJgCl7T/oA0 9R/SoLg20My2lJfMTJBBOVEBqRgM95UEVQgNjcVIJ3VYl5l0ckhgkLSkApVZbGG79u PQxtdbpzhfJ+CuR3Sn/5ct6gY2wolkLH8/Zl9f2s= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from longitude ([37.201.215.209]) by mail.gmx.com (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M3DJv-1l3tVk0XAT-003fu1; Sat, 16 Jan 2021 20:53:45 +0100 From: =?utf-8?q?Jonathan_Neusch=C3=A4fer?= To: linux-kernel@vger.kernel.org Subject: [PATCH v8 3/7] mfd: Add base driver for Netronix embedded controller Date: Sat, 16 Jan 2021 20:48:22 +0100 Message-Id: <20210116194826.3866540-4-j.neuschaefer@gmx.net> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210116194826.3866540-1-j.neuschaefer@gmx.net> References: <20210116194826.3866540-1-j.neuschaefer@gmx.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:ZO8MXnyNhSdw2eqn2FrxYAPzGIGgLmqjhfoziYhRZoUbICVN5eL o5QNZTJ67/sE/g/AtRZBO5ORRVPXZhffvHcfYwvDhGWnC1bVgJg+uZEpl7S7hObDc9J98ai 0qvp9hz9gz/ojakzD01IAMZcOll3kPqLUyuXyliYZJC9TrE4FlCphlPsp3wKy30UwskDCd1 YZmViY6y+3LpyNKmko2Jw== X-UI-Out-Filterresults: notjunk:1;V03:K0:1eonLJSSPnI=:wwZFSzM/8XR1tZMopU6oyc 7TokuiY0mkYBFEPW0YgwZ16DKRDUNl09Vuqh4eKR9uT4bXzl4S1y6il0Y7qJ7+6grMztDBT17 ks2AeSai8rgCmEMHZNBvIAQTZoNIgYZMwvIOetW80NUevPJ6Dojd5QUZMO25GnbDHy/uKFNf3 arBLxWRhwW9KhviNyGOEEUo7QVgmbsewpiIaPgxSnFY0vRseInk+DfXd1LWAvoXdF8uG+ppRE dcHlNzn2LhF/+7fxFw9ztrn/zUmp/4owSFqX85TBdeDg27HjU99wtdyix4teFkXv+j+qSoRYZ fJcYp4PCBjf9eRmdwrAInfHKeVIEg6oIaCW1guCUvS2QNRLg8dYnBy/zRtSYmu7w0VnTjctqF HiP3YfrgyxRcr7AGk46W0Y2nUiN7dTZefY0kSsOXocpk7wwGvrQsywMnNHk/VecJla5C/MuNC bC1v/nOHHForuqgCbxBA2TXhjRUXQ6neeL++Vc6CYoPlmrVH1edUOGr29bbomEyvtM+xBXcgZ w/30YO0FO+DCM3HwI/jr/gRS9qtVPmfi7Bzzpgbrm45A/UC6xNU890neQpo3Xb2gXOpZFD38w MDVwsMjTU22ejApNHU5G3QI3BzrzovvU9/ddsx4Ier4RbxcaugLDRDHrkBd9kubjE4v2YwNXq 6fYbIU57MntQrpU/VElbAqX3DpnZkxdKlg/LU/+E4mWcVHZvLWTim387mcFYcytE45AenvemZ npZzqtOPf8viP3bnF3CpEGb1bSCGoBKuPIMVh9jU4rmmzWQj1GG0ueNacXNV5M4pI85a3mIH1 NdXdVxu4Ct+jDUJf6TyLP8fBJSI3oPeQSshWDxLNIFK4lp/smFZwsbO3oHczzZv7HF6G3mHxQ tmsy5C38aljWnBQwcqWQ== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210116_145428_839361_1AC0853C X-CRM114-Status: GOOD ( 37.18 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Belloni , Heiko Stuebner , linux-pwm@vger.kernel.org, Linus Walleij , Thierry Reding , Fabio Estevam , linux-rtc@vger.kernel.org, Arnd Bergmann , Mauro Carvalho Chehab , Sam Ravnborg , Daniel Palmer , Andy Shevchenko , Andreas Kemnade , NXP Linux Team , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , devicetree@vger.kernel.org, Stephan Gerhold , allen , Sascha Hauer , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Lubomir Rintel , Rob Herring , Lee Jones , linux-arm-kernel@lists.infradead.org, Alessandro Zummo , Mark Brown , Pengutronix Kernel Team , Heiko Stuebner , Josua Mayer , Shawn Guo , "David S. Miller" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 Acked-for-MFD-by: Lee Jones --- v8: - Add missing MODULE_DEVICE_TABLE - Add module metadata (author, description, license) v7: - Add #define for version number (suggested by Lee Jones). v6: - https://lore.kernel.org/lkml/20201208011000.3060239-4-j.neuschaefer@gmx.net/ - Add Lee Jones' ACK 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 | 221 ++++++++++++++++++++++++++++++++++++++ include/linux/mfd/ntxec.h | 37 +++++++ 4 files changed, 270 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 bdfce7b156216..4280bcd47ec7d 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -976,6 +976,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 14fdb188af022..948a3bf8e3e57 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -219,6 +219,7 @@ obj-$(CONFIG_MFD_INTEL_PMC_BXT) += intel_pmc_bxt.o obj-$(CONFIG_MFD_INTEL_PMT) += intel_pmt.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..9c435bcd9d88a --- /dev/null +++ b/drivers/mfd/ntxec.c @@ -0,0 +1,221 @@ +// 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 NTXEC_VERSION_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", }, + {} +}; +MODULE_DEVICE_TABLE(of, of_ntxec_match_table); + +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); + +MODULE_AUTHOR("Jonathan Neuschäfer "); +MODULE_DESCRIPTION("Core driver for Netronix EC"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/mfd/ntxec.h b/include/linux/mfd/ntxec.h new file mode 100644 index 0000000000000..361204d125f1a --- /dev/null +++ b/include/linux/mfd/ntxec.h @@ -0,0 +1,37 @@ +/* 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; +} + +/* Known firmware versions */ +#define NTXEC_VERSION_KOBO_AURA 0xd726 /* found in Kobo Aura */ + +#endif From patchwork Sat Jan 16 19:48:23 2021 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: 12025031 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=-13.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 9DF2BC433DB for ; Sat, 16 Jan 2021 20:56:04 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4333422C97 for ; Sat, 16 Jan 2021 20:56:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4333422C97 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmx.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=YQZVuBgoSfEU1yLMIShk9bGldWUzUgfftVW+CTH15cI=; b=yuQlnDngS2urxI9PQwjeqt9rb 3rpJxn2+4feFi5fgS3ZSwKlnoVLpmrbqobZnHt9Pgq0TfhC/u7OFJwNzUhyjPeXw4sPPT3Ihtvewl sYrT+QlzvUlHolTBTGbY/ZIJXQjvNVzIbTm41KuFtpFfTEjcmGDUsoIgYdb86BIau2gJWFhTcJwkT fBV6KJPUJ+p21eHq0y+gA1udoI2njL6PV2+jo81f5dLKmjsOOK0FmBwRnCh8kk6OQ9acPCZJ8IHrd Arp2NSe+HnuC8L82nERdfsFUkD+/+HIZlMD42igF7qtGwVx7JOFtxuUvYoB1QmpX3HUt6vwW/hLxS 2xiEdwITA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l0san-0004vB-UG; Sat, 16 Jan 2021 20:54:41 +0000 Received: from mout.gmx.net ([212.227.15.19]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l0sag-0004sG-DR for linux-arm-kernel@lists.infradead.org; Sat, 16 Jan 2021 20:54:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1610830430; bh=CNBRA+c+NY/9LumPB+UY4n0iAV9NlGywmp537B5vKd8=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=KiJ+6HQi0sh/5TcrGBksGevwJEAa39i2VCGib66pvYjsdlC1QSDp7m2NPRGzToIAM hRBYh2rB4z6qo7ACn12LzjY+QB7goGWLUZxkaZh5IT5MX2l9JJ4rq1t8xxefHDbxXP TXzEQ8M0WJLnihZ7FiqWA4OCyM23fnyPSeaI37Vo= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from longitude ([37.201.215.209]) by mail.gmx.com (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1Mkpf3-1llXGr29q3-00mHL8; Sat, 16 Jan 2021 21:53:50 +0100 From: =?utf-8?q?Jonathan_Neusch=C3=A4fer?= To: linux-kernel@vger.kernel.org Subject: [PATCH v8 4/7] pwm: ntxec: Add driver for PWM function in Netronix EC Date: Sat, 16 Jan 2021 20:48:23 +0100 Message-Id: <20210116194826.3866540-5-j.neuschaefer@gmx.net> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210116194826.3866540-1-j.neuschaefer@gmx.net> References: <20210116194826.3866540-1-j.neuschaefer@gmx.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:sR0d3iqo8IyQZSTjKPwyjcol376hsZD6Y/nteZGtp/f6UWwNUfn 4UICbrr4QpIG3aUq8auyoRBckRdFWzg+sG8RFmnf/0IxP0wmoA4tZQemZ3dsqgqRW2o14fi I8aPDY+ijTb03qU1koS3VASpaAYb9qphVjur4vq1H/OCvWUKlPl1P8mlfoW4Gkt8UtlTQc0 2dScoDyVg8xEv1vdcz3uQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:AL4DOgyui78=:C8UVbU7Z4sDYtGu3aOjPpN LhHzT6kWMYSxJmRm7ED8GJa4yamikvi9OZvM6HqXVGSjxd8klRRQ3UjKpwI7PPz8eSYuI5hMs sH95aVzKWor6v8tRAU0CUusoSw7lu0U8PtRqWjqUITQ9o7/7QPbxuPxrlPCcXmSJ8Fsj5t3L8 PQ5ltcEcl+GCQ65CfeG0o3dcCyT2cVgLKhVJQ6vFAVlKH2BO2xnWbmTntA9lDI1eyGWL4GmuX qjTQ/ukymFL/lGJbDa81sBb33g2xm5TcfRos3pYFxCtWD9DS3QiuFyv0kvEyQ0Mz0SODsNv3k TJsJWqZAZ78jpFTxWfijoV3UfS9w1/vLkCXK0A4Rrm6C2N7aax9FxCfzAjQs2L6hGTu50bLTA XZS8QcmroRmEXos4eyvcxywaBslyAFZGuecbo744IXakFXBXXyzl1O4Y16/B/JDpEH1etr5uN IhDAsFBWzKQsPekso8RiEgvj5D56bbYlTKnYmp40Oh46tETIRZ1olBYdlo2vY/5+nDgETP3QF /7MBPn5j/+1+vd49QCmYppNGQ02Uap1HQxkB3f3/7OSFt/v6mObTiQGtNi06mPhiWKrzha4iC xpmDhqUz5SFPNHVN3jpqAJLb3NK8JgUFEQ3urPDACNr9GVDVtJblQKD/qekLQlxmOLavRBbs8 Xq13UPa+UXeG9QhnAW8mh0zl8GFPQudJH1zF+ahpgcMh6GcWEHiJNxHPb7S9/kFWacPDImWbA 5Ruc85iPSIssEHyZSOnbaMCf2yQGaQZd/EUOqcoMA2ufSXwNb3BoGeXY23Of57lVhtsTpKjIC WiTfA+uEbj5/ozndy6Ey2oScDOFndEQ08nsUkSO4KV2sPM5qD/0hz/8zGqLN/ulULkcgNFPvM JYZLgX/6k+PzfFSnuqcQ== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210116_155434_793263_AA008449 X-CRM114-Status: GOOD ( 35.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Belloni , Heiko Stuebner , linux-pwm@vger.kernel.org, Linus Walleij , Thierry Reding , Fabio Estevam , linux-rtc@vger.kernel.org, Arnd Bergmann , Mauro Carvalho Chehab , Sam Ravnborg , Daniel Palmer , Andy Shevchenko , Andreas Kemnade , NXP Linux Team , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , devicetree@vger.kernel.org, Stephan Gerhold , allen , Sascha Hauer , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Lubomir Rintel , Rob Herring , Lee Jones , linux-arm-kernel@lists.infradead.org, Alessandro Zummo , Mark Brown , Pengutronix Kernel Team , Heiko Stuebner , Josua Mayer , Shawn Guo , "David S. Miller" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 Reviewed-by: Uwe Kleine-König Acked-by: Thierry Reding --- v8: - Add Uwe Kleine-König's R-b tag - Copy dev.of_node from parent device v7: - no changes v6: - https://lore.kernel.org/lkml/20201208011000.3060239-5-j.neuschaefer@gmx.net/ - Move period / duty cycle setting code to a function - Rename pwmchip_to_priv to ntxec_pwm_from_chip - Set period and duty cycle only before enabling the output - Mention that duty=0, enable=1 is assumed not to happen - Interleave writes to the period and duty cycle registers, to minimize the window of time that an inconsistent state is configured v5: - https://lore.kernel.org/lkml/20201201011513.1627028-5-j.neuschaefer@gmx.net/ - 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 | 184 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 193 insertions(+) create mode 100644 drivers/pwm/pwm-ntxec.c -- 2.29.2 diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index 0937e1c047acb..a2830b8832b97 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig @@ -393,6 +393,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 18b89d7fd092a..7d97eb595bbef 100644 --- a/drivers/pwm/Makefile +++ b/drivers/pwm/Makefile @@ -35,6 +35,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..50c454c553c46 --- /dev/null +++ b/drivers/pwm/pwm-ntxec.c @@ -0,0 +1,184 @@ +// 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 *ntxec_pwm_from_chip(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_set_raw_period_and_duty_cycle(struct pwm_chip *chip, + int period, int duty) +{ + struct ntxec_pwm *priv = ntxec_pwm_from_chip(chip); + + /* + * 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. + * + * To minimize the time between the changes to period and duty cycle + * taking effect, the writes are interleaved. + */ + + struct reg_sequence regs[] = { + { NTXEC_REG_PERIOD_HIGH, ntxec_reg8(period >> 8) }, + { NTXEC_REG_DUTY_HIGH, ntxec_reg8(duty >> 8) }, + { NTXEC_REG_PERIOD_LOW, ntxec_reg8(period) }, + { NTXEC_REG_DUTY_LOW, ntxec_reg8(duty) }, + }; + + return regmap_multi_reg_write(priv->ec->regmap, regs, ARRAY_SIZE(regs)); +} + +static int ntxec_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm_dev, + const struct pwm_state *state) +{ + struct ntxec_pwm *priv = ntxec_pwm_from_chip(chip); + unsigned int period, duty; + 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; + + /* + * 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. + * The case that something has previously set the duty cycle to zero + * but ENABLE=1, is not handled. + */ + if (state->enabled && duty != 0) { + res = ntxec_pwm_set_raw_period_and_duty_cycle(chip, period, duty); + if (res) + return res; + + 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; + + pdev->dev.of_node = pdev->dev.parent->of_node; + + 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 Sat Jan 16 19:48:24 2021 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: 12025033 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=-13.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 E6A48C433E0 for ; Sat, 16 Jan 2021 20:56:04 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8ED7822CAE for ; Sat, 16 Jan 2021 20:56:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8ED7822CAE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmx.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Px6F0khhwFJoSaQq4XpECv4wVP6yvg3BMeN4UhutnIc=; b=rp3eIfybFgh56kPSrY06alMKi /OiQ76XuyNTQq3agYyBhGtHXMVBtc9sSJt30wopg/E8JEej3bb2SXJy17mGEmsDHug6q8XN17pNK+ zpyGON4MT8XS3FoRWcbZnxfpmCQqt23kidixpSlnn/PlPnbTf404tM7sIx0PzZtiXkCUBTft/iTYg ghTpeZLRxdjy61ZV+nr2CjbWP/wrfV2yxsHHjOgYgA7cu57R3VbOveLdZwIMY05PRk23upt/PodlP F2LgarEf8dbfJcuYfxr5I11Xi47znkAFCsdZzJ+id9QZcvKC1mCnN+FoIiAZPpQdlMIxKI9YxkwSi 5e5M6Gvzw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l0saf-0004sI-Ef; Sat, 16 Jan 2021 20:54:33 +0000 Received: from mout.gmx.net ([212.227.17.22]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l0sac-0004rm-Fu for linux-arm-kernel@lists.infradead.org; Sat, 16 Jan 2021 20:54:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1610830437; bh=htvvCNs4FySpgIx3KYqNE7hzLBDcFLrrcug3g/cjWQ4=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=K0S5ysApmYyApHZI4XTHMUxXGPE4ejKD/DO3A9vF6BVjKTdiYfcfe7Nca717K+u33 JiHvEq1yhe5zfkr+aM4bRt61B0XGdhTfmO+z3q2Z78e0LLLiSYRYtvAVOK49baCAQJ 50BdFguXt8lG3hb+ox0zYhmPFZHERnJf3xpQDmFE= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from longitude ([37.201.215.209]) by mail.gmx.com (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1M7sDq-1l4i4V0S2c-0054kN; Sat, 16 Jan 2021 21:53:57 +0100 From: =?utf-8?q?Jonathan_Neusch=C3=A4fer?= To: linux-kernel@vger.kernel.org Subject: [PATCH v8 5/7] rtc: New driver for RTC in Netronix embedded controller Date: Sat, 16 Jan 2021 20:48:24 +0100 Message-Id: <20210116194826.3866540-6-j.neuschaefer@gmx.net> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210116194826.3866540-1-j.neuschaefer@gmx.net> References: <20210116194826.3866540-1-j.neuschaefer@gmx.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:hDgiveW+962CxPjTkilMmElkf+a6Dxrv5YTjcrlDHEGgXquWnAz 2AFXjvbONsrcdIp760AjFzkhkgP2GOUPCT3OGPCnghZB40/3v1eVPgx3rVLMHerbHuXWikb dztTqAvlY98v5hAetMGlLKA2TCVwYPmQq8CPebOAiUkQuhfc2qqHc6NHY3hGKipBij1vmCf MHmagwWiX7bNzb2jLU5Bw== X-UI-Out-Filterresults: notjunk:1;V03:K0:F2IcZSfByuE=:3uqeR2rNH6N2RD/v3MTuIS n9/dGBP9s7WnOfI96UuNyI4mGNz1JAxHsZOk6703tpd+ys7IId55L6LHGkLJFqqJBLyMPWAAK 1L7x5ZUvKkkYfJPKfM8ydqURW+MjKFkOJFuekzWVmoF7DaGsD3sAlZEiQlM5ya9QQvkzxPQUq WsClsRT+KpBhSkh1LJPyiPvSDkZkoMN5SwPo6Ja/mK9WR6jF36tR8euR/zEUbfrB/u4oKZaMx BKcyKO2eEoybqNRQDJdDmGxeImfyzj7emwpbEE4FS9oMrSyB9xe8s/m2AqQiIiVjMft6VjkqR 4vLA5xOZ/UrehtmGFv74TOXEMMJvyGgTqgeJQPwxh156rK8G5uvJDELBjfxHrB136G4LB56K/ lYi306rcpnsorzoVbWKewGldnrZ70omeQJ4eAjmWkGHXchy+Fy433vCZDdy/KxyH2n6YqBE62 uga5JoZQ7Fv8sSMTaXpgyqHHoYcWP8xZB9pU8e4B+ClykUY0xLrUNZM13JwIeXv+OSqzSFAVi OMINReyPsw39s6JS9Nb+PK3gxc+DsJB72bWG0gzqPOYLE9sPllGWoNix5uZ4ViMYUXUKzAe1h yEsn8zyvFoaP98Sg26jHqXCn31enZ3fVd9hS60cmOqTeiWtWkAL3sr5yZ+6HLmMRQgdgFx/Yw x1iEJsuZosepYxZjkF2uUjF1i+GeUHtT1Xm6pOwFNRfBwy0EdkZiQ9xI0XtA045TJR75tDZRr hA8DxVRgbMJQ4d8ZP2PyhwaQPTN8hX47Nt3VBMwqbY71vvBpvgELk6N4h972kk4aVzxvPsMBB q23db0zumyu0VUONFUHRLlOdnF22fbdsLAjSZilbeiAvNlNbG6b/50Ndx1rrtGmFjakc0pe5d ZOA0KjXG185AWPUiDvuQ== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210116_155430_887413_6DD1D12D X-CRM114-Status: GOOD ( 30.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Belloni , Heiko Stuebner , linux-pwm@vger.kernel.org, Linus Walleij , Thierry Reding , Fabio Estevam , linux-rtc@vger.kernel.org, Arnd Bergmann , Mauro Carvalho Chehab , Sam Ravnborg , Daniel Palmer , Andy Shevchenko , Andreas Kemnade , NXP Linux Team , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , devicetree@vger.kernel.org, Stephan Gerhold , allen , Sascha Hauer , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Lubomir Rintel , Rob Herring , Lee Jones , linux-arm-kernel@lists.infradead.org, Alessandro Zummo , Mark Brown , Pengutronix Kernel Team , Heiko Stuebner , Josua Mayer , Shawn Guo , "David S. Miller" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 --- v8: - Copy dev.of_node from parent device v7: - Adjust to recent RTC API change (rtc_register_device -> devm_rtc_register_device) v6: - no changes v5: - https://lore.kernel.org/lkml/20201201011513.1627028-6-j.neuschaefer@gmx.net/ - 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 | 145 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 154 insertions(+) create mode 100644 drivers/rtc/rtc-ntxec.c -- 2.29.2 diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 6123f9f4fbc90..d49cf387add14 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig @@ -1315,6 +1315,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 bb8f319b09fbf..92c26eafe70ce 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile @@ -110,6 +110,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..850ca49186fdc --- /dev/null +++ b/drivers/rtc/rtc-ntxec.c @@ -0,0 +1,145 @@ +// 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; + + pdev->dev.of_node = pdev->dev.parent->of_node; + + 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 devm_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 Sat Jan 16 19:48:25 2021 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: 12025029 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=-13.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 00687C433E6 for ; Sat, 16 Jan 2021 20:56:01 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A996922C97 for ; Sat, 16 Jan 2021 20:56:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A996922C97 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmx.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=apqT9CqfE1EuOa7vRA334BFv96n5ZlXOI3r/eR3ODZA=; b=BMJw0doMk2TdhnJIj52RN2piX O2/lTvmt51GqabKYidDOa5iup0P+u+rhmIO6/5u00Ui/2lLVA+mAXSSD4qFSsGvrMZ5oFbDVdj/E0 E9d506V2iQJ7cxFaNuLDfwNd3O0dRbE/NrfKA3T6Kqg4ja33uOX/Svjm16XPRXIM0dVWrigsu0PRs vIlBGw+ExLrUEHV2N5D3PXADOXw2oroBsvawUgweXxmdDWnFgzJLFg+1GoaOJl1ljE+N26giKjkfJ D0sGc0angfre0aU0nK1fmmBA5yBQ9ze07uMsmvknjEvlHrCe06t1f7ZR/XeCKEGtHaxcNVYGwuz+H Z5vqE9EwQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l0sak-0004uS-K1; Sat, 16 Jan 2021 20:54:38 +0000 Received: from mout.gmx.net ([212.227.17.20]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l0sae-0004s9-NI for linux-arm-kernel@lists.infradead.org; Sat, 16 Jan 2021 20:54:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1610830439; bh=8S9aI3ClrGBcFUY7dvHm0J6Z1DKlVcMmgEJFmYkG5Gw=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=URX2uOP0BbwciB1uYUiHWfahdeLR2+3LihSdeNF4CGyGHl66cao0oFH168KDg/Ke9 TonCUIh+VbS97H+Y3qOorDxqqmnnWI/Fcey6GRTHGL/O7bgB0SHRWXCMdUfpNHLVyB zh3MuiCDAd8NBz3n+gxLx7fuAgKSK7iBVTJZ33zk= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from longitude ([37.201.215.209]) by mail.gmx.com (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MQMyf-1lMWAh2ztR-00MHuL; Sat, 16 Jan 2021 21:53:58 +0100 From: =?utf-8?q?Jonathan_Neusch=C3=A4fer?= To: linux-kernel@vger.kernel.org Subject: [PATCH v8 6/7] MAINTAINERS: Add entry for Netronix embedded controller Date: Sat, 16 Jan 2021 20:48:25 +0100 Message-Id: <20210116194826.3866540-7-j.neuschaefer@gmx.net> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210116194826.3866540-1-j.neuschaefer@gmx.net> References: <20210116194826.3866540-1-j.neuschaefer@gmx.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:u0DJpXh3/VFmATk3b2+OGivHMdWFxS49GuyPCDgWwI1vfQzSnhj MwJqQcar3AQsRv2J6UQ+nZVJUiSOfkckOLAa4iGnzlFoHiJmjRJO7dprHRgA+JICNl2OqbO CarA8SQvpw/oXYICpfTKHrGJOsiuy9KiptoV4E8YcS5FbZODN+jiFPXxHT0Bu0uuomS9k7d kiSrPUmJ048fn15i3Qveg== X-UI-Out-Filterresults: notjunk:1;V03:K0:g2JU5UqzKjE=:1RUtdlFmVSzHHrS6bfDh8r 6xeeBjYTHSB/Nhgked09r3Hy4cS1De2spa5tiOi12AuaCnkkapdwjqMuqyEkAx29Kps/448NU OgJA97W+IbVt5zuO7em3Ua5eM6dK+lBhTQT87hVTDtHUeckwRzn2klrU8w6pEl/3+1MUTQazb 5Bv6ipROkaVIWFUxAAE32NzeoEazDbWa8ogLC3SVPKiNopG110QC/R3sLbECn7oxUb7Vg3X9+ N6KnjkC4/zyYxHFoUPmpmG4VKenG09+SYGekzud6ON9HGGG4eZ9G+kgHb2AzeaRzLxn6yY0YP 3nAWawFQMjWzAiw35W8Nb02A2Pfn21vUomzR1Bd0J8qomtMfrrdcSmbSPXz9lE8QBanNwbcZn HMDuljY5DE9WdhtTZ3RuHG5lxtfEHyfvyx+pN89uU8+lg59Eu//xDI2ZicCOTiDehVA8wf7sO 5nT68MLOWdvvitjp7mxrlBG3yHL09vS8fQjmKOrJwpmRpTfawQLlQWoc23hBPAZWPEB/bcgcW c2FNjorM/sfjZ8Tl2Z4vo43b/Op4Uji3qg1OzQpIiMZnZiHPgXQLN4sie/t1Wn3bmk21N9clt dXzNsqrwU+dAO72RkXhBOoVWWmG0WLmCxswxZHs3VTVjAEGJ0WVojDOwCW1juS7QCUx068UWG HpCQDV94RdBXdc0MCbyvRyfW+3GB6TZk8vzgho25Gg4WP1oMMit6xwE8Nx5k+S9U/pmuupdTy 42yqXaNUCti/iTCeCM4X0NTE/GSaRvVhISBW9+R+/6MquaULeZ0Ye4oLPUNZ67PbVWbZpuvB6 C2PjXx52w+XAxL9FLqIuFb3oVKIw3IEaiI/NzpYHTP9iV/L1fX4cact7fyhS7wIfEYaziijIA F4+jaXqL6nRnNpKDonYA== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210116_155433_039465_7D904B33 X-CRM114-Status: GOOD ( 13.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Belloni , Heiko Stuebner , linux-pwm@vger.kernel.org, Linus Walleij , Thierry Reding , Fabio Estevam , linux-rtc@vger.kernel.org, Arnd Bergmann , Mauro Carvalho Chehab , Sam Ravnborg , Daniel Palmer , Andy Shevchenko , Andreas Kemnade , NXP Linux Team , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , devicetree@vger.kernel.org, Stephan Gerhold , allen , Sascha Hauer , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Lubomir Rintel , Rob Herring , Lee Jones , linux-arm-kernel@lists.infradead.org, Alessandro Zummo , Mark Brown , Pengutronix Kernel Team , Heiko Stuebner , Josua Mayer , Shawn Guo , "David S. Miller" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Let's make sure I'll notice when there are patches for the NTXEC drivers. Signed-off-by: Jonathan Neuschäfer --- v4-v8: - 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 546aa66428c9f..0c6e739e3afb7 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -12298,6 +12298,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 Sat Jan 16 19:48:26 2021 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: 12025027 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=-13.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 E8B84C433E0 for ; Sat, 16 Jan 2021 20:55:59 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 854DD22C97 for ; Sat, 16 Jan 2021 20:55:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 854DD22C97 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmx.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=XDnyuhpMCLXigrh1u5j5PR//sWDqr5THHIJfc2BsDRY=; b=ZG19tFVPr9Jh8dTdBWJFqfNtp guDa+591zXar8a6CFJ5ufOiplv+1YBzKYB4i7FtUokrZwEJv0RSio0cuaU8TxcieJukXfz6avcqI8 /fRUX0GFIZVjQM5MMxWDzQ3ME9+MulFFP8T0Lsar4a+N0SZVQtbgdeVbflPwRvzBHtFqFVOataeH3 QEmgdzp+Etw7GtlaD5XCrblDZg7CCynZZFE4LDJsT+FnPvxxb9S4g+zYzRdYsnUNjqdmRkeqLGmUm wMCOLc/otYy9cZpzf6yAOS8oaufeT3OknawEucWlavmoo3j5EOWKbsEP/gNvIvtPPAjsBmTuQk3mD wHbEaujSg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l0sam-0004uu-9O; Sat, 16 Jan 2021 20:54:40 +0000 Received: from mout.gmx.net ([212.227.17.20]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l0sae-0004s8-NH for linux-arm-kernel@lists.infradead.org; Sat, 16 Jan 2021 20:54:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1610830440; bh=7B6YBniBlOdUKUBNpIZoTRJoQhsWL/33VK8gWA6nQR0=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=ljKvnS5DcTcWGglUZc7S5r2nf+1Ay8faK0t+OTQTHDxY0fQup1oJOWZBb4ypbLOB9 2zxYqQrl6VVlb5cDxkXDrInME0yNy2mFoMcfS9e2v809/mLiWol+4BqIb6W1+pw0lH DHvVRvAVohb5s6jzznWpA850XFRAK4X+Uq8sXF84= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from longitude ([37.201.215.209]) by mail.gmx.com (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MVvPJ-1lS4bN0qpx-00Rm0T; Sat, 16 Jan 2021 21:54:00 +0100 From: =?utf-8?q?Jonathan_Neusch=C3=A4fer?= To: linux-kernel@vger.kernel.org Subject: [PATCH v8 7/7] ARM: dts: imx50-kobo-aura: Add Netronix embedded controller Date: Sat, 16 Jan 2021 20:48:26 +0100 Message-Id: <20210116194826.3866540-8-j.neuschaefer@gmx.net> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210116194826.3866540-1-j.neuschaefer@gmx.net> References: <20210116194826.3866540-1-j.neuschaefer@gmx.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:+jp6Fwxyu/nDxR+wW8seHUGOUPvLEAiset4N4MtufT7Oc6Q1H2z vgGOQA8TIu2zXrneixwjHpWyVlmxoN+ZyoKCu9fow5rgm8q7OhqO+Xe+crmZ5Ynsnri35tl H2YBkUBonCUhLUxk4Pe1J3quJbTC/eTjf/woiTfoJJUAf4DksWKkht7Misn58jht2pbNlv4 GZEQZDNhUQrhmKmD1v8/A== X-UI-Out-Filterresults: notjunk:1;V03:K0:V1e2MGs1JUw=:DlxAGfpi0DVwORanN725CO dgmkRx7uNS5HKdTuGsGB2HBOxdR31P8eSxJQImujGcx7JBZS7YLt16T2ekImW+vDvhi5DA7xL FXIMb+RdCWLjTUoJeTqpwIgeX/76XUBJ3sX1G3CocUlp5S6Np2T3mM9+2PK+Y8Uj/KIE7IlwQ PIOHGTNNPIjkTsdh3p9hCySSUKcXoE9FcLAEOWVv9m10oL9DY9dviEWLmqY/ng3Tqxoy64H+q +QcsFZS3Ixpe0VltL4Kx01fWuLUurcR+7+WB9Av4wcA2qxGYzC7gXu3PYEO/4tsd3KKCEr4bF VP9Gr7Oqp0wl430YPeknqj5hj9v9jxzgVMzmi9lNhpo77MJ4EAlRgimj7EhoWr1Tzc3544Wb7 QLBOTlm4yMNTjfQOFP91eg5UP8c7K9yCx3UYKMbo6UTd/+CBprWQ0q6OMT5xIE8vXfKRwFC7P ktHrqUgCuoa/w/cgdHuCrgjCEmE8C/bQYsRXT5/u6LpL6gnn7aKoeL281fMRhDMEppZFATEAF JvTsp8pw8e3HruZBWGc9gYNcUxPZyvSGEXFTsiUoBvcfK25Xhir86wvjs40NCK35XKNp+FRZ6 cmeBQ+rUSF6INSDceXZA9GIq/34Qr/RVqbxvYpztU5KEAH9Q8JtNBMpNeNIHVcic9NPY8CG04 Hzrnq6ccohlQPG3uXlEjEF7JDpFFWJubqR1I5Hth/Bf7QDGTY3bwTSxoJw+IcOpn+Un4Pdy3x JXvTC1hAQoEpYKjBBrIBb1wo3qV5Hhomr1RESOfB12o3uKZhroZtXlFiWimmAw7n68qdGay6A NhkMH4BkKSvM5ajk3ppRDQvuYA/aTw9zuC6rYXBgFyWrS6dYltI+ypnW9zwEXQo3ul2PGFhcK EAlQCbQASncgDUl5U2SQ== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210116_155433_028803_758E1898 X-CRM114-Status: GOOD ( 15.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Belloni , Heiko Stuebner , linux-pwm@vger.kernel.org, Linus Walleij , Thierry Reding , Fabio Estevam , linux-rtc@vger.kernel.org, Arnd Bergmann , Mauro Carvalho Chehab , Sam Ravnborg , Daniel Palmer , Andy Shevchenko , Andreas Kemnade , NXP Linux Team , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , devicetree@vger.kernel.org, Stephan Gerhold , allen , Sascha Hauer , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Lubomir Rintel , Rob Herring , Lee Jones , linux-arm-kernel@lists.infradead.org, Alessandro Zummo , Mark Brown , Pengutronix Kernel Team , Heiko Stuebner , Josua Mayer , Shawn Guo , "David S. Miller" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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-v8: - no changes v4: - https://lore.kernel.org/lkml/20201123000913.1506944-1-j.neuschaefer@gmx.net/ - 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