From patchwork Wed Apr 10 17:06:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 1922160 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=YxlkRUn4; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VF8Qn15pZz1yYH for ; Thu, 11 Apr 2024 03:07:45 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 75C62881A6; Wed, 10 Apr 2024 19:07:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.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=linaro.org header.i=@linaro.org header.b="YxlkRUn4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C52E587A00; Wed, 10 Apr 2024 19:07:14 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id CC9258815A for ; Wed, 10 Apr 2024 19:07:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-a51d3193e54so422955966b.2 for ; Wed, 10 Apr 2024 10:07:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712768830; x=1713373630; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=02zx0nKuszz8w4M8rcBUaVZHu951fIoW3vmJjCnRxRI=; b=YxlkRUn4WkjqMw8z/0H7J9Yzm+Rd9VY4MspkYuV44UiQ1m1Bq+IlvYShY3ZtAFtopQ 6Xyd5qtEwPzXX7MB+SDzZLPUpJY9z/W/Q6PkRaVJ+RmupTAoCS8oZEDsB1dr1WFdNCw1 My1Hcdmv+IfOesmMWAqiil4eXfLeJE1L/txFrFbAN6Ad8syo+x+K3iNNhoaRbDERbvcV lb8EuEKwEzAjxmt5D5Anjdbi47aC9EJhf0t+sF/3MOUuC7Gn/oQuXYRlHL8PdMcczsTv 5XtFuSwlHokzj3B3RIO8J33KsGeTvOYOz5LWiIUkHYYgFsu/2lp9lKbRLGybKm53PAit VygA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712768830; x=1713373630; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=02zx0nKuszz8w4M8rcBUaVZHu951fIoW3vmJjCnRxRI=; b=T/QpXvv3YMM1VgPzb/YB7e1VAFwGflT7S8E58IfHMZIZI497CQnMM0NOMwaUWdz/wn eHWvcNgZ6lHfR6ZfwxDymqi+/F6PcuvaDtFnVh+tZ94/w6qp5B+hJ3IFz1Ga6J9mKYHT 95RN7V+r/tXqEjDLV98IZ7UXZxZFjF3oKeAQVrxO4XJPag9APHR377lwicTDo9mSwjN/ BsIxrMXYiDhNIvhn3AMO7B6I0E2QRiKbWTNtV7kZQARvKAq7h0tLQB0vZH5fuKJEvSiW sDAUJVwYSgn26QbDWBu3/696691XgAFfo/3xWos/9VH0QBZD7RhoQg+LTgAx7N0t5lJD VELw== X-Forwarded-Encrypted: i=1; AJvYcCVZGBtlc5jfhePi1wma/PsUYZ0Mr1kz7rPYOJcJzaLcs8ZVPYxecQCei1lMqpfRplOvvz7pjaR3Nzbgag6b0eWU5FNCkA== X-Gm-Message-State: AOJu0Yz2LyrWIhuMq5ooulCfz6OR9+H6AfioxQl/vxIIhU5Nq93kDyb9 fETkMD+iFi4uJFFCn13YD9fDlOFSW+5T7ZhEgzn+7wPGG49sa4oaImAOmJm6R/A= X-Google-Smtp-Source: AGHT+IFl6OnMsLwkH7TwWe+xbuR36hz09wRiilZ3b9Ruur/2iS3YSyVCLJ/3X7RUhZ7bIe69kL2nIg== X-Received: by 2002:a17:906:168e:b0:a47:3312:b32a with SMTP id s14-20020a170906168e00b00a473312b32amr1919786ejd.58.1712768830205; Wed, 10 Apr 2024 10:07:10 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::4716]) by smtp.gmail.com with ESMTPSA id fw14-20020a170906c94e00b00a51def4861bsm3331881ejb.91.2024.04.10.10.07.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 10:07:09 -0700 (PDT) From: Caleb Connolly Date: Wed, 10 Apr 2024 19:06:57 +0200 Subject: [PATCH 1/2] dm: core: add support for fallback drivers MIME-Version: 1.0 Message-Id: <20240410-b4-stub-drivers-v1-1-6935bd2c07d1@linaro.org> References: <20240410-b4-stub-drivers-v1-0-6935bd2c07d1@linaro.org> In-Reply-To: <20240410-b4-stub-drivers-v1-0-6935bd2c07d1@linaro.org> To: Simon Glass , Tom Rini , Lukasz Majewski , Sean Anderson Cc: Heinrich Schuchardt , Ilias Apalodimas , Neil Armstrong , Sumit Garg , u-boot-qcom@groups.io, u-boot@lists.denx.de, Caleb Connolly X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3910; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=uW3PK2f+vNh4A0TYpzbXWCElmio+ONn45bjBs9aUpF0=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmFsc7YF0BDVZO+uz5tupQgE07BKp8Ga8CO2qp9 hox89OoEr+JAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZhbHOwAKCRAFgzErGV9k tkOOD/0SKIDh/houY3Vc1EjRfU89aK1EFjC00epK1FvezX141IgzZ09dqoVNGNGd/snA1StVIgQ XJJANgWevmKq8no0jP9Hl8ERYQRSabpmIfjiwYCKBoPhWrhwf4paUyCG3lI6JtDkb5OrTpCEH+k m3bKNijBP6LgGbyYPWRWMN9aNLFtDGYqmHglPZHWJmXXnjDsmg486vJcIpitGNpqULk9ZExEUmr ZiPkvsJOx/1l3Lq6fx6hB2MHA3EzHPLHz6Vo5DGauYoELr/FICtmSelMbdm76mvvWWN3kwlIDQS A877anXpMNxYLpWWsOszX/FxthHjLZEKFC6eQBcva/AI9X3sFLzg88cDY1dsGk3LIuX6AGYilKJ bCfGqObCderWBuCjIV+mygAyrULbS4GLwD79mBST2PPb+qK9i6FGx/9s0iHIn+icfuD5b4n02eu yoZ+WV1P6CqjHENkc3gGc/qDo+bmAbyIOZStS1LWrX5zP7035k+qhIaiBoDu0Az1k2S4w/N2xNw Wgkr1WT6Wsoee/SOgt/Rf/7qQNnBSZlujUwJcThoJHMCVbAQMjNTj7X9pBJHKuwQJ3rWTkT4li/ TKb20UnbFHKueU+hHNwVEeZoDSmmGVLJGaknY0qMdBufm7abR7x05hrln9NTT/6oRPAqqBpef9P eEOVafkRsRNQOfg== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.8 at phobos.denx.de X-Virus-Status: Clean Introduce support for a uclass to provide a fallback/stub driver which can be used when no device is found for a given node. This might be useful for handling non-essential clock controllers like the RPMh on Qualcomm platforms, or during early bringup to get UART output before a real clock driver has been created. Signed-off-by: Caleb Connolly --- drivers/core/Kconfig | 10 ++++++++++ drivers/core/uclass.c | 24 +++++++++++++++++++++++- include/dm/uclass.h | 3 +++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/drivers/core/Kconfig b/drivers/core/Kconfig index 1081d61fcf01..09075b9b7a15 100644 --- a/drivers/core/Kconfig +++ b/drivers/core/Kconfig @@ -466,5 +466,15 @@ config BOUNCE_BUFFER A second possible use of bounce buffers is their ability to provide aligned buffers for DMA operations. +menuconfig FALLBACK_DRIVERS + bool "Enable per-uclass fallback drivers" + depends on DM + help + If a driver requests a resource (like a clock) from a node which + isn't bound to a driver, the driver model will look for a fallback + driver to "stub" the resource. These stubs usually do nothing and + are therefore only suitable in instances where the resource is not + required. + endmenu diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c index e46d5717aa62..91d3a48d77b8 100644 --- a/drivers/core/uclass.c +++ b/drivers/core/uclass.c @@ -378,8 +378,26 @@ int uclass_find_device_by_of_offset(enum uclass_id id, int node, return -ENODEV; } +static int uclass_bind_fallback(struct uclass *uc, ofnode node, struct udevice **devp) +{ + struct driver *drv; + + log(LOGC_DM, LOGL_ERR, " - binding fallback '%s' driver '%s'\n", + uc->uc_drv->name, uc->uc_drv->fallback_drv_name); + + drv = lists_driver_lookup_name(uc->uc_drv->fallback_drv_name); + if (!drv) { + log(LOGC_DM, LOGL_DEBUG, " - Can't find stub driver '%s' for uclass '%s'\n", + uc->uc_drv->fallback_drv_name, uc->uc_drv->name); + return -ENOENT; + } + + return device_bind_with_driver_data(gd->dm_root, drv, + ofnode_get_name(node), 0, node, devp); +} + int uclass_find_device_by_ofnode(enum uclass_id id, ofnode node, struct udevice **devp) { struct uclass *uc; @@ -401,9 +419,13 @@ int uclass_find_device_by_ofnode(enum uclass_id id, ofnode node, *devp = dev; goto done; } } - ret = -ENODEV; + + if (CONFIG_IS_ENABLED(FALLBACK_DRIVERS) && uc->uc_drv->fallback_drv_name) + ret = uclass_bind_fallback(uc, node, devp); + else + ret = -ENODEV; done: log(LOGC_DM, LOGL_DEBUG, " - result for %s: %s (ret=%d)\n", ofnode_get_name(node), *devp ? (*devp)->name : "(none)", ret); diff --git a/include/dm/uclass.h b/include/dm/uclass.h index 456eef7f2f31..b99e36485bc5 100644 --- a/include/dm/uclass.h +++ b/include/dm/uclass.h @@ -67,8 +67,10 @@ struct udevice; * @child_pre_probe: Called before a child in this uclass is probed * @child_post_probe: Called after a child in this uclass is probed * @init: Called to set up the uclass * @destroy: Called to destroy the uclass + * @stub_drv_name: Name of a stub driver to use for devices that are not + * supported by any other driver. * @priv_auto: If non-zero this is the size of the private data * to be allocated in the uclass's ->priv pointer. If zero, then the uclass * driver is responsible for allocating any data required. * @per_device_auto: Each device can hold private data owned @@ -98,8 +100,9 @@ struct uclass_driver { int (*child_pre_probe)(struct udevice *dev); int (*child_post_probe)(struct udevice *dev); int (*init)(struct uclass *class); int (*destroy)(struct uclass *class); + const char *fallback_drv_name; int priv_auto; int per_device_auto; int per_device_plat_auto; int per_child_auto; From patchwork Wed Apr 10 17:06:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 1922159 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=k7E0Ennv; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VF8QR6zrsz1yYH for ; Thu, 11 Apr 2024 03:07:27 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EAF4887D8E; Wed, 10 Apr 2024 19:07:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.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=linaro.org header.i=@linaro.org header.b="k7E0Ennv"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CD22D87D8E; Wed, 10 Apr 2024 19:07:13 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C84B887861 for ; Wed, 10 Apr 2024 19:07:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-a4702457ccbso892714266b.3 for ; Wed, 10 Apr 2024 10:07:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712768831; x=1713373631; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=eVioKkTmCH1Nx0KyUgx1w3MclznpU3yEZ5FT6wVgby4=; b=k7E0EnnvGtVx+hrI+ubvN10Km6v2r0ZPN3/EofbY8DgwbkYN2GWcWolRjPVfmpV54o b2B1x6/a7MO9kOYgkwoPZdVb0qVoxDcHGAEI958egO+o632UVgD0Y/Q6E/w15svIIY9W GxWJ0A4HnVDoQNT+0ARvKtosznU+uZ3GxHpF+rExgY2U8qAtJAaN4MgJmMKa7wYsLSn7 EzFKtynCIBQ9IpESfKjZJ4Gd/AGaxDG2ssxB6DHGhoMvB16b1Y3ifI6lNCp9CILsHPCy CUO9XHG9tfaZ9UzbbbTKPTE94fWT/ucGpbAXHADiqnW/0dNlnG6TfMUom4MBmEsn3MD7 pMrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712768831; x=1713373631; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eVioKkTmCH1Nx0KyUgx1w3MclznpU3yEZ5FT6wVgby4=; b=HxPcgVytqJ3nq4McmpFJmtduQxHg0Vb4VT9BbO2GGHZr/HrINgQI0T2YPpf+6VfiEK K5fLeueY8zXxZ+tsFmEEmxXVrxFjjSXB3NyRe/DXAIsP5U6gHPdGdwKHLmsBeHLqPw81 fMOxo1K16XAr/9N/KRGGP3wvlbpHhOV/2387kauqCwbHYC+thnZmDRY3rSbFgj+ZnJ5D K9ujpygfYCBxceMHVUgSIuFhm5zRcc0rrgRfwPyZHxmEQ/y/vYBqqX7G5W8nrLxPjFbg G2X1fxbeYqpZLKRzFVkK6W77n0htE9kighfpjpvquaLIMGt4NkiJFnifmAdMIV14NM2u JR3g== X-Forwarded-Encrypted: i=1; AJvYcCX9/86YZOqs+MLOnr9odxKWLbH8XcAjdSHZhLlaSQdx++ZIdNtvLSu2B05Xsur+YWDJPdSKdjxQXbOBoA6xV1Nb9xdeFQ== X-Gm-Message-State: AOJu0YyfEU7EryR0m2lcYpKfZSZTmKxGzlvGTWWeKB8KOCJmvFkqiiwH Lm1KNQVMk6ZXFr+IUV1hrudmDch5jVb4lo3SxvlIcqiWATwAtROlTwxy2e7m0AA= X-Google-Smtp-Source: AGHT+IHvv1qXuVUIzrjS+woPEwlONEjpeOytx07Cg6GH3+kN1568bvmmFVricFG0MVTiGyHOJy6glQ== X-Received: by 2002:a17:906:f44:b0:a47:5182:3b83 with SMTP id h4-20020a1709060f4400b00a4751823b83mr1636475ejj.61.1712768831322; Wed, 10 Apr 2024 10:07:11 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::4716]) by smtp.gmail.com with ESMTPSA id fw14-20020a170906c94e00b00a51def4861bsm3331881ejb.91.2024.04.10.10.07.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 10:07:10 -0700 (PDT) From: Caleb Connolly Date: Wed, 10 Apr 2024 19:06:58 +0200 Subject: [PATCH 2/2] clk: introduce a fallback stub driver MIME-Version: 1.0 Message-Id: <20240410-b4-stub-drivers-v1-2-6935bd2c07d1@linaro.org> References: <20240410-b4-stub-drivers-v1-0-6935bd2c07d1@linaro.org> In-Reply-To: <20240410-b4-stub-drivers-v1-0-6935bd2c07d1@linaro.org> To: Simon Glass , Tom Rini , Lukasz Majewski , Sean Anderson Cc: Heinrich Schuchardt , Ilias Apalodimas , Neil Armstrong , Sumit Garg , u-boot-qcom@groups.io, u-boot@lists.denx.de, Caleb Connolly X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3815; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=tBzmh2+z4vL+U5q54pC35iQjh4TVM9yOxn7t7BbRAqs=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmFsc7fk2dJtS0lNtDTm1f5r74RQpDgRCdIx2Uv JpQ0DHxDu6JAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZhbHOwAKCRAFgzErGV9k tpPSD/kBTyY8/lr3PXTIFo6ch91RY1PNBfX5KPQhI4v9VRZLHwPF2BIsVhu9x8e5ztaD4zKXKaT qWLjyelCNiaqhxCsDcaFLK6owHRfGZYiiF28t2Ji6nKtO8rhktoVeW4pR5omgVyGIwWHmcd3cZK 0CJfOiRZA3herCXeh4cZII0liovc5hgYMF6UZCBQ3Npd/9eGOeX+tjASUjf2HLf9z3Zuh4KCPgK JNmEZLhsjaJJK/v8c2C0AU+o2N00swtWqfplXnVjV7O5SvieNdPEHOc8Ype5rOizT61Vdw1Sv13 PLBQVY0PnW2RfWiZoQO7Tehrizmww1UXo0ooDeUu/tIoKE3WwrFdKedw8FqZTaHPJdz4ND/aMg6 1VqQSp9i1u9IZueWpsjfHN1k3j8TRlVxqflWx1GhtLmO5LZsIWla816hSBXM+DkPOXcD0etmQ55 MZnz4SOZdIIlJDC0m1OIonS1d6/nVSdv7XKw/Z8XiI95V4DJVl/vrQaznZhCZUiMkM47x6glJL0 uBiLrpJSkxXl8Oi/aFL+LfFi1EqKYF5aEoMt+5CtET4+z0fNrAOIWSaS32+NTFwPgrFYIXNovP3 YwtVgWDDlU51R6J87kJj0pWZTpY2wWUNqrLDMO9HWEq7qfFW+3GiTofKd0qzdP3Fwgc7934w/As u9MWb25Z1Rbzcsw== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.8 at phobos.denx.de X-Virus-Status: Clean Add a stub_clk driver which does absolutely nothing and is configured as the fallback stub for UCLASS_CLK. If there is a dependency on a clock device which is not supported by any existing driver, and CONFIG_CLK_STUB is enabled, then the stub driver will kick in. This is intended to be useful during early bringup (e.g. if the serial port is already configured for a default rate) or for clock controllers that simply aren't vital for a platform to work. Signed-off-by: Caleb Connolly --- drivers/clk/Makefile | 1 + drivers/clk/clk-fallback.c | 39 +++++++++++++++++++++++++++++++++++++++ drivers/clk/clk-uclass.c | 4 ++++ drivers/core/Kconfig | 10 ++++++++++ 4 files changed, 54 insertions(+) diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile index 638ad04baeb0..dd57f2fd0397 100644 --- a/drivers/clk/Makefile +++ b/drivers/clk/Makefile @@ -4,8 +4,9 @@ # Wolfgang Denk, DENX Software Engineering, wd@denx.de. # obj-$(CONFIG_$(SPL_TPL_)CLK) += clk-uclass.o +obj-$(CONFIG_CLK_FALLBACK) += clk-fallback.o obj-$(CONFIG_$(SPL_TPL_)CLK) += clk_fixed_rate.o obj-$(CONFIG_$(SPL_TPL_)CLK) += clk_fixed_factor.o obj-$(CONFIG_$(SPL_TPL_)CLK_CCF) += clk.o clk-divider.o clk-mux.o clk-gate.o obj-$(CONFIG_$(SPL_TPL_)CLK_CCF) += clk-fixed-factor.o diff --git a/drivers/clk/clk-fallback.c b/drivers/clk/clk-fallback.c new file mode 100644 index 000000000000..f5733821e998 --- /dev/null +++ b/drivers/clk/clk-fallback.c @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2024 Linaro Ltd. + * + * Stub clock driver for non-vital clocks. + */ + +#include +#include +#include + +static ulong fallback_clk_set_rate(struct clk *clk, ulong rate) +{ + return (clk->rate = rate); +} + +static ulong fallback_clk_get_rate(struct clk *clk) +{ + return clk->rate; +} + +static int fallback_clk_nop(struct clk *clk) +{ + return 0; +}; + +static struct clk_ops fallback_clk_ops = { + .set_rate = fallback_clk_set_rate, + .get_rate = fallback_clk_get_rate, + .enable = fallback_clk_nop, + .disable = fallback_clk_nop, +}; + +U_BOOT_DRIVER(clk_fallback) = { + .name = "clk_fallback", + .id = UCLASS_CLK, + .ops = &fallback_clk_ops, + .flags = DM_FLAG_DEFAULT_PD_CTRL_OFF, +}; diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c index ed6e60bc4841..c0cdb3cf529c 100644 --- a/drivers/clk/clk-uclass.c +++ b/drivers/clk/clk-uclass.c @@ -11,8 +11,9 @@ #include #include #include #include +#include #include #include #include #include @@ -801,6 +802,9 @@ int clk_uclass_post_probe(struct udevice *dev) UCLASS_DRIVER(clk) = { .id = UCLASS_CLK, .name = "clk", +#if CONFIG_IS_ENABLED(CLK_FALLBACK) + .fallback_drv_name = "clk_fallback", +#endif .post_probe = clk_uclass_post_probe, }; diff --git a/drivers/core/Kconfig b/drivers/core/Kconfig index 09075b9b7a15..1cf78b4303ca 100644 --- a/drivers/core/Kconfig +++ b/drivers/core/Kconfig @@ -476,5 +476,15 @@ menuconfig FALLBACK_DRIVERS driver to "stub" the resource. These stubs usually do nothing and are therefore only suitable in instances where the resource is not required. +config CLK_FALLBACK + bool "Enable the clock fallback driver" + depends on FALLBACK_DRIVERS && CLK + help + This provides a no-op clock driver that can be used as a fallback + when no other driver is available. This is useful for systems with + clock controllers that are not actually required for peripherals to + work correctly (for example the RPMh clock controller on Qualcomm + platforms). + endmenu