Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
serial.c
Go to the documentation of this file.
1 /*
2  * Registration of WRPPMC UART platform device.
3  *
4  * Copyright (C) 2007 Yoichi Yuasa <[email protected]>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 #include <linux/errno.h>
21 #include <linux/init.h>
22 #include <linux/ioport.h>
23 #include <linux/platform_device.h>
24 #include <linux/serial_8250.h>
25 
26 #include <asm/gt64120.h>
27 
28 static struct resource wrppmc_uart_resource[] __initdata = {
29  {
30  .start = WRPPMC_UART16550_BASE,
31  .end = WRPPMC_UART16550_BASE + 7,
32  .flags = IORESOURCE_MEM,
33  },
34  {
35  .start = WRPPMC_UART16550_IRQ,
36  .end = WRPPMC_UART16550_IRQ,
37  .flags = IORESOURCE_IRQ,
38  },
39 };
40 
41 static struct plat_serial8250_port wrppmc_serial8250_port[] = {
42  {
43  .irq = WRPPMC_UART16550_IRQ,
44  .uartclk = WRPPMC_UART16550_CLOCK,
45  .iotype = UPIO_MEM,
46  .flags = UPF_IOREMAP | UPF_SKIP_TEST,
47  .mapbase = WRPPMC_UART16550_BASE,
48  },
49  {},
50 };
51 
52 static __init int wrppmc_uart_add(void)
53 {
54  struct platform_device *pdev;
55  int retval;
56 
57  pdev = platform_device_alloc("serial8250", -1);
58  if (!pdev)
59  return -ENOMEM;
60 
61  pdev->id = PLAT8250_DEV_PLATFORM;
62  pdev->dev.platform_data = wrppmc_serial8250_port;
63 
64  retval = platform_device_add_resources(pdev, wrppmc_uart_resource,
65  ARRAY_SIZE(wrppmc_uart_resource));
66  if (retval)
67  goto err_free_device;
68 
69  retval = platform_device_add(pdev);
70  if (retval)
71  goto err_free_device;
72 
73  return 0;
74 
75 err_free_device:
76  platform_device_put(pdev);
77 
78  return retval;
79 }
80 device_initcall(wrppmc_uart_add);