mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-21 06:31:31 +00:00
mpc83xx: Use pre-defined asm functions
For a lot of inline assembly calls in the mpc8xxx and mpc83xx directories, we already have convenient pre-defined helper functions, but they're not used, resulting in hard-to-read code. Use these helper functions where ever possible and useful. Signed-off-by: Mario Six <mario.six@gdsys.cc>
This commit is contained in:
parent
1e718f43de
commit
5c22998503
4 changed files with 60 additions and 43 deletions
|
@ -133,18 +133,18 @@ do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
|
||||||
#ifdef MPC83xx_RESET
|
#ifdef MPC83xx_RESET
|
||||||
|
|
||||||
/* Interrupts and MMU off */
|
/* Interrupts and MMU off */
|
||||||
__asm__ __volatile__ ("mfmsr %0":"=r" (msr):);
|
msr = mfmsr();
|
||||||
|
|
||||||
msr &= ~(MSR_EE | MSR_IR | MSR_DR);
|
msr &= ~(MSR_EE | MSR_IR | MSR_DR);
|
||||||
__asm__ __volatile__ ("mtmsr %0"::"r" (msr));
|
mtmsr(msr);
|
||||||
|
|
||||||
/* enable Reset Control Reg */
|
/* enable Reset Control Reg */
|
||||||
immap->reset.rpr = 0x52535445;
|
immap->reset.rpr = 0x52535445;
|
||||||
__asm__ __volatile__ ("sync");
|
sync();
|
||||||
__asm__ __volatile__ ("isync");
|
isync();
|
||||||
|
|
||||||
/* confirm Reset Control Reg is enabled */
|
/* confirm Reset Control Reg is enabled */
|
||||||
while(!((immap->reset.rcer) & RCER_CRE));
|
while(!((immap->reset.rcer) & RCER_CRE))
|
||||||
|
;
|
||||||
|
|
||||||
udelay(200);
|
udelay(200);
|
||||||
|
|
||||||
|
@ -156,10 +156,9 @@ do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
|
||||||
immap->reset.rmr = RMR_CSRE; /* Checkstop Reset enable */
|
immap->reset.rmr = RMR_CSRE; /* Checkstop Reset enable */
|
||||||
|
|
||||||
/* Interrupts and MMU off */
|
/* Interrupts and MMU off */
|
||||||
__asm__ __volatile__ ("mfmsr %0":"=r" (msr):);
|
msr = mfmsr();
|
||||||
|
|
||||||
msr &= ~(MSR_ME | MSR_EE | MSR_IR | MSR_DR);
|
msr &= ~(MSR_ME | MSR_EE | MSR_IR | MSR_DR);
|
||||||
__asm__ __volatile__ ("mtmsr %0"::"r" (msr));
|
mtmsr(msr);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Trying to execute the next instruction at a non-existing address
|
* Trying to execute the next instruction at a non-existing address
|
||||||
|
|
|
@ -191,8 +191,8 @@ int do_ecc(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
ddr->err_disable = val;
|
ddr->err_disable = val;
|
||||||
__asm__ __volatile__("sync");
|
sync();
|
||||||
__asm__ __volatile__("isync");
|
isync();
|
||||||
return 0;
|
return 0;
|
||||||
} else if (strcmp(argv[1], "errdetectclr") == 0) {
|
} else if (strcmp(argv[1], "errdetectclr") == 0) {
|
||||||
val = ddr->err_detect;
|
val = ddr->err_detect;
|
||||||
|
@ -249,8 +249,8 @@ int do_ecc(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
|
||||||
printf("Incorrect command\n");
|
printf("Incorrect command\n");
|
||||||
|
|
||||||
ddr->ecc_err_inject = val;
|
ddr->ecc_err_inject = val;
|
||||||
__asm__ __volatile__("sync");
|
sync();
|
||||||
__asm__ __volatile__("isync");
|
isync();
|
||||||
return 0;
|
return 0;
|
||||||
} else if (strcmp(argv[1], "mirror") == 0) {
|
} else if (strcmp(argv[1], "mirror") == 0) {
|
||||||
val = ddr->ecc_err_inject;
|
val = ddr->ecc_err_inject;
|
||||||
|
@ -282,26 +282,26 @@ int do_ecc(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
|
||||||
|
|
||||||
/* enable injects */
|
/* enable injects */
|
||||||
ddr->ecc_err_inject |= ECC_ERR_INJECT_EIEN;
|
ddr->ecc_err_inject |= ECC_ERR_INJECT_EIEN;
|
||||||
__asm__ __volatile__("sync");
|
sync();
|
||||||
__asm__ __volatile__("isync");
|
isync();
|
||||||
|
|
||||||
/* write memory location injecting errors */
|
/* write memory location injecting errors */
|
||||||
ppcDWstore((u32 *) i, pattern);
|
ppcDWstore((u32 *) i, pattern);
|
||||||
__asm__ __volatile__("sync");
|
sync();
|
||||||
|
|
||||||
/* disable injects */
|
/* disable injects */
|
||||||
ddr->ecc_err_inject &= ~ECC_ERR_INJECT_EIEN;
|
ddr->ecc_err_inject &= ~ECC_ERR_INJECT_EIEN;
|
||||||
__asm__ __volatile__("sync");
|
sync();
|
||||||
__asm__ __volatile__("isync");
|
isync();
|
||||||
|
|
||||||
/* read data, this generates ECC error */
|
/* read data, this generates ECC error */
|
||||||
ppcDWload((u32 *) i, ret);
|
ppcDWload((u32 *) i, ret);
|
||||||
__asm__ __volatile__("sync");
|
sync();
|
||||||
|
|
||||||
/* re-initialize memory, double word write the location again,
|
/* re-initialize memory, double word write the location again,
|
||||||
* generates new ECC code this time */
|
* generates new ECC code this time */
|
||||||
ppcDWstore((u32 *) i, writeback);
|
ppcDWstore((u32 *) i, writeback);
|
||||||
__asm__ __volatile__("sync");
|
sync();
|
||||||
}
|
}
|
||||||
enable_interrupts();
|
enable_interrupts();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -321,29 +321,29 @@ int do_ecc(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
|
||||||
|
|
||||||
/* enable injects */
|
/* enable injects */
|
||||||
ddr->ecc_err_inject |= ECC_ERR_INJECT_EIEN;
|
ddr->ecc_err_inject |= ECC_ERR_INJECT_EIEN;
|
||||||
__asm__ __volatile__("sync");
|
sync();
|
||||||
__asm__ __volatile__("isync");
|
isync();
|
||||||
|
|
||||||
/* write memory location injecting errors */
|
/* write memory location injecting errors */
|
||||||
*(u32 *) i = 0xfedcba98UL;
|
*(u32 *) i = 0xfedcba98UL;
|
||||||
__asm__ __volatile__("sync");
|
sync();
|
||||||
|
|
||||||
/* sub double word write,
|
/* sub double word write,
|
||||||
* bus will read-modify-write,
|
* bus will read-modify-write,
|
||||||
* generates ECC error */
|
* generates ECC error */
|
||||||
*((u32 *) i + 1) = 0x76543210UL;
|
*((u32 *) i + 1) = 0x76543210UL;
|
||||||
__asm__ __volatile__("sync");
|
sync();
|
||||||
|
|
||||||
/* disable injects */
|
/* disable injects */
|
||||||
ddr->ecc_err_inject &= ~ECC_ERR_INJECT_EIEN;
|
ddr->ecc_err_inject &= ~ECC_ERR_INJECT_EIEN;
|
||||||
__asm__ __volatile__("sync");
|
sync();
|
||||||
__asm__ __volatile__("isync");
|
isync();
|
||||||
|
|
||||||
/* re-initialize memory,
|
/* re-initialize memory,
|
||||||
* double word write the location again,
|
* double word write the location again,
|
||||||
* generates new ECC code this time */
|
* generates new ECC code this time */
|
||||||
ppcDWstore((u32 *) i, writeback);
|
ppcDWstore((u32 *) i, writeback);
|
||||||
__asm__ __volatile__("sync");
|
sync();
|
||||||
}
|
}
|
||||||
enable_interrupts();
|
enable_interrupts();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -436,7 +436,7 @@ long int spd_sdram()
|
||||||
else if (caslat == 4)
|
else if (caslat == 4)
|
||||||
ddr->debug_reg = 0x202c0000; /* CL=3.0 */
|
ddr->debug_reg = 0x202c0000; /* CL=3.0 */
|
||||||
|
|
||||||
__asm__ __volatile__ ("sync");
|
sync();
|
||||||
|
|
||||||
debug("Errata DDR6 (debug_reg=0x%08x)\n", ddr->debug_reg);
|
debug("Errata DDR6 (debug_reg=0x%08x)\n", ddr->debug_reg);
|
||||||
}
|
}
|
||||||
|
@ -765,7 +765,8 @@ long int spd_sdram()
|
||||||
#endif
|
#endif
|
||||||
debug("DDR:sdram_clk_cntl=0x%08x\n", ddr->sdram_clk_cntl);
|
debug("DDR:sdram_clk_cntl=0x%08x\n", ddr->sdram_clk_cntl);
|
||||||
|
|
||||||
asm("sync;isync");
|
sync();
|
||||||
|
isync();
|
||||||
|
|
||||||
udelay(600);
|
udelay(600);
|
||||||
|
|
||||||
|
@ -834,7 +835,8 @@ long int spd_sdram()
|
||||||
#endif
|
#endif
|
||||||
/* Enable controller, and GO! */
|
/* Enable controller, and GO! */
|
||||||
ddr->sdram_cfg = sdram_cfg;
|
ddr->sdram_cfg = sdram_cfg;
|
||||||
asm("sync;isync");
|
sync();
|
||||||
|
isync();
|
||||||
udelay(500);
|
udelay(500);
|
||||||
|
|
||||||
debug("DDR:sdram_cfg=0x%08x\n", ddr->sdram_cfg);
|
debug("DDR:sdram_cfg=0x%08x\n", ddr->sdram_cfg);
|
||||||
|
@ -843,6 +845,22 @@ long int spd_sdram()
|
||||||
#endif /* CONFIG_SPD_EEPROM */
|
#endif /* CONFIG_SPD_EEPROM */
|
||||||
|
|
||||||
#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
|
#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
|
||||||
|
static inline u32 mftbu(void)
|
||||||
|
{
|
||||||
|
u32 rval;
|
||||||
|
|
||||||
|
asm volatile("mftbu %0" : "=r" (rval));
|
||||||
|
return rval;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline u32 mftb(void)
|
||||||
|
{
|
||||||
|
u32 rval;
|
||||||
|
|
||||||
|
asm volatile("mftb %0" : "=r" (rval));
|
||||||
|
return rval;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Use timebase counter, get_timer() is not available
|
* Use timebase counter, get_timer() is not available
|
||||||
* at this point of initialization yet.
|
* at this point of initialization yet.
|
||||||
|
@ -858,9 +876,9 @@ static __inline__ unsigned long get_tbms (void)
|
||||||
|
|
||||||
/* get the timebase ticks */
|
/* get the timebase ticks */
|
||||||
do {
|
do {
|
||||||
asm volatile ("mftbu %0":"=r" (tbu1):);
|
tbu1 = mftbu();
|
||||||
asm volatile ("mftb %0":"=r" (tbl):);
|
tbl = mftb();
|
||||||
asm volatile ("mftbu %0":"=r" (tbu2):);
|
tbu2 = mftbu();
|
||||||
} while (tbu1 != tbu2);
|
} while (tbu1 != tbu2);
|
||||||
|
|
||||||
/* convert ticks to ms */
|
/* convert ticks to ms */
|
||||||
|
@ -897,7 +915,7 @@ void ddr_enable_ecc(unsigned int dram_size)
|
||||||
for (p = 0; p < (u64*)(size); p++) {
|
for (p = 0; p < (u64*)(size); p++) {
|
||||||
ppcDWstore((u32*)p, pattern);
|
ppcDWstore((u32*)p, pattern);
|
||||||
}
|
}
|
||||||
__asm__ __volatile__ ("sync");
|
sync();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
t_end = get_tbms();
|
t_end = get_tbms();
|
||||||
|
@ -922,8 +940,8 @@ void ddr_enable_ecc(unsigned int dram_size)
|
||||||
/* Enable errors for ECC */
|
/* Enable errors for ECC */
|
||||||
ddr->err_disable &= ECC_ERROR_ENABLE;
|
ddr->err_disable &= ECC_ERROR_ENABLE;
|
||||||
|
|
||||||
__asm__ __volatile__ ("sync");
|
sync();
|
||||||
__asm__ __volatile__ ("isync");
|
isync();
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_DDR_ECC */
|
#endif /* CONFIG_DDR_ECC */
|
||||||
|
|
||||||
|
|
|
@ -131,10 +131,10 @@ static int pamu_config_ppaace(uint32_t liodn, uint64_t win_addr,
|
||||||
set_bf(ppaace->addr_bitfields, PAACE_AF_AP, PAACE_AP_PERMS_ALL);
|
set_bf(ppaace->addr_bitfields, PAACE_AF_AP, PAACE_AP_PERMS_ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
asm volatile("sync" : : : "memory");
|
sync();
|
||||||
/* Mark the ppace entry valid */
|
/* Mark the ppace entry valid */
|
||||||
ppaace->addr_bitfields |= PAACE_V_VALID;
|
ppaace->addr_bitfields |= PAACE_V_VALID;
|
||||||
asm volatile("sync" : : : "memory");
|
sync();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -279,7 +279,7 @@ int pamu_init(void)
|
||||||
out_be32(®s->splah, spaact_lim >> 32);
|
out_be32(®s->splah, spaact_lim >> 32);
|
||||||
out_be32(®s->splal, (uint32_t)spaact_lim);
|
out_be32(®s->splal, (uint32_t)spaact_lim);
|
||||||
}
|
}
|
||||||
asm volatile("sync" : : : "memory");
|
sync();
|
||||||
|
|
||||||
base_addr += PAMU_OFFSET;
|
base_addr += PAMU_OFFSET;
|
||||||
}
|
}
|
||||||
|
@ -294,7 +294,7 @@ void pamu_enable(void)
|
||||||
for (i = 0; i < CONFIG_NUM_PAMU; i++) {
|
for (i = 0; i < CONFIG_NUM_PAMU; i++) {
|
||||||
setbits_be32((void *)base_addr + PAMU_PCR_OFFSET,
|
setbits_be32((void *)base_addr + PAMU_PCR_OFFSET,
|
||||||
PAMU_PCR_PE);
|
PAMU_PCR_PE);
|
||||||
asm volatile("sync" : : : "memory");
|
sync();
|
||||||
base_addr += PAMU_OFFSET;
|
base_addr += PAMU_OFFSET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -318,7 +318,7 @@ void pamu_reset(void)
|
||||||
out_be32(®s->splal, 0);
|
out_be32(®s->splal, 0);
|
||||||
|
|
||||||
clrbits_be32((void *)regs + PAMU_PCR_OFFSET, PAMU_PCR_PE);
|
clrbits_be32((void *)regs + PAMU_PCR_OFFSET, PAMU_PCR_PE);
|
||||||
asm volatile("sync" : : : "memory");
|
sync();
|
||||||
base_addr += PAMU_OFFSET;
|
base_addr += PAMU_OFFSET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -331,7 +331,7 @@ void pamu_disable(void)
|
||||||
|
|
||||||
for (i = 0; i < CONFIG_NUM_PAMU; i++) {
|
for (i = 0; i < CONFIG_NUM_PAMU; i++) {
|
||||||
clrbits_be32((void *)base_addr + PAMU_PCR_OFFSET, PAMU_PCR_PE);
|
clrbits_be32((void *)base_addr + PAMU_PCR_OFFSET, PAMU_PCR_PE);
|
||||||
asm volatile("sync" : : : "memory");
|
sync();
|
||||||
base_addr += PAMU_OFFSET;
|
base_addr += PAMU_OFFSET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue