This article was reproduced from: http://blog.csdn.net/kris_fei/article/details/76919134
Platform:rockchip
Os:android 6.0
kernel:3.10.92
RK's PMU module only provides read and write for each individual register, and the driver provides this node for use:/sys/rk818/rk818_test
Example:
echo r 0x23 > /sys/rk818/rk818_test: 读取地址 0x23 的值,r 表示读;
echo w 0x23 0x7f > /sys/rk818/rk818_test: 对地址 0x23 赋值为 0x7f, w 表示写。
Code Implementation section:
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,ConstChar *buf, size_t N) {u32 getdata[8]; U8 regaddr; U8 data;char cmd;Constchar *buftmp = BUF; struct rk818 *rk818 = g_rk818;/** * W Addr (8Bit) regaddr (8Bit) data0 (8Bit) data1 (8Bit) data2 (8Bit) data3 (8Bit) *:d ATA can is less than 4 byte * R Regad DR (8Bit) * C gpio_name (POWERON/POWERHOLD/SLEEP/BOOT0/BOOT1) value (h/l) */sscanf (buftmp,"%c", &cmd); Printk"------zhangqing:get cmd =%c\n", 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 =%x\n", data); Rk818_i2c_write (rk818, REGADDR,1, data); Rk818_i2c_read (rk818, REGADDR,1, &data); Printk "%x%x\n", Getdata[1], data); break; case ' R ': sscanf (buftmp, 0]); PRINTK ( "cmd:%c%x\n", cmd, Getdata[0]); regaddr = (U8) (getdata[< Span class= "Hljs-number" >0] & 0xff); Rk818_i2c_read (rk818, regaddr, 1, &data), PRINTK ( "%x%x\n", Getdata[0], data); break; DEFAULT:PRINTK ( "Unknown command\n"); break;} return N;}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21st
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
If you want to implement all register dumps, you can add an option, like other PMU module methods.
[RK3288] [Android6.0] Debug Notes---PMU (rk818) register read and write "Turn"