diff options
author | wdenk <wdenk> | 2004-08-01 22:48:16 +0000 |
---|---|---|
committer | wdenk <wdenk> | 2004-08-01 22:48:16 +0000 |
commit | 281e00a3be453a169d854f824a460359d10f92bb (patch) | |
tree | 43dab398f1d6f601bb44df108427f7e0c611d68d /cpu/mpc8xx | |
parent | cfca5e604d5692f081cc1a9185ca5dc6dc77599d (diff) | |
download | u-boot-imx-281e00a3be453a169d854f824a460359d10f92bb.zip u-boot-imx-281e00a3be453a169d854f824a460359d10f92bb.tar.gz u-boot-imx-281e00a3be453a169d854f824a460359d10f92bb.tar.bz2 |
* Code cleanup
* Patch by Sascha Hauer, 28 Jun:
- add generic support for Motorola i.MX architecture
- add support for mx1ads, mx1fs2 and scb9328 boards
* Patches by Marc Leeman, 23 Jul 2004:
- Add define for the PCI/Memory Buffer Configuration Register
- corrected comments in cpu/mpc824x/cpu_init.c
* Add support for multiple serial interfaces
(for example to allow modem dial-in / dial-out)
Diffstat (limited to 'cpu/mpc8xx')
-rw-r--r-- | cpu/mpc8xx/scc.c | 6 | ||||
-rw-r--r-- | cpu/mpc8xx/serial.c | 234 | ||||
-rw-r--r-- | cpu/mpc8xx/spi.c | 10 |
3 files changed, 153 insertions, 97 deletions
diff --git a/cpu/mpc8xx/scc.c b/cpu/mpc8xx/scc.c index 78b2f99..6b9110f 100644 --- a/cpu/mpc8xx/scc.c +++ b/cpu/mpc8xx/scc.c @@ -193,6 +193,10 @@ static int scc_init (struct eth_device *dev, bd_t * bis) volatile immap_t *immr = (immap_t *) CFG_IMMR; +#if defined(CONFIG_LWMON) + reset_phy(); +#endif + #ifdef CONFIG_FADS #if defined(CONFIG_MPC86xADS) || defined(CONFIG_MPC860T) /* The MPC86xADS/FADS860T don't use the MODEM_EN or DATA_VOICE signals. */ @@ -550,6 +554,8 @@ static void scc_halt (struct eth_device *dev) immr->im_cpm.cp_scc[SCC_ENET].scc_gsmrl &= ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT); + + immr->im_ioport.iop_pcso &= ~(PC_ENET_CLSN | PC_ENET_RENA); } #if 0 diff --git a/cpu/mpc8xx/serial.c b/cpu/mpc8xx/serial.c index 71f3ae1..fa0405f 100644 --- a/cpu/mpc8xx/serial.c +++ b/cpu/mpc8xx/serial.c @@ -24,49 +24,44 @@ #include <common.h> #include <commproc.h> #include <command.h> +#include <serial.h> #include <watchdog.h> #if !defined(CONFIG_8xx_CONS_NONE) /* No Console at all */ #if defined(CONFIG_8xx_CONS_SMC1) /* Console on SMC1 */ #define SMC_INDEX 0 -#undef SCC_INDEX #define PROFF_SMC PROFF_SMC1 #define CPM_CR_CH_SMC CPM_CR_CH_SMC1 #elif defined(CONFIG_8xx_CONS_SMC2) /* Console on SMC2 */ #define SMC_INDEX 1 -#undef SCC_INDEX #define PROFF_SMC PROFF_SMC2 #define CPM_CR_CH_SMC CPM_CR_CH_SMC2 -#elif defined(CONFIG_8xx_CONS_SCC1) /* Console on SCC1 */ -#undef SMC_INDEX +#endif /* CONFIG_8xx_CONS_SMCx */ + +#if defined(CONFIG_8xx_CONS_SCC1) /* Console on SCC1 */ #define SCC_INDEX 0 #define PROFF_SCC PROFF_SCC1 #define CPM_CR_CH_SCC CPM_CR_CH_SCC1 #elif defined(CONFIG_8xx_CONS_SCC2) /* Console on SCC2 */ -#undef SMC_INDEX #define SCC_INDEX 1 #define PROFF_SCC PROFF_SCC2 #define CPM_CR_CH_SCC CPM_CR_CH_SCC2 #elif defined(CONFIG_8xx_CONS_SCC3) /* Console on SCC3 */ -#undef SMC_INDEX #define SCC_INDEX 2 #define PROFF_SCC PROFF_SCC3 #define CPM_CR_CH_SCC CPM_CR_CH_SCC3 #elif defined(CONFIG_8xx_CONS_SCC4) /* Console on SCC4 */ -#undef SMC_INDEX #define SCC_INDEX 3 #define PROFF_SCC PROFF_SCC4 #define CPM_CR_CH_SCC CPM_CR_CH_SCC4 -#else /* CONFIG_8xx_CONS_? */ -#error "console not correctly defined" -#endif +#endif /* CONFIG_8xx_CONS_SCCx */ static void serial_setdivisor(volatile cpm8xx_t *cp) { @@ -96,7 +91,23 @@ static void serial_setdivisor(volatile cpm8xx_t *cp) * as serial console interface. */ -int serial_init (void) +static void smc_setbrg (void) +{ + volatile immap_t *im = (immap_t *)CFG_IMMR; + volatile cpm8xx_t *cp = &(im->im_cpm); + + /* Set up the baud rate generator. + * See 8xx_io/commproc.c for details. + * + * Wire BRG1 to SMCx + */ + + cp->cp_simode = 0x00000000; + + serial_setdivisor(cp); +} + +static int smc_init (void) { volatile immap_t *im = (immap_t *)CFG_IMMR; volatile smc_t *sp; @@ -217,7 +228,7 @@ int serial_init (void) /* Set up the baud rate generator. */ - serial_setbrg (); + smc_setbrg (); /* Make the first buffer the only buffer. */ @@ -247,39 +258,8 @@ int serial_init (void) return (0); } -void -serial_setbrg (void) -{ - volatile immap_t *im = (immap_t *)CFG_IMMR; - volatile cpm8xx_t *cp = &(im->im_cpm); - - /* Set up the baud rate generator. - * See 8xx_io/commproc.c for details. - * - * Wire BRG1 to SMCx - */ - - cp->cp_simode = 0x00000000; - - serial_setdivisor(cp); -} - -#ifdef CONFIG_MODEM_SUPPORT -void disable_putc(void) -{ - DECLARE_GLOBAL_DATA_PTR; - gd->be_quiet = 1; -} - -void enable_putc(void) -{ - DECLARE_GLOBAL_DATA_PTR; - gd->be_quiet = 0; -} -#endif - -void -serial_putc(const char c) +static void +smc_putc(const char c) { volatile cbd_t *tbdf; volatile char *buf; @@ -295,7 +275,7 @@ serial_putc(const char c) #endif if (c == '\n') - serial_putc ('\r'); + smc_putc ('\r'); up = (smc_uart_t *)&cpmp->cp_dparam[PROFF_SMC]; @@ -317,8 +297,16 @@ serial_putc(const char c) } } -int -serial_getc(void) +static void +smc_puts (const char *s) +{ + while (*s) { + smc_putc (*s++); + } +} + +static int +smc_getc(void) { volatile cbd_t *rbdf; volatile unsigned char *buf; @@ -344,8 +332,8 @@ serial_getc(void) return(c); } -int -serial_tstc() +static int +smc_tstc(void) { volatile cbd_t *rbdf; volatile smc_uart_t *up; @@ -359,9 +347,41 @@ serial_tstc() return(!(rbdf->cbd_sc & BD_SC_EMPTY)); } -#else /* ! CONFIG_8xx_CONS_SMC1, CONFIG_8xx_CONS_SMC2 */ +struct serial_device serial_smc_device = +{ + "serial_smc", + "SMC", + smc_init, + smc_setbrg, + smc_getc, + smc_tstc, + smc_putc, + smc_puts, +}; + +#endif /* CONFIG_8xx_CONS_SMC1 || CONFIG_8xx_CONS_SMC2 */ + +#if defined(CONFIG_8xx_CONS_SCC1) || defined(CONFIG_8xx_CONS_SCC2) || \ + defined(CONFIG_8xx_CONS_SCC3) || defined(CONFIG_8xx_CONS_SCC4) + +static void +scc_setbrg (void) +{ + volatile immap_t *im = (immap_t *)CFG_IMMR; + volatile cpm8xx_t *cp = &(im->im_cpm); -int serial_init (void) + /* Set up the baud rate generator. + * See 8xx_io/commproc.c for details. + * + * Wire BRG1 to SCCx + */ + + cp->cp_sicr &= ~(0x000000FF << (8 * SCC_INDEX)); + + serial_setdivisor(cp); +} + +static int scc_init (void) { volatile immap_t *im = (immap_t *)CFG_IMMR; volatile scc_t *sp; @@ -426,7 +446,7 @@ int serial_init (void) #ifdef CFG_ALLOC_DPRAM dpaddr = dpram_alloc_align (sizeof(cbd_t)*2 + 2, 8) ; #else - dpaddr = CPM_SERIAL_BASE ; + dpaddr = CPM_SERIAL2_BASE ; #endif /* Enable SDMA. @@ -446,7 +466,7 @@ int serial_init (void) /* Set up the baud rate generator. */ - serial_setbrg (); + scc_setbrg (); /* Set up the uart parameters in the parameter ram. */ @@ -497,9 +517,11 @@ int serial_init (void) /* Set UART mode, clock divider 16 on Tx and Rx */ + sp->scc_gsmrl &= ~0xF; sp->scc_gsmrl |= (SCC_GSMRL_MODE_UART | SCC_GSMRL_TDCR_16 | SCC_GSMRL_RDCR_16); + sp->scc_psmr = 0; sp->scc_psmr |= SCU_PSMR_CL; /* Mask all interrupts and remove anything pending. @@ -521,25 +543,8 @@ int serial_init (void) return (0); } -void -serial_setbrg (void) -{ - volatile immap_t *im = (immap_t *)CFG_IMMR; - volatile cpm8xx_t *cp = &(im->im_cpm); - - /* Set up the baud rate generator. - * See 8xx_io/commproc.c for details. - * - * Wire BRG1 to SCCx - */ - - cp->cp_sicr &= ~(0x000000FF << (8 * SCC_INDEX)); - - serial_setdivisor(cp); -} - -void -serial_putc(const char c) +static void +scc_putc(const char c) { volatile cbd_t *tbdf; volatile char *buf; @@ -547,8 +552,15 @@ serial_putc(const char c) volatile immap_t *im = (immap_t *)CFG_IMMR; volatile cpm8xx_t *cpmp = &(im->im_cpm); +#ifdef CONFIG_MODEM_SUPPORT + DECLARE_GLOBAL_DATA_PTR; + + if (gd->be_quiet) + return; +#endif + if (c == '\n') - serial_putc ('\r'); + scc_putc ('\r'); up = (scc_uart_t *)&cpmp->cp_dparam[PROFF_SCC]; @@ -570,8 +582,16 @@ serial_putc(const char c) } } -int -serial_getc(void) +static void +scc_puts (const char *s) +{ + while (*s) { + scc_putc (*s++); + } +} + +static int +scc_getc(void) { volatile cbd_t *rbdf; volatile unsigned char *buf; @@ -597,8 +617,8 @@ serial_getc(void) return(c); } -int -serial_tstc() +static int +scc_tstc(void) { volatile cbd_t *rbdf; volatile scc_uart_t *up; @@ -612,36 +632,66 @@ serial_tstc() return(!(rbdf->cbd_sc & BD_SC_EMPTY)); } -#endif /* CONFIG_8xx_CONS_SMC1, CONFIG_8xx_CONS_SMC2 */ - +struct serial_device serial_scc_device = +{ + "serial_scc", + "SCC", + scc_init, + scc_setbrg, + scc_getc, + scc_tstc, + scc_putc, + scc_puts, +}; + +#endif /* CONFIG_8xx_CONS_SCCx */ -void -serial_puts (const char *s) +#ifdef CONFIG_MODEM_SUPPORT +void disable_putc(void) { - while (*s) { - serial_putc (*s++); - } + DECLARE_GLOBAL_DATA_PTR; + gd->be_quiet = 1; } +void enable_putc(void) +{ + DECLARE_GLOBAL_DATA_PTR; + gd->be_quiet = 0; +} +#endif #if (CONFIG_COMMANDS & CFG_CMD_KGDB) void kgdb_serial_init(void) { + int i = -1; + + if (strcmp(default_serial_console()->ctlr, "SMC") == 0) + { #if defined(CONFIG_8xx_CONS_SMC1) - serial_printf("[on SMC1] "); + i = 1; #elif defined(CONFIG_8xx_CONS_SMC2) - serial_printf("[on SMC2] "); -#elif defined(CONFIG_8xx_CONS_SCC1) - serial_printf("[on SCC1] "); + i = 2; +#endif + } + else if (strcmp(default_serial_console()->ctlr, "SMC") == 0) + { +#if defined(CONFIG_8xx_CONS_SCC1) + i = 1; #elif defined(CONFIG_8xx_CONS_SCC2) - serial_printf("[on SCC2] "); + i = 2; #elif defined(CONFIG_8xx_CONS_SCC3) - serial_printf("[on SCC3] "); + i = 3; #elif defined(CONFIG_8xx_CONS_SCC4) - serial_printf("[on SCC4] "); + i = 4; #endif + } + + if (i >= 0) + { + serial_printf("[on %s%d] ", default_serial_console()->ctlr, i); + } } void diff --git a/cpu/mpc8xx/spi.c b/cpu/mpc8xx/spi.c index 5d75207..9213d10 100644 --- a/cpu/mpc8xx/spi.c +++ b/cpu/mpc8xx/spi.c @@ -39,7 +39,7 @@ #include <linux/ctype.h> #include <malloc.h> #include <post.h> -#include <net.h> +#include <serial.h> #if (defined(CONFIG_SPI)) || (CONFIG_POST & CFG_POST_SPI) @@ -542,13 +542,13 @@ int spi_post_test (int flags) cp->cp_spmode &= ~SPMODE_LOOP; /* - * SCC2 Ethernet parameter RAM space overlaps + * SCC2 parameter RAM space overlaps * the SPI parameter RAM space. So we need to restore - * the SCC2 configuration if it is used by UART or Ethernet. + * the SCC2 configuration if it is used by UART. */ -#if defined(CONFIG_8xx_CONS_SCC2) - serial_init (); +#if !defined(CONFIG_8xx_CONS_NONE) + serial_reinit_all (); #endif if (res != 0) { |