From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933151AbdEWFY1 (ORCPT ); Tue, 23 May 2017 01:24:27 -0400 Received: from mail-lf0-f46.google.com ([209.85.215.46]:34082 "EHLO mail-lf0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761288AbdEWFYX (ORCPT ); Tue, 23 May 2017 01:24:23 -0400 Subject: Re: [V2, 2/6] tty: serial: lpuart: add little endian 32 bit register support To: Dong Aisheng References: <1494834539-17523-3-git-send-email-aisheng.dong@nxp.com> <20170517033139.GB9913@b29396-OptiPlex-7040> <48819894-4943-7d14-ccf8-83cfd2195c9a@cogentembedded.com> <55bae8d2-0e23-b5e1-f304-63d9130ccb08@cogentembedded.com> <20170517070019.GG9913@b29396-OptiPlex-7040> <045d1888-4a23-cf73-ab4c-009e29fde974@cogentembedded.com> <20170519150722.GB23227@b29396-OptiPlex-7040> Cc: "A.S. Dong" , "linux-serial@vger.kernel.org" , Andy Duan , "gregkh@linuxfoundation.org" , "Y.B. Lu" , "linux-kernel@vger.kernel.org" , "stefan@agner.ch" , Mingkai Hu , "jslaby@suse.com" , "linux-arm-kernel@lists.infradead.org" From: Nikita Yushchenko X-Enigmail-Draft-Status: N1110 Message-ID: <2f873a62-0e4e-7da6-5c5e-be570fcceff1@cogentembedded.com> Date: Tue, 23 May 2017 08:24:18 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170519150722.GB23227@b29396-OptiPlex-7040> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, >>>> Alternative solution could be - have separate write path for earlycon. >>> >>> It looks to me having the same issue with a separate write patch >>> for earlycon as we still need distinguish Little or Big endian >>> for Layerscape and IMX. >>> >>>> At a glance, it is dozen lines of code. >>> >>> Would you please show some sample code? >> >> Do not reuse lpuart32_console_putchar() in earlycon code. >> >> Have two sets of early_setup/early_write/putchar - for BE and >> defaut-endian earlycon. And in these putchar's do not use >> lpuart_(read|write). >> > > Isn't that introducing another consistency break after fix one > consistency break? > > If doing that, we then have two register read/write APIs. > One for normal driver operation by dynamically checking lpuart_is_be > property to distinguish the endian difference problem. > Another is specifically implemented for only early console read/write > and use hardcoded way to read/write register directly instead of using > the standard API lpuart32_read/write, like follows: > e.g. > lpuart32_le_console_write() { > writel(); > } > > lpuart32_be_console_write() { > iowrite32be() > } > This also makes the driver a bit strange and ugly. > > It looks to me both way are trade offs and the later one seems sacrifice > more. And i doubt if it's really necessary for probably a no real gain > purpose as the FPGA you mentioned is a theoretical case and less > possibility to exist. > > I'm still wondering how about keep using the exist way and adding more > information in code to explain why use a global var? I've checked other driver under drivers/tty/serial/, for examples of similar cases. Please look at serial8250_early_in() / serial8250_early_out() ? These do handle different endian, via port->iotype Another example is drivers/tty/serial/samsung.c, where port->private_data is initialized and used. Nikita