Chinaunix首页 | 论坛 | 博客
  • 博客访问: 121647
  • 博文数量: 31
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 296
  • 用 户 组: 普通用户
  • 注册时间: 2015-01-10 21:57
文章分类

全部博文(31)

文章存档

2016年(4)

2015年(27)

我的朋友

分类: LINUX

2015-03-19 22:20:16


随后调用s3c24xx_init_uarts()->s3c2410_init_uarts()->s3c24xx_init_uartdevs()


点击(此处)折叠或打开

  1. MACHINE_START(MINI2440, "MINI2440")
  2.     /* Maintainer: Michel Pollet <buserror@gmail.com> */
  3.     .boot_params    = S3C2410_SDRAM_PA + 0x100,
  4.     .map_io        = mini2440_map_io,
  5.     .init_machine    = mini2440_init,
  6.     .init_irq    = s3c24xx_init_irq,
  7.     .timer        = &s3c24xx_timer,
  8. MACHINE_END

  9. static void __init mini2440_map_io(void)
  10. {
  11.     s3c24xx_init_io(mini2440_iodesc, ARRAY_SIZE(mini2440_iodesc));
  12.     s3c24xx_init_clocks(12000000);
  13.     s3c24xx_init_uarts(mini2440_uartcfgs, ARRAY_SIZE(mini2440_uartcfgs));
  14. }


  15. void __init s3c24xx_init_uarts(struct s3c2410_uartcfg *cfg, int no)
  16. {
  17.     if (cpu == NULL)
  18.         return;

  19.     if (cpu->init_uarts == NULL) {
  20.         printk(KERN_ERR "s3c24xx_init_uarts: cpu has no uart init\n");
  21.     } else
  22.         (cpu->init_uarts)(cfg, no);
  23. }
根据cpu id找到对应的cpu_table结构,确定调用

点击(此处)折叠或打开

  1. static struct cpu_table cpu_ids[] __initdata = {
  2.     {
  3.         .idcode        = 0x32410000,
  4.         .idmask        = 0xffffffff,
  5.         .map_io        = s3c2410_map_io,
  6.         .init_clocks    = s3c2410_init_clocks,
  7.         .init_uarts    = s3c2410_init_uarts,
  8.         .init        = s3c2410_init,
  9.         .name        = name_s3c2410
  10.     },
  11. ...
  12. }


  13. void __init s3c2410_init_uarts(struct s3c2410_uartcfg *cfg, int no)
  14. {
  15.     s3c24xx_init_uartdevs("s3c2410-uart", s3c2410_uart_resources, cfg, no);
  16. }

  1. 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,
};


  1. void __init s3c24xx_init_uartdevs(char *name,
  2.                  struct s3c24xx_uart_resources *res,
  3.                  struct s3c2410_uartcfg *cfg, int no)
  4. {
  5.     struct platform_device *platdev;
  6.     struct s3c2410_uartcfg *cfgptr = uart_cfgs;
  7.     struct s3c24xx_uart_resources *resp;
  8.     int uart;

           //把配置信息保存起来,包括对寄存器的设置值
  1.     memcpy(cfgptr, cfg, sizeof(struct s3c2410_uartcfg) * no);

            //给平台设备s3c24xx_uart_device0,s3c24xx_uart_device1,s3c24xx_uart_device2赋值
  1.     for (uart = 0; uart < no; uart++, cfg++, cfgptr++) {
  2.         platdev = s3c24xx_uart_src[cfgptr->hwport];

  3.         resp = res + cfgptr->hwport;

                /*
                    struct platform_device *s3c24xx_uart_devs[4] = {
                     };
                */
     
        s3c24xx_uart_devs[uart] = platdev;

              //给平台总线设备结构体赋值
  1.         platdev->name = name;//设备名
  2.         platdev->resource = resp->resources;//设备资源
  3.         platdev->num_resources = resp->nr_resources;//设备所使用各类资源数量

  4.         platdev->dev.platform_data = cfgptr;
  5.     }

  6.     nr_uarts = no;
  7. }




阅读(1770) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~