diff mbox

[U-Boot,3/3] ARM: configs: cm_fx6: add mtd support

Message ID c80e03b327e3441198284b3e1b080b2f@rwthex-s1-b.rwth-ad.de
State Accepted
Commit 63a930937755e97928a75fa3afe2c09f1800188e
Delegated to: Stefano Babic
Headers show

Commit Message

Christopher Spinrath June 19, 2016, 3:44 p.m. UTC
The cm-fx6 module has an on-board spi flash chip. Enable mtd support
and the mtdparts command. Also define a default partitioning, add
it to the default environment, and enable support to overwrite the
partitioning defined in a device tree by it.

These changes move the effective default partitioning from the device
tree shipped with the vendor kernels to u-boot which becomes the single
point of definition for the partitioning for all device tree based
kernels (in particular, for the upstream linux kernel which does not
have a default partitioning defined in its device tree).

Signed-off-by: Christopher Spinrath <christopher.spinrath@rwth-aachen.de>
---
 include/configs/cm_fx6.h | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

Comments

Igor Grinberg June 22, 2016, 4:15 p.m. UTC | #1
On 06/19/2016 06:44 PM, Christopher Spinrath wrote:
> The cm-fx6 module has an on-board spi flash chip. Enable mtd support
> and the mtdparts command. Also define a default partitioning, add
> it to the default environment, and enable support to overwrite the
> partitioning defined in a device tree by it.
> 
> These changes move the effective default partitioning from the device
> tree shipped with the vendor kernels to u-boot which becomes the single
> point of definition for the partitioning for all device tree based
> kernels (in particular, for the upstream linux kernel which does not
> have a default partitioning defined in its device tree).
> 
> Signed-off-by: Christopher Spinrath <christopher.spinrath@rwth-aachen.de>
> ---
>  include/configs/cm_fx6.h | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/include/configs/cm_fx6.h b/include/configs/cm_fx6.h
> index f054ca8..c839b03 100644
> --- a/include/configs/cm_fx6.h
> +++ b/include/configs/cm_fx6.h

[...]

> @@ -157,7 +174,7 @@
>  	"run setupnandboot;" \
>  	"run nandboot;"
>  
> -#define CONFIG_PREBOOT		"usb start"
> +#define CONFIG_PREBOOT		"usb start;sf probe"

Probably, this is really needed.
Care to explain?

>  
>  /* SPI */
>  #define CONFIG_SPI
>
Christopher Spinrath June 22, 2016, 7:27 p.m. UTC | #2
Hi Igor,

