Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp3924092ybh; Tue, 17 Mar 2020 09:00:35 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsdSnkQooB01HUqWgx5u/ry+NnjTaLc9tTuwLL11AAKU9+tCXfYOoS2ZxCTQK61gf2KranU X-Received: by 2002:a54:4e13:: with SMTP id a19mr18606oiy.108.1584460835073; Tue, 17 Mar 2020 09:00:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584460835; cv=none; d=google.com; s=arc-20160816; b=BMBoUa6o0F/jK8MRSYhxBQkfZUVstaGDWVu2ONtN+2MwzULTbHC00RNJo/OtojeLPp FauZlyuJ7wz1jwzWAtljKOhH5g/oiVxzLw8Om/137g0TlovfiOBNyebGFNW3hSJ8f0CA v6tbad7LyBptB7wS1n9vvsyTp7UqWGfAxqg9sUIL5Ib502HMZWL8NcdZFuHeZ/4ZtXip HOaAOn6BgaOyNYaSQNwg59Cmw1axwLVhzN2/VAvHVNjWNK2WhQZ5QnktGqRn5EECZ+gr 4Ir8la2Ux8W+YTiQMHwG2YU64w6GBRPnHaA7Zuu4JfclhURpjCycw+pm1CWo4RV6ORUW UfJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=euefWLuxU1COLDNswebG/zDd8n44iQG/oIUiow0l+k8=; b=Q5xW5RBoRv4TdgEkrLt94rJBpAoISDgHb6Tu1K217slvFvvwcPb2Yq5Yqhuh3CS31L P6flvozLHyZVPuEjsqa/fd1gxNgJm8Tr0g7UrKrb7dquQWnWkEJbh+wEu0lJQmsgV5hl RYFjhUcaXTCPWfWCSUbE5o8clCfKuSwbnuYKSz+J2QvhmbQGPr6oYKShARc0whkNZTU1 6J8tkUA5N25SxX/Okyg2hScFa6YBu6yFBKFI/vZDQdxNon3CzQBALmG+0wekjP46h3EL Yv+IDE+j13+kBoYxDqrTwlK7adaiQYh1fKxpZSv66WDihttLI3dBLYezCf9C4S6y3pXB YLfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@pascalroeleven.nl header.s=x header.b=Rd1sHmCw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=pascalroeleven.nl Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k16si1596396oiw.128.2020.03.17.09.00.19; Tue, 17 Mar 2020 09:00:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@pascalroeleven.nl header.s=x header.b=Rd1sHmCw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=pascalroeleven.nl Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726774AbgCQP74 (ORCPT + 99 others); Tue, 17 Mar 2020 11:59:56 -0400 Received: from web0081.zxcs.nl ([185.104.29.10]:54488 "EHLO web0081.zxcs.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726294AbgCQP7z (ORCPT ); Tue, 17 Mar 2020 11:59:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=pascalroeleven.nl; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-Id :Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=euefWLuxU1COLDNswebG/zDd8n44iQG/oIUiow0l+k8=; b=Rd1sHmCw7URX7qFwECdA+CQdfs Qq2BrOmNMSVVqJQqoZNPM7HO8qoGH5WrmSylPSMBRBVb3SyN8k8eSviqUFEMp1e8KZ51mstYxJjpx KOizuubWsrzlUvgg1ARTz1n2ZxfnwcCE3W4VmF2J4jYiwSU7H7RmbVXfpwkcNUurkxQpLsdodkEke RrVlpvoPD+5nvA8yYwJuxu07V/5qt2jalgyBA/G2VhqMUTW0ARFcZc3feBY+pHPOFu4URZy3tuPqS deUEST4nlY5nh8Qwllch1OXaH0Y3McorydONMSBziwRFVXXrRbnh2c3nC+dvX/xQDN2htJneQYgoA MsfsJtOg==; Received: from ip565b1bc7.direct-adsl.nl ([86.91.27.199]:60802 helo=localhost.localdomain) by web0081.zxcs.nl with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92.3) (envelope-from ) id 1jEEdB-001IGT-Mc; Tue, 17 Mar 2020 16:59:49 +0100 From: Pascal Roeleven To: Thierry Reding , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Maxime Ripard , Chen-Yu Tsai , Philipp Zabel , linux-pwm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: linux-sunxi@googlegroups.com, Pascal Roeleven Subject: [RFC PATCH 0/4] pwm: sun4i: Properly turn pwm off and fix stuck output state Date: Tue, 17 Mar 2020 16:59:02 +0100 Message-Id: <20200317155906.31288-1-dev@pascalroeleven.nl> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Authenticated-Id: dev@pascalroeleven.nl Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi all, For the last few days I've been debugging a lot to get pwm working again since recent changes in 5.6-rc1 broke it for me. Testing shows the pwm controller crashes (or the output gets stuck) when the period register is written when the channel is disabled while the clock gate is still on. Usually after multiple writes, but one write can also lead to unpredictable behaviour. Patch 3 and 4 fix this. Patch 2 contains a fix which wouldn't completely turn off the pwm if the output is disabled. The clock gate needs to stay on for at least one more period to ensure the output is properly disabled. This issue has been around for a long time but has probably stayed unnoticed because if the duty_cycle is also changed to 0, you can't tell the difference. Patch 1 removes some leftovers which aren't needed anymore. Obviously these patches work for my device, but I'd like to hear your opinion if any of these changes make sense. After days, this one is a bit blurry for me. Thanks to Uwe for some help with debugging. Pascal. Pascal Roeleven (4): pwm: sun4i: Remove redundant needs_delay pwm: sun4i: Disable pwm before turning off clock gate pwm: sun4i: Move delay to function pwm: sun4i: Delay after writing the period drivers/pwm/pwm-sun4i.c | 53 ++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 27 deletions(-) -- 2.20.1