mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-29 08:01:08 +00:00
FSL LAW: Keep track of LAW allocations
Make it so we keep track of which LAWs have allocated and provide a function (set_next_law) which can allocate a LAW for us if one is free. In the future we will move to doing more "dynamic" LAW allocation since the majority of users dont really care about what LAW number they are at. Also, add CONFIG_MPC8540 or CONFIG_MPC8560 to those boards which needed them Signed-off-by: Kumar Gala <galak@kernel.crashing.org> Signed-off-by: Andy Fleming <afleming@freescale.com>
This commit is contained in:
parent
ddde74a159
commit
f060054dad
10 changed files with 59 additions and 25 deletions
|
@ -148,6 +148,12 @@ void cpu_init_early_f(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
/* Pointer is writable since we allocated a register for it */
|
||||
gd = (gd_t *) (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET);
|
||||
|
||||
/* Clear initial global data */
|
||||
memset ((void *) gd, 0, sizeof (gd_t));
|
||||
|
||||
init_laws();
|
||||
invalidate_tlb(0);
|
||||
init_tlbs();
|
||||
|
@ -168,12 +174,6 @@ void cpu_init_f (void)
|
|||
disable_tlb(14);
|
||||
disable_tlb(15);
|
||||
|
||||
/* Pointer is writable since we allocated a register for it */
|
||||
gd = (gd_t *) (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET);
|
||||
|
||||
/* Clear initial global data */
|
||||
memset ((void *) gd, 0, sizeof (gd_t));
|
||||
|
||||
#ifdef CONFIG_CPM2
|
||||
config_8560_ioports((ccsr_cpm_t *)CFG_MPC85xx_CPM_ADDR);
|
||||
#endif
|
||||
|
@ -254,17 +254,6 @@ void cpu_init_f (void)
|
|||
|
||||
int cpu_init_r(void)
|
||||
{
|
||||
#ifdef CONFIG_CLEAR_LAW0
|
||||
#ifdef CONFIG_FSL_LAW
|
||||
disable_law(0);
|
||||
#else
|
||||
volatile ccsr_local_ecm_t *ecm = (void *)(CFG_MPC85xx_ECM_ADDR);
|
||||
|
||||
/* clear alternate boot location LAW (used for sdram, or ddr bank) */
|
||||
ecm->lawar0 = 0;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
puts ("L2: ");
|
||||
|
||||
#if defined(CONFIG_L2_CACHE)
|
||||
|
|
|
@ -27,8 +27,22 @@
|
|||
#include <asm/fsl_law.h>
|
||||
#include <asm/io.h>
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
#define LAWAR_EN 0x80000000
|
||||
#define FSL_HW_NUM_LAWS 10 /* number of LAWs in the hw implementation */
|
||||
/* number of LAWs in the hw implementation */
|
||||
#if defined(CONFIG_MPC8540) || defined(CONFIG_MPC8541) || \
|
||||
defined(CONFIG_MPC8560) || defined(CONFIG_MPC8555)
|
||||
#define FSL_HW_NUM_LAWS 8
|
||||
#elif defined(CONFIG_MPC8548) || defined(CONFIG_MPC8544) || \
|
||||
defined(CONFIG_MPC8568) || \
|
||||
defined(CONFIG_MPC8641) || defined(CONFIG_MPC8610)
|
||||
#define FSL_HW_NUM_LAWS 10
|
||||
#elif defined(CONFIG_MPC8572)
|
||||
#define FSL_HW_NUM_LAWS 12
|
||||
#else
|
||||
#error FSL_HW_NUM_LAWS not defined for this platform
|
||||
#endif
|
||||
|
||||
void set_law(u8 idx, phys_addr_t addr, enum law_size sz, enum law_trgt_if id)
|
||||
{
|
||||
|
@ -36,18 +50,34 @@ void set_law(u8 idx, phys_addr_t addr, enum law_size sz, enum law_trgt_if id)
|
|||
volatile u32 *lawbar = base + 8 * idx;
|
||||
volatile u32 *lawar = base + 8 * idx + 2;
|
||||
|
||||
gd->used_laws |= (1 << idx);
|
||||
|
||||
out_be32(lawbar, addr >> 12);
|
||||
out_be32(lawar, LAWAR_EN | ((u32)id << 20) | (u32)sz);
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
int set_next_law(phys_addr_t addr, enum law_size sz, enum law_trgt_if id)
|
||||
{
|
||||
u32 idx = ffz(gd->used_laws);
|
||||
|
||||
if (idx >= FSL_HW_NUM_LAWS)
|
||||
return -1;
|
||||
|
||||
set_law(idx, addr, sz, id);
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
||||
void disable_law(u8 idx)
|
||||
{
|
||||
volatile u32 *base = (volatile u32 *)(CFG_IMMR + 0xc08);
|
||||
volatile u32 *lawbar = base + 8 * idx;
|
||||
volatile u32 *lawar = base + 8 * idx + 2;
|
||||
|
||||
gd->used_laws &= ~(1 << idx);
|
||||
|
||||
out_be32(lawar, 0);
|
||||
out_be32(lawbar, 0);
|
||||
|
||||
|
@ -75,14 +105,16 @@ void print_laws(void)
|
|||
void init_laws(void)
|
||||
{
|
||||
int i;
|
||||
u8 law_idx = 0;
|
||||
|
||||
gd->used_laws = ~((1 << FSL_HW_NUM_LAWS) - 1);
|
||||
|
||||
for (i = 0; i < num_law_entries; i++) {
|
||||
if (law_table[i].index != -1)
|
||||
law_idx = law_table[i].index;
|
||||
|
||||
set_law(law_idx++, law_table[i].addr,
|
||||
law_table[i].size, law_table[i].trgt_id);
|
||||
if (law_table[i].index == -1)
|
||||
set_next_law(law_table[i].addr, law_table[i].size,
|
||||
law_table[i].trgt_id);
|
||||
else
|
||||
set_law(law_table[i].index, law_table[i].addr,
|
||||
law_table[i].size, law_table[i].trgt_id);
|
||||
}
|
||||
|
||||
return ;
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
#define SET_LAW_ENTRY(idx, a, sz, trgt) \
|
||||
{ .index = idx, .addr = a, .size = sz, .trgt_id = trgt }
|
||||
|
||||
#define SET_LAW(a, sz, trgt) \
|
||||
{ .index = -1, .addr = a, .size = sz, .trgt_id = trgt }
|
||||
|
||||
enum law_size {
|
||||
LAW_SIZE_4K = 0xb,
|
||||
LAW_SIZE_8K,
|
||||
|
@ -70,6 +73,7 @@ struct law_entry {
|
|||
};
|
||||
|
||||
extern void set_law(u8 idx, phys_addr_t addr, enum law_size sz, enum law_trgt_if id);
|
||||
extern int set_next_law(phys_addr_t addr, enum law_size sz, enum law_trgt_if id);
|
||||
extern void disable_law(u8 idx);
|
||||
extern void init_laws(void);
|
||||
extern void print_laws(void);
|
||||
|
|
|
@ -96,6 +96,9 @@ typedef struct global_data {
|
|||
uint mp_alloc_base;
|
||||
uint mp_alloc_top;
|
||||
#endif /* CONFIG_QE */
|
||||
#if defined(CONFIG_FSL_LAW)
|
||||
u32 used_laws;
|
||||
#endif
|
||||
#if defined(CONFIG_MPC5xxx)
|
||||
unsigned long ipb_clk;
|
||||
unsigned long pci_clk;
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#define CONFIG_MPC85xx 1 /* MPC8540/MPC8560 */
|
||||
#define CONFIG_CPM2 1 /* has CPM2 */
|
||||
#define CONFIG_MPC8560ADS 1 /* MPC8560ADS board specific */
|
||||
#define CONFIG_MPC8560 1
|
||||
|
||||
#define CONFIG_PCI
|
||||
#define CONFIG_TSEC_ENET /* tsec ethernet support */
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#define CONFIG_CPM2 1 /* has CPM2 */
|
||||
|
||||
#define CONFIG_SBC8540 1 /* configuration for SBC8560 board */
|
||||
#define CONFIG_MPC8540 1
|
||||
|
||||
#define CONFIG_MPC8560ADS 1 /* MPC8560ADS board specific (supplement) */
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
|
||||
#define CONFIG_CPM2 1 /* has CPM2 */
|
||||
#define CONFIG_SBC8560 1 /* configuration for SBC8560 board */
|
||||
#define CONFIG_MPC8560 1
|
||||
|
||||
/* XXX flagging this as something I might want to delete */
|
||||
#define CONFIG_MPC8560ADS 1 /* MPC8560ADS board specific */
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#define CONFIG_MPC85xx 1 /* MPC8540/MPC8560 */
|
||||
#define CONFIG_CPM2 1 /* has CPM2 */
|
||||
#define CONFIG_STXGP3 1 /* Silicon Tx GPPP board specific*/
|
||||
#define CONFIG_MPC8560 1
|
||||
|
||||
#undef CONFIG_PCI /* pci ethernet support */
|
||||
#define CONFIG_TSEC_ENET /* tsec ethernet support*/
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#define CONFIG_MPC85xx 1 /* MPC8540/MPC8560 */
|
||||
#define CONFIG_CPM2 1 /* has CPM2 */
|
||||
#define CONFIG_STXSSA 1 /* Silicon Tx GPPP SSA board specific*/
|
||||
#define CONFIG_MPC8560 1
|
||||
|
||||
#define CONFIG_PCI /* PCI ethernet support */
|
||||
#define CONFIG_TSEC_ENET /* tsec ethernet support*/
|
||||
|
|
|
@ -421,7 +421,8 @@ void board_init_f (ulong bootflag)
|
|||
/* compiler optimization barrier needed for GCC >= 3.4 */
|
||||
__asm__ __volatile__("": : :"memory");
|
||||
|
||||
#if !defined(CONFIG_CPM2) && !defined(CONFIG_MPC83XX)
|
||||
#if !defined(CONFIG_CPM2) && !defined(CONFIG_MPC83XX) && \
|
||||
!defined(CONFIG_MPC85xx) && !defined(CONFIG_MPC86xx)
|
||||
/* Clear initial global data */
|
||||
memset ((void *) gd, 0, sizeof (gd_t));
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue