diff mbox

[U-Boot,RESEND,v5,1/6] cgtqmx6eval: Add SPI NOR flash support

Message ID 1447440549-23145-1-git-send-email-otavio@ossystems.com.br
State Superseded
Delegated to: Jagannadha Sutradharudu Teki
Headers show

Commit Message

Otavio Salvador Nov. 13, 2015, 6:49 p.m. UTC
Add SPI NOR support:

=> sf probe
SF: Detected SST25VF032B with page size 256 Bytes, erase size 4 KiB, total 4 MiB

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
---

Changes in v5: None
Changes in v4: None

 board/congatec/cgtqmx6eval/cgtqmx6eval.c | 23 +++++++++++++++++++++++
 include/configs/cgtqmx6eval.h            | 12 ++++++++++++
 2 files changed, 35 insertions(+)

Comments

Jagan Teki Nov. 17, 2015, 6:07 a.m. UTC | #1
On 14 November 2015 at 00:19, Otavio Salvador <otavio@ossystems.com.br> wrote:
> Add SPI NOR support:
>
> => sf probe
> SF: Detected SST25VF032B with page size 256 Bytes, erase size 4 KiB, total 4 MiB
>
> Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>

I have asked to move the spi_nor int stuff on #ifdef CONFIG_SPI_MXC in
previous patch any response on that?

