From patchwork Fri Dec 24 21:39:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: peter.vasil@gmail.com X-Patchwork-Id: 527891 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6AFBC433F5 for ; Fri, 24 Dec 2021 21:52:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236589AbhLXVw4 (ORCPT ); Fri, 24 Dec 2021 16:52:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231639AbhLXVw4 (ORCPT ); Fri, 24 Dec 2021 16:52:56 -0500 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9930EC061401 for ; Fri, 24 Dec 2021 13:52:55 -0800 (PST) Received: by mail-ed1-x52b.google.com with SMTP id j21so37284006edt.9 for ; Fri, 24 Dec 2021 13:52:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:subject:date:message-id:in-reply-to:references :reply-to:mime-version:content-transfer-encoding; bh=bLPKiuECka/YE3JJhoSvhijCqaMQjSLtYjjU3gVDyq8=; b=GQi3Sq3qWYQu+x4crrqxzV3WRSRDF3trB5dMo5Q62UGfpSb3p7KWKysN+5nLUAhBoQ 4nC9YpB0fmKyZ1InYBb34WlJDQFYDIf3lKCHDjqZ+k61vxsipwn2nXvKLh+eDiI1KKkF kts2thtNPbBL2VmgACrqDIpX+kCCMmqK/uxRdjwLjafw9PSDG0fLoV7BJDLkrji6BHs8 UaiSgoPRKu9zyZvtJ0By9OCITbcYWB84KxU3wcDnsIfJ12jYzli4rVdXbitWLhrwv/Nd OgaJHfSha3Xs6LCoDBrWCPfls8o1QPMABDyOywTfjUQQctPPDvaAAw/42qvKji46rRU7 mhQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:reply-to:mime-version :content-transfer-encoding; bh=bLPKiuECka/YE3JJhoSvhijCqaMQjSLtYjjU3gVDyq8=; b=b9wLaCPi8wRNg7mqLCpJ+5ddSDcskbyIsc65ZOa/pOPmxOr+cSkuHBWjqJ/lGa5Dsj LjZa4TinREOFuG7bQPyNt7nZT/cvwQjUwl6G+fquemzfJKoaTj3NMOlwxRsHwYnICx1b UslyFwfkV8+K1+tSo0xw3WQl/OjKG1dB5/23Gd9FBL7Cm22P0hQG5I8+pqtd0g90Gb+r gmQmy42LZgNqpSOGSggXnz2ichyHbwPLJHhORnR6VhSDDsB+2PKkuuzmMB1Gj+L4yzZ/ qPF2E0wY/rQ7JZZ5A9nTiZgI/pv8Bbu34dZz2MH30bGUQF8X/U0M2tHYPKYt6a3VTj5j +GDQ== X-Gm-Message-State: AOAM5333RWk1VLUrcPfD/CigYmQKkwsrmm7oHp/suUmbwiz2mdnqIN2/ b63Fg6xy5/gZjMsQuTKmAPTktO5o720= X-Google-Smtp-Source: ABdhPJyHepFlhUHgKm3A6/PpNzGPyddR1kcdEX3ZbP0u9JoGtjfGHT1fGMreqPPWBw54adqE02sFbQ== X-Received: by 2002:a17:906:888f:: with SMTP id ak15mr6382425ejc.0.1640382774229; Fri, 24 Dec 2021 13:52:54 -0800 (PST) Received: from localhost.localdomain (bband-dyn119.178-40-49.t-com.sk. [178.40.49.119]) by smtp.gmail.com with ESMTPSA id di5sm3021692ejc.45.2021.12.24.13.52.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Dec 2021 13:52:53 -0800 (PST) Sender: Peter Vasil From: peter.vasil@gmail.com To: peter.vasil@gmail.com, linux-omap@vger.kernel.org Subject: [PATCH 2/6] dt-bindings: regulator: Nokia Tahvo/Betty ASIC Vcore regulator Date: Fri, 24 Dec 2021 22:39:21 +0100 Message-Id: <20211224214512.1583430-3-peter.vasil@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211224214512.1583430-1-peter.vasil@gmail.com> References: <20211224214512.1583430-1-peter.vasil@gmail.com> Reply-To: peter.vasil@gmail.com MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Peter Vasil One of the functions of Tahvo/Betty ASIC MFD chip is a voltage regulator for Vcore output, adjustable from 1.005V to 1.475V. On Nokia N8x0 Internet Tablet devices, this controls power to the Epson S1D13745 framebuffer IC. Reviewed-by: Tony Lindgren --- .../nokia,tahvo-vcore-regulator.yaml | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/nokia,tahvo-vcore-regulator.yaml diff --git a/Documentation/devicetree/bindings/regulator/nokia,tahvo-vcore-regulator.yaml b/Documentation/devicetree/bindings/regulator/nokia,tahvo-vcore-regulator.yaml new file mode 100644 index 000000000000..5e1e98c32311 --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/nokia,tahvo-vcore-regulator.yaml @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/regulator/nokia,tahvo-vcore-regulator.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Nokia Tahvo/Betty ASIC Vcore regulator + +maintainers: + - Peter Vasil + +description: | + One of the functions of Tahvo/Betty ASIC MFD chip is a voltage regulator + for Vcore output, adjustable from 1.005V to 1.475V. + On Nokia N8x0 Internet Tablet devices, this controls power to the Epson + S1D13745 framebuffer IC. + +allOf: + - $ref: "regulator.yaml#" + +properties: + compatible: + const: nokia,tahvo-vcore-regulator + +required: + - compatible + +unevaluatedProperties: false + +examples: + - | + tahvo { + tahvo_vcore { + compatible = "nokia,tahvo-vcore-regulator"; + regulator-name = "tornado_vcore"; + regulator-min-microvolt = <1500000>; + regulator-max-microvolt = <3000000>; + regulator-always-on; + }; + }; +... From patchwork Fri Dec 24 21:56:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: peter.vasil@gmail.com X-Patchwork-Id: 528776 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E270DC433EF for ; Fri, 24 Dec 2021 21:57:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240510AbhLXV5I (ORCPT ); Fri, 24 Dec 2021 16:57:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240336AbhLXV5I (ORCPT ); Fri, 24 Dec 2021 16:57:08 -0500 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0960AC061401 for ; Fri, 24 Dec 2021 13:57:08 -0800 (PST) Received: by mail-ed1-x52f.google.com with SMTP id x15so37445366edv.1 for ; Fri, 24 Dec 2021 13:57:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=OyvgihyUKnAkZZ9N6i7mgmHZa3IHB4liX5osoY6lCeQ=; b=Y6C6iEc5HdmsvJJI6MnL2itrQfEaEwHZNd82qLNXR81C5WUso1WPZ1Ae/vbaspcaVa e0K8SHvAmxjKKNXKKYLSaBkBGAvaryqgHPZhc+P+Y/wedrEAajsfd9+Pq2/WN5b+ykzS Lu50vtZFv9nKOzrr99iFXzQGLcfQ07H1P8xdvRZy+OAz1ZSmFYciel6Wb/RM979g+dL8 +3iaP0AXB28/E+rnL6Mfq/YDxC8yU9nfpvkLbj4cLOISKROyRL0L7OhWAmbpNqbyWBR8 c5TwV196QZaPPavxN7edd3Evwkj94Tt7UnA++HcH3i593DTA06Jw+DokVW+3lUaXAZHj yE9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=OyvgihyUKnAkZZ9N6i7mgmHZa3IHB4liX5osoY6lCeQ=; b=vNSJukgZS+S2kjbY23HyUg43uZktwVfG71JozGGQq2CCwoXGNpfURI2rmGmf2I7v1f 3dZeXraEyvKTHiQo2fZksOvhzn5+oreEHxbD2LAFqf1oRmMhsHB4joXISZ/aJQdidC8N aqNpmLxOzHKjHGwaSg0b4CpO1Ayi2Wo2NQqt+ldifckT+fqNuzlLLVwvn1mEPX3yK0Bj SuqRhw2ZsezNXQU/wcHeBa9zXVW3sffFJHfN7QFIqvccXv3kp2PdPdHwEcwft/P4MsiK kpA7Fdl2XA3B4uGpYurSpy81tDjIQSkstknAWYrPt2SNswwYqpyDchAZDI0lxyAuONVf uKPA== X-Gm-Message-State: AOAM533i+SGs63Ajw0ytpeiMzyYKnlNKVBvRnbZcBKZlrGt6OyoTXgyU MyallKH7Cs1X/bj1LvJgrttJ5JXr0fA= X-Google-Smtp-Source: ABdhPJxqYE2Ryv7GxMSII2owvomOT9QYy8K5P/ZcO9TCAJrpgIYEjTqwkCJM1MQWRzvNMaEx2PbakA== X-Received: by 2002:a17:906:c08c:: with SMTP id f12mr6251860ejz.419.1640383026499; Fri, 24 Dec 2021 13:57:06 -0800 (PST) Received: from localhost.localdomain (bband-dyn119.178-40-49.t-com.sk. [178.40.49.119]) by smtp.gmail.com with ESMTPSA id dn10sm3022476ejc.139.2021.12.24.13.56.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Dec 2021 13:57:06 -0800 (PST) Sender: Peter Vasil From: peter.vasil@gmail.com To: linux-omap@vger.kernel.org Cc: peter.vasil@gmail.com Subject: [PATCH 3/6] ARM: dts: omap2420-n810: Add Tahvo/Betty LEDPWM and Vcore bindings Date: Fri, 24 Dec 2021 22:56:32 +0100 Message-Id: <20211224215635.1585808-3-peter.vasil@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Peter Vasil Nokia Tahvo/Betty ASIC provides PWM output for LED control and voltage regulator for adjustable Vcore output. These are both used on N8x0 devices for display control; LEDPWM for backlight and Vcore for framebuffer IC power. --- arch/arm/boot/dts/omap2420-n810.dts | 13 +++++++++++++ arch/arm/boot/dts/omap2420-n8x0-common.dtsi | 8 +++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/arch/arm/boot/dts/omap2420-n810.dts b/arch/arm/boot/dts/omap2420-n810.dts index 09c1dbc0bb69..30f9f9e1a377 100644 --- a/arch/arm/boot/dts/omap2420-n810.dts +++ b/arch/arm/boot/dts/omap2420-n810.dts @@ -22,6 +22,19 @@ v28_aic: v28_aic { }; }; +&tahvo { + tahvo_ledpwm: tahvo_ledpwm { + compatible = "nokia,tahvo-ledpwm"; + }; + tahvo_vcore: tahvo_vcore { + compatible = "nokia,tahvo-vcore-regulator"; + regulator-name = "tornado_vcore"; + regulator-min-microvolt = <1005000>; + regulator-max-microvolt = <1475000>; + regulator-always-on; + }; +}; + &omap2420_pmx { mcbsp2_pins: mcbsp2_pins { pinctrl-single,pins = < diff --git a/arch/arm/boot/dts/omap2420-n8x0-common.dtsi b/arch/arm/boot/dts/omap2420-n8x0-common.dtsi index 63b0b4921e4e..88d44f5a5f63 100644 --- a/arch/arm/boot/dts/omap2420-n8x0-common.dtsi +++ b/arch/arm/boot/dts/omap2420-n8x0-common.dtsi @@ -22,9 +22,15 @@ &gpio3 0 GPIO_ACTIVE_HIGH /* gpio64 sel */ #size-cells = <0>; retu: retu@1 { compatible = "nokia,retu"; + reg = <0x1>; interrupt-parent = <&gpio4>; interrupts = <12 IRQ_TYPE_EDGE_RISING>; - reg = <0x1>; + }; + tahvo: tahvo@2 { + compatible = "nokia,tahvo"; + reg = <0x2>; + interrupt-parent = <&gpio4>; + interrupts = <15 IRQ_TYPE_EDGE_RISING>; }; }; }; From patchwork Fri Dec 24 21:56:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: peter.vasil@gmail.com X-Patchwork-Id: 527890 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5192C433EF for ; Fri, 24 Dec 2021 21:57:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234534AbhLXV5Q (ORCPT ); Fri, 24 Dec 2021 16:57:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233643AbhLXV5P (ORCPT ); Fri, 24 Dec 2021 16:57:15 -0500 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87112C061401 for ; Fri, 24 Dec 2021 13:57:15 -0800 (PST) Received: by mail-ed1-x531.google.com with SMTP id f5so37329662edq.6 for ; Fri, 24 Dec 2021 13:57:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rwn2XFIyLqDYr0I7kyX/47b7/JOctwrfRN+rhupWkLI=; b=YjiOouUZtOGXYBcvuACaLmGQQDHVwnHKqOZOoHVqLA7yUBFmajKroh4smqNzZYmX54 p8GFbKm/QoevwEcsK2o+GSAL8s5hXN2h6wPJB8qXmMnNdEznSAOv7YJeDoeu0Kd0f6Ye gnjKIM1Y81+nMpYxTXg28xfPM6Kpi0YW7yp0QPNWp8UPjvELO1yg4Z6pew/L6Z69bITI /FBbuckFqaOe7tHUcOxC39oZmhJaooixydXAZAnwfvcBlZZPpClX/Sr7X9tqkshNY+Dc Y84duCZY/sNbP8Xmv8yHlQygJYyvI25Gg5NtvsZS+no9NAkZgap/XOAuo/UhqEFUAl3b G6gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=rwn2XFIyLqDYr0I7kyX/47b7/JOctwrfRN+rhupWkLI=; b=MeSGF/jWXHJ33x/nHYrlJqFnFPXqtobSQ4kNTasAThr9ckb8rjraxEt/wct2B5Opmi CMg5lqFV6FYysyCWjR7A3j+faRnuZRa0dlJ+I74zoPooQc09UXPuThBwcKP9pZ5yTxG/ 2QJYFOfFGLwkmMgF+qhlUJ9oZKHqCAW8DLuSClpUI5VXWn8vKZu6VCgXNCmVwWmPidKf lBiaEtlwxYMT4y/6Z1R0THH2u9m37kGA6tk+uo5922hoVtwwtqlVYRPiawi7l+t1d1Ai GQVAJaDj9qOYxSSKYsbCgwG/u3usgEYjtj4Rx4Nm/5NrVO7kn2oGCmUPksJrfaMJn5d5 dwQA== X-Gm-Message-State: AOAM533rs3843nxU0n0xWzDHFMCUO9nAZVR8fnCAV3U3Do6ZVClFNDDv v5eMorDcjWFQhX6hQPEkOPXLl0vFP90= X-Google-Smtp-Source: ABdhPJySHpGKLehPJSwAej7tnJ69s99gKdRQ2npcmETHO/vWh8VfcO4UO6DFdmdYL4xD/mV8Xsg+RQ== X-Received: by 2002:a17:906:9acd:: with SMTP id ah13mr6436058ejc.666.1640383034157; Fri, 24 Dec 2021 13:57:14 -0800 (PST) Received: from localhost.localdomain (bband-dyn119.178-40-49.t-com.sk. [178.40.49.119]) by smtp.gmail.com with ESMTPSA id dn10sm3022476ejc.139.2021.12.24.13.57.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Dec 2021 13:57:13 -0800 (PST) Sender: Peter Vasil From: peter.vasil@gmail.com To: linux-omap@vger.kernel.org Cc: peter.vasil@gmail.com Subject: [PATCH 4/6] leds: tahvo: Driver for Tahvo/Betty ASIC LEDPWM output Date: Fri, 24 Dec 2021 22:56:33 +0100 Message-Id: <20211224215635.1585808-4-peter.vasil@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211224215635.1585808-3-peter.vasil@gmail.com> References: <20211224215635.1585808-3-peter.vasil@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Peter Vasil Nokia Tahvo/Betty ASIC is a companion chip for mobile devices. One of its outputs is a 127-levels PWM, usually used for LED or backlight control. Register control code has been written based on original Nokia kernel sources for N810 display driver. Driver expects a regmap device as parent, usually retu-mfd driver bound to the Tahvo ASIC. --- drivers/leds/Kconfig | 12 ++++++ drivers/leds/Makefile | 1 + drivers/leds/leds-tahvo.c | 85 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 drivers/leds/leds-tahvo.c diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index ed800f5da7d8..010d455a2151 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -871,6 +871,18 @@ config LEDS_ACER_A500 This option enables support for the Power Button LED of Acer Iconia Tab A500. +config LEDS_TAHVO + tristate "Tahvo PWM led support" + depends on LEDS_CLASS && MFD_RETU + help + Tahvo PWM LED driver for Nokia Internet Tablets (770, N800, + N810). At least on N810 the LCD backlight is controlled by + Tahvo/Betty MFD. + + To compile this driver as a module, choose M here: the + module will be called leds-tahvo. + + source "drivers/leds/blink/Kconfig" comment "Flash and Torch LED drivers" diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index c636ec069612..30832d3bc947 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -87,6 +87,7 @@ obj-$(CONFIG_LEDS_TURRIS_OMNIA) += leds-turris-omnia.o obj-$(CONFIG_LEDS_WM831X_STATUS) += leds-wm831x-status.o obj-$(CONFIG_LEDS_WM8350) += leds-wm8350.o obj-$(CONFIG_LEDS_WRAP) += leds-wrap.o +obj-$(CONFIG_LEDS_TAHVO) += leds-tahvo.o # LED SPI Drivers obj-$(CONFIG_LEDS_CR0014114) += leds-cr0014114.o diff --git a/drivers/leds/leds-tahvo.c b/drivers/leds/leds-tahvo.c new file mode 100644 index 000000000000..53feb0749e76 --- /dev/null +++ b/drivers/leds/leds-tahvo.c @@ -0,0 +1,85 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Tahvo LED PWM driver + * + * Copyright (C) 2004, 2005 Nokia Corporation + * + * Based on original 2.6 kernel driver for Nokia N8x0 LCD panel. + * Rewritten by Peter Vasil. + */ + +#include +#include +#include +#include +#include + +#define TAHVO_REG_LEDPWM 0x05 + +/* Maximum power/brightness value */ +#define TAHVO_LEDPWM_MAX 127 + +struct tahvo_led { + struct led_classdev cdev; + struct regmap *regmap; +}; + +static int tahvo_led_brightness_set(struct led_classdev *cdev, + enum led_brightness brightness) +{ + struct tahvo_led *led = container_of(cdev, struct tahvo_led, cdev); + + return regmap_write(led->regmap, TAHVO_REG_LEDPWM, brightness); +} + +static int tahvo_led_probe(struct platform_device *pdev) +{ + struct tahvo_led *led; + struct led_init_data init_data; + int ret; + + led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL); + if (!led) + return -ENOMEM; + + if (pdev->dev.of_node && pdev->dev.of_node->name) { + led->cdev.name = pdev->dev.of_node->name; + } else { + dev_warn(&pdev->dev, "No OF node found, using default name!\n"); + led->cdev.name = "tahvo:led"; + } + + led->cdev.max_brightness = TAHVO_LEDPWM_MAX; + led->cdev.brightness_set_blocking = tahvo_led_brightness_set; + + led->regmap = dev_get_regmap(pdev->dev.parent, NULL); + + init_data.fwnode = of_fwnode_handle(pdev->dev.of_node); + + ret = devm_led_classdev_register_ext(&pdev->dev, &led->cdev, &init_data); + if (ret) { + dev_err(&pdev->dev, "failed to register PWM LED (%d)\n", ret); + return ret; + } + + return 0; +} + +static const struct of_device_id of_tahvo_leds_match[] = { + { .compatible = "nokia,tahvo-ledpwm", }, + {}, +}; + +static struct platform_driver tahvo_led_driver = { + .probe = tahvo_led_probe, + .driver = { + .name = "tahvo-ledpwm", + .of_match_table = of_match_ptr(of_tahvo_leds_match), + }, +}; +module_platform_driver(tahvo_led_driver); + +MODULE_ALIAS("platform:tahvo-ledpwm"); +MODULE_DESCRIPTION("Tahvo LED PWM"); +MODULE_AUTHOR("Peter Vasil "); +MODULE_LICENSE("GPL"); From patchwork Fri Dec 24 21:56:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: peter.vasil@gmail.com X-Patchwork-Id: 528775 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85E83C433F5 for ; Fri, 24 Dec 2021 21:57:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233643AbhLXV5V (ORCPT ); Fri, 24 Dec 2021 16:57:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233632AbhLXV5V (ORCPT ); Fri, 24 Dec 2021 16:57:21 -0500 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D0B0C061401 for ; Fri, 24 Dec 2021 13:57:21 -0800 (PST) Received: by mail-ed1-x530.google.com with SMTP id o6so37367855edc.4 for ; Fri, 24 Dec 2021 13:57:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8SExs5MqnW1iYmYp73hdM/V09cGq8YvDMs/ITrsptY0=; b=bC01/raFpkGU7KlHcaPlKkslHbxnc+yWM3xwIq9fW+OwkrZs9CvKuqTl2nyVBjYbw3 SaHQANteA2uwRBMJl3dBkJmrPKKetkNoOYDPo5ZlN2jWg1wDuhv/VoY3nlSTiUccLMVX TfzgPUoXNGGI9gRvPg8CrlrDM5ihDiXLCmhKGvLiCJagkcLTsAtzelRpj+vWGcY+vRgp 1uz/enc/1AQTura52XLcWSSsX9RjcKvPClPokYA7e81hW6kER6TTUT/SJs7Zsoy2uq8r qvd0agzgxknwqr+fqdhgLZ9+z/DeFQPs+7CJ8whO3LXdE9xU3wEulbq+DOfUTP6BSiS0 +7Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=8SExs5MqnW1iYmYp73hdM/V09cGq8YvDMs/ITrsptY0=; b=NM064dUTLpQYUBUJTwf2ZIeUw9kcU7EsEQFl7iEYlnm63kY7M8IWs3+tRXTVLvDrSj c86HHADX2mlcWYa1ZfTh+vdN8J2ZlPJ8GTI9e5dHSqzvkz65uCKHMX5AUK+G8Cq746pu wh+dA1KxwDdpYx3JrBnMLmban+8iS7LMugq59yEJlpF1MWrCj+Gv25sGraBMIGnUQ8F8 JeDNkO7LlflHCB1Svzv6SSX0cDmZ8mfPMa8isUqb57CtjIrVJb7Ds8EeianyemnmAbCB PQJsmnDjOwsONV8LM3roGeKjfpbItVgklDGse6IXw8hpMs1W4rFmgDqsWfA2s8QRQn0e /o1g== X-Gm-Message-State: AOAM532olWcJp+JBmIRboj8o/7crGTRzk/gqm+q/4Jd4AaNLxEslcutG YMz6Akm1/iuoLWKfPhDWRACo2YedW8Q= X-Google-Smtp-Source: ABdhPJzF5WWOp2nw5OotBVppBEV1DdNvw80rZwGlYOteeLgHluckWtqf7G5XmuxSaORxD5pZhrXwdA== X-Received: by 2002:a17:907:7f1d:: with SMTP id qf29mr6933134ejc.560.1640383039800; Fri, 24 Dec 2021 13:57:19 -0800 (PST) Received: from localhost.localdomain (bband-dyn119.178-40-49.t-com.sk. [178.40.49.119]) by smtp.gmail.com with ESMTPSA id dn10sm3022476ejc.139.2021.12.24.13.57.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Dec 2021 13:57:19 -0800 (PST) Sender: Peter Vasil From: peter.vasil@gmail.com To: linux-omap@vger.kernel.org Cc: peter.vasil@gmail.com Subject: [PATCH 5/6] regulator: tahvo-vcore: Add basic Tahvo/Betty ASIC Vcore output support Date: Fri, 24 Dec 2021 22:56:34 +0100 Message-Id: <20211224215635.1585808-5-peter.vasil@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211224215635.1585808-3-peter.vasil@gmail.com> References: <20211224215635.1585808-3-peter.vasil@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Peter Vasil Nokia Tahvo/Betty ASIC is a companion chip for mobile devices. One of its outputs is a Vcore adjustable voltage regulator. Register control code has been written based on original Nokia kernel sources for N810 display driver. Driver expects a regmap device as parent, usually retu-mfd driver bound to the Tahvo ASIC. --- drivers/regulator/Kconfig | 8 ++ drivers/regulator/Makefile | 1 + drivers/regulator/tahvo-vcore-regulator.c | 104 ++++++++++++++++++++++ 3 files changed, 113 insertions(+) create mode 100644 drivers/regulator/tahvo-vcore-regulator.c diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 6be9b1c8a615..16c684c742cf 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -1404,6 +1404,14 @@ config REGULATOR_WM8994 This driver provides support for the voltage regulators on the WM8994 CODEC. +config REGULATOR_TAHVO_VCORE + tristate "Tahvo/Betty Vcore regulator support" + depends on MFD_RETU + help + This driver supports Vcore voltage control on Nokia's Tahvo/Betty + ASIC chip. The regulator controls framebuffer supply voltage in + Nokia internet tablets (for sure at least N810). + config REGULATOR_QCOM_LABIBB tristate "QCOM LAB/IBB regulator support" depends on SPMI || COMPILE_TEST diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index b07d2a22df0b..ed64d2cf8a42 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile @@ -170,5 +170,6 @@ obj-$(CONFIG_REGULATOR_WM831X) += wm831x-ldo.o obj-$(CONFIG_REGULATOR_WM8350) += wm8350-regulator.o obj-$(CONFIG_REGULATOR_WM8400) += wm8400-regulator.o obj-$(CONFIG_REGULATOR_WM8994) += wm8994-regulator.o +obj-$(CONFIG_REGULATOR_TAHVO_VCORE) += tahvo-vcore-regulator.o ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG diff --git a/drivers/regulator/tahvo-vcore-regulator.c b/drivers/regulator/tahvo-vcore-regulator.c new file mode 100644 index 000000000000..a7c92aa7a148 --- /dev/null +++ b/drivers/regulator/tahvo-vcore-regulator.c @@ -0,0 +1,104 @@ +// SPDX-License-Identifier: GPL-2.0+ +// +// Copyright (C) 2004, 2005 Nokia Corporation +// +// Based on original 2.6 kernel driver for Nokia N8x0 LCD panel. +// Rewritten in 2021 by Peter Vasil . +// +// Driver for Nokia Betty/Tahvo Vcore regulator +// The only known voltages are currently 1.005V==0x0f and 1.475V==0x00 with mask 0x0f +// Whether the sequence is actually linear is only a guess. + +#include +#include +#include +#include +#include +#include +#include +#include + +#define TAHVO_REG_VCORE 0x07 + +// Values in this table are simply interpolated from the only known min/max. +static const unsigned int tahvo_vcore_voltages[] = { + 1475000, 1443667, 1412333, 1381000, 1349667, 1318333, 1287000, 1255667, + 1224333, 1193000, 1161667, 1130333, 1099000, 1067667, 1036333, 1005000, +}; + +static const struct regulator_ops tahvo_vcore_regulator_voltage_ops = { + .list_voltage = regulator_list_voltage_table, + .map_voltage = regulator_map_voltage_iterate, + .get_voltage_sel = regulator_get_voltage_sel_regmap, + .set_voltage_sel = regulator_set_voltage_sel_regmap, +}; + +static const struct regulator_desc vcore_regulator = { + .name = "vcore", + .ops = &tahvo_vcore_regulator_voltage_ops, + .type = REGULATOR_VOLTAGE, + .owner = THIS_MODULE, + .volt_table = tahvo_vcore_voltages, + .n_voltages = ARRAY_SIZE(tahvo_vcore_voltages), + .vsel_reg = TAHVO_REG_VCORE, + .vsel_mask = 0x0f, +}; + +static const struct regmap_config tahvo_vcore_regmap_config = { + .reg_bits = 8, + .reg_stride = 1, + .val_bits = 16, +}; + +static int tahvo_vcore_regulator_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct regulator_init_data *init_data; + struct regulator_config cfg = {}; + struct regulator_dev *rdev; + + init_data = of_get_regulator_init_data(dev, dev->of_node, + &vcore_regulator); + if (!init_data) { + dev_err(dev, "Failed to init regulator data!\n"); + return -EINVAL; + } + + cfg.dev = dev; + cfg.init_data = init_data; + cfg.of_node = dev->of_node; + + cfg.regmap = dev_get_regmap(dev->parent, NULL); + if (!cfg.regmap) { + dev_err(dev, "failed to locate regmap\n"); + return -ENODEV; + } + + rdev = devm_regulator_register(dev, &vcore_regulator, &cfg); + if (IS_ERR(rdev)) { + dev_err(dev, "Failed to register regulator: %ld\n", + PTR_ERR(rdev)); + return PTR_ERR(rdev); + } + platform_set_drvdata(pdev, rdev); + + return 0; +} + +static const struct of_device_id regulator_tahvo_vcore_of_match[] = { + { .compatible = "nokia,tahvo-vcore-regulator", }, + {}, +}; + +static struct platform_driver tahvo_vcore_regulator_driver = { + .probe = tahvo_vcore_regulator_probe, + .driver = { + .name = "tahvo-vcore-regulator", + .of_match_table = of_match_ptr(regulator_tahvo_vcore_of_match), + }, +}; +module_platform_driver(tahvo_vcore_regulator_driver); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Peter Vasil "); +MODULE_DESCRIPTION("Tahvo/Betty Vcore voltage regulator"); From patchwork Fri Dec 24 21:56:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: peter.vasil@gmail.com X-Patchwork-Id: 527889 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97022C433EF for ; Fri, 24 Dec 2021 21:57:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237355AbhLXV53 (ORCPT ); Fri, 24 Dec 2021 16:57:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233632AbhLXV52 (ORCPT ); Fri, 24 Dec 2021 16:57:28 -0500 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AAA7C061401 for ; Fri, 24 Dec 2021 13:57:28 -0800 (PST) Received: by mail-ed1-x52e.google.com with SMTP id w16so37288747edc.11 for ; Fri, 24 Dec 2021 13:57:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JGZIbbsGOGDyIHFhL0ruciSkXe78R0Kf5Ainmkje574=; b=LUlEvItqcVPfG92VEKV93vYAp0apjmqyc+oxWCAB0S8Haot+e6gFpgcAv6gWXa+RH5 O424D+wnUqjKgJG0kBN+kLe8qxPSmGVGw9bwO5vXVpAzPYiWzFq4D1nxZM5SutCbWHpl OGfIR0BlAitPHtbzOTnMjdmhlvgpZ/FVIOyiTrZrBU0ASjqEWgbGg6SGborNHE8lW2Pp LePgpr3u7DamJGJfN9MbEJytBrYKtsLoCRzNQzBKvuzEFDBVasgrNIO/OTvU71JO2Nmc D17bOa5OpMi0J1k5oa/gJ39/4rwYf7pTElfRLje5WrEiO3F+VmFlD/WDNT8//ZiZ+SmY qp0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=JGZIbbsGOGDyIHFhL0ruciSkXe78R0Kf5Ainmkje574=; b=dB270EqQHWUEAmXVtDW62P5jFTnhe3sAa7Ojjd+78EiZvc8TFMBKU0CSqmW4kFH5OG htqSZWk5j1zkrMZ1CBUwmVqihwyVcxNOkno+dT3N9uz+Cwq4Pc5sjw6nIhsYHMM2GSjD ctbqhioxhclon9ing3KQhb+rmFglhPzQ+b+d7dLSEI/t+v9T1f0tUY/gCGO2yCbiZ0pm qEf7Nba1rSPOOQ1O/Vk+Q0IG5D9Jft/KBNWxYVIVRZRLvkcK3jkiS/uIOWrI60l5E75+ tZ8J54ZG/QwapoozFyVoS7bowi+xcV9iTBNyb0O+FjfZqK5RuVEe0OhpsqIY9BgQBVf3 kATA== X-Gm-Message-State: AOAM5301Ohbg1c7g+EjFBx0KQ8ZaNpevNYlO13WBWSiPcTEBmPWlOsNi ecgMIk1Pkqv8o9+V3bXcgIRSv5R1hT8= X-Google-Smtp-Source: ABdhPJyJNGCAgyBgNX3tuBucuODiq5YP7vP6sxslvyrF3xlgE8agpf1ZgXB0qqbYMdNz5UFoElDwYQ== X-Received: by 2002:a05:6402:16cd:: with SMTP id r13mr7134777edx.264.1640383047030; Fri, 24 Dec 2021 13:57:27 -0800 (PST) Received: from localhost.localdomain (bband-dyn119.178-40-49.t-com.sk. [178.40.49.119]) by smtp.gmail.com with ESMTPSA id dn10sm3022476ejc.139.2021.12.24.13.57.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Dec 2021 13:57:26 -0800 (PST) Sender: Peter Vasil From: peter.vasil@gmail.com To: linux-omap@vger.kernel.org Cc: peter.vasil@gmail.com Subject: [PATCH 6/6] mfd: retu: Add support for LEDPWM and Vcore regulator MFD cells Date: Fri, 24 Dec 2021 22:56:35 +0100 Message-Id: <20211224215635.1585808-6-peter.vasil@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211224215635.1585808-3-peter.vasil@gmail.com> References: <20211224215635.1585808-3-peter.vasil@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Peter Vasil Add MFD cells for new Tahvo ASIC LEDPWM and Vcore regulator drivers. --- drivers/mfd/retu-mfd.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/mfd/retu-mfd.c b/drivers/mfd/retu-mfd.c index c748fd29a220..3a4f3c64ae72 100644 --- a/drivers/mfd/retu-mfd.c +++ b/drivers/mfd/retu-mfd.c @@ -99,6 +99,14 @@ static const struct mfd_cell tahvo_devs[] = { .resources = tahvo_usb_res, .num_resources = ARRAY_SIZE(tahvo_usb_res), }, + { + .name = "tahvo-ledpwm", + .of_compatible = "nokia,tahvo-ledpwm" + }, + { + .name = "tahvo-vcore-regulator", + .of_compatible = "nokia,tahvo-vcore-regulator" + }, }; static struct regmap_irq tahvo_irqs[] = {