From patchwork Thu Oct 5 16:05:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Devi Priya X-Patchwork-Id: 148894 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2016:b0:403:3b70:6f57 with SMTP id fe22csp414563vqb; Thu, 5 Oct 2023 09:23:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFb5R2qlrQh0pi+psHeJTiplOEUTFEh3Ryt3IDj9VaWOrQ6B2AAk3FvS70bMtJ+7Dg0DfRq X-Received: by 2002:a17:902:bf49:b0:1c6:112f:5d02 with SMTP id u9-20020a170902bf4900b001c6112f5d02mr5248154pls.55.1696522994913; Thu, 05 Oct 2023 09:23:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696522994; cv=none; d=google.com; s=arc-20160816; b=BamcMBaqr4/Jx3ii9lbnHdeuf4e12FcR+aXOmJ6nYPaxLgugQOtRJ/ZVFX6Y/IWEyS sFiuOxYnfgDr6Jwj2YpSyIo6lkiKuIRje+hWlDBzEnqv2Gq5IVKxEqYeNh7xYeyu/q3o sxgiEIFl34RqBhvbYdyFBfgs5JcJnjkn0MD70Fo8DFUet6MnCm85I1bQ49KtMC4qIoCZ icPKZwgCVPfblY4F1IXI5gC4+OE6uNlN2rGyEuOSIoCXS4N2SHNWsjeWiH5SViK4m94q FWQs/PNQ2oizeKDrXSWbVCsy+Tm+J7lgFdz49cQ4TqVW9ImVvUv4nmJ8/7Q2wh2OAAjL jf4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pL305QZpgz9DE4v+JRgsjWEqf1lM32BSKRkIofAZtYI=; fh=6AwcISBGklEC0U2b8ZFmhdtzZmcvKnccaXqP9iERvtc=; b=AQ0/h0BQA2SyfXxcOZKpdmz7k3As1ao1194Kln3p/GnBQNOLUpBkNQF/aias2Sr952 rUIKHvc75Sz6Q4q8i6ha1nn4cVh38Ab6phySmjdPhyFQnJGr/fVgZYYlPK8EWPwXWick yUiLsBRf4q2UBhdlKnCjGFCvJ1UYHUa/w75f3Kp6+4xure+mtMyJB1UjxQ+nKXBUzBSZ EXwzd/ZRtzNk1ZOLQ1ZiFXLw26dfF9abIvtpMEaFoioQ0abKR1oLLY09bIT+pbi/7z4J XqwJvA4KnGjaW3vfnyyVas8dvD+/85IRM6PBuji1vtXk5d48Wu7PzL4nmnn/Y9GlB16x RUMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="N/VkHpLP"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id kp15-20020a170903280f00b001c446f12975si1618727plb.447.2023.10.05.09.23.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 09:23:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="N/VkHpLP"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 2B83D831DBCD; Thu, 5 Oct 2023 09:23:14 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243434AbjJEQWr (ORCPT + 19 others); Thu, 5 Oct 2023 12:22:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242441AbjJEQR7 (ORCPT ); Thu, 5 Oct 2023 12:17:59 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 654563F020; Thu, 5 Oct 2023 09:06:56 -0700 (PDT) Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 395Aarqd017488; Thu, 5 Oct 2023 16:06:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=qcppdkim1; bh=pL305QZpgz9DE4v+JRgsjWEqf1lM32BSKRkIofAZtYI=; b=N/VkHpLPyHQX0FtgqwJTY18MM5NIRAxm/+ejcJgF+GzogJXQJVrX/JAaY+GrGMI/jBWB fXAGI3rifkl9eKUkW2WiW2CM3NLpeKa1XcRfGYC3FvWNeVEKpAdNUnneWq5jII/7rjwr LOEF9iGjSkqgE38uQGz0bcm+TCePCLBym1xS29C8u1B7Xx0M74w+Du98muz8yAqjQbLM xbUkhQ5rGl34cLkYMUaT8Zuu4Je14xfsUL+dVCk2/TppUvaqZz3mzOdGiwKGz9AWdnJ2 1+/sxswdw/5WhuALaDoCncbTHD0BtxYj3SYmNtE0+NHQ4IJ6rpa04qfytuU3+2V8h0xw FQ== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3th8e1u8ty-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 05 Oct 2023 16:06:22 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 395G6Lmf025392 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 5 Oct 2023 16:06:21 GMT Received: from hu-devipriy-blr.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.36; Thu, 5 Oct 2023 09:06:16 -0700 From: Devi Priya To: , , , , , , , , , , , , , , CC: , , Subject: [PATCH V15 1/4] pwm: driver for qualcomm ipq6018 pwm block Date: Thu, 5 Oct 2023 21:35:47 +0530 Message-ID: <20231005160550.2423075-2-quic_devipriy@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231005160550.2423075-1-quic_devipriy@quicinc.com> References: <20231005160550.2423075-1-quic_devipriy@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: dUK910BXNf0cPwSxJTAoChM7COrWyzeE X-Proofpoint-ORIG-GUID: dUK910BXNf0cPwSxJTAoChM7COrWyzeE X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-05_11,2023-10-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 suspectscore=0 adultscore=0 priorityscore=1501 mlxscore=0 lowpriorityscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310050126 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 05 Oct 2023 09:23:14 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778933295919005700 X-GMAIL-MSGID: 1778933295919005700 Driver for the PWM block in Qualcomm IPQ6018 line of SoCs. Based on driver from downstream Codeaurora kernel tree. Removed support for older (V1) variants because I have no access to that hardware. Tested on IPQ6010 based hardware. Co-developed-by: Baruch Siach Signed-off-by: Baruch Siach Signed-off-by: Devi Priya --- V15: No change V14: No change V13: No change V12: Fix the below clang warning for overflow check reported by kernel test robot drivers/pwm/pwm-ipq.c:122:11: warning: result of comparison of constant 16000000000 with expression of type 'unsigned long' is always false [-Wtautological-constant-out-of-range-compare] >> if (rate > 16ULL * GIGA) v11: Address comment from Uwe Kleine-König: Drop redundant registers field comments Fix period limit check in .apply Clarify the comment explaining skip of pre_div > pwm_div values Add explicit check for clock rate within limit Add comment explaining the selection of initial pre_div Use pwm_div division with remainder instead of separate diff calculation Round up duty_cycle calculation in .get_state v10: Restore round up in pwm_div calculation; otherwise diff is always <= 0, so only bingo match works Don't overwrite min_diff on every loop iteration v9: Address comment from Uwe Kleine-König: Use period_ns*rate in dividers calculation for better accuracy Round down pre_div and pwm_div Add a comment explaining why pwm_div can't underflow Add a comment explaining why pre_div > pwm_div end the search loop Drop 'CFG_' from register macros Rename to_ipq_pwm_chip() to ipq_pwm_from_chip() Change bare 'unsigned' to 'unsigned int' Clarify the comment on separate REG1 write for enable/disable Round up the period value in .get_state Use direct readl/writel so no need to check for regmap errors v7: Change 'offset' to 'reg' for the tcsr offset (Rob) Drop clock name; there is only one clock (Bjorn) Simplify probe failure code path (Bjorn) v6: Address Uwe Kleine-König review comments: Drop IPQ_PWM_MAX_DEVICES Rely on assigned-clock-rates; drop IPQ_PWM_CLK_SRC_FREQ Simplify register offset calculation Calculate duty cycle more precisely Refuse to set inverted polarity Drop redundant IPQ_PWM_REG1_ENABLE bit clear Remove x1000 factor in pwm_div calculation, use rate directly, and round up Choose initial pre_div such that pwm_div < IPQ_PWM_MAX_DIV Ensure pre_div <= pwm_div Rename close_ to best_ Explain in comment why effective_div doesn't overflow Limit pwm_div to IPQ_PWM_MAX_DIV - 1 to allow 100% duty cycle Disable clock only after pwmchip_remove() const pwm_ops Other changes: Add missing linux/bitfield.h header include (kernel test robot) Adjust code for PWM device node under TCSR (Rob Herring) v5: Use &tcsr_q6 syscon to access registers (Bjorn Andersson) Address Uwe Kleine-König review comments: Implement .get_state() Add IPQ_PWM_ prefix to local macros Use GENMASK/BIT/FIELD_PREP for register fields access Make type of config_div_and_duty() parameters consistent Derive IPQ_PWM_MIN_PERIOD_NS from IPQ_PWM_CLK_SRC_FREQ Integrate enable/disable into config_div_and_duty() to save register read, and reduce frequency glitch on update Use min() instead of min_t() Fix comment format Use dev_err_probe() to indicate probe step failure Add missing clk_disable_unprepare() in .remove Don't set .owner v4: Use div64_u64() to fix link for 32-bit targets ((kernel test robot , Uwe Kleine-König) v3: s/qcom,pwm-ipq6018/qcom,ipq6018-pwm/ (Rob Herring) Fix integer overflow on 32-bit targets (kernel test robot ) v2: Address Uwe Kleine-König review comments: Fix period calculation when out of range Don't set period larger than requested Remove PWM disable on configuration change Implement .apply instead of non-atomic .config/.enable/.disable Don't modify PWM on .request/.free Check pwm_div underflow Fix various code and comment formatting issues Other changes: Use u64 divisor safe division Remove now empty .request/.free drivers/pwm/Kconfig | 12 ++ drivers/pwm/Makefile | 1 + drivers/pwm/pwm-ipq.c | 282 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 295 insertions(+) create mode 100644 drivers/pwm/pwm-ipq.c diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index 8ebcddf91f7b..c2d51680823a 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig @@ -282,6 +282,18 @@ config PWM_INTEL_LGM To compile this driver as a module, choose M here: the module will be called pwm-intel-lgm. +config PWM_IPQ + tristate "IPQ PWM support" + depends on ARCH_QCOM || COMPILE_TEST + depends on HAVE_CLK && HAS_IOMEM + help + Generic PWM framework driver for IPQ PWM block which supports + 4 pwm channels. Each of the these channels can be configured + independent of each other. + + To compile this driver as a module, choose M here: the module + will be called pwm-ipq. + config PWM_IQS620A tristate "Azoteq IQS620A PWM support" depends on MFD_IQS62X || COMPILE_TEST diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile index c822389c2a24..1b69e8cb2b91 100644 --- a/drivers/pwm/Makefile +++ b/drivers/pwm/Makefile @@ -24,6 +24,7 @@ obj-$(CONFIG_PWM_IMX1) += pwm-imx1.o obj-$(CONFIG_PWM_IMX27) += pwm-imx27.o obj-$(CONFIG_PWM_IMX_TPM) += pwm-imx-tpm.o obj-$(CONFIG_PWM_INTEL_LGM) += pwm-intel-lgm.o +obj-$(CONFIG_PWM_IPQ) += pwm-ipq.o obj-$(CONFIG_PWM_IQS620A) += pwm-iqs620a.o obj-$(CONFIG_PWM_JZ4740) += pwm-jz4740.o obj-$(CONFIG_PWM_KEEMBAY) += pwm-keembay.o diff --git a/drivers/pwm/pwm-ipq.c b/drivers/pwm/pwm-ipq.c new file mode 100644 index 000000000000..5dbe46bb56d6 --- /dev/null +++ b/drivers/pwm/pwm-ipq.c @@ -0,0 +1,282 @@ +// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 +/* + * Copyright (c) 2016-2017, 2020 The Linux Foundation. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* The frequency range supported is 1 Hz to clock rate */ +#define IPQ_PWM_MAX_PERIOD_NS ((u64)NSEC_PER_SEC) + +/* + * The max value specified for each field is based on the number of bits + * in the pwm control register for that field + */ +#define IPQ_PWM_MAX_DIV 0xFFFF + +/* + * Two 32-bit registers for each PWM: REG0, and REG1. + * Base offset for PWM #i is at 8 * #i. + */ +#define IPQ_PWM_REG0 0 +#define IPQ_PWM_REG0_PWM_DIV GENMASK(15, 0) +#define IPQ_PWM_REG0_HI_DURATION GENMASK(31, 16) + +#define IPQ_PWM_REG1 4 +#define IPQ_PWM_REG1_PRE_DIV GENMASK(15, 0) +/* + * Enable bit is set to enable output toggling in pwm device. + * Update bit is set to reflect the changed divider and high duration + * values in register. + */ +#define IPQ_PWM_REG1_UPDATE BIT(30) +#define IPQ_PWM_REG1_ENABLE BIT(31) + +struct ipq_pwm_chip { + struct pwm_chip chip; + struct clk *clk; + void __iomem *mem; +}; + +static struct ipq_pwm_chip *ipq_pwm_from_chip(struct pwm_chip *chip) +{ + return container_of(chip, struct ipq_pwm_chip, chip); +} + +static unsigned int ipq_pwm_reg_read(struct pwm_device *pwm, unsigned int reg) +{ + struct ipq_pwm_chip *ipq_chip = ipq_pwm_from_chip(pwm->chip); + unsigned int off = 8 * pwm->hwpwm + reg; + + return readl(ipq_chip->mem + off); +} + +static void ipq_pwm_reg_write(struct pwm_device *pwm, unsigned int reg, + unsigned int val) +{ + struct ipq_pwm_chip *ipq_chip = ipq_pwm_from_chip(pwm->chip); + unsigned int off = 8 * pwm->hwpwm + reg; + + writel(val, ipq_chip->mem + off); +} + +static void config_div_and_duty(struct pwm_device *pwm, unsigned int pre_div, + unsigned int pwm_div, unsigned long rate, u64 duty_ns, + bool enable) +{ + unsigned long hi_dur; + unsigned long val = 0; + + /* + * high duration = pwm duty * (pwm div + 1) + * pwm duty = duty_ns / period_ns + */ + hi_dur = div64_u64(duty_ns * rate, (pre_div + 1) * NSEC_PER_SEC); + + val = FIELD_PREP(IPQ_PWM_REG0_HI_DURATION, hi_dur) | + FIELD_PREP(IPQ_PWM_REG0_PWM_DIV, pwm_div); + ipq_pwm_reg_write(pwm, IPQ_PWM_REG0, val); + + val = FIELD_PREP(IPQ_PWM_REG1_PRE_DIV, pre_div); + ipq_pwm_reg_write(pwm, IPQ_PWM_REG1, val); + + /* PWM enable toggle needs a separate write to REG1 */ + val |= IPQ_PWM_REG1_UPDATE; + if (enable) + val |= IPQ_PWM_REG1_ENABLE; + ipq_pwm_reg_write(pwm, IPQ_PWM_REG1, val); +} + +static int ipq_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, + const struct pwm_state *state) +{ + struct ipq_pwm_chip *ipq_chip = ipq_pwm_from_chip(chip); + unsigned int pre_div, pwm_div, best_pre_div, best_pwm_div; + unsigned long rate = clk_get_rate(ipq_chip->clk); + u64 period_ns, duty_ns, period_rate; + u64 min_diff; + + if (state->polarity != PWM_POLARITY_NORMAL) + return -EINVAL; + + if (state->period < DIV64_U64_ROUND_UP(NSEC_PER_SEC, rate)) + return -ERANGE; + + period_ns = min(state->period, IPQ_PWM_MAX_PERIOD_NS); + duty_ns = min(state->duty_cycle, period_ns); + + /* + * period_ns is 1G or less. As long as rate is less than 16 GHz, + * period_rate does not overflow. Make that explicit. + */ + if ((unsigned long long)rate > 16ULL * GIGA) + return -EINVAL; + period_rate = period_ns * rate; + best_pre_div = IPQ_PWM_MAX_DIV; + best_pwm_div = IPQ_PWM_MAX_DIV; + /* + * We don't need to consider pre_div values smaller than + * + * period_rate + * pre_div_min := ------------------------------------ + * NSEC_PER_SEC * (IPQ_PWM_MAX_DIV + 1) + * + * because pre_div = pre_div_min results in a better + * approximation. + */ + pre_div = div64_u64(period_rate, + (u64)NSEC_PER_SEC * (IPQ_PWM_MAX_DIV + 1)); + min_diff = period_rate; + + for (; pre_div <= IPQ_PWM_MAX_DIV; pre_div++) { + u64 remainder; + + pwm_div = div64_u64_rem(period_rate, + (u64)NSEC_PER_SEC * (pre_div + 1), &remainder); + /* pwm_div is unsigned; the check below catches underflow */ + pwm_div--; + + /* + * Swapping values for pre_div and pwm_div produces the same + * period length. So we can skip all settings with pre_div > + * pwm_div which results in bigger constraints for selecting + * the duty_cycle than with the two values swapped. + */ + if (pre_div > pwm_div) + break; + + /* + * Make sure we can do 100% duty cycle where + * hi_dur == pwm_div + 1 + */ + if (pwm_div > IPQ_PWM_MAX_DIV - 1) + continue; + + if (remainder < min_diff) { + best_pre_div = pre_div; + best_pwm_div = pwm_div; + min_diff = remainder; + + if (min_diff == 0) /* bingo */ + break; + } + } + + /* config divider values for the closest possible frequency */ + config_div_and_duty(pwm, best_pre_div, best_pwm_div, + rate, duty_ns, state->enabled); + + return 0; +} + +static int ipq_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, + struct pwm_state *state) +{ + struct ipq_pwm_chip *ipq_chip = ipq_pwm_from_chip(chip); + unsigned long rate = clk_get_rate(ipq_chip->clk); + unsigned int pre_div, pwm_div, hi_dur; + u64 effective_div, hi_div; + u32 reg0, reg1; + + reg0 = ipq_pwm_reg_read(pwm, IPQ_PWM_REG0); + reg1 = ipq_pwm_reg_read(pwm, IPQ_PWM_REG1); + + state->polarity = PWM_POLARITY_NORMAL; + state->enabled = reg1 & IPQ_PWM_REG1_ENABLE; + + pwm_div = FIELD_GET(IPQ_PWM_REG0_PWM_DIV, reg0); + hi_dur = FIELD_GET(IPQ_PWM_REG0_HI_DURATION, reg0); + pre_div = FIELD_GET(IPQ_PWM_REG1_PRE_DIV, reg1); + + /* No overflow here, both pre_div and pwm_div <= 0xffff */ + effective_div = (u64)(pre_div + 1) * (pwm_div + 1); + state->period = DIV64_U64_ROUND_UP(effective_div * NSEC_PER_SEC, rate); + + hi_div = hi_dur * (pre_div + 1); + state->duty_cycle = DIV64_U64_ROUND_UP(hi_div * NSEC_PER_SEC, rate); + + return 0; +} + +static const struct pwm_ops ipq_pwm_ops = { + .apply = ipq_pwm_apply, + .get_state = ipq_pwm_get_state, + .owner = THIS_MODULE, +}; + +static int ipq_pwm_probe(struct platform_device *pdev) +{ + struct ipq_pwm_chip *pwm; + struct device *dev = &pdev->dev; + int ret; + + pwm = devm_kzalloc(dev, sizeof(*pwm), GFP_KERNEL); + if (!pwm) + return -ENOMEM; + + platform_set_drvdata(pdev, pwm); + + pwm->mem = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(pwm->mem)) + return dev_err_probe(dev, PTR_ERR(pwm->mem), + "regs map failed"); + + pwm->clk = devm_clk_get(dev, NULL); + if (IS_ERR(pwm->clk)) + return dev_err_probe(dev, PTR_ERR(pwm->clk), + "failed to get clock"); + + ret = clk_prepare_enable(pwm->clk); + if (ret) + return dev_err_probe(dev, ret, "clock enable failed"); + + pwm->chip.dev = dev; + pwm->chip.ops = &ipq_pwm_ops; + pwm->chip.npwm = 4; + + ret = pwmchip_add(&pwm->chip); + if (ret < 0) { + dev_err_probe(dev, ret, "pwmchip_add() failed\n"); + clk_disable_unprepare(pwm->clk); + } + + return ret; +} + +static int ipq_pwm_remove(struct platform_device *pdev) +{ + struct ipq_pwm_chip *pwm = platform_get_drvdata(pdev); + + pwmchip_remove(&pwm->chip); + clk_disable_unprepare(pwm->clk); + + return 0; +} + +static const struct of_device_id pwm_ipq_dt_match[] = { + { .compatible = "qcom,ipq6018-pwm", }, + {} +}; +MODULE_DEVICE_TABLE(of, pwm_ipq_dt_match); + +static struct platform_driver ipq_pwm_driver = { + .driver = { + .name = "ipq-pwm", + .of_match_table = pwm_ipq_dt_match, + }, + .probe = ipq_pwm_probe, + .remove = ipq_pwm_remove, +}; + +module_platform_driver(ipq_pwm_driver); + +MODULE_LICENSE("Dual BSD/GPL"); From patchwork Thu Oct 5 16:05:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Devi Priya X-Patchwork-Id: 148923 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2016:b0:403:3b70:6f57 with SMTP id fe22csp433935vqb; Thu, 5 Oct 2023 09:57:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH1H2wNqz/2o5/MuNMfXw9RT0PjZsQX2sNFYkSAjlXrNGd4TH0QyyHjNWzHUwVYeFSDJZpy X-Received: by 2002:a17:902:a504:b0:1c3:308b:ecb9 with SMTP id s4-20020a170902a50400b001c3308becb9mr5300953plq.11.1696525050098; Thu, 05 Oct 2023 09:57:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696525050; cv=none; d=google.com; s=arc-20160816; b=gU2aeTRvKRmBZ9I7o5DD8QB6hVPvlwesEOCM6XZ49zPmKDP8MWlEC0ySwyqQqrjBJ9 OqB7/h+8/sWYtqYDrAYW83MFnh1Dt1F7H0oy9WRFZnuFLtEyR93sxLbuA0ZJSPmcx6Wy wlMkbiU4WjLbqJykub/rTjg1glCSpmCYiwTpwi9zfNoVOAyu7IfNoNfvO2taiF2LIyr8 cAKaaL4kbQ2ODmvOTDq90SfmHtmqe0INvz7m4fjzr+ORr9gydpYXzzyHJy8+2Ts31uHq dw7sI0+zIYFnzHO2Hq5dcrRojrLu3T2iV+Vowfr4I1eY21Imm5Ngsx6cFAVIYTtdLWF6 Hxpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vR2FSBSTd8HPJ7sNxrVy7SiMCwoEMH2Vx+lLqcKHOV0=; fh=6AwcISBGklEC0U2b8ZFmhdtzZmcvKnccaXqP9iERvtc=; b=c093HFiHcFvhza9HukGYs9z5pduoOKlBTuh/G1qj92156A9G8LQeAnUUpSTw/SKp7u Sy8PQ+1VTfYXo5zihdJNirOX8o2e8q/5TBPBX3Z/SA+3sEfchn6HLW/dZCx7O/AntXWC RsmnzeRfaZj9P1BLWBuSluY8MHHnJ9pjCqEQElG3GX0/+NdICFo/Oj03kHBVd4kcMd08 d614afIzZxZlbA19qUgvnsN4sHQKObr7ftiE6NO+mghRlEDctHPbQYCNBNU0jf3UA1+l uR2plqQPFHroiIqDni+HaDB+2Zlc279+tOzmWWdjctsbJKrVE6Ubd1yY3IATODyrbEQF edtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=lz3gPwTs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id h9-20020a170902f54900b001c3ffc982cfsi1934785plf.142.2023.10.05.09.57.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 09:57:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=lz3gPwTs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 056C98073DEC; Thu, 5 Oct 2023 09:57:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243519AbjJEQXG (ORCPT + 18 others); Thu, 5 Oct 2023 12:23:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242473AbjJEQSF (ORCPT ); Thu, 5 Oct 2023 12:18:05 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 172E13F026; Thu, 5 Oct 2023 09:06:57 -0700 (PDT) Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 395FkVwW026073; Thu, 5 Oct 2023 16:06:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=qcppdkim1; bh=vR2FSBSTd8HPJ7sNxrVy7SiMCwoEMH2Vx+lLqcKHOV0=; b=lz3gPwTs1haTlg7NkKIOMZflT7gYi8N6AtiOg6eF/LQGFOc0UdPokp5EPpp++hvU1IuY KbF19chQxl4pzAVQD+T42ubSVUX8Gabz6DTD5Qhk11Ug5/Aw/8crdJH152QQ4ext6lgV nsFEQSFesr32DuDxkhHgxXI6GdYc4AZuxfOYRXXqy66o2YgeXjrpQNBV8TaFIT3J+j9T BcnBBUfQ2tCKacCWoZOKAlWYBw4/PFiYPcTFfDMEdgeB44KirvS1V6ITCFW/GL8OYOXD 7k3TYnC0wGYKIxRhtRdm9zf2xFQsem1kVSRRd5wv5IgG/zLxGAKezmxjU5rYOBbZ/xdC gQ== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3thrk391k7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 05 Oct 2023 16:06:29 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 395G6RHg002202 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 5 Oct 2023 16:06:27 GMT Received: from hu-devipriy-blr.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.36; Thu, 5 Oct 2023 09:06:22 -0700 From: Devi Priya To: , , , , , , , , , , , , , , CC: , , Subject: [PATCH V15 2/4] dt-bindings: pwm: add IPQ6018 binding Date: Thu, 5 Oct 2023 21:35:48 +0530 Message-ID: <20231005160550.2423075-3-quic_devipriy@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231005160550.2423075-1-quic_devipriy@quicinc.com> References: <20231005160550.2423075-1-quic_devipriy@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: _R7pG3AXmqQpzaX0InNXJTjWeicMxkVy X-Proofpoint-GUID: _R7pG3AXmqQpzaX0InNXJTjWeicMxkVy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-05_11,2023-10-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 impostorscore=0 spamscore=0 priorityscore=1501 malwarescore=0 clxscore=1015 lowpriorityscore=0 suspectscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310050125 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 05 Oct 2023 09:57:19 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778935450983064235 X-GMAIL-MSGID: 1778935450983064235 DT binding for the PWM block in Qualcomm IPQ6018 SoC. Reviewed-by: Bjorn Andersson Reviewed-by: Krzysztof Kozlowski Co-developed-by: Baruch Siach Signed-off-by: Baruch Siach Signed-off-by: Devi Priya --- v15: No change v14: Picked up the R-b tag v13: Updated the file name to match the compatible Sorted the properties and updated the order in the required field Dropped the syscon node from examples v12: Picked up the R-b tag v11: No change v10: No change v9: Add 'ranges' property to example (Rob) Drop label in example (Rob) v8: Add size cell to 'reg' (Rob) v7: Use 'reg' instead of 'offset' (Rob) Drop 'clock-names' and 'assigned-clock*' (Bjorn) Use single cell address/size in example node (Bjorn) Move '#pwm-cells' lower in example node (Bjorn) List 'reg' as required v6: Device node is child of TCSR; remove phandle (Rob Herring) Add assigned-clocks/assigned-clock-rates (Uwe Kleine-König) v5: Use qcom,pwm-regs for phandle instead of direct regs (Bjorn Andersson, Kathiravan T) v4: Update the binding example node as well (Rob Herring's bot) v3: s/qcom,pwm-ipq6018/qcom,ipq6018-pwm/ (Rob Herring) v2: Make #pwm-cells const (Rob Herring) .../bindings/pwm/qcom,ipq6018-pwm.yaml | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Documentation/devicetree/bindings/pwm/qcom,ipq6018-pwm.yaml diff --git a/Documentation/devicetree/bindings/pwm/qcom,ipq6018-pwm.yaml b/Documentation/devicetree/bindings/pwm/qcom,ipq6018-pwm.yaml new file mode 100644 index 000000000000..6d0d7ed271f7 --- /dev/null +++ b/Documentation/devicetree/bindings/pwm/qcom,ipq6018-pwm.yaml @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pwm/qcom,ipq6018-pwm.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Qualcomm IPQ6018 PWM controller + +maintainers: + - Baruch Siach + +properties: + compatible: + const: qcom,ipq6018-pwm + + reg: + description: Offset of PWM register in the TCSR block. + maxItems: 1 + + clocks: + maxItems: 1 + + "#pwm-cells": + const: 2 + +required: + - compatible + - reg + - clocks + - "#pwm-cells" + +additionalProperties: false + +examples: + - | + #include + + pwm: pwm@a010 { + compatible = "qcom,ipq6018-pwm"; + reg = <0xa010 0x20>; + clocks = <&gcc GCC_ADSS_PWM_CLK>; + assigned-clocks = <&gcc GCC_ADSS_PWM_CLK>; + assigned-clock-rates = <100000000>; + #pwm-cells = <2>; + }; From patchwork Thu Oct 5 16:05:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Devi Priya X-Patchwork-Id: 148895 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2016:b0:403:3b70:6f57 with SMTP id fe22csp414672vqb; Thu, 5 Oct 2023 09:23:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFjXFPc6XmSaLJP2hfurjE3l4VXJpT62Vb1u8YtUx+5iI0JUnFFo2kZLTj7OwoIRH5uydqQ X-Received: by 2002:a05:6a00:1302:b0:692:b8b9:f728 with SMTP id j2-20020a056a00130200b00692b8b9f728mr5924222pfu.30.1696523005787; Thu, 05 Oct 2023 09:23:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696523005; cv=none; d=google.com; s=arc-20160816; b=u4o2gH4lzKNh7clxQWyhjMnTzLxvPGV3fDowHmUvEmLMnpQXYm2GLOe+cHuibl0dDU 1zNqF6hBD2mpr6fpzzLTFQxNX9Gpm3i0P10dPhLhGFzIQga9nc7+FIpigvONEgW7n7Al pcS9ysyIEPJDUMldhdaIIFjosiAK48bFM1tYdXRhvQdJ9u9ChSptYCeSrP7uvdkq0Ecp gQdChT+e3tXjm5kTS3PjjUtxRnOPibtHNrsszrmmgmS4LAWrt/pgvPlXZPZcZEvaBK37 UCdYRALTvjmv+KxodAJQL4YEO7FsyE5CoJ99vgI8eypg3yHpxWQ53zuHewFPFOD38trW Kadw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zpPueMzy8NacgapM4hPPe1DYhp5ru0FS8kAbfBI2rSE=; fh=6AwcISBGklEC0U2b8ZFmhdtzZmcvKnccaXqP9iERvtc=; b=X/d1DamIvYuCftZNVz+8u6kkrwm/tcDZGbAkMFIJuPp1jhKDYcyuId3N5DpIqkjrOr lw66NDlmVmV10xAC4Xr1JR7f+hgDz9Uu3yGrC1DadSVZAx6mG9bYKeqW/nr2knxsKFLt XqYzcPThm9CJQvqXLlG30an26a954qx4oYHwoKsmmzrX6y6k+vWr8lIv0Q3/OaGZ1T/R PHOP5ktg5NXZBg+zYeEPnr/oQQ9QdfxF9RiCDNK7eMmQWAi2n9JZBW51MWaibgJVuoNE hqFY7M8U4HkqpHFsB7cJWYXFv/XabgTD86DalU9rsOhyGaR37HLbnL7tzL5ZhipvHx/2 LH2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=p1OPRm2U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id bd40-20020a056a0027a800b0068fbac77dd0si1644543pfb.226.2023.10.05.09.23.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 09:23:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=p1OPRm2U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id A3135831DBE7; Thu, 5 Oct 2023 09:23:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243454AbjJEQWw (ORCPT + 19 others); Thu, 5 Oct 2023 12:22:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242461AbjJEQSE (ORCPT ); Thu, 5 Oct 2023 12:18:04 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C61A53F023; Thu, 5 Oct 2023 09:06:56 -0700 (PDT) Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 395DiBDh026642; Thu, 5 Oct 2023 16:06:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=zpPueMzy8NacgapM4hPPe1DYhp5ru0FS8kAbfBI2rSE=; b=p1OPRm2U++3oj0FDPkmqzzlevDAXENAmBLfKFwiG2galGYzuRt3SF9RA5Hx0+mALNKlS FFNacDyyvy21BT1chOjdftdM+OyivPcCmUvsgqBlivO81TNRV+qVmw4VLsVcbl7VymYU kwAucFqfEiK3eUofRe6ObWu/mUvcW2wpCvfKM1x5R9R8SeAxOsDvAJq7XT/jZtIG/csx Il+e5UtTzRtNCitpgpB9Vepujb4r4JntwXiOGXCZOzZYKwh8At0zqz+Q7MiYRjw9BGbM PpnqnaDJ6A3EUQF+FtjybG457/JEPm5M5H7soiSbiHXzHBwtRgvWumjai7xbDadB5ma5 Uw== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3thnfa9bak-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 05 Oct 2023 16:06:40 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 395G6XSJ027626 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 5 Oct 2023 16:06:34 GMT Received: from hu-devipriy-blr.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.36; Thu, 5 Oct 2023 09:06:28 -0700 From: Devi Priya To: , , , , , , , , , , , , , , CC: , , Subject: [PATCH V15 3/4] dt-bindings: mfd: qcom,tcsr: Add simple-mfd support for IPQ6018 Date: Thu, 5 Oct 2023 21:35:49 +0530 Message-ID: <20231005160550.2423075-4-quic_devipriy@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231005160550.2423075-1-quic_devipriy@quicinc.com> References: <20231005160550.2423075-1-quic_devipriy@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: 12pXrpyw4m_B8_1g7uyH7Pg47S1eo8qT X-Proofpoint-ORIG-GUID: 12pXrpyw4m_B8_1g7uyH7Pg47S1eo8qT X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-05_11,2023-10-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 mlxlogscore=999 malwarescore=0 bulkscore=0 spamscore=0 impostorscore=0 clxscore=1015 adultscore=0 phishscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310050126 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 05 Oct 2023 09:23:24 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778933307394409090 X-GMAIL-MSGID: 1778933307394409090 Update the binding to include pwm as the child node to TCSR block and add simple-mfd support for IPQ6018. Reviewed-by: Krzysztof Kozlowski Signed-off-by: Devi Priya --- v15: Picked up the R-b tag v14: Addressed comments suggested by krzysztof Added type: object to patternProperties and added the complete path to pwm.yaml in the reference Disallow pwm for targets other than ipq6018 Moved ranges property just after reg in the examples v13: Added simple-mfd support for IPQ6018 based devices Added support to include pwm as the child node to TCSR Included syscon node found on IPQ6018 to the examples .../devicetree/bindings/mfd/qcom,tcsr.yaml | 112 +++++++++++++----- 1 file changed, 81 insertions(+), 31 deletions(-) diff --git a/Documentation/devicetree/bindings/mfd/qcom,tcsr.yaml b/Documentation/devicetree/bindings/mfd/qcom,tcsr.yaml index 33c3d023a106..f836b973e382 100644 --- a/Documentation/devicetree/bindings/mfd/qcom,tcsr.yaml +++ b/Documentation/devicetree/bindings/mfd/qcom,tcsr.yaml @@ -15,50 +15,100 @@ description: properties: compatible: - items: - - enum: - - qcom,msm8976-tcsr - - qcom,msm8998-tcsr - - qcom,qcs404-tcsr - - qcom,sc7180-tcsr - - qcom,sc7280-tcsr - - qcom,sc8280xp-tcsr - - qcom,sdm630-tcsr - - qcom,sdm845-tcsr - - qcom,sdx55-tcsr - - qcom,sdx65-tcsr - - qcom,sm4450-tcsr - - qcom,sm8150-tcsr - - qcom,sm8450-tcsr - - qcom,tcsr-apq8064 - - qcom,tcsr-apq8084 - - qcom,tcsr-ipq5332 - - qcom,tcsr-ipq6018 - - qcom,tcsr-ipq8064 - - qcom,tcsr-ipq8074 - - qcom,tcsr-ipq9574 - - qcom,tcsr-mdm9615 - - qcom,tcsr-msm8226 - - qcom,tcsr-msm8660 - - qcom,tcsr-msm8916 - - qcom,tcsr-msm8953 - - qcom,tcsr-msm8960 - - qcom,tcsr-msm8974 - - qcom,tcsr-msm8996 - - const: syscon + oneOf: + - items: + - enum: + - qcom,msm8976-tcsr + - qcom,msm8998-tcsr + - qcom,qcs404-tcsr + - qcom,sc7180-tcsr + - qcom,sc7280-tcsr + - qcom,sc8280xp-tcsr + - qcom,sdm630-tcsr + - qcom,sdm845-tcsr + - qcom,sdx55-tcsr + - qcom,sdx65-tcsr + - qcom,sm4450-tcsr + - qcom,sm8150-tcsr + - qcom,sm8450-tcsr + - qcom,tcsr-apq8064 + - qcom,tcsr-apq8084 + - qcom,tcsr-ipq5332 + - qcom,tcsr-ipq8064 + - qcom,tcsr-ipq8074 + - qcom,tcsr-ipq9574 + - qcom,tcsr-mdm9615 + - qcom,tcsr-msm8226 + - qcom,tcsr-msm8660 + - qcom,tcsr-msm8916 + - qcom,tcsr-msm8953 + - qcom,tcsr-msm8960 + - qcom,tcsr-msm8974 + - qcom,tcsr-msm8996 + - const: syscon + - items: + - const: qcom,tcsr-ipq6018 + - const: syscon + - const: simple-mfd reg: maxItems: 1 + ranges: true + + "#address-cells": + const: 1 + + "#size-cells": + const: 1 + +patternProperties: + "pwm@[a-f0-9]+$": + type: object + $ref: /schemas/pwm/qcom,ipq6018-pwm.yaml + required: - compatible - reg +allOf: + - if: + not: + properties: + compatible: + contains: + enum: + - qcom,tcsr-ipq6018 + then: + patternProperties: + "pwm@[a-f0-9]+$": false + additionalProperties: false examples: + # Example 1 - Syscon node found on MSM8960 - | syscon@1a400000 { compatible = "qcom,tcsr-msm8960", "syscon"; reg = <0x1a400000 0x100>; }; + # Example 2 - Syscon node found on IPQ6018 + - | + #include + + syscon@1937000 { + compatible = "qcom,tcsr-ipq6018", "syscon", "simple-mfd"; + reg = <0x01937000 0x21000>; + ranges = <0 0x1937000 0x21000>; + #address-cells = <1>; + #size-cells = <1>; + + pwm: pwm@a010 { + compatible = "qcom,ipq6018-pwm"; + reg = <0xa010 0x20>; + clocks = <&gcc GCC_ADSS_PWM_CLK>; + assigned-clocks = <&gcc GCC_ADSS_PWM_CLK>; + assigned-clock-rates = <100000000>; + #pwm-cells = <2>; + }; + }; From patchwork Thu Oct 5 16:05:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Devi Priya X-Patchwork-Id: 148903 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2016:b0:403:3b70:6f57 with SMTP id fe22csp417682vqb; Thu, 5 Oct 2023 09:28:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGx17j3Ruf3z+mWbJcSB7DjEP6z197K2x+svqfJ29d+tFBapk2GF0SVxvLjhZBNaeewO1Ga X-Received: by 2002:a05:6a21:33a1:b0:169:3769:2739 with SMTP id yy33-20020a056a2133a100b0016937692739mr4024147pzb.14.1696523329337; Thu, 05 Oct 2023 09:28:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696523329; cv=none; d=google.com; s=arc-20160816; b=lAslhFjkZQMs5izpKYhha0Y077EaHn0GU1XsDs5VSQfkgfZYrQ5xi3sxrPuVpex+tk YovUKCX0hk6BjGpNHgwwGFkv+epaNk7xscJD+RKu1U6CD3km9OymFxkBajj74PAvFV7a f5V4u3yF2hVosaGDEhpR/vgNsh4iaA7lzsUKdC89l9aQFX8n45DoZS9IeFKJhkliWnFk jTufquR/jZRDzXLwUhBjZcJWKknBel3vQ6QNYBMYayIIViMmNP1VvxMY7ejX+KyiKTUd RS1AwTTwopQlcX0KkR9RfuG4LOSlZw7Akh0Q80uQzYrdNrLaJtdVsqtZikIGoqLam2k9 DhIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=NSi6brrY0QDAZ3HzHxPaf2hgz27vKeKX8LZRRHNWQWc=; fh=6AwcISBGklEC0U2b8ZFmhdtzZmcvKnccaXqP9iERvtc=; b=WtjqCQFxy+uKiJWmWpDkmO62bbb9R09mSqqsO8liDvepngktNRYfuT9TWUBqpSXJW6 +032fbwn1cNbf1KYOyZWQtpV0V3xc0yiAjm9h++xYDF214rnqLV1dUmM2YeDpiRc88Hx CjLFlm43aj9s1bYzUdoylYk5fcn23+pZILn0MSjmA3Up8xKdl3fZJLPsyG3zUWxlv21j 1j4iAD09d413QS9ELCxXjh9voLnhoFtnti8dhYJlBP1k7+/N054F1r34sR58WCN08NHW N3DL98Dr5J9BWrDGv3agj43Th49uRSwFDjWamUxhuXkH8XrC5fVv/3482BAfeLkN11aI cqXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=bhnUe3rj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id q19-20020a056a00085300b006934390d0casi1764662pfk.36.2023.10.05.09.28.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 09:28:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=bhnUe3rj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 36E518057464; Thu, 5 Oct 2023 09:28:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243503AbjJEQW7 (ORCPT + 19 others); Thu, 5 Oct 2023 12:22:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242451AbjJEQSB (ORCPT ); Thu, 5 Oct 2023 12:18:01 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6E8D3F025; Thu, 5 Oct 2023 09:06:56 -0700 (PDT) Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 395CsRur015464; Thu, 5 Oct 2023 16:06:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=qcppdkim1; bh=NSi6brrY0QDAZ3HzHxPaf2hgz27vKeKX8LZRRHNWQWc=; b=bhnUe3rjnlfJlfGglxvqihGmTNQCt2GnP9fbZBkIsYd0LKp5VGtAlA0IYUcwsiTLb7RK zTJfR/Llub7KabA70G7qxopCKO0GgBFRq3Xhug1Nnrpr08qcHCrAOSuS16i8viiv5tE/ Lrn3/Dj59DKIWaBWzrTmI5pK0eLkK0nAPYsTjv03eE8JFtw3M0lHrMQdjuwtpNE7ivjl CCkahl9YDirevdy+EdeBg17dBw4R3t/qo+3tDzom1COe5knM5DIJI79fxqY1ueFFOM6D D5mVEsufaOcEQFeLv3y7PtEsPTmWdyN2PCiU8GpFFz6KH8iJLyhzHc6o5pItDDupV1EG uQ== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3thn059cyw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 05 Oct 2023 16:06:41 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 395G6dfE025540 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 5 Oct 2023 16:06:40 GMT Received: from hu-devipriy-blr.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.36; Thu, 5 Oct 2023 09:06:34 -0700 From: Devi Priya To: , , , , , , , , , , , , , , CC: , , Subject: [PATCH V15 4/4] arm64: dts: qcom: ipq6018: add pwm node Date: Thu, 5 Oct 2023 21:35:50 +0530 Message-ID: <20231005160550.2423075-5-quic_devipriy@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231005160550.2423075-1-quic_devipriy@quicinc.com> References: <20231005160550.2423075-1-quic_devipriy@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: pbCgYn8v-0OpdxaoHvIbH76mglvWkJsO X-Proofpoint-GUID: pbCgYn8v-0OpdxaoHvIbH76mglvWkJsO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-05_11,2023-10-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 suspectscore=0 impostorscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 priorityscore=1501 mlxscore=0 malwarescore=0 lowpriorityscore=0 phishscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310050125 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 05 Oct 2023 09:28:17 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778933646554865178 X-GMAIL-MSGID: 1778933646554865178 Describe the PWM block on IPQ6018. The PWM is in the TCSR area. Make &tcsr "simple-mfd" compatible, and add &pwm as child of &tcsr. Add also ipq6018 specific compatible string. Reviewed-by: Krzysztof Kozlowski Co-developed-by: Baruch Siach Signed-off-by: Baruch Siach Signed-off-by: Devi Priya --- v15: Fixed the indentation of pwm node v14: Moved ranges just after reg as suggested by Krzysztof Picked up the R-b tag v13: No change v12: No change v11: No change v10: No change v9: Add 'ranges' property (Rob) v8: Add size cell to 'reg' (Rob) v7: Use 'reg' instead of 'offset' (Rob) Add qcom,tcsr-ipq6018 (Rob) Drop clock-names (Bjorn) v6: Make the PWM node child of TCSR (Rob Herring) Add assigned-clocks/assigned-clock-rates (Uwe Kleine-König) v5: Use qcom,pwm-regs for TCSR phandle instead of direct regs v3: s/qcom,pwm-ipq6018/qcom,ipq6018-pwm/ (Rob Herring) arch/arm64/boot/dts/qcom/ipq6018.dtsi | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/qcom/ipq6018.dtsi b/arch/arm64/boot/dts/qcom/ipq6018.dtsi index e59b9df96c7e..18f9fffba08b 100644 --- a/arch/arm64/boot/dts/qcom/ipq6018.dtsi +++ b/arch/arm64/boot/dts/qcom/ipq6018.dtsi @@ -390,8 +390,21 @@ tcsr_mutex: hwlock@1905000 { }; tcsr: syscon@1937000 { - compatible = "qcom,tcsr-ipq6018", "syscon"; + compatible = "qcom,tcsr-ipq6018", "syscon", "simple-mfd"; reg = <0x0 0x01937000 0x0 0x21000>; + ranges = <0x0 0x0 0x01937000 0x21000>; + #address-cells = <1>; + #size-cells = <1>; + + pwm: pwm@a010 { + compatible = "qcom,ipq6018-pwm"; + reg = <0xa010 0x20>; + clocks = <&gcc GCC_ADSS_PWM_CLK>; + assigned-clocks = <&gcc GCC_ADSS_PWM_CLK>; + assigned-clock-rates = <100000000>; + #pwm-cells = <2>; + status = "disabled"; + }; }; usb2: usb@70f8800 {