x86: quark: MRC codes clean up
PATCH 1/1 x86: quark: MRC codes clean up
This patch cleans up the quark MRC codes coding style by:
- Remove BIT0/1../31 defines from mrc_util.h
- Create names for the documented BITs and use them
- For undocumented single BITs, use (1 << n) directly
- For undocumented ORed BITs, use the hex number directly
- Remove redundancy parenthesis all over the codes
- Replace to use lower case hex numbers
---
arch/x86/cpu/quark/hte.c | 74 +-- arch/x86/cpu/quark/hte.h | 4 +- arch/x86/cpu/quark/mrc.c | 12 +- arch/x86/cpu/quark/mrc_util.c | 326 ++++++----- arch/x86/cpu/quark/mrc_util.h | 34 -- arch/x86/cpu/quark/smc.c | 1205 ++++++++++++++++++----------------------- arch/x86/cpu/quark/smc.h | 349 +++++++----- 7 files changed, 955 insertions(+), 1049 deletions(-)
arch/x86/cpu/quark/hte.c +37 -37
@@ -20,9 +20,9 @@*/ static void hte_enable_all_errors (void ) { -msg_port_write (HTE ,0x000200A2 ,0xFFFFFFFF ); -msg_port_write (HTE ,0x000200A3 ,0x000000FF ); -msg_port_write (HTE ,0x000200A4 ,0x00000000 ); +msg_port_write (HTE ,0x000200a2 ,0xffffffff ); +msg_port_write (HTE ,0x000200a3 ,0x000000ff ); +msg_port_write (HTE ,0x000200a4 ,0x00000000 ); }/**
@@ -32,7 +32,7 @@ static void hte_enable_all_errors(void)*/ static u32 hte_check_errors (void ) { -return msg_port_read (HTE ,0x000200A7 ); +return msg_port_read (HTE ,0x000200a7 ); }/**
@@ -44,11 +44,11 @@ static void hte_wait_for_complete(void)ENTERFN (); -do {}while ((msg_port_read (HTE ,0x00020012 ) &BIT30 ) !=0 ); +do {}while ((msg_port_read (HTE ,0x00020012 ) & (1 <<30 )) !=0 ); tmp =msg_port_read (HTE ,0x00020011 ); - tmp |=BIT9 ; - tmp &= ~(BIT12 |BIT13 ); + tmp |= (1 <<9 ); + tmp &= ~((1 <<12 ) | (1 <<13 ));msg_port_write (HTE ,0x00020011 , tmp);LEAVEFN ();
@@ -65,9 +65,9 @@ static void hte_clear_error_regs(void)* Clear all HTE errors and enable error checking * for burst and chunk. */ - tmp =msg_port_read (HTE ,0x000200A1 ); - tmp |=BIT8 ; -msg_port_write (HTE ,0x000200A1 , tmp); + tmp =msg_port_read (HTE ,0x000200a1 ); + tmp |= (1 <<8 ); +msg_port_write (HTE ,0x000200a1 , tmp); }/**
@@ -91,25 +91,25 @@ static u16 hte_basic_data_cmp(struct mrc_params *mrc_params, u32 addr,u32 offset;if (first_run) { -msg_port_write (HTE ,0x00020020 ,0x01B10021 ); +msg_port_write (HTE ,0x00020020 ,0x01b10021 );msg_port_write (HTE ,0x00020021 ,0x06000000 );msg_port_write (HTE ,0x00020022 , addr >>6 );msg_port_write (HTE ,0x00020062 ,0x00800015 ); -msg_port_write (HTE ,0x00020063 ,0xAAAAAAAA ); -msg_port_write (HTE ,0x00020064 ,0xCCCCCCCC ); -msg_port_write (HTE ,0x00020065 ,0xF0F0F0F0 ); +msg_port_write (HTE ,0x00020063 ,0xaaaaaaaa ); +msg_port_write (HTE ,0x00020064 ,0xcccccccc ); +msg_port_write (HTE ,0x00020065 ,0xf0f0f0f0 );msg_port_write (HTE ,0x00020061 ,0x00030008 );if (mode ==WRITE_TRAIN ) - pattern =0xC33C0000 ; + pattern =0xc33c0000 ;else /* READ_TRAIN */ - pattern =0xAA5555AA ; + pattern =0xaa5555aa ; -for (offset =0x80 ; offset <=0x8F ; offset++) +for (offset =0x80 ; offset <=0x8f ; offset++)msg_port_write (HTE , offset, pattern); } -msg_port_write (HTE ,0x000200A1 ,0xFFFF1000 ); +msg_port_write (HTE ,0x000200a1 ,0xffff1000 );msg_port_write (HTE ,0x00020011 ,0x00011000 );msg_port_write (HTE ,0x00020011 ,0x00011100 );
@@ -119,7 +119,7 @@ static u16 hte_basic_data_cmp(struct mrc_params *mrc_params, u32 addr,* Return bits 15:8 of HTE_CH0_ERR_XSTAT to check for * any bytelane errors. */ -return (hte_check_errors () >>8 ) &0xFF ; +return (hte_check_errors () >>8 ) &0xff ; }/**
@@ -153,7 +153,7 @@ static u16 hte_rw_data_cmp(struct mrc_params *mrc_params, u32 addr,msg_port_write (HTE ,0x00020024 ,0x06070000 );msg_port_write (HTE ,0x00020022 , addr >>6 );msg_port_write (HTE ,0x00020025 , addr >>6 ); -msg_port_write (HTE ,0x00020062 ,0x0000002A ); +msg_port_write (HTE ,0x00020062 ,0x0000002a );msg_port_write (HTE ,0x00020063 , seed_victim);msg_port_write (HTE ,0x00020064 , seed_aggressor);msg_port_write (HTE ,0x00020065 , seed_victim);
@@ -163,21 +163,21 @@ static u16 hte_rw_data_cmp(struct mrc_params *mrc_params, u32 addr,* * Start with bit0 */ -for (offset =0x80 ; offset <=0x8F ; offset++) { +for (offset =0x80 ; offset <=0x8f ; offset++) {if ((offset %8 ) == victim_bit)msg_port_write (HTE , offset,0x55555555 );else -msg_port_write (HTE , offset,0xCCCCCCCC ); +msg_port_write (HTE , offset,0xcccccccc ); }msg_port_write (HTE ,0x00020061 ,0x00000000 );msg_port_write (HTE ,0x00020066 ,0x03440000 ); -msg_port_write (HTE ,0x000200A1 ,0xFFFF1000 ); +msg_port_write (HTE ,0x000200a1 ,0xffff1000 ); } tmp =0x10001000 | (loop_cnt <<16 );msg_port_write (HTE ,0x00020011 , tmp); -msg_port_write (HTE ,0x00020011 , tmp |BIT8 ); +msg_port_write (HTE ,0x00020011 , tmp | (1 <<8 ));hte_wait_for_complete ();
@@ -185,7 +185,7 @@ static u16 hte_rw_data_cmp(struct mrc_params *mrc_params, u32 addr,* Return bits 15:8 of HTE_CH0_ERR_XSTAT to check for * any bytelane errors. */ -return (hte_check_errors () >>8 ) &0xFF ; +return (hte_check_errors () >>8 ) &0xff ; }/**
@@ -219,14 +219,14 @@ u32 hte_mem_init(struct mrc_params *mrc_params, u8 flag)msg_port_write (HTE ,0x00020062 ,0x00000015 ); -for (offset =0x80 ; offset <=0x8F ; offset++) -msg_port_write (HTE , offset, ((offset &1 ) ?0xA55A :0x5AA5 )); +for (offset =0x80 ; offset <=0x8f ; offset++) +msg_port_write (HTE , offset, ((offset &1 ) ?0xa55a :0x5aa5 ));msg_port_write (HTE ,0x00020021 ,0x00000000 );msg_port_write (HTE ,0x00020022 , (mrc_params->mem_size >>6 ) -1 ); -msg_port_write (HTE ,0x00020063 ,0xAAAAAAAA ); -msg_port_write (HTE ,0x00020064 ,0xCCCCCCCC ); -msg_port_write (HTE ,0x00020065 ,0xF0F0F0F0 ); +msg_port_write (HTE ,0x00020063 ,0xaaaaaaaa ); +msg_port_write (HTE ,0x00020064 ,0xcccccccc ); +msg_port_write (HTE ,0x00020065 ,0xf0f0f0f0 );msg_port_write (HTE ,0x00020066 ,0x03000000 );switch (flag) {
@@ -243,7 +243,7 @@ u32 hte_mem_init(struct mrc_params *mrc_params, u8 flag)break ;default :DPF (D_INFO ,"Unknown parameter for flag: %d\n" , flag); -return 0xFFFFFFFF ; +return 0xffffffff ; }DPF (D_INFO ,"hte_mem_init" );
@@ -379,16 +379,16 @@ void hte_mem_op(u32 addr, u8 first_run, u8 is_write)msg_port_write (HTE ,0x00020021 ,0x06000000 );msg_port_write (HTE ,0x00020022 , addr >>6 );msg_port_write (HTE ,0x00020062 ,0x00800015 ); -msg_port_write (HTE ,0x00020063 ,0xAAAAAAAA ); -msg_port_write (HTE ,0x00020064 ,0xCCCCCCCC ); -msg_port_write (HTE ,0x00020065 ,0xF0F0F0F0 ); +msg_port_write (HTE ,0x00020063 ,0xaaaaaaaa ); +msg_port_write (HTE ,0x00020064 ,0xcccccccc ); +msg_port_write (HTE ,0x00020065 ,0xf0f0f0f0 );msg_port_write (HTE ,0x00020061 ,0x00030008 ); -for (offset =0x80 ; offset <=0x8F ; offset++) -msg_port_write (HTE , offset,0xC33C0000 ); +for (offset =0x80 ; offset <=0x8f ; offset++) +msg_port_write (HTE , offset,0xc33c0000 ); } -msg_port_write (HTE ,0x000200A1 ,0xFFFF1000 ); +msg_port_write (HTE ,0x000200a1 ,0xffff1000 );msg_port_write (HTE ,0x00020011 ,0x00011000 );msg_port_write (HTE ,0x00020011 ,0x00011100 );
arch/x86/cpu/quark/hte.h +2 -2
@@ -29,10 +29,10 @@ enum {#define HTE_LOOP_CNT 5/* random seed for victim */ -#define HTE_LFSR_VICTIM_SEED 0xF294BA21 +#define HTE_LFSR_VICTIM_SEED 0xf294ba21/* random seed for aggressor */ -#define HTE_LFSR_AGRESSOR_SEED 0xEBA7492D +#define HTE_LFSR_AGRESSOR_SEED 0xeba7492du32 hte_mem_init (struct mrc_params *mrc_params,u8 flag); u16 hte_basic_write_read(struct mrc_params *mrc_params, u32 addr,
arch/x86/cpu/quark/mrc.c +6 -6
@@ -105,8 +105,8 @@ static void mrc_adjust_params(struct mrc_params *mrc_params)* Column: 11 for 8Gbx8, else 10 */ mrc_params->column_bits[0 ] = - ((dram_params[0 ].density ==4 ) && - (dram_width ==X8 )) ? (11 ) : (10 ); + (dram_params[0 ].density ==4 ) && + (dram_width ==X8 ) ?11 :10 ;/* * Determine row bits:
@@ -117,9 +117,9 @@ static void mrc_adjust_params(struct mrc_params *mrc_params)* 4Gbx16=15 4Gbx8=16 * 8Gbx16=16 8Gbx8=16 */ - mrc_params->row_bits[0 ] =12 + (dram_params[0 ].density) + - (((dram_params[0 ].density <4 ) && - (dram_width ==X8 )) ? (1 ) : (0 )); + mrc_params->row_bits[0 ] =12 + dram_params[0 ].density + + (dram_params[0 ].density <4 ) && + (dram_width ==X8 ) ?1 :0 ;/* * Determine per-channel memory size:
@@ -137,7 +137,7 @@ static void mrc_adjust_params(struct mrc_params *mrc_params)* 4Gb x16 0x040000000 (1024MB) * 4Gb x8 0x080000000 (2048MB) */ - mrc_params->channel_size[0 ] = (1 << dram_params[0 ].density); + mrc_params->channel_size[0 ] =1 << dram_params[0 ].density; mrc_params->channel_size[0 ] *= (dram_width ==X8 ) ?2 :1 ; mrc_params->channel_size[0 ] *= (rank_enables ==0x3 ) ?2 :1 ; mrc_params->channel_size[0 ] *= (channel_width ==X16 ) ?1 :2 ;
arch/x86/cpu/quark/mrc_util.c +161 -165
779 lines not on this page · raw message
arch/x86/cpu/quark/mrc_util.h +0 -34
@@ -41,40 +41,6 @@#define LEAVEFN (...) debug_cond(D_FCALL, "</%s>\n", __func__)#define REPORTFN (...) debug_cond(D_FCALL, "<%s/>\n", __func__) -/* Generic Register Bits */ -#define BIT0 0x00000001 -#define BIT1 0x00000002 -#define BIT2 0x00000004 -#define BIT3 0x00000008 -#define BIT4 0x00000010 -#define BIT5 0x00000020 -#define BIT6 0x00000040 -#define BIT7 0x00000080 -#define BIT8 0x00000100 -#define BIT9 0x00000200 -#define BIT10 0x00000400 -#define BIT11 0x00000800 -#define BIT12 0x00001000 -#define BIT13 0x00002000 -#define BIT14 0x00004000 -#define BIT15 0x00008000 -#define BIT16 0x00010000 -#define BIT17 0x00020000 -#define BIT18 0x00040000 -#define BIT19 0x00080000 -#define BIT20 0x00100000 -#define BIT21 0x00200000 -#define BIT22 0x00400000 -#define BIT23 0x00800000 -#define BIT24 0x01000000 -#define BIT25 0x02000000 -#define BIT26 0x04000000 -#define BIT27 0x08000000 -#define BIT28 0x10000000 -#define BIT29 0x20000000 -#define BIT30 0x40000000 -#define BIT31 0x80000000 -/* Message Bus Port */ #define MEM_CTLR 0x01#define HOST_BRIDGE 0x03
arch/x86/cpu/quark/smc.c +531 -674
1,962 lines not on this page · raw message
arch/x86/cpu/quark/smc.h +218 -131
349 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.8.2.1
Part of the diff is not shown here. View the raw message.
PATCH 1/1 x86: quark: MRC codes clean up
Hi Bin,
Quoted 9 lines · Bin Meng
This patch cleans up the quark MRC codes coding style by:
- Remove BIT0/1../31 defines frommrc_util.h
- Create names for the documented BITs and use them
- For undocumented single BITs, use (1 << n) directly
- For undocumented ORed BITs, use the hex number directly
- Remove redundancy parenthesis all over the codes
- Replace to use lower case hex numbersSigned-off-by Bin Meng <[email protected]>
The code is now 80% less awful. Thank you for taking on this task.
Applied to u-boot/x86.
Regards,
Simon