From patchwork Fri Dec 4 18:31:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Ford X-Patchwork-Id: 11952099 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1C4BC4361A for ; Fri, 4 Dec 2020 18:33:28 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3F00022582 for ; Fri, 4 Dec 2020 18:33:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3F00022582 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=K54HjcAXX676Lb874YtEwnHtqo3EJJrFY5toUSoAZ6Q=; b=rQE0jlGvoKldTyYjvR8BRnAww+ MzHymsfOB8BXZu0iurxYu+hd+0IJ0Jp9BaSWlh+/qDlQyUK2+WRZlFQPNzQL3gbEIZ6Jw1e8AhiPs 7mxPi6JWO3nO8Qg751fJNJwyxIOnjvduOChqNVS9ZWYHV6I0px6MpaHWHhXwMZipdMDTAL+V2pK/O MyRk2T+QIEciOKZoi+MUkHn0TjSUowtc1J/NbOI/6LRr75O3czK1RYpFWmMWtTJWNi0oAto9kLu+5 yo9GEnhVKbPRJ9EI4/34V0taeJXaYubw8Xvx05In4k5aOFltdwlKcOtuzS9HgA9yFK2RQPrF+iRGt n4wFQqNw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1klFsL-0002FC-S5; Fri, 04 Dec 2020 18:32:13 +0000 Received: from mail-il1-x135.google.com ([2607:f8b0:4864:20::135]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1klFsJ-0002Ec-Ji for linux-arm-kernel@lists.infradead.org; Fri, 04 Dec 2020 18:32:12 +0000 Received: by mail-il1-x135.google.com with SMTP id r17so6039848ilo.11 for ; Fri, 04 Dec 2020 10:32:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=NzKZ943JGTNloiN146GZP9I+EpZC20D+gFEel4Gitb8=; b=SeSqVhHl47UvFR6qCSbOqOwUPvIQm298r8//4V8E3E1wtei2+ml27FPsm6fF9oqWJi JKLkIZSgtRmjYJEBXq8encd8/ps9kieq3N/Fk/jOxEOLXe1BmyUjnxz4wdv9j3ZOesml ULm4YCbA7x9cs8vMJ0VhcsjLq+l6MqgQLP3ERg4jzYkrEgdgCOXcMzMynFWlm/yIInaT oNxZX4R7UId/p162m8BDccGn99S/W3FsQUDKBtGmByPLIoS6qz+YOE9fUR0QrHTYocjr yBQd1bZdoxNPWwjEmvejjcKyh9hNoGdkXOZwKufxeJGmLG90AhrfOUue8/w+dU4KDvhd OqXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=NzKZ943JGTNloiN146GZP9I+EpZC20D+gFEel4Gitb8=; b=E7A0fkmuZ8daMt9hOzpO8559TpaHqjXDCe95Eo/8sVDYW1Swnohkts2HH/hAB9xNSL INJ3spDaiYCO9bN1XY18dHhikhjp567r/x0K8Qsm8xyvvKObIXS34GhuJI2RD8xiBMFG kiefnHxXufqLiLTQVKS4CljbUiSVDkHWJdNKDNXeTQ6Yb0TRcii1SjhfFwrq+H0MXemh Crtqv/H9d8Byou/sDQkklzddsY3dufYitmOH83jdltZATx3b1r3a6+tSy//VEZ8HfeQz /y75uxbm/F8fIiRIhTLPw1fFtbkRKoHr2NYh75xfWQ2VAZooslX0mODXboMYkSh4dFHv 4/Sw== X-Gm-Message-State: AOAM532ksB4xz38684LQNXxqwPyz8GMLRBpIpyxtxDUHx5VzsQV45Ofi qWwNV41sIuS3bqFOLmLDhYw= X-Google-Smtp-Source: ABdhPJxGsBLdSmKY8+m4xFcwZUgkJ1jukKmUe+1owxKbk3IXvQtv0d+e0qtlamj75Nr3azRE9cCSCQ== X-Received: by 2002:a05:6e02:929:: with SMTP id o9mr8055335ilt.42.1607106729669; Fri, 04 Dec 2020 10:32:09 -0800 (PST) Received: from aford-IdeaCentre-A730.lan ([2601:448:8400:9e8:4c53:aff:c64:cd45]) by smtp.gmail.com with ESMTPSA id s17sm1955714ilj.25.2020.12.04.10.32.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2020 10:32:08 -0800 (PST) From: Adam Ford To: linux-clk@vger.kernel.org Subject: [PATCH] clk: imx: Fix reparenting of UARTs not associated with sdout Date: Fri, 4 Dec 2020 12:31:54 -0600 Message-Id: <20201204183154.94002-1-aford173@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201204_133211_723086_93BA1295 X-CRM114-Status: GOOD ( 14.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Aisheng Dong , Linus Walleij , Fabio Estevam , linux-kernel@vger.kernel.org, Stephen Boyd , Shawn Guo , Michael Turquette , aford@beaconembedded.com, charles.steves@logicpd.com, NXP Linux Team , Pengutronix Kernel Team , Adam Ford , Sascha Hauer , linux-arm-kernel@lists.infradead.org, Jerome Brunet Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The default clock source on i.MX8M Mini and Nano boards use a 24MHz clock, but users who need to re-parent the clock source run into issues because all the UART clocks are enabled whether or not they're needed by sdout. Any attempt to change the parent results in an busy error because the clocks have been enabled already. clk: failed to reparent uart1 to sys_pll1_80m: -16 Instead of pre-initializing all UARTS, scan the device tree to see if UART clock is used as stdout before initializing it. Only enable the UART clock if it's needed in order to delay the clock initialization until after the re-parenting of the clocks. Fixes: 9461f7b33d11c ("clk: fix CLK_SET_RATE_GATE with clock rate protection") Suggested-by: Aisheng Dong Signed-off-by: Adam Ford diff --git a/drivers/clk/imx/clk.c b/drivers/clk/imx/clk.c index 47882c51cb85..6dcc5fbd8f3f 100644 --- a/drivers/clk/imx/clk.c +++ b/drivers/clk/imx/clk.c @@ -163,12 +163,18 @@ __setup_param("earlyprintk", imx_keep_uart_earlyprintk, void imx_register_uart_clocks(struct clk ** const clks[]) { + struct clk *uart_clk; if (imx_keep_uart_clocks) { int i; imx_uart_clocks = clks; - for (i = 0; imx_uart_clocks[i]; i++) - clk_prepare_enable(*imx_uart_clocks[i]); + for (i = 0; imx_uart_clocks[i]; i++) { + uart_clk = of_clk_get(of_stdout, i); + if (IS_ERR(uart_clk)) + continue; + clk_prepare_enable(uart_clk); + clk_put(uart_clk); + } } }