From nobody Tue Feb 10 00:06:22 2026 Received: from smtpbgjp3.qq.com (smtpbgjp3.qq.com [54.92.39.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B5DC2163B7 for ; Thu, 9 Jan 2025 12:10:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=54.92.39.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736424616; cv=none; b=Y1GRYr4zdfM/Cnjd6v5liTXBYk0T/p7fdJL/WWKTLy2rBvC4eZPXFyw14kd+HSGjlivQM/tS4M55qrZpmolk5ilsrld3yADRwvRr/qV+XqLNGZiKYyvZLP6x0AA2IrNnwVocGUhySL2wU/TCTMwGcLEGLN4ql+6QvgGm2y1SkGQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736424616; c=relaxed/simple; bh=HE8nbJi1Xb1DwgNSlZYpK6LkiOkTqwFG93+xUjEaw2M=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=nhhsTocbIAKv4Cx4t13b/XJ0MM+MZzMqg1zZyFT1GN/Aa5Sdx/JEjmINpli3Vmppsz9n2/6BRNasstZ9EGMPfSBpXwwEUv/1cwRpscGIFb1OrsvtBa6mb05/BWcj9Jv/KTlO4n9gb50G/c57/zCJq/p83ZCnDu5J7Hbrb4BQ3wY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=uniontech.com; spf=pass smtp.mailfrom=uniontech.com; dkim=pass (1024-bit key) header.d=uniontech.com header.i=@uniontech.com header.b=Avd/yF/l; arc=none smtp.client-ip=54.92.39.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=uniontech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=uniontech.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=uniontech.com header.i=@uniontech.com header.b="Avd/yF/l" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uniontech.com; s=onoh2408; t=1736424552; bh=nmOvcYAk4I1cIEb8TdiQgvFwANxHx6ROhpH2hY99X64=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=Avd/yF/lF/FO7Hqy95zW9LKlbmpVoFJKjQx9wihuep6vcMaK4COs7aM7H4GFCHp4b R51fb9RoM96pQtenJbH9g7PjIeh7LF6SvpF+RU4t1VWrUPctLc6eeGKedblVLp30Cz uxPMoPR1BmbOkinAaoBYBtOrqc0Qmz1c/+NnoAtM= X-QQ-mid: bizesmtpip4t1736424503trxb7a4 X-QQ-Originating-IP: LcxtlZi0S+tRh7YKwOEYnjcHWPvnp7CshAHgjbE3tF0= Received: from localhost.localdomain ( [localhost]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 09 Jan 2025 20:08:20 +0800 (CST) X-QQ-SSF: 0002000000000000000000000000000 X-QQ-GoodBg: 1 X-BIZMAIL-ID: 9136327612947122579 From: WangYuli To: gregkh@linuxfoundation.org, jirislaby@kernel.org, wangyuli@uniontech.com Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, andriy.shevchenko@linux.intel.com, arnd@kernel.org, schnelle@linux.ibm.com, pnewman@connecttech.com, sunilvl@ventanamicro.com, paulmck@kernel.org, arnd@arndb.de, zhanjun@uniontech.com, guanwentao@uniontech.com, Zhuozhen He , Guowei Chen Subject: [PATCH] serial: 8250_it8768e: Create iTE IT8768E specific 8250 driver Date: Thu, 9 Jan 2025 20:08:08 +0800 Message-ID: <41B1320691916DE6+20250109120808.559950-1-wangyuli@uniontech.com> X-Mailer: git-send-email 2.47.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-QQ-S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fGToHBE2Z+Ej6X7Q2v/CVBstTF649Ur5VrKUbDDA/H8lK0p2cBtDsQH2ImYf9/GAm rqbIWFAYuAyt1/iSn6K0Y6rqk0TaT8hleoUZtWXw== X-QQ-XMRINFO: Nq+8W0+stu50PRdwbJxPCL0= X-QQ-RECHKSPAM: 0 [ General description per its product manual: ] The IT8768E-I is a highly integrated Super I/O using the Low Pin Count Interface. The device=E2=80=99s LPC interface complies with Intel "LPC Interface Specification Rev. 1.1=E2=80=9D. The IT8768E-I is ACPI & LANDesk compliant. Integrated in the IT8768E-I are five logical devices, which can be individually enabled or disabled via software configuration registers, and four 16C550standard compatible enhanced UARTs perofrmacing asynchronous communication. The devices also provide GPIO port controlling up to 12 GPIO pins. The IT8768E-I utilizes power-saving circuitry to reduce power consumption, and once a logical device is disabled, the inputs are inhibited with the clock disabled and the outputs are tri-stated. The device requires a single 24/48 MHz clock input and operates with +3.3V power supply. The IT8768E-I is available in 48-pin LQFP. It has been determined that this chip is currently employed within YIHUA STS-320 intelligent teller terminals utilizing PCBA F21-2401 D2000 MB VerA LF motherboards. Add a driver to support it. [ Kernel logs without this driver: ] [ 1.016170] EFI Variables Facility v0.08 2004-May-17 [ 1.034039] Serial: 8250/16550 driver, 32 ports, IRQ sharing enabled [ 1.035215] serial 0000:06:00.0: enabling device (0000 -> 0002) [ 1.035649] 0000:06:00.0: ttyS0 at MMIO 0x64100000 (irq =3D 31, base_b= aud =3D 7812500) is a XR17V35X [ 1.035812] 0000:06:00.0: ttyS1 at MMIO 0x64100400 (irq =3D 31, base_b= aud =3D 7812500) is a XR17V35X [ 1.035966] 0000:06:00.0: ttyS2 at MMIO 0x64100800 (irq =3D 31, base_b= aud =3D 7812500) is a XR17V35X [ 1.036119] 0000:06:00.0: ttyS3 at MMIO 0x64100c00 (irq =3D 31, base_b= aud =3D 7812500) is a XR17V35X [ 1.036271] 0000:06:00.0: ttyS4 at MMIO 0x64101000 (irq =3D 31, base_b= aud =3D 7812500) is a XR17V35X [ 1.036425] 0000:06:00.0: ttyS5 at MMIO 0x64101400 (irq =3D 31, base_b= aud =3D 7812500) is a XR17V35X [ 1.036576] 0000:06:00.0: ttyS6 at MMIO 0x64101800 (irq =3D 31, base_b= aud =3D 7812500) is a XR17V35X [ 1.036727] 0000:06:00.0: ttyS7 at MMIO 0x64101c00 (irq =3D 31, base_b= aud =3D 7812500) is a XR17V35X [ Kernel logs with this driver: ] [ 1.017777] EFI Variables Facility v0.08 2004-May-17 [ 1.036036] Serial: 8250/16550 driver, 32 ports, IRQ sharing enabled [ 1.037286] ITES0001:00: ttyS0 at MMIO 0x20000130 (irq =3D 0, base_bau= d =3D 115200) is a 16550A [ 1.037444] ITES0001:01: ttyS1 at MMIO 0x20000138 (irq =3D 0, base_bau= d =3D 115200) is a 16550A [ 1.037607] ITES0001:02: ttyS2 at MMIO 0x20000140 (irq =3D 0, base_bau= d =3D 115200) is a 16550A [ 1.037759] ITES0001:03: ttyS3 at MMIO 0x20000148 (irq =3D 0, base_bau= d =3D 115200) is a 16550A [ 1.037906] ITES0001:04: ttyS4 at MMIO 0x20000150 (irq =3D 0, base_bau= d =3D 115200) is a 16550A [ 1.038056] serial 0000:06:00.0: enabling device (0000 -> 0002) [ 1.038438] 0000:06:00.0: ttyS5 at MMIO 0x64100000 (irq =3D 31, base_b= aud =3D 7812500) is a XR17V35X [ 1.038595] 0000:06:00.0: ttyS6 at MMIO 0x64100400 (irq =3D 31, base_b= aud =3D 7812500) is a XR17V35X [ 1.038749] 0000:06:00.0: ttyS7 at MMIO 0x64100800 (irq =3D 31, base_b= aud =3D 7812500) is a XR17V35X [ 1.038907] 0000:06:00.0: ttyS8 at MMIO 0x64100c00 (irq =3D 31, base_b= aud =3D 7812500) is a XR17V35X [ 1.039059] 0000:06:00.0: ttyS9 at MMIO 0x64101000 (irq =3D 31, base_b= aud =3D 7812500) is a XR17V35X [ 1.039214] 0000:06:00.0: ttyS10 at MMIO 0x64101400 (irq =3D 31, base_= baud =3D 7812500) is a XR17V35X [ 1.039367] 0000:06:00.0: ttyS11 at MMIO 0x64101800 (irq =3D 31, base_= baud =3D 7812500) is a XR17V35X [ 1.039519] 0000:06:00.0: ttyS12 at MMIO 0x64101c00 (irq =3D 31, base_= baud =3D 7812500) is a XR17V35X Reported-by: Zhuozhen He Tested-by: Guowei Chen Signed-off-by: WangYuli --- drivers/tty/serial/8250/8250_it8768e.c | 138 +++++++++++++++++++++++++ drivers/tty/serial/8250/Kconfig | 6 ++ drivers/tty/serial/8250/Makefile | 1 + 3 files changed, 145 insertions(+) create mode 100644 drivers/tty/serial/8250/8250_it8768e.c diff --git a/drivers/tty/serial/8250/8250_it8768e.c b/drivers/tty/serial/82= 50/8250_it8768e.c new file mode 100644 index 000000000000..c2c0aeed3918 --- /dev/null +++ b/drivers/tty/serial/8250/8250_it8768e.c @@ -0,0 +1,138 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Probe for 8250/16550-type iTE IT8768E serial ports. + * + * Based on drivers/char/serial.c which is in the history, by Linus Torval= ds, Theodore Ts'o. + * + * Copyright (C) 2025 Uniontech Ltd. + * Author: WangYuli + */ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "8250.h" + +struct it8768e_data { + struct uart_8250_port uart; + int line; +}; + +static int it8768e_probe(struct platform_device *pdev) +{ + struct it8768e_data *data; + struct resource *res; + void *__iomem sio_base; + + res =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + dev_err(&pdev->dev, "memory resource not found\n"); + return -EINVAL; + } + + sio_base =3D devm_ioremap(&pdev->dev, res->start, resource_size(res)); + if (!sio_base) { + dev_err(&pdev->dev, "devm_ioremap error\n"); + return -ENOMEM; + } + + data =3D devm_kcalloc(&pdev->dev, 1, + sizeof(struct it8768e_data), + GFP_KERNEL); + if (!data) { + dev_err(&pdev->dev, "Failed to alloc private mem struct.\n"); + return -ENOMEM; + } + + spin_lock_init(&data->uart.port.lock); + data->uart.port.dev =3D &pdev->dev; + data->uart.port.regshift =3D 0; + data->uart.port.iotype =3D UPIO_MEM; + data->uart.port.type =3D PORT_16550A; + data->uart.port.membase =3D sio_base; + data->uart.port.mapbase =3D res->start; + data->uart.port.uartclk =3D 1843200; + data->uart.port.flags =3D UPF_FIXED_PORT | UPF_FIXED_TYPE | UPF_SKIP_TEST; + + data->line =3D serial8250_register_8250_port(&data->uart); + if (data->line < 0) { + dev_err(&pdev->dev, + "unable to resigter 8250 port (MEM%llx): %d\n", + (unsigned long long)res->start, 0); + return data->line; + } + + dev_set_drvdata(&pdev->dev, data); + return 0; +} + +static void it8768e_remove(struct platform_device *pdev) +{ + struct it8768e_data *data =3D dev_get_drvdata(&pdev->dev); + + if (!data) + return; + + del_timer(&data->uart.timer); + serial8250_unregister_port(data->line); +} + +#ifdef CONFIG_PM +static int it8768e_suspend(struct platform_device *pdev, pm_message_t stat= e) +{ + struct it8768e_data *data =3D dev_get_drvdata(&pdev->dev); + + if (!data) + return -ENODEV; + + serial8250_suspend_port(data->line); + return 0; +} + +static int it8768e_resume(struct platform_device *pdev) +{ + struct it8768e_data *data =3D dev_get_drvdata(&pdev->dev); + + if (!data) + return -ENODEV; + + serial8250_resume_port(data->line); + + return 0; +} +#else +#define it8768e_suspend NULL +#define it8768e_resume NULL +#endif /* PM */ + +#ifdef CONFIG_ACPI +static const struct acpi_device_id it8768e_acpi_ids[] =3D { + { .id =3D "ITES0001" }, + {} +}; +MODULE_DEVICE_TABLE(acpi, it8768e_acpi_ids); +#else +#define it8768e_acpi_ids NULL +#endif /* ACPI */ + +static struct platform_driver it8768e_driver =3D { + .probe =3D it8768e_probe, + .remove =3D it8768e_remove, + .suspend =3D it8768e_suspend, + .resume =3D it8768e_resume, + .driver =3D { + .name =3D "it8768e", + .acpi_match_table =3D it8768e_acpi_ids, + }, +}; +module_platform_driver(it8768e_driver); + +MODULE_AUTHOR("WangYuli"); +MODULE_DESCRIPTION("8250 uart driver for iTE IT8768E"); +MODULE_LICENSE("GPL"); diff --git a/drivers/tty/serial/8250/Kconfig b/drivers/tty/serial/8250/Kcon= fig index 55d26d16df9b..72e7f33d61d6 100644 --- a/drivers/tty/serial/8250/Kconfig +++ b/drivers/tty/serial/8250/Kconfig @@ -569,6 +569,12 @@ config SERIAL_8250_BCM7271 including DMA support and high accuracy BAUD rates, say Y to this option. If unsure, say N. =20 +config SERIAL_8250_IT8768E + tristate "8250 support for iTE IT8768E uart" + depends on SERIAL_8250 + help + This option is used for iTE IT8768E serial ports. + config SERIAL_OF_PLATFORM tristate "Devicetree based probing for 8250 ports" depends on SERIAL_8250 && OF diff --git a/drivers/tty/serial/8250/Makefile b/drivers/tty/serial/8250/Mak= efile index 1516de629b61..97bbf05a49bd 100644 --- a/drivers/tty/serial/8250/Makefile +++ b/drivers/tty/serial/8250/Makefile @@ -35,6 +35,7 @@ obj-$(CONFIG_SERIAL_8250_HP300) +=3D 8250_hp300.o obj-$(CONFIG_SERIAL_8250_HUB6) +=3D 8250_hub6.o obj-$(CONFIG_SERIAL_8250_INGENIC) +=3D 8250_ingenic.o obj-$(CONFIG_SERIAL_8250_IOC3) +=3D 8250_ioc3.o +obj-$(CONFIG_SERIAL_8250_IT8768E) +=3D 8250_it8768e.o obj-$(CONFIG_SERIAL_8250_LPC18XX) +=3D 8250_lpc18xx.o obj-$(CONFIG_SERIAL_8250_LPSS) +=3D 8250_lpss.o obj-$(CONFIG_SERIAL_8250_MEN_MCB) +=3D 8250_men_mcb.o --=20 2.47.1