首页 > 代码库 > I2C实时时钟rx-8025板卡实际应用
I2C实时时钟rx-8025板卡实际应用
rx-8025是片外I2C实时时钟,其应用于9260板卡方法如下。总体思想是配置内核添加驱动(I2C驱动,内核已提供的很完备),板级文件添加设备,添加设备文件以应用程序操作。
1. 配置内核
1)I2C支持(可选择debug信息)。
2)I2Chw选择gpio作为I2C硬件。
3)不选择片上RTT,选择芯片RX-8025。
其中rtc0为设备启动时钟。
2. 添加设备
/arch/arm/mach-at91/board-sam9260ek.c中添加以下语句:
static struct i2c_board_info __initdata ek_i2c_devices[] = {
{
I2C_BOARD_INFO("24c512", 0x50),
.platform_data = http://www.mamicode.com/&at24c512,
},
/* more devices can be added using expansion connectors */
/* Added for R8025 rtc 20120914 */
{
I2C_BOARD_INFO("rx8025", 0x32),
}
};
----------------------------------------------------------------------------------------------------------
/**
* I2C_BOARD_INFO - macro used to list an i2c device and its address
* @dev_type: identifies the device type
* @dev_addr: the device‘s address on the bus.
*
* This macro initializes essential fields of a struct i2c_board_info,
* declaring what has been provided on a particular board. Optional
* fields (such as associated irq, or device-specific platform_data)
* are provided using conventional syntax.
*/
#define I2C_BOARD_INFO(dev_type, dev_addr) \
.type = dev_type, .addr = (dev_addr)
/driver/rtc/rtc-s1370.c
static const struct i2c_device_id ds1307_id[] = {
{ "ds1307", ds_1307 },
{ "ds1337", ds_1337 },
{ "ds1338", ds_1338 },
{ "ds1339", ds_1339 },
{ "ds1340", ds_1340 },
{ "m41t00", m41t00 },
{ "rx8025", rx_8025 },
{ }
};
注:I2C_BOARD_INFO()中,第一项为type,第二项为addr,
dev_type必须与驱动中i2c_device_id数组中name匹配,其也是I2C设备与驱动匹配的基础。
3. 创建设备文件
在根文件系统中,创建设备文件
mknod /dev/rtc0 c 10 135
注:rtc0与内核配置启动时钟吻合。
4. 编译内核,查看启动信息。
I2C实时时钟rx-8025板卡实际应用