From: Stefano Babic <sbabic@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/3] mx53_smd: add spi nor support
Date: Fri, 17 Aug 2012 12:36:34 +0200 [thread overview]
Message-ID: <502E1EB2.3070206@denx.de> (raw)
In-Reply-To: <1345012685-24932-1-git-send-email-r65388@freescale.com>
On 15/08/2012 08:38, Terry Lv wrote:
> Add spi nor support to mx53 smd, including iomux, configs, etc.
> To test spi nor on mx53 smd:
Hi Terry,
> MX53SMD U-Boot > sf probe 0:21249
> JEDEC ID: 0x202016
> m25p32 (4096 Kbytes)
> SF: Detected m25p32 with page size 0 Bytes, total 4 MiB
>
> Here, 21249 is integer of hex 0x5301. 0x01 is cs and 0x53 is active gpio
> number.
I think sf probe accepts also parameter in hex, such as sf probe 0x5301.
>
> Signed-off-by: Terry Lv <r65388@freescale.com>
> ---
> board/freescale/mx53smd/mx53smd.c | 63 +++++++++++++++++++++++++++++++++++++
> include/configs/mx53smd.h | 17 ++++++++++
> 2 files changed, 80 insertions(+), 0 deletions(-)
>
> diff --git a/board/freescale/mx53smd/mx53smd.c b/board/freescale/mx53smd/mx53smd.c
> index 87fa7fa..abb1e9b 100644
> --- a/board/freescale/mx53smd/mx53smd.c
> +++ b/board/freescale/mx53smd/mx53smd.c
> @@ -127,6 +127,65 @@ static void setup_iomux_fec(void)
> PAD_CTL_HYS_ENABLE | PAD_CTL_PKE_ENABLE);
> }
>
> +#ifdef CONFIG_MXC_SPI
> +static void setup_iomux_spi(u8 bus, u8 ss)
> +{
> + switch (bus) {
> + case 0:
> + /* SCLK */
> + mxc_request_iomux(MX53_PIN_EIM_D16, IOMUX_CONFIG_ALT4);
> + mxc_iomux_set_pad(MX53_PIN_EIM_D16,
> + PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH);
> + mxc_iomux_set_input(MX53_ECSPI1_IPP_CSPI_CLK_IN_SELECT_INPUT,
> + 0x3);
> +
> + /* MISO */
> + mxc_request_iomux(MX53_PIN_EIM_D17, IOMUX_CONFIG_ALT4);
> + mxc_iomux_set_pad(MX53_PIN_EIM_D17,
> + PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH);
> + mxc_iomux_set_input(MX53_ECSPI1_IPP_IND_MISO_SELECT_INPUT,
> + 0x3);
> +
> + /* MOSI */
> + mxc_request_iomux(MX53_PIN_EIM_D18, IOMUX_CONFIG_ALT4);
> + mxc_iomux_set_pad(MX53_PIN_EIM_D18,
> + PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH);
> + mxc_iomux_set_input(MX53_ECSPI1_IPP_IND_MOSI_SELECT_INPUT,
> + 0x3);
> +
> + if (0 == ss) {
> + mxc_request_iomux(MX53_PIN_EIM_EB2,
> + IOMUX_CONFIG_ALT4);
> + mxc_iomux_set_pad(MX53_PIN_EIM_EB2,
> + PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH);
> + mxc_iomux_set_input(
> + MX53_ECSPI1_IPP_IND_SS_B_1_SELECT_INPUT,
> + 0x3);
> +
> + mxc_request_iomux(MX53_PIN_EIM_EB2, IOMUX_CONFIG_ALT1);
> + mxc_iomux_set_pad(MX53_PIN_EIM_EB2,
> + PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH);
> + } else if (1 == ss){
> + mxc_request_iomux(MX53_PIN_EIM_D19, IOMUX_CONFIG_ALT4);
> + mxc_iomux_set_pad(MX53_PIN_EIM_D19,
> + PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH);
> + mxc_iomux_set_input(
> + MX53_ECSPI1_IPP_IND_SS_B_2_SELECT_INPUT,
> + 0x2);
> +
> + mxc_request_iomux(MX53_PIN_EIM_D19, IOMUX_CONFIG_ALT1);
> + mxc_iomux_set_pad(MX53_PIN_EIM_D19,
> + PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH);
> + }
Instead of this if-else, it can be more readable if you introduce a
switch-case, printing in the default case an error message if the cs is
not expected.
> + break;
> + case 1:
> + case 2:
> + default:
> + break;
bus different as 1 is an error currently on this board. Insert a default
case, with some message as "unsupported" or such like that.
> diff --git a/include/configs/mx53smd.h b/include/configs/mx53smd.h
> index 48b32dd..e830c1b 100644
> --- a/include/configs/mx53smd.h
> +++ b/include/configs/mx53smd.h
> @@ -65,6 +65,23 @@
> #define CONFIG_CMD_FAT
> #define CONFIG_DOS_PARTITION
>
> +/* SPI Configs*/
> +#define CONFIG_CMD_SPI
> +#define CONFIG_MXC_SPI
> +#define CONFIG_SPI_VER_2_3 1
Ok, this depends on your previous patchset. It must be merged firstly
before applying this series. Can you mention it in the next changelog ?
> +#define CONFIG_CSPI1_BASE_ADDR CSPI1_BASE_ADDR
> +#define CONFIG_CSPI2_BASE_ADDR CSPI2_BASE_ADDR
> +#define CONFIG_CSPI3_BASE_ADDR CSPI3_BASE_ADDR
> +
> +/* SPI Flash Configs */
> +#define CONFIG_CMD_SF
> +#define CONFIG_SPI_FLASH
> +#define CONFIG_SPI_FLASH_STMICRO 1
> +#define CONFIG_SF_DEFAULT_SPEED 25000000
> +#define CONFIG_SF_DEFAULT_MODE (SPI_MODE_0)
> +#define CONFIG_SPI_FLASH_BUS 0
> +#define CONFIG_SPI_FLASH_CS 1
There is also a CONFIG_SF_DEFAULT_CS, if you like to use it. You can set
it to 0x5301 (better write as in your comment, (GPIO << 8) + CS) and sf
probe will take it automatically.
Best regards,
Stefano Babic
--
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
=====================================================================
prev parent reply other threads:[~2012-08-17 10:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-15 6:38 [U-Boot] [PATCH 1/3] mx53_smd: add spi nor support Terry Lv
2012-08-15 6:38 ` [U-Boot] [PATCH 2/3] mxc_spi: change to use version config instead of soc config in mxc_spi Terry Lv
2012-08-17 10:44 ` Stefano Babic
2012-08-15 6:38 ` [U-Boot] [PATCH 3/3] mxc_spi: apply new mxc_spi version configs to other soc configs Terry Lv
2012-08-17 10:46 ` Stefano Babic
2012-08-17 10:36 ` Stefano Babic [this message]
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=502E1EB2.3070206@denx.de \
--to=sbabic@denx.de \
--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.