LANPhone U-boot Kernel Rev1.0

12
Never stop thinking. CO NFI D EN T IAL Dis t ribu tion w ith NDA INCA-IP Infineon LAN Phone Software Solution (Linux/SIP) Integration Guide Release 1.1 User’s Manual, Rev. 1, Mar. 2005 Wireline Communications

Transcript of LANPhone U-boot Kernel Rev1.0

Page 1: LANPhone U-boot Kernel Rev1.0

N e v e r s t o p t h i n k i n g .

CO

NF

I DE

NT

I AL

Dis

t ri b

ut i

on

wi t

h N

DA

INCA-IPInf ineon LAN Phone Software Solut ion (Linux/SIP) Integrat ion GuideRelease 1.1

User’s Manual , Rev. 1, Mar. 2005

Wirel ine Communicat ions

Page 2: LANPhone U-boot Kernel Rev1.0

CONFIDENTIAL

INCA-IP LAN PhoneSoftware Integration Guide

User’s Manual 2 Rev. 1, 2005-03-18

Trademarks

ABM®, ACE®, AOP®, ARCOFI®, ASM®, ASP®, DigiTape®, DuSLIC®, EPIC®, ELIC®, FALC®, GEMINAX®, IDEC®, INCA®, IOM®, IPAT®-2, ISAC®, ITAC®, IWE®, IWORX®, MUSAC®, MuSLIC®, OCTAT®, OptiPort®, POTSWIRE®, QUAT®, QuadFALC®, SCOUT®, SICAT®, SICOFI®, SIDEC®, SLICOFI®, SMINT®, SOCRATES®, VINETIC®, 10BaseV®, 10BaseVX® are registered trademarks of Infineon Technologies AG. 10BaseS™, EasyPort™, VDSLite™ are trademarks of Infineon Technologies AG. Microsoft® is a registered trademark of Microsoft Corporation, Linux® of Linus Torvalds, Visio® of Visio Corporation, and FrameMaker® of Adobe Systems Incorporated.

PSB 21553 Infineon LAN Phone Software Solution (Linux/SIP) Integration GuideCONFIDENTIALRevision History: 2005-03-18, Rev. 1

Previous Version:

Page Subjects (major changes since last revision)

Page 3: LANPhone U-boot Kernel Rev1.0

User’s Manual 3 Rev. 1, 2005-03-18

CONFIDENTIAL

INCA-IP LAN PhoneSoftware Integration Guide

1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

2 The Bootloader U-Boot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62.1 cpu/mips/start.S:_start() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.2 board/incaip/memsetup.S:memsetup() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.3 lib_mips/board.c:board_init_r() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82.4 board/incaip/flash.c:flash_init() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82.5 board/incaip/flash.c:jffs2_part_info() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92.6 include/flash.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

3 The Linux Kernel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93.1 arch/mips/kernel/head.S:kernel_entry() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93.2 arch/mips/infineon/incaip/basic/prom.c:prom_init() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103.3 init/main.c:start_kernel() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103.4 drivers/mtd/maps/incaip.c:init_incaip_mtd() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103.5 arch/mips/defconfig-incaip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

Table of Contents

Page 4: LANPhone U-boot Kernel Rev1.0

User’s Manual 4 Rev. 1, 2005-03-18

CONFIDENTIAL

INCA-IP LAN PhoneSoftware Integration Guide

Table 1 EBU Memory Mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7Table 2 Kernel Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

List of Tables

Page 5: LANPhone U-boot Kernel Rev1.0

User’s Manual 5 Rev. 1, 2005-03-18

CONFIDENTIAL

INCA-IP LAN PhoneSoftware Integration Guide

Figure 1 U-Boot Initialization Phase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

List of Figures

Page 6: LANPhone U-boot Kernel Rev1.0

CONFIDENTIAL

INCA-IP LAN PhoneSoftware Integration Guide

Introduction

1 IntroductionThis document is intended to help developers to integrate the existing Infineon LAN Phone software solution into their own designs. Each chapter focuses on a specific part of the software (boot loader or Linux kernel). For U-Boot it gives an overview of what happens during boot.

