Книга: Embedded Linux Primer: A Practical, Real-World Approach
10.3.5. Board-Specific Initialization
10.3.5. Board-Specific Initialization
Along with a mapping driver, your board-specific (platform) setup must provide the underlying definitions for proper MTD Flash system operation. Listing 10-12 reproduces the relevant portions of .../arch/arm/mach-ixp4xx/coyote-setup.c.
Listing 10-12. Coyote-Specific Board Setup
static struct flash_platform_data coyote_flash_data = {
.map_name = "cfi_probe",
.width = 2,
};
static struct resource coyote_flash_resource = {
.start = COYOTE_FLASH_BASE,
.end = COYOTE_FLASH_BASE + COYOTE_FLASH_SIZE - 1,
.flags = IORESOURCE_MEM,
};
static struct platform_device coyote_flash = {
.name = "IXP4XX-Flash",
.id = 0,
.dev = {
.platform_data = &coyote_flash_data,
},
.num_resources = 1,
.resource = &coyote_flash_resource,
};
...
static struct platform_device *coyote_devices[] __initdata = {
&coyote_flash,
&coyote_uart
};
static void __init coyote_init(void) {
...
platform_add_devices(coyote_devices, ARRAY_SIZE(coyote_devices));
}
...
In Listing 10-12, only the relevant portions of the coyote-setup.c platform initialization file are reproduced. Starting from the bottom, the coyote_init() function calls platform_add_devices(), specifying the Coyote-specific devices defined earlier in this file. You'll notice that two devices are defined just above the coyote_init() routine. The one we're interested in for this discussion is coyote_flash. This structure of type struct platform_device contains all the important details needed by the Linux kernel and MTD subsystem.
The .name member of the coyote_flash structure binds our platform-specific Flash resource to a mapping driver with the same name. You can see this in the mapping driver file .../drivers/mtd/maps/ixp4xx.c. The .resource member communicates the base address of the Flash on the board. The .dev member, which contains a .platform_data member, ties our Flash setup to a chip driver. In this case, we have specified that our board will use the CFI probe method, specified in the kernel configuration as CONFIG_MTD_CFI. You can see this configuration selection in Figure 10-4.
Depending on your own architecture and board, you can use a method similar to this to define the Flash support for your own board.
- 2.2.2. Starting the Target Board
- 5.4. Subsystem Initialization
- 7.4.3. EP405 Processor Initialization
- 7.4.4. Board-Specific Initialization
- Initialization and association
- 3.4.2 RTOS Initialization
- Understanding init Scripts and the Final Stage of Initialization
- Interpreting Shell Scripts Through Specific Shells
- Chapter 5. Kernel Initialization
- Chapter 6. System Initialization
- 5.2. Initialization Flow of Control
- 5.5.1. Initialization via initcalls