[U-Boot] [PATCH 2/3] Add board specific code for da850 EVM

Provides initial support for TI OMAP-L138/DA850 SoC devices on a Logic PD EVM board.
Provides: Initial boot and configuration. Support for i2c. UART support (console).
Signed-off-by: Sudhakar Rajashekhara sudhakar.raj@ti.com --- board/davinci/da8xxevm/Makefile | 1 + board/davinci/da8xxevm/da850evm.c | 124 +++++++++++++++++++++++++++++++ include/asm-arm/arch-davinci/hardware.h | 1 + 3 files changed, 126 insertions(+), 0 deletions(-) create mode 100644 board/davinci/da8xxevm/da850evm.c
diff --git a/board/davinci/da8xxevm/Makefile b/board/davinci/da8xxevm/Makefile index 45da94b..93dbcbb 100644 --- a/board/davinci/da8xxevm/Makefile +++ b/board/davinci/da8xxevm/Makefile @@ -28,6 +28,7 @@ include $(TOPDIR)/config.mk LIB = $(obj)lib$(BOARD).a
COBJS-$(CONFIG_DA830_EVM) += da830evm.o +COBJS-$(CONFIG_DA850_EVM) += da850evm.o
COBJS := $(sort $(COBJS-y))
diff --git a/board/davinci/da8xxevm/da850evm.c b/board/davinci/da8xxevm/da850evm.c new file mode 100644 index 0000000..92548e2 --- /dev/null +++ b/board/davinci/da8xxevm/da850evm.c @@ -0,0 +1,124 @@ +/* + * (C) Copyright 2009, Texas Instruments, Inc. http://www.ti.com/ + * + * Based on da830evm.c + * + * Copyright (C) 2007 Sergey Kubushyn ksi@koi8.net + * + * Parts are shamelessly stolen from various TI sources, original copyright + * follows: + * ----------------------------------------------------------------- + * + * Copyright (C) 2004 Texas Instruments. + * + * ---------------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * ---------------------------------------------------------------------------- + */ + +#include <common.h> +#include <i2c.h> +#include <asm/arch/hardware.h> +#include <asm/io.h> +#include "../common/misc.h" + +DECLARE_GLOBAL_DATA_PTR; + +#define pinmux &davinci_syscfg_regs->pinmux + +#ifdef CONFIG_SPI_FLASH +/* SPI0 pin muxer settings */ +const struct pinmux_config spi1_pins[] = { + { pinmux[5], 1, 1 }, + { pinmux[5], 1, 2 }, + { pinmux[5], 1, 4 }, + { pinmux[5], 1, 5 } +}; +#endif + +/* UART pin muxer settings */ +const struct pinmux_config uart_pins[] = { + { pinmux[0], 4, 6 }, + { pinmux[0], 4, 7 }, + { pinmux[4], 2, 4 }, + { pinmux[4], 2, 5 } +}; + +/* I2C pin muxer settings */ +const struct pinmux_config i2c_pins[] = { + { pinmux[4], 2, 2 }, + { pinmux[4], 2, 3 } +}; + +int board_init(void) +{ +#ifndef CONFIG_USE_IRQ + /* + * Mask all IRQs by clearing the global enable and setting + * the enable clear for all the 90 interrupts. + */ + + writel(0, &davinci_aintc_regs->ger); + + writel(0, &davinci_aintc_regs->hier); + + writel(0xffffffff, &davinci_aintc_regs->ecr1); + writel(0xffffffff, &davinci_aintc_regs->ecr2); + writel(0xffffffff, &davinci_aintc_regs->ecr3); +#endif + + /* arch number of the board */ + gd->bd->bi_arch_number = MACH_TYPE_DAVINCI_DA850_EVM; + + /* address of boot parameters */ + gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR; + + /* + * Power on required peripherals + * ARM does not have access by default to PSC0 and PSC1 + * assuming here that the DSP bootloader has set the IOPU + * such that PSC access is available to ARM + */ + lpsc_on(DAVINCI_LPSC_AEMIF); /* NAND, NOR */ + lpsc_on(DAVINCI_LPSC_SPI1); /* Serial Flash */ + lpsc_on(DAVINCI_LPSC_EMAC); /* image download */ + lpsc_on(DAVINCI_LPSC_UART2); /* console */ + lpsc_on(DAVINCI_LPSC_GPIO); + + /* setup the SUSPSRC for ARM to control emulation suspend */ + writel(readl(&davinci_syscfg_regs->suspsrc) & + ~(DAVINCI_SYSCFG_SUSPSRC_EMAC | DAVINCI_SYSCFG_SUSPSRC_I2C | + DAVINCI_SYSCFG_SUSPSRC_SPI1 | DAVINCI_SYSCFG_SUSPSRC_TIMER0 | + DAVINCI_SYSCFG_SUSPSRC_UART2), + &davinci_syscfg_regs->suspsrc); + +#ifdef CONFIG_SPI_FLASH + if (davinci_configure_pin_mux(spi1_pins, ARRAY_SIZE(spi1_pins)) != 0) + return 1; +#endif + + if (davinci_configure_pin_mux(uart_pins, ARRAY_SIZE(uart_pins)) != 0) + return 1; + + if (davinci_configure_pin_mux(i2c_pins, ARRAY_SIZE(i2c_pins)) != 0) + return 1; + + /* enable the console UART */ + writel((DAVINCI_UART_PWREMU_MGMT_FREE | DAVINCI_UART_PWREMU_MGMT_URRST | + DAVINCI_UART_PWREMU_MGMT_UTRST), + &davinci_uart2_ctrl_regs->pwremu_mgmt); + + return(0); +} diff --git a/include/asm-arm/arch-davinci/hardware.h b/include/asm-arm/arch-davinci/hardware.h index 81cc8ab..3520cf8 100644 --- a/include/asm-arm/arch-davinci/hardware.h +++ b/include/asm-arm/arch-davinci/hardware.h @@ -398,6 +398,7 @@ struct davinci_syscfg_regs { #define DAVINCI_SYSCFG_SUSPSRC_EMAC (1 << 5) #define DAVINCI_SYSCFG_SUSPSRC_I2C (1 << 16) #define DAVINCI_SYSCFG_SUSPSRC_SPI0 (1 << 21) +#define DAVINCI_SYSCFG_SUSPSRC_SPI1 (1 << 22) #define DAVINCI_SYSCFG_SUSPSRC_UART2 (1 << 20) #define DAVINCI_SYSCFG_SUSPSRC_TIMER0 (1 << 27)

