85xx: socrates: autoprobe Lime chip

This patch is an attempt to implement autoprobing for the Lime
presence on the bus.
Configure GPCM for Lime CS2 and try to access chip ID registers.
Second read atempt delivers register values if the chip is present.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
This commit is contained in:
u-boot@bugs.denx.de 2008-09-11 15:40:01 +02:00 committed by Wolfgang Denk
parent e99b607a5e
commit fb661ea444

View File

@ -36,12 +36,15 @@
#include <libfdt.h> #include <libfdt.h>
#include <fdt_support.h> #include <fdt_support.h>
#include <asm/io.h> #include <asm/io.h>
#include <i2c.h>
#include <mb862xx.h>
#include <video_fb.h>
#include "upm_table.h" #include "upm_table.h"
DECLARE_GLOBAL_DATA_PTR; DECLARE_GLOBAL_DATA_PTR;
extern flash_info_t flash_info[]; /* FLASH chips info */ extern flash_info_t flash_info[]; /* FLASH chips info */
extern GraphicDevice mb862xx;
void local_bus_init (void); void local_bus_init (void);
ulong flash_get_size (ulong base, int banknum); ulong flash_get_size (ulong base, int banknum);
@ -174,11 +177,9 @@ void local_bus_init (void)
out_be32 (&lbc->mamr, 0x44440); /* Use a customer-supplied value */ out_be32 (&lbc->mamr, 0x44440); /* Use a customer-supplied value */
upmconfig (UPMA, (uint *)UPMTableA, sizeof(UPMTableA)/sizeof(int)); upmconfig (UPMA, (uint *)UPMTableA, sizeof(UPMTableA)/sizeof(int));
if (getenv("lime")) { /* Init UPMB for Lime controller access */
/* Init UPMB for Lime controller access */ out_be32 (&lbc->mbmr, 0x444440); /* Use a customer-supplied value */
out_be32 (&lbc->mbmr, 0x444440); /* Use a customer-supplied value */ upmconfig (UPMB, (uint *)UPMTableB, sizeof(UPMTableB)/sizeof(int));
upmconfig (UPMB, (uint *)UPMTableB, sizeof(UPMTableB)/sizeof(int));
}
} }
#if defined(CONFIG_PCI) #if defined(CONFIG_PCI)
@ -245,7 +246,7 @@ ft_board_setup(void *blob, bd_t *bd)
val[i++] = gd->bd->bi_flashstart; val[i++] = gd->bd->bi_flashstart;
val[i++] = gd->bd->bi_flashsize; val[i++] = gd->bd->bi_flashsize;
if (getenv("lime")) { if (mb862xx.frameAdrs == CFG_LIME_BASE) {
/* Fixup LIME mapping */ /* Fixup LIME mapping */
val[i++] = 2; /* chip select number */ val[i++] = 2; /* chip select number */
val[i++] = 0; /* always 0 */ val[i++] = 0; /* always 0 */
@ -267,10 +268,6 @@ ft_board_setup(void *blob, bd_t *bd)
} }
#endif /* defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) */ #endif /* defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) */
#include <i2c.h>
#include <mb862xx.h>
#include <video_fb.h>
#define CFG_LIME_SRST ((CFG_LIME_BASE) + 0x01FC002C) #define CFG_LIME_SRST ((CFG_LIME_BASE) + 0x01FC002C)
#define CFG_LIME_CCF ((CFG_LIME_BASE) + 0x01FC0038) #define CFG_LIME_CCF ((CFG_LIME_BASE) + 0x01FC0038)
#define CFG_LIME_MMR ((CFG_LIME_BASE) + 0x01FCFFFC) #define CFG_LIME_MMR ((CFG_LIME_BASE) + 0x01FCFFFC)
@ -285,8 +282,6 @@ ft_board_setup(void *blob, bd_t *bd)
#define DEFAULT_BRIGHTNESS 25 #define DEFAULT_BRIGHTNESS 25
#define BACKLIGHT_ENABLE (1 << 31) #define BACKLIGHT_ENABLE (1 << 31)
extern GraphicDevice mb862xx;
static const gdc_regs init_regs [] = static const gdc_regs init_regs [] =
{ {
{0x0100, 0x00010f00}, {0x0100, 0x00010f00},
@ -313,11 +308,44 @@ const gdc_regs *board_get_regs (void)
return init_regs; return init_regs;
} }
#define CFG_LIME_CID ((CFG_LIME_BASE) + 0x01FC00F0)
#define CFG_LIME_REV ((CFG_LIME_BASE) + 0x01FF8084)
int lime_probe(void)
{
volatile ccsr_lbc_t *memctl = (void *)(CFG_MPC85xx_LBC_ADDR);
uint cfg_br2;
uint cfg_or2;
uint reg;
cfg_br2 = memctl->br2;
cfg_or2 = memctl->or2;
/* Configure GPCM for CS2 */
memctl->br2 = 0;
memctl->or2 = 0xfc000410;
memctl->br2 = (CFG_LIME_BASE) | 0x00001901;
/* Try to access GDC ID/Revision registers */
reg = in_be32((void *)CFG_LIME_CID);
reg = in_be32((void *)CFG_LIME_CID);
if (reg == 0x303) {
reg = in_be32((void *)CFG_LIME_REV);
reg = in_be32((void *)CFG_LIME_REV);
reg = ((reg & ~0xff) == 0x20050100) ? 1 : 0;
} else
reg = 0;
/* Restore previous CS2 configuration */
memctl->br2 = 0;
memctl->or2 = cfg_or2;
memctl->br2 = cfg_br2;
return reg;
}
/* Returns Lime base address */ /* Returns Lime base address */
unsigned int board_video_init (void) unsigned int board_video_init (void)
{ {
if (!lime_probe())
if (!getenv("lime"))
return 0; return 0;
/* /*