Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1561991ybj; Fri, 8 May 2020 04:23:17 -0700 (PDT) X-Google-Smtp-Source: APiQypJlY8bQ4yQICG/yaNp1jHmYbeSzpdOqIpxl/83RKPFp6sLmW5oivhob7nxnw1yC+ZTq7LMt X-Received: by 2002:a17:907:2098:: with SMTP id pv24mr1500075ejb.22.1588936996862; Fri, 08 May 2020 04:23:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588936996; cv=none; d=google.com; s=arc-20160816; b=aOQ/AYh2XnkMoQU3NmD9UI5xp4+bc27HoLafmn1WE8tcOKGhq/KmV8ZKbojIfrQIJp wByDWaUtdUl+zRgx/NtzODjtm2nAg504XtoaU8khgGkG/9teH/srdi1NaR/qkhj+o+0f fpi58pf8cAAG0O6fvyldeay/H7XjWuKxaEokwsJFXzZ8IL3WTeXmv283kuF6XRHCG/Tx s/m7CBMRMN3PfUSLvrwBd/mosulE4oQLx8OsrLOhuP3paV95gVt+GQuKZ5/JEC+9MhxN Xf7diqpOxrXWSyAUtQ171+5QTSm9uXd0iiEgzAc2I5WeVtJJUXPzNn7v6CfqpOxT9pWs AWkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=Ddpx+ZAiFu+jfp4GvSyxtgbyAZ7W7EUrasQoYXB2n5c=; b=r6NL1a9Efk8jE0WAJRL6tQEkIXFQERQhdTBeYcMH7U+5Pyd6rmWcK7DOo58r78JbeS 60iN16xvKfm9p6vUsxrAPGYAt6Zci1qQ5dZQfVzwLUPlLIQlz4TPmHaeFCqxwcIMjIeN WCN2z6gI5iF11mY/hjnaKUG0a+vKYE9GOdwsjMeSK8wLLC87cupjBUsmbklkaZiPIqEZ MDEnr+qLvMNRGjMT1ZzwpqDoZeZlWni0zhaGQed1j8J4WxjsRh844RmCCrvv+n8TmeBo JXn4gDhf6WJYHyrROBZIKwrC13N/fFW/haarOiwqoGiIXRm7nlrVz0DPeJ9bUm3hawSI Qsjg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn17si989188ejc.311.2020.05.08.04.22.54; Fri, 08 May 2020 04:23:16 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726756AbgEHLUz (ORCPT + 99 others); Fri, 8 May 2020 07:20:55 -0400 Received: from mga12.intel.com ([192.55.52.136]:58519 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726616AbgEHLUy (ORCPT ); Fri, 8 May 2020 07:20:54 -0400 IronPort-SDR: b73UGGSDcvgsjMD7FPZE7nxcwvpYjFDSqp/OA8iIiVJETZJ1n+a3d33ySm+GJjZqA6BtOGsxTx ewQ04HaJpDww== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 May 2020 04:20:54 -0700 IronPort-SDR: L3ZS7pIBLFx1WplCTOxs1Usmy4xWOZgzH/gYmTuqoCsyWtA/xFY2jYQ59pIeoK7WZSkIgZouhB F9F0e8zfQzLg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,367,1583222400"; d="scan'208";a="370429123" Received: from sgsxdev001.isng.intel.com (HELO localhost) ([10.226.88.11]) by fmsmga001.fm.intel.com with ESMTP; 08 May 2020 04:20:52 -0700 From: Rahul Tanwar To: gregkh@linuxfoundation.org, linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org, andriy.shevchenko@intel.com, Rahul Tanwar Subject: [PATCH] serial: lantiq: Make driver modular and console configurable Date: Fri, 8 May 2020 19:20:49 +0800 Message-Id: <42292519ba78f086eb19d058dec6411f5f29da51.1588936756.git.rahul.tanwar@linux.intel.com> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add changes so Lantiq serial driver can be compiled as a module. Also, make this driver's use as console selectable/configurable. Signed-off-by: Rahul Tanwar --- drivers/tty/serial/Kconfig | 13 +++++++++++-- drivers/tty/serial/lantiq.c | 43 ++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 4b0a7b98f8c7..996782247174 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -1034,13 +1034,22 @@ config SERIAL_SIFIVE_CONSOLE boot time.) config SERIAL_LANTIQ - bool "Lantiq serial driver" + tristate "Lantiq serial driver" depends on (LANTIQ || X86) || COMPILE_TEST select SERIAL_CORE + help + Support for UART on Lantiq and Intel SoCs. + To compile this driver as a module, choose M here, the + module will be called lantiq. + +config SERIAL_LANTIQ_CONSOLE + bool "Console on Lantiq UART" + depends on SERIAL_LANTIQ=y select SERIAL_CORE_CONSOLE select SERIAL_EARLYCON help - Support for console and UART on Lantiq SoCs. + Select this option if you would like to use a Lantiq UART as the + system console. config SERIAL_QE tristate "Freescale QUICC Engine serial port support" diff --git a/drivers/tty/serial/lantiq.c b/drivers/tty/serial/lantiq.c index c5e46ff972e4..93ed59bccd11 100644 --- a/drivers/tty/serial/lantiq.c +++ b/drivers/tty/serial/lantiq.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -597,6 +598,13 @@ static const struct uart_ops lqasc_pops = { .verify_port = lqasc_verify_port, }; + +/* + * Linux console interface + */ + +#ifdef CONFIG_SERIAL_LANTIQ_CONSOLE + static void lqasc_console_putchar(struct uart_port *port, int ch) { @@ -705,6 +713,14 @@ lqasc_serial_early_console_setup(struct earlycon_device *device, OF_EARLYCON_DECLARE(lantiq, "lantiq,asc", lqasc_serial_early_console_setup); OF_EARLYCON_DECLARE(lantiq, "intel,lgm-asc", lqasc_serial_early_console_setup); +#define LANTIQ_SERIAL_CONSOLE (&lqasc_console) + +#else + +#define LANTIQ_SERIAL_CONSOLE NULL + +#endif + static struct uart_driver lqasc_reg = { .owner = THIS_MODULE, .driver_name = DRVNAME, @@ -712,7 +728,7 @@ static struct uart_driver lqasc_reg = { .major = 0, .minor = 0, .nr = MAXPORTS, - .cons = &lqasc_console, + .cons = LANTIQ_SERIAL_CONSOLE, }; static int fetch_irq_lantiq(struct device *dev, struct ltq_uart_port *ltq_port) @@ -899,6 +915,13 @@ lqasc_probe(struct platform_device *pdev) return ret; } +static int lqasc_remove(struct platform_device *pdev) +{ + struct uart_port *port = platform_get_drvdata(pdev); + + return uart_remove_one_port(&lqasc_reg, port); +} + static const struct ltq_soc_data soc_data_lantiq = { .fetch_irq = fetch_irq_lantiq, .request_irq = request_irq_lantiq, @@ -916,8 +939,11 @@ static const struct of_device_id ltq_asc_match[] = { { .compatible = "intel,lgm-asc", .data = &soc_data_intel }, {}, }; +MODULE_DEVICE_TABLE(of, ltq_asc_match); static struct platform_driver lqasc_driver = { + .probe = lqasc_probe, + .remove = lqasc_remove, .driver = { .name = DRVNAME, .of_match_table = ltq_asc_match, @@ -933,10 +959,21 @@ init_lqasc(void) if (ret != 0) return ret; - ret = platform_driver_probe(&lqasc_driver, lqasc_probe); + ret = platform_driver_register(&lqasc_driver); if (ret != 0) uart_unregister_driver(&lqasc_reg); return ret; } -device_initcall(init_lqasc); + +static void __exit exit_lqasc(void) +{ + platform_driver_unregister(&lqasc_driver); + uart_unregister_driver(&lqasc_reg); +} + +module_init(init_lqasc); +module_exit(exit_lqasc); + +MODULE_DESCRIPTION("Serial driver for Lantiq & Intel gateway SoCs"); +MODULE_LICENSE("GPL v2"); -- 2.11.0