First, the system is initialized, the registration of the platform bus:
struct device platform_bus = {.bus_id = "platform",};
struct bus_type platform_bus_type = {.name = "platform",.match = platform_match,.suspend = platform_suspend,.resume = platform_resume,};
int __init platform_bus_init(void){device_register(&platform_bus);return bus_register( & platform_bus_type);}
registered
device
static struct platform_device * smdk2410_devices [] __initdata = {& s3c_device_usb, & s3c_device_lcd, & s3c_device_wdt, & s3c_device_i2c, & s3c_device_iis ,};//The structure of these devices is defined in devs.c, as an example: /* NAND Controller */
static struct resource s3c_nand_resource[] = {[0] = {.start = S3C2410_PA_NAND,.end = S3C2410_PA_NAND + S3C24XX_SZ_NAND,.flags = IORESOURCE_MEM,}};
struct platform_device s3c_device_nand = {.name = "s3c2410-nand",.id = -1,.num_resources = ARRAY_SIZE(s3c_nand_res ource) ,. resource = s3c_nand_resource,};
So we can add the device we want by the above method
=============. ======================================= The above list of devices is added to the board-level system static struct s3c24xx_board smdk2410_board __initdata = {.devices = smdk2410_devices, .devices_count = ARRAY_SIZE (smdk2410_devices)};
static void __init smdk2410_map_io (void) {s3c24xx_init_io (smdk2410_iodesc, ARRAY_SIZE (smdk2410_iodesc)); s3c24xx_init_clocks (0); s3c24xx_init_uarts ( smdk2410_uartcfgs, ARRAY_SIZE (smdk2410_uartcfgs)); s3c24xx_set_board (& smdk2410_board); //Note that this step}
static void __init smdk2410_init_irq (void) {s3c24xx_init_irq ();}
==== ======================================== This is a macro to create a structure MACHINE_START (SMDK2410, "SMDK2410") /* @TODO: request a new identifier and switch* to SMDK2410 *//* Maintainer: Jonas Dietsche */.phys_ram = S3C2410_SDRAM_PA,.phys_io = S3C2410_PA_UART,.io_pg_offst = (((u32) S3C24X X_VA_UART) >> 18) & 0xfffc,.boot_params = S3C2410_SDRAM_PA + 0x100,.map_io = smdk2410_map_io,.init_irq = smdk2410_init_irq,.timer = &s3c24xx_timer,MACHINE_END
//The macro is defined as follows: /** Set of macros to define architecture features. This is built into* a table by the linker.*/#define MACHINE_START(_type,_name) \\const struct machine_desc __mach_desc_##_type \\__attribute__((__section__(".arch .info.init"))) = { \\.nr = MACH_TYPE_##_type, \\.name = _name,
#define MACHINE_END \\};
There is a _ named _ _mach_desc_SMDK2410_type, type of structure struct machine_desc
===================== look s3c24xx_set_board. (& smdk2410_board) (in cpu. c)
/* board information */
static struct s3c24xx_board *board;
void s3c24xx_set_board(struct s3c24xx_board *b){int i;
Board = b; //Set this global variable
if (b->clocks_count != 0) {struct clk **ptr = b->clocks;;
for (i = b- & gt; clocks_count; i & gt; 0; i--, ptr ++) s 3c24xx_register_clock(*ptr);}}
The following initialization function will use this variable static int __init s3c_arch_init(void){int ret;
//do the correct init for Cpu
if (cpu == NULL)panic("s3c_arch_init: NULL cpu\ ");
ret = (cpu->init)();if (ret != 0)return ret;
if (board != NULL) {struct platform_device **ptr = board->devices;int i;
//traverse every device in the platform for (i = 0; i < board->devices_count; i++, ptr++) {//Register into the platform bus, so you can find these platform devices when loading the driver. ret = platform_device_register(*ptr );if (ret) {printk(KERN_ERR "s3c24xx: failed to add board device %s (%d)
@%p\ ", (*ptr)->name, ret, * Ptr);}}
/* mask any error, we may not need all these board* devices */ret = 0;}
return ret;}
arch_initcall (s3c_arch_init);
=========================================== =
/*** platform_device_register - add a platform-level device* @pdev: platform device we're adding**/int platform_device_register(struct platform_device * pdev){int i, ret = 0;
if (!pdev)return -EINVAL;
//Associate parent device if (!pdev->dev.parent)pdev->dev.parent = &platform_bus;
pdev->dev.bus = &platform_bus_type;
//id == -1 processing, just the name of the different if (pdev->id != -1)snprintf(pdev->dev.bus_id, BUS_ID_SIZE, "%s.%u", pdev- >name, pdev->id);zh-CN"],null,[0.94743574],zh-CN"]]]
I will talk about how to use the command in Linux to test the read and write input of the hard disk
The Linux operating system has been around for 20 years without knowing it. Just 20 years ago, just
The Linux command line is useful, efficient, and fun, but sometimes dangerous, especially if you are
Now let us use the two digital tubes on the experiment board to do a cycle to display the 00~99 numb
Find the file content find+grep
Explain how to add soft routes in Linux
Linux Network Operation Command Encyclopedia
Linux kernel source code structure overview
Teach you how to install application software in Linux
USB to serial port under virtual machine
Introduction to three commonly used network security tools under Linux system
Repairing System Faults in Windows 7 System Security Mode
How to use the recovery code to retrieve the account under the Win10 system
Solution: The best way to customize the document library is
Win8.1 system delete avatar and avatar thumbnail record skills
Qq computer housekeeper free upgrade win10 common problem summary
Win8 system upgrade Firefox browser can not open IE browser how to do
How to configure the basic configuration of Windows XP English?
Windows 7 Tips: Speed up system boot and shutdown speed
How to solve my computer does not display scanners and cameras?