On 16/12/09 10:24, Sudhakar Rajashekhara wrote:
Provides initial support for TI OMAP-L138/DA850 SoC devices on a Logic PD EVM board.
Provides: Initial boot and configuration. Support for i2c. UART support (console).
Signed-off-by: Sudhakar Rajashekhara sudhakar.raj@ti.com
board/davinci/da8xxevm/Makefile | 1 + board/davinci/da8xxevm/da850evm.c | 124 +++++++++++++++++++++++++++++++ include/asm-arm/arch-davinci/hardware.h | 1 + 3 files changed, 126 insertions(+), 0 deletions(-) create mode 100644 board/davinci/da8xxevm/da850evm.c
[...]
diff --git a/board/davinci/da8xxevm/da850evm.c b/board/davinci/da8xxevm/da850evm.c new file mode 100644 index 0000000..92548e2 --- /dev/null +++ b/board/davinci/da8xxevm/da850evm.c @@ -0,0 +1,124 @@ +/*
- (C) Copyright 2009, Texas Instruments, Inc. http://www.ti.com/
- Based on da830evm.c
At this point, this seem to be a copy of da830evm.c (well except the first few lines above).
Copied code is not good. I have changes still in the pipe line for da830evm.c for adding support for NAND and Ethernet and there is a USB patch out there IIRC.
Since the da850 is so similar, I suspect we can at least factor out the common parts so that we don't have to edit two files to add NAND support for example.
I think it is the case that the only difference is DDR instead of SDRAM and the UBL will handle that for us. Is that true for the device *and* the EVM? If so, then possibly da830evm.c could be renamed to da8xxevm.c and the code kept completely common - at the risk of adding a few ifdefs later.
Nick.

Nick Thompson <nick.thompson <at> ge.com> writes:
On 16/12/09 10:24, Sudhakar Rajashekhara wrote:
Provides initial support for TI OMAP-L138/DA850 SoC devices on a Logic PD EVM board.
Provides: Initial boot and configuration. Support for i2c. UART support (console).
Signed-off-by: Sudhakar Rajashekhara <sudhakar.raj <at> ti.com>
board/davinci/da8xxevm/Makefile | 1 + board/davinci/da8xxevm/da850evm.c | 124
+++++++++++++++++++++++++++++++
include/asm-arm/arch-davinci/hardware.h | 1 + 3 files changed, 126 insertions(+), 0 deletions(-) create mode 100644 board/davinci/da8xxevm/da850evm.c
[...]
diff --git a/board/davinci/da8xxevm/da850evm.c
b/board/davinci/da8xxevm/da850evm.c
new file mode 100644 index 0000000..92548e2 --- /dev/null +++ b/board/davinci/da8xxevm/da850evm.c @@ -0,0 +1,124 @@ +/*
- (C) Copyright 2009, Texas Instruments, Inc. http://www.ti.com/
- Based on da830evm.c
At this point, this seem to be a copy of da830evm.c (well except the first
few lines above).
I don't think you have observed that the PINMUX registers are different on da850. So we are at risk of adding many ifdefs now itself if we combine da830 and da850. Also, there are few things which differ between da830 and da850, for example, MAC address is stored in I2C eeprom on da830 and in SPI eeprom on da850. You can have a look at http://www.arago-project.org/git/people/? p=sekhar/u-boot-omapl1.git;a=summary to understand how the da830 and da850 files look later when support for most peripherals are added.
To avoid code cluttering, I prefer using two separate files for da830 and da850.
Regards, Sudhakar

On 18/12/09 10:23, Sudhakar Rajashekhar wrote:
Nick Thompson <nick.thompson <at> ge.com> writes:
On 16/12/09 10:24, Sudhakar Rajashekhara wrote:
Provides initial support for TI OMAP-L138/DA850 SoC devices on a Logic PD EVM board.
Provides: Initial boot and configuration. Support for i2c. UART support (console).
Signed-off-by: Sudhakar Rajashekhara <sudhakar.raj <at> ti.com>
board/davinci/da8xxevm/Makefile | 1 + board/davinci/da8xxevm/da850evm.c | 124
+++++++++++++++++++++++++++++++
include/asm-arm/arch-davinci/hardware.h | 1 + 3 files changed, 126 insertions(+), 0 deletions(-) create mode 100644 board/davinci/da8xxevm/da850evm.c
[...]
diff --git a/board/davinci/da8xxevm/da850evm.c
b/board/davinci/da8xxevm/da850evm.c
new file mode 100644 index 0000000..92548e2 --- /dev/null +++ b/board/davinci/da8xxevm/da850evm.c @@ -0,0 +1,124 @@ +/*
- (C) Copyright 2009, Texas Instruments, Inc. http://www.ti.com/
- Based on da830evm.c
At this point, this seem to be a copy of da830evm.c (well except the first
few lines above).
I don't think you have observed that the PINMUX registers are different on da850. So we are at risk of adding many ifdefs now itself if we combine da830 and da850. Also, there are few things which differ between da830 and da850, for example, MAC address is stored in I2C eeprom on da830 and in SPI eeprom on da850. You can have a look at http://www.arago-project.org/git/people/? p=sekhar/u-boot-omapl1.git;a=summary to understand how the da830 and da850 files look later when support for most peripherals are added.
To avoid code cluttering, I prefer using two separate files for da830 and da850.
Yes, the pinmux table definitions are different, but I don't see how this requires duplicating code.
In the latest patches for da830, the pinmux setup is table driven. It would be very simple to pull out the two tables into da830 and da850 specific files (selected by the build system) and use common pinmux code to setup the pins appropriately. The code part for this is simply:
/* configure pinmux settings */ if (davinci_configure_pin_mux_items(pinmuxes, ARRAY_SIZE(pinmuxes))) return 1;
That would be exactly the same line of code for both devices.
It should be possible to put i2c (da830) and spi (da850) equivalent functions into that same file to read the MAC address. Abstractions of this form are also likely to make the code more readable. [In fact the function is already abstracted into misc.c, but it only provides for i2c currently]
There might be an issue with functions supported on one platform that are not supported on the other, but these could also be abstracted out. They also ought to be few because of the similarities of the devices.
Not doing so puts us at risk of increasing commmits and maintenance. There is no need to clutter the code - it can be layered and abstracted to handle differences cleanly.
Nick.

