linux/drivers/tty/serial/8250/8250_ioc3.c
Linus Torvalds f1aa129d80 DT updates for ralink, mobileye and ralink
Clean up of mc146818 usage
 Speed up delay calibration for CPS
 Other cleanups and fixes
 -----BEGIN PGP SIGNATURE-----
 
 iQJOBAABCAA4FiEEbt46xwy6kEcDOXoUeZbBVTGwZHAFAmiKJdMaHHRzYm9nZW5k
 QGFscGhhLmZyYW5rZW4uZGUACgkQeZbBVTGwZHCJYA/9HzXnlEbszpTAQl/1BEYY
 sr0AQDjJCnDKep9/nnWilAEZrBRNJ6wkv64MIzEN59gpDc5EKbZrTA8AJkwr34Rt
 TJqnpaeAGyErJwc/1VZvlDUUlsySOd5sAhQ7v2HdhSn4txMAbEY5SXW1EfmfFx5q
 Uj9Ku6Llr8xP29QA75CG2uOfS/wxc0zPio9ykxZxnvk4SL7QqzCaSMYJndJ2GqKg
 GTFlbgkpFjlAidJuflijM4ZN4oE7PG6ZhFUSJOBpdML4lzbEsx5e9zWxfVFjh8Db
 ZFOuIlpvwzn4+nAc7V3ywc5+7YoCrrBL6HbR5VIy4VAz0ktjp5sV6OBFi8izDIEe
 2ncOJXS/Dc0NjY4GBagigwlB1r85+kW2bZVCp2naSXNnUJvqjDW/kRVw/bLVIWMv
 AiWxNJMYFAvmK28i52PRMu2i8HeAy3jaYj26Gy9cBAayNRs807y21rKkutO1x65h
 3cQTjTzOB9p1zCs3yOPg9s+oOz/okpnLfQFt5fty1mVzHAn7lV9JLArwdW36mLO8
 6GeQzxlKrgQZyBvCdtzDCNncCnp/q2rLPLbiZslJmAZFV76wkkLzNpSR2LUl5NYx
 /ShFcQQNVSrfuMk4tWS8zeFdaTMSBDSDM+gdx9yQBrA+tZVgqhBz3GtsjXM84HOj
 HDBBLtmJ6CFJeY2b3k7odqo=
 =H2nx
 -----END PGP SIGNATURE-----

Merge tag 'mips_6.17' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux

Pull MIPS updates from Thomas Bogendoerfer:

 - DT updates for ralink, mobileye and atheros/qualcomm

 - Clean up of mc146818 usage

 - Speed up delay calibration for CPS

 - Other cleanups and fixes

* tag 'mips_6.17' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux: (50 commits)
  MIPS: Don't use %pK through printk
  MIPS: Update Joshua Kinard's e-mail address
  MIPS: mobileye: dts: eyeq5,eyeq6h: rename the emmc controller
  MIPS: mm: tlb-r4k: Uniquify TLB entries on init
  MIPS: SGI-IP27: Delete an unnecessary check before kfree() in hub_domain_free()
  mips/malta,loongson2ef: use generic mc146818_get_time function
  mips: remove redundant macro mc146818_decode_year
  mips/mach-rm: remove custom mc146818rtc.h file
  mips: remove unused function mc146818_set_rtc_mmss
  MIPS: CPS: Optimise delay CPU calibration for SMP
  MIPS: CPS: Improve mips_cps_first_online_in_cluster()
  MIPS: disable MMID when not supported by the hardware
  MIPS: eyeq5_defconfig: add I2C subsystem, driver and temp sensor driver
  MIPS: eyeq5_defconfig: add GPIO subsystem & driver
  MIPS: mobileye: eyeq5: add two GPIO bank nodes
  MIPS: mobileye: eyeq5: add evaluation board I2C temp sensor
  MIPS: mobileye: eyeq5: add 5 I2C controller nodes
  MIPS: eyeq5_defconfig: Update for v6.16-rc1
  MIPS: vpe-mt: add missing prototypes for vpe_{alloc,start,stop,free}
  mips: boot: use 'targets' instead of extra-y in Makefile
  ...
2025-07-31 11:08:55 -07:00

97 lines
2.3 KiB
C

// SPDX-License-Identifier: GPL-2.0
/*
* SGI IOC3 8250 UART driver
*
* Copyright (C) 2019 Thomas Bogendoerfer <tbogendoerfer@suse.de>
*
* based on code Copyright (C) 2005 Stanislaw Skowronek <skylark@unaligned.org>
* Copyright (C) 2014 Joshua Kinard <linux@kumba.dev>
*/
#include <linux/module.h>
#include <linux/errno.h>
#include <linux/io.h>
#include <linux/platform_device.h>
#include "8250.h"
#define IOC3_UARTCLK (22000000 / 3)
struct ioc3_8250_data {
int line;
};
static u32 ioc3_serial_in(struct uart_port *p, unsigned int offset)
{
return readb(p->membase + (offset ^ 3));
}
static void ioc3_serial_out(struct uart_port *p, unsigned int offset, u32 value)
{
writeb(value, p->membase + (offset ^ 3));
}
static int serial8250_ioc3_probe(struct platform_device *pdev)
{
struct ioc3_8250_data *data;
struct uart_8250_port up;
struct resource *r;
void __iomem *membase;
int irq, line;
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!r)
return -ENODEV;
data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
membase = devm_ioremap(&pdev->dev, r->start, resource_size(r));
if (!membase)
return -ENOMEM;
irq = platform_get_irq(pdev, 0);
if (irq < 0)
irq = 0; /* no interrupt -> use polling */
/* Register serial ports with 8250.c */
memset(&up, 0, sizeof(struct uart_8250_port));
up.port.iotype = UPIO_MEM;
up.port.uartclk = IOC3_UARTCLK;
up.port.type = PORT_16550A;
up.port.irq = irq;
up.port.flags = (UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ);
up.port.dev = &pdev->dev;
up.port.membase = membase;
up.port.mapbase = r->start;
up.port.serial_in = ioc3_serial_in;
up.port.serial_out = ioc3_serial_out;
line = serial8250_register_8250_port(&up);
if (line < 0)
return line;
platform_set_drvdata(pdev, data);
return 0;
}
static void serial8250_ioc3_remove(struct platform_device *pdev)
{
struct ioc3_8250_data *data = platform_get_drvdata(pdev);
serial8250_unregister_port(data->line);
}
static struct platform_driver serial8250_ioc3_driver = {
.probe = serial8250_ioc3_probe,
.remove = serial8250_ioc3_remove,
.driver = {
.name = "ioc3-serial8250",
}
};
module_platform_driver(serial8250_ioc3_driver);
MODULE_AUTHOR("Thomas Bogendoerfer <tbogendoerfer@suse.de>");
MODULE_DESCRIPTION("SGI IOC3 8250 UART driver");
MODULE_LICENSE("GPL");