John Crispin | 8ec6d93 | 2011-03-30 09:27:48 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This program is free software; you can redistribute it and/or modify it |
| 3 | * under the terms of the GNU General Public License version 2 as published |
| 4 | * by the Free Software Foundation. |
| 5 | * |
| 6 | * EBU - the external bus unit attaches PCI, NOR and NAND |
| 7 | * |
| 8 | * Copyright (C) 2010 John Crispin <blogic@openwrt.org> |
| 9 | */ |
| 10 | |
| 11 | #include <linux/kernel.h> |
| 12 | #include <linux/module.h> |
John Crispin | 8ec6d93 | 2011-03-30 09:27:48 +0200 | [diff] [blame] | 13 | #include <linux/ioport.h> |
| 14 | |
| 15 | #include <lantiq_soc.h> |
| 16 | |
| 17 | /* all access to the ebu must be locked */ |
| 18 | DEFINE_SPINLOCK(ebu_lock); |
| 19 | EXPORT_SYMBOL_GPL(ebu_lock); |
| 20 | |
| 21 | static struct resource ltq_ebu_resource = { |
| 22 | .name = "ebu", |
| 23 | .start = LTQ_EBU_BASE_ADDR, |
| 24 | .end = LTQ_EBU_BASE_ADDR + LTQ_EBU_SIZE - 1, |
| 25 | .flags = IORESOURCE_MEM, |
| 26 | }; |
| 27 | |
| 28 | /* remapped base addr of the clock unit and external bus unit */ |
| 29 | void __iomem *ltq_ebu_membase; |
| 30 | |
| 31 | static int __init lantiq_ebu_init(void) |
| 32 | { |
| 33 | /* insert and request the memory region */ |
| 34 | if (insert_resource(&iomem_resource, <q_ebu_resource) < 0) |
Ralf Baechle | ab75dc0 | 2011-11-17 15:07:31 +0000 | [diff] [blame] | 35 | panic("Failed to insert ebu memory"); |
John Crispin | 8ec6d93 | 2011-03-30 09:27:48 +0200 | [diff] [blame] | 36 | |
| 37 | if (request_mem_region(ltq_ebu_resource.start, |
| 38 | resource_size(<q_ebu_resource), "ebu") < 0) |
Ralf Baechle | ab75dc0 | 2011-11-17 15:07:31 +0000 | [diff] [blame] | 39 | panic("Failed to request ebu memory"); |
John Crispin | 8ec6d93 | 2011-03-30 09:27:48 +0200 | [diff] [blame] | 40 | |
| 41 | /* remap ebu register range */ |
| 42 | ltq_ebu_membase = ioremap_nocache(ltq_ebu_resource.start, |
| 43 | resource_size(<q_ebu_resource)); |
| 44 | if (!ltq_ebu_membase) |
Ralf Baechle | ab75dc0 | 2011-11-17 15:07:31 +0000 | [diff] [blame] | 45 | panic("Failed to remap ebu memory"); |
John Crispin | 8ec6d93 | 2011-03-30 09:27:48 +0200 | [diff] [blame] | 46 | |
| 47 | /* make sure to unprotect the memory region where flash is located */ |
| 48 | ltq_ebu_w32(ltq_ebu_r32(LTQ_EBU_BUSCON0) & ~EBU_WRDIS, LTQ_EBU_BUSCON0); |
| 49 | return 0; |
| 50 | } |
| 51 | |
| 52 | postcore_initcall(lantiq_ebu_init); |