From patchwork Thu Feb 21 21:43:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Goldschmidt X-Patchwork-Id: 1046466 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) 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="De336kzO"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4457Mm6YT8z9s2R for ; Fri, 22 Feb 2019 08:46:28 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 7232DC21F3E; Thu, 21 Feb 2019 21:45:10 +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, 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 774CEC21F82; Thu, 21 Feb 2019 21:43:56 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 3D059C21F51; Thu, 21 Feb 2019 21:43:49 +0000 (UTC) Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by lists.denx.de (Postfix) with ESMTPS id 09AF8C21F53 for ; Thu, 21 Feb 2019 21:43:46 +0000 (UTC) Received: by mail-wm1-f66.google.com with SMTP id z84so106522wmg.4 for ; Thu, 21 Feb 2019 13:43:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dGvmOqGdTHuZNYwumBpTg5PwfdplIkmuysPEC1cwVIc=; b=De336kzOH7nlj0iXpfmTZk7BbHVV6T+Js/JsM9fRBuCBFc3eaBTFYqJETcfPsMiAyA y8Dqr3MRzxagvXB3R1HL7X2K24TgWzQXv1hbrfb6UXvsqaCsG9Zd1E1e8/pzDCaXEeJh if3zbWEUj7om1cLExSje4zABiY73N0aTgBrwm+74PKU5DnoFlDbBAwuv97HcV1F6mYdA tCvtkLMcrlWaE4iD8iJf0+On6pf5zLlx/U6Hbzsqfk4hMZ9Hz5AA7A6QhX6zEDf0tGSf WdVUZ2Ze2rl1iUV60IhYYKPBJ9wkY/VmPoeJM7AUYjzEerlkXRaE6qkt998UwiF8+lYd UhJA== 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:in-reply-to :references; bh=dGvmOqGdTHuZNYwumBpTg5PwfdplIkmuysPEC1cwVIc=; b=hN9EpQRnYAG8DdIGS+aKr4sOzVV1VoMWsqpZxWjoQGTbg4M6PjrVsNzDv77ypcGgrA e7sA4Ce5CIT4lFIeHRXCv9rDQU/bFNbmUybj2TaEEGCNsviqEWASvF3dzE2kAhPN/kl5 7XGMzsILhPVInXb9wV3t9cZJvvKZAIpxpRS5qsWiOnlF+0aoTyI9HE6Los4O9CemBtYU izdTfSYXhZHfiOGQKMwvClwBodSiMJnJA4bvkfP0kpMQwjHq++ZEmxHFNYIewmByVqcX 2StwoVzgy5uwNXtiW2kRUaBJChTxU99TyV1YkI+5fsFBlHW2ZWsPDOMKY8R3Stdhspb1 Czfg== X-Gm-Message-State: AHQUAuaiqQ2LWW9yrml57BdAcBBjwqn86OfjrYWTnHJYUMRzvv8UI/2P vmlBg5A7pcM5KMJQ3UScy/s= X-Google-Smtp-Source: AHgI3IasikxPB7Y2698WTAU4s6Py2ORkCLhkLf+/19qTbK5gGGYkLEgp/pvHd+oe5KsF9nSM4+jfGA== X-Received: by 2002:a1c:4844:: with SMTP id v65mr381171wma.66.1550785425749; Thu, 21 Feb 2019 13:43:45 -0800 (PST) Received: from ubuntu.home ([2a02:8071:6a3:700:9065:254c:ff38:3288]) by smtp.gmail.com with ESMTPSA id m26sm4308wmg.13.2019.02.21.13.43.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 13:43:45 -0800 (PST) From: Simon Goldschmidt To: Marek Vasut , u-boot@lists.denx.de Date: Thu, 21 Feb 2019 22:43:30 +0100 Message-Id: <20190221214332.4246-7-simon.k.r.goldschmidt@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190221214332.4246-1-simon.k.r.goldschmidt@gmail.com> References: <20190221214332.4246-1-simon.k.r.goldschmidt@gmail.com> Subject: [U-Boot] [PATCH v2 6/8] reset: socfpga: add reset handling for old kernels 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This adds code to take peripherals out of reset based on an environment variable. This is in preparation for removing the code that does this from SPL. However, some drivers even in current Linux cannot handle peripheral reset, so until this works, we need a compatibility workaround. This workaround is implemented in the 'remove' callback of this reset driver, which is called on OS_PREPARE: it checks if the environment variable "socfpga_permodrst_ungate" - if it is set to 1, it deasserts all peripheral resets, which is what the gen5 SPL did up to now. This is in preparation to clean up the SPL and implementing proper reset handling for U-Boot. Signed-off-by: Simon Goldschmidt --- Changes in v2: - moved from Kernel option "OLD_SOCFPGA_KERNEL_COMPAT" to environment variable "socfpga_permodrst_ungate" drivers/reset/reset-socfpga.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/reset/reset-socfpga.c b/drivers/reset/reset-socfpga.c index b2acfcd2ec..749f671e05 100644 --- a/drivers/reset/reset-socfpga.c +++ b/drivers/reset/reset-socfpga.c @@ -89,6 +89,36 @@ static int socfpga_reset_probe(struct udevice *dev) return 0; } +#ifndef CONFIG_SPL_BUILD +/* + * This remove function is called before starting OS to deassert peripheral + * resets for Kernels that don't support this. + * + * The reset driver checks the environment variable "socfpga_permodrst_ungate" + * when it is removed. If this variable is '1', all peripherals in 'permodrst' + * are taken out of reset before booting into the OS. + * This should be required for gen5 systems only that are running Linux kernels + * without proper peripheral reset support for all drivers used. + */ +static int socfpga_reset_remove(struct udevice *dev) +{ + struct socfpga_reset_data *data = dev_get_priv(dev); + const char *env_str; + long val; + + env_str = env_get("socfpga_permodrst_ungate"); + if (env_str) { + val = simple_strtol(env_str, NULL, 0); + if (val == 1) { + puts("Deasserting all peripheral resets\n"); + writel(0, data->membase + 4); + } + } + + return 0; +} +#endif + static const struct udevice_id socfpga_reset_match[] = { { .compatible = "altr,rst-mgr" }, { /* sentinel */ }, @@ -101,4 +131,8 @@ U_BOOT_DRIVER(socfpga_reset) = { .probe = socfpga_reset_probe, .priv_auto_alloc_size = sizeof(struct socfpga_reset_data), .ops = &socfpga_reset_ops, +#ifndef CONFIG_SPL_BUILD + .remove = socfpga_reset_remove, + .flags = DM_FLAG_OS_PREPARE, +#endif };