From patchwork Wed Oct 23 20:23:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Goldschmidt X-Patchwork-Id: 1182467 X-Patchwork-Delegate: simon.k.r.goldschmidt@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="cw9m9I/1"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46z1zM0nWfz9sP6 for ; Thu, 24 Oct 2019 07:23:26 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id A6945C21E1E; Wed, 23 Oct 2019 20:23:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 11458C21D8A; Wed, 23 Oct 2019 20:23:21 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 4C7F5C21D8A; Wed, 23 Oct 2019 20:23:20 +0000 (UTC) Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by lists.denx.de (Postfix) with ESMTPS id D2A7BC21C27 for ; Wed, 23 Oct 2019 20:23:19 +0000 (UTC) Received: by mail-wm1-f67.google.com with SMTP id i13so315502wmd.3 for ; Wed, 23 Oct 2019 13:23:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=AB3bcwqFiORvK3BGP7tbx8yEdgXIUqgKUKzLd9fT3I0=; b=cw9m9I/1jLjJfMmVZdBpwrg4shA1XLQ5LKk+2DFoZk7m3zYP+wOdMzhxxQsW4in7vS AGVj09psKdLoINbL3enl6tToshuBddE5VRN/RhOYxTfd1G2BEUN0TocV2OGfOst/Knd/ NOE0mQg0ZwTu6YMu6PpMT9f5JCMStEvyTKGX3tH6f70DADuyazXtHFRzdze0W+mKxqLC oPyv1aZfNlv7EHJDDdiDdeg0XGCA7qzMKMBXDlS4xmbE4jP/scpauvVso+nZ9gyX6I0F IrO7GhLW7SHMAH7lL+CoDEuo8AdkiHgNbIRL7sGAI0eKzSlyOP7GR6iZCdVo5Wuy+Kdb V9Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=AB3bcwqFiORvK3BGP7tbx8yEdgXIUqgKUKzLd9fT3I0=; b=RYzy2ClGCOyGggKs8xPy4lJnEZUlcodnYFXtLWwS7cpfikBEsR3VZAxn6+zD+uaUq4 5E8QUQNGfBf6ssVa5MTnevgIw4opcYHmH98U1OKIGWqGhZPP15xb8O8Qs1hGoggzGPXJ jK/sZ9nmaaPnHQcYOiJY7yrK9queOoVug8ZUNP7e65xDedzS/DQSjgoYzoZsofV7wZF1 qjBIskZubNyWy02CJmqQVbYCLNjYexIxCzYqTAj4MXBJoO3+4nAgmt684g5vxMOCa1cm L7yGpELeQ2vg17lvz5Rkg/M0JbfIUqWyfMSuKNKsMme5MKGjROuiuAWu2rpq3ybV5Dg/ HdxA== X-Gm-Message-State: APjAAAUKc6TBRk3TwdY0Hq96ZjCDkLZ6QQ6zmLW+47louKK738wsiY/7 egNFdAIphEDRvMxoyZGVwZ0= X-Google-Smtp-Source: APXvYqxMmhQ9AO+ouJlJ5BZ0ry4qBRcgqWvIe6lW7narZqX9qXseP3ocRq93b8j442OEbKGXkQrIUA== X-Received: by 2002:a05:600c:294b:: with SMTP id n11mr1499646wmd.70.1571862199474; Wed, 23 Oct 2019 13:23:19 -0700 (PDT) Received: from ubuntu.home ([2a02:8071:6a3:700:50e:1b2d:a4c8:d388]) by smtp.gmail.com with ESMTPSA id g69sm223049wme.31.2019.10.23.13.23.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 13:23:18 -0700 (PDT) From: Simon Goldschmidt To: Marek Vasut Date: Wed, 23 Oct 2019 22:23:12 +0200 Message-Id: <20191023202312.32744-1-simon.k.r.goldschmidt@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH] timer: dw-apb: add reset handling X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" To use this DM timer on socfpga as system tick, it needs to take itself out of reset. Signed-off-by: Simon Goldschmidt --- drivers/timer/dw-apb-timer.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/timer/dw-apb-timer.c b/drivers/timer/dw-apb-timer.c index 86312b8dc7..fad22be8c9 100644 --- a/drivers/timer/dw-apb-timer.c +++ b/drivers/timer/dw-apb-timer.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -18,7 +19,8 @@ #define DW_APB_CTRL 0x8 struct dw_apb_timer_priv { - fdt_addr_t regs; + fdt_addr_t regs; + struct reset_ctl_bulk resets; }; static int dw_apb_timer_get_count(struct udevice *dev, u64 *count) @@ -42,6 +44,12 @@ static int dw_apb_timer_probe(struct udevice *dev) struct clk clk; int ret; + 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; @@ -67,6 +75,13 @@ static int dw_apb_timer_ofdata_to_platdata(struct udevice *dev) return 0; } +static int dw_apb_timer_remove(struct udevice *dev) +{ + struct dw_apb_timer_priv *priv = dev_get_priv(dev); + + return reset_release_bulk(&priv->resets); +} + static const struct timer_ops dw_apb_timer_ops = { .get_count = dw_apb_timer_get_count, }; @@ -83,5 +98,6 @@ U_BOOT_DRIVER(dw_apb_timer) = { .probe = dw_apb_timer_probe, .of_match = dw_apb_timer_ids, .ofdata_to_platdata = dw_apb_timer_ofdata_to_platdata, + .remove = dw_apb_timer_remove, .priv_auto_alloc_size = sizeof(struct dw_apb_timer_priv), };