~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/mips/bcm63xx/dev-flash.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  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  * Copyright (C) 2012 Jonas Gorski <jonas.gorski@gmail.com>
 11  */
 12 
 13 #include <linux/init.h>
 14 #include <linux/kernel.h>
 15 #include <linux/platform_device.h>
 16 #include <linux/mtd/mtd.h>
 17 #include <linux/mtd/partitions.h>
 18 #include <linux/mtd/physmap.h>
 19 
 20 #include <bcm63xx_cpu.h>
 21 #include <bcm63xx_dev_flash.h>
 22 #include <bcm63xx_regs.h>
 23 #include <bcm63xx_io.h>
 24 
 25 static struct mtd_partition mtd_partitions[] = {
 26         {
 27                 .name           = "cfe",
 28                 .offset         = 0x0,
 29                 .size           = 0x40000,
 30         }
 31 };
 32 
 33 static const char *bcm63xx_part_types[] = { "bcm63xxpart", NULL };
 34 
 35 static struct physmap_flash_data flash_data = {
 36         .width                  = 2,
 37         .parts                  = mtd_partitions,
 38         .part_probe_types       = bcm63xx_part_types,
 39 };
 40 
 41 static struct resource mtd_resources[] = {
 42         {
 43                 .start          = 0,    /* filled at runtime */
 44                 .end            = 0,    /* filled at runtime */
 45                 .flags          = IORESOURCE_MEM,
 46         }
 47 };
 48 
 49 static struct platform_device mtd_dev = {
 50         .name                   = "physmap-flash",
 51         .resource               = mtd_resources,
 52         .num_resources          = ARRAY_SIZE(mtd_resources),
 53         .dev                    = {
 54                 .platform_data  = &flash_data,
 55         },
 56 };
 57 
 58 static int __init bcm63xx_detect_flash_type(void)
 59 {
 60         u32 val;
 61 
 62         switch (bcm63xx_get_cpu_id()) {
 63         case BCM6328_CPU_ID:
 64                 val = bcm_misc_readl(MISC_STRAPBUS_6328_REG);
 65                 if (val & STRAPBUS_6328_BOOT_SEL_SERIAL)
 66                         return BCM63XX_FLASH_TYPE_SERIAL;
 67                 else
 68                         return BCM63XX_FLASH_TYPE_NAND;
 69         case BCM6338_CPU_ID:
 70         case BCM6345_CPU_ID:
 71         case BCM6348_CPU_ID:
 72                 /* no way to auto detect so assume parallel */
 73                 return BCM63XX_FLASH_TYPE_PARALLEL;
 74         case BCM3368_CPU_ID:
 75         case BCM6358_CPU_ID:
 76                 val = bcm_gpio_readl(GPIO_STRAPBUS_REG);
 77                 if (val & STRAPBUS_6358_BOOT_SEL_PARALLEL)
 78                         return BCM63XX_FLASH_TYPE_PARALLEL;
 79                 else
 80                         return BCM63XX_FLASH_TYPE_SERIAL;
 81         case BCM6362_CPU_ID:
 82                 val = bcm_misc_readl(MISC_STRAPBUS_6362_REG);
 83                 if (val & STRAPBUS_6362_BOOT_SEL_SERIAL)
 84                         return BCM63XX_FLASH_TYPE_SERIAL;
 85                 else
 86                         return BCM63XX_FLASH_TYPE_NAND;
 87         case BCM6368_CPU_ID:
 88                 val = bcm_gpio_readl(GPIO_STRAPBUS_REG);
 89                 switch (val & STRAPBUS_6368_BOOT_SEL_MASK) {
 90                 case STRAPBUS_6368_BOOT_SEL_NAND:
 91                         return BCM63XX_FLASH_TYPE_NAND;
 92                 case STRAPBUS_6368_BOOT_SEL_SERIAL:
 93                         return BCM63XX_FLASH_TYPE_SERIAL;
 94                 case STRAPBUS_6368_BOOT_SEL_PARALLEL:
 95                         return BCM63XX_FLASH_TYPE_PARALLEL;
 96                 }
 97                 fallthrough;
 98         default:
 99                 return -EINVAL;
100         }
101 }
102 
103 int __init bcm63xx_flash_register(void)
104 {
105         int flash_type;
106         u32 val;
107 
108         flash_type = bcm63xx_detect_flash_type();
109 
110         switch (flash_type) {
111         case BCM63XX_FLASH_TYPE_PARALLEL:
112                 /* read base address of boot chip select (0) */
113                 val = bcm_mpi_readl(MPI_CSBASE_REG(0));
114                 val &= MPI_CSBASE_BASE_MASK;
115 
116                 mtd_resources[0].start = val;
117                 mtd_resources[0].end = 0x1FFFFFFF;
118 
119                 return platform_device_register(&mtd_dev);
120         case BCM63XX_FLASH_TYPE_SERIAL:
121                 pr_warn("unsupported serial flash detected\n");
122                 return -ENODEV;
123         case BCM63XX_FLASH_TYPE_NAND:
124                 pr_warn("unsupported NAND flash detected\n");
125                 return -ENODEV;
126         default:
127                 pr_err("flash detection failed for BCM%x: %d\n",
128                        bcm63xx_get_cpu_id(), flash_type);
129                 return -ENODEV;
130         }
131 }
132 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php