Hi,
On Mon, Dec 21, 2009 at 15:48:38, Nick Thompson wrote:
[...]
At this point, this seem to be a copy of da830evm.c (well except the first
few lines above).
I don't think you have observed that the PINMUX registers are different on da850. So we are at risk of adding many ifdefs now itself if we combine da830 and da850. Also, there are few things which differ between da830 and da850, for example, MAC address is stored in I2C eeprom on da830 and in SPI eeprom on da850. You can have a look at http://www.arago-project.org/git/people/? p=sekhar/u-boot-omapl1.git;a=summary to understand how the da830 and da850 files look later when support for most peripherals are added.
To avoid code cluttering, I prefer using two separate files for da830 and da850.
Yes, the pinmux table definitions are different, but I don't see how this requires duplicating code.
In the latest patches for da830, the pinmux setup is table driven. It would be very simple to pull out the two tables into da830 and da850 specific files (selected by the build system) and use common pinmux code to setup the pins appropriately. The code part for this is simply:
/* configure pinmux settings */ if (davinci_configure_pin_mux_items(pinmuxes, ARRAY_SIZE(pinmuxes))) return 1;
That would be exactly the same line of code for both devices.
Now I understand your intention. You are OK having two different files for da830 and da850, but you want me to put the common code in one place. I'll rework on this patch based on your comments and will resubmit it.
Also, you are talking about the latest patches for da830 which are following the above framework, but I did not see them in u-boot-ti branch. Have you submitted them to the list? If you have any public tree where you have maintained them, can you point me to that?
Thanks, Sudhakar

