From patchwork Fri Jul 13 09:15:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 943372 X-Patchwork-Delegate: sjg@chromium.org 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=none (p=none dis=none) header.from=xilinx.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.b="YY1IAbRD"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41RnH35NBQz9s2M for ; Fri, 13 Jul 2018 19:16:14 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 123F3C21F35; Fri, 13 Jul 2018 09:15:58 +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=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 CD92DC21FE4; Fri, 13 Jul 2018 09:15:54 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 02F56C22009; Fri, 13 Jul 2018 09:15:12 +0000 (UTC) Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by lists.denx.de (Postfix) with ESMTPS id EBF83C21F35 for ; Fri, 13 Jul 2018 09:15:11 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id j5-v6so17845720wrr.8 for ; Fri, 13 Jul 2018 02:15:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id; bh=cZMu7HwZ2I6d7M3bYMN5tG0noMXHgBTV5TC6MvmCjTc=; b=YY1IAbRDh+jpfbc4U5iI1WtrjEuIcd7IYdZuq3LSMrFbzVwSafyKS4/wTXlRNQFZpG m4vyqb8aEVKl+NUBgmAHgP28yZB/eyvEAukoHQHzrtqJo5mF4H3bmNt7u8sdmmVhS/rw UaZx2ALGj0hT0Ao3FoH62V5RrNmOI3HVcqxzRSSswGcRxhNVHEMDtJbhrkKQY9rFqJIo lshP/zI/eiRprY2DEhbk++KzKJkONxt758H+oGwxRLMYo+KkMDxM53io4OHWH4XbFqY6 EBcraCzVLrVDstoMJtKAN7y2fOwRCv7yxaGRRQhH8WMaipYfclQcSokWriaU3OAyyOh6 Jrgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=cZMu7HwZ2I6d7M3bYMN5tG0noMXHgBTV5TC6MvmCjTc=; b=tnH3Xm3XVgYeENwGz4kTIM0I0U4166UhVrwz9CwLm8idjvax7ttrYQnnR78+XOrvlS ZWz7VdlU4vUt1DeaDVoOwpv8MYjzyizNszl6E0TlYKQDccZXvsogYHypL2UCho+O6elJ 8u3Sb6rS+ktwJk5PsXxJWkMVAvyn09bQPc6k9hOGx/DA9BBIQ1t9NcgLmqMS8DT4jjLX GWLAuhrwdVrco8ZlRDQnKXR09jAeoBGgaxhcsgZX1SxIuj32aWWuw1NY2A1K5/+iXk3F 27IVaopmWzKhRq4hUZerYWFkJsyoRTuD1+fnPelcEzmvwJlt+GUy1RtNF/Z5QysOr0cm AkQg== X-Gm-Message-State: AOUpUlFjVsnztpYjA+fQET5IzY7SybrN1tvR5QetAsz1vDshK9JRxGV+ noJ5EeT6veT7SstmqpUKD5vM3D+Q X-Google-Smtp-Source: AAOMgpfH9p+jrElpfGEPfUVGDZm/VqXGPiDQMnUxViFXbJDLW3vGjPQY7qT1aTtg1nq00tmlz6AIjw== X-Received: by 2002:a5d:4b50:: with SMTP id w16-v6mr4208106wrs.87.1531473311408; Fri, 13 Jul 2018 02:15:11 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id 64-v6sm16065861wrj.50.2018.07.13.02.15.10 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 13 Jul 2018 02:15:10 -0700 (PDT) From: Michal Simek To: u-boot@lists.denx.de Date: Fri, 13 Jul 2018 11:15:07 +0200 Message-Id: <95aa37ae30807f8363a3d238883cee49f289fe4c.1531473305.git.michal.simek@xilinx.com> X-Mailer: git-send-email 1.9.1 Cc: Jorge Ramirez-Ortiz Subject: [U-Boot] [PATCH] sysreset: Add support for gpio-restart 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" The Linux kernel has binding for gpio-restart node. This patch is adding basic support without supporting any optional properties. This driver was tested on Microblaze system where gpio is connected to SoC reset logic. Output value is handled via gpios cells values. In gpio_reboot_request() set_value is writing 1 because dm_gpio_set_value() is capable to changing it when it is ACTIVE_LOW. ... if (desc->flags & GPIOD_ACTIVE_LOW) value = !value; ... Signed-off-by: Michal Simek Reviewed-by: Philipp Tomsich Reviewed-by: Simon Glass --- drivers/sysreset/Kconfig | 6 ++++ drivers/sysreset/Makefile | 1 + drivers/sysreset/sysreset_gpio.c | 59 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 drivers/sysreset/sysreset_gpio.c diff --git a/drivers/sysreset/Kconfig b/drivers/sysreset/Kconfig index a6d48e8a662c..1e228b97443a 100644 --- a/drivers/sysreset/Kconfig +++ b/drivers/sysreset/Kconfig @@ -15,6 +15,12 @@ config SYSRESET if SYSRESET +config SYSRESET_GPIO + bool "Enable support for GPIO restart driver" + select GPIO + help + Restart support via GPIO pin connected reset logic. + config SYSRESET_PSCI bool "Enable support for PSCI System Reset" depends on ARM_PSCI_FW diff --git a/drivers/sysreset/Makefile b/drivers/sysreset/Makefile index 0da58a1cf6ad..ca533cfefaad 100644 --- a/drivers/sysreset/Makefile +++ b/drivers/sysreset/Makefile @@ -3,6 +3,7 @@ # (C) Copyright 2016 Cadence Design Systems Inc. obj-$(CONFIG_SYSRESET) += sysreset-uclass.o +obj-$(CONFIG_SYSRESET_GPIO) += sysreset_gpio.o obj-$(CONFIG_SYSRESET_PSCI) += sysreset_psci.o obj-$(CONFIG_SYSRESET_SYSCON) += sysreset_syscon.o obj-$(CONFIG_SYSRESET_WATCHDOG) += sysreset_watchdog.o diff --git a/drivers/sysreset/sysreset_gpio.c b/drivers/sysreset/sysreset_gpio.c new file mode 100644 index 000000000000..4c1c1510f285 --- /dev/null +++ b/drivers/sysreset/sysreset_gpio.c @@ -0,0 +1,59 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2018 Xilinx, Inc. - Michal Simek + */ + +#include +#include +#include +#include +#include + +struct gpio_reboot_priv { + struct gpio_desc gpio; +}; + +static int gpio_reboot_request(struct udevice *dev, enum sysreset_t type) +{ + struct gpio_reboot_priv *priv = dev_get_priv(dev); + + /* + * When debug log is enabled please make sure that chars won't end up + * in output fifo. Or you can append udelay(); to get enough time + * to HW to emit output fifo. + */ + debug("GPIO restart\n"); + + /* 1 is just setting value - based on gpio->flags 0 or 1 is written */ + return dm_gpio_set_value(&priv->gpio, 1); +} + +static struct sysreset_ops gpio_reboot_ops = { + .request = gpio_reboot_request, +}; + +int gpio_reboot_probe(struct udevice *dev) +{ + struct gpio_reboot_priv *priv = dev_get_priv(dev); + + /* + * Linux kernel DT binding contain others optional properties + * which are not supported now + */ + + return gpio_request_by_name(dev, "gpios", 0, &priv->gpio, GPIOD_IS_OUT); +} + +static const struct udevice_id led_gpio_ids[] = { + { .compatible = "gpio-restart" }, + { } +}; + +U_BOOT_DRIVER(gpio_reboot) = { + .id = UCLASS_SYSRESET, + .name = "gpio_restart", + .of_match = led_gpio_ids, + .ops = &gpio_reboot_ops, + .priv_auto_alloc_size = sizeof(struct gpio_reboot_priv), + .probe = gpio_reboot_probe, +};