diff mbox series

[07/10] stm32mp: stm32prog: use get_cpu_dev for GetID command

Message ID 20210518151206.7.I874b9d67ab66c4a1b44c880721f697effa226c5b@changeid
State Accepted
Commit 69446dee3759e09dfaeb99673ad70d1556ed5972
Delegated to: Patrice Chotard
Headers show
Series stm32mp: stm32prog: several features and fixes | expand

Commit Message

Patrick Delaunay May 18, 2021, 1:12 p.m. UTC
Use get_cpu_dev() in uart getID command and remove the defines
DEVICE_ID_BYTE1 and 2 defines.

This patch prepare the support for new SOC family.

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
---

 arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog_serial.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Patrice CHOTARD May 28, 2021, 12:54 p.m. UTC | #1
Hi Patrick

On 5/18/21 3:12 PM, Patrick Delaunay wrote:
> Use get_cpu_dev() in uart getID command and remove the defines
> DEVICE_ID_BYTE1 and 2 defines.
> 
> This patch prepare the support for new SOC family.
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
> ---
> 
>  arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog_serial.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog_serial.c b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog_serial.c
> index 2550ae6a2b..7de62668fe 100644
> --- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog_serial.c
> +++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog_serial.c
> @@ -10,6 +10,7 @@
>  #include <malloc.h>
>  #include <serial.h>
>  #include <watchdog.h>
> +#include <asm/arch/sys_proto.h>
>  #include <dm/lists.h>
>  #include <dm/device-internal.h>
>  #include <linux/delay.h>
> @@ -19,8 +20,7 @@
>  /* - configuration part -----------------------------*/
>  #define USART_BL_VERSION	0x40	/* USART bootloader version V4.0*/
>  #define UBOOT_BL_VERSION	0x03	/* bootloader version V0.3*/
> -#define DEVICE_ID_BYTE1		0x05	/* MSB byte of device ID*/
> -#define DEVICE_ID_BYTE2		0x00	/* LSB byte of device ID*/
> +
>  #define USART_RAM_BUFFER_SIZE	256	/* Size of USART_RAM_Buf buffer*/
>  
>  /* - Commands -----------------------------*/
> @@ -436,10 +436,12 @@ static void get_version_command(struct stm32prog_data *data)
>   */
>  static void get_id_command(struct stm32prog_data *data)
>  {
> +	u32 cpu = get_cpu_dev();
> +
>  	/* Send Device IDCode */
>  	stm32prog_serial_putc(0x1);
> -	stm32prog_serial_putc(DEVICE_ID_BYTE1);
> -	stm32prog_serial_putc(DEVICE_ID_BYTE2);
> +	stm32prog_serial_putc((cpu >> 8) & 0xFF);
> +	stm32prog_serial_putc(cpu & 0xFF);
>  	stm32prog_serial_result(ACK_BYTE);
>  }
>  
> 

Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>

Thanks
Patrice
Patrice CHOTARD June 18, 2021, 7:56 a.m. UTC | #2
On 5/28/21 2:54 PM, Patrice CHOTARD wrote:
> Hi Patrick
> 
> On 5/18/21 3:12 PM, Patrick Delaunay wrote:
>> Use get_cpu_dev() in uart getID command and remove the defines
>> DEVICE_ID_BYTE1 and 2 defines.
>>
>> This patch prepare the support for new SOC family.
>>
>> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
>> ---
>>
>>  arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog_serial.c | 10 ++++++----
>>  1 file changed, 6 insertions(+), 4 deletions(-)
>>
>> diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog_serial.c b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog_serial.c
>> index 2550ae6a2b..7de62668fe 100644
>> --- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog_serial.c
>> +++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog_serial.c
>> @@ -10,6 +10,7 @@
>>  #include <malloc.h>
>>  #include <serial.h>
>>  #include <watchdog.h>
>> +#include <asm/arch/sys_proto.h>
>>  #include <dm/lists.h>
>>  #include <dm/device-internal.h>
>>  #include <linux/delay.h>
>> @@ -19,8 +20,7 @@
>>  /* - configuration part -----------------------------*/
>>  #define USART_BL_VERSION	0x40	/* USART bootloader version V4.0*/
>>  #define UBOOT_BL_VERSION	0x03	/* bootloader version V0.3*/
>> -#define DEVICE_ID_BYTE1		0x05	/* MSB byte of device ID*/
>> -#define DEVICE_ID_BYTE2		0x00	/* LSB byte of device ID*/
>> +
>>  #define USART_RAM_BUFFER_SIZE	256	/* Size of USART_RAM_Buf buffer*/
>>  
>>  /* - Commands -----------------------------*/
>> @@ -436,10 +436,12 @@ static void get_version_command(struct stm32prog_data *data)
>>   */
>>  static void get_id_command(struct stm32prog_data *data)
>>  {
>> +	u32 cpu = get_cpu_dev();
>> +
>>  	/* Send Device IDCode */
>>  	stm32prog_serial_putc(0x1);
>> -	stm32prog_serial_putc(DEVICE_ID_BYTE1);
>> -	stm32prog_serial_putc(DEVICE_ID_BYTE2);
>> +	stm32prog_serial_putc((cpu >> 8) & 0xFF);
>> +	stm32prog_serial_putc(cpu & 0xFF);
>>  	stm32prog_serial_result(ACK_BYTE);
>>  }
>>  
>>
> 
> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
> 
> Thanks
> Patrice
> _______________________________________________
> Uboot-stm32 mailing list
> Uboot-stm32@st-md-mailman.stormreply.com
> https://st-md-mailman.stormreply.com/mailman/listinfo/uboot-stm32
> 
Applied on u-boot-stm32/next

Thanks
diff mbox series

Patch

diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog_serial.c b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog_serial.c
index 2550ae6a2b..7de62668fe 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog_serial.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog_serial.c
@@ -10,6 +10,7 @@ 
 #include <malloc.h>
 #include <serial.h>
 #include <watchdog.h>
+#include <asm/arch/sys_proto.h>
 #include <dm/lists.h>
 #include <dm/device-internal.h>
 #include <linux/delay.h>
@@ -19,8 +20,7 @@ 
 /* - configuration part -----------------------------*/
 #define USART_BL_VERSION	0x40	/* USART bootloader version V4.0*/
 #define UBOOT_BL_VERSION	0x03	/* bootloader version V0.3*/
-#define DEVICE_ID_BYTE1		0x05	/* MSB byte of device ID*/
-#define DEVICE_ID_BYTE2		0x00	/* LSB byte of device ID*/
+
 #define USART_RAM_BUFFER_SIZE	256	/* Size of USART_RAM_Buf buffer*/
 
 /* - Commands -----------------------------*/
@@ -436,10 +436,12 @@  static void get_version_command(struct stm32prog_data *data)
  */
 static void get_id_command(struct stm32prog_data *data)
 {
+	u32 cpu = get_cpu_dev();
+
 	/* Send Device IDCode */
 	stm32prog_serial_putc(0x1);
-	stm32prog_serial_putc(DEVICE_ID_BYTE1);
-	stm32prog_serial_putc(DEVICE_ID_BYTE2);
+	stm32prog_serial_putc((cpu >> 8) & 0xFF);
+	stm32prog_serial_putc(cpu & 0xFF);
 	stm32prog_serial_result(ACK_BYTE);
 }