|
|
 |
Kernel Porting Guide
Board setup
|
|
Board setup
The next step is to create the board specific parts of the port. This is described in the following procedure.
-
Create the directory arch/st200/boards/acme/coyote with the command:
host% mkdir -p arch/st200/boards/acme/coyote |
|
|
-
Create the file arch/st200/boards/acme/coyote/Makefile, which simply contains:
-
The top level makefile must be modified to pass information about the new directories. In arch/st200/Makefile add the following lines, which direct the make system to use the 5301 SoC directory, and declare acme/coyote as the board directory:
boarddir-$(CONFIG_ST200_ACME_COYOTE) := acme/coyote socdir-$(CONFIG_ST200_ACME_COYOTE) := 5301 |
|
|
-
Create a minimal board support package with just enough code to control the serial port. This should be placed in arch/st200/boards/acme/coyote/setup.c. For example:
#include <linux/device.h> #include <linux/stpio.h> #include <linux/st_soc.h> #include <asm/io.h> #include <asm/irq_ilc.h> #include <asm/5301_sysconfig.h> extern int early_asc_setup(struct device *dev); static int __init configure_pios(void) { struct stpio_pin *p; /* Do the serial ports */ stpio_request_pin(2, 1,"ASC0", STPIO_ALT_OUT); /* Tx */ stpio_request_pin(2, 2,"ASC0", STPIO_IN); /* Rx */ stpio_request_pin(2, 3,"ASC0", STPIO_IN); /* CTS */ stpio_request_pin(2, 0,"ASC0", STPIO_ALT_OUT); /* RTS */ return 0; } int __init board_setup(void) { configure_pios(); soc_data.uarts[2].id=0; // This is ttyAS0 #ifdef CONFIG_SERIAL_ST_ASC_CONSOLE early_asc_setup(&(soc_data.uarts[2].dev)); #endif return 0; } static int __init register_board_devices(void) { int ret; ret=platform_add_devices(soc_data.devices,soc_data.num_devices); ret|=platform_device_register(soc_data.uarts+2); return ret; } arch_initcall(register_board_devices); |
|
|
-
The code in board_setup() first sets all the necessary PIOs to their alternate functions (to run the UART). It then sets the line number of UART2 to be zero, which means that UART2 in hardware will be recognized as /dev/ttyAS0, and then initializes the UART.
-
In register_board_devices() all the devices presented by the soc layer are registered. This also registers the UART driver as a standard serial port. As the line id has already been changed in board_setup() it is not necessary to do it again here.
-
At this stage it should be possible to compile the kernel as normal to produce a runnable kernel with the command:
host% make ARCH=st200 CROSS_COMPILE=st231-linux- |
|
|
When porting to a new board, it is recommended that you stop at this stage and verify that the kernel runs. It is strongly recommended that you have serial output before proceeding further.
|