--- zzzz-none-000/linux-4.9.279/drivers/tty/serial/8250/8250_core.c 2021-08-08 06:38:54.000000000 +0000 +++ puma7-arm-6591-750/linux-4.9.279/drivers/tty/serial/8250/8250_core.c 2023-02-08 10:58:14.000000000 +0000 @@ -18,6 +18,35 @@ * (at your option) any later version. */ +/* Copyright 2008, Texas Instruments Incorporated + * + * This program has been modified from its original operation by Texas Instruments + * to do the following: + * 1) Set uartclk in serial8250_resume_port to support arm frequency change in + * Puma5. + * + * THIS MODIFIED SOFTWARE AND DOCUMENTATION ARE PROVIDED + * "AS IS," AND TEXAS INSTRUMENTS MAKES NO REPRESENTATIONS + * OR WARRENTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED + * TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY + * PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR + * DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, + * COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. + * See The GNU General Public License for more details. + * + * These changes are covered under version 2 of the GNU General Public License, + * dated June 1991. + */ +/* + * Includes Intel Corporation's changes/modifications dated: 2017, 2019. + * Changed/modified portions - Copyright (c) 2017-2019, Intel Corporation. + */ + + +#if defined(CONFIG_SERIAL_8250_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) +#define SUPPORT_SYSRQ +#endif + #include #include #include @@ -45,6 +74,10 @@ #include "8250.h" +#include + +#include + /* * Configuration: * share_irqs - whether we pass IRQF_SHARED to request_irq(). This option @@ -58,6 +91,10 @@ static unsigned int skip_txen_test; /* force skip of txen test at init time */ +#ifdef CONFIG_INTEL_UART_ENABLE_CONTROL +static int serial_sysfs_create_uart_enable_ctrl(void); +#endif + #define PASS_LIMIT 512 #include @@ -779,6 +816,12 @@ { struct uart_8250_port *up = &serial8250_ports[line]; struct uart_port *port = &up->port; +#if defined (CONFIG_MACH_PUMA5) + extern unsigned int avalanche_get_vbus_freq(void); + serial8250_ports[line].port.uartclk = avalanche_get_vbus_freq (); +#else /* CONFIG_MACH_PUMA6 For Puma-6 SoC */ + serial8250_ports[line].port.uartclk = PAL_sysClkcGetFreq(PAL_SYS_CLKC_UART0); +#endif up->canary = 0; @@ -1108,6 +1151,46 @@ } EXPORT_SYMBOL(serial8250_unregister_port); +#ifdef CONFIG_INTEL_UART_ENABLE_CONTROL +static ssize_t serial_get_attr_enable_ctrl(struct device *dev, + struct device_attribute *attr, char *buf) +{ + int enable; + + if (IO_CTRL_readDocsisUartCtrl(&enable) != IOCNFG_OK) + printk(KERN_ERR "Unable to read DocsisUartCtrl status\n"); + + return sprintf(buf, "%d\n", enable); +} + +static ssize_t serial_set_attr_enable_ctrl(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + int enable; + + enable = (int)(buf[0] - '0'); + if ((enable == 0) || (enable == 1)) + IO_CTRL_configDocsisUartCtrl(enable); + else + printk(KERN_ERR "uart_enable_ctrl: 0(disable) / 1(enable) UART\n"); + + return count; +} + +/* Initialize device attribute structure */ +static DEVICE_ATTR(uart_enable_ctrl, S_IRUSR | S_IWUSR, serial_get_attr_enable_ctrl, serial_set_attr_enable_ctrl); + +static int serial_sysfs_create_uart_enable_ctrl(void) +{ + int retval = sysfs_create_file(kernel_kobj, &dev_attr_uart_enable_ctrl.attr); + + if (retval) + return -ENOMEM; + + return retval; +} +#endif + static int __init serial8250_init(void) { int ret; @@ -1133,6 +1216,11 @@ if (ret) goto unreg_uart_drv; +#ifdef CONFIG_INTEL_UART_ENABLE_CONTROL + if (serial_sysfs_create_uart_enable_ctrl()) + goto out; +#endif + serial8250_isa_devs = platform_device_alloc("serial8250", PLAT8250_DEV_LEGACY); if (!serial8250_isa_devs) { @@ -1162,6 +1250,9 @@ uart_unregister_driver(&serial8250_reg); #endif out: +#ifndef CONFIG_INTEL_UART_ENABLE + IO_CTRL_configDocsisUartCtrl(0); +#endif return ret; }