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 EC6A1C433F5 for ; Thu, 6 Jan 2022 12:00:12 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7ABF183146; Thu, 6 Jan 2022 13:00:08 +0100 (CET) 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="ZVhI1oee"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3158C80F9C; Thu, 6 Jan 2022 13:00:04 +0100 (CET) Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) (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 B1D6482FD0 for ; Thu, 6 Jan 2022 12:59:58 +0100 (CET) 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-ed1-x52b.google.com with SMTP id f5so8508166edq.6 for ; Thu, 06 Jan 2022 03:59:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=QOBSX0JQ2uHa03D1RMT0G7LgaA3iSc0bPHMPvu1cS/o=; b=ZVhI1oee4fcfanaOGSgQAVE/+9w1Qfz3SaFUPkN+XtSkzHzGl8SoCADKMuCoU8VhFG XisXy3W6AYyeTnOAJnGKAMd8B883GiK9KRjhBFqJ8I4tOctSpuYTGmOSwqWVU7SvXYzL TumD5WEPFUONuDRFngQz066wsmDxtETx1GAUYp5MZ1ZKWrP0s2pM/CI3iFzltVDym3EN KEyDhQLqwpopk9jE7cXbxAs/lGnhi14KjRwgQNqzTrerTSvxrHnfAKaZt7cugDgDPQSB BMnYsSUvRSTPUgxc7GAkzY1iGWKZ0EQ6HPDeMN/Ks88WqShfXnnlHUP9e+t3KBJLNAqM 1SMw== 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:mime-version :content-transfer-encoding; bh=QOBSX0JQ2uHa03D1RMT0G7LgaA3iSc0bPHMPvu1cS/o=; b=dmVRFMfdhsC9/7xxVnXae7gSHpIrREcCDQpGNZSWLBFYKt8ZCDKwFSLiWUp5te21Ze VqUJmfyweHMpQ2on3QITI+qdHu3w2FAqiMkvb/gGUWL9v6KHP+QTpj5xKdcqTvovUNt+ g33xOsUl/u2aeMMii0PIOB5FMpyKGEh3BNEx4jBM2dlxdThnjJqE9XmdzBu4pC2EE4Qb KbPdIPFPyewSJL7eQ6ZEwjm0ENcOsOU8QCgl4oAUyodbzef/4dmSLVvrb/ngdY+YDQEJ ths/AepA+Yuye7YW2q8mKCdOYz5JfPaVdERs9dCM58Vm9grPtTMDf4LL582v1VqHSWPs Z+tQ== X-Gm-Message-State: AOAM530FeZbKOUi9XJ1rIu9AFYZmih1SwULRTBrLP8WfdEYkIPX/ZFfX Yl3j3dw9MS7rQsVE1OQC5bs= X-Google-Smtp-Source: ABdhPJwieuL3b8YYzBtpuprMZiMwFM+BuTSKwGC0nGmeAQHbFw8a4pqNnxuo8WsWR3fjUNhmCw5NIg== X-Received: by 2002:aa7:d4d9:: with SMTP id t25mr2145779edr.298.1641470398372; Thu, 06 Jan 2022 03:59:58 -0800 (PST) Received: from debian.home (81-204-249-205.fixed.kpn.net. [81.204.249.205]) by smtp.gmail.com with ESMTPSA id ds1sm442234ejc.97.2022.01.06.03.59.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 03:59:57 -0800 (PST) From: Johan Jonker To: kever.yang@rock-chips.com Cc: sjg@chromium.org, philipp.tomsich@vrull.eu, marex@denx.de, u-boot@lists.denx.de Subject: [PATCH v3 1/2] rockchip: timer: add OF_PLATDATA support for dw-apb-timer Date: Thu, 6 Jan 2022 12:59:49 +0100 Message-Id: <20220106115950.2132-1-jbx6244@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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 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 --- 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 9aed5dd2..f7226979 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