Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2733622pxv; Mon, 12 Jul 2021 00:11:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSt0I3QNAbhypA9mEAIDYDgdH1O3/djKM+DlamJ7Nq9Ow0ibM2p82/6jHYtnRHOeENfjQP X-Received: by 2002:a6b:7c07:: with SMTP id m7mr38853933iok.47.1626073900631; Mon, 12 Jul 2021 00:11:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626073900; cv=none; d=google.com; s=arc-20160816; b=IqKsdH9v7beZTe55IJj/c1WoyZbl0U56f1Z5VoU9M43F8+6AughuOFx9Rgya595f6t nh+7ybSXmtUlc72TGRxKg0vMBrMIWrx2q03ITWUHmMgfBLwcT2fApYIwiEyLnk0ErYJB x6f2kyG/Z5RBT+Bfzi/jxpMc6OGFfDUqfmCqhCshahTpqLbpb7ZEC43YlN+0rjvkMFmL X07YaHao7F/S1tsDOkHjcnUFke/ERlTRRH98M9I2zm9I+0kD581z+6s2LIdSqtUzeGFK u4sxdrzBKUsIVzUVIJ3YYsA2CuSN4F0+nnLsFEhYg8m6c34tvqBJ5sZizHDugXAsVudE G+jg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Bh/s7nEG52HT/fhyK+NeYbimNuTOYUzC80YqUhdOB8Y=; b=byB3h7wMTkiuw2tjNgWE+4GAQfyPwQ3f4oqjvtGGgYqJdNG9tlaWTfRzC6KhZab5tz uWOUUBCQMwKBdbqk8VO60J7gpdAN9QmmlAVdAVMrxnusHWbF/tIchVosbEm3cv9RaHWm 1nni2IQMfS5VwfnfyE+w14qkmlH8Cr9QA1CJbHZfGzAnJuLbXMKBUytUrCnoqbKST9AH qkiecEz6cy2VIiAJMeTWuwvO2CjxzyolNkDmAxWxeFL6wQwlOe7J5UcSAejrq1iFA+nY WS2qCgY4hyw6kWyss3NmVXhT4AQsF0V9oMBAMRy1E1Zs1ao5idLbWIWU2MqRQnorU1fe BIhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WJAyepVa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v1si16431927ioj.78.2021.07.12.00.11.29; Mon, 12 Jul 2021 00:11:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WJAyepVa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241014AbhGLHNM (ORCPT + 99 others); Mon, 12 Jul 2021 03:13:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:45530 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238416AbhGLGsk (ORCPT ); Mon, 12 Jul 2021 02:48:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BB3E360233; Mon, 12 Jul 2021 06:44:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626072269; bh=G8YL6T1iBH1nBWOx2yCzGcu378wr6uJX+MtL00NrUdo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WJAyepVaxpgyaDgoODqS2LcVi+K6I9iKPaNGPGGQ59413ggzJ5N889S9R8A57/bfg BRVTKjO9YqpAr7ul3FQraUwWsvLOMDFalcuCyGxTqaveCw4gHrNeHyAiMBIfPqzv++ N4QOcRKttw3W+MvEK+9X0yQAa97+bHhlxKZFQ38U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Robert Hancock , Stephen Boyd , Sasha Levin Subject: [PATCH 5.10 424/593] clk: si5341: Check for input clock presence and PLL lock on startup Date: Mon, 12 Jul 2021 08:09:44 +0200 Message-Id: <20210712060934.964551890@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060843.180606720@linuxfoundation.org> References: <20210712060843.180606720@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Robert Hancock [ Upstream commit 71dcc4d1f7d2ad97ff7ab831281bc6893ff713a2 ] After initializing the device, wait for it to report that the input clock is present and the PLL has locked before declaring success. Fixes: 3044a860fd ("clk: Add Si5341/Si5340 driver") Signed-off-by: Robert Hancock Link: https://lore.kernel.org/r/20210325192643.2190069-5-robert.hancock@calian.com Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- drivers/clk/clk-si5341.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/clk/clk-si5341.c b/drivers/clk/clk-si5341.c index ac1ccec2b681..da40b90c2aa8 100644 --- a/drivers/clk/clk-si5341.c +++ b/drivers/clk/clk-si5341.c @@ -92,6 +92,9 @@ struct clk_si5341_output_config { #define SI5341_PN_BASE 0x0002 #define SI5341_DEVICE_REV 0x0005 #define SI5341_STATUS 0x000C +#define SI5341_LOS 0x000D +#define SI5341_STATUS_STICKY 0x0011 +#define SI5341_LOS_STICKY 0x0012 #define SI5341_SOFT_RST 0x001C #define SI5341_IN_SEL 0x0021 #define SI5341_DEVICE_READY 0x00FE @@ -99,6 +102,12 @@ struct clk_si5341_output_config { #define SI5341_IN_EN 0x0949 #define SI5341_INX_TO_PFD_EN 0x094A +/* Status bits */ +#define SI5341_STATUS_SYSINCAL BIT(0) +#define SI5341_STATUS_LOSXAXB BIT(1) +#define SI5341_STATUS_LOSREF BIT(2) +#define SI5341_STATUS_LOL BIT(3) + /* Input selection */ #define SI5341_IN_SEL_MASK 0x06 #define SI5341_IN_SEL_SHIFT 1 @@ -1416,6 +1425,7 @@ static int si5341_probe(struct i2c_client *client, unsigned int i; struct clk_si5341_output_config config[SI5341_MAX_NUM_OUTPUTS]; bool initialization_required; + u32 status; data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); if (!data) @@ -1583,6 +1593,22 @@ static int si5341_probe(struct i2c_client *client, return err; } + /* wait for device to report input clock present and PLL lock */ + err = regmap_read_poll_timeout(data->regmap, SI5341_STATUS, status, + !(status & (SI5341_STATUS_LOSREF | SI5341_STATUS_LOL)), + 10000, 250000); + if (err) { + dev_err(&client->dev, "Error waiting for input clock or PLL lock\n"); + return err; + } + + /* clear sticky alarm bits from initialization */ + err = regmap_write(data->regmap, SI5341_STATUS_STICKY, 0); + if (err) { + dev_err(&client->dev, "unable to clear sticky status\n"); + return err; + } + /* Free the names, clk framework makes copies */ for (i = 0; i < data->num_synth; ++i) devm_kfree(&client->dev, (void *)synth_clock_names[i]); -- 2.30.2