2 * Octeon Bootbus flash setup
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
8 * Copyright (C) 2007, 2008 Cavium Networks
10 #include <linux/kernel.h>
11 #include <linux/mtd/mtd.h>
12 #include <linux/mtd/map.h>
13 #include <linux/mtd/partitions.h>
15 #include <asm/octeon/octeon.h>
17 static struct map_info flash_map;
18 static struct mtd_info *mymtd;
19 #ifdef CONFIG_MTD_PARTITIONS
21 static struct mtd_partition *parts;
22 static const char *part_probe_types[] = {
24 #ifdef CONFIG_MTD_REDBOOT_PARTS
32 * Module/ driver initialization.
34 * Returns Zero on success
36 static int __init flash_init(void)
39 * Read the bootbus region 0 setup to determine the base
40 * address of the flash.
42 union cvmx_mio_boot_reg_cfgx region_cfg;
43 region_cfg.u64 = cvmx_read_csr(CVMX_MIO_BOOT_REG_CFGX(0));
44 if (region_cfg.s.en) {
46 * The bootloader always takes the flash and sets its
47 * address so the entire flash fits below
48 * 0x1fc00000. This way the flash aliases to
49 * 0x1fc00000 for booting. Software can access the
50 * full flash at the true address, while core boot can
53 /* Use this name so old part lines work */
54 flash_map.name = "phys_mapped_flash";
55 flash_map.phys = region_cfg.s.base << 16;
56 flash_map.size = 0x1fc00000 - flash_map.phys;
57 flash_map.bankwidth = 1;
58 flash_map.virt = ioremap(flash_map.phys, flash_map.size);
59 pr_notice("Bootbus flash: Setting flash for %luMB flash at "
60 "0x%08lx\n", flash_map.size >> 20, flash_map.phys);
61 simple_map_init(&flash_map);
62 mymtd = do_map_probe("cfi_probe", &flash_map);
64 mymtd->owner = THIS_MODULE;
66 #ifdef CONFIG_MTD_PARTITIONS
67 nr_parts = parse_mtd_partitions(mymtd,
71 add_mtd_partitions(mymtd, parts, nr_parts);
73 add_mtd_device(mymtd);
75 add_mtd_device(mymtd);
78 pr_err("Failed to register MTD device for flash\n");
84 late_initcall(flash_init);