Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp610164ybg; Fri, 12 Jun 2020 09:50:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmHzqtNyKHj2A0mWrBOAqt1C6TUGwd9FU1wys/yuUtssP3qfZqWgtoKT51lxAPN4nz1TsK X-Received: by 2002:a17:906:1804:: with SMTP id v4mr13670178eje.104.1591980647846; Fri, 12 Jun 2020 09:50:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591980647; cv=none; d=google.com; s=arc-20160816; b=gktWN4h/Zr7mjdb85RfJ4cJvUwAahPVTyI3CUKzcHTAaTyqSJglK7shASd/yul7y1T wbyC+HDdOBZb5a8RyB95fqI2SFein6XmOxQmlxRwOhJhEa55EnfsYT3eJX+364KBxUPi NTWaELEMCyNVKzcYIw18YFQaIjdOECBclmxfzKFWC9UC4pqF51GiZ2A8UP2qzlrkKhCL Q211l1vS0AujeI7sAFKJbRtEUrGXgAga5+zeXr4KpemOc0I+L0U5zKc/5ncsEU4Y8dK6 sDS1HR6mZ1ZRpIT4r8mfOu2l1azPaBztzSWsOG9ild0LtDe/ygW9d5+U6vkHACXIqRhT qhHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=D9l0pPjE2lFu9VW6N+EJgYeT9GVvRDA8md7+4wp1Cmo=; b=Ff8FSssLKQSdpNRyvWvynE8JboLJdRqhwnpkePQC4xprgUttRMpqaEvCb2GfZONYPU AUwbWeqzVeNElphyGE8k+K5lsFM8s5lBppjePGEUTcxDRBliOWKBdUxKyNLq7n37kldy YF3crRL4j1H1irhLDJ7aVSjj16i3Cy7pUX0MIuovPiADVBTK0uBfJgBkuiILAyYzlHny VWHDcEFEgWJOwTvbtsfTiv/7VYH93AyblFpkPI8oE8SPk/hq0+agLYTcZMCyf+XaWiwt +BvL3fROmvaLxAqPqLeB+6YeoIhmoOUSOV+wD5MsSltW1M0xDaHRj+xU2wJglG59dA3z Dzuw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y1si4101314ejq.726.2020.06.12.09.50.25; Fri, 12 Jun 2020 09:50:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726414AbgFLQrh (ORCPT + 99 others); Fri, 12 Jun 2020 12:47:37 -0400 Received: from mx2.suse.de ([195.135.220.15]:59026 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726085AbgFLQr0 (ORCPT ); Fri, 12 Jun 2020 12:47:26 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 7CEA1AAD0; Fri, 12 Jun 2020 16:47:27 +0000 (UTC) From: Nicolas Saenz Julienne To: mbrugger@suse.com, u-boot@lists.denx.de, bmeng.cn@gmail.com, marex@denx.de, linux-kernel@vger.kernel.org Cc: sjg@chromium.org, m.szyprowski@samsung.com, s.nawrocki@samsung.com, mark.kettenis@xs4all.nl, Nicolas Saenz Julienne Subject: [PATCH v4 2/5] reset: Add Raspberry Pi 4 firmware reset controller Date: Fri, 12 Jun 2020 18:46:30 +0200 Message-Id: <20200612164632.25648-3-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200612164632.25648-1-nsaenzjulienne@suse.de> References: <20200612164632.25648-1-nsaenzjulienne@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Raspberry Pi 4's co-processor controls some of the board's HW initialization process, but it's up to Linux to trigger it when relevant. Introduce a reset controller capable of interfacing with RPi4's co-processor that models these firmware initialization routines as reset lines. Signed-off-by: Nicolas Saenz Julienne --- drivers/reset/Kconfig | 10 ++++ drivers/reset/Makefile | 1 + drivers/reset/reset-raspberrypi.c | 60 +++++++++++++++++++ .../reset/raspberrypi,firmware-reset.h | 13 ++++ 4 files changed, 84 insertions(+) create mode 100644 drivers/reset/reset-raspberrypi.c create mode 100644 include/dt-bindings/reset/raspberrypi,firmware-reset.h diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig index 88d3be1593..d02c1522e5 100644 --- a/drivers/reset/Kconfig +++ b/drivers/reset/Kconfig @@ -148,4 +148,14 @@ config RESET_IMX7 help Support for reset controller on i.MX7/8 SoCs. +config RESET_RASPBERRYPI + bool "Raspberry Pi 4 Firmware Reset Controller Driver" + depends on DM_RESET && ARCH_BCM283X + default USB_XHCI_PCI + help + Raspberry Pi 4's co-processor controls some of the board's HW + initialization process, but it's up to Linux to trigger it when + relevant. This driver provides a reset controller capable of + interfacing with RPi4's co-processor and model these firmware + initialization routines as reset lines. endmenu diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile index 0a044d5d8c..be54dae725 100644 --- a/drivers/reset/Makefile +++ b/drivers/reset/Makefile @@ -23,3 +23,4 @@ obj-$(CONFIG_RESET_MTMIPS) += reset-mtmips.o obj-$(CONFIG_RESET_SUNXI) += reset-sunxi.o obj-$(CONFIG_RESET_HISILICON) += reset-hisilicon.o obj-$(CONFIG_RESET_IMX7) += reset-imx7.o +obj-$(CONFIG_RESET_RASPBERRYPI) += reset-raspberrypi.o diff --git a/drivers/reset/reset-raspberrypi.c b/drivers/reset/reset-raspberrypi.c new file mode 100644 index 0000000000..e2d284e5ac --- /dev/null +++ b/drivers/reset/reset-raspberrypi.c @@ -0,0 +1,60 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Raspberry Pi 4 firmware reset driver + * + * Copyright (C) 2020 Nicolas Saenz Julienne + */ +#include +#include +#include +#include +#include + +static int raspberrypi_reset_request(struct reset_ctl *reset_ctl) +{ + if (reset_ctl->id >= RASPBERRYPI_FIRMWARE_RESET_NUM_IDS) + return -EINVAL; + + return 0; +} + +static int raspberrypi_reset_free(struct reset_ctl *reset_ctl) +{ + return 0; +} + +static int raspberrypi_reset_assert(struct reset_ctl *reset_ctl) +{ + switch (reset_ctl->id) { + case RASPBERRYPI_FIRMWARE_RESET_ID_USB: + bcm2711_notify_vl805_reset(); + return 0; + default: + return -EINVAL; + } +} + +static int raspberrypi_reset_deassert(struct reset_ctl *reset_ctl) +{ + return 0; +} + +struct reset_ops raspberrypi_reset_ops = { + .request = raspberrypi_reset_request, + .rfree = raspberrypi_reset_free, + .rst_assert = raspberrypi_reset_assert, + .rst_deassert = raspberrypi_reset_deassert, +}; + +static const struct udevice_id raspberrypi_reset_ids[] = { + { .compatible = "raspberrypi,firmware-reset" }, + { } +}; + +U_BOOT_DRIVER(raspberrypi_reset) = { + .name = "raspberrypi-reset", + .id = UCLASS_RESET, + .of_match = raspberrypi_reset_ids, + .ops = &raspberrypi_reset_ops, +}; + diff --git a/include/dt-bindings/reset/raspberrypi,firmware-reset.h b/include/dt-bindings/reset/raspberrypi,firmware-reset.h new file mode 100644 index 0000000000..1a4f4c7927 --- /dev/null +++ b/include/dt-bindings/reset/raspberrypi,firmware-reset.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2020 Nicolas Saenz Julienne + * Author: Nicolas Saenz Julienne + */ + +#ifndef _DT_BINDINGS_RASPBERRYPI_FIRMWARE_RESET_H +#define _DT_BINDINGS_RASPBERRYPI_FIRMWARE_RESET_H + +#define RASPBERRYPI_FIRMWARE_RESET_ID_USB 0 +#define RASPBERRYPI_FIRMWARE_RESET_NUM_IDS 1 + +#endif -- 2.26.2