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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 99649C433EF for ; Sun, 12 Sep 2021 15:21:51 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C0019608FB for ; Sun, 12 Sep 2021 15:21:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C0019608FB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 970508393C; Sun, 12 Sep 2021 17:21:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=sholland.org header.i=@sholland.org header.b="AUV5LOaB"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="pkG0YxhQ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F1CEA83941; Sun, 12 Sep 2021 17:21:46 +0200 (CEST) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3080E838C6 for ; Sun, 12 Sep 2021 17:21:44 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=samuel@sholland.org Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 5B1CE5C0079; Sun, 12 Sep 2021 11:21:43 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 12 Sep 2021 11:21:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm3; bh=wptcZGM5lkvHBLMTs0PGxquW8x 2lV3xP9vaR7bHmmuw=; b=AUV5LOaBh+KnOnJj7MXHAH0TxAnVIThYR/AZyuho1Y 5fa7DU53gLDbnEiyIadSwzIAVfH6rfXaGizUy9DFzcmm/me61kenSKgH67wfYldU yZOUvU25rjBF9pBwWgqkbSXFt0d7GAnCQjlxJ8kUW5PSkNhGz1bzoPtkNrOH0knx P5fGReW/z0JiPXFr+VPmuwpAqZOEIvm6JUyZkEBikd6PoJGAzI9qJETdfZTpdRIL xbh/KfbpCCZ8gxp1R1fxRk5yE45KhbilhjDljk6QHaBG06hDJSq1mIaCj0DXmgR3 W3kOZ4cnPPMBiLory2bBP9mT8uwpAr78++L/myasAvag== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=wptcZGM5lkvHBLMTs 0PGxquW8x2lV3xP9vaR7bHmmuw=; b=pkG0YxhQjZUDHehPPz8PISmPVVWsjbWEu +SwevYG66q7pEAa9GF6vX33V/dOSNiSkiV6W4JepBa44VySutCnraJu4KqcVtD8e Fh5ZpZTxjZBq/6X/FeLguSWsO6YugGDPJkL5S1rYi3QVqjhYHV4OsxNMCVI6Mzcw L3Dy+UQiZH06eIUeyQge60ixAPEfWDtn2Kyd3rvoUSPwIN1JjEfpqexQzAIL6vP0 HU6ppNqlhkUmyu4e5cjIyjJ5ZlnGV7MGfJL7Okfk7Jk81Mq/7gK7WWROeyyTYQq3 4SLuTMu035Mu+mfcsRlP6/JzDaUPmuAajnurdA5x0lvW0E3gnuGuQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudeghedgkeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffoggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgvlhcu jfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtffrrg htthgvrhhnpeeiteekhfehuddugfeltddufeejjeefgeevheekueffhffhjeekheeiffdt vedtveenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 12 Sep 2021 11:21:40 -0400 (EDT) From: Samuel Holland To: u-boot@lists.denx.de, Heiko Schocher Cc: Jagan Teki , Andre Przywara , Samuel Holland Subject: [PATCH] i2c: mvtwsi: Add support for DM clocks and resets Date: Sun, 12 Sep 2021 10:21:39 -0500 Message-Id: <20210912152140.40552-1-samuel@sholland.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean The controller may need to have clocks/resets enabled for it to work. Add support for this. Since the clocks/resets are optional on some platforms (per the device tree binding), do not prevent probing the controller if they are missing. Signed-off-by: Samuel Holland --- drivers/i2c/mvtwsi.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/i2c/mvtwsi.c b/drivers/i2c/mvtwsi.c index d33e2c7c9d8..236bfb8d8e7 100644 --- a/drivers/i2c/mvtwsi.c +++ b/drivers/i2c/mvtwsi.c @@ -17,7 +17,9 @@ #include #include #if CONFIG_IS_ENABLED(DM_I2C) +#include #include +#include #endif DECLARE_GLOBAL_DATA_PTR; @@ -835,7 +837,18 @@ static int mvtwsi_i2c_bind(struct udevice *bus) static int mvtwsi_i2c_probe(struct udevice *bus) { struct mvtwsi_i2c_dev *dev = dev_get_priv(bus); + struct reset_ctl reset; + struct clk clk; uint actual_speed; + int ret; + + ret = reset_get_by_index(bus, 0, &reset); + if (!ret) + reset_deassert(&reset); + + ret = clk_get_by_index(bus, 0, &clk); + if (!ret) + clk_enable(&clk); __twsi_i2c_init(dev->base, dev->speed, dev->slaveadd, &actual_speed); dev->speed = actual_speed; -- 2.31.1