Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  * Mapping of a custom board with both AMD CFI and JEDEC flash in partitions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Config with both CFI and JEDEC device support.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Basically physmap.c with the addition of partitions and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * an array of mapping info to accommodate more than one flash type per board.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * Copyright 2005-2007 PMC-Sierra, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  *  This program is free software; you can redistribute  it and/or modify it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  *  under  the terms of  the GNU General  Public License as published by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *  Free Software Foundation;  either version 2 of the  License, or (at your
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *  option) any later version.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  *  You should have received a copy of the  GNU General Public License along
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  *  with this program; if not, write  to the Free Software Foundation, Inc.,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  *  675 Mass Ave, Cambridge, MA 02139, USA.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #include <linux/mtd/mtd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #include <linux/mtd/map.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #include <linux/mtd/partitions.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #include <asm/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #include <msp_prom.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #include <msp_regs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) static struct mtd_info **msp_flash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) static struct mtd_partition **msp_parts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) static struct map_info *msp_maps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) static int fcnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #define DEBUG_MARKER printk(KERN_NOTICE "%s[%d]\n", __func__, __LINE__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) static int __init init_msp_flash(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	int i, j, ret = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	int offset, coff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	char *env;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	int pcnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	char flash_name[] = "flash0";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	char part_name[] = "flash0_0";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	unsigned addr, size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	/* If ELB is disabled by "ful-mux" mode, we can't get at flash */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	if ((*DEV_ID_REG & DEV_ID_SINGLE_PC) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	    (*ELB_1PC_EN_REG & SINGLE_PCCARD)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 		printk(KERN_NOTICE "Single PC Card mode: no flash access\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 		return -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	/* examine the prom environment for flash devices */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	for (fcnt = 0; (env = prom_getenv(flash_name)); fcnt++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		flash_name[5] = '0' + fcnt + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	if (fcnt < 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 		return -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	printk(KERN_NOTICE "Found %d PMC flash devices\n", fcnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	msp_flash = kcalloc(fcnt, sizeof(*msp_flash), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	if (!msp_flash)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	msp_parts = kcalloc(fcnt, sizeof(*msp_parts), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	if (!msp_parts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		goto free_msp_flash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	msp_maps = kcalloc(fcnt, sizeof(*msp_maps), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	if (!msp_maps)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		goto free_msp_parts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	/* loop over the flash devices, initializing each */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	for (i = 0; i < fcnt; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		/* examine the prom environment for flash partititions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		part_name[5] = '0' + i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		part_name[7] = '0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		for (pcnt = 0; (env = prom_getenv(part_name)); pcnt++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 			part_name[7] = '0' + pcnt + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		if (pcnt == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 			printk(KERN_NOTICE "Skipping flash device %d "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 				"(no partitions defined)\n", i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 		msp_parts[i] = kcalloc(pcnt, sizeof(struct mtd_partition),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 				       GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 		if (!msp_parts[i])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 			goto cleanup_loop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		/* now initialize the devices proper */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		flash_name[5] = '0' + i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		env = prom_getenv(flash_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 		if (sscanf(env, "%x:%x", &addr, &size) < 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 			ret = -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 			kfree(msp_parts[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 			goto cleanup_loop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		addr = CPHYSADDR(addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 		printk(KERN_NOTICE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 			"MSP flash device \"%s\": 0x%08x at 0x%08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 			flash_name, size, addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		/* This must matchs the actual size of the flash chip */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		msp_maps[i].size = size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		msp_maps[i].phys = addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		 * Platforms have a specific limit of the size of memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		 * which may be mapped for flash:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		if (size > CONFIG_MSP_FLASH_MAP_LIMIT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 			size = CONFIG_MSP_FLASH_MAP_LIMIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		msp_maps[i].virt = ioremap(addr, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		if (msp_maps[i].virt == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 			ret = -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 			kfree(msp_parts[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 			goto cleanup_loop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 		msp_maps[i].bankwidth = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		msp_maps[i].name = kstrndup(flash_name, 7, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		if (!msp_maps[i].name) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 			iounmap(msp_maps[i].virt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 			kfree(msp_parts[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 			goto cleanup_loop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 		for (j = 0; j < pcnt; j++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 			part_name[5] = '0' + i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 			part_name[7] = '0' + j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 			env = prom_getenv(part_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 			if (sscanf(env, "%x:%x:%n", &offset, &size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 						&coff) < 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 				ret = -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 				kfree(msp_maps[i].name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 				iounmap(msp_maps[i].virt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 				kfree(msp_parts[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 				goto cleanup_loop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 			msp_parts[i][j].size = size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 			msp_parts[i][j].offset = offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 			msp_parts[i][j].name = env + coff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 		/* now probe and add the device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		simple_map_init(&msp_maps[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		msp_flash[i] = do_map_probe("cfi_probe", &msp_maps[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 		if (msp_flash[i]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 			msp_flash[i]->owner = THIS_MODULE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 			mtd_device_register(msp_flash[i], msp_parts[i], pcnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 			printk(KERN_ERR "map probe failed for flash\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 			ret = -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 			kfree(msp_maps[i].name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 			iounmap(msp_maps[i].virt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 			kfree(msp_parts[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 			goto cleanup_loop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) cleanup_loop:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	while (i--) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 		mtd_device_unregister(msp_flash[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 		map_destroy(msp_flash[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		kfree(msp_maps[i].name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		iounmap(msp_maps[i].virt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		kfree(msp_parts[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	kfree(msp_maps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) free_msp_parts:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	kfree(msp_parts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) free_msp_flash:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	kfree(msp_flash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) static void __exit cleanup_msp_flash(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	for (i = 0; i < fcnt; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		mtd_device_unregister(msp_flash[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		map_destroy(msp_flash[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 		iounmap((void *)msp_maps[i].virt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		/* free the memory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 		kfree(msp_maps[i].name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		kfree(msp_parts[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	kfree(msp_flash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	kfree(msp_parts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	kfree(msp_maps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) MODULE_AUTHOR("PMC-Sierra, Inc");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) MODULE_DESCRIPTION("MTD map driver for PMC-Sierra MSP boards");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) module_init(init_msp_flash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) module_exit(cleanup_msp_flash);