All of lore.kernel.org
 help / color / mirror / Atom feed
From: Scott Wood <scottwood@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH RFC] Add general nand functions
Date: Fri, 23 Sep 2011 12:22:59 -0500	[thread overview]
Message-ID: <4E7CC073.3070000@freescale.com> (raw)
In-Reply-To: <1316795819-3163-1-git-send-email-simonschwarzcor@gmail.com>

On 09/23/2011 11:36 AM, Simon Schwarz wrote:
> Added a nand_base.h header that defines all prototypes of nand_base.c
> functions.

Just add the new prototypes to include/linux/mtd/nand.h (which gets
included by nand.h), that's the header that goes with
drivers/mtd/nand/nand_base.c.

> This is necessary because these functions were often copied
> in SPLs. 

You'd rather add new #includes to dozens of files, and keep duplicated
code around, than fix a few SPLs?  NACK.

> It was necessary to also add nand_interface.c. 

You maen nand_interface.h?

> This now defines static
> inline functions former defined in nand.h - theses functions had name
> conflicts with these in nand_base.c/h.

If we have two functions with the same name that do different things,
change the name of the one in nand.h.

> diff --git a/arch/blackfin/lib/board.c b/arch/blackfin/lib/board.c
> index bfdb586..4568820 100644
> --- a/arch/blackfin/lib/board.c
> +++ b/arch/blackfin/lib/board.c
> @@ -25,7 +25,8 @@
>  #include <kgdb.h>
>  
>  #ifdef CONFIG_CMD_NAND
> -#include <nand.h>	/* cannot even include nand.h if it isnt configured */
> +#include <nand.h>
> +#include <nand_interface.h>	/* cannot even include nand.h if it isnt configured */


I don't think it's still true that you can't include nand.h if it isn't
configured, BTW.

> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index e7dfcb1..3fe0935 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -51,6 +51,8 @@
>  #include <asm/io.h>
>  #include <asm/errno.h>
>  
> +#include <nand_base.h>

Wait, there's *two* new headers?

> +/* nand_base.c Standard implementation of nand functions */
> +void nand_release_device (struct mtd_info *mtd);
> +uint8_t nand_read_byte(struct mtd_info *mtd);
> +uint8_t nand_read_byte16(struct mtd_info *mtd);
> +u16 nand_read_word(struct mtd_info *mtd);
> +void nand_select_chip(struct mtd_info *mtd, int chipnr);
> +void nand_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len);
> +void nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len);
> +int nand_verify_buf(struct mtd_info *mtd, const uint8_t *buf, int len);
> +void nand_write_buf16(struct mtd_info *mtd, const uint8_t *buf, int len);
> +void nand_read_buf16(struct mtd_info *mtd, uint8_t *buf, int len);
> +int nand_verify_buf16(struct mtd_info *mtd, const uint8_t *buf, int len);
> +int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip);
> +int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs);
> +int nand_check_wp(struct mtd_info *mtd);
> +int nand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int getchip,
> +		int allowbbt);
> +void nand_wait_ready(struct mtd_info *mtd);
> +void nand_command(struct mtd_info *mtd, unsigned int command, int column,
> +		int page_addr);
> +void nand_command_lp(struct mtd_info *mtd, unsigned int command, int column,
> +		 int page_addr);
> +int nand_get_device (struct nand_chip *this, struct mtd_info *mtd,
> +		int new_state);
> +int nand_wait(struct mtd_info *mtd, struct nand_chip *this);
> +int nand_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
> +		uint8_t *buf, int page);
> +static int nand_read_page_raw_syndrome(struct mtd_info *mtd,
> +		struct nand_chip *chip, uint8_t *buf, int page);
> +int nand_read_subpage(struct mtd_info *mtd, struct nand_chip *chip,
> +		uint32_t data_offs, uint32_t readlen, uint8_t *bufpoi);
> +int nand_read_page_swecc(struct mtd_info *mtd, struct nand_chip *chip,
> +		uint8_t *buf, int page);
> +int nand_read_subpage(struct mtd_info *mtd, struct nand_chip *chip,
> +		uint32_t data_offs, uint32_t readlen, uint8_t *bufpoi);
> +int nand_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
> +		uint8_t *buf, int page);
> +int nand_read_page_hwecc_oob_first(struct mtd_info *mtd,
> +		struct nand_chip *chip, uint8_t *buf, int page);
> +int nand_read_page_syndrome(struct mtd_info *mtd,
> +		struct nand_chip *chip, uint8_t *buf, int page);
> +uint8_t *nand_transfer_oob(struct nand_chip *chip, uint8_t *oob,
> +		struct mtd_oob_ops *ops, size_t len);
> +int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
> +		struct mtd_oob_ops *ops);
> +int nand_read_oob_std(struct mtd_info *mtd, struct nand_chip *chip,
> +		int page, int sndcmd);
> +int nand_read_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
> +		int page, int sndcmd);
> +int nand_write_oob_std(struct mtd_info *mtd, struct nand_chip *chip,
> +		int page);
> +int nand_write_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
> +		int page);
> +int nand_do_read_oob(struct mtd_info *mtd, loff_t from,
> +		struct mtd_oob_ops *ops);
> +int nand_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops);
> +void nand_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
> +		const uint8_t *buf);
> +void nand_write_page_raw_syndrome(struct mtd_info *mtd,
> +		struct nand_chip *chip, const uint8_t *buf);
> +void nand_write_page_swecc(struct mtd_info *mtd, struct nand_chip *chip,
> +		const uint8_t *buf);
> +void nand_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
> +		const uint8_t *buf);
> +void nand_write_page_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
> +		const uint8_t *buf);
> +int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip,
> +		const uint8_t *buf, int page, int cached, int raw);
> +uint8_t *nand_fill_oob(struct nand_chip *chip, uint8_t *oob,
> +		struct mtd_oob_ops *ops);
> +int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
> +		struct mtd_oob_ops *ops);
> +int nand_do_write_oob(struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops);
> +int nand_write_oob(struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops);
> +void single_erase_cmd(struct mtd_info *mtd, int page);
> +void multi_erase_cmd(struct mtd_info *mtd, int page);
> +int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr,
> +		int allowbbt);
> +int nand_read(struct mtd_info *mtd, loff_t from, size_t len,
> +		size_t *retlen, uint8_t *buf);
> +int nand_write(struct mtd_info *mtd, loff_t to, size_t len,
> +		size_t *retlen, const uint8_t *buf);
> +int nand_erase(struct mtd_info *mtd, struct erase_info *instr);
> +void nand_sync(struct mtd_info *mtd);
> +int nand_block_isbad(struct mtd_info *mtd, loff_t offs);
> +int nand_block_markbad(struct mtd_info *mtd, loff_t ofs);
> +void nand_set_defaults(struct nand_chip *chip, int busw);
> +u16 onfi_crc16(u16 crc, u8 const *p, size_t len);
> +int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip,
> +		int *busw);
> +void nand_flash_detect_non_onfi(struct mtd_info *mtd, struct nand_chip *chip,
> +		const struct nand_flash_dev *type, int *busw);
> +const struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
> +		struct nand_chip *chip, int busw, int *maf_id, int *dev_id,
> +		const struct nand_flash_dev *type);
> +int nand_scan_ident(struct mtd_info *mtd, int maxchips,
> +		const struct nand_flash_dev *table);
> +int nand_scan_tail(struct mtd_info *mtd);
> +int nand_scan(struct mtd_info *mtd, int maxchips);
> +void nand_release(struct mtd_info *mtd);

Can we limit the scope of this to functions (or classes thereof -- if we
export one buffer function might as well export all the variants) that
we actually need from a current SPL?

> diff --git a/nand_spl/board/samsung/smdk6400/Makefile b/nand_spl/board/samsung/smdk6400/Makefile
> index 2f9c307..32ea116 100644
> --- a/nand_spl/board/samsung/smdk6400/Makefile
> +++ b/nand_spl/board/samsung/smdk6400/Makefile
> @@ -33,12 +33,12 @@ nandobj	:= $(OBJTREE)/nand_spl/
>  
>  LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
>  LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
> -	   $(LDFLAGS_FINAL)
> +	   $(LDFLAGS_FINAL) -gc-sections
>  AFLAGS	+= -DCONFIG_NAND_SPL
> -CFLAGS	+= -DCONFIG_NAND_SPL
> +CFLAGS	+= -DCONFIG_NAND_SPL -ffunction-sections 

Are gc-sections/function-sections not already being set?

>  SOBJS	= start.o cpu_init.o lowlevel_init.o
> -COBJS	= nand_boot.o nand_ecc.o s3c64xx.o smdk6400_nand_spl.o
> +COBJS	= nand_boot.o nand_ecc.o s3c64xx.o smdk6400_nand_spl.o nand_base.o
>  
>  SRCS	:= $(addprefix $(obj),$(SOBJS:.o=.S) $(COBJS:.o=.c))
>  OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
> @@ -98,6 +98,10 @@ $(obj)smdk6400_nand_spl.c:
>  	@rm -f $@
>  	@ln -s $(TOPDIR)/board/samsung/smdk6400/smdk6400_nand_spl.c $@
>  
> +$(obj)nand_base.c:
> +	@rm -f $@
> +	@ln -s $(TOPDIR)/drivers/mtd/nand/nand_base.c $@

This is a separate (albeit dependent) change from the NAND function
exporting, BTW.

-Scott

  parent reply	other threads:[~2011-09-23 17:22 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-18 23:39 [U-Boot] Please pull u-boot-ti/next s-paulraj at ti.com
2011-09-19  7:15 ` Albert ARIBAUD
2011-09-19  7:47   ` Wolfgang Denk
2011-09-19 12:11     ` Albert ARIBAUD
2011-09-19 14:21       ` Paulraj, Sandeep
2011-09-20  6:47         ` [U-Boot] SMDK6400 regression (was: Please pull u-boot-ti/next) Albert ARIBAUD
2011-09-20  7:38           ` [U-Boot] SMDK6400 regression Simon Schwarz
2011-09-21  9:13           ` Simon Schwarz
2011-09-21 19:35             ` Scott Wood
2011-09-23 16:36               ` [U-Boot] [PATCH RFC] Add general nand functions Simon Schwarz
2011-09-23 16:42                 ` Simon Schwarz
2011-09-23 17:22                 ` Scott Wood [this message]
2011-09-26  8:27                   ` Simon Schwarz
2011-09-27  0:28                     ` Scott Wood
2011-09-27 10:09                       ` [U-Boot] [PATCH RFC 1/3] nand: Remove static modifier from common functions Simon Schwarz
2011-09-27 10:09                         ` [U-Boot] [PATCH RFC 2/3] nand: Add common functions to nand.h Simon Schwarz
2011-09-27 10:09                         ` [U-Boot] [PATCH RFC 3/3] Fix regression in SMDK6400 Simon Schwarz
2011-09-27 10:14                       ` [U-Boot] [PATCH RFC] Add general nand functions Simon Schwarz
2011-09-27 22:50                         ` Scott Wood
2011-09-28  8:48                           ` Simon Schwarz
2011-09-20  6:49 ` [U-Boot] Please pull u-boot-ti/next Albert ARIBAUD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E7CC073.3070000@freescale.com \
    --to=scottwood@freescale.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.