Add support to fetch baudrate from dtb
v3 cover Add support to fetch baudrate from dtb
From: Algapally Santosh Sagar <[email protected]>
In this patch series
- Fetch baudrate from the dtb and update
- Add support in Kconfig and convert for armada boards
Changes in v3:
- Moved filler changes from zynqmp.h to generic file env_default.h
- Removed ENV_RW_FILLER and added padding in the generic file env_default.h.
- Print baudrate parameter properly when SERIAL_DT is enabled.
- Add SERIAL_DT_BAUD to Kconfig
- Moved DEFAULT_ENV_IS_RW to Kconfig also updated armada files
Changes in v2:
- Changed to #ifdef from #if CONFIG_IS_ENABLED to enable patching in spl.
- Added SPL_ENV_SUPPORT dependency in SERIAL_DT_BAUD to allow SPL compilation.
- Moved DEFAULT_ENV_IS_RW to Kconfig also updated armada files
- Moved ENV_RW_FILLER to generic file env_default.h.
- Increased the ENV_RW_FILLER padding to support 8000000 baud.
Algapally Santosh Sagar (2):
serial: zynqmp: Fetch baudrate from dtb and update
configs: Add support in Kconfig and convert for armada boards
configs/mvebu_db-88f3720_defconfig | 1 + configs/mvebu_espressobin-88f3720_defconfig | 1 + configs/mvebu_mcbin-88f8040_defconfig | 1 + drivers/serial/Kconfig | 16 +++++++++ drivers/serial/serial-uclass.c | 32 +++++++++++++++++ include/configs/mvebu_armada-37xx.h | 1 - include/env_default.h | 7 ++-- include/env_internal.h | 2 +- include/fdtdec.h | 8 +++++ include/serial.h | 1 + lib/fdtdec.c | 40 +++++++++++++++++++++ 11 files changed, 106 insertions(+), 4 deletions(-)
Signature · 1 line
2.25.1
PATCH v3 1/2 serial: zynqmp: Fetch baudrate from dtb and update
From: Algapally Santosh Sagar <[email protected]>
The baudrate configured in .config is taken by default by serial. If change of baudrate is required then the .config needs to changed and u-boot recompilation is required or the u-boot environment needs to be updated.
To avoid this, support is added to fetch the baudrate directly from the device tree file and update.
The serial, prints the log with the configured baudrate in the dtb. The commit c4df0f6f315c ("arm: mvebu: Espressobin: Set default value for $fdtfile env variable") is taken as reference for changing the default environment variable.
The default environment stores the default baudrate value, When default baudrate and dtb baudrate are not same glitches are seen on the serial. So, the environment also needs to be updated with the dtb baudrate to avoid the glitches on the serial.
--- drivers/serial/serial-uclass.c | 32 +++++++++++++++++++++++++++ include/env_default.h | 7 ++++-- include/env_internal.h | 2 +- include/fdtdec.h | 8 +++++++ include/serial.h | 1 + lib/fdtdec.c | 40 ++++++++++++++++++++++++++++++++++ 6 files changed, 87 insertions(+), 3 deletions(-)
drivers/serial/serial-uclass.c +32 -0
@@ -154,12 +154,44 @@ static void serial_find_console_or_panic(void) }#endif /* CONFIG_SERIAL_PRESENT */ +#ifdef CONFIG_SERIAL_DT_BAUD +int serial_get_valid_baudrate (int baud) +{ +int i; + +for (i =0 ; i <ARRAY_SIZE (baudrate_table); ++i) { +if (baud == baudrate_table[i]) +return 0 ; + } + +return -EINVAL ; +} +#endif +/* Called prior to relocation */ int serial_init (void ) {#if CONFIG_IS_ENABLED (SERIAL_PRESENT )serial_find_console_or_panic (); gd->flags |=GD_FLG_SERIAL_READY ; +#ifdef CONFIG_SERIAL_DT_BAUD +int ret =0 ; +char *ptr = &default_environment[0 ]; + +/* +* Fetch the baudrate from the dtb and update the value in the +* default environment. +*/ + ret =fdtdec_get_baud_from_dtb (gd->fdt_blob); +if (ret != -EINVAL && ret != -EFAULT ) { + gd->baudrate = ret; + +while (*ptr !='\0' && *(ptr +1 ) !='\0' ) + ptr++; + ptr +=2 ; +sprintf (ptr,"baudrate=%d" , gd->baudrate); + } +#endif serial_setbrg ();#endif
include/env_default.h +5 -2
@@ -23,7 +23,7 @@ env_t embedded_environment __UBOOT_ENV_SECTION__(environment) = { { #elif defined(DEFAULT_ENV_INSTANCE_STATIC) static char default_environment[] = { -#elif defined(DEFAULT_ENV_IS_RW) +#elif defined(CONFIG_DEFAULT_ENV_IS_RW) char default_environment[] = { #else const char default_environment[] = {
@@ -44,7 +44,7 @@ const char default_environment[] = {#if defined(CONFIG_BOOTDELAY ) "bootdelay=" __stringify(CONFIG_BOOTDELAY) "\0"#endif -#if defined(CONFIG_BAUDRATE ) && (CONFIG_BAUDRATE >=0 ) +#if !defined(CONFIG_SERIAL_DT_BAUD ) && defined(CONFIG_BAUDRATE ) && (CONFIG_BAUDRATE >=0 ) "baudrate=" __stringify(CONFIG_BAUDRATE) "\0"#endif #ifdef CONFIG_LOADS_ECHO
@@ -120,6 +120,9 @@ const char default_environment[] = {#endif #ifdef CFG_EXTRA_ENV_SETTINGS CFG_EXTRA_ENV_SETTINGS +#endif +#ifdef CONFIG_SERIAL_DT_BAUD +"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" #endif"\0" #else /* CONFIG_USE_DEFAULT_ENV_FILE */
include/env_internal.h +1 -1
@@ -89,7 +89,7 @@ typedef struct environment_s {extern env_t embedded_environment;#endif /* ENV_IS_EMBEDDED */ -#ifdef DEFAULT_ENV_IS_RW +#ifdef CONFIG_DEFAULT_ENV_IS_RW extern char default_environment[];#else extern const char default_environment[];
include/fdtdec.h +8 -0
@@ -657,6 +657,14 @@ int fdtdec_get_alias_seq(const void *blob, const char *base, int node,*/ int fdtdec_get_alias_highest_id (const void *blob,const char *base); +/** +* Get baudrate from the dtb +* +* @param blob Device tree blob (if NULL, then error is returned) +* @return Baud rate value, or -ve error . +*/ +int fdtdec_get_baud_from_dtb (const void *blob); +/** * Get a property from the /chosen node *
include/serial.h +1 -0
@@ -337,6 +337,7 @@ int serial_setconfig(struct udevice *dev, uint config);*/ int serial_getinfo (struct udevice *dev,struct serial_device_info *info); +int serial_get_valid_baudrate (int baud);void atmel_serial_initialize (void );void mcf_serial_initialize (void );void mpc85xx_serial_initialize (void );
lib/fdtdec.c +40 -0
@@ -570,6 +570,46 @@ int fdtdec_get_alias_highest_id(const void *blob, const char *base)return max; } +#ifdef CONFIG_SERIAL_DT_BAUD +int fdtdec_get_baud_from_dtb (const void *blob) +{ +const char *str, *p, *baud_start; +u32 baud; + +if (!blob) +return -EFAULT ; + + str =fdtdec_get_chosen_prop (blob,"stdout-path" ); +if (!str) +return -EINVAL ; + + p =strchr (str,':' ); +if (!p) +return -EINVAL ; + + baud =0 ; + baud_start = p +1 ; +while (*baud_start !='\0' ) { +/* +* Uart binding is <baud>{<parity>{<bits>{...}}} +* So the baudrate either is the whole string, or +* ends in the parity characters. +*/ +if (*baud_start =='n' || *baud_start =='o' || + *baud_start =='e' ) +break ; + + baud = baud *10 + (*baud_start -'0' ); + baud_start++; + } + +if (serial_get_valid_baudrate (baud) == -EINVAL ) +return -EINVAL ; + +return baud; +} +#endif +const char *fdtdec_get_chosen_prop (const void *blob,const char *name) {int chosen_node;
Signature · 1 line
2.17.1
Re: [PATCH v3 1/2] serial: zynqmp: Fetch baudrate from dtb and update
Hi Venkatesh,
Quoted 22 lines · Venkatesh Yadav Abbarapu
From: Algapally Santosh Sagar <[email protected]>
The baudrate configured in .config is taken by default by serial. If change of baudrate is required then the .config needs to changed and u-boot recompilation is required or the u-boot environment needs to be updated.
To avoid this, support is added to fetch the baudrate directly from the device tree file and update.
The serial, prints the log with the configured baudrate in the dtb. The commitc4df0f6f315c("arm: mvebu: Espressobin: Set default value for $fdtfile env variable") is taken as reference for changing the default environment variable.The default environment stores the default baudrate value, When default baudrate and dtb baudrate are not same glitches are seen on the serial. So, the environment also needs to be updated with the dtb baudrate to avoid the glitches on the serial.
Signed-off-by Algapally Santosh Sagar <[email protected]>Signed-off-by Venkatesh Yadav Abbarapu <[email protected]>
Quoted 8 lines
--- drivers/serial/serial-uclass.c | 32 +++++++++++++++++++++++++++ include/env_default.h | 7 ++++-- include/env_internal.h | 2 +- include/fdtdec.h | 8 +++++++ include/serial.h | 1 + lib/fdtdec.c | 40 ++++++++++++++++++++++++++++++++++ 6 files changed, 87 insertions(+), 3 deletions(-)
Can you please add something to doc/ for this feature?
drivers/serial/serial-uclass.c static void serial_find_console_or_panic(void) · line 157
Quoted 10 lines
drivers/serial/serial-uclass.c +1
-0@@ -154,12 +154,44 @@ static void serial_find_console_or_panic(void) }#endif /* CONFIG_SERIAL_PRESENT */ +#ifdef CONFIG_SERIAL_DT_BAUD
Please drop this #ifdef
Quoted 10 lines
drivers/serial/serial-uclass.c +10
-0+int serial_get_valid_baudrate (int baud) +{ +int i; + +for (i =0 ; i <ARRAY_SIZE (baudrate_table); ++i) { +if (baud == baudrate_table[i]) +return 0 ; + } + +return -EINVAL ;
drivers/serial/serial-uclass.c static void serial_find_console_or_panic(void) · line 177
Quoted 10 lines
drivers/serial/serial-uclass.c +4
-0+} +#endif +/* Called prior to relocation */ int serial_init (void ) {#if CONFIG_IS_ENABLED (SERIAL_PRESENT )serial_find_console_or_panic (); gd->flags |=GD_FLG_SERIAL_READY ; +#ifdef CONFIG_SERIAL_DT_BAUD
if (IS_ENABLED(CONFIG_SERIAL_DT_BAUD)
You also should add a Kconfig option. I suggest naming it OF_SERIAL_BOARD since we typically put an OF_ prefix on such options.
Quoted 43 lines
drivers/serial/serial-uclass.c +17
-0+int ret =0 ; +char *ptr = &default_environment[0 ]; + +/* +* Fetch the baudrate from the dtb and update the value in the +* default environment. +*/ + ret =fdtdec_get_baud_from_dtb (gd->fdt_blob); +if (ret != -EINVAL && ret != -EFAULT ) { + gd->baudrate = ret; + +while (*ptr !='\0' && *(ptr +1 ) !='\0' ) + ptr++; + ptr +=2 ; +sprintf (ptr,"baudrate=%d" , gd->baudrate); + } +#endif serial_setbrg ();#endif include/env_default.h +2
-2@@ -23,7 +23,7 @@ env_t embedded_environment __UBOOT_ENV_SECTION__(environment) = { { #elif defined(DEFAULT_ENV_INSTANCE_STATIC) static char default_environment[] = { -#elif defined(DEFAULT_ENV_IS_RW) +#elif defined(CONFIG_DEFAULT_ENV_IS_RW) char default_environment[] = { #else const char default_environment[] = {@@ -44,7 +44,7 @@ const char default_environment[] = {#if defined(CONFIG_BOOTDELAY ) "bootdelay=" __stringify(CONFIG_BOOTDELAY) "\0"#endif -#if defined(CONFIG_BAUDRATE ) && (CONFIG_BAUDRATE >=0 ) +#if !defined(CONFIG_SERIAL_DT_BAUD ) && defined(CONFIG_BAUDRATE ) && (CONFIG_BAUDRATE >=0 ) "baudrate=" __stringify(CONFIG_BAUDRATE) "\0"#endif #ifdef CONFIG_LOADS_ECHO
include/env_default.h const char default_environment[] = { · line 125
Quoted 6 lines
include/env_default.h +3
-0@@ -120,6 +120,9 @@ const char default_environment[] = {#endif #ifdef CFG_EXTRA_ENV_SETTINGS CFG_EXTRA_ENV_SETTINGS +#endif +#ifdef CONFIG_SERIAL_DT_BAUD +"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
What is this for?
include/env_internal.h typedef struct environment_s { · line 92
Quoted 13 lines
include/env_default.h +0
-0#endif "\0" #else /* CONFIG_USE_DEFAULT_ENV_FILE */include/env_internal.h +1
-1@@ -89,7 +89,7 @@ typedef struct environment_s {extern env_t embedded_environment;#endif /* ENV_IS_EMBEDDED */ -#ifdef DEFAULT_ENV_IS_RW +#ifdef CONFIG_DEFAULT_ENV_IS_RW
What is this change for?
include/fdtdec.h int fdtdec_get_alias_seq(const void *blob, const char *base, int node, · line 658
Quoted 10 lines
include/env_internal.h +0
-0extern char default_environment[];#else extern const char default_environment[];include/fdtdec.h +0
-0@@ -657,6 +657,14 @@ int fdtdec_get_alias_seq(const void *blob, const char *base, int node,*/ int fdtdec_get_alias_highest_id (const void *blob,const char *base);
Could you make this an ofnode_...() function instead? Then you can call ofnode_read_chosen_string() from your function.
We are trying to drop the fdtdec API.
include/fdtdec.h int fdtdec_get_alias_seq(const void *blob, const char *base, int node, · line 664
Quoted 6 lines
include/fdtdec.h +5
-0+/** +* Get baudrate from the dtb +* +* @param blob Device tree blob (if NULL, then error is returned) +* @return Baud rate value, or -ve error .
Return: Baud ...
(we changed to that syntax to work with Sphinx)
But this should become ofnode_read_baud(void)
Exported functions should be documented in the header file, not the C file
Quoted 11 lines
include/fdtdec.h +3
-0+*/ +int fdtdec_get_baud_from_dtb (const void *blob); +/** * Get a property from the /chosen node * include/serial.h +0
-0
include/serial.h int serial_setconfig(struct udevice *dev, uint config); · line 340
Quoted 4 lines
include/serial.h +1
-0@@ -337,6 +337,7 @@ int serial_setconfig(struct udevice *dev, uint config);*/ int serial_getinfo (struct udevice *dev,struct serial_device_info *info); +int serial_get_valid_baudrate (int baud);
check_valid_baudrate() would be better since it is checking the provided rate, not returning a valid rate (as I understand it).
This needs function docs
Quoted 20 lines
include/serial.h +0
-0void atmel_serial_initialize (void );void mcf_serial_initialize (void );void mpc85xx_serial_initialize (void );lib/fdtdec.c +9
-0@@ -570,6 +570,46 @@ int fdtdec_get_alias_highest_id(const void *blob, const char *base)return max; } +#ifdef CONFIG_SERIAL_DT_BAUD +int fdtdec_get_baud_from_dtb (const void *blob) +{ +const char *str, *p, *baud_start; +u32 baud; + +if (!blob) +return -EFAULT ; +
lib/fdtdec.c int fdtdec_get_alias_highest_id(const void *blob, const char *base) · line 591
Quoted 10 lines
lib/fdtdec.c +10
-0+ str =fdtdec_get_chosen_prop (blob,"stdout-path" ); +if (!str) +return -EINVAL ; + + p =strchr (str,':' ); +if (!p) +return -EINVAL ; + + baud =0 ; + baud_start = p +1 ;
It would help to have a comment about the format you are parsing, e.g. an example string.
I thought it was something like: "serial0:115200n8" in which case I think you could do:
p = strchr(str, ':')
if (p) {
uint baud = dectoul(p + 1, NULL);
...
}
Quoted 6 lines
lib/fdtdec.c +6
-0+while (*baud_start !='\0' ) { +/* +* Uart binding is <baud>{<parity>{<bits>{...}}} +* So the baudrate either is the whole string, or +* ends in the parity characters. +*/
lib/fdtdec.c int fdtdec_get_alias_highest_id(const void *blob, const char *base) · line 607
Quoted 10 lines
lib/fdtdec.c +10
-0+if (*baud_start =='n' || *baud_start =='o' || + *baud_start =='e' ) +break ; + + baud = baud *10 + (*baud_start -'0' ); + baud_start++; + } + +if (serial_get_valid_baudrate (baud) == -EINVAL ) +return -EINVAL ;
ret = func ...
if (ret)
return ret
(i.e. don't change the error number, and catch all errors that it might return)
Quoted 11 lines
lib/fdtdec.c +5
-1+ + return baud; +} +#endif +const char *fdtdec_get_chosen_prop (const void *blob,const char *name) {int chosen_node; --2.17.1
Regards,
Simon
RE: [PATCH v3 1/2] serial: zynqmp: Fetch baudrate from dtb and update
Hi Simon,
Thanks,
A Santosh Sagar.
Quoted 49 lines
-----Original Message-----
From: Simon Glass <[email protected]>
Sent: Tuesday, April 25, 2023 11:31 PM
To: Abbarapu, Venkatesh <[email protected]>
Cc: [email protected]; Simek, Michal <[email protected]>; [email protected]; Algapally, Santosh Sagar <[email protected]>
Subject: Re: [PATCH v3 1/2] serial: zynqmp: Fetch baudrate from dtb and updateCaution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Hi Venkatesh,
Quoted 15 lines · Venkatesh Yadav Abbarapu
From: Algapally Santosh Sagar <[email protected]>
The baudrate configured in .config is taken by default by serial. If change of baudrate is required then the .config needs to changed and u-boot recompilation is required or the u-boot environment needs to be updated.
To avoid this, support is added to fetch the baudrate directly from the device tree file and update.
The serial, prints the log with the configured baudrate in the dtb. The commitc4df0f6f315c("arm: mvebu: Espressobin: Set default value for $fdtfile env variable") is taken as reference for changing the default environment variable.Quoted 2 lines
The default environment stores the default baudrate value, When default baudrate and dtb baudrate are not same glitches are seen on the
serial.
Quoted 6 lines
So, the environment also needs to be updated with the dtb baudrate to avoid the glitches on the serial.
Signed-off-by: Algapally Santosh Sagar
<[email protected]>Signed-off-by Venkatesh Yadav Abbarapu <[email protected]>Quoted 8 lines
--- drivers/serial/serial-uclass.c | 32 +++++++++++++++++++++++++++ include/env_default.h | 7 ++++-- include/env_internal.h | 2 +- include/fdtdec.h | 8 +++++++ include/serial.h | 1 + lib/fdtdec.c | 40 ++++++++++++++++++++++++++++++++++ 6 files changed, 87 insertions(+), 3 deletions(-)
Quoted 1 line
Can you please add something to doc/ for this feature?
Ok sure
Quoted 10 lines
Quoted 10 lines
(quoted diff) +0
-0
b/drivers/serial/serial-uclass.cindex067fae2614..d77d3bda36100644drivers/serial/serial-uclass.c +0
-0@@ -154,12 +154,44 @@ static void serial_find_console_or_panic(void) }#endif /* CONFIG_SERIAL_PRESENT */
Quoted 3 lines
drivers/serial/serial-uclass.c static void serial_find_console_or_panic(void) · line 157
Quoted 1 line
drivers/serial/serial-uclass.c +1
-0+#ifdef CONFIG_SERIAL_DT_BAUD Please drop this #ifdef
Will drop
Quoted 14 lines
Quoted 14 lines
drivers/serial/serial-uclass.c +12
-0+int serial_get_valid_baudrate (int baud) { +int i; + +for (i =0 ; i <ARRAY_SIZE (baudrate_table); ++i) { +if (baud == baudrate_table[i]) +return 0 ; + } + +return -EINVAL ; +} +#endif +/* Called prior to relocation */
Quoted 8 lines
drivers/serial/serial-uclass.c static void serial_find_console_or_panic(void) · line 177
Quoted 6 lines
drivers/serial/serial-uclass.c +1
-0int serial_init (void ) {#if CONFIG_IS_ENABLED (SERIAL_PRESENT )serial_find_console_or_panic (); gd->flags |=GD_FLG_SERIAL_READY ; +#ifdef CONFIG_SERIAL_DT_BAUD if (
IS_ENABLED(CONFIG_SERIAL_DT_BAUD)
On using this
if (IS_ENABLED(CONFIG_SERIAL_DT_BAUD))
The variables declared below are getting compiled and the below warning is thrown. So, not changing this.
drivers/serial/serial-uclass.c: In function 'serial_init':drivers/serial/serial-uclass.c:189:21: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
189 | char *ptr = &default_environment[0];
Quoted 4 lines
You also should add a
Kconfigoption. I suggest naming itOF_SERIAL_BOARDsince we typically put anOF_prefix on such options.
Will change SERIAL_DT_BAUD to OF_SERIAL_DT_BAUD
Quoted 44 lines
include/env_default.h env_t embedded_environment
Quoted 25 lines
drivers/serial/serial-uclass.c +17
-0+int ret =0 ; +char *ptr = &default_environment[0 ]; + +/* +* Fetch the baudrate from the dtb and update the value in the +* default environment. +*/ + ret =fdtdec_get_baud_from_dtb (gd->fdt_blob); +if (ret != -EINVAL && ret != -EFAULT ) { + gd->baudrate = ret; + +while (*ptr !='\0' && *(ptr +1 ) !='\0' ) + ptr++; + ptr +=2 ; +sprintf (ptr,"baudrate=%d" , gd->baudrate); + } +#endif serial_setbrg ();#endif include/env_default.h index renamed from include/env_default.h +0
-0
c0df39d62f..4f286ffc9e100644include/env_default.h +0
-0@@ -23,7 +23,7 @@ env_t embedded_environment
__UBOOT_ENV_SECTION__(environment)= {Quoted 18 lines
include/env_default.h +3
-1{ #elif defined(DEFAULT_ENV_INSTANCE_STATIC) static char default_environment[] = { -#elif defined(DEFAULT_ENV_IS_RW) +#elif defined(CONFIG_DEFAULT_ENV_IS_RW) char default_environment[] = { #else const char default_environment[] = {@@ -44,7 +44,7 @@ const char default_environment[] = { #ifdefined (CONFIG_BOOTDELAY) "bootdelay=" __stringify(CONFIG_BOOTDELAY) "\0" #endif -#if defined(CONFIG_BAUDRATE) && (CONFIG_BAUDRATE >= 0) +#if !defined(CONFIG_SERIAL_DT_BAUD) && defined(CONFIG_BAUDRATE) && +(CONFIG_BAUDRATE >= 0) "baudrate=" __stringify(CONFIG_BAUDRATE) "\0" #endif #ifdef CONFIG_LOADS_ECHO
Quoted 8 lines
include/env_default.h const char default_environment[] = { #endif · line 124
Quoted 6 lines
include/env_default.h +3
-0@@ -120,6 +120,9 @@ const char default_environment[] = { #endif#ifdef CFG_EXTRA_ENV_SETTINGS CFG_EXTRA_ENV_SETTINGS +#endif +#ifdef CONFIG_SERIAL_DT_BAUD +"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" What is this for?
The padding is needed at the end of default environment for baudrate when environment is writable.
Quoted 11 lines
Quoted 11 lines
include/env_default.h +0
-0#endif "\0" #else /* CONFIG_USE_DEFAULT_ENV_FILE */ diff --git
a/include/env_internal.hb/include/env_internal.hindex6a69494646..fcb464263f100644include/env_internal.h +0
-0@@ -89,7 +89,7 @@ typedef struct environment_s { extern env_t
embedded_environment; #endif /*ENV_IS_EMBEDDED*/
Quoted 4 lines
include/env_internal.h typedef struct environment_s { · line 92
Quoted 2 lines
include/env_internal.h +1
-1-#ifdef DEFAULT_ENV_IS_RW +#ifdef CONFIG_DEFAULT_ENV_IS_RW What is this change for?
This is done as DEFAULT_ENV_IS_RW is moved to Kconfig.
Quoted 10 lines
include/fdtdec.h int fdtdec_get_alias_seq(const void *blob, const char
Quoted 9 lines
extern char default_environment[];
#else
extern const char default_environment[]; diff --gita/include/fdtdec.hb/include/fdtdec.hindexaa61a0fca1..48937a7a46100644include/fdtdec.h +0
-0@@ -657,6 +657,14 @@ int fdtdec_get_alias_seq(const void *blob, const char*base, int node,
Quoted 7 lines
include/fdtdec.h int fdtdec_get_alias_seq(const void *blob, const char *base, int node, · line 658
Quoted 2 lines
include/fdtdec.h +0
-0*/ int fdtdec_get_alias_highest_id (const void *blob,const char *base);Could you make this an ofnode_...() function instead? Then you can call
ofnode_read_chosen_string()from your function.We are trying to drop the fdtdec API.
Will change
Quoted 8 lines
include/fdtdec.h int fdtdec_get_alias_seq(const void *blob, const char *base, int node, · line 664
Quoted 7 lines
include/fdtdec.h +5
-0+/** +* Get baudrate from the dtb +* +* @param blob Device tree blob (if NULL, then error is returned) +* @return Baud rate value, or -ve error .
Quoted 8 lines
Return: Baud ...
(we changed to that syntax to work with Sphinx)
But this should become
ofnode_read_baud(void)Exported functions should be documented in the header file, not the C file
Will do
Quoted 15 lines
Quoted 15 lines
include/fdtdec.h +3
-0+*/ +int fdtdec_get_baud_from_dtb (const void *blob); +/** * Get a property from the /chosen node * include/serial.h index renamed from include/serial.h +0
-0
42bdf3759c..48834b517c100644include/serial.h +0
-0@@ -337,6 +337,7 @@ int serial_setconfig(struct udevice *dev, uint config);*/ int serial_getinfo (struct udevice *dev,struct serial_device_info *info);
Quoted 6 lines
include/serial.h int serial_setconfig(struct udevice *dev, uint config); · line 340
Quoted 1 line
include/serial.h +1
-0+int serial_get_valid_baudrate (int baud);
check_valid_baudrate()would be better since it is checking the provided rate, not returning a valid rate (as I understand it).This needs function docs
Ok sure
Quoted 36 lines
lib/fdtdec.c int fdtdec_get_alias_highest_id(const void *blob,
Quoted 7 lines
include/serial.h +0
-0void atmel_serial_initialize (void );void mcf_serial_initialize (void );void
mpc85xx_serial_initialize(void); diff --gita/lib/fdtdec.cb/lib/fdtdec.cindex0827e16859..2fcc12148e100644lib/fdtdec.c +0
-0@@ -570,6 +570,46 @@ int fdtdec_get_alias_highest_id(const void *blob,const char *base)
Quoted 11 lines
lib/fdtdec.c +8
-0return max; } +#ifdef CONFIG_SERIAL_DT_BAUD +int fdtdec_get_baud_from_dtb (const void *blob) { +const char *str, *p, *baud_start; +u32 baud; + +if (!blob) +return -EFAULT ; +lib/fdtdec.c int fdtdec_get_alias_highest_id(const void *blob, const char *base) · line 591
Quoted 10 lines
lib/fdtdec.c +10
-0+ str =fdtdec_get_chosen_prop (blob,"stdout-path" ); +if (!str) +return -EINVAL ; + + p =strchr (str,':' ); +if (!p) +return -EINVAL ; + + baud =0 ; + baud_start = p +1 ;It would help to have a comment about the format you are parsing, e.g. an example string.
I thought it was something like: "serial0:115200n8" in which case I think you could do:
Quoted 7 lines
p =
strchr(str, ':')if (p) { uint baud = dectoul(p + 1, NULL); ...}
Will do
Quoted 21 lines
Quoted 6 lines
lib/fdtdec.c +6
-0+while (*baud_start !='\0' ) { +/* +* Uart binding is <baud>{<parity>{<bits>{...}}} +* So the baudrate either is the whole string, or +* ends in the parity characters. +*/ lib/fdtdec.c int fdtdec_get_alias_highest_id(const void *blob, const char *base) · line 607
Quoted 10 lines
lib/fdtdec.c +10
-0+if (*baud_start =='n' || *baud_start =='o' || + *baud_start =='e' ) +break ; + + baud = baud *10 + (*baud_start -'0' ); + baud_start++; + } + +if (serial_get_valid_baudrate (baud) == -EINVAL ) +return -EINVAL ;ret = func ...
if (ret)
return ret
Quoted 2 lines
(i.e. don't change the error number, and catch all errors that it might return)
Ok sure
Quoted 6 lines
Quoted 6 lines
lib/fdtdec.c +5
-0+ +return baud; +} +#endif + const char *fdtdec_get_chosen_prop(const void *blob, const char
Quoted 8 lines
Quoted 5 lines
lib/fdtdec.c +0
-1*name) {int chosen_node; --2.17.1
Regards,
Simon
Will do the changes and send v4
PATCH v3 2/2 configs: Add support in Kconfig and convert for armada boards
In reply to Venkatesh Yadav AbbarapuFrom: Algapally Santosh Sagar <[email protected]>
The SERIAL_DT_BAUD is added to Kconfig and the DEFAULT_ENV_IS_RW is moved to the Kconfig for easier configuration.
Hence, the CONFIG_DEFAULT_ENV_IS_RW config is added to the defconfig files to allow enabling them for armada boards.
--- configs/mvebu_db-88f3720_defconfig | 1 + configs/mvebu_espressobin-88f3720_defconfig | 1 + configs/mvebu_mcbin-88f8040_defconfig | 1 + drivers/serial/Kconfig | 16 ++++++++++++++++ include/configs/mvebu_armada-37xx.h | 1 - 5 files changed, 19 insertions(+), 1 deletion(-)
configs/mvebu_db-88f3720_defconfig +1 -0
@@ -21,6 +21,7 @@ CONFIG_USE_PREBOOT=y CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_DISPLAY_CPUINFO is not set # CONFIG_DISPLAY_BOARDINFO is not set +CONFIG_DEFAULT_ENV_IS_RW=y CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_ARCH_EARLY_INIT_R=y CONFIG_BOARD_EARLY_INIT_F=y
configs/mvebu_espressobin-88f3720_defconfig +1 -0
@@ -22,6 +22,7 @@ CONFIG_USE_PREBOOT=y CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_DISPLAY_CPUINFO is not set # CONFIG_DISPLAY_BOARDINFO is not set +CONFIG_DEFAULT_ENV_IS_RW=y CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_ARCH_EARLY_INIT_R=y CONFIG_BOARD_EARLY_INIT_F=y
configs/mvebu_mcbin-88f8040_defconfig +1 -0
@@ -22,6 +22,7 @@ CONFIG_USE_PREBOOT=y CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_DISPLAY_CPUINFO is not set # CONFIG_DISPLAY_BOARDINFO is not set +CONFIG_DEFAULT_ENV_IS_RW=y CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_ARCH_EARLY_INIT_R=y CONFIG_BOARD_EARLY_INIT_F=y
drivers/serial/Kconfig +16 -0
@@ -24,6 +24,22 @@ config BAUDRATE in the SPL stage (most drivers) or for choosing a default baudrate in the absence of an environment setting (serial_mxc.c). +config SERIAL_DT_BAUD + bool "Fetch serial baudrate from device tree" + depends on DM_SERIAL && SPL_ENV_SUPPORT + select DEFAULT_ENV_IS_RW + help + Select this to enable fetching and setting of the baudrate + configured in the DT. Replace the default baudrate with the DT + baudrate and also set it to the environment. + +config DEFAULT_ENV_IS_RW + bool "Make default environment as writable" + depends on DM_SERIAL + help + Select this to enable to make default environment writable. This + allows modifying the default environment. + config REQUIRE_SERIAL_CONSOLE bool "Require a serial port for console" # Running without a serial console is not supported by the
include/configs/mvebu_armada-37xx.h +0 -1
@@ -30,7 +30,6 @@/* * Environment */ -#define DEFAULT_ENV_IS_RW /* required for configuring default fdtfile= */ #ifdef CONFIG_MMC #define BOOT_TARGET_DEVICES_MMC (func, i) func(MMC, mmc, i)
Signature · 1 line
2.17.1
Re: [PATCH v3 2/2] configs: Add support in Kconfig and convert for armada boards
Quoted 59 lines · Venkatesh Yadav Abbarapu
From: Algapally Santosh Sagar <[email protected]>
The
SERIAL_DT_BAUDis added toKconfigand theDEFAULT_ENV_IS_RWis moved to theKconfigfor easier configuration.
Hence, theCONFIG_DEFAULT_ENV_IS_RWconfig is added to the defconfig files to allow enabling them for armada boards.Signed-off-by Algapally Santosh Sagar <[email protected]>Signed-off-by Venkatesh Yadav Abbarapu <[email protected]>--- configs/mvebu_db-88f3720_defconfig | 1 + configs/mvebu_espressobin-88f3720_defconfig | 1 + configs/mvebu_mcbin-88f8040_defconfig | 1 + drivers/serial/Kconfig | 16 ++++++++++++++++ include/configs/mvebu_armada-37xx.h | 1 - 5 files changed, 19 insertions(+), 1 deletion(-)configs/mvebu_db-88f3720_defconfig +1
-0@@ -21,6 +21,7 @@ CONFIG_USE_PREBOOT=y CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_DISPLAY_CPUINFO is not set # CONFIG_DISPLAY_BOARDINFO is not set +CONFIG_DEFAULT_ENV_IS_RW=y CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_ARCH_EARLY_INIT_R=y CONFIG_BOARD_EARLY_INIT_F=yconfigs/mvebu_espressobin-88f3720_defconfig +1
-0@@ -22,6 +22,7 @@ CONFIG_USE_PREBOOT=y CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_DISPLAY_CPUINFO is not set # CONFIG_DISPLAY_BOARDINFO is not set +CONFIG_DEFAULT_ENV_IS_RW=y CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_ARCH_EARLY_INIT_R=y CONFIG_BOARD_EARLY_INIT_F=yconfigs/mvebu_mcbin-88f8040_defconfig +1
-0@@ -22,6 +22,7 @@ CONFIG_USE_PREBOOT=y CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_DISPLAY_CPUINFO is not set # CONFIG_DISPLAY_BOARDINFO is not set +CONFIG_DEFAULT_ENV_IS_RW=y CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_ARCH_EARLY_INIT_R=y CONFIG_BOARD_EARLY_INIT_F=ydrivers/serial/Kconfig +0
-0@@ -24,6 +24,22 @@ config BAUDRATE in the SPL stage (most drivers) or for choosing a default baudrate
drivers/serial/Kconfig config BAUDRATE · line 34
Quoted 10 lines
drivers/serial/Kconfig +8
-0in the absence of an environment setting (serial_mxc.c). +config SERIAL_DT_BAUD + bool "Fetch serial baudrate from device tree" + depends on DM_SERIAL && SPL_ENV_SUPPORT + select DEFAULT_ENV_IS_RW + help + Select this to enable fetching and setting of the baudrate + configured in the DT. Replace the default baudrate with the DT + baudrate and also set it to the environment.
This should be in 1/2.
And the whole patch itself should be the first one in this series.
M