Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3427454imm; Sun, 13 May 2018 11:05:34 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr+t/c39RNVaXcqv+tOOSxpI4s0uyve78trsRmPmw8doKxeOdriV8shMJa8mbPwcZKh93ud X-Received: by 2002:a62:e0cf:: with SMTP id d76-v6mr7298011pfm.52.1526234734811; Sun, 13 May 2018 11:05:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526234734; cv=none; d=google.com; s=arc-20160816; b=AEaGDfu2WUU6lP6YOgIh1iqq4sckjz+3qOmGCqkfgafxaDgkx53htU0HUgh9cJnyXW DVzJ+P+H+c2eZwd41IB1hpC6dgKUPQwIkQB+oW1BVA6ZvI5Myfe3NnFcX61oLT99rWgd 4JdVANlVcNbKHaSSZQHezcsL2qbDFrx7OXMx8YaBL61UOHJZM0DkoKxokqsxi1pmoWFv ay7SEuIXhsTdlA0YNvj+aOeRTHoobRM+nzgIf7k3eG5Ip3tb3lY/0iI2bOL/MuYMHrje b4FmeJZ9mCPamHXQROOpP5zwmUImK2KDj5AN4PJHMEK2x1KtQ4kEeTx+yCOPluCW5f9M YsRg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=KRH7jRF1NeZ1WgFRiFngddW+ANsJtp8yFNtk1aXutlc=; b=biqaVm630RIw7w6XB4B4cofn05Yi3pqpx7kLkiBRRzXPvGBw2JgcwCK/3vpikvgXRh TBekfQ+7NUk3NKt92QJiRY9jc0o1NnKsVeAh1j5t6V4fubyANAKWdvzfmojr1PYASEwP +lupkFA06eReTgZ3xMH/xputZ5C/Z8a+DKBuMbeLmH1761n3kHmee7s0OSkow+CBENSq Oo1uI1dk9ah2dQGqf3EnMvjLnn2y8wcuI1GQaOl3d/VDoaI+XG6W1byc8vqfjibMpirJ f8potopR8sCqAIywi0/jFgdKi8aGk8G5Pnki8y+HyqSVNyQIjd3MnvZnm7ek8v1zvFX/ kjtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kapsi.fi header.s=20161220 header.b=AU+eC3cI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 126-v6si6281212pgc.535.2018.05.13.11.05.19; Sun, 13 May 2018 11:05:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kapsi.fi header.s=20161220 header.b=AU+eC3cI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751762AbeEMSFC (ORCPT + 99 others); Sun, 13 May 2018 14:05:02 -0400 Received: from mail.kapsi.fi ([91.232.154.25]:56555 "EHLO mail.kapsi.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751270AbeEMSE7 (ORCPT ); Sun, 13 May 2018 14:04:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kapsi.fi; s=20161220; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject; bh=KRH7jRF1NeZ1WgFRiFngddW+ANsJtp8yFNtk1aXutlc=; b=AU+eC3cIpcHDOwzkArGJSfKPfaK30g5al1YG5iOo0QXWAEqkyLiZUsv8UMfx1j/bCbc9JhFkBdl7+PMIlhxrsGJkliLf6zkwKE0y6lCd/P3Dktl2VRID9dPFRtG74blFL0pwAi/US4YG7kMPMKmy7TFccKK1tO8gxPGl//VNkye4zzp5YPv3b+xJ2i+b2VS3CKdqaRPvvtwnGOILAWC+KPmikExN5fmaaPxTCvkvMOBu51fFhJYf3QH+RZDejF3V5M07CpnUj2XNlRYOK7GfJcm4v/cr4LFtOZ0Na1V2AwiND6C/BajOcn9dI/FDhs6hfdNYlEOTqoYMQQatqAOu5A==; Received: from dsl-hkibng22-54faa2-250.dhcp.inet.fi ([84.250.162.250]) by mail.kapsi.fi with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1fHvMd-0004Ao-6B; Sun, 13 May 2018 21:04:55 +0300 Subject: Re: [PATCH 6/8] serial: Add Tegra Combined UART driver To: Andy Shevchenko , Mikko Perttunen Cc: Rob Herring , Mark Rutland , Jassi Brar , Greg Kroah-Hartman , Thierry Reding , Jon Hunter , araza@nvidia.com, devicetree , "open list:SERIAL DRIVERS" , linux-tegra@vger.kernel.org, linux-arm Mailing List , Linux Kernel Mailing List References: <20180508114403.14499-1-mperttunen@nvidia.com> <20180508114403.14499-7-mperttunen@nvidia.com> From: Mikko Perttunen Message-ID: <662ce972-56a9-9daa-d332-faa08b89c05a@kapsi.fi> Date: Sun, 13 May 2018 21:04:51 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 84.250.162.250 X-SA-Exim-Mail-From: cyndis@kapsi.fi X-SA-Exim-Scanned: No (on mail.kapsi.fi); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/13/2018 05:16 PM, Andy Shevchenko wrote: > On Tue, May 8, 2018 at 2:44 PM, Mikko Perttunen wrote: >> The Tegra Combined UART (TCU) is a mailbox-based mechanism that allows >> multiplexing multiple "virtual UARTs" into a single hardware serial >> port. The TCU is the primary serial port on Tegra194 devices. >> >> Add a TCU driver utilizing the mailbox framework, as the used mailboxes >> are part of Tegra HSP blocks that are already controlled by the Tegra >> HSP mailbox driver. > > First question, can it be done utilizing SERDEV framework? Based on some brief research, the SERDEV framework is for devices that are behind some UART interface. In this case, this driver implements the UART interface itself, so by my understanding SERDEV is not appropriate. Please correct me if I'm wrong. > >> +static void tegra_tcu_uart_set_mctrl(struct uart_port *port, unsigned int mctrl) >> +{ > >> + (void)port; >> + (void)mctrl; > > Huh? The serial core calls these callbacks without checking if they are set. They don't make sense for this driver so they are stubbed out. > >> +} > >> +static void tegra_tcu_uart_stop_tx(struct uart_port *port) >> +{ >> + (void)port; >> +} > > Ditto. > >> + if (written == 3) { >> + value |= 3 << 24; >> + value |= BIT(26); >> + mbox_send_message(tcu->tx, &value); > >> + } > > (1) > >> + } >> + >> + if (written) { >> + value |= written << 24; >> + value |= BIT(26); >> + mbox_send_message(tcu->tx, &value); >> + } > > (2) > > These are code duplications. Indeed - the length of the duplicated code is so short, and the instances are so close to each other, that I don't find it necessary (or clearer) to have an extra function. > >> +static void tegra_tcu_uart_stop_rx(struct uart_port *port) >> +{ >> + (void)port; >> +} >> + >> +static void tegra_tcu_uart_break_ctl(struct uart_port *port, int ctl) >> +{ >> + (void)port; >> + (void)ctl; >> +} >> + >> +static int tegra_tcu_uart_startup(struct uart_port *port) >> +{ >> + (void)port; >> + >> + return 0; >> +} >> + >> +static void tegra_tcu_uart_shutdown(struct uart_port *port) >> +{ >> + (void)port; >> +} >> + >> +static void tegra_tcu_uart_set_termios(struct uart_port *port, >> + struct ktermios *new, >> + struct ktermios *old) >> +{ >> + (void)port; >> + (void)new; >> + (void)old; >> +} > > Remove those unused stub contents. Sure. I had these here so that we don't get unused parameter warnings, but I can just as well remove the parameter names. > >> + return uart_set_options(&tegra_tcu_uart_port, cons, >> + 115200, 'n', 8, 'n'); > > Can't it be one line? It would be a total of 81 characters in length on one line, so no. > >> +static void tegra_tcu_receive(struct mbox_client *client, void *msg_p) >> +{ >> + struct tty_port *port = &tegra_tcu_uart_port.state->port; > >> + uint32_t msg = *(uint32_t *)msg_p; > > Redundant casting. Will remove. > >> + unsigned int num_bytes; >> + int i; >> + > >> + num_bytes = (msg >> 24) & 0x3; > > Two magic numbers. Sure, will add defines. > >> + for (i = 0; i < num_bytes; i++) >> + tty_insert_flip_char(port, (msg >> (i*8)) & 0xff, TTY_NORMAL); >> + >> + tty_flip_buffer_push(port); >> +} > >> +MODULE_AUTHOR("Mikko Perttunen "); >> +MODULE_LICENSE("GPL v2"); >> +MODULE_DESCRIPTION("NVIDIA Tegra Combined UART driver"); >> diff --git a/include/uapi/linux/serial_core.h b/include/uapi/linux/serial_core.h >> index dce5f9dae121..eaf3c303cba6 100644 >> --- a/include/uapi/linux/serial_core.h >> +++ b/include/uapi/linux/serial_core.h >> @@ -281,4 +281,7 @@ >> /* MediaTek BTIF */ >> #define PORT_MTK_BTIF 117 >> >> +/* NVIDIA Tegra Combined UART */ >> +#define PORT_TEGRA_TCU 118 > > Check if there is an unused gap. IIRC we still have one near to 40ish. > Correct, looks like 41-43 are unused. I'll change this 41. Thanks for reviewing! Mikko