Each file is described separately and the main function is specified in the chapter title. If it might be necessary to apply some changes in order to port the software to a new design it will be mentioned.

Notes:

1. This guide assumes the usage of an INCA-IP as CPU. It is not intended to be a porting guide for any other MIPS based CPU.

2. For changes regarding HAPI please refer to “LAN Phone - User’s Manual Software Descrition” chapter 6 “Customization Examples”.

2 The Bootloader U-BootThe first thing to be adapted to a new design is the bootloader since it is the first piece of software, that will be executed after power-up. Infineon uses U-Boot as bootloader for the INCA-IP demo board. Normally the bootloader does not support all devices on a specific board. Only devices that are needed for starting the Linux kernel and for maintenance issues should be initialized.

The current U-Boot uses the following devices:

• SDRAM• Flash memory• ASC• Ethernet Switch and Phys

Figure 1 U-Boot Initialization Phase

After Reset, code execution starts from flash

cpu/mips/start.S:_start()

board/incaip/memsetup.S:memsetup()

lib_mips/board.c:board_init_r()

board/incaip/flash.c:flash_init()

ebu_setup()

cgu_setup()

sdram_setup()

Relocate code from flash to RAM

Networking initialization

Console setup

Start command line from common/main.c:main_loop()

U-BOOT-STARTUP-SEQUENCE

User’s Manual 6 Rev. 1, 2005-03-18

Page 7: LANPhone U-boot Kernel Rev1.0

CONFIDENTIAL

INCA-IP LAN PhoneSoftware Integration Guide

The Bootloader U-Boot

2.1 cpu/mips/start.S:_start()

This file contains the first executed code after a power-up or reset. The _start label marks the beginning of the exception vector table, where the first entry is a jump to the U-Boot entry point (reset:) and the second entry is the software reboot vector. All other exception vectors are set to a default handler, which just consists of an endless loop.

In case of the INCA-IP the first two entries are followed by a 32bit word which is the configuration word for the EBU. When using external memory as source for boot code, this dataword is fetched by the EBU “blindly” after reset and it is used to configure the EBU before fetching the first code. If the external memory cannot be accessed with the default value for BUSCON0 the correct value needs to be set here (see chapter 13.2.4 in “User’s Manual Hardware Description” for details). For 100MHz the default value for the EBU config word is 0x000020C4, which enables write accesses to the memory at chip select 0, with 3 read wait states and 1 recovery cycle.

_start:

RVECENT(reset,0)/* U-boot entry point */ RVECENT(reset,1)/* software reboot */

#if defined(CONFIG_INCA_IP) .word INFINEON_EBU_BOOTCFG /* EBU init code, fetched during booting */ .word 0x00000000 /* phase of the flash */

#else RVECENT(romReserved,2)

#endif RVECENT(romReserved,3) RVECENT(romReserved,4) RVECENT(romReserved,5)

... /* Exception handlers. */ romReserved:

b romReserved

The reset routine will initialize internal CPU registers and check whether an NMI occurred. Then memory (function memsetup()) and caches (function mips_cache_reset()) will be initialized before the code is relocated from flash to RAM (function board_init_f() in file lib_mips/board.c). After relocation the bootloader will continue with function board_init_r() in file lib_mips/board.c.

2.2 board/incaip/memsetup.S:memsetup()

In an early stage of the boot phase it is necessary to set up EBU, CPU frequency and SDRAM. Function memsetup() calls a separate function for each item.

ebu_init() initializes all BUSCON and ADDSEL registers. If any other device is connected to the INCA-IP via EBU the corresponding BUSCON and ADDSEL values need also to be configured here (for example the buswidth often needs to be set to the correct value).

During compilation the default clock rate is defined (100 MHz or 150 MHz). cgu_init() configures the internal PLL to use this clock rate. Normally there are no changes needed here.

Table 1 EBU Memory Mapping

Register Value Description

ADDSEL0 0xA0000041 FPI Address 0xA0000000 - 0xA07FFFFF used for CS0 (Flash bank 0)

ADDSEL1 0xBE0000F1 FPI Address 0xBE000000 - 0xBE001000 used for CS1 (Latch)

ADDSEL2 0xA0800041 FPI Address 0xA0800000 - 0xA0FFFFFF used for CS2 (Flash bank 1)