On 06/22/2016 06:15 PM, Igor Grinberg wrote:
> On 06/19/2016 06:44 PM, Christopher Spinrath wrote:
>> The cm-fx6 module has an on-board spi flash chip. Enable mtd support
>> and the mtdparts command. Also define a default partitioning, add
>> it to the default environment, and enable support to overwrite the
>> partitioning defined in a device tree by it.
>>
>> These changes move the effective default partitioning from the device
>> tree shipped with the vendor kernels to u-boot which becomes the single
>> point of definition for the partitioning for all device tree based
>> kernels (in particular, for the upstream linux kernel which does not
>> have a default partitioning defined in its device tree).
>>
>> Signed-off-by: Christopher Spinrath <christopher.spinrath@rwth-aachen.de>
>> ---
>>  include/configs/cm_fx6.h | 19 ++++++++++++++++++-
>>  1 file changed, 18 insertions(+), 1 deletion(-)
>>
>> diff --git a/include/configs/cm_fx6.h b/include/configs/cm_fx6.h
>> index f054ca8..c839b03 100644
>> --- a/include/configs/cm_fx6.h
>> +++ b/include/configs/cm_fx6.h
> 
> [...]
> 
>> @@ -157,7 +174,7 @@
>>  	"run setupnandboot;" \
>>  	"run nandboot;"
>>  
>> -#define CONFIG_PREBOOT		"usb start"
>> +#define CONFIG_PREBOOT		"usb start;sf probe"
> 
> Probably, this is really needed.
> Care to explain?
>
The sf probe command probes for the spi flash and registers (on success)
the device as nor0. This device is used by mtdparts (cf. the mtdids
variable; it maps the U-Boot name nor0 to the kernel name spi0.0) and
the mtd fixup code in patch 2 (cf. the nodes array; it specifies the
compatible of the flash chip of type NOR #0, i.e. nor0).

Without this all mtdparts commands will fail and the fixup code won't
work because there is nor0 device.

Cheers,
Christopher

>>  
>>  /* SPI */
>>  #define CONFIG_SPI
>>
>
Igor Grinberg June 23, 2016, 9:03 a.m. UTC | #3
On 06/22/2016 10:27 PM, Christopher Spinrath wrote:
> Hi Igor,
> 
> On 06/22/2016 06:15 PM, Igor Grinberg wrote:
>> On 06/19/2016 06:44 PM, Christopher Spinrath wrote:
>>> The cm-fx6 module has an on-board spi flash chip. Enable mtd support
>>> and the mtdparts command. Also define a default partitioning, add
>>> it to the default environment, and enable support to overwrite the
>>> partitioning defined in a device tree by it.
>>>
>>> These changes move the effective default partitioning from the device
>>> tree shipped with the vendor kernels to u-boot which becomes the single
>>> point of definition for the partitioning for all device tree based
>>> kernels (in particular, for the upstream linux kernel which does not
>>> have a default partitioning defined in its device tree).
>>>
>>> Signed-off-by: Christopher Spinrath <christopher.spinrath@rwth-aachen.de>
>>> ---
>>>  include/configs/cm_fx6.h | 19 ++++++++++++++++++-
>>>  1 file changed, 18 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/include/configs/cm_fx6.h b/include/configs/cm_fx6.h
>>> index f054ca8..c839b03 100644
>>> --- a/include/configs/cm_fx6.h
>>> +++ b/include/configs/cm_fx6.h
>>
>> [...]
>>
>>> @@ -157,7 +174,7 @@
>>>  	"run setupnandboot;" \
>>>  	"run nandboot;"
>>>  
>>> -#define CONFIG_PREBOOT		"usb start"
>>> +#define CONFIG_PREBOOT		"usb start;sf probe"
>>
>> Probably, this is really needed.
>> Care to explain?
>>
> The sf probe command probes for the spi flash and registers (on success)
> the device as nor0. This device is used by mtdparts (cf. the mtdids
> variable; it maps the U-Boot name nor0 to the kernel name spi0.0) and
> the mtd fixup code in patch 2 (cf. the nodes array; it specifies the
> compatible of the flash chip of type NOR #0, i.e. nor0).
> 
> Without this all mtdparts commands will fail and the fixup code won't
> work because there is nor0 device.

Thanks for the explanation!
That sounds to me like this should go away once we have the DM in place
for spi flash and MTD (added Simon to Cc).
Meanwhile, may be a short notice in the commit message?
Christopher Spinrath June 25, 2016, 3:05 p.m. UTC | #4
Hi Igor,

On 06/23/2016 11:03 AM, Igor Grinberg wrote:
> On 06/22/2016 10:27 PM, Christopher Spinrath wrote:
>> Hi Igor,
>>
>> On 06/22/2016 06:15 PM, Igor Grinberg wrote:
>>> On 06/19/2016 06:44 PM, Christopher Spinrath wrote:
>>>> The cm-fx6 module has an on-board spi flash chip. Enable mtd support
>>>> and the mtdparts command. Also define a default partitioning, add
>>>> it to the default environment, and enable support to overwrite the
>>>> partitioning defined in a device tree by it.
>>>>
>>>> These changes move the effective default partitioning from the device
>>>> tree shipped with the vendor kernels to u-boot which becomes the single
>>>> point of definition for the partitioning for all device tree based
>>>> kernels (in particular, for the upstream linux kernel which does not
>>>> have a default partitioning defined in its device tree).
>>>>
>>>> Signed-off-by: Christopher Spinrath <christopher.spinrath@rwth-aachen.de>
>>>> ---
>>>>  include/configs/cm_fx6.h | 19 ++++++++++++++++++-
>>>>  1 file changed, 18 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/include/configs/cm_fx6.h b/include/configs/cm_fx6.h
>>>> index f054ca8..c839b03 100644
>>>> --- a/include/configs/cm_fx6.h
>>>> +++ b/include/configs/cm_fx6.h
>>>
>>> [...]
>>>
>>>> @@ -157,7 +174,7 @@
>>>>  	"run setupnandboot;" \
>>>>  	"run nandboot;"
>>>>
>>>> -#define CONFIG_PREBOOT		"usb start"
>>>> +#define CONFIG_PREBOOT		"usb start;sf probe"
>>>
>>> Probably, this is really needed.
>>> Care to explain?
>>>
>> The sf probe command probes for the spi flash and registers (on success)
>> the device as nor0. This device is used by mtdparts (cf. the mtdids
>> variable; it maps the U-Boot name nor0 to the kernel name spi0.0) and
>> the mtd fixup code in patch 2 (cf. the nodes array; it specifies the
>> compatible of the flash chip of type NOR #0, i.e. nor0).
>>
>> Without this all mtdparts commands will fail and the fixup code won't
>> work because there is nor0 device.
>
> Thanks for the explanation!
> That sounds to me like this should go away once we have the DM in place
> for spi flash and MTD (added Simon to Cc).
> Meanwhile, may be a short notice in the commit message?
>

Sure, I will add it.

Thanks,
Christopher
diff mbox

Patch

diff --git a/include/configs/cm_fx6.h b/include/configs/cm_fx6.h
index f054ca8..c839b03 100644
--- a/include/configs/cm_fx6.h
+++ b/include/configs/cm_fx6.h
@@ -18,6 +18,7 @@ 
 #define CONFIG_MACH_TYPE		4273
 
 /* CMD */
+#define CONFIG_CMD_MTDPARTS
 
 /* MMC */
 #define CONFIG_SYS_FSL_USDHC_NUM	3
@@ -53,6 +54,20 @@ 
 #define CONFIG_SF_DEFAULT_SPEED		25000000
 #define CONFIG_SF_DEFAULT_MODE		(SPI_MODE_0)
 
+/* MTD support */
+#ifndef CONFIG_SPL_BUILD
+#define CONFIG_FDT_FIXUP_PARTITIONS
+#define CONFIG_MTD_DEVICE
+#define CONFIG_MTD_PARTITIONS
+#define CONFIG_SPI_FLASH_MTD
+#endif
+
+#define MTDIDS_DEFAULT		"nor0=spi0.0"
+#define MTDPARTS_DEFAULT	"mtdparts=spi0.0:" \
+				"768k(uboot)," \
+				"256k(uboot-environment)," \
+				"-(reserved)"
+
 /* Environment */
 #define CONFIG_ENV_IS_IN_SPI_FLASH
 #define CONFIG_ENV_SPI_MAX_HZ		CONFIG_SF_DEFAULT_SPEED
@@ -83,6 +98,8 @@ 
 	"video_dvi=mxcfb0:dev=dvi,1280x800M-32@50,if=RGB32\0" \
 	"doboot=bootm ${loadaddr}\0" \
 	"doloadfdt=false\0" \
+	"mtdids=" MTDIDS_DEFAULT "\0" \
+	"mtdparts=" MTDPARTS_DEFAULT "\0" \
 	"setboottypez=setenv kernel ${zImage};" \
 		"setenv doboot bootz ${loadaddr} - ${fdtaddr};" \
 		"setenv doloadfdt true;\0" \
@@ -157,7 +174,7 @@ 
 	"run setupnandboot;" \
 	"run nandboot;"
 
-#define CONFIG_PREBOOT		"usb start"
+#define CONFIG_PREBOOT		"usb start;sf probe"
 
 /* SPI */
 #define CONFIG_SPI