Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  *  Registration of Cobalt UART platform device.
0004  *
0005  *  Copyright (C) 2007  Yoichi Yuasa <yuasa@linux-mips.org>
0006  */
0007 #include <linux/errno.h>
0008 #include <linux/init.h>
0009 #include <linux/ioport.h>
0010 #include <linux/platform_device.h>
0011 #include <linux/serial_8250.h>
0012 
0013 #include <cobalt.h>
0014 #include <irq.h>
0015 
0016 static struct resource cobalt_uart_resource[] __initdata = {
0017     {
0018         .start  = 0x1c800000,
0019         .end    = 0x1c800007,
0020         .flags  = IORESOURCE_MEM,
0021     },
0022     {
0023         .start  = SERIAL_IRQ,
0024         .end    = SERIAL_IRQ,
0025         .flags  = IORESOURCE_IRQ,
0026     },
0027 };
0028 
0029 static struct plat_serial8250_port cobalt_serial8250_port[] = {
0030     {
0031         .irq        = SERIAL_IRQ,
0032         .uartclk    = 18432000,
0033         .iotype     = UPIO_MEM,
0034         .flags      = UPF_IOREMAP | UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
0035         .mapbase    = 0x1c800000,
0036     },
0037     {},
0038 };
0039 
0040 static __init int cobalt_uart_add(void)
0041 {
0042     struct platform_device *pdev;
0043     int retval;
0044 
0045     /*
0046      * Cobalt Qube1 has no UART.
0047      */
0048     if (cobalt_board_id == COBALT_BRD_ID_QUBE1)
0049         return 0;
0050 
0051     pdev = platform_device_alloc("serial8250", -1);
0052     if (!pdev)
0053         return -ENOMEM;
0054 
0055     pdev->id = PLAT8250_DEV_PLATFORM;
0056     pdev->dev.platform_data = cobalt_serial8250_port;
0057 
0058     retval = platform_device_add_resources(pdev, cobalt_uart_resource, ARRAY_SIZE(cobalt_uart_resource));
0059     if (retval)
0060         goto err_free_device;
0061 
0062     retval = platform_device_add(pdev);
0063     if (retval)
0064         goto err_free_device;
0065 
0066     return 0;
0067 
0068 err_free_device:
0069     platform_device_put(pdev);
0070 
0071     return retval;
0072 }
0073 device_initcall(cobalt_uart_add);