From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH] Add MIMC200 board - now uses board_eth_init()
Date: Mon, 28 Jul 2008 22:03:43 +0200 [thread overview]
Message-ID: <20080728200343.GA28249@game.jcrosoft.org> (raw)
In-Reply-To: <488E1EE7.20104@mimc.co.uk>
+
> +static const struct sdram_config sdram_config = {
> + .data_bits = SDRAM_DATA_16BIT,
> + .row_bits = 13,
> + .col_bits = 9,
> + .bank_bits = 2,
> + .cas = 3,
> + .twr = 2,
> + .trc = 6,
> + .trp = 2,
> + .trcd = 2,
> + .tras = 6,
> + .txsr = 6,
^^^^^^^^
please indent with tab for all files
> + /* 15.6 us */
> + .refresh_period = (156 * (SDRAMC_BUS_HZ / 1000)) / 10000,
> +};
> +
> +int board_early_init_f(void)
> +{
> + /* Enable SDRAM in the EBI mux */
> + hmatrix_slave_write(EBI, SFR, HMATRIX_BIT(EBI_SDRAM_ENABLE));
> +
> + gpio_enable_ebi();
> + gpio_enable_usart1();
> +
> + // enable higher address lines for larger flash devices
please never use c++ comment style
> + gpio_select_periph_A(GPIO_PIN_PE16, 0); /* ADDR23 */
> + gpio_select_periph_A(GPIO_PIN_PE17, 0); /* ADDR24 */
> + gpio_select_periph_A(GPIO_PIN_PE18, 0); /* ADDR25 */
> +
> + // enable data flash chip select
> + gpio_select_periph_A(GPIO_PIN_PE25, 0); /* NCS2 */
+
> + // reset phys
> + gpio_select_pio(GPIO_PIN_PE24, 0);
> + gpio_set_value(GPIO_PIN_PC18, 1); /* PHY RESET */
> + gpio_select_pio(GPIO_PIN_PC18, GPIOF_OUTPUT);
> +
> + // GCLK0 - 10MHz clock
> + gpio_select_periph_A(GPIO_PIN_PA30, 0);
please replace with tab or a simple space.
> + // GCLK1 - 25MHz clock
> + //gpio_select_periph_A(GPIO_PIN_PA31, 0);
please remove dead code
> +
> + udelay(5000);
> +
> + // release phys reset
> + gpio_set_value(GPIO_PIN_PC18, 0); /* PHY RESET (Release) */
> +
> +#if defined(CONFIG_MACB)
> + gpio_enable_macb0();
> + gpio_enable_macb1();
> +#endif
> +#if defined(CONFIG_MMC)
> + gpio_enable_mmci();
> +#endif
> +
> + return 0;
> +}
> +
> +phys_size_t initdram(int board_type)
> +{
> + unsigned long expected_size;
> + unsigned long actual_size;
> + void *sdram_base;
> +
> + sdram_base = map_physmem(EBI_SDRAM_BASE, EBI_SDRAM_SIZE, MAP_NOCACHE);
> +
> + expected_size = sdram_init(sdram_base, &sdram_config);
> + actual_size = get_ram_size(sdram_base, expected_size);
> +
> + unmap_physmem(sdram_base, EBI_SDRAM_SIZE);
> +
> + if (expected_size != actual_size)
> + printf("Warning: Only %lu of %lu MiB SDRAM is working\n",
> + actual_size >> 20, expected_size >> 20);
> +
> + return actual_size;
> +}
> +
> +void board_init_info(void)
> +{
> + gd->bd->bi_phy_id[0] = 0x01;
> + gd->bd->bi_phy_id[1] = 0x03;
> +}
> +
> +/* SPI chip select control */
> +#ifdef CONFIG_ATMEL_SPI
> +#include <spi.h>
> +
> +int spi_cs_is_valid(unsigned int bus, unsigned int cs)
> +{
> + return bus == 0 && cs == 0;
please replace by
return (bus == 0) && (cs == 0);
> +}
> +
> +void spi_cs_activate(struct spi_slave *slave)
> +{
> +}
> +
> +void spi_cs_deactivate(struct spi_slave *slave)
> +{
> +}
> +#endif /* CONFIG_ATMEL_SPI */
> +
> +#ifdef CONFIG_CMD_NET
> +extern int macb_eth_initialize(int id, void *regs, unsigned int phy_addr);
> +
> +void board_eth_init(bd_t *bi)
> +{
> + macb_eth_initialize(0, (void *)MACB0_BASE, bi->bi_phy_id[0]);
> + macb_eth_initialize(1, (void *)MACB1_BASE, bi->bi_phy_id[1]);
> +}
> +#endif
> --- a/drivers/serial/atmel_usart.c
> +++ b/drivers/serial/atmel_usart.c
> @@ -21,6 +21,9 @@
> #include <asm/io.h>
> #include <asm/arch/clk.h>
> #include <asm/arch/memory-map.h>
> +#if defined(CONFIG_MIMC200_DBGLINK)
> +#include <asm/arch/gpio.h>
> +#endif
>
> #if defined(CONFIG_USART0)
> # define USART_ID 0
> @@ -73,27 +76,67 @@ int serial_init(void)
>
> void serial_putc(char c)
> {
> +#if defined(CONFIG_MIMC200_DBGLINK)
> + // only output serial data if DEBUG link connected
> + // this is connected to PIOE_21
> + if (gpio_get_value(GPIO_PIN_PE21) == 0)
> + {
> +#endif
> +
> if (c == '\n')
> serial_putc('\r');
>
> while (!(usart3_readl(CSR) & USART3_BIT(TXRDY))) ;
> usart3_writel(THR, c);
> +
> +#if defined(CONFIG_MIMC200_DBGLINK)
> + }
> +#endif
> }
>
> void serial_puts(const char *s)
> {
> +#if defined(CONFIG_MIMC200_DBGLINK)
> + // only output serial data if DEBUG link connected
> + // this is connected to PIOE_21
> + if (gpio_get_value(GPIO_PIN_PE21) == 0)
> + {
> +#endif
> +
> while (*s)
> serial_putc(*s++);
> +
> +#if defined(CONFIG_MIMC200_DBGLINK)
> + }
> +#endif
> }
>
> int serial_getc(void)
> {
> +#if defined(CONFIG_MIMC200_DBGLINK)
> + // only get serial data if DEBUG link connected
> + // this is connected to PIOE_21
> + if (gpio_get_value(GPIO_PIN_PE21) == 1)
> + {
> + return 0;
> + }
> +#endif
> +
> while (!(usart3_readl(CSR) & USART3_BIT(RXRDY))) ;
> return usart3_readl(RHR);
> }
>
> int serial_tstc(void)
> {
> +#if defined(CONFIG_MIMC200_DBGLINK)
> + // only get serial data if DEBUG link connected
> + // this is connected to PIOE_21
> + if (gpio_get_value(GPIO_PIN_PE21) == 1)
> + {
> + return (1 == 0);
why not return 0?
> + }
> +#endif
> +
> return (usart3_readl(CSR) & USART3_BIT(RXRDY)) != 0;
> }
Could you do this with a more generic way?
Maybe not in the atmel serial.
>
> diff --git a/include/configs/mimc200.h b/include/configs/mimc200.h
> new file mode 100644
> index 0000000..2376a15
> --- /dev/null
Best Regards,
J.
next prev parent reply other threads:[~2008-07-28 20:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-28 19:32 [U-Boot-Users] [PATCH] Add MIMC200 board - now uses board_eth_init() Mark Jackson
2008-07-28 19:56 ` Ben Warren
2008-07-29 8:52 ` Mark Jackson
2008-07-29 20:06 ` Scott Wood
2008-07-30 9:03 ` Mark Jackson
2008-07-28 20:03 ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2008-07-28 20:22 ` Scott Wood
2008-07-29 23:04 ` Wolfgang Denk
2008-07-29 23:16 ` Scott Wood
2008-07-29 8:26 ` Haavard Skinnemoen
2008-07-29 9:40 ` Mark Jackson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080728200343.GA28249@game.jcrosoft.org \
--to=plagnioj@jcrosoft.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.