> ---
>
> Changes in v5: None
> Changes in v4: None
>
>  board/congatec/cgtqmx6eval/cgtqmx6eval.c | 23 +++++++++++++++++++++++
>  include/configs/cgtqmx6eval.h            | 12 ++++++++++++
>  2 files changed, 35 insertions(+)
>
> diff --git a/board/congatec/cgtqmx6eval/cgtqmx6eval.c b/board/congatec/cgtqmx6eval/cgtqmx6eval.c
> index cf5607b..18e408b 100644
> --- a/board/congatec/cgtqmx6eval/cgtqmx6eval.c
> +++ b/board/congatec/cgtqmx6eval/cgtqmx6eval.c
> @@ -45,6 +45,10 @@ DECLARE_GLOBAL_DATA_PTR;
>         PAD_CTL_DSE_40ohm | PAD_CTL_HYS |                       \
>         PAD_CTL_ODE | PAD_CTL_SRE_FAST)
>
> +#define SPI_PAD_CTRL (PAD_CTL_HYS |                            \
> +       PAD_CTL_SPEED_MED |             \
> +       PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST)
> +
>  #define MX6Q_QMX6_PFUZE_MUX            IMX_GPIO_NR(6, 9)
>
>
> @@ -152,6 +156,13 @@ static iomux_v3_cfg_t enet_pads_ar8035[] = {
>         MX6_PAD_RGMII_RX_CTL__RGMII_RX_CTL | MUX_PAD_CTRL(ENET_PAD_CTRL),
>  };
>
> +static iomux_v3_cfg_t const ecspi1_pads[] = {
> +       MX6_PAD_EIM_D16__ECSPI1_SCLK | MUX_PAD_CTRL(SPI_PAD_CTRL),
> +       MX6_PAD_EIM_D17__ECSPI1_MISO | MUX_PAD_CTRL(SPI_PAD_CTRL),
> +       MX6_PAD_EIM_D18__ECSPI1_MOSI | MUX_PAD_CTRL(SPI_PAD_CTRL),
> +       MX6_PAD_EIM_D19__GPIO3_IO19 | MUX_PAD_CTRL(NO_PAD_CTRL),
> +};
> +
>  #define PC MUX_PAD_CTRL(I2C_PAD_CTRL)
>  struct i2c_pads_info i2c_pad_info1 = {
>         .scl = {
> @@ -381,6 +392,12 @@ static void setup_iomux_uart(void)
>         imx_iomux_v3_setup_multiple_pads(uart2_pads, ARRAY_SIZE(uart2_pads));
>  }
>
> +void setup_spinor(void)
> +{
> +       imx_iomux_v3_setup_multiple_pads(ecspi1_pads, ARRAY_SIZE(ecspi1_pads));
> +       gpio_direction_output(IMX_GPIO_NR(3, 19), 0);
> +}
> +
>  #ifdef CONFIG_FSL_ESDHC
>  static struct fsl_esdhc_cfg usdhc_cfg[] = {
>         {USDHC2_BASE_ADDR},
> @@ -646,6 +663,7 @@ int board_early_init_f(void)
>  {
>         setup_iomux_uart();
>         setup_display();
> +       setup_spinor();
>
>         return 0;
>  }
> @@ -671,6 +689,11 @@ int checkboard(void)
>         return 0;
>  }
>
> +int board_spi_cs_gpio(unsigned bus, unsigned cs)
> +{
> +       return (bus == 0 && cs == 0) ? (IMX_GPIO_NR(3, 19)) : -EINVAL;
> +}
> +
>  #ifdef CONFIG_CMD_BMODE
>  static const struct boot_mode board_boot_modes[] = {
>         /* 4 bit bus width */
> diff --git a/include/configs/cgtqmx6eval.h b/include/configs/cgtqmx6eval.h
> index e0aa4b0..9aa66c7 100644
> --- a/include/configs/cgtqmx6eval.h
> +++ b/include/configs/cgtqmx6eval.h
> @@ -29,6 +29,16 @@
>  /* MMC Configs */
>  #define CONFIG_SYS_FSL_ESDHC_ADDR      0
>
> +/* SPI NOR */
> +#define CONFIG_CMD_SF
> +#define CONFIG_SPI_FLASH
> +#define CONFIG_SPI_FLASH_STMICRO
> +#define CONFIG_SPI_FLASH_SST
> +#define CONFIG_MXC_SPI
> +#define CONFIG_SF_DEFAULT_BUS          0
> +#define CONFIG_SF_DEFAULT_SPEED                20000000
> +#define CONFIG_SF_DEFAULT_MODE         (SPI_MODE_0)
> +
>  /* Miscellaneous commands */
>  #define CONFIG_CMD_BMODE
>
> @@ -200,8 +210,10 @@
>                 "else " \
>                         "bootz; " \
>                 "fi;\0" \
> +       "spilock=sf probe && sf protect lock 0x3f0000 0x10000;"\
>
>  #define CONFIG_BOOTCOMMAND \
> +       "run spilock;"      \
>         "mmc dev ${mmcdev};" \
>         "if mmc rescan; then " \
>                 "if run loadbootscript; then " \
> --
> 2.6.2
>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
Otavio Salvador Nov. 17, 2015, 10:30 a.m. UTC | #2
On Tue, Nov 17, 2015 at 4:07 AM, Jagan Teki <jteki@openedev.com> wrote:
> On 14 November 2015 at 00:19, Otavio Salvador <otavio@ossystems.com.br> wrote:
>> Add SPI NOR support:
>>
>> => sf probe
>> SF: Detected SST25VF032B with page size 256 Bytes, erase size 4 KiB, total 4 MiB
>>
>> Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
>
> I have asked to move the spi_nor int stuff on #ifdef CONFIG_SPI_MXC in
> previous patch any response on that?

I missed this; but any other request so we can finally get this merged?
Jagan Teki Nov. 17, 2015, 6:24 p.m. UTC | #3
On 17 November 2015 at 16:00, Otavio Salvador
<otavio.salvador@ossystems.com.br> wrote:
> On Tue, Nov 17, 2015 at 4:07 AM, Jagan Teki <jteki@openedev.com> wrote:
>> On 14 November 2015 at 00:19, Otavio Salvador <otavio@ossystems.com.br> wrote:
>>> Add SPI NOR support:
>>>
>>> => sf probe
>>> SF: Detected SST25VF032B with page size 256 Bytes, erase size 4 KiB, total 4 MiB
>>>
>>> Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
>>
>> I have asked to move the spi_nor int stuff on #ifdef CONFIG_SPI_MXC in
>> previous patch any response on that?
>
> I missed this; but any other request so we can finally get this merged?

No other comments please add the driver #ifdef on spi_nor init code
and send the next version patch.

thanks!
Fabio Estevam Nov. 18, 2015, 9:20 p.m. UTC | #4
Hi Jagan,

On Tue, Nov 17, 2015 at 4:07 AM, Jagan Teki <jteki@openedev.com> wrote:
> On 14 November 2015 at 00:19, Otavio Salvador <otavio@ossystems.com.br> wrote:
>> Add SPI NOR support:
>>
>> => sf probe
>> SF: Detected SST25VF032B with page size 256 Bytes, erase size 4 KiB, total 4 MiB
>>
>> Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
>
> I have asked to move the spi_nor int stuff on #ifdef CONFIG_SPI_MXC in
> previous patch any response on that?

Is this really needed?

Given that:

- The boot medium of this board is SPI NOR
- We want CONFIG_SPI_MXC to be always selected
- We don't want to polute the code with ifdef's

I thinks the code is fine as is.

Regards,

Fabio Estevam
Jagan Teki Nov. 19, 2015, 8:27 a.m. UTC | #5
Hi Fabio,

On 19 November 2015 at 02:50, Fabio Estevam <festevam@gmail.com> wrote:
> Hi Jagan,
>
> On Tue, Nov 17, 2015 at 4:07 AM, Jagan Teki <jteki@openedev.com> wrote:
>> On 14 November 2015 at 00:19, Otavio Salvador <otavio@ossystems.com.br> wrote:
>>> Add SPI NOR support:
>>>
>>> => sf probe
>>> SF: Detected SST25VF032B with page size 256 Bytes, erase size 4 KiB, total 4 MiB
>>>
>>> Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
>>
>> I have asked to move the spi_nor int stuff on #ifdef CONFIG_SPI_MXC in
>> previous patch any response on that?
>
> Is this really needed?
>
> Given that:
>
> - The boot medium of this board is SPI NOR
> - We want CONFIG_SPI_MXC to be always selected
> - We don't want to polute the code with ifdef's

Since it's u-boot, size is main constraint ie the main reason to use
ifdef and also this initialization code must be part of driver probe
instead of board file, once the driver moved to dm then will move this
as well so to indicate that this could be a driver code better to use
the driver config in #ifdef.

See this
$ grep -R CONFIG_MXC_SPI board/

And use setup_spi instead of setup_spinor

>
> I thinks the code is fine as is.

thanks!
Fabio Estevam Nov. 19, 2015, 2:42 p.m. UTC | #6
On Thu, Nov 19, 2015 at 6:27 AM, Jagan Teki <jteki@openedev.com> wrote:

> Since it's u-boot, size is main constraint ie the main reason to use
> ifdef and also this initialization code must be part of driver probe
> instead of board file, once the driver moved to dm then will move this
> as well so to indicate that this could be a driver code better to use
> the driver config in #ifdef.

In this board CONFIG_SPI_MXC will always be selected, so size
constraint does not apply here.

> See this
> $ grep -R CONFIG_MXC_SPI board/
>
> And use setup_spi instead of setup_spinor

What is the reason for that?
Jagan Teki Nov. 19, 2015, 3:49 p.m. UTC | #7
On 19 November 2015 at 20:12, Fabio Estevam <festevam@gmail.com> wrote:
> On Thu, Nov 19, 2015 at 6:27 AM, Jagan Teki <jteki@openedev.com> wrote:
>
>> Since it's u-boot, size is main constraint ie the main reason to use
>> ifdef and also this initialization code must be part of driver probe
>> instead of board file, once the driver moved to dm then will move this
>> as well so to indicate that this could be a driver code better to use
>> the driver config in #ifdef.
>
> In this board CONFIG_SPI_MXC will always be selected, so size
> constraint does not apply here.

I'm saying about setup_spinor init code see  "grep -R CONFIG_MXC_SPI
board/ " how they defined.

>
>> See this
>> $ grep -R CONFIG_MXC_SPI board/
>>
>> And use setup_spi instead of setup_spinor
>
> What is the reason for that?

Because this is spi controller setup not the spi_nor - please see the
boards which uses CONFIG_MXC_SPI

$ grep -R CONFIG_MXC_SPI board/

thanks!
diff mbox

Patch

diff --git a/board/congatec/cgtqmx6eval/cgtqmx6eval.c b/board/congatec/cgtqmx6eval/cgtqmx6eval.c
index cf5607b..18e408b 100644
--- a/board/congatec/cgtqmx6eval/cgtqmx6eval.c
+++ b/board/congatec/cgtqmx6eval/cgtqmx6eval.c
@@ -45,6 +45,10 @@  DECLARE_GLOBAL_DATA_PTR;
 	PAD_CTL_DSE_40ohm | PAD_CTL_HYS |			\
 	PAD_CTL_ODE | PAD_CTL_SRE_FAST)
 
+#define SPI_PAD_CTRL (PAD_CTL_HYS |				\
+	PAD_CTL_SPEED_MED |		\
+	PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST)
+
 #define MX6Q_QMX6_PFUZE_MUX		IMX_GPIO_NR(6, 9)
 
 
