sf_ops: Unify bank_sel calculation code
Subsystems (3)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v2 1/5 sf_ops: Unify bank_sel calculation code
Unified the bank_sel calculation code for erase and write ops.
---
Changes for v2:
- none
drivers/mtd/spi/sf_ops.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-)
drivers/mtd/spi/sf_ops.c +20 -16
@@ -59,6 +59,22 @@ static int spi_flash_cmd_bankaddr_write(struct spi_flash *flash, u8 bank_sel) return 0; } + +static int spi_flash_bank (struct spi_flash *flash,u32 offset) +{ +u8 bank_sel; +int ret; + + bank_sel = offset /SPI_FLASH_16MB_BOUN ; + + ret =spi_flash_cmd_bankaddr_write (flash, bank_sel); +if (ret) { +debug ("SF: fail to set bank%d\n" , bank_sel); +return ret; + } + +return 0 ; +}#endif int spi_flash_cmd_wait_ready (struct spi_flash *flash,unsigned long timeout)
@@ -162,15 +178,9 @@ int spi_flash_cmd_erase_ops(struct spi_flash *flash, u32 offset, size_t len) cmd[0 ] = flash->erase_cmd;while (len) {#ifdef CONFIG_SPI_FLASH_BAR -u8 bank_sel; - - bank_sel = offset /SPI_FLASH_16MB_BOUN ; - - ret =spi_flash_cmd_bankaddr_write (flash, bank_sel); -if (ret) { -debug ("SF: fail to set bank%d\n" , bank_sel); + ret =spi_flash_bank (flash, offset); +if (ret <0 )return ret; - }#endif spi_flash_addr (offset, cmd);
@@ -203,15 +213,9 @@ int spi_flash_cmd_write_ops(struct spi_flash *flash, u32 offset, cmd[0 ] =CMD_PAGE_PROGRAM ;for (actual =0 ; actual < len; actual += chunk_len) {#ifdef CONFIG_SPI_FLASH_BAR -u8 bank_sel; - - bank_sel = offset /SPI_FLASH_16MB_BOUN ; - - ret =spi_flash_cmd_bankaddr_write (flash, bank_sel); -if (ret) { -debug ("SF: fail to set bank%d\n" , bank_sel); + ret =spi_flash_bank (flash, offset); +if (ret <0 )return ret; - }#endif byte_addr = offset % page_size; chunk_len =min (len - actual, page_size - byte_addr);
Signature · 1 line
1.8.3
PATCH v2 2/5 sf: Minor cleanups.
In reply to a message not in the archive- Add comments.
- Renamed few macros.
- Add tabs.
---
Changes for v2:
- none
drivers/mtd/spi/sf_internal.h | 6 +++--- drivers/mtd/spi/sf_ops.c | 2 +- drivers/mtd/spi/sf_probe.c | 5 +++-- include/spi.h | 14 +++++++------- 4 files changed, 14 insertions(+), 13 deletions(-)
drivers/mtd/spi/sf_internal.h +3 -3
@@ -7,8 +7,8 @@* Licensed under the GPL-2 or later. */ -#ifndef _SPI_FLASH_INTERNAL_H_ -#define _SPI_FLASH_INTERNAL_H_ +#ifndef _SF_INTERNAL_H_ +#define _SF_INTERNAL_H_#define SPI_FLASH_16MB_BOUN 0x1000000
@@ -139,4 +139,4 @@ int spi_flash_read_common(struct spi_flash *flash, const u8 *cmd,int spi_flash_cmd_read_ops (struct spi_flash *flash,u32 offset,size_t len,void *data); -#endif /* _SPI_FLASH_INTERNAL_H_ */ +#endif /* _SF_INTERNAL_H_ */
drivers/mtd/spi/sf_ops.c +1 -1
@@ -292,7 +292,7 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset, return ret; }#endif - remain_len = (SPI_FLASH_16MB_BOUN * (bank_sel +1 ) - offset); + remain_len = (SPI_FLASH_16MB_BOUN * (bank_sel +1 )) - offset;if (len < remain_len) read_len = len;else
drivers/mtd/spi/sf_probe.c +3 -2
@@ -25,7 +25,7 @@ DECLARE_GLOBAL_DATA_PTR;* @jedec: Device jedec ID (0x[1byte_manuf_id][2byte_dev_id]) * @ext_jedec: Device ext_jedec ID * @sector_size: Sector size of this device -* @nr_sectors: No.of sectors on this device +* @nr_sectors: No.of sectors on this device * @flags: Importent param, for flash specific behaviour */ struct spi_flash_params {
@@ -139,7 +139,7 @@ static const struct spi_flash_params spi_flash_params_table[] = {#endif /* * Note: -* Below paired flash devices has similar spi_flash_params params. +* Below paired flash devices has similar spi_flash params. * (S25FL129P_64K, S25FL128S_64K) * (W25Q80BL, W25Q80BV) * (W25Q16CL, W25Q16DV)
@@ -188,6 +188,7 @@ static struct spi_flash *spi_flash_validate_params(struct spi_slave *spi, }memset (flash,'\0' ,sizeof (*flash)); +/* Assign spi data */ flash->spi = spi; flash->name = params->name; flash->memory_map = spi->memory_map;
include/spi.h +7 -7
@@ -1,4 +1,6 @@/* +* Common SPI Interface: Controller-specific definitions +* * (C) Copyright 2001 * Gerald Van Baren, Custom IDEAS, vanbaren at cideas.com. *
@@ -8,8 +10,6 @@#ifndef _SPI_H_#define _SPI_H_ -/* Controller-specific definitions: */ -/* SPI mode flags */ #define SPI_CPHA 0x01/* clock phase */ #define SPI_CPOL 0x02/* clock polarity */
@@ -241,11 +241,11 @@ static inline int spi_w8r8(struct spi_slave *slave, unsigned char byte)* This calls spi_setup_slave() with the correct bus number. Call * spi_free_slave() to free it later. * -* @param blob Device tree blob -* @param node SPI peripheral node to use -* @param cs Chip select to use -* @param max_hz Maximum SCK rate in Hz (0 for default) -* @param mode Clock polarity, clock phase and other parameters +* @param blob: Device tree blob +* @param node: SPI peripheral node to use +* @param cs: Chip select to use +* @param max_hz: Maximum SCK rate in Hz (0 for default) +* @param mode: Clock polarity, clock phase and other parameters * @return pointer to new spi_slave structure */ struct spi_slave *spi_setup_slave_fdt(const void *blob, int node,
Signature · 1 line
1.8.3
PATCH v2 3/5 sf: Add GPL-2.0+ SPDX-License-Identifier for missing ones
In reply to a message not in the archiveAdded GPL-2.0+ SPDX-License-Identifier for missed sf source files.
---
Changes for v2:
- none
common/cmd_sf.c | 3 ++- drivers/mtd/spi/sf.c | 2 +- drivers/mtd/spi/sf_internal.h | 2 +- drivers/mtd/spi/sf_ops.c | 2 +- drivers/mtd/spi/sf_probe.c | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-)
common/cmd_sf.c +2 -1
@@ -2,7 +2,8 @@* Command for accessing SPI flash. * * Copyright (C) 2008 Atmel Corporation -* Licensed under the GPL-2 or later. +* +* SPDX-License-Identifier: GPL-2.0+ */ #include <common.h>
drivers/mtd/spi/sf.c +1 -1
@@ -4,7 +4,7 @@* Copyright (C) 2008 Atmel Corporation * Copyright (C) 2010 Reinhard Meyer, EMK Elektronik * -* Licensed under the GPL-2 or later. +* SPDX-License-Identifier: GPL-2.0+ */ #include <common.h>
drivers/mtd/spi/sf_internal.h +1 -1
@@ -4,7 +4,7 @@* Copyright (C) 2008 Atmel Corporation * Copyright (C) 2013 Jagannadha Sutradharudu Teki, Xilinx Inc. * -* Licensed under the GPL-2 or later. +* SPDX-License-Identifier: GPL-2.0+ */ #ifndef _SF_INTERNAL_H_
drivers/mtd/spi/sf_ops.c +1 -1
@@ -5,7 +5,7 @@* Copyright (C) 2010 Reinhard Meyer, EMK Elektronik * Copyright (C) 2013 Jagannadha Sutradharudu Teki, Xilinx Inc. * -* Licensed under the GPL-2 or later. +* SPDX-License-Identifier: GPL-2.0+ */ #include <common.h>
drivers/mtd/spi/sf_probe.c +1 -1
@@ -5,7 +5,7 @@* Copyright (C) 2010 Reinhard Meyer, EMK Elektronik * Copyright (C) 2013 Jagannadha Sutradharudu Teki, Xilinx Inc. * -* Licensed under the GPL-2 or later. +* SPDX-License-Identifier: GPL-2.0+ */ #include <common.h>
Signature · 1 line
1.8.3
PATCH v2 4/5 spi: Add GPL-2.0+ SPDX-License-Identifier for missing files
In reply to a message not in the archiveAdded GPL-2.0+ SPDX-License-Identifier for missed spi source files.
---
Changes for v2:
- none
drivers/spi/altera_spi.c | 2 +- drivers/spi/bfin_spi.c | 2 +- drivers/spi/oc_tiny_spi.c | 2 +- drivers/spi/xilinx_spi.c | 2 +- drivers/spi/xilinx_spi.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)
drivers/spi/altera_spi.c +1 -1
@@ -5,7 +5,7 @@* Copyright (c) 2005-2008 Analog Devices Inc. * Copyright (C) 2010 Thomas Chou <[email protected]> * -* Licensed under the GPL-2 or later. +* SPDX-License-Identifier: GPL-2.0+ */ #include <common.h> #include <asm/io.h>
drivers/spi/bfin_spi.c +1 -1
@@ -3,7 +3,7 @@* * Copyright (c) 2005-2010 Analog Devices Inc. * -* Licensed under the GPL-2 or later. +* SPDX-License-Identifier: GPL-2.0+ */ /*#define DEBUG*/
drivers/spi/oc_tiny_spi.c +1 -1
@@ -7,7 +7,7 @@* Copyright (c) 2005-2008 Analog Devices Inc. * Copyright (C) 2010 Thomas Chou <[email protected]> * -* Licensed under the GPL-2 or later. +* SPDX-License-Identifier: GPL-2.0+ */ #include <common.h>
drivers/spi/xilinx_spi.c +1 -1
@@ -9,7 +9,7 @@* Copyright (c) 2010 Graeme Smecher <[email protected]> * Copyright (c) 2012 Stephan Linz <[email protected]> * -* Licensed under the GPL-2 or later. +* SPDX-License-Identifier: GPL-2.0+ * * [0]: http://www.xilinx.com/support/documentation *
drivers/spi/xilinx_spi.h +1 -1
@@ -9,7 +9,7 @@* Copyright (c) 2010 Graeme Smecher <[email protected]> * Copyright (c) 2012 Stephan Linz <[email protected]> * -* Licensed under the GPL-2 or later. +* SPDX-License-Identifier: GPL-2.0+ * * [0]: http://www.xilinx.com/support/documentation *
Signature · 1 line
1.8.3
PATCH v2 5/5 sf: probe: Add missing Atmel at25df321 flash
In reply to a message not in the archiveFrom: Bo Shen <[email protected]>
As the spi flash transfer to multiple parts, it is forgot to add Atmel AT25DF321 spi flash support, which broken several Atmel EK boards which this chip. So, add it
---
Changes for v2:
- none
drivers/mtd/spi/sf_probe.c | 1 + 1 file changed, 1 insertion(+)
drivers/mtd/spi/sf_probe.c +1 -0
@@ -46,6 +46,7 @@ static const struct spi_flash_params spi_flash_params_table[] = { {"AT45DB161D", 0x1f2600, 0x0, 64 * 1024, 32, SECT_4K}, {"AT45DB321D", 0x1f2700, 0x0, 64 * 1024, 64, SECT_4K}, {"AT45DB641D", 0x1f2800, 0x0, 64 * 1024, 128, SECT_4K}, + {"AT25DF321", 0x1f4701, 0x0, 64 * 1024, 64, SECT_4K}, #endif #ifdef CONFIG_SPI_FLASH_EON /* EON */ {"EN25Q32B", 0x1c3016, 0x0, 64 * 1024, 64, 0},
Signature · 1 line
1.8.3