@@ -32,82 +32,82 @@ void sleep_us(uint32_t usec);
3232
3333/* Manual division operation */
3434static int division (uint32_t dividend ,
35- uint32_t divisor ,
36- uint32_t * quotient ,
37- uint32_t * remainder )
38- {
39- uint32_t shift ;
40- uint32_t divisor_shift ;
41- uint32_t factor = 0 ;
42- unsigned char end_flag = 0 ;
43-
44- if (!divisor )
45- return 0xffffffff ;
46-
47- if (dividend < divisor ) {
48- * quotient = 0 ;
49- * remainder = dividend ;
50- return 0 ;
51- }
35+ uint32_t divisor ,
36+ uint32_t * quotient ,
37+ uint32_t * remainder )
38+ {
39+ uint32_t shift ;
40+ uint32_t divisor_shift ;
41+ uint32_t factor = 0 ;
42+ unsigned char end_flag = 0 ;
43+
44+ if (!divisor )
45+ return 0xffffffff ;
46+
47+ if (dividend < divisor ) {
48+ * quotient = 0 ;
49+ * remainder = dividend ;
50+ return 0 ;
51+ }
5252
53- while (dividend >= divisor ) {
54- for (shift = 0 , divisor_shift = divisor ;
55- dividend >= divisor_shift ;
56- divisor_shift <<= 1 , shift ++ ) {
57- if (dividend - divisor_shift < divisor_shift ) {
58- factor += 1 << shift ;
59- dividend -= divisor_shift ;
60- end_flag = 1 ;
61- break ;
62- }
63- }
53+ while (dividend >= divisor ) {
54+ for (shift = 0 , divisor_shift = divisor ;
55+ dividend >= divisor_shift ;
56+ divisor_shift <<= 1 , shift ++ ) {
57+ if (dividend - divisor_shift < divisor_shift ) {
58+ factor += 1 << shift ;
59+ dividend -= divisor_shift ;
60+ end_flag = 1 ;
61+ break ;
62+ }
63+ }
6464
65- if (end_flag )
66- continue ;
65+ if (end_flag )
66+ continue ;
6767
68- factor += 1 << (shift - 1 );
69- dividend -= divisor_shift >> 1 ;
70- }
68+ factor += 1 << (shift - 1 );
69+ dividend -= divisor_shift >> 1 ;
70+ }
7171
72- if (quotient )
73- * quotient = factor ;
72+ if (quotient )
73+ * quotient = factor ;
7474
75- if (remainder )
76- * remainder = dividend ;
75+ if (remainder )
76+ * remainder = dividend ;
7777
78- return 0 ;
78+ return 0 ;
7979}
8080
8181static uint32_t div (uint32_t dividend , uint32_t divisor )
8282{
83- uint32_t quotient = 0 ;
84- uint32_t remainder = 0 ;
85- int ret ;
83+ uint32_t quotient = 0 ;
84+ uint32_t remainder = 0 ;
85+ int ret ;
8686
87- ret = division (dividend , divisor , & quotient , & remainder );
88- if (ret )
89- return 0xffffffff ;
87+ ret = division (dividend , divisor , & quotient , & remainder );
88+ if (ret )
89+ return 0xffffffff ;
9090
91- return quotient ;
91+ return quotient ;
9292}
9393
9494static uint32_t mod (uint32_t dividend , uint32_t divisor )
9595{
96- uint32_t quotient = 0 ;
97- uint32_t remainder = 0 ;
98- int ret ;
96+ uint32_t quotient = 0 ;
97+ uint32_t remainder = 0 ;
98+ int ret ;
9999
100- ret = division (dividend , divisor , & quotient , & remainder );
101- if (ret )
102- return 0xffffffff ;
100+ ret = division (dividend , divisor , & quotient , & remainder );
101+ if (ret )
102+ return 0xffffffff ;
103103
104- return remainder ;
104+ return remainder ;
105105}
106106
107107/* RAM configuration: 2 x MT47H64M16 on SAMA5D3-Xplained
108108 * 8 Mwords x 8 Banks x 16 bits x 2, total 2 Gbit
109109 */
110- static struct dram ddram = {
110+ static const struct dram ddram = {
111111 .timing = { /* Hardcoded for MT47H64M16, */
112112 .tras = 6 ,
113113 .trcd = 2 ,
@@ -132,7 +132,7 @@ static struct dram ddram ={
132132
133133void master_clock_set (uint32_t prescaler )
134134{
135- uint32_t mck = PMC_MCKR & (PMC_MDIV_MASK | PMC_CSS_MASK );
135+ uint32_t mck = PMC_MCKR & (PMC_MDIV_MASK | PMC_CSS_MASK );
136136 uint32_t diff = mck ^ prescaler ;
137137
138138 if (diff & PMC_ALTPRES_MASK ) {
@@ -262,7 +262,6 @@ static void ddr_init(void)
262262 cal &= ~(MPDDRC_IOCALIBR_RDIV_MASK );
263263 cal |= MPDDRC_IOCALIBR_RDIV_DDR2_RZQ_50 ; /* 50 ohm */
264264 cal &= ~(MPDDRC_IOCALIBR_TZQIO_MASK );
265- //cal |= (80 << MPDDRC_IOCALIBR_TZQIO_SHIFT); /* 100 cycles at 133MHz is 0.75 us, 100 cycles at 166MHz is 0.6 us */
266265 cal |= (100 << MPDDRC_IOCALIBR_TZQIO_SHIFT ); /* 100 cycles at 133MHz is 0.75 us, 100 cycles at 166MHz is 0.6 us */
267266
268267 MPDDRC_IO_CALIBR = cal ;
@@ -608,7 +607,7 @@ int ext_flash_read(uintptr_t address, uint8_t *data, int len)
608607 sz = remaining ;
609608
610609 do {
611- ret = nand_check_bad_block (block );
610+ ret = nand_check_bad_block (block );
612611 if (ret < 0 ) {
613612 /* Block is bad, skip it */
614613 block ++ ;
@@ -661,35 +660,39 @@ void pit_init(void)
661660
662661void sleep_us (uint32_t usec )
663662{
664- uint32_t base = PIT_PIIR ;
665- uint32_t delay ;
666- uint32_t current ;
667-
668- /* Since our division function which costs much run time
669- * causes the delay time error.
670- * So here using shifting to implement the division.
671- * to change "1000" to "1024", this cause some inaccuacy,
672- * but it is acceptable.
673- * ((MASTER_CLOCK / 1024) * usec) / (16 * 1024)
674- */
663+ uint32_t base = PIT_PIIR ;
664+ uint32_t delay ;
665+ uint32_t current ;
666+
667+ /* Since our division function which costs much run time
668+ * causes the delay time error.
669+ * So here using shifting to implement the division.
670+ * to change "1000" to "1024", this cause some inaccuacy,
671+ * but it is acceptable.
672+ * ((MASTER_CLOCK / 1024) * usec) / (16 * 1024)
673+ */
675674 delay = ((MASTER_FREQ >> 10 ) * usec ) >> 14 ;
676- do {
677- current = PIT_PIIR ;
678- current -= base ;
679- } while (current < delay );
675+ do {
676+ current = PIT_PIIR ;
677+ current -= base ;
678+ } while (current < delay );
680679}
681680
682-
683-
684-
685-
686681int ext_flash_write (uintptr_t address , const uint8_t * data , int len )
687682{
683+ /* TODO */
684+ (void )address ;
685+ (void )data ;
686+ (void )len ;
687+
688688 return 0 ;
689689}
690690
691691int ext_flash_erase (uintptr_t address , int len )
692692{
693+ /* TODO */
694+ (void )address ;
695+ (void )len ;
693696 return 0 ;
694697}
695698
@@ -704,22 +707,12 @@ void ext_flash_lock(void)
704707
705708void * hal_get_dts_address (void )
706709{
707- return (void * )& dts_addr ;
710+ return (void * )& dts_addr ;
708711}
709712
710713void * hal_get_dts_update_address (void )
711714{
712- return NULL ; /* Not yet supported */
713- }
714-
715- /* QSPI functions */
716- void qspi_init (uint32_t cpu_clock , uint32_t flash_freq )
717- {
718- }
719-
720-
721- void zynq_init (uint32_t cpu_clock )
722- {
715+ return NULL ; /* Not yet supported */
723716}
724717
725718
@@ -740,6 +733,9 @@ void hal_prepare_boot(void)
740733
741734int RAMFUNCTION hal_flash_write (uint32_t address , const uint8_t * data , int len )
742735{
736+ (void )address ;
737+ (void )data ;
738+ (void )len ;
743739 return 0 ;
744740}
745741
@@ -754,6 +750,8 @@ void RAMFUNCTION hal_flash_lock(void)
754750
755751int RAMFUNCTION hal_flash_erase (uint32_t address , int len )
756752{
753+ (void )address ;
754+ (void )len ;
757755 return 0 ;
758756}
759757
0 commit comments