Uwe Kleine-König | 210b94e | 2008-01-31 14:20:21 +0100 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-ns9xxx/plat-serial8250.c |
| 3 | * |
| 4 | * Copyright (C) 2008 by Digi International Inc. |
| 5 | * All rights reserved. |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU General Public License version 2 as published by |
| 9 | * the Free Software Foundation. |
| 10 | */ |
| 11 | #include <linux/platform_device.h> |
| 12 | #include <linux/serial_8250.h> |
| 13 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 14 | #include <mach/regs-board-a9m9750dev.h> |
| 15 | #include <mach/board.h> |
Uwe Kleine-König | 210b94e | 2008-01-31 14:20:21 +0100 | [diff] [blame] | 16 | |
| 17 | #define DRIVER_NAME "serial8250" |
| 18 | |
| 19 | static int __init ns9xxx_plat_serial8250_init(void) |
| 20 | { |
| 21 | struct plat_serial8250_port *pdata; |
| 22 | struct platform_device *pdev; |
| 23 | int ret = -ENOMEM; |
| 24 | int i; |
| 25 | |
| 26 | if (!board_is_a9m9750dev()) |
| 27 | return -ENODEV; |
| 28 | |
| 29 | pdev = platform_device_alloc(DRIVER_NAME, 0); |
| 30 | if (!pdev) |
| 31 | goto err; |
| 32 | |
| 33 | pdata = kzalloc(5 * sizeof(*pdata), GFP_KERNEL); |
| 34 | if (!pdata) |
| 35 | goto err; |
| 36 | |
| 37 | pdev->dev.platform_data = pdata; |
| 38 | |
| 39 | pdata[0].iobase = FPGA_UARTA_BASE; |
| 40 | pdata[1].iobase = FPGA_UARTB_BASE; |
| 41 | pdata[2].iobase = FPGA_UARTC_BASE; |
| 42 | pdata[3].iobase = FPGA_UARTD_BASE; |
| 43 | |
| 44 | for (i = 0; i < 4; ++i) { |
| 45 | pdata[i].membase = (void __iomem *)pdata[i].iobase; |
| 46 | pdata[i].mapbase = pdata[i].iobase; |
| 47 | pdata[i].iotype = UPIO_MEM; |
| 48 | pdata[i].uartclk = 18432000; |
| 49 | pdata[i].flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ; |
| 50 | } |
| 51 | |
| 52 | pdata[0].irq = IRQ_FPGA_UARTA; |
| 53 | pdata[1].irq = IRQ_FPGA_UARTB; |
| 54 | pdata[2].irq = IRQ_FPGA_UARTC; |
| 55 | pdata[3].irq = IRQ_FPGA_UARTD; |
| 56 | |
| 57 | ret = platform_device_add(pdev); |
| 58 | if (ret) { |
| 59 | err: |
| 60 | platform_device_put(pdev); |
| 61 | |
| 62 | printk(KERN_WARNING "Could not add %s (errno=%d)\n", |
| 63 | DRIVER_NAME, ret); |
| 64 | } |
| 65 | |
| 66 | return 0; |
| 67 | } |
| 68 | |
| 69 | arch_initcall(ns9xxx_plat_serial8250_init); |