Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1371554lqp; Mon, 15 Apr 2024 04:49:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWZOa4oWVq2mRk195RKSvMRAVlU2+xK9WpiOWfkxV5Zb69wjjwy8g4nfQoRiC1syYb/etslJGwnlHU91g4tKWtehf8PqT3ZmGLtElNY1g== X-Google-Smtp-Source: AGHT+IGJquunI4MMMhwxG8aGOqdZmuZ1Zpag928D1g2OgDSYBJX9YazHgVWXivJuSPD0BYN5KRgY X-Received: by 2002:a05:6a20:43a0:b0:1aa:282e:8dac with SMTP id i32-20020a056a2043a000b001aa282e8dacmr1415120pzl.0.1713181747626; Mon, 15 Apr 2024 04:49:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713181747; cv=pass; d=google.com; s=arc-20160816; b=HmgLmQ4cG5kUcjwrKh/A9784jCywMqDebXcm53oUhcxMh4CWJq00g2F+zYcg/XYgTY TNcdRjNJUS+MCz8Oe+DZYIWElhVtuoV4brtuZ2U39FpaaHPslp6XdhAmP+tzSj3VR3oP 27PZ7auRtauWTSqbcpfJJjgi9GzmLp/aXv0s4sruYl31XcsD1L0FssN+eFn4Q4ps62lW nci8/b9MTsIQaFpZkN1II5gO4XzdqQPhwOx/3dq7xnBE97TA4PlMT8emds/3YQJKPS30 IK7XcPzMXUTWFJnxl9c95S3nD67XRld4KVfhUmLOIz+4UDimyIMC1CNxTsZcrxB4pilV oeNA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language:subject :references:cc:to:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=mHFzrlLFn4E1ExYOjEZ9nCG7yBy5rx/gtcDIhxkwf64=; fh=tddC5zeHlyn2Dt5fWzWr+NQywvnEOnl8sDHC5hFfGs4=; b=rwh0IQo1i7TcVRuWvZgnEbzLobGPvypm9WOXtlddFtYqCdNLWBQVGymK/gGFTEBzj3 9kc2YLtchOwO7/tE8PG4Koo74FPKW3vxtSxNvByyPCy/ljM5v6TdTYUnbHnG0Hziofms xgHA1f1OHyHNiOnZ7HrX1WD9SpnEXBTSrH1FpmznbR/T0f+pxZABzMIVq0Xrdd/1YIOr ipj62VGVNjaMFJqxZ1TY9WDiRfvAf999ZEDFcGpyO4czvbcPHN0KIbTwb55n7ju0rTa3 AucbeHph3OJ7BBL/txxBL9Kqp6SsQ/Mx2ZjYAh5ve+4h5KR/EIVWzMPsgeSEVr5s9IyU 8f0Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=hTWESPEz; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-145004-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145004-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id me12-20020a170902fc4c00b001e510d549casi8054593plb.294.2024.04.15.04.49.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 04:49:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-145004-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=hTWESPEz; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-145004-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145004-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 21790B21EBF for ; Mon, 15 Apr 2024 11:49:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 395C864CF9; Mon, 15 Apr 2024 11:48:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="hTWESPEz" Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E1A74E1C9; Mon, 15 Apr 2024 11:48:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.198 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713181734; cv=none; b=QcmI59SP4+UCfhQ6htnEjGXx5dCCSJb1uRw4Y3AT77VsjEODQlFNmt9VXQHmhv/szqnXdSkTlTKhcmvts5NmdKtS6PSImohLknYtl36mDrJpUsa+bIlLu44RFNnRrZMg7uplu6oM4Ox13wNC4U6dz2O0vySz8qvtaJVolPOsdIM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713181734; c=relaxed/simple; bh=eET1pX9I1cdrhU3c46Ss84IQIxFOX+xYeTVK4Qtj68o=; h=Message-ID:Date:MIME-Version:To:Cc:References:Subject:From: In-Reply-To:Content-Type; b=MWRR3YQUsMuXEPPZPR1J7/Ia8Zv+8M0TYFT7pDiMHIEcjyzsgam7az4EleWV9TvfIkfmjJqxiOeLiBVM3gsWDaY8y/1b8ydtR9Zrxr2bLxOM/P4Z1Utn7RN2MnFW/FIpcvuo6M9YTyffm4WZVw0L0tG3anJ8d+je8Hlv+8rfoSE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=hTWESPEz; arc=none smtp.client-ip=217.70.183.198 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id E09C8C0005; Mon, 15 Apr 2024 11:48:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1713181729; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mHFzrlLFn4E1ExYOjEZ9nCG7yBy5rx/gtcDIhxkwf64=; b=hTWESPEzV9xVD9Q+wMDkau2rPvUPdmuiyZ6O3MBPlHaTgXpNpDJ4OA1hrr1XvjZ+ub5NkR 49r8eQUbSd2w9nB4Xzlfe5kwmrWB6Jr6LVsuRel7mO3jJWreOBg7qh1PPMh0OgYgiCWVYE 1ZgjoAGwgkM88blAik+YLtkNfZa92iaZnlIYlcMMlrbe1U0rMruQBAr636aj1wZTDbHZJB dITN890v6oSkUGEd5rkLayad6YXeX0SRS3xo6wHC3avpvA4+qbnqZQqRjkO9oucAANQsQH lvlumYo8Rlgeb6y/q7JnpBJGoqdVfsi8yoFKtjh2vEEfoIm4P6i80EjDDwiUWA== Message-ID: <9f8a584c-03a7-437e-96a7-56484523b2e4@bootlin.com> Date: Mon, 15 Apr 2024 13:48:48 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: jszhang@kernel.org Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, guoren@kernel.org, krzysztof.kozlowski+dt@linaro.org, linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org, linux-riscv@lists.infradead.org, robh+dt@kernel.org, thierry.reding@gmail.com, u.kleine-koenig@pengutronix.de, wefu@redhat.com, Miquel Raynal , Thomas Petazzoni References: <20231005130519.3864-3-jszhang@kernel.org> Subject: Re: [PATCH v3 2/2] pwm: add T-HEAD PWM driver Content-Language: en-US From: Thomas Bonnefille In-Reply-To: <20231005130519.3864-3-jszhang@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-GND-Sasl: thomas.bonnefille@bootlin.com > T-HEAD SoCs such as the TH1520 contain a PWM controller used > to control the LCD backlight, fan and so on. Add driver for it. > > Signed-off-by: Jisheng Zhang --- Hello, I've just tested your driver and it works flawlessly on the BeagleV-Ahead with the last mainline kernel. However, I had to modify some portion of the code to comply with the last kernel needs. > +static const struct pwm_ops thead_pwm_ops = { > + .apply = thead_pwm_apply, > + .get_state = thead_pwm_get_state, > + .owner = THIS_MODULE, Since commit 384461abcab6, the owner of a pwm_ops structure is implicit and so, you can (must) remove this last line now. > +}; > ... > +static int thead_pwm_probe(struct platform_device *pdev) > +{ > + struct thead_pwm_chip *priv; > + int ret, i; > + u32 val; > + > + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); > + if (!priv) > + return -ENOMEM; > + > + platform_set_drvdata(pdev, priv); > + > + priv->mmio_base = devm_platform_ioremap_resource(pdev, 0); > + if (IS_ERR(priv->mmio_base)) > + return PTR_ERR(priv->mmio_base); > + > + priv->clk = devm_clk_get_enabled(&pdev->dev, NULL); > + if (IS_ERR(priv->clk)) > + return PTR_ERR(priv->clk); > + > + priv->chip.ops = &thead_pwm_ops; > + priv->chip.dev = &pdev->dev; > + priv->chip.npwm = THEAD_PWM_MAX_NUM; > + > + /* check whether PWM is ever started or not */ > + for (i = 0; i < priv->chip.npwm; i++) { > + val = readl(priv->mmio_base + THEAD_PWM_FP(i)); > + if (val) > + priv->channel_ever_started |= 1 << i; BIT(i) ? If the bootloader starts a PWM channel for some reason, it will not be referenced by the PM usage counter, I added this line in the if statement to counter this problem : pm_runtime_get(&pdev->dev); > + } > + > + ret = devm_pwmchip_add(&pdev->dev, &priv->chip); > + if (ret) > + return ret; > + > + devm_pm_runtime_enable(&pdev->dev); > + > + return 0; > +} Thank you for your work. With the above comments addressed: Tested-by: Thomas Bonnefille Do you plan to send out a new iteration of this patch soon ? Best regards, Thomas Bonnefille