From: Igor Grinberg <grinberg@compulab.co.il>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v4 10/14] OMAP3 SPL: Add identify_nand_chip function
Date: Sun, 20 Nov 2011 09:36:20 +0200 [thread overview]
Message-ID: <4EC8ADF4.8050702@compulab.co.il> (raw)
In-Reply-To: <1321656491-19874-11-git-send-email-trini@ti.com>
Hi Tom,
On 11/19/11 00:48, Tom Rini wrote:
> A number of boards are populated with a PoP chip for both DDR and NAND
> memory. Other boards may simply use this as an easy way to identify
> board revs. So we provide a function that can be called early to reset
> the NAND chip and return the result of NAND_CMD_READID. All of this
> code is put into spl_id_nand.c and controlled via CONFIG_SPL_OMAP3_ID_NAND.
>
> Signed-off-by: Tom Rini <trini@ti.com>
> ---
> arch/arm/cpu/armv7/omap3/Makefile | 3 +
> arch/arm/cpu/armv7/omap3/spl_id_nand.c | 87 +++++++++++++++++++++++++++
> arch/arm/include/asm/arch-omap3/sys_proto.h | 1 +
> 3 files changed, 91 insertions(+), 0 deletions(-)
> create mode 100644 arch/arm/cpu/armv7/omap3/spl_id_nand.c
>
> diff --git a/arch/arm/cpu/armv7/omap3/Makefile b/arch/arm/cpu/armv7/omap3/Makefile
> index 8e85891..4b38e45 100644
> --- a/arch/arm/cpu/armv7/omap3/Makefile
> +++ b/arch/arm/cpu/armv7/omap3/Makefile
> @@ -31,6 +31,9 @@ COBJS += board.o
> COBJS += clock.o
> COBJS += mem.o
> COBJS += sys_info.o
> +ifdef CONFIG_SPL_BUILD
> +COBJS-$(CONFIG_SPL_OMAP3_ID_NAND) += spl_id_nand.o
> +endif
You haven't responded to my question on the above stuff.
Otherwise all the series look good to me.
Original version available at:
http://www.mail-archive.com/u-boot at lists.denx.de/msg68828.html
Here is the relevant part:
>>> diff --git a/arch/arm/cpu/armv7/omap3/Makefile b/arch/arm/cpu/armv7/omap3/Makefile
>>> >>> index 8e85891..772f3d4 100644
>>> >>> --- a/arch/arm/cpu/armv7/omap3/Makefile
>>> >>> +++ b/arch/arm/cpu/armv7/omap3/Makefile
>>> >>> @@ -31,6 +31,9 @@ COBJS += board.o
>>> >>> COBJS += clock.o
>>> >>> COBJS += mem.o
>>> >>> COBJS += sys_info.o
>>> >>> +ifdef CONFIG_SPL_BUILD
>>> >>> +COBJS-$(CONFIG_SPL_OMAP3_POP_PROBE) += spl_pop_probe.o
>>> >>> +endif
>> >>
>> >> Can't CONFIG_SPL_OMAP3_..._PROBE symbol default to "no"
>> >> and depend on CONFIG_SPL_BUILD, so you don't need to enclose
>> >> it in #ifdef?
> >
> > But then it would build for both SPL and non-SPL cases.
No, it should not.
What do you think of the following:
In the Makefile have only:
COBJS-$(CONFIG_SPL_OMAP3_POP_PROBE) += spl_pop_probe.o
Then in the spl_pop_probe.c have this type of check:
#ifndef CONFIG_SPL_BUILD
# error CONFIG_SPL_OMAP3_POP_PROBE requires CONFIG_SPL_BUILD
#endif
This way, you require the CONFIG_SPL_OMAP3_POP_PROBE symbol
be a part of the CONFIG_SPL_BUILD symbols group.
>
> COBJS-$(CONFIG_EMIF4) += emif4.o
> COBJS-$(CONFIG_SDRC) += sdrc.o
> diff --git a/arch/arm/cpu/armv7/omap3/spl_id_nand.c b/arch/arm/cpu/armv7/omap3/spl_id_nand.c
> new file mode 100644
> index 0000000..0871fc9
> --- /dev/null
> +++ b/arch/arm/cpu/armv7/omap3/spl_id_nand.c
> @@ -0,0 +1,87 @@
> +/*
> + * (C) Copyright 2011
> + * Texas Instruments, <www.ti.com>
> + *
> + * Author :
> + * Tom Rini <trini@ti.com>
> + *
> + * Initial Code from:
> + * Richard Woodruff <r-woodruff2@ti.com>
> + * Jian Zhang <jzhang@ti.com>
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation; either version 2 of
> + * the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
> + * MA 02111-1307 USA
> + */
> +
> +#include <common.h>
> +#include <linux/mtd/nand.h>
> +#include <asm/io.h>
> +#include <asm/arch/sys_proto.h>
> +#include <asm/arch/mem.h>
> +
> +static struct gpmc *gpmc_config = (struct gpmc *)GPMC_BASE;
> +
> +/* nand_command: Send a flash command to the flash chip */
> +static void nand_command(u8 command)
> +{
> + writeb(command, &gpmc_config->cs[0].nand_cmd);
> +
> + if (command == NAND_CMD_RESET) {
> + unsigned char ret_val;
> + writeb(NAND_CMD_STATUS, &gpmc_config->cs[0].nand_cmd);
> + do {
> + /* Wait until ready */
> + ret_val = readl(&gpmc_config->cs[0].nand_dat);
> + } while ((ret_val & NAND_STATUS_READY) != NAND_STATUS_READY);
> + }
> +}
> +
> +/*
> + * Many boards will want to know the results of the NAND_CMD_READID command
> + * in order to decide what to do about DDR initialization. This function
> + * allows us to do that very early and to pass those results back to the
> + * board so it can make whatever decisions need to be made.
> + */
> +void identify_nand_chip(int *mfr, int *id)
> +{
> + /* Make sure that we have setup GPMC for NAND correctly. */
> + writel(M_NAND_GPMC_CONFIG1, &gpmc_config->cs[0].config1);
> + writel(M_NAND_GPMC_CONFIG2, &gpmc_config->cs[0].config2);
> + writel(M_NAND_GPMC_CONFIG3, &gpmc_config->cs[0].config3);
> + writel(M_NAND_GPMC_CONFIG4, &gpmc_config->cs[0].config4);
> + writel(M_NAND_GPMC_CONFIG5, &gpmc_config->cs[0].config5);
> + writel(M_NAND_GPMC_CONFIG6, &gpmc_config->cs[0].config6);
> +
> + /*
> + * Enable the config. The CS size goes in bits 11:8. We set
> + * bit 6 to enable the CS and the base address goes into bits 5:0.
> + */
> + writel((GPMC_SIZE_128M << 8) | (GPMC_CS_ENABLE << 6) |
> + ((NAND_BASE >> 24) & GPMC_BASEADDR_MASK),
> + &gpmc_config->cs[0].config7);
> +
> + sdelay(2000);
> +
> + /* Issue a RESET and then READID */
> + nand_command(NAND_CMD_RESET);
> + nand_command(NAND_CMD_READID);
> +
> + /* Set the address to read to 0x0 */
> + writeb(0x0, &gpmc_config->cs[0].nand_adr);
> +
> + /* Read off the manufacturer and device id. */
> + *mfr = readb(&gpmc_config->cs[0].nand_dat);
> + *id = readb(&gpmc_config->cs[0].nand_dat);
> +}
> diff --git a/arch/arm/include/asm/arch-omap3/sys_proto.h b/arch/arm/include/asm/arch-omap3/sys_proto.h
> index 80e167b..e5031d5 100644
> --- a/arch/arm/include/asm/arch-omap3/sys_proto.h
> +++ b/arch/arm/include/asm/arch-omap3/sys_proto.h
> @@ -40,6 +40,7 @@ void sdrc_init(void);
> void do_sdrc_init(u32, u32);
> void get_board_mem_timings(u32 *mcfg, u32 *ctrla, u32 *ctrlb, u32 *rfr_ctrl,
> u32 *mr);
> +void identify_nand_chip(int *mfr, int *id);
> void emif4_init(void);
> void gpmc_init(void);
> void enable_gpmc_cs_config(const u32 *gpmc_config, struct gpmc_cs *cs, u32 base,
--
Regards,
Igor.
next prev parent reply other threads:[~2011-11-20 7:36 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-18 22:47 [U-Boot] [PATCH v4 0/14] Add more framework to OMAP3 SPL, port more boards Tom Rini
2011-11-18 22:47 ` [U-Boot] [PATCH v4 01/14] omap3: mem: Comment enable_gpmc_cs_config more Tom Rini
2011-11-18 22:47 ` [U-Boot] [PATCH v4 02/14] OMAP3: Update SDRC dram_init to always call make_cs1_contiguous() Tom Rini
2011-11-18 22:48 ` [U-Boot] [PATCH v4 03/14] OMAP3: Add a helper function to set timings in SDRC Tom Rini
2011-11-18 22:48 ` [U-Boot] [PATCH v4 04/14] OMAP3: Change mem_ok to clear again after reading back Tom Rini
2011-11-18 22:48 ` [U-Boot] [PATCH v4 05/14] OMAP3: Remove get_mem_type prototype Tom Rini
2011-11-18 22:48 ` [U-Boot] [PATCH v4 06/14] omap3: mem: Add MCFG helper macro Tom Rini
2011-11-18 22:48 ` [U-Boot] [PATCH v4 07/14] OMAP3: Add optimal SDRC autorefresh control values Tom Rini
2011-11-18 22:48 ` [U-Boot] [PATCH v4 08/14] OMAP3: Suffix all Micron memory timing parts with their speed Tom Rini
2011-11-18 22:48 ` [U-Boot] [PATCH v4 09/14] OMAP3 SPL: Rework memory initalization and devkit8000 support Tom Rini
2011-11-18 22:48 ` [U-Boot] [PATCH v4 10/14] OMAP3 SPL: Add identify_nand_chip function Tom Rini
2011-11-20 7:36 ` Igor Grinberg [this message]
2011-11-20 14:26 ` Tom Rini
2011-11-21 7:04 ` Igor Grinberg
2011-11-21 14:12 ` Tom Rini
2011-11-21 14:41 ` Igor Grinberg
2011-11-21 15:33 ` Tom Rini
2011-11-22 14:33 ` Igor Grinberg
2011-11-22 14:51 ` Tom Rini
2011-11-22 15:39 ` Tom Rini
2011-11-23 7:39 ` Igor Grinberg
2011-11-23 14:48 ` Tom Rini
2011-11-18 22:48 ` [U-Boot] [PATCH v4 11/14] OMAP3: Add SPL support to Beagleboard Tom Rini
2011-11-18 22:48 ` [U-Boot] [PATCH v4 12/14] OMAP3: Add SPL support to omap3_evm Tom Rini
2011-11-29 22:20 ` Tom Rini
2011-11-18 22:48 ` [U-Boot] [PATCH v4 13/14] AM3517: Add SPL support Tom Rini
2011-11-18 22:48 ` [U-Boot] [PATCH v4 14/14] AM3517 CraneBoard: " Tom Rini
2011-11-29 21:55 ` [U-Boot] [PATCH v4 0/14] Add more framework to OMAP3 SPL, port more boards Tom Rini
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=4EC8ADF4.8050702@compulab.co.il \
--to=grinberg@compulab.co.il \
--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.