一
首先在板级目录下 arch/mips/platform 定义设备信息
static struct resource ls2h_i2c0_resources[] = {
[0] = {
.start = LS2H_I2C0_REG_BASE,
.end = LS2H_I2C0_REG_BASE + 0x8,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = LS2H_I2C0_IRQ,
.end = LS2H_I2C0_IRQ,
.flags = IORESOURCE_IRQ,
},
};
static struct platform_device ls2h_i2c0_device = {
.name = "ls2h-i2c",
.id = 0,
.num_resources = ARRAY_SIZE(ls2h_i2c0_resources),
.resource = ls2h_i2c0_resources,
};
而且这里还定义了一个设备结构体
static struct platform_device *ls2h_platform_devices[] = {
&uart8250_device,
&ls2h_i2c0_device,
&ls2h_i2c1_device,
&ls2h_nand_device,
&ls2h_ohci_device,
&ls2h_ehci_device,
&ls2h_gmac0_device,
&ls2h_gmac1_device,
&ls2h_ahci_device,
&ls2h_dc_device,
&ls2h_audio_device,
#if !defined(CONFIG_CPU_LOONGSON3) || !defined(CONFIG_SUSPEND)
&ls2h_otg_device,
#endif
&ls2h_rtc_device,
&ls2h_gpu_device,
};
结构体中的设备都会通过函数ls2h_platform_init(也在这个文件中)被注册到系统中。
大概看一下这个函数做