Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 7239EC433EF for ; Sun, 3 Apr 2022 23:08:51 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8F8BF83C67; Mon, 4 Apr 2022 01:08:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com 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=gmail.com header.i=@gmail.com header.b="aKcAyZpy"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1619983C06; Mon, 4 Apr 2022 01:07:21 +0200 (CEST) Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) (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 29FFA81D5A for ; Mon, 4 Apr 2022 01:07:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jbx6244@gmail.com Received: by mail-ej1-x630.google.com with SMTP id k23so13033755ejd.3 for ; Sun, 03 Apr 2022 16:07:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LMyHsywWeDZ0IpQdXgBcLdvABFXedCLYfK6i541cYbM=; b=aKcAyZpyNQqx5+2uQRlAJ3RPBm7NVIJQU3flzK14b5APtFOCwB1BmiDU6kMGAyOLJu ZoLR5leqfIbadxjfTEFrwQ2h5tzHbdwBpzxhMVoKrTrbPdcrfc4i0MjmkrIV9V3vvT+j xGB3f7s44DmfBwSTzo7U/O88KFosqw8N71ceJ7wiLnIpmqfuZM+ksdIfyEwClRaZPG2Z itDyy6j8ZP1shd09S+e5FOh0v50CcAv3C+Q2qPrvn1B0jC6vJRP3NpDs8nPuGvRgE9F1 UlbwVte0g8vVMMuJcN8143/VYnfQIDOSpuIxm+H7aNsfh7Uc5k9FNfh0y5dZuOIzPLq5 ITkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LMyHsywWeDZ0IpQdXgBcLdvABFXedCLYfK6i541cYbM=; b=JZpVB1zKsOnQwnas8u55ZpJ4Ug1p5uwrxByZ0/TNQxrF4dXHrw0ljZV5bCx2qcFFgF 4rznjC+4DTTYsALitXqrOk1FfTuPJTb59VU7NZ2sm9QE/1e9Co/HsgK1QZkr6RpxNzcu XDXkR7lsl4V+AMstySaV8CP7TCJBTkggOFJGoCOMtO/l+jv012cj5w35X4l5XsKwWVYJ oXS/Q4iyKMsvFs1qy+LHqG126FR+pSifTkSJsaPYPI3MUaEWk2FOZHgerfr/P5eB4+41 Me3/CzYZY1DKpWbLtk0gtskrwBc5HD780D0V6I91aO+H59w15RpMB2W7BWTgSHCwhBIn SOCg== X-Gm-Message-State: AOAM531byjxunXKA8wxzJBpNYrLMGJ1EAYRsoyuOnXMdSmeE4deD2iyt 2UivkXRN/Qr573n6V+rvNSo= X-Google-Smtp-Source: ABdhPJwmvNLaqi8xugf1rynGu/bJL17jJ3mW93/nGuzTW97dpHf4foqt99Nm1Qz8P/4mpaQ8K8JLPg== X-Received: by 2002:a17:906:730c:b0:6e6:c512:49c8 with SMTP id di12-20020a170906730c00b006e6c51249c8mr6178359ejc.405.1649027229750; Sun, 03 Apr 2022 16:07:09 -0700 (PDT) Received: from debian.home (81-204-249-205.fixed.kpn.net. [81.204.249.205]) by smtp.gmail.com with ESMTPSA id c14-20020a170906340e00b006ce98f2581asm3645597ejb.205.2022.04.03.16.07.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Apr 2022 16:07:09 -0700 (PDT) From: Johan Jonker To: kever.yang@rock-chips.com Cc: sjg@chromium.org, philipp.tomsich@vrull.eu, heiko@sntech.de, peng.fan@nxp.com, jh80.chung@samsung.com, u-boot@lists.denx.de Subject: [PATCH v4 06/12] rockchip: timer: add OF_PLATDATA support for dw-apb-timer Date: Mon, 4 Apr 2022 01:06:53 +0200 Message-Id: <20220403230659.12039-7-jbx6244@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220403230659.12039-1-jbx6244@gmail.com> References: <20220403230659.12039-1-jbx6244@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.5 at phobos.denx.de X-Virus-Status: Clean The Rockchip rk3066 SoC has 3 dw-apb-timer nodes. U-boot is compiled with OF_PLATDATA TPL/SPL options, so add OF_PLATDATA support for the dw-apb-timer. Also change driver name to be able to compile with U-boot scripts. No reset OF_PLATDATA support was added, because the rk3066 nodes don't need/have them. Signed-off-by: Johan Jonker Reviewed-by: Simon Glass --- Changed V3: use if (CONFIG_IS_ENABLED(OF_REAL)) remove white space fix Changed V2: use #if CONFIG_IS_ENABLED(OF_REAL) --- drivers/timer/dw-apb-timer.c | 50 ++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/drivers/timer/dw-apb-timer.c b/drivers/timer/dw-apb-timer.c index 9aed5dd217..f722697934 100644 --- a/drivers/timer/dw-apb-timer.c +++ b/drivers/timer/dw-apb-timer.c @@ -8,10 +8,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include @@ -25,6 +27,12 @@ struct dw_apb_timer_priv { struct reset_ctl_bulk resets; }; +struct dw_apb_timer_plat { +#if CONFIG_IS_ENABLED(OF_PLATDATA) + struct dtd_snps_dw_apb_timer dtplat; +#endif +}; + static u64 dw_apb_timer_get_count(struct udevice *dev) { struct dw_apb_timer_priv *priv = dev_get_priv(dev); @@ -43,20 +51,33 @@ static int dw_apb_timer_probe(struct udevice *dev) struct dw_apb_timer_priv *priv = dev_get_priv(dev); struct clk clk; int ret; +#if CONFIG_IS_ENABLED(OF_PLATDATA) + struct dw_apb_timer_plat *plat = dev_get_plat(dev); + struct dtd_snps_dw_apb_timer *dtplat = &plat->dtplat; - ret = reset_get_bulk(dev, &priv->resets); - if (ret) - dev_warn(dev, "Can't get reset: %d\n", ret); - else - reset_deassert_bulk(&priv->resets); + priv->regs = dtplat->reg[0]; - ret = clk_get_by_index(dev, 0, &clk); - if (ret) + ret = clk_get_by_phandle(dev, &dtplat->clocks[0], &clk); + if (ret < 0) return ret; - uc_priv->clock_rate = clk_get_rate(&clk); + uc_priv->clock_rate = dtplat->clock_frequency; +#endif + if (CONFIG_IS_ENABLED(OF_REAL)) { + ret = reset_get_bulk(dev, &priv->resets); + if (ret) + dev_warn(dev, "Can't get reset: %d\n", ret); + else + reset_deassert_bulk(&priv->resets); + + ret = clk_get_by_index(dev, 0, &clk); + if (ret) + return ret; - clk_free(&clk); + uc_priv->clock_rate = clk_get_rate(&clk); + + clk_free(&clk); + } /* init timer */ writel(0xffffffff, priv->regs + DW_APB_LOAD_VAL); @@ -68,9 +89,11 @@ static int dw_apb_timer_probe(struct udevice *dev) static int dw_apb_timer_of_to_plat(struct udevice *dev) { - struct dw_apb_timer_priv *priv = dev_get_priv(dev); + if (CONFIG_IS_ENABLED(OF_REAL)) { + struct dw_apb_timer_priv *priv = dev_get_priv(dev); - priv->regs = dev_read_addr(dev); + priv->regs = dev_read_addr(dev); + } return 0; } @@ -91,8 +114,8 @@ static const struct udevice_id dw_apb_timer_ids[] = { {} }; -U_BOOT_DRIVER(dw_apb_timer) = { - .name = "dw_apb_timer", +U_BOOT_DRIVER(snps_dw_apb_timer) = { + .name = "snps_dw_apb_timer", .id = UCLASS_TIMER, .ops = &dw_apb_timer_ops, .probe = dw_apb_timer_probe, @@ -100,4 +123,5 @@ U_BOOT_DRIVER(dw_apb_timer) = { .of_to_plat = dw_apb_timer_of_to_plat, .remove = dw_apb_timer_remove, .priv_auto = sizeof(struct dw_apb_timer_priv), + .plat_auto = sizeof(struct dw_apb_timer_plat), }; -- 2.20.1