From mboxrd@z Thu Jan 1 00:00:00 1970 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 20F5CC433F5 for ; Sat, 9 Apr 2022 16:56:48 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EA95183DB7; Sat, 9 Apr 2022 18:55:59 +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="djo5uAAJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 228AC83DA3; Sat, 9 Apr 2022 18:55:37 +0200 (CEST) Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) (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 9900C83A97 for ; Sat, 9 Apr 2022 18:55:29 +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-x635.google.com with SMTP id bh17so22946732ejb.8 for ; Sat, 09 Apr 2022 09:55:29 -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=ct5CXwtg7VpoGCafqP7uJh1v+ZfOF43c8bZObIGtNzM=; b=djo5uAAJUzga3/0+IweKnaQaKV5frb5a5XxEmcIZdHMSDvWD9I9ZY9Yy5p2gmB+x5I 3VuL7wcgC5TmpCdGPQjs758EM9aBJpRXh/ZGTsyKUQiLTeaa6w1/eRVh9lDpL4/5DLxH 3VIUrRrx2sHVkTr13nwBKbe+VBZQrtVhQfGJZcqVbi8TXUnZxw6241VhSjUry9Sr8adD c9LnuOuB2WUByBh9WEWoJWwfJyzsVIwBVSWV2eakPkpB2GaJBay6rtGOWn9H/54plTFS BLbqf/6badylAPtQG1Tj03vE7SRRbGWdbXmgkIBCcteGCXYa1ZPqk0tNwq2eltJVvqCE w80A== 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=ct5CXwtg7VpoGCafqP7uJh1v+ZfOF43c8bZObIGtNzM=; b=lh07ZOMJrMIwOBtJt/qAz9T4tuS1fZ5CJ8kkTic/lMbNUaq5eIxdS61dIrIwFZtMDm 0DZ2SXVVB6L6/0rC1+1UKGkcFRsSrv7UktwaY1RF6OfJQ0QTmBFf+qPAU9qcifbq+pZO EuIhuQui0EmOi97QMR0CLzKHCH8UDIsnQVkhQ3wXpRIpDdL9IYuY+Jt6a8I76gad5jos wz0Hf6CekHQZM8VtF2ynqe8lWR5uJFHdRgXjDBW2VSBueWLIUDARsXS1Iu8lqcPsZays Ge7l6eqvPddV9tjlREgtqwyKow9wgTKle1nclmVXjrB4ryV9USY5COU5loJis/oJXWsO zCAA== X-Gm-Message-State: AOAM530Lep+n0r5itW9xHjkdDK8sGpqhv1rXCwg6rrXRYOKgJ9GFcIH0 WEYbCtXzSIH+4owCLSon+RU8z4orH+EeTA== X-Google-Smtp-Source: ABdhPJydeiXHVTMl2FXWYAY9SV9wH6PRUO4v55RYKDvON3C8qBMR5KfB7m/bwe1gxVM3hICyUhcEsQ== X-Received: by 2002:a17:907:9720:b0:6e8:3613:6224 with SMTP id jg32-20020a170907972000b006e836136224mr12824430ejc.421.1649523329213; Sat, 09 Apr 2022 09:55:29 -0700 (PDT) Received: from debian.home (81-204-249-205.fixed.kpn.net. [81.204.249.205]) by smtp.gmail.com with ESMTPSA id t14-20020a170906608e00b006d1455acc62sm10004538ejj.74.2022.04.09.09.55.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Apr 2022 09:55:28 -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 v5 05/13] rockchip: timer: add OF_PLATDATA support for dw-apb-timer Date: Sat, 9 Apr 2022 18:55:06 +0200 Message-Id: <20220409165514.19220-6-jbx6244@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220409165514.19220-1-jbx6244@gmail.com> References: <20220409165514.19220-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 Reviewed-by: Kever Yang --- 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