linux2.6.28 i2c 24CXX驱动device板级描述信息及设备信息

plat-s3c/dev-i2c0.c>
mach-s3c6410/mach-smdk6410.c>
//
mach-s3c6410/mach-smdk6410.c>
static void __init smdk6410_machine_init(void)
{
unsigned int tmp;
s3c_i2c0_set_platdata(NULL);
//s3c_i2c1_set_platdata(NULL);
i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0));
i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
spi_register_board_info(sam_spi_devs, ARRAY_SIZE(sam_spi_devs));
platform_add_devices(smdk6410_devices, ARRAY_SIZE(smdk6410_devices));

}

//

/**

  • i2c_register_board_info - statically declare I2C devices

  • @busnum: identifies the bus to which these devices belong

  • @info: vector of i2c device descriptors

  • @len: how many descriptors in the vector; may be zero to reserve

  • the specified bus number.

  • Systems using the Linux I2C driver stack can declare tables of board info

  • while they initialize. This should be done in board-specific init code

  • near arch_initcall() time, or equivalent, before any I2C adapter driver is

  • registered. For example, mainboard init code could define several devices,

  • as could the init code for each daughtercard in a board stack.

  • The I2C devices will be created later, after the adapter for the relevant

  • bus has been registered. After that moment, standard driver model tools

  • are used to bind “new style” I2C drivers to the devices. The bus number

  • for any device declared using this routine is not available for dynamic

  • allocation.

  • The board info passed can safely be __initdata, but be careful of embedded

  • pointers (for platform_data, functions, etc) since that won’t be copied.
    */
    int __init
    i2c_register_board_info(int busnum,
    struct i2c_board_info const *info, unsigned len)
    {
    int status;

    mutex_lock(&__i2c_board_lock);

    /* dynamic bus numbers will be assigned after the last static one */
    if (busnum >= __i2c_first_dynamic_bus_num)
    __i2c_first_dynamic_bus_num = busnum + 1;

    for (status = 0; len; len–, info++) {
    struct i2c_devinfo *devinfo;

     devinfo = kzalloc(sizeof(*devinfo), GFP_KERNEL);
     if (!devinfo) {
         pr_debug("i2c-core: can't register boardinfo!\n");
         status = -ENOMEM;
         break;
     }
    
     devinfo->busnum = busnum;
     devinfo->board_info = *info;
    

//将 struct i2c_devinfo *devinfo;通过list成员挂接到__i2c_board_list链表上
list_add_tail(&devinfo->list, &__i2c_board_list);
}

mutex_unlock(&__i2c_board_lock);

return status;

}

//

static struct platform_device *smdk6410_devices[] __initdata = {
&s3c_device_i2c0,
//&s3c_device_i2c1,
&s3c_device_spi0,
&s3c_device_spi1,
&s3c_device_keypad,
};

//
plat-s3c/dev-i2c0.c>

static struct resource s3c_i2c_resource[] = {
[0] = {
.start = S3C_PA_IIC,
.end = S3C_PA_IIC + SZ_4K - 1,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = IRQ_IIC,
.end = IRQ_IIC,
.flags = IORESOURCE_IRQ,
},
};

struct platform_device s3c_device_i2c0 = {
//匹配//static struct platform_driver s3c2410_i2c_driver
.name = “s3c2410-i2c”,
#ifdef CONFIG_S3C_DEV_I2C1
.id = 0,
#else
.id = -1,
#endif
.num_resources = ARRAY_SIZE(s3c_i2c_resource),
.resource = s3c_i2c_resource,
};

//

//
//struct i2c_client *i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const info)
// ------> strlcpy(client->name, info->type, sizeof(client->name));// i2c_board_info中的名字给了client
//static struct i2c_board_info i2c_devs0[]
"24c08"这个名字就是用来创建i2c_client来和里static struct i2c_driver at24_driver进行匹配的。
static struct i2c_board_info i2c_devs0[] __initdata = {
{ I2C_BOARD_INFO(“24c08”, 0x50), }, //0x50为IIC芯片从设备地址 7bit
/
{ I2C_BOARD_INFO(“WM8580”, 0x1b), }, */
};

static struct i2c_board_info i2c_devs1[] __initdata = {
{ I2C_BOARD_INFO(“24c128”, 0x57), }, /* Samsung S524AD0XD1 */
{ I2C_BOARD_INFO(“WM8580”, 0x1b), },
};

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

xx-xx-xxx-xxx

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值