| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* linux/drivers/serial/bast_sio.c | 
|  | 2 | * | 
|  | 3 | * Copyright (c) 2004 Simtec Electronics | 
|  | 4 | *   Ben Dooks <ben@simtec.co.uk> | 
|  | 5 | * | 
|  | 6 | * http://www.simtec.co.uk/products/EB2410ITX/ | 
|  | 7 | * | 
|  | 8 | * This program is free software; you can redistribute it and/or modify | 
|  | 9 | * it under the terms of the GNU General Public License version 2 as | 
|  | 10 | * published by the Free Software Foundation. | 
|  | 11 | * | 
|  | 12 | * Modifications: | 
|  | 13 | *	23-Sep-2004  BJD  Added copyright header | 
|  | 14 | *	23-Sep-2004  BJD  Added serial port remove code | 
|  | 15 | */ | 
|  | 16 |  | 
|  | 17 | #include <linux/module.h> | 
|  | 18 | #include <linux/config.h> | 
|  | 19 | #include <linux/kernel.h> | 
|  | 20 | #include <linux/init.h> | 
|  | 21 | #include <linux/tty.h> | 
|  | 22 | #include <linux/serial.h> | 
|  | 23 | #include <linux/serial_core.h> | 
|  | 24 | #include <linux/types.h> | 
|  | 25 |  | 
|  | 26 | #include <asm/io.h> | 
|  | 27 | #include <asm/serial.h> | 
|  | 28 | #include <asm/mach-types.h> | 
|  | 29 |  | 
|  | 30 | #include <asm/arch/map.h> | 
|  | 31 | #include <asm/arch/irqs.h> | 
|  | 32 | #include <asm/arch/bast-map.h> | 
|  | 33 | #include <asm/arch/bast-irq.h> | 
|  | 34 |  | 
|  | 35 | static int __init serial_bast_register(unsigned long port, unsigned int irq) | 
|  | 36 | { | 
|  | 37 | struct serial_struct serial_req; | 
|  | 38 |  | 
|  | 39 | serial_req.flags      = UPF_AUTOPROBE | UPF_SHARE_IRQ; | 
|  | 40 | serial_req.baud_base  = BASE_BAUD; | 
|  | 41 | serial_req.irq        = irq; | 
|  | 42 | serial_req.io_type    = UPIO_MEM; | 
|  | 43 | serial_req.iomap_base = port; | 
|  | 44 | serial_req.iomem_base = ioremap(port, 0x10); | 
|  | 45 | serial_req.iomem_reg_shift = 0; | 
|  | 46 |  | 
|  | 47 | return register_serial(&serial_req); | 
|  | 48 | } | 
|  | 49 |  | 
|  | 50 | #define SERIAL_BASE (S3C2410_CS2 + BAST_PA_SUPERIO) | 
|  | 51 |  | 
|  | 52 | static int port[2] = { -1, -1 }; | 
|  | 53 |  | 
|  | 54 | static int __init serial_bast_init(void) | 
|  | 55 | { | 
|  | 56 | if (machine_is_bast()) { | 
|  | 57 | port[0] = serial_bast_register(SERIAL_BASE + 0x2f8, IRQ_PCSERIAL1); | 
|  | 58 | port[1] = serial_bast_register(SERIAL_BASE + 0x3f8, IRQ_PCSERIAL2); | 
|  | 59 | } | 
|  | 60 |  | 
|  | 61 | return 0; | 
|  | 62 | } | 
|  | 63 |  | 
|  | 64 | static void __exit serial_bast_exit(void) | 
|  | 65 | { | 
|  | 66 | if (port[0] != -1) | 
|  | 67 | unregister_serial(port[0]); | 
|  | 68 | if (port[1] != -1) | 
|  | 69 | unregister_serial(port[1]); | 
|  | 70 | } | 
|  | 71 |  | 
|  | 72 |  | 
|  | 73 | module_init(serial_bast_init); | 
|  | 74 | module_exit(serial_bast_exit); | 
|  | 75 |  | 
|  | 76 | MODULE_LICENSE("GPL"); | 
|  | 77 | MODULE_AUTHOR("Ben Dooks, ben@simtec.co.uk"); | 
|  | 78 | MODULE_DESCRIPTION("BAST Onboard Serial setup"); | 
|  | 79 |  | 
|  | 80 |  |