@@ -152,6 +156,13 @@  static iomux_v3_cfg_t enet_pads_ar8035[] = {
 	MX6_PAD_RGMII_RX_CTL__RGMII_RX_CTL | MUX_PAD_CTRL(ENET_PAD_CTRL),
 };
 
+static iomux_v3_cfg_t const ecspi1_pads[] = {
+	MX6_PAD_EIM_D16__ECSPI1_SCLK | MUX_PAD_CTRL(SPI_PAD_CTRL),
+	MX6_PAD_EIM_D17__ECSPI1_MISO | MUX_PAD_CTRL(SPI_PAD_CTRL),
+	MX6_PAD_EIM_D18__ECSPI1_MOSI | MUX_PAD_CTRL(SPI_PAD_CTRL),
+	MX6_PAD_EIM_D19__GPIO3_IO19 | MUX_PAD_CTRL(NO_PAD_CTRL),
+};
+
 #define PC MUX_PAD_CTRL(I2C_PAD_CTRL)
 struct i2c_pads_info i2c_pad_info1 = {
 	.scl = {
@@ -381,6 +392,12 @@  static void setup_iomux_uart(void)
 	imx_iomux_v3_setup_multiple_pads(uart2_pads, ARRAY_SIZE(uart2_pads));
 }
 
+void setup_spinor(void)
+{
+	imx_iomux_v3_setup_multiple_pads(ecspi1_pads, ARRAY_SIZE(ecspi1_pads));
+	gpio_direction_output(IMX_GPIO_NR(3, 19), 0);
+}
+
 #ifdef CONFIG_FSL_ESDHC
 static struct fsl_esdhc_cfg usdhc_cfg[] = {
 	{USDHC2_BASE_ADDR},
@@ -646,6 +663,7 @@  int board_early_init_f(void)
 {
 	setup_iomux_uart();
 	setup_display();
+	setup_spinor();
 
 	return 0;
 }
@@ -671,6 +689,11 @@  int checkboard(void)
 	return 0;
 }
 
+int board_spi_cs_gpio(unsigned bus, unsigned cs)
+{
+	return (bus == 0 && cs == 0) ? (IMX_GPIO_NR(3, 19)) : -EINVAL;
+}
+
 #ifdef CONFIG_CMD_BMODE
 static const struct boot_mode board_boot_modes[] = {
 	/* 4 bit bus width */
diff --git a/include/configs/cgtqmx6eval.h b/include/configs/cgtqmx6eval.h
index e0aa4b0..9aa66c7 100644
--- a/include/configs/cgtqmx6eval.h
+++ b/include/configs/cgtqmx6eval.h
@@ -29,6 +29,16 @@ 
 /* MMC Configs */
 #define CONFIG_SYS_FSL_ESDHC_ADDR      0
 
+/* SPI NOR */
+#define CONFIG_CMD_SF
+#define CONFIG_SPI_FLASH
+#define CONFIG_SPI_FLASH_STMICRO
+#define CONFIG_SPI_FLASH_SST
+#define CONFIG_MXC_SPI
+#define CONFIG_SF_DEFAULT_BUS		0
+#define CONFIG_SF_DEFAULT_SPEED		20000000
+#define CONFIG_SF_DEFAULT_MODE		(SPI_MODE_0)
+
 /* Miscellaneous commands */
 #define CONFIG_CMD_BMODE
 
@@ -200,8 +210,10 @@ 
 		"else " \
 			"bootz; " \
 		"fi;\0" \
+	"spilock=sf probe && sf protect lock 0x3f0000 0x10000;"\
 
 #define CONFIG_BOOTCOMMAND \
+	"run spilock;"	    \
 	"mmc dev ${mmcdev};" \
 	"if mmc rescan; then " \
 		"if run loadbootscript; then " \