-
static struct cpu_table cpu_ids[] __initdata = {
-
{
-
.idcode = 0x32410000,
-
.idmask = 0xffffffff,
-
.map_io = s3c2410_map_io,
-
.init_clocks = s3c2410_init_clocks,
-
.init_uarts = s3c2410_init_uarts,
-
.init = s3c2410_init,
-
.name = name_s3c2410
-
},
-
...
-
}
-
-
-
void __init s3c2410_init_uarts(struct s3c2410_uartcfg *cfg, int no)
-
{
-
s3c24xx_init_uartdevs("s3c2410-uart", s3c2410_uart_resources, cfg, no);
-
}
-
struct s3c24xx_uart_resources s3c2410_uart_resources[] __initdata = {
[0] = {
.resources = s3c2410_uart0_resource,
.nr_resources = ARRAY_SIZE(s3c2410_uart0_resource),
},
[1] = {
.resources = s3c2410_uart1_resource,
.nr_resources = ARRAY_SIZE(s3c2410_uart1_resource),
},
[2] = {
.resources = s3c2410_uart2_resource,
.nr_resources = ARRAY_SIZE(s3c2410_uart2_resource),
},
[3] = {
.resources = s3c2410_uart3_resource,
.nr_resources = ARRAY_SIZE(s3c2410_uart3_resource),
},
};
static struct resource
s3c2410_uart0_resource[] = {
[0] = {
.start = S3C2410_PA_UART0,
.end = S3C2410_PA_UART0 + 0x3fff,
.flags = IORESOURCE_MEM,//内存资源
},
[1] = {
.start = IRQ_S3CUART_RX0,
.end = IRQ_S3CUART_ERR0,
.flags = IORESOURCE_IRQ,//中断资源
}
};
cfg的传入值
static struct s3c2410_uartcfg mini2440_uartcfgs[] __initdata = {
[0] = {
.hwport = 0,
.flags = 0,
.ucon = UCON,
.ulcon = ULCON,
.ufcon = UFCON,
},
[1] = {
.hwport = 1,
.flags = 0,
.ucon = UCON,
.ulcon = ULCON,
.ufcon = UFCON,
},
[2] = {
.hwport = 2,
.flags = 0,
.ucon = UCON,
.ulcon = ULCON,
.ufcon = UFCON,
},
};
no 的传入值 = 3
struct platform_device *s3c24xx_uart_src[4] = {
&s3c24xx_uart_device0,
&s3c24xx_uart_device1,
&s3c24xx_uart_device2,
&s3c24xx_uart_device3,
};
static struct platform_device s3c24xx_uart_device0 = {
.id = 0,
};
static struct platform_device s3c24xx_uart_device1 = {
.id = 1,
};
static struct platform_device s3c24xx_uart_device2 = {
.id = 2,
};
static struct platform_device s3c24xx_uart_device3 = {
.id = 3,
};
-
void __init s3c24xx_init_uartdevs(char *name,
-
struct s3c24xx_uart_resources *res,
-
struct s3c2410_uartcfg *cfg, int no)
-
{
-
struct platform_device *platdev;
-
struct s3c2410_uartcfg *cfgptr = uart_cfgs;
-
struct s3c24xx_uart_resources *resp;
-
int uart;
-
//把配置信息保存起来,包括对寄存器的设置值
-
memcpy(cfgptr, cfg, sizeof(struct s3c2410_uartcfg) * no);
//给平台设备s3c24xx_uart_device0,s3c24xx_uart_device1,s3c24xx_uart_device2赋值
-
for (uart = 0; uart < no; uart++, cfg++, cfgptr++) {
-
platdev = s3c24xx_uart_src[cfgptr->hwport];
-
-
resp = res + cfgptr->hwport;
/*
struct platform_device *s3c24xx_uart_devs[4] = {
};
*/
s3c24xx_uart_devs[uart] = platdev;
//给平台总线设备结构体赋值
-
platdev->name = name;//设备名
-
platdev->resource = resp->resources;//设备资源
-
platdev->num_resources = resp->nr_resources;//设备所使用各类资源数量
-
-
platdev->dev.platform_data = cfgptr;
-
}
-
-
nr_uarts = no;
-
}