Hi,
On Mon, Dec 21, 2009 at 15:48:38, Nick Thompson wrote:
On 18/12/09 10:23, Sudhakar Rajashekhar wrote:
Nick Thompson <nick.thompson <at> ge.com> writes:
On 16/12/09 10:24, Sudhakar Rajashekhara wrote:
Provides initial support for TI OMAP-L138/DA850 SoC devices on a Logic PD EVM board.
Provides: Initial boot and configuration. Support for i2c. UART support (console).
Signed-off-by: Sudhakar Rajashekhara <sudhakar.raj <at> ti.com>
board/davinci/da8xxevm/Makefile | 1 + board/davinci/da8xxevm/da850evm.c | 124
+++++++++++++++++++++++++++++++
include/asm-arm/arch-davinci/hardware.h | 1 + 3 files changed, 126 insertions(+), 0 deletions(-) create mode 100644 board/davinci/da8xxevm/da850evm.c
[...]
diff --git a/board/davinci/da8xxevm/da850evm.c
b/board/davinci/da8xxevm/da850evm.c
new file mode 100644 index 0000000..92548e2 --- /dev/null +++ b/board/davinci/da8xxevm/da850evm.c @@ -0,0 +1,124 @@ +/*
- (C) Copyright 2009, Texas Instruments, Inc. http://www.ti.com/
- Based on da830evm.c
At this point, this seem to be a copy of da830evm.c (well except the first
few lines above).
I don't think you have observed that the PINMUX registers are different on da850. So we are at risk of adding many ifdefs now itself if we combine da830 and da850. Also, there are few things which differ between da830 and da850, for example, MAC address is stored in I2C eeprom on da830 and in SPI eeprom on da850. You can have a look at http://www.arago-project.org/git/people/? p=sekhar/u-boot-omapl1.git;a=summary to understand how the da830 and da850 files look later when support for most peripherals are added.
To avoid code cluttering, I prefer using two separate files for da830 and da850.
Yes, the pinmux table definitions are different, but I don't see how this requires duplicating code.
In the latest patches for da830, the pinmux setup is table driven. It would be very simple to pull out the two tables into da830 and da850 specific files (selected by the build system) and use common pinmux code to setup the pins appropriately. The code part for this is simply:
/* configure pinmux settings */ if (davinci_configure_pin_mux_items(pinmuxes, ARRAY_SIZE(pinmuxes))) return 1;
That would be exactly the same line of code for both devices.
It should be possible to put i2c (da830) and spi (da850) equivalent functions into that same file to read the MAC address. Abstractions of this form are also likely to make the code more readable. [In fact the function is already abstracted into misc.c, but it only provides for i2c currently]
There might be an issue with functions supported on one platform that are not supported on the other, but these could also be abstracted out. They also ought to be few because of the similarities of the devices.
Not doing so puts us at risk of increasing commmits and maintenance. There is no need to clutter the code - it can be layered and abstracted to handle differences cleanly.
I tried modifying the code in the way discussed above, but during the process I realized that by doing so it is becoming more difficult to add a new board based on da830/da850 SoC. Also, I feel it is better to extract out the common code in some Soc related file (say da8xx.c in cpu/arm926ejs/davinci) and still have two separate board files. Common code like IRQ disabling etc. can be implemented in this SoC specific file and this function will be called from the board files. Even in Linux kernel, two different board files are being maintained for da830 and da850 and there is a SoC specific file where the common code exists.
Regards, Sudhakar
participants (3)
-
Nick Thompson
-
Sudhakar Rajashekhar
-
Sudhakar Rajashekhara