User’s Manual 7 Rev. 1, 2005-03-18

Page 8: LANPhone U-boot Kernel Rev1.0

CONFIDENTIAL

INCA-IP LAN PhoneSoftware Integration Guide

The Bootloader U-Boot

sdram_init() configures the SDRAM memory controller. Depending on the type of SDRAM it might be necessary to adjust settings (for example size, number of columns/rows, timing etc.). Check SDRAM datasheet for details about these settings and User’s Manual Hardware Description for information on how to correctly configure the SDRAM controller.

2.3 lib_mips/board.c:board_init_r()

Function board_init_r() is called after the code was relocated to RAM. Memory management, networking and other devices are initialized now. If there is an external device that should be supported by U-Boot, it can be configured here. Flash memory is initialized by calling flash_init() in file board/incaip/flash.c.

If the MAC address for the Ethernet device is not stored as an U-Boot environment variable it should be read from the appropriate location before eth_initialize() is called.

2.4 board/incaip/flash.c:flash_init()

flash_init() will set up the flash and return the flash size. During compilation the number of flash banks and memory location is defined. With these values U-Boot probes for known flash chips by checking the manufacturer code of the flash (function flash_get_size()). If some unknown flash is used flash_get_size() needs to be adapted to support the new flash type.

/* Write auto select command sequence and test FLASH answer */ addr[FLASH_CYCLE1] = (FPW)0x00AA00AA;/* for AMD, Intel ignores this */ addr[FLASH_CYCLE2] = (FPW)0x00550055;/* for AMD, Intel ignores this */ addr[FLASH_CYCLE1] = (FPW)0x00900090;/* selects Intel or AMD */

/* The manufacturer codes are only 1 byte, so just use 1 byte. * This works for any bus width and any FLASH device width. */ reg=addr[1];

switch (reg & 0xff) {

case (uchar)AMD_MANUFACT: info->flash_id = FLASH_MAN_AMD; break;

case (uchar)INTEL_MANUFACT: info->flash_id = FLASH_MAN_INTEL; break;

default: info->flash_id = FLASH_UNKNOWN; info->sector_count = 0; info->size = 0; break;

} /* Check 16 bits or 32 bits of ID so work on 32 or 16 bit bus. */ if (info->flash_id != FLASH_UNKNOWN) {

reg=addr[0]; switch (reg) {

case (FPW)AMD_ID_LV640U:/* 29LV640 and 29LV641 have same ID */ info->flash_id += FLASH_AM640U; info->sector_count = 128; info->size = 0x00800000 * (sizeof(FPW)/2); break; /* => 8 or 16 MB*/

...

User’s Manual 8 Rev. 1, 2005-03-18

Page 9: LANPhone U-boot Kernel Rev1.0

CONFIDENTIAL

INCA-IP LAN PhoneSoftware Integration Guide

The Linux Kernel

Note: Due to the implementation of the external device access of the INCA-IP, it is necessary to switch the addresses for flash probing. The code example takes this into account, by reading first addr[1] and then addr[0].

2.5 board/incaip/flash.c:jffs2_part_info()

In the current version the JFFS2 root partition, which can be accessed by U-Boot starts at 0xB0400000. If the partition should be located elsewhere the offset and size needs to be modified in jffs2_part_info().

2.6 include/flash.h

If a new flash type should be supported by U-Boot, the manufacturer ID and the flash ID should be defined here.

3 The Linux KernelWhen the Linux kernel is started, it will rely on the fact that the bootloader initialized some hardware parts. For example SDRAM controller and EBU settings should not be changed by Linux. Some devices will be re initialized during the Linux boot phase, like ASC and Ethernet switch.

If an external device is connected to an external interrupt the settings for rising and falling edge etc. should be handled by the specific device driver.

3.1 arch/mips/kernel/head.S:kernel_entry()

The kernel is started by calling kernel_entry(). This function will set up the stackpointer, clear the bss segment and then call init_arch() to proceed with the booting process. The kernel needs some registers set up before starting (see Table 2). U-Boot will do this correctly. If another bootloader is used, it needs to be checked whether these registers are supported.

As an example of how to set up the register, the following script for the Lauterbach JTAG debugger can be used:

Register.RESetRegister.Set PC kernel_entryRegister.Set R4 2 ; argcRegister.Set R5 0x800c0000 ; argvRegister.Set R6 0x800c0100 ; envpRegister.Set R7 0x04000000 ; memsizeData.Set 0x800c0000 %l 0x800c0010 0x800c0020 ; argvData.Set 0x800c0010 "go" 0 ; first argumentData.Set 0x800c0020 "root=/dev/ram rootfstype=romfs" 0 ; boot cmdData.Set 0x800c0100 %l 0x800c0110 0x800c0120 0x800c0140 0x00000000; envpData.Set 0x800c0110 "memsize=16" 0 ; memory sizeData.Set 0x800c0120 "flash_start=0xb0000000" 0 ; flash start addressData.Set 0x800c0140 "flash_size=16777216" 0 ; flash size

Table 2 Kernel Parameters

Register Description

R4 Number of arguments (argc)

R5 Pointer to array of arguments (argv)

R6 Pointer to environment (envp)

R7 Memory size

User’s Manual 9 Rev. 1, 2005-03-18

Page 10: LANPhone U-boot Kernel Rev1.0

CONFIDENTIAL

INCA-IP LAN PhoneSoftware Integration Guide

The Linux Kernel

3.2 arch/mips/infineon/incaip/basic/prom.c:prom_init()

prom_init() checks the provided environment array for values like memsize and flash location. Depending on the type of bootloader used, the format of this data might be different. If the bootloader does not provide such an environment at all it should be changed here accordingly.

3.3 init/main.c:start_kernel()

start_kernel() is the first architecture independent function, that is called. After initializing basic functions like interrupt handling and caches, the init() task is created and the main task will enter the idle loop. init() will set up system busses and call all init functions, which were registered with the __init macro during compilation. Then /sbin/init is started as first user space program. If anything special (like setting some GPIO pins) needs to be done to initialize devices on the board it should be done as part of an __init function. If this is not possible since a special calling order needs to be obeyed, such a function can be called from init() directly.

3.4 drivers/mtd/maps/incaip.c:init_incaip_mtd()

Linux uses Memory Technology Devices (MTD) for flash support. There are some access functions that might need adaptation if the type of flash memory is different from the INCA-IP Demo board (for example 8bit instead of 16bit bus width).

For each flash chip a partition layout needs to be defined (structures incaip_partitions and incaip_fs_partitions). This layout needs to be changed to support the actual amount of flash memory on a specific board. For example if only 8MB flash is available then the incaip_fs_partitions structure could be removed.

/* partition definition for first flash bank */ static struct mtd_partition incaip_partitions[] = {

{ name: "U-Boot", /* U-Boot firmware */ offset: 0x00000000, size: 0x00030000, }, { name: "Environment",/* U-Boot environment / offset: 0x00030000, size: 0x00010000, }, { name: "Linux", /* Factory kernel image */ offset: 0x00040000, size: 0x000C0000, }, { name: "rootfs", /* Factory root filesystem */ offset: 0x00100000, size: 0x00300000, }, { name: "Linux 2", /* Default filesystem + kernel */ offset: 0x00400000, size: 0x003c0000, },

};

User’s Manual 10 Rev. 1, 2005-03-18

Page 11: LANPhone U-boot Kernel Rev1.0

CONFIDENTIAL

INCA-IP LAN PhoneSoftware Integration Guide

The Linux Kernel

3.5 arch/mips/defconfig-incaip

Due to the flexibility of the INCA-IP multiplexing system it is possible that for a new design the number of supported LEDs, keys and GPIO pins is different than for the Infineon demo board. To be able to support all kinds of designs, the multiplex settings can be defined for each pin during compilation of the Linux kernel.

By running “make menuconfig”, it is possible to create a custom setting for an unsupported board, which can be converted later to a new default setting for that board. There are already some boards defined, which can be used as an example on how to add a new board setup.

User’s Manual 11 Rev. 1, 2005-03-18

Page 12: LANPhone U-boot Kernel Rev1.0

Published by Infineon Technologies AG

w w w . i n f i n e o n . c o m