Path: blob/master/arch/mips/cavium-octeon/flash_setup.c
10817 views
/*1* Octeon Bootbus flash setup2*3* This file is subject to the terms and conditions of the GNU General Public4* License. See the file "COPYING" in the main directory of this archive5* for more details.6*7* Copyright (C) 2007, 2008 Cavium Networks8*/9#include <linux/kernel.h>10#include <linux/mtd/mtd.h>11#include <linux/mtd/map.h>12#include <linux/mtd/partitions.h>1314#include <asm/octeon/octeon.h>1516static struct map_info flash_map;17static struct mtd_info *mymtd;18static int nr_parts;19static struct mtd_partition *parts;20static const char *part_probe_types[] = {21"cmdlinepart",22#ifdef CONFIG_MTD_REDBOOT_PARTS23"RedBoot",24#endif25NULL26};2728/**29* Module/ driver initialization.30*31* Returns Zero on success32*/33static int __init flash_init(void)34{35/*36* Read the bootbus region 0 setup to determine the base37* address of the flash.38*/39union cvmx_mio_boot_reg_cfgx region_cfg;40region_cfg.u64 = cvmx_read_csr(CVMX_MIO_BOOT_REG_CFGX(0));41if (region_cfg.s.en) {42/*43* The bootloader always takes the flash and sets its44* address so the entire flash fits below45* 0x1fc00000. This way the flash aliases to46* 0x1fc00000 for booting. Software can access the47* full flash at the true address, while core boot can48* access 4MB.49*/50/* Use this name so old part lines work */51flash_map.name = "phys_mapped_flash";52flash_map.phys = region_cfg.s.base << 16;53flash_map.size = 0x1fc00000 - flash_map.phys;54flash_map.bankwidth = 1;55flash_map.virt = ioremap(flash_map.phys, flash_map.size);56pr_notice("Bootbus flash: Setting flash for %luMB flash at "57"0x%08llx\n", flash_map.size >> 20, flash_map.phys);58simple_map_init(&flash_map);59mymtd = do_map_probe("cfi_probe", &flash_map);60if (mymtd) {61mymtd->owner = THIS_MODULE;6263nr_parts = parse_mtd_partitions(mymtd,64part_probe_types,65&parts, 0);66mtd_device_register(mymtd, parts, nr_parts);67} else {68pr_err("Failed to register MTD device for flash\n");69}70}71return 0;72}7374late_initcall(flash_init);757677