mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 04:15:07 +07:00
4793f2ebff
Now that the SPDX tag is in all tty files, that identifies the license in a specific and legally-defined manner. So the extra GPL text wording can be removed as it is no longer needed at all. This is done on a quest to remove the 700+ different ways that files in the kernel describe the GPL license text. And there's unneeded stuff like the address (sometimes incorrect) for the FSF which is never needed. No copyright headers or other non-license-description text was removed. Cc: Jiri Slaby <jslaby@suse.com> Cc: Eric Anholt <eric@anholt.net> Cc: Stefan Wahren <stefan.wahren@i2se.com> Cc: Florian Fainelli <f.fainelli@gmail.com> Cc: Ray Jui <rjui@broadcom.com> Cc: Scott Branden <sbranden@broadcom.com> Cc: bcm-kernel-feedback-list@broadcom.com Cc: "James E.J. Bottomley" <jejb@parisc-linux.org> Cc: Helge Deller <deller@gmx.de> Cc: Joachim Eastwood <manabian@gmail.com> Cc: Matthias Brugger <matthias.bgg@gmail.com> Cc: Masahiro Yamada <yamada.masahiro@socionext.com> Cc: Tobias Klauser <tklauser@distanz.ch> Cc: Russell King <linux@armlinux.org.uk> Cc: Vineet Gupta <vgupta@synopsys.com> Cc: Richard Genoud <richard.genoud@gmail.com> Cc: Alexander Shiyan <shc_work@mail.ru> Cc: Baruch Siach <baruch@tkos.co.il> Cc: Pat Gefre <pfg@sgi.com> Cc: "Guilherme G. Piccoli" <gpiccoli@linux.vnet.ibm.com> Cc: Jason Wessel <jason.wessel@windriver.com> Cc: Vladimir Zapolskiy <vz@mleia.com> Cc: Sylvain Lemieux <slemieux.tyco@gmail.com> Cc: Carlo Caione <carlo@caione.org> Cc: Kevin Hilman <khilman@baylibre.com> Cc: Liviu Dudau <liviu.dudau@arm.com> Cc: Sudeep Holla <sudeep.holla@arm.com> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Cc: Andy Gross <andy.gross@linaro.org> Cc: David Brown <david.brown@linaro.org> Cc: "Andreas Färber" <afaerber@suse.de> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Kevin Cernekee <cernekee@gmail.com> Cc: Laxman Dewangan <ldewangan@nvidia.com> Cc: Thierry Reding <thierry.reding@gmail.com> Cc: Jonathan Hunter <jonathanh@nvidia.com> Cc: Barry Song <baohua@kernel.org> Cc: Patrice Chotard <patrice.chotard@st.com> Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com> Cc: Alexandre Torgue <alexandre.torgue@st.com> Cc: Chris Metcalf <cmetcalf@mellanox.com> Cc: Peter Korsgaard <jacmet@sunsite.dk> Cc: Timur Tabi <timur@tabi.org> Cc: Tony Prisk <linux@prisktech.co.nz> Cc: Michal Simek <michal.simek@xilinx.com> Cc: "Sören Brinkmann" <soren.brinkmann@xilinx.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
159 lines
4.0 KiB
C
159 lines
4.0 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Renesas Emma Mobile 8250 driver
|
|
*
|
|
* Copyright (C) 2012 Magnus Damm
|
|
*/
|
|
|
|
#include <linux/device.h>
|
|
#include <linux/io.h>
|
|
#include <linux/module.h>
|
|
#include <linux/serial_8250.h>
|
|
#include <linux/serial_reg.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/clk.h>
|
|
#include <linux/slab.h>
|
|
|
|
#include "8250.h"
|
|
|
|
#define UART_DLL_EM 9
|
|
#define UART_DLM_EM 10
|
|
|
|
struct serial8250_em_priv {
|
|
struct clk *sclk;
|
|
int line;
|
|
};
|
|
|
|
static void serial8250_em_serial_out(struct uart_port *p, int offset, int value)
|
|
{
|
|
switch (offset) {
|
|
case UART_TX: /* TX @ 0x00 */
|
|
writeb(value, p->membase);
|
|
break;
|
|
case UART_FCR: /* FCR @ 0x0c (+1) */
|
|
case UART_LCR: /* LCR @ 0x10 (+1) */
|
|
case UART_MCR: /* MCR @ 0x14 (+1) */
|
|
case UART_SCR: /* SCR @ 0x20 (+1) */
|
|
writel(value, p->membase + ((offset + 1) << 2));
|
|
break;
|
|
case UART_IER: /* IER @ 0x04 */
|
|
value &= 0x0f; /* only 4 valid bits - not Xscale */
|
|
/* fall-through */
|
|
case UART_DLL_EM: /* DLL @ 0x24 (+9) */
|
|
case UART_DLM_EM: /* DLM @ 0x28 (+9) */
|
|
writel(value, p->membase + (offset << 2));
|
|
}
|
|
}
|
|
|
|
static unsigned int serial8250_em_serial_in(struct uart_port *p, int offset)
|
|
{
|
|
switch (offset) {
|
|
case UART_RX: /* RX @ 0x00 */
|
|
return readb(p->membase);
|
|
case UART_MCR: /* MCR @ 0x14 (+1) */
|
|
case UART_LSR: /* LSR @ 0x18 (+1) */
|
|
case UART_MSR: /* MSR @ 0x1c (+1) */
|
|
case UART_SCR: /* SCR @ 0x20 (+1) */
|
|
return readl(p->membase + ((offset + 1) << 2));
|
|
case UART_IER: /* IER @ 0x04 */
|
|
case UART_IIR: /* IIR @ 0x08 */
|
|
case UART_DLL_EM: /* DLL @ 0x24 (+9) */
|
|
case UART_DLM_EM: /* DLM @ 0x28 (+9) */
|
|
return readl(p->membase + (offset << 2));
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static int serial8250_em_serial_dl_read(struct uart_8250_port *up)
|
|
{
|
|
return serial_in(up, UART_DLL_EM) | serial_in(up, UART_DLM_EM) << 8;
|
|
}
|
|
|
|
static void serial8250_em_serial_dl_write(struct uart_8250_port *up, int value)
|
|
{
|
|
serial_out(up, UART_DLL_EM, value & 0xff);
|
|
serial_out(up, UART_DLM_EM, value >> 8 & 0xff);
|
|
}
|
|
|
|
static int serial8250_em_probe(struct platform_device *pdev)
|
|
{
|
|
struct resource *regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
struct resource *irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
|
|
struct serial8250_em_priv *priv;
|
|
struct uart_8250_port up;
|
|
int ret;
|
|
|
|
if (!regs || !irq) {
|
|
dev_err(&pdev->dev, "missing registers or irq\n");
|
|
return -EINVAL;
|
|
}
|
|
|
|
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
|
|
if (!priv)
|
|
return -ENOMEM;
|
|
|
|
priv->sclk = devm_clk_get(&pdev->dev, "sclk");
|
|
if (IS_ERR(priv->sclk)) {
|
|
dev_err(&pdev->dev, "unable to get clock\n");
|
|
return PTR_ERR(priv->sclk);
|
|
}
|
|
|
|
memset(&up, 0, sizeof(up));
|
|
up.port.mapbase = regs->start;
|
|
up.port.irq = irq->start;
|
|
up.port.type = PORT_UNKNOWN;
|
|
up.port.flags = UPF_BOOT_AUTOCONF | UPF_FIXED_PORT | UPF_IOREMAP;
|
|
up.port.dev = &pdev->dev;
|
|
up.port.private_data = priv;
|
|
|
|
clk_prepare_enable(priv->sclk);
|
|
up.port.uartclk = clk_get_rate(priv->sclk);
|
|
|
|
up.port.iotype = UPIO_MEM32;
|
|
up.port.serial_in = serial8250_em_serial_in;
|
|
up.port.serial_out = serial8250_em_serial_out;
|
|
up.dl_read = serial8250_em_serial_dl_read;
|
|
up.dl_write = serial8250_em_serial_dl_write;
|
|
|
|
ret = serial8250_register_8250_port(&up);
|
|
if (ret < 0) {
|
|
dev_err(&pdev->dev, "unable to register 8250 port\n");
|
|
clk_disable_unprepare(priv->sclk);
|
|
return ret;
|
|
}
|
|
|
|
priv->line = ret;
|
|
platform_set_drvdata(pdev, priv);
|
|
return 0;
|
|
}
|
|
|
|
static int serial8250_em_remove(struct platform_device *pdev)
|
|
{
|
|
struct serial8250_em_priv *priv = platform_get_drvdata(pdev);
|
|
|
|
serial8250_unregister_port(priv->line);
|
|
clk_disable_unprepare(priv->sclk);
|
|
return 0;
|
|
}
|
|
|
|
static const struct of_device_id serial8250_em_dt_ids[] = {
|
|
{ .compatible = "renesas,em-uart", },
|
|
{},
|
|
};
|
|
MODULE_DEVICE_TABLE(of, serial8250_em_dt_ids);
|
|
|
|
static struct platform_driver serial8250_em_platform_driver = {
|
|
.driver = {
|
|
.name = "serial8250-em",
|
|
.of_match_table = serial8250_em_dt_ids,
|
|
},
|
|
.probe = serial8250_em_probe,
|
|
.remove = serial8250_em_remove,
|
|
};
|
|
|
|
module_platform_driver(serial8250_em_platform_driver);
|
|
|
|
MODULE_AUTHOR("Magnus Damm");
|
|
MODULE_DESCRIPTION("Renesas Emma Mobile 8250 Driver");
|
|
MODULE_LICENSE("GPL v2");
|