This source file includes following definitions.
- lasat_uart_add
1
2
3
4
5
6
7 #include <linux/errno.h>
8 #include <linux/init.h>
9 #include <linux/ioport.h>
10 #include <linux/platform_device.h>
11 #include <linux/serial_8250.h>
12
13 #include <asm/lasat/lasat.h>
14 #include <asm/lasat/serial.h>
15
16 static struct resource lasat_serial_res[2] __initdata;
17
18 static struct plat_serial8250_port lasat_serial8250_port[] = {
19 {
20 .iotype = UPIO_MEM,
21 .flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF |
22 UPF_SKIP_TEST,
23 },
24 {},
25 };
26
27 static __init int lasat_uart_add(void)
28 {
29 struct platform_device *pdev;
30 int retval;
31
32 pdev = platform_device_alloc("serial8250", -1);
33 if (!pdev)
34 return -ENOMEM;
35
36 if (!IS_LASAT_200()) {
37 lasat_serial_res[0].start = KSEG1ADDR(LASAT_UART_REGS_BASE_100);
38 lasat_serial_res[0].end = lasat_serial_res[0].start + LASAT_UART_REGS_SHIFT_100 * 8 - 1;
39 lasat_serial_res[0].flags = IORESOURCE_MEM;
40 lasat_serial_res[1].start = LASATINT_UART_100;
41 lasat_serial_res[1].end = LASATINT_UART_100;
42 lasat_serial_res[1].flags = IORESOURCE_IRQ;
43
44 lasat_serial8250_port[0].mapbase = LASAT_UART_REGS_BASE_100;
45 lasat_serial8250_port[0].uartclk = LASAT_BASE_BAUD_100 * 16;
46 lasat_serial8250_port[0].regshift = LASAT_UART_REGS_SHIFT_100;
47 lasat_serial8250_port[0].irq = LASATINT_UART_100;
48 } else {
49 lasat_serial_res[0].start = KSEG1ADDR(LASAT_UART_REGS_BASE_200);
50 lasat_serial_res[0].end = lasat_serial_res[0].start + LASAT_UART_REGS_SHIFT_200 * 8 - 1;
51 lasat_serial_res[0].flags = IORESOURCE_MEM;
52 lasat_serial_res[1].start = LASATINT_UART_200;
53 lasat_serial_res[1].end = LASATINT_UART_200;
54 lasat_serial_res[1].flags = IORESOURCE_IRQ;
55
56 lasat_serial8250_port[0].mapbase = LASAT_UART_REGS_BASE_200;
57 lasat_serial8250_port[0].uartclk = LASAT_BASE_BAUD_200 * 16;
58 lasat_serial8250_port[0].regshift = LASAT_UART_REGS_SHIFT_200;
59 lasat_serial8250_port[0].irq = LASATINT_UART_200;
60 }
61
62 pdev->id = PLAT8250_DEV_PLATFORM;
63 pdev->dev.platform_data = lasat_serial8250_port;
64
65 retval = platform_device_add_resources(pdev, lasat_serial_res, ARRAY_SIZE(lasat_serial_res));
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(lasat_uart_add);