Lines Matching full:flash
2 * SMI (Serial Memory Controller) device driver for Serial NOR Flash on
90 /* flash opcodes */
93 /* Flash Device Ids maintenance section */
95 /* data structure to maintain flash ids from different vendors */
165 * @cmd_complete: queue to wait for command completion of NOR-flash.
167 * @flash: separate structure for each Serial NOR-flash attached to SMI.
178 struct spear_snor_flash *flash[MAX_NUM_FLASH_CHIP]; member
182 * struct spear_snor_flash - Structure for Serial NOR Flash
184 * @bank: Bank number(0, 1, 2, 3) for each NOR-flash.
185 * @dev_id: Device ID of NOR-flash.
186 * @lock: lock to manage flash read, write and erase operations
187 * @mtd: MTD info for each NOR-flash.
188 * @num_parts: Total number of partition in each bank of NOR-flash.
189 * @parts: Partition info for each bank of NOR-flash.
190 * @page_size: Page size of NOR-flash.
191 * @base_addr: Base address of NOR-flash.
192 * @erase_cmd: erase command may vary on different flash types
193 * @fast_mode: flash supports read in fast mode
214 * spear_smi_read_sr - Read status register of flash through SMI
216 * @bank: bank to which flash is connected
218 * This routine will return the status register of the flash chip present at the
256 * spear_smi_wait_till_ready - wait till flash is ready
258 * @bank: flash corresponding to this bank
350 * get_flash_index - match chip id from a flash list.
351 * @flash_id: a valid nor flash chip id obtained from board.
354 * returns negative. In case of success returns index in to the flash devices
361 /* Matches chip-id to entire list of 'serial-nor flash' ids */ in get_flash_index()
372 * spear_smi_write_enable - Enable the flash to do write operation
374 * @bank: enable write for flash connected to this bank
391 /* give the flash, write enable command */ in spear_smi_write_enable()
420 get_sector_erase_cmd(struct spear_snor_flash *flash, u32 offset) in get_sector_erase_cmd() argument
425 x[0] = flash->erase_cmd; in get_sector_erase_cmd()
434 * spear_smi_erase_sector - erase one sector of flash
440 * Erase one sector of flash memory at offset ``offset'' which is any
487 * spear_mtd_erase - perform flash erase operation as requested by user
491 * Erase an address range on the flash chip. The address range may extend
496 struct spear_snor_flash *flash = get_flash_data(mtd); in spear_mtd_erase() local
501 if (!flash || !dev) in spear_mtd_erase()
504 bank = flash->bank; in spear_mtd_erase()
513 mutex_lock(&flash->lock); in spear_mtd_erase()
517 command = get_sector_erase_cmd(flash, addr); in spear_mtd_erase()
518 /* preparing the command for flash */ in spear_mtd_erase()
521 mutex_unlock(&flash->lock); in spear_mtd_erase()
528 mutex_unlock(&flash->lock); in spear_mtd_erase()
534 * spear_mtd_read - performs flash read operation as requested by the user
541 * Read an address range from the flash chip. The address range
548 struct spear_snor_flash *flash = get_flash_data(mtd); in spear_mtd_read() local
554 if (!flash || !dev) in spear_mtd_read()
557 if (flash->bank > dev->num_flashes - 1) { in spear_mtd_read()
563 src = flash->base_addr + from; in spear_mtd_read()
565 mutex_lock(&flash->lock); in spear_mtd_read()
568 ret = spear_smi_wait_till_ready(dev, flash->bank, SMI_MAX_TIME_OUT); in spear_mtd_read()
570 mutex_unlock(&flash->lock); in spear_mtd_read()
578 if (flash->fast_mode) in spear_mtd_read()
590 mutex_unlock(&flash->lock); in spear_mtd_read()
669 * Write an address range to the flash chip. Data must be written in
677 struct spear_snor_flash *flash = get_flash_data(mtd); in spear_mtd_write() local
683 if (!flash || !dev) in spear_mtd_write()
686 if (flash->bank > dev->num_flashes - 1) { in spear_mtd_write()
692 dest = flash->base_addr + to; in spear_mtd_write()
693 mutex_lock(&flash->lock); in spear_mtd_write()
695 page_offset = (u32)to % flash->page_size; in spear_mtd_write()
698 if (page_offset + len <= flash->page_size) { in spear_mtd_write()
699 ret = spear_smi_cpy_toio(dev, flash->bank, dest, buf, len); in spear_mtd_write()
706 page_size = flash->page_size - page_offset; in spear_mtd_write()
708 ret = spear_smi_cpy_toio(dev, flash->bank, dest, buf, in spear_mtd_write()
718 if (page_size > flash->page_size) in spear_mtd_write()
719 page_size = flash->page_size; in spear_mtd_write()
721 ret = spear_smi_cpy_toio(dev, flash->bank, dest + i, in spear_mtd_write()
731 mutex_unlock(&flash->lock); in spear_mtd_write()
737 * spear_smi_probe_flash - Detects the NOR Flash chip.
739 * @bank: bank on which flash must be probed
741 * This routine will check whether there exists a flash chip on a given memory
743 * Return index of the probed flash in flash devices structure
814 /* Fill structs for each subnode (flash device) */ in spear_smi_probe_config_dt()
847 struct spear_snor_flash *flash; in spear_smi_setup_banks() local
861 flash = devm_kzalloc(&pdev->dev, sizeof(*flash), GFP_ATOMIC); in spear_smi_setup_banks()
862 if (!flash) in spear_smi_setup_banks()
864 flash->bank = bank; in spear_smi_setup_banks()
865 flash->fast_mode = flash_info->fast_mode ? 1 : 0; in spear_smi_setup_banks()
866 mutex_init(&flash->lock); in spear_smi_setup_banks()
868 /* verify whether nor flash is really present on board */ in spear_smi_setup_banks()
874 /* map the memory for nor flash chip */ in spear_smi_setup_banks()
875 flash->base_addr = devm_ioremap(&pdev->dev, flash_info->mem_base, in spear_smi_setup_banks()
877 if (!flash->base_addr) in spear_smi_setup_banks()
880 dev->flash[bank] = flash; in spear_smi_setup_banks()
881 flash->mtd.priv = dev; in spear_smi_setup_banks()
884 flash->mtd.name = flash_info->name; in spear_smi_setup_banks()
886 flash->mtd.name = flash_devices[flash_index].name; in spear_smi_setup_banks()
888 flash->mtd.dev.parent = &pdev->dev; in spear_smi_setup_banks()
889 mtd_set_of_node(&flash->mtd, np); in spear_smi_setup_banks()
890 flash->mtd.type = MTD_NORFLASH; in spear_smi_setup_banks()
891 flash->mtd.writesize = 1; in spear_smi_setup_banks()
892 flash->mtd.flags = MTD_CAP_NORFLASH; in spear_smi_setup_banks()
893 flash->mtd.size = flash_info->size; in spear_smi_setup_banks()
894 flash->mtd.erasesize = flash_devices[flash_index].sectorsize; in spear_smi_setup_banks()
895 flash->page_size = flash_devices[flash_index].pagesize; in spear_smi_setup_banks()
896 flash->mtd.writebufsize = flash->page_size; in spear_smi_setup_banks()
897 flash->erase_cmd = flash_devices[flash_index].erase_cmd; in spear_smi_setup_banks()
898 flash->mtd._erase = spear_mtd_erase; in spear_smi_setup_banks()
899 flash->mtd._read = spear_mtd_read; in spear_smi_setup_banks()
900 flash->mtd._write = spear_mtd_write; in spear_smi_setup_banks()
901 flash->dev_id = flash_devices[flash_index].device_id; in spear_smi_setup_banks()
904 flash->mtd.name, flash->mtd.size, in spear_smi_setup_banks()
905 flash->mtd.size / (1024 * 1024)); in spear_smi_setup_banks()
908 flash->mtd.erasesize, flash->mtd.erasesize / 1024); in spear_smi_setup_banks()
917 ret = mtd_device_register(&flash->mtd, parts, count); in spear_smi_setup_banks()
1021 /* loop for each serial nor-flash which is connected to smi */ in spear_smi_probe()
1047 struct spear_snor_flash *flash; in spear_smi_remove() local
1056 /* clean up for all nor flash */ in spear_smi_remove()
1058 flash = dev->flash[i]; in spear_smi_remove()
1059 if (!flash) in spear_smi_remove()
1063 ret = mtd_device_unregister(&flash->mtd); in spear_smi_remove()
1122 MODULE_DESCRIPTION("MTD SMI driver for serial nor flash chips");