add powersave fixes based on patches by Steven Luo (#4376)
[openwrt.git] / package / broadcom-57xx / src / robo_register.c
1
2 #if 1
3 #define DEBUG_REG printk
4 #else
5 #define DEBUG_REG
6 #endif
7
8 void ReadDataFromRegister(robo_info_t *robo, uint16 page_num,uint16 addr_num, uint16 len, void* data)
9 {
10
11 uint32 val32 = 0,val64[2];
12 uint16 val16 =0,val48[3];//,val32[2],val64[4];
13 memset(val48,0,6);
14 memset(val64,0,8);
15 //memset(val32,0,4);
16 DEBUG_REG("Read ioctl Page[0x%02x] Addr[0x%02x] len[%d].\n", page_num, addr_num, len);
17 switch (len)
18 {
19 case 1:
20 case 2:
21 {
22 robo->ops->read_reg(robo, page_num, addr_num, &val16, len);
23 DEBUG_REG("IRead 8/16 bit Page[0x%02x]addr[0x%02x]len[%d]val[0x%04x].\n",
24 page_num, addr_num, len, val16);
25 memcpy(data,&val16,2);
26 break;
27 }
28 case 4:
29 {
30 robo->ops->read_reg(robo, page_num, addr_num, &val32, len);
31 DEBUG_REG("IRead 32bit Page[0x%02x]addr[0x%02x]len[%d]val[0x%08x].\n",
32 page_num, addr_num, len, val32);
33 memcpy(data,&val32,4);
34 break;
35 }
36 case 6:
37 {
38 robo->ops->read_reg(robo, page_num,addr_num, &val48, len);
39 DEBUG_REG("IRead 48bit Page[0x%02x]addr[0x%02x]len[%d]val[0x%04x-0x%04x-0x%04x].\n",
40 page_num, addr_num, len, val48[0], val48[1], val48[2]);
41 memcpy(data,&val48,6);
42 break;
43 }
44 case 8:
45 {
46 robo->ops->read_reg(robo, page_num, addr_num, &val64, len);
47 DEBUG_REG("IRead 64bit Page[0x%02x]addr[0x%02x]len[%d]val[0x%08x-0x%08x].\n",
48 page_num, addr_num, len, val64[0], val64[1]);
49 memcpy(data,&val64,8);
50 break;
51 }
52 }
53 }
54
55
56
57 void WriteDataToRegister(robo_info_t *robo,uint16 page_num,uint16 addr_num, uint16 len, void* data)
58 {
59 DEBUG_REG("Write ioctl Page[0x%02x]Addr[0x%02x]len[%d].\n",page_num,addr_num,len);
60 switch (len)
61 {
62 case 1:
63 case 2:
64 {
65 DEBUG_REG("Write 2byte Page[0x%02x]addr[0x%02x]len[%d]val[0x%04x].\n",
66 page_num, addr_num, len, *((uint16 *)data));
67 robo->ops->write_reg(robo, page_num, addr_num, data, len);
68 if (page_num < 0x10 || page_num > 0x17) {
69 robo->ops->read_reg(robo, page_num, addr_num, data, len);
70 DEBUG_REG("Reload Page[0x%02x]addr[0x%02x]len[%d]val[0x%04x].\n",
71 page_num, addr_num, len, *((uint16 *)data));
72 }
73 break;
74 }
75 case 4:
76 {
77 DEBUG_REG("Write 4byte Page[0x%02x]addr[0x%02x]len[%d]val[0x%08x].\n",
78 page_num, addr_num, len, *((uint32 *)data));
79 robo->ops->write_reg(robo, page_num, addr_num, data, len);
80 if (page_num < 0x10 || page_num > 0x17) {
81 robo->ops->read_reg(robo, page_num, addr_num, data, len);
82 DEBUG_REG("Reload Page[0x%02x]addr[0x%02x]len[%d]val[0x%08x].\n",
83 page_num, addr_num, len, *((uint32 *)data));
84 }
85 break;
86 }
87 case 6:
88 {
89 DEBUG_REG("Write 6byte Page[0x%02x]addr[0x%02x]len[%d]val[0x%04x-0x%04x-0x%04x].\n",
90 page_num, addr_num, len, *((uint16 *)data),*((((uint16 *)data)+1)),
91 *(((uint16 *)data)+2));
92 robo->ops->write_reg(robo, page_num, addr_num, data, len);
93 robo->ops->read_reg(robo, page_num, addr_num, data, len);
94 DEBUG_REG("Reload Page[0x%02x]addr[0x%02x]len[%d]val[0x%04x-0x%04x-0x%04x].\n",
95 page_num, addr_num, len,*((uint16 *)data),*((((uint16 *)data)+1)),
96 *(((uint16 *)data)+2));
97 break;
98 }
99 case 8:
100 {
101 DEBUG_REG("Write 8byte Page[0x%02x]addr[0x%02x]len[%d]val[0x%08x-0x%08x].\n",
102 page_num, addr_num, len, *((uint32*)data),*(((uint32 *)data)+1));
103 robo->ops->write_reg(robo, page_num, addr_num, data, len);
104 robo->ops->read_reg(robo, page_num, addr_num, data, len);
105 DEBUG_REG("Reload Page[0x%x]addr[0x%x]len[%d]val[0x%08x-0x%08x].\n",
106 page_num, addr_num, len,*((uint32 *)data), *(((uint32 *)data)+1));
107 break;
108 }
109 }
110 }
111
This page took 0.056582 seconds and 5 git commands to generate.