mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-28 20:02:17 +00:00
![Linus Torvalds](/assets/img/avatar_default.png)
This is a merge error on my part - the driver was merged into mainline by commitc5951e7c8e
("Merge tag 'mips_5.6' of git://../mips/linux") over a week ago, but nobody apparently noticed that it didn't actually build due to still having a reference to the devm_ioremap_nocache() function, removed a few days earlier through commit6a1000bd27
("Merge tag 'ioremap-5.6' of git://../ioremap"). Apparently this didn't get any build testing anywhere. Not perhaps all that surprising: it's restricted to 64-bit MIPS only, and only with the new SGI_MFD_IOC3 support enabled. I only noticed because the ioremap conflicts in the ARM SoC driver update made me check there weren't any others hiding, and I found this one. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
98 lines
2.3 KiB
C
98 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 <kumba@gentoo.org>
|
|
*/
|
|
|
|
#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 unsigned int ioc3_serial_in(struct uart_port *p, int offset)
|
|
{
|
|
return readb(p->membase + (offset ^ 3));
|
|
}
|
|
|
|
static void ioc3_serial_out(struct uart_port *p, int offset, int 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 int serial8250_ioc3_remove(struct platform_device *pdev)
|
|
{
|
|
struct ioc3_8250_data *data = platform_get_drvdata(pdev);
|
|
|
|
serial8250_unregister_port(data->line);
|
|
return 0;
|
|
}
|
|
|
|
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");
|