public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] nand_get_device() and nand_release_device()
@ 2012-05-07 16:14 Timur Tabi
  2012-05-15 20:32 ` Scott Wood
  0 siblings, 1 reply; 2+ messages in thread
From: Timur Tabi @ 2012-05-07 16:14 UTC (permalink / raw)
  To: u-boot

Scott,

As you know, the P1022 has this weird LBC/DIU muxing problem.  I'd like to
add support for the 'nand' command while the DIU is active.  Looking at
the NAND code, I see functions nand_get_device() and
nand_release_device().  What is the idea behind these functions?  Would it
make sense to do something like this:


static int __board_start_nand(void)
{
	return 0;
}
int board_start_nand(void) __attribute__((weak, alias("__board_start_nand")));

static void __board_finish_nand(void)
{
}
void board_finish_nand(void) __attribute__((weak,
alias("__board_finish_nand")));


static int nand_get_device(struct nand_chip *chip, struct mtd_info *mtd,
int new_state)
{
	chip->state = new_state;

	return board_start_nand();
}

static void nand_release_device(struct mtd_info *mtd)
{
	struct nand_chip *chip = mtd->priv;

	board_finish_nand();

	/* De-select the NAND device */
	chip->select_chip(mtd, -1);
}

-- 
Timur Tabi
Linux kernel developer at Freescale

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [U-Boot] nand_get_device() and nand_release_device()
  2012-05-07 16:14 [U-Boot] nand_get_device() and nand_release_device() Timur Tabi
@ 2012-05-15 20:32 ` Scott Wood
  0 siblings, 0 replies; 2+ messages in thread
From: Scott Wood @ 2012-05-15 20:32 UTC (permalink / raw)
  To: u-boot

On 05/07/2012 11:14 AM, Timur Tabi wrote:
> Scott,
> 
> As you know, the P1022 has this weird LBC/DIU muxing problem.  I'd like to
> add support for the 'nand' command while the DIU is active.  Looking at
> the NAND code, I see functions nand_get_device() and
> nand_release_device().  What is the idea behind these functions? 

In U-Boot they don't do much.  In Linux they handle locking

> Would it
> make sense to do something like this:
> 
> 
> static int __board_start_nand(void)
> {
> 	return 0;
> }
> int board_start_nand(void) __attribute__((weak, alias("__board_start_nand")));
> 
> static void __board_finish_nand(void)
> {
> }
> void board_finish_nand(void) __attribute__((weak,
> alias("__board_finish_nand")));
> 
> 
> static int nand_get_device(struct nand_chip *chip, struct mtd_info *mtd,
> int new_state)
> {
> 	chip->state = new_state;
> 
> 	return board_start_nand();
> }
> 
> static void nand_release_device(struct mtd_info *mtd)
> {
> 	struct nand_chip *chip = mtd->priv;
> 
> 	board_finish_nand();
> 
> 	/* De-select the NAND device */
> 	chip->select_chip(mtd, -1);
> }
> 

What's wrong with the existing select_chip interface?

And if something new is needed, please use the function pointer
interface rather than weak symbols, and do it first in Linux.

-Scott

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-05-15 20:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-07 16:14 [U-Boot] nand_get_device() and nand_release_device() Timur Tabi
2012-05-15 20:32 ` Scott Wood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox