From patchwork Fri Mar 1 11:11:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dimitri Fedrau X-Patchwork-Id: 208786 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp1004577dyb; Fri, 1 Mar 2024 03:15:03 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUTFIrQs4pFS1LFSDV94bAKNbCHiwry2J/ORvh32KzBS5QJIlpQ4ijZOERnfCGeiZ/a/cCwrvgbRXCRvyNgqlMUqwlRCA== X-Google-Smtp-Source: AGHT+IGS8BbvSgtGJAA3lgUqV/FvA+b+7bzuRiU16mLcMOHzc+MG59WbzitLAj6tEIXRnU68GJgu X-Received: by 2002:a50:cc43:0:b0:565:78ff:f066 with SMTP id n3-20020a50cc43000000b0056578fff066mr1046829edi.5.1709291703793; Fri, 01 Mar 2024 03:15:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709291703; cv=pass; d=google.com; s=arc-20160816; b=haEk1w4/wxHll+hpmpI7r+X0ZMCrik/5vhhQ8Ts4g+lVuWv9PASR6ZRT5YbJnyDHQS LwlqVqN4f6n1/FZujuro0AkH9sJH+p5AjDWMAIM8W2m7df7nlEO/2AC5VSPpzeUSPVbH 7x+PfoCBbjWLiiC2yWiRYhmX4cUJqUBYoVB8yoGLkoGkbCrj5caxRJBERG2oMjFEU9G+ DeNCZn3+CxqaTH5X6DIEt4BJ3nsfS0iIC/ql7/z4QJcyEtzYgGxK3ZPEt2+f+PRRpeNg AfLev7iZvnJhBKj9J3Hrj9H1HK0of/uO6lZ/mUSSM6xO053I1ssdS8TYGpq8FrdLMQLC zFuQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=TFXpgh2dqrGyE1Rignr5uC/50XLP7JPOWIkkNnxbS/8=; fh=uiYkAr9F8tTc/ja6MFTGDjo9PAxwJE9+DI5RFgX5e2A=; b=f08DPYxrBi9cD1fyvNbaqcUMvo3+SVpujMHce7Zc54BDFwA5CIWASRqDD4bfcQcI/j 6t0vsr2qYZrOsCIurU4qmgO/L6BPprQLjQZCxYS2+mkMf/cQAz1WQEao5cgOy/u9rqtF HRUOIKRXJDi1g+dT+IOyq3fn98fRem7NrIAF9WYdD3mlFFib04flo8hu+p+mdClnQ2+7 ULMtsRcIL7b4HcN19e7wJjfG1o9FJ+e33feHn7Khv+5Iq/OdJmMQSwi92iYvpjpYMXSg taix5rQAwR5gquXfNUhQcp907fJhmVuYf9RVmaxJDU7CmRq9UlWqU4S3Zgv6IF6gtJEo jE5Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=jpgMwL0k; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-88317-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88317-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id q12-20020a056402032c00b00564dd8b0d48si1436324edw.638.2024.03.01.03.15.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 03:15:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88317-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=jpgMwL0k; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-88317-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88317-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 40DBB1F21AF1 for ; Fri, 1 Mar 2024 11:15:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E60AE6FBB7; Fri, 1 Mar 2024 11:12:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jpgMwL0k" Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7B78B6CDA5; Fri, 1 Mar 2024 11:12:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709291563; cv=none; b=Vx+ZFj/GLaeA9I2cBQZjf0ethJcVAHaIo0lTUzVqm4WfZ8KebB7SjxhFgmsoexK1kBnrFIVhTW7mLj+KJXJWeofM/uy5hSN/SZIPpdrvCslDrTpqARTZ811GevRfgh6uhFUaLI69bqfP4aifWxGQEkH+QGQdOTwElRjeD83i1S4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709291563; c=relaxed/simple; bh=ZcXh5FtON65IFFWLi8WCHoxgIUc/5UvzSJLTC0D+gNQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=eCmjdcWnkpHSUwt5Vcg7egCcf9jSW/uwyAuGJeTA18p4XzXCgG6JLQOl2x6ej6BH59pqhQWYQJtzf9tMtH0CUziu0vrM63LlIAaS8iK2p8WC7eeZzphjWTS6DpU7IbfoT2dN62wa6d3o2/9zaNUcA2pt3qkvU72e049isjD6IbM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jpgMwL0k; arc=none smtp.client-ip=209.85.208.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-565c6cf4819so5094183a12.1; Fri, 01 Mar 2024 03:12:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709291560; x=1709896360; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TFXpgh2dqrGyE1Rignr5uC/50XLP7JPOWIkkNnxbS/8=; b=jpgMwL0k29ruQU1wmWPgGaVhI+N0FsK8OyXMmbF8ELJFe0V2miHvHPEVNR+F4uq5OA BHtbcQaqdPEDW+NOS8thOur7RvB9wbd42uKsShqo5LbsvI7y4RlULKZTW8/xjAPRuPwn bSKc0nCjFZ7PPujcF7a0RJVtEjniaRQcgTzzyyQLisgVHPBs8DFq7c+p8ulH3dRyOFzu iJoXnAEGJYwiJxRdnG6iXWx88ZYkk/7bysZCVLFdfSNVuUAlvNEGsYGXc0AjmP4jN4HS V+Fv7Jc9/3eG4uRRyk5G5m+M3aCOiJb7kmt6DKfFC1ww4mq1l3w4S2lVgxQPUjrp8h7D KQXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709291560; x=1709896360; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TFXpgh2dqrGyE1Rignr5uC/50XLP7JPOWIkkNnxbS/8=; b=LucRiZ2wiLVp4Vb0iupHP7W7vAkqXDACzFn1I67D/EGxL1KSIEd4XPpW6riVRY29Ua QtUMEvnjWBRiqfhvMUHIDdSv3JPLKPtTqGYkazNFSb0mFkIKCc7Nxiy/2vo0d36I5vU8 Xy4eMQyj3Xxxt12mkzK6n0M+2i6SpwkKj/CfjdJujJZmg/M0FC3zuWE5mUSPualYm5cA GmdkGh0aLZwC1E89OtyfMTCqSVKGJwxpIPJwHxER9ZCz3U+KhcyamemlWKN+0yJNIhbm IF7ozSC9rJncoWuE90XBdRrAc97Jic3TDEAs/thNU0C6U1Q9khU2NysUQ/GJn5zsA5u4 kVvg== X-Forwarded-Encrypted: i=1; AJvYcCXs8M/Mr26a3xxtfQarmAFImBDtiqybcSdQXRm71sdiZ5uGUePeUTX9o7rIeQ76kfougStsSWrxvFigKyVCiriQPqkkYGobp0ZYpT/eSgAFrXomXvXRf+nuDtwwoTIsJJ/9lQU7ZDcaCukyoHLAAHQ3LmidJM8vz+nrtPtpddWOOgSJxQ== X-Gm-Message-State: AOJu0YzQybvoVuIIGRUHDywVbgvXgLdgFZK2Qc92bwdlhIDlP6Gq0x/6 xv+wAv1vEA44Ng4D5yqYF9WvVgJzDZ5axD8olhK7hqCjwu5re7uV+zK1vPQh X-Received: by 2002:a17:906:7f0f:b0:a3f:d260:4a72 with SMTP id d15-20020a1709067f0f00b00a3fd2604a72mr1197125ejr.27.1709291559560; Fri, 01 Mar 2024 03:12:39 -0800 (PST) Received: from debian.fritz.box ([93.184.186.109]) by smtp.gmail.com with ESMTPSA id n18-20020a170906089200b00a43a478e4f0sm1583254eje.180.2024.03.01.03.12.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 03:12:39 -0800 (PST) From: Dimitri Fedrau To: Cc: Dimitri Fedrau , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-pwm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/3] dt-bindings: pwm: add support for MC33XS2410 Date: Fri, 1 Mar 2024 12:11:22 +0100 Message-Id: <20240301111124.29283-2-dima.fedrau@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240301111124.29283-1-dima.fedrau@gmail.com> References: <20240301111124.29283-1-dima.fedrau@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792322257092034589 X-GMAIL-MSGID: 1792322257092034589 Adding documentation for NXPs MC33XS2410 high side switch. Signed-off-by: Dimitri Fedrau Reviewed-by: Krzysztof Kozlowski --- .../bindings/pwm/nxp,mc33xs2410.yaml | 118 ++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 Documentation/devicetree/bindings/pwm/nxp,mc33xs2410.yaml diff --git a/Documentation/devicetree/bindings/pwm/nxp,mc33xs2410.yaml b/Documentation/devicetree/bindings/pwm/nxp,mc33xs2410.yaml new file mode 100644 index 000000000000..1729fe5c3dfb --- /dev/null +++ b/Documentation/devicetree/bindings/pwm/nxp,mc33xs2410.yaml @@ -0,0 +1,118 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pwm/nxp,mc33xs2410.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: High-side switch MC33XS2410 + +maintainers: + - Dimitri Fedrau + +allOf: + - $ref: pwm.yaml# + - $ref: /schemas/spi/spi-peripheral-props.yaml# + +properties: + compatible: + const: nxp,mc33xs2410 + + reg: + maxItems: 1 + + spi-max-frequency: + maximum: 10000000 + + spi-cpha: true + + spi-cs-setup-delay-ns: + minimum: 100 + default: 100 + + spi-cs-hold-delay-ns: + minimum: 10 + default: 10 + + spi-cs-inactive-delay-ns: + minimum: 300 + default: 300 + + reset-gpios: + description: + GPIO connected to the active low reset pin. + maxItems: 1 + + "#pwm-cells": + const: 3 + + pwm-names: + items: + - const: di0 + - const: di1 + - const: di2 + - const: di3 + + pwms: + description: + Direct inputs(di0-3) are used to directly turn-on or turn-off the + outputs. + maxItems: 4 + + interrupts: + maxItems: 1 + + clocks: + description: + The external clock can be used if the internal clock doesn't meet + timing requirements over temperature and voltage operating range. + maxItems: 1 + + vdd-supply: + description: + Logic supply voltage + + vspi-supply: + description: + Supply voltage for SPI + + vpwr-supply: + description: + Power switch supply + +required: + - compatible + - reg + +unevaluatedProperties: false + +examples: + - | + #include + #include + spi { + #address-cells = <1>; + #size-cells = <0>; + + pwm@0 { + compatible = "nxp,mc33xs2410"; + reg = <0x0>; + spi-max-frequency = <4000000>; + spi-cpha; + spi-cs-setup-delay-ns = <100>; + spi-cs-hold-delay-ns = <10>; + spi-cs-inactive-delay-ns = <300>; + reset-gpios = <&gpio3 22 GPIO_ACTIVE_LOW>; + #pwm-cells = <3>; + pwm-names = "di0", "di1", "di2", "di3"; + pwms = <&pwm0 0 1000000>, + <&pwm1 0 1000000>, + <&pwm2 0 1000000>, + <&pwm3 0 1000000>; + interrupt-parent = <&gpio0>; + interrupts = <31 IRQ_TYPE_LEVEL_LOW>; + clocks = <&clk_ext_fixed>; + vdd-supply = <®_3v3>; + vspi-supply = <®_3v3>; + vpwr-supply = <®_24v0>; + }; + }; From patchwork Fri Mar 1 11:11:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dimitri Fedrau X-Patchwork-Id: 208787 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp1004685dyb; Fri, 1 Mar 2024 03:15:14 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUuu1TjrVRL/IBHFJncNUp2KWWg+XvJnkH75ech/1S/3+CSeFusJYQI2HrYM7X/GTNKY80f9CEMuPPubXHXEC0cTF4rQg== X-Google-Smtp-Source: AGHT+IEo4vPFY48Oh2ZUiq+EU6v/EnFXv9ZATaH/LMTlGXya72dXLrzV4yz0YGQepfgZYn+p9kFu X-Received: by 2002:a17:90b:889:b0:299:87ba:8a2 with SMTP id bj9-20020a17090b088900b0029987ba08a2mr1283388pjb.41.1709291714451; Fri, 01 Mar 2024 03:15:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709291714; cv=pass; d=google.com; s=arc-20160816; b=xtFRgHFfC3nXy2I1/PIok/nyc74J+0/xJfyeTE8NtieC3ipR0DYTZr1481xTGPO0L8 IOfdhUOCqDDGxILpaAyCZrlof7xz6AicCIqr9TO2KSwc82eNSi81g7dMgihJup7z3hAI z+sLrHYCaUizJ9NGnrgS5acBL7JB/lX7urWeLmBQgQFnmKBP8PkL/7HBL6fa15HTolkD TCeVRJmN6dfEzJVaj4dItqIU3eFPBU3/ldsI94vsyAxnA14xDGAdl0rFJ0yTZHEjtQh7 9Kmp7lAvhLVvweGmBV4ctgAhnuxzpd+XBJ33fKCWy8klWK/o1KNQjy980XFEVQ58etAn xrWg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=GPr5OT0hjAf7wDQpFiXt+umkADr7mP/nXjReYVXPj5M=; fh=C6KNRX8KGlM1kP/th5O1m+bTp3eGi7923Iyh9t2RYqg=; b=yT6TVBH/h1e3KiMklkcoXn2/f016AuAbIwgS9jHkFoB9VpP5Qmde/paHToM9x8Gq/l cea/BxXX6IC3jJSn5RA2sz4ahKl+dAC8W2h1c+ZXAQ6WvJZG8l+tm2ksdZkrmlfvt+5G mOgZF6QMtpzoLnYbgkQOjVd05p1JNtv3J1b2Hd/PQsxWzp1sBVTMvFI1zw/E6oU1wTD1 JSgcsDsP32Zcj2Y890aBWcjkU+IrZMGxiwTN4+lAP0hM9HrGwMXzwQBJ5h3X3QWg1IKp qQ2HHE1EX2ddoS5Jfrrxmlgrm8kotgMVtyv5wFC1WkDdAcbkBKxcy4VSGId1jw1JDzEN M1hA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=IuJ7dY3n; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-88319-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88319-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id a23-20020a17090a8c1700b002931b3873dasi5368524pjo.22.2024.03.01.03.15.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 03:15:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88319-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=IuJ7dY3n; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-88319-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88319-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 42A952849C4 for ; Fri, 1 Mar 2024 11:15:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 17EF270CA0; Fri, 1 Mar 2024 11:12:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IuJ7dY3n" Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B23D6CDC3; Fri, 1 Mar 2024 11:12:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709291565; cv=none; b=rJly8cPylIZqhlm5ZNmr7baMDfZ7ZCx7ghHhd7qwyoKiSeqipkbqqQ5NDtsMaeZ5Dbs/m6wy1juheKTV6ZQyi9KmIiQBRD+5+pNIyErbAfKx5E93NCi9N4Kxk8sYmT5L/loBqtPk3Ix5+S6sY6S8gaxHnCYr/eYGRvACHB6qw3c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709291565; c=relaxed/simple; bh=7IIXC1qsD1MFpjVOqYYi+BOf0Ko89zjnAhsRvckXXLA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JZECmuiTBEy4nqfQfDTlDKTjSBsAH8jU4hlsi9S254ADwZFqejfnpfqMGZsk75CO+RRStzCuf/qiOiv/BAoGGoUxIx2bjzUH7eq0xslxjB18wK+6VWxYsOhjGfDE7HRl/sx0kpP07j2KyoSaAb3ftzw3R72OmU39fd1qdS15BM0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=IuJ7dY3n; arc=none smtp.client-ip=209.85.218.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-a441d7c6125so253510966b.2; Fri, 01 Mar 2024 03:12:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709291562; x=1709896362; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GPr5OT0hjAf7wDQpFiXt+umkADr7mP/nXjReYVXPj5M=; b=IuJ7dY3nK6Qgu/hBg3XdZzffbClVFdoSGQfWE1vXYhRyaNB7r2TPmPXWvkmuVPg8H7 mT31J9He6NVPNV4n7gh4o19UHsg63Z9KsSYHY6cxZvWt0pUDgXwD3P7VbFYaPt4CO7Tm OrQ/EchUsm4C94HpfDOcoofs2Hmz+9qouMN7nyy2aZGwwawEWl3NCEu4j2JdPS2wsmPm OQ34JII8VAf+QqUtDjVr/pGTFcy+nehhlVUCAXbjHQMzhAw73iFbw1eXGoZuL0GJvICT wRPjsK+wxrR6biXn9BnLrtK5Nx4NIxu21296exygR5ybmW430rk6I3MIavy6ZrXyFb0x 8xBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709291562; x=1709896362; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GPr5OT0hjAf7wDQpFiXt+umkADr7mP/nXjReYVXPj5M=; b=NAiXzG/SBrwHhK7Oo0qMxQ/KCbRsURMRuJeqXpyocLF/Nx7tjxhVshlz5DeqWTy7SZ HCFQ75ESt9ZXzv7kXuBHEZtJk7wKxgziNs7dsBZ/Uzeo+9WT1YDA6jqd5yQ9gXXKDh4a 0+9kPlmMUtV8QTPBbNEtx5RcwPZchIfDf6+yN/BVHWaEjR0zYufgiYuGQeJMuJi9lFud KSLBLeTmT9y9gS5YGhs+/WrXRItceF+T5ibFYZC57En3UWo0klM1ksIatq7DymcSyYc5 /sDphp+46grZAJmhnmTDQpttEG4DcwSmaHhHGvoYqvNZRZh9yAZMc0PET0uwgLZRQpKg ZYlg== X-Forwarded-Encrypted: i=1; AJvYcCU12yxnDCai8VpuckolvX18dfkZvJc2usfCLct/o5bRE9aHBJIljMBUOYnBJhtY7XxgOG00oYlIY2yejTJvmIuGRo4LcnoV7+wHqhXKwrfUZninPmANmppEwFS7NUzdGMsTDKt2bVVFaBwyja4swWoBAHJzz3Qiigx4aXMHKRdy9X2Fgw== X-Gm-Message-State: AOJu0Yx5reZteLfSyqwZhCe+eUMSHbUo621Han5fnFJqPPUN96il3Lod 3S9iyCPKTnrXhmJYMZHczZVsGYaKibt820VNtAMefFz+6svjJG0R X-Received: by 2002:a17:906:6d4e:b0:a44:731c:bacc with SMTP id a14-20020a1709066d4e00b00a44731cbaccmr1146651ejt.10.1709291561812; Fri, 01 Mar 2024 03:12:41 -0800 (PST) Received: from debian.fritz.box ([93.184.186.109]) by smtp.gmail.com with ESMTPSA id n18-20020a170906089200b00a43a478e4f0sm1583254eje.180.2024.03.01.03.12.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 03:12:41 -0800 (PST) From: Dimitri Fedrau To: Cc: Dimitri Fedrau , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-pwm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/3] pwm: mc33xs2410: add support for direct inputs Date: Fri, 1 Mar 2024 12:11:24 +0100 Message-Id: <20240301111124.29283-4-dima.fedrau@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240301111124.29283-1-dima.fedrau@gmail.com> References: <20240301111124.29283-1-dima.fedrau@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792322268781071788 X-GMAIL-MSGID: 1792322268781071788 Add support for direct inputs, which are used to directly turn-on or turn-off the outputs. Direct inputs have the advantage over the SPI controlled outputs that they aren't limited to the frequency steps. Frequency resolution depends on the input signal, range is still from 0.5Hz to 2.048kHz. Signed-off-by: Dimitri Fedrau --- drivers/pwm/pwm-mc33xs2410.c | 116 +++++++++++++++++++++++++++++++---- 1 file changed, 105 insertions(+), 11 deletions(-) diff --git a/drivers/pwm/pwm-mc33xs2410.c b/drivers/pwm/pwm-mc33xs2410.c index 35753039da6b..828a67227185 100644 --- a/drivers/pwm/pwm-mc33xs2410.c +++ b/drivers/pwm/pwm-mc33xs2410.c @@ -18,7 +18,10 @@ #define MC33XS2410_GLB_CTRL_MODE_MASK GENMASK(7, 6) #define MC33XS2410_GLB_CTRL_NORMAL_MODE BIT(6) #define MC33XS2410_GLB_CTRL_SAFE_MODE BIT(7) +#define MC33XS2410_GLB_CTRL_CMOS_LEVEL BIT(0) #define MC33XS2410_OUT1_4_CTRL 0x02 +#define MC33XS2410_IN_CTRL1 0x03 +#define MC33XS2410_IN_CTRL1_IN_EN(x) BIT(x) #define MC33XS2410_PWM_CTRL1 0x05 #define MC33XS2410_PWM_CTRL1_POL_INV(x) BIT(x) #define MC33XS2410_PWM_CTRL3 0x07 @@ -45,6 +48,7 @@ struct mc33xs2410_pwm { struct pwm_chip chip; struct spi_device *spi; + struct pwm_device *di[4]; struct mutex lock; }; @@ -154,20 +158,15 @@ static u8 mc33xs2410_pwm_get_freq(const struct pwm_state *state) return (ret | FIELD_PREP(MC33XS2410_PWM_FREQ_STEP_MASK, step)); } -static int mc33xs2410_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, - const struct pwm_state *state) +static int mc33xs2410_pwm_apply_spi(struct pwm_chip *chip, + struct pwm_device *pwm, + const struct pwm_state *state) { struct mc33xs2410_pwm *mc33xs2410 = mc33xs2410_pwm_from_chip(chip); struct spi_device *spi = mc33xs2410->spi; u8 mask, val; int ret; - if (state->period > mc33xs2410_period[STEP_05HZ][MC33XS2410_PERIOD_MAX]) - return -EINVAL; - - if (state->period < mc33xs2410_period[STEP_32HZ][MC33XS2410_PERIOD_MIN]) - return -EINVAL; - guard(mutex)(&mc33xs2410->lock); mask = MC33XS2410_PWM_CTRL1_POL_INV(pwm->hwpwm); val = (state->polarity == PWM_POLARITY_INVERSED) ? mask : 0; @@ -190,9 +189,38 @@ static int mc33xs2410_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, return mc33xs2410_modify_reg(spi, MC33XS2410_PWM_CTRL3, mask, val); } -static int mc33xs2410_pwm_get_state(struct pwm_chip *chip, - struct pwm_device *pwm, - struct pwm_state *state) +static int mc33xs2410_pwm_apply_direct_inputs(struct pwm_chip *chip, + struct pwm_device *pwm, + const struct pwm_state *state) +{ + struct mc33xs2410_pwm *mc33xs2410 = mc33xs2410_pwm_from_chip(chip); + struct pwm_device *di = mc33xs2410->di[pwm->hwpwm]; + + guard(mutex)(&mc33xs2410->lock); + + return pwm_apply_state(di, state); +} + +static int mc33xs2410_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, + const struct pwm_state *state) +{ + struct mc33xs2410_pwm *mc33xs2410 = mc33xs2410_pwm_from_chip(chip); + + if (state->period > mc33xs2410_period[STEP_05HZ][MC33XS2410_PERIOD_MAX]) + return -EINVAL; + + if (state->period < mc33xs2410_period[STEP_32HZ][MC33XS2410_PERIOD_MIN]) + return -EINVAL; + + if (mc33xs2410->di[pwm->hwpwm]) + return mc33xs2410_pwm_apply_direct_inputs(chip, pwm, state); + else + return mc33xs2410_pwm_apply_spi(chip, pwm, state); +} + +static int mc33xs2410_pwm_get_state_spi(struct pwm_chip *chip, + struct pwm_device *pwm, + struct pwm_state *state) { struct mc33xs2410_pwm *mc33xs2410 = mc33xs2410_pwm_from_chip(chip); struct spi_device *spi = mc33xs2410->spi; @@ -236,6 +264,28 @@ static int mc33xs2410_pwm_get_state(struct pwm_chip *chip, return 0; } +static int mc33xs2410_pwm_get_state_direct_inputs(struct pwm_chip *chip, + struct pwm_device *pwm, + struct pwm_state *state) +{ + struct mc33xs2410_pwm *mc33xs2410 = mc33xs2410_pwm_from_chip(chip); + + pwm_get_state(mc33xs2410->di[pwm->hwpwm], state); + return 0; +} + +static int mc33xs2410_pwm_get_state(struct pwm_chip *chip, + struct pwm_device *pwm, + struct pwm_state *state) +{ + struct mc33xs2410_pwm *mc33xs2410 = mc33xs2410_pwm_from_chip(chip); + + if (mc33xs2410->di[pwm->hwpwm]) + return mc33xs2410_pwm_get_state_direct_inputs(chip, pwm, state); + else + return mc33xs2410_pwm_get_state_spi(chip, pwm, state); +} + static const struct pwm_ops mc33xs2410_pwm_ops = { .apply = mc33xs2410_pwm_apply, .get_state = mc33xs2410_pwm_get_state, @@ -257,6 +307,45 @@ static int mc33xs2410_reset(struct device *dev) return 0; } +static int mc33xs2410_direct_inputs_probe(struct mc33xs2410_pwm *mc33xs2410) +{ + struct device *dev = &mc33xs2410->spi->dev; + u16 di_en = 0; + char buf[4]; + int ret, ch; + + for (ch = 0; ch < 4; ch++) { + sprintf(buf, "di%d", ch); + mc33xs2410->di[ch] = devm_pwm_get(dev, buf); + ret = PTR_ERR_OR_ZERO(mc33xs2410->di[ch]); + switch (ret) { + case 0: + di_en |= MC33XS2410_IN_CTRL1_IN_EN(ch); + break; + case -ENODATA: + mc33xs2410->di[ch] = NULL; + break; + case -EPROBE_DEFER: + return ret; + default: + dev_err(dev, "Failed to request %s: %d\n", buf, ret); + return ret; + } + } + + if (!di_en) + return 0; + + /* CMOS input logic level */ + ret = mc33xs2410_modify_reg(mc33xs2410->spi, MC33XS2410_GLB_CTRL, + MC33XS2410_GLB_CTRL_CMOS_LEVEL, + MC33XS2410_GLB_CTRL_CMOS_LEVEL); + if (ret < 0) + return ret; + + return mc33xs2410_write_reg(mc33xs2410->spi, MC33XS2410_IN_CTRL1, di_en); +} + static int mc33xs2410_probe(struct spi_device *spi) { struct mc33xs2410_pwm *mc33xs2410; @@ -290,6 +379,11 @@ static int mc33xs2410_probe(struct spi_device *spi) return dev_err_probe(dev, ret, "Failed to transition to normal mode\n"); + /* Enable direct inputs */ + ret = mc33xs2410_direct_inputs_probe(mc33xs2410); + if (ret) + return ret; + ret = devm_pwmchip_add(dev, &mc33xs2410->chip); if (ret < 0) return dev_err_probe(dev, ret, "Failed to add pwm chip\n");