]> Pileus Git - ~andy/linux/blob - arch/mips/bcm63xx/dev-flash.c
MIPS: BCM63XX: Move flash registration out of board_bcm963xx.c
[~andy/linux] / arch / mips / bcm63xx / dev-flash.c
1 /*
2  * Broadcom BCM63xx flash registration
3  *
4  * This file is subject to the terms and conditions of the GNU General Public
5  * License.  See the file "COPYING" in the main directory of this archive
6  * for more details.
7  *
8  * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
9  * Copyright (C) 2008 Florian Fainelli <florian@openwrt.org>
10  */
11
12 #include <linux/init.h>
13 #include <linux/kernel.h>
14 #include <linux/platform_device.h>
15 #include <linux/mtd/mtd.h>
16 #include <linux/mtd/partitions.h>
17 #include <linux/mtd/physmap.h>
18
19 #include <bcm63xx_cpu.h>
20 #include <bcm63xx_dev_flash.h>
21 #include <bcm63xx_regs.h>
22 #include <bcm63xx_io.h>
23
24 static struct mtd_partition mtd_partitions[] = {
25         {
26                 .name           = "cfe",
27                 .offset         = 0x0,
28                 .size           = 0x40000,
29         }
30 };
31
32 static const char *bcm63xx_part_types[] = { "bcm63xxpart", NULL };
33
34 static struct physmap_flash_data flash_data = {
35         .width                  = 2,
36         .parts                  = mtd_partitions,
37         .part_probe_types       = bcm63xx_part_types,
38 };
39
40 static struct resource mtd_resources[] = {
41         {
42                 .start          = 0,    /* filled at runtime */
43                 .end            = 0,    /* filled at runtime */
44                 .flags          = IORESOURCE_MEM,
45         }
46 };
47
48 static struct platform_device mtd_dev = {
49         .name                   = "physmap-flash",
50         .resource               = mtd_resources,
51         .num_resources          = ARRAY_SIZE(mtd_resources),
52         .dev                    = {
53                 .platform_data  = &flash_data,
54         },
55 };
56
57 int __init bcm63xx_flash_register(void)
58 {
59         u32 val;
60
61         /* read base address of boot chip select (0) */
62         val = bcm_mpi_readl(MPI_CSBASE_REG(0));
63         val &= MPI_CSBASE_BASE_MASK;
64
65         mtd_resources[0].start = val;
66         mtd_resources[0].end = 0x1FFFFFFF;
67
68         return platform_device_register(&mtd_dev);
69 }