From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?windows-1252?Q?Andreas_F=E4rber?= Date: Fri, 26 Sep 2014 19:58:12 +0200 Subject: [U-Boot] [PATCH] spi:ls102xqds:Support for compatibility for QSPI and DSPI modules drivers In-Reply-To: <1411718199-27215-1-git-send-email-b44548@freescale.com> References: <1411718199-27215-1-git-send-email-b44548@freescale.com> Message-ID: <5425A934.90904@suse.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi, Am 26.09.2014 um 09:56 schrieb Chao Fu: > From: Chao Fu > > Useage: > For exmaple(ls1021 ls1021aqds): > > SPI bus defination can be find in > arch/arm/include/asm/arch-ls102xa/config.h > > SPI_BUS_FSL_QSPI 0 > SPI_BUS_FSL_DSPI1 1 > SPI_BUS_FSL_DSPI2 2 > > and SPI devices info: > AT45DB021 is on spi bus 1 cs 0 > S25FL064 is on spi bus 2 cs 0 > S25FL128S is on spi bus 0 cs 0 > > Before using any SPI bus and SPI flash, execute sf probe bus:cs in uboot cmdline > Such as use S25FL064, sf probe 2:0 This could use some spellchecking... (usage, example, definition, found) > > Signed-off-by: Chao Fu > --- > arch/arm/include/asm/arch-ls102xa/config.h | 5 +- > board/freescale/ls1021aqds/ls1021aqds.c | 33 ++++ > drivers/spi/Makefile | 1 + > drivers/spi/fsl_dspi.c | 78 +++------ > drivers/spi/fsl_qspi.c | 35 ++-- > drivers/spi/fsl_spi_interface.c | 267 +++++++++++++++++++++++++++++ > 6 files changed, 339 insertions(+), 80 deletions(-) > create mode 100644 drivers/spi/fsl_spi_interface.c [...] > diff --git a/board/freescale/ls1021aqds/ls1021aqds.c b/board/freescale/ls1021aqds/ls1021aqds.c > index 12e83f7..5db2126 100644 > --- a/board/freescale/ls1021aqds/ls1021aqds.c > +++ b/board/freescale/ls1021aqds/ls1021aqds.c > @@ -230,6 +230,39 @@ int board_init(void) > return 0; > } > > +int board_spi_find_bus(unsigned int bus, unsigned int cs) > +{ > + switch (bus) { > + case SPI_BUS_FSL_DSPI1: > + case SPI_BUS_FSL_DSPI2: > + case SPI_BUS_FSL_QSPI: > + break; > + default: > + return -1; > + } > + > + switch (bus) { > + case SPI_BUS_FSL_DSPI1: > + if (cs == 0) > + return 0; > + case SPI_BUS_FSL_DSPI2: > + if (cs == 0) > + return 0; > + case SPI_BUS_FSL_QSPI: > + if (cs == 0) > + return 0; > + default: > + return -1; > + } > +} [snip] This code is both redundant and potentially dangerous. In the cs != 0 case, it falls through to the next case label, where the same if is being executed - no harm done, but someone might want to touch that code in the future. Why not simply move a single if+return into the first switch? Regards, Andreas -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N?rnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend?rffer; HRB 16746 AG N?rnberg