From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-it0-x22e.google.com (mail-it0-x22e.google.com [IPv6:2607:f8b0:4001:c0b::22e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 757C721CF3B67 for ; Mon, 3 Jul 2017 03:56:59 -0700 (PDT) Received: by mail-it0-x22e.google.com with SMTP id v202so85673765itb.0 for ; Mon, 03 Jul 2017 03:58:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=GriArpXIJlV28EJaqeBIbk5pyxuXIK+lbyRyHHACgYw=; b=GdTT/9A1D5DUmFR5XJe6Pw0YqAjRm0MF2JQVgPYC6LYA/BU2W2iCLVOt3cSi7k3Veb YXQSZ1WgqaSgWVDCB286Tjs5VVgLkLoTC/kae1JV2Bw/N3HsJ2ACF9YwbXwSCZRRL7z2 bSqaTy9GmTS1TI2OAlvXX/FGZ2q5jvrvyTU50= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=GriArpXIJlV28EJaqeBIbk5pyxuXIK+lbyRyHHACgYw=; b=NUlQkqjpRyLEdN1+dknUTnqJK+jCoQljDzytKHkdd8dSwQhtXOrlxU7jzcBFLM57Ib WUQL6Osd5zvXHTUic1yq3RbhClB7C2nZXeXUnubj6jnIZ/4kphnpXjHgOTXXnqYuOvCG 27/aNoQHA+H5kAsNX5Darr2Gzyos5KfuuthmSrp9nnEcPLc47Yd4f/zL/ekPQBo9IwCB ArfaB67XYoWv0gwm34LdgnmZ/OZoSKXOxH4xjA957gw8lTu8pNVabD9nTGDKHjzfzUYk XhgM/TR84RboReuJNKB5vGllKs5Q1/LKh4GSPJvbnIcb1VNiNRsLT4lx6JDrv4ZOMjP3 A8NQ== X-Gm-Message-State: AIVw112f0Tzc9cXQfY60jqTSdIyGFbW/hWriHrqjRrp4b8mMXeLrBJp2 qqTWRg+qGvG8AP1LmaYAgwGzvVN+fCzv X-Received: by 10.36.9.144 with SMTP id 138mr8208159itm.98.1499079515823; Mon, 03 Jul 2017 03:58:35 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.134.134 with HTTP; Mon, 3 Jul 2017 03:58:35 -0700 (PDT) In-Reply-To: <1499050106-12875-1-git-send-email-jun.nie@linaro.org> References: <1499050106-12875-1-git-send-email-jun.nie@linaro.org> From: Ard Biesheuvel Date: Mon, 3 Jul 2017 11:58:35 +0100 Message-ID: To: Jun Nie Cc: Leif Lindholm , "edk2-devel@lists.01.org" , Evan Lloyd , Alexei Fedorov , Shawn Guo , jason.liu@linaro.org Subject: Re: [PATCH] ArmPlatformPkg: Support different reg offset to PL011 X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jul 2017 10:56:59 -0000 Content-Type: text/plain; charset="UTF-8" On 3 July 2017 at 03:48, Jun Nie wrote: > ZTE SoC has different offset for some registers and bits. > Add a macro flag to undef/redef those value. The macro > flag can be enabled in BuildOptions section of platform.dsc. > > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Jun Nie Please use a single UINT8 type fixed PCD to configure whether your alternative register mapping should be used. You can test its value using preprocessor conditionals, e.g., #if !FixedPcdget8 (xxxx) #else #endif > --- > ArmPlatformPkg/Include/Drivers/PL011Uart.h | 40 ++++++++++++++++++++++++++++++ > 1 file changed, 40 insertions(+) > > diff --git a/ArmPlatformPkg/Include/Drivers/PL011Uart.h b/ArmPlatformPkg/Include/Drivers/PL011Uart.h > index d5e88e8..87fab60 100644 > --- a/ArmPlatformPkg/Include/Drivers/PL011Uart.h > +++ b/ArmPlatformPkg/Include/Drivers/PL011Uart.h > @@ -40,6 +40,34 @@ > #define UARTPID2 0xFE8 > #define UARTPID3 0xFEC > > +#ifdef ZX_PL011_FLAG > +#undef UARTDR > +#undef UARTFR > +#undef UARTIBRD > +#undef UARTFBRD > +#undef UARTLCR_H > +#undef UARTCR > +#undef UARTIFLS > +#undef UARTIMSC > +#undef UARTRIS > +#undef UARTMIS > +#undef UARTICR > +#undef UARTDMACR > + Please don't use #undef and redefine. Create two equivalent blocks instead, one with the default values and one with the alternative values. > +#define UARTDR 0x004 > +#define UARTFR 0x014 > +#define UARTIBRD 0x024 > +#define UARTFBRD 0x028 > +#define UARTLCR_H 0x030 > +#define UARTCR 0x034 > +#define UARTIFLS 0x038 > +#define UARTIMSC 0x040 > +#define UARTRIS 0x044 > +#define UARTMIS 0x048 > +#define UARTICR 0x04c > +#define UARTDMACR 0x050 > +#endif > + > // Data status bits > #define UART_DATA_ERROR_MASK 0x0F00 > > @@ -57,6 +85,18 @@ > #define PL011_UARTFR_DSR (1 << 1) // Data set ready > #define PL011_UARTFR_CTS (1 << 0) // Clear to send > > +#ifdef ZX_PL011_FLAG > +#undef PL011_UARTFR_RI > +#undef PL011_UARTFR_BUSY > +#undef PL011_UARTFR_DSR > +#undef PL011_UARTFR_CTS > + > +#define PL011_UARTFR_RI 0x001 // Ring indicator > +#define PL011_UARTFR_BUSY 0x100 // UART busy > +#define PL011_UARTFR_DSR 0x008 // Data set ready > +#define PL011_UARTFR_CTS 0x002 // Clear to send Please use the same style to define the constants (1 << n)