Chinaunix首页 | 论坛 | 博客
  • 博客访问: 50820
  • 博文数量: 19
  • 博客积分: 30
  • 博客等级: 民兵
  • 技术积分: 105
  • 用 户 组: 普通用户
  • 注册时间: 2010-08-27 15:16
个人简介

长期潜藏于CSDN http://blog.csdn.net/npjocj

文章分类
文章存档

2013年(1)

2012年(18)

我的朋友

分类:

2012-11-21 14:53:51

上一篇文章已经把I2C控制器所用的platform devices准备好啦,现在开始注册,该文件在板级支持文件中,board-xxx.c文件中。
static struct platform_device *surf_devices[] __initdata = {
.........
#ifdef CONFIG_I2C_QUP
 &msm_gsbi3_qup_i2c_device,
 &msm_gsbi4_qup_i2c_device,
 &msm_gsbi7_qup_i2c_device,
 &msm_gsbi8_qup_i2c_device,
 &msm_gsbi9_qup_i2c_device,
 &msm_gsbi12_qup_i2c_device,
#endif
........
};
 
继续对该I2C平台设备结构体初始化
static void __init msm8x60_init_buses(void)
{
 ............
 #ifdef CONFIG_I2C_QUP
 msm_gsbi3_qup_i2c_device.dev.platform_data = &msm_gsbi3_qup_i2c_pdata;
 msm_gsbi4_qup_i2c_device.dev.platform_data = &msm_gsbi4_qup_i2c_pdata;
 msm_gsbi7_qup_i2c_device.dev.platform_data = &msm_gsbi7_qup_i2c_pdata;
 msm_gsbi8_qup_i2c_device.dev.platform_data = &msm_gsbi8_qup_i2c_pdata;
 msm_gsbi9_qup_i2c_device.dev.platform_data = &msm_gsbi9_qup_i2c_pdata;
 msm_gsbi12_qup_i2c_device.dev.platform_data = &msm_gsbi12_qup_i2c_pdata;
 #endif
............
}
其中初始化的platform_data如下
static struct msm_i2c_platform_data msm_gsbi3_qup_i2c_pdata = {
 .clk_freq = 100000,
 .src_clk_rate = 24000000,
 .clk = "gsbi_qup_clk",
 .pclk = "gsbi_pclk",
 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
};
static struct msm_i2c_platform_data msm_gsbi4_qup_i2c_pdata = {
 .clk_freq = 100000,
 .src_clk_rate = 24000000,
 .clk = "gsbi_qup_clk",
 .pclk = "gsbi_pclk",
 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
};
static struct msm_i2c_platform_data msm_gsbi7_qup_i2c_pdata = {
 .clk_freq = 100000,
 .src_clk_rate = 24000000,
 .clk = "gsbi_qup_clk",
 .pclk = "gsbi_pclk",
 .pri_clk = 60,
 .pri_dat = 59,
 .msm_i2c_config_gpio = gsbi7_qup_i2c_gpio_config,
};
static struct msm_i2c_platform_data msm_gsbi8_qup_i2c_pdata = {
 .clk_freq = 100000,
 .src_clk_rate = 24000000,
 .clk = "gsbi_qup_clk",
 .pclk = "gsbi_pclk",
 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
};
static struct msm_i2c_platform_data msm_gsbi9_qup_i2c_pdata = {
 .clk_freq = 100000,
 .src_clk_rate = 24000000,
 .clk = "gsbi_qup_clk",
 .pclk = "gsbi_pclk",
 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
};
static struct msm_i2c_platform_data msm_gsbi12_qup_i2c_pdata = {
 .clk_freq = 100000,
 .src_clk_rate = 24000000,
 .clk = "gsbi_qup_clk",
 .pclk = "gsbi_pclk",
 .use_gsbi_shared_mode = 1,
 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
};
其中的msm_i2c_config_gpio赋值的值的定义如下
static void gsbi7_qup_i2c_gpio_config(int adap_id, int config_type)
{
 if (config_type == 0) {
  gpio_tlmm_config(gsbi7_gpio_table[0], GPIO_CFG_ENABLE);
  gpio_tlmm_config(gsbi7_gpio_table[1], GPIO_CFG_ENABLE);
 } else {
  gpio_tlmm_config(gsbi7_i2c_table[0], GPIO_CFG_ENABLE);
  gpio_tlmm_config(gsbi7_i2c_table[1], GPIO_CFG_ENABLE);
 }
}
下面的函数会注册该平台设备
static void __init msm8x60_init(struct msm_board_data *board_data)
{
  ..........
  msm8x60_init_buses();
  ..........
  platform_add_devices(surf_devices,ARRAY_SIZE(surf_devices));
  ..........
}
 
下面的函数会调用上面的初始化
static void __init msm8x60_xxx_init(void)
{
  msm8x60_init(&msm8x60_xxx_board_data);
}
上面的函数会挂载到板级的结构中。
MACHINE_START(MSM8X60_xxx, "QCT MSM8X60 xxx")
 .map_io = msm8x60_map_io,
 .init_irq = msm8x60_init_irq,
 .init_machine = msm8x60_xxx_init, //挂载的板级初始化函数
 .timer = &msm_timer,
MACHINE_END
以上就是对I2C控制器的注册。

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