From patchwork Thu Jan 31 17:38:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Tyshchenko X-Patchwork-Id: 1034396 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="pwec1t3e"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43r79b1nt1z9s4V for ; Fri, 1 Feb 2019 04:52:35 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id E5FE1C21E0B; Thu, 31 Jan 2019 17:52: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, 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 56CF2C21FB7; Thu, 31 Jan 2019 17:51:06 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id EB26CC21DB3; Thu, 31 Jan 2019 17:39:05 +0000 (UTC) Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) by lists.denx.de (Postfix) with ESMTPS id CC721C21D56 for ; Thu, 31 Jan 2019 17:39:04 +0000 (UTC) Received: by mail-lj1-f195.google.com with SMTP id g11-v6so3435778ljk.3 for ; Thu, 31 Jan 2019 09:39:04 -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=Omm+jhw4f7gGiFMnkf/sb3INtFGGDTmZqCdNSOOE9ss=; b=pwec1t3e8oXYA+NspIHsLTmpM+VubRxUPnVQiBvdnSpxKGyc/zroEofofd2dtQXPcM 2hnK7pYm75vKtl5IKSTeG1S8HyUDffug+82WkDw+2HkVNKj0LXNVJ62nZMPBDzQZMCND XQJCLE74psvtpsB16snbDGWtdW6ZjwExaNrOu+uQqBgth/ZioAMsuZxW/MkmsAtJq478 nRZkLODAuCSqxlL3rm8ST8FbE9INi5T5V8U2d+uowNd5vDichx+vDMHhXcSjBt/F36OA eTqYBWl5L8VUf+aLbrSxfRXOklgVCIJ0YJB+spx0ROEkhugYWc9ui+Rf/HfUhIOV4v2a MFLg== 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=Omm+jhw4f7gGiFMnkf/sb3INtFGGDTmZqCdNSOOE9ss=; b=ivus+ZThwfnObjYbtzAYMZeuhvVkIFxvXuTlwTBCKkMlQp/6stwegYeduYOkvSh1ou NI7kKp2NCSsiKuSTXCCOC/qy9/xhCSa7l96Cu/DPa6rTVPVnSnKqvhea50owYiztwziK kERflMB9NuYUhcf0QYY6E301cHc1h04NbsbclRwZybZOU3PeLPUDctdnyDXdhqay80Vj Hfy7NGnet67SSwn3CsLPaluzRpSw8wUYBJO2ZAm50dwiOqJcwCVoiuLHX0zsSuFyUArX by8e/915FjVovDAs9bzg49P7olMwSWMsyl1mIIvk6D0d0CktbnL2OS3nVvGK2EmvZYko erKQ== X-Gm-Message-State: AJcUukd8UvLNkUAjEGcxnz9blwTuFqr2hNzDbOa3Pd55NfvI8eMd+74J /XGVMq8wLp4bdm67VMxfwmssnk9r X-Google-Smtp-Source: ALg8bN4/bi2U9IhxI6sPboDh+BzZFeV2Xj/sHZNWunYeSRRcgk/xmICnXKd0CVG1f1nqxUIO+4Q3jg== X-Received: by 2002:a2e:8ec8:: with SMTP id e8-v6mr28754127ljl.162.1548956344013; Thu, 31 Jan 2019 09:39:04 -0800 (PST) Received: from otyshchenko.kyiv.epam.com (ll-74.141.223.85.sovam.net.ua. [85.223.141.74]) by smtp.gmail.com with ESMTPSA id l21-v6sm896830ljj.48.2019.01.31.09.39.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 Jan 2019 09:39:03 -0800 (PST) From: Oleksandr Tyshchenko To: u-boot@lists.denx.de Date: Thu, 31 Jan 2019 19:38:29 +0200 Message-Id: <1548956309-24113-4-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1548956309-24113-1-git-send-email-olekstysh@gmail.com> References: <1548956309-24113-1-git-send-email-olekstysh@gmail.com> X-Mailman-Approved-At: Thu, 31 Jan 2019 17:51:04 +0000 Cc: Nobuhiro Iwamatsu , Tom Rini , Oleksandr Tyshchenko , Julien Grall , Marek Vasut Subject: [U-Boot] [PATCH 3/3] ARM: rmobile: Add possibility to debug main PSCI commands 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" From: Oleksandr Tyshchenko Also take care of the fact that Lager and Stout boards use different serial interface for console. Signed-off-by: Oleksandr Tyshchenko --- arch/arm/mach-rmobile/debug.h | 91 +++++++++++++++++++++++++++++++++++++++++++ arch/arm/mach-rmobile/psci.c | 23 +++++++++++ 2 files changed, 114 insertions(+) create mode 100644 arch/arm/mach-rmobile/debug.h diff --git a/arch/arm/mach-rmobile/debug.h b/arch/arm/mach-rmobile/debug.h new file mode 100644 index 0000000..5d4ec77 --- /dev/null +++ b/arch/arm/mach-rmobile/debug.h @@ -0,0 +1,91 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Contains functions used for PSCI debug. + * + * Copyright (C) 2018 EPAM Systems Inc. + * + * Based on arch/arm/mach-uniphier/debug.h + */ + +#ifndef __DEBUG_H__ +#define __DEBUG_H__ + +#include + +/* SCIFA definitions */ +#define SCIFA_BASE 0xe6c40000 + +#define SCIFA_SCASSR 0x14 /* Serial status register */ +#define SCIFA_SCAFTDR 0x20 /* Transmit FIFO data register */ + +/* SCIF definitions */ +#define SCIF_BASE 0xe6e60000 + +#define SCIF_SCFSR 0x10 /* Serial status register */ +#define SCIF_SCFTDR 0x0c /* Transmit FIFO data register */ + +/* Common for both interfaces definitions */ +#define SCFSR_TDFE BIT(5) /* Transmit FIFO Data Empty */ +#define SCFSR_TEND BIT(6) /* Transmission End */ + +#ifdef CONFIG_SCIF_A +#define UART_BASE SCIFA_BASE +#define UART_STATUS_REG SCIFA_SCASSR +#define UART_TX_FIFO_REG SCIFA_SCAFTDR +#else +#define UART_BASE SCIF_BASE +#define UART_STATUS_REG SCIF_SCFSR +#define UART_TX_FIFO_REG SCIF_SCFTDR +#endif + +/* All functions are inline so that they can be called from .secure section. */ + +#ifdef DEBUG +static inline void debug_putc(int c) +{ + void __iomem *base = (void __iomem *)UART_BASE; + + while (!(readw(base + UART_STATUS_REG) & SCFSR_TDFE)) + ; + + writeb(c, base + UART_TX_FIFO_REG); + writew(readw(base + UART_STATUS_REG) & ~(SCFSR_TEND | SCFSR_TDFE), + base + UART_STATUS_REG); +} + +static inline void debug_puts(const char *s) +{ + while (*s) { + if (*s == '\n') + debug_putc('\r'); + + debug_putc(*s++); + } +} + +static inline void debug_puth(unsigned long val) +{ + int i; + unsigned char c; + + for (i = 8; i--; ) { + c = ((val >> (i * 4)) & 0xf); + c += (c >= 10) ? 'a' - 10 : '0'; + debug_putc(c); + } +} +#else +static inline void debug_putc(int c) +{ +} + +static inline void debug_puts(const char *s) +{ +} + +static inline void debug_puth(unsigned long val) +{ +} +#endif + +#endif /* __DEBUG_H__ */ diff --git a/arch/arm/mach-rmobile/psci.c b/arch/arm/mach-rmobile/psci.c index 95850b8..4d78b0f 100644 --- a/arch/arm/mach-rmobile/psci.c +++ b/arch/arm/mach-rmobile/psci.c @@ -14,6 +14,7 @@ #include #include "pm-r8a7790.h" +#include "debug.h" #define R8A7790_PSCI_NR_CPUS 8 #if R8A7790_PSCI_NR_CPUS > CONFIG_ARMV7_PSCI_NR_CPUS @@ -105,6 +106,16 @@ int __secure psci_cpu_on(u32 function_id, u32 target_cpu, u32 entry_point, { int cpu; + debug_puts("[U-Boot PSCI] cpu_on: cpu="); + debug_puth(get_current_cpu()); + debug_puts(", target_cpu="); + debug_puth(target_cpu); + debug_puts(", entry_point="); + debug_puth(entry_point); + debug_puts(", context_id="); + debug_puth(context_id); + debug_puts("\n"); + cpu = mpidr_to_cpu_index(target_cpu); if (cpu == -1) return ARM_PSCI_RET_INVAL; @@ -130,6 +141,10 @@ int __secure psci_cpu_off(void) { int cpu = get_current_cpu(); + debug_puts("[U-Boot PSCI] cpu_off: cpu="); + debug_puth(cpu); + debug_puts("\n"); + /* * Place the CPU interface in a state where it can never make a CPU * exit WFI as result of an asserted interrupt. @@ -154,6 +169,10 @@ int __secure psci_cpu_off(void) void __secure psci_system_reset(u32 function_id) { + debug_puts("[U-Boot PSCI] system_reset: cpu="); + debug_puth(get_current_cpu()); + debug_puts("\n"); + r8a7790_system_reset(); /* Drain the WB before WFI */ @@ -166,6 +185,10 @@ void __secure psci_system_reset(u32 function_id) void __secure psci_system_off(u32 function_id) { + debug_puts("[U-Boot PSCI] system_off: cpu="); + debug_puth(get_current_cpu()); + debug_puts("\n"); + /* Drain the WB before WFI */ dsb();