寄存器 RK3288 dump
如何去实现RK3288系统所有寄存器dump的读写呢?
回帖(1)
2022-3-10 14:10:20
Platform: Rockchip
OS: Android 6.0
Kernel: 3.10.92
rk的pmu模块只提供了每次单个寄存器的读写,驱动提供了这个节点供使用:/sys/rk818/rk818_test
举例:
echo r 0x23 > /sys/rk818/rk818_test: 读取地址 0x23 的值,r 表示读;
echo w 0x23 0x7f > /sys/rk818/rk818_test: 对地址 0x23 赋值为 0x7f, w 表示写。
代码实现部分:
rk818.c
static struct rk818_attribute rk818_attrs[] = {
/* node_name permision show_func store_func */
__ATTR(rk818_test, S_IRUGO | S_IWUSR, rk818_test_show, rk818_test_store),
};
static ssize_t rk818_test_store(struct kobject *kobj, struct kobj_attribute *attr,
const char *buf, size_t n)
{
u32 getdata[8];
u8 regAddr;
u8 data;
char cmd;
const char *buftmp = buf;
struct rk818 *rk818 = g_rk818;
/**
* W Addr(8Bit) regAddr(8Bit) data0(8Bit) data1(8Bit) data2(8Bit) data3(8Bit)
* :data can be less than 4 byte
* R regAddr(8Bit)
* C gpio_name(poweron/powerhold/sleep/boot0/boot1) value(H/L)
*/
sscanf(buftmp, "%c ", &cmd);
printk("------zhangqing: get cmd = %cn", cmd);
switch (cmd) {
case 'w':
sscanf(buftmp, "%c %x %x ", &cmd, &getdata[0], &getdata[1]);
regAddr = (u8)(getdata[0] & 0xff);
data = (u8)(getdata[1] & 0xff);
printk("get value = %xn", data);
rk818_i2c_write(rk818, regAddr, 1, data);
rk818_i2c_read(rk818, regAddr, 1, &data);
printk("%x %xn", getdata[1], data);
break;
case 'r':
sscanf(buftmp, "%c %x ", &cmd, &getdata[0]);
printk("CMD : %c %xn", cmd, getdata[0]);
regAddr = (u8)(getdata[0] & 0xff);
rk818_i2c_read(rk818, regAddr, 1, &data);
printk("%x %xn", getdata[0], data);
break;
default:
printk("Unknown commandn");
break;
}
return n;
}
如果要实现所有寄存器dump,可以添加一个选项,其他pmu模块方法一样。
Platform: Rockchip
OS: Android 6.0
Kernel: 3.10.92
rk的pmu模块只提供了每次单个寄存器的读写,驱动提供了这个节点供使用:/sys/rk818/rk818_test
举例:
echo r 0x23 > /sys/rk818/rk818_test: 读取地址 0x23 的值,r 表示读;
echo w 0x23 0x7f > /sys/rk818/rk818_test: 对地址 0x23 赋值为 0x7f, w 表示写。
代码实现部分:
rk818.c
static struct rk818_attribute rk818_attrs[] = {
/* node_name permision show_func store_func */
__ATTR(rk818_test, S_IRUGO | S_IWUSR, rk818_test_show, rk818_test_store),
};
static ssize_t rk818_test_store(struct kobject *kobj, struct kobj_attribute *attr,
const char *buf, size_t n)
{
u32 getdata[8];
u8 regAddr;
u8 data;
char cmd;
const char *buftmp = buf;
struct rk818 *rk818 = g_rk818;
/**
* W Addr(8Bit) regAddr(8Bit) data0(8Bit) data1(8Bit) data2(8Bit) data3(8Bit)
* :data can be less than 4 byte
* R regAddr(8Bit)
* C gpio_name(poweron/powerhold/sleep/boot0/boot1) value(H/L)
*/
sscanf(buftmp, "%c ", &cmd);
printk("------zhangqing: get cmd = %cn", cmd);
switch (cmd) {
case 'w':
sscanf(buftmp, "%c %x %x ", &cmd, &getdata[0], &getdata[1]);
regAddr = (u8)(getdata[0] & 0xff);
data = (u8)(getdata[1] & 0xff);
printk("get value = %xn", data);
rk818_i2c_write(rk818, regAddr, 1, data);
rk818_i2c_read(rk818, regAddr, 1, &data);
printk("%x %xn", getdata[1], data);
break;
case 'r':
sscanf(buftmp, "%c %x ", &cmd, &getdata[0]);
printk("CMD : %c %xn", cmd, getdata[0]);
regAddr = (u8)(getdata[0] & 0xff);
rk818_i2c_read(rk818, regAddr, 1, &data);
printk("%x %xn", getdata[0], data);
break;
default:
printk("Unknown commandn");
break;
}
return n;
}
如果要实现所有寄存器dump,可以添加一个选项,其他pmu模块方法一样。
举报