3 # Run this program on the integrator
4 # - Tests select sysfs attributes.
5 # - Todo ... test more attributes, hnp/srp, buspower/bussuspend, etc.
6 # -----------------------------------------------------------------------------
15 my ($attr,$expected) = @_;
16 my $string = get($attr);
18 if ($string eq $expected) {
19 printf("$attr = $string, okay\n");
22 warn "ERROR: value of $attr != $expected, $string\n";
30 my ($reg, $value) = @_;
31 system "echo $value > $sysfsdir/$reg";
38 my $string = `cat $sysfsdir/$attr`;
40 if ($string =~ m/\s\=\s/) {
42 ($tmp, $string) = split /\s=\s/, $string;
50 print("\nTesting Sysfs Attributes\n");
52 load_module("") or die;
54 # Test initial values of regoffset/regvalue/guid/gsnpsid
55 print("\nTesting Default Values\n");
57 test("regoffset", "0xffffffff");
58 test("regvalue", "invalid offset");
59 test("guid", "0x12345678"); # this will fail if it has been changed
60 test("gsnpsid", "0x4f54200a");
62 # Test operation of regoffset/regvalue
63 print("\nTesting regoffset\n");
64 set('regoffset', '5a5a5a5a');
65 test("regoffset", "0xffffffff");
67 set('regoffset', '0');
68 test("regoffset", "0x00000000");
70 set('regoffset', '40000');
71 test("regoffset", "0x00000000");
73 set('regoffset', '3ffff');
74 test("regoffset", "0x0003ffff");
76 set('regoffset', '1');
77 test("regoffset", "0x00000001");
79 print("\nTesting regvalue\n");
80 set('regoffset', '3c');
81 test("regvalue", "0x12345678");
82 set('regvalue', '5a5a5a5a');
83 test("regvalue", "0x5a5a5a5a");
84 set('regvalue','a5a5a5a5');
85 test("regvalue", "0xa5a5a5a5");
86 set('guid','12345678');
89 print("\nTesting HNP Capable bit\n");
90 set('hnpcapable', '1');
91 test("hnpcapable", "0x1");
92 set('hnpcapable','0');
93 test("hnpcapable", "0x0");
95 set('regoffset','0c');
97 my $old = get('gusbcfg');
98 print("setting hnpcapable\n");
99 set('hnpcapable', '1');
100 test("hnpcapable", "0x1");
101 test('gusbcfg', sprintf "0x%08x", (oct ($old) | (1<<9)));
102 test('regvalue', sprintf "0x%08x", (oct ($old) | (1<<9)));
104 $old = get('gusbcfg');
105 print("clearing hnpcapable\n");
106 set('hnpcapable', '0');
107 test("hnpcapable", "0x0");
108 test ('gusbcfg', sprintf "0x%08x", oct ($old) & (~(1<<9)));
109 test ('regvalue', sprintf "0x%08x", oct ($old) & (~(1<<9)));
112 print("\nTesting SRP Capable bit\n");
113 set('srpcapable', '1');
114 test("srpcapable", "0x1");
115 set('srpcapable','0');
116 test("srpcapable", "0x0");
118 set('regoffset','0c');
120 $old = get('gusbcfg');
121 print("setting srpcapable\n");
122 set('srpcapable', '1');
123 test("srpcapable", "0x1");
124 test('gusbcfg', sprintf "0x%08x", (oct ($old) | (1<<8)));
125 test('regvalue', sprintf "0x%08x", (oct ($old) | (1<<8)));
127 $old = get('gusbcfg');
128 print("clearing srpcapable\n");
129 set('srpcapable', '0');
130 test("srpcapable", "0x0");
131 test('gusbcfg', sprintf "0x%08x", oct ($old) & (~(1<<8)));
132 test('regvalue', sprintf "0x%08x", oct ($old) & (~(1<<8)));
135 print("\nTesting GGPIO\n");
136 set('ggpio','5a5a5a5a');
137 test('ggpio','0x5a5a0000');
138 set('ggpio','a5a5a5a5');
139 test('ggpio','0xa5a50000');
140 set('ggpio','11110000');
141 test('ggpio','0x11110000');
142 set('ggpio','00001111');
143 test('ggpio','0x00000000');
146 print("\nTesting DEVSPEED\n");
147 set('regoffset','800');
148 $old = get('regvalue');
150 test('devspeed','0x0');
151 test('regvalue',sprintf("0x%08x", oct($old) & ~(0x3)));
153 test('devspeed','0x1');
154 test('regvalue',sprintf("0x%08x", oct($old) & ~(0x3) | 1));
156 test('devspeed','0x2');
157 test('regvalue',sprintf("0x%08x", oct($old) & ~(0x3) | 2));
159 test('devspeed','0x3');
160 test('regvalue',sprintf("0x%08x", oct($old) & ~(0x3) | 3));
162 test('devspeed','0x0');
163 test('regvalue',sprintf("0x%08x", oct($old) & ~(0x3)));
165 test('devspeed','0x1');
166 test('regvalue',sprintf("0x%08x", oct($old) & ~(0x3) | 1));
169 # mode Returns the current mode:0 for device mode1 for host mode Read
170 # hnp Initiate the Host Negotiation Protocol. Read returns the status. Read/Write
171 # srp Initiate the Session Request Protocol. Read returns the status. Read/Write
172 # buspower Get or Set the Power State of the bus (0 - Off or 1 - On) Read/Write
173 # bussuspend Suspend the USB bus. Read/Write
174 # busconnected Get the connection status of the bus Read
176 # gotgctl Get or set the Core Control Status Register. Read/Write
177 ## gusbcfg Get or set the Core USB Configuration Register Read/Write
178 # grxfsiz Get or set the Receive FIFO Size Register Read/Write
179 # gnptxfsiz Get or set the non-periodic Transmit Size Register Read/Write
180 # gpvndctl Get or set the PHY Vendor Control Register Read/Write
181 ## ggpio Get the value in the lower 16-bits of the General Purpose IO Register or Set the upper 16 bits. Read/Write
182 ## guid Get or set the value of the User ID Register Read/Write
183 ## gsnpsid Get the value of the Synopsys ID Regester Read
184 ## devspeed Get or set the device speed setting in the DCFG register Read/Write
185 # enumspeed Gets the device enumeration Speed. Read
186 # hptxfsiz Get the value of the Host Periodic Transmit FIFO Read
187 # hprt0 Get or Set the value in the Host Port Control and Status Register Read/Write
189 test_status("TEST NYI") or die;