summaryrefslogtreecommitdiff
path: root/arch/mips/lantiq/xway/ebu.c
blob: 419b47b70f325b23b6ee67c93d3946f24dc66235 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
 *  This program is free software; you can redistribute it and/or modify it
 *  under the terms of the GNU General Public License version 2 as published
 *  by the Free Software Foundation.
 *
 *  EBU - the external bus unit attaches PCI, NOR and NAND
 *
 *  Copyright (C) 2010 John Crispin <blogic@openwrt.org>
 */

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/ioport.h>

#include <lantiq_soc.h>

static struct resource ltq_ebu_resource = {
	.name	= "ebu",
	.start	= LTQ_EBU_BASE_ADDR,
	.end	= LTQ_EBU_BASE_ADDR + LTQ_EBU_SIZE - 1,
	.flags	= IORESOURCE_MEM,
};

/* remapped base addr of the clock unit and external bus unit */
void __iomem *ltq_ebu_membase;

static int __init lantiq_ebu_init(void)
{
	/* insert and request the memory region */
	if (insert_resource(&iomem_resource, &ltq_ebu_resource) < 0)
		panic("Failed to insert ebu memory");

	if (request_mem_region(ltq_ebu_resource.start,
			resource_size(&ltq_ebu_resource), "ebu") < 0)
		panic("Failed to request ebu memory");

	/* remap ebu register range */
	ltq_ebu_membase = ioremap_nocache(ltq_ebu_resource.start,
				resource_size(&ltq_ebu_resource));
	if (!ltq_ebu_membase)
		panic("Failed to remap ebu memory");

	/* make sure to unprotect the memory region where flash is located */
	ltq_ebu_w32(ltq_ebu_r32(LTQ_EBU_BUSCON0) & ~EBU_WRDIS, LTQ_EBU_BUSCON0);
	return 0;
}

postcore_initcall(lantiq_ebu_init);