20 #include <asm/fixmap.h>
25 #define EXI_CLK_32MHZ 5
28 #define EXI_CSR_CLKMASK (0x7<<4)
29 #define EXI_CSR_CLK_32MHZ (EXI_CLK_32MHZ<<4)
30 #define EXI_CSR_CSMASK (0x7<<7)
31 #define EXI_CSR_CS_0 (0x1<<7)
34 #define EXI_CR_TSTART (1<<0)
35 #define EXI_CR_WRITE (1<<2)
36 #define EXI_CR_READ_WRITE (2<<2)
37 #define EXI_CR_TLEN(len) (((len)-1)<<4)
41 #define UG_READ_ATTEMPTS 100
42 #define UG_WRITE_ATTEMPTS 100
45 static void __iomem *ug_io_base;
82 static int ug_is_adapter_present(
void)
87 return ug_io_transaction(0x90000000) == 0x04700000;
93 static int ug_is_txfifo_ready(
void)
95 return ug_io_transaction(0xc0000000) & 0x04000000;
102 static void ug_raw_putc(
char ch)
104 ug_io_transaction(0xb0000000 | (ch << 20));
121 while (!ug_is_txfifo_ready() && count--)
130 static int ug_is_rxfifo_ready(
void)
132 return ug_io_transaction(0xd0000000) & 0x04000000;
139 static int ug_raw_getc(
void)
141 u32 data = ug_io_transaction(0xa0000000);
142 if (data & 0x08000000)
143 return (data >> 16) & 0xff;
152 static int ug_getc(
void)
159 while (!ug_is_rxfifo_ready() && count--)
161 return ug_raw_getc();
180 static int ug_udbg_getc(
void)
184 while ((ch = ug_getc()) == -1)
192 static int ug_udbg_getc_poll(
void)
194 if (!ug_is_rxfifo_ready())
206 const unsigned int *
reg;
212 exi_io_base =
ioremap(paddr, reg[1]);
225 for (i = 0; i < 2; i++) {
226 ug_io_base = exi_io_base + 0x14 *
i;
227 if (ug_is_adapter_present())
253 exi_io_base = ug_udbg_setup_exi_io_base(np);
255 udbg_printf(
"%s: failed to setup EXI io base\n", __func__);
259 if (!ug_udbg_probe(exi_io_base)) {
275 #ifdef CONFIG_PPC_EARLY_DEBUG_USBGECKO
279 #if defined(CONFIG_GAMECUBE)
281 #elif defined(CONFIG_WII)
284 #error Invalid platform for USB Gecko based early debugging.
293 void __iomem *early_debug_area;
305 exi_io_base = early_debug_area + 0x00006800;
308 if (!ug_udbg_probe(exi_io_base))
323 setbat(1, (
unsigned long)early_debug_area,