Eric Biederman | d1ea539 | 2003-06-28 06:49:45 +0000 | [diff] [blame] | 1 | static void spd_set_memclk(void) |
| 2 | { |
| 3 | unsigned min_cycle_time, min_latency; |
| 4 | unsigned device; |
| 5 | int new_cycle_time, new_latency; |
| 6 | int index; |
| 7 | int latency; |
| 8 | |
| 9 | min_cycle_time = 0x50; |
| 10 | min_latency = 2; |
| 11 | device = 0x50; |
| 12 | new_latency = 5; |
| 13 | new_cycle_time = 0xa0; |
| 14 | latency = 23; |
| 15 | |
| 16 | for(index = 0; index < 3; index++, latency++) { |
| 17 | unsigned long loops; |
| 18 | unsigned address = index; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame^] | 19 | |
Eric Biederman | d1ea539 | 2003-06-28 06:49:45 +0000 | [diff] [blame] | 20 | loops = 1000000; |
| 21 | do { |
| 22 | } while(--loops); |
| 23 | if (loops) { |
| 24 | continue; |
| 25 | } |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame^] | 26 | |
Eric Biederman | d1ea539 | 2003-06-28 06:49:45 +0000 | [diff] [blame] | 27 | __builtin_outb(device, 0x10e4); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame^] | 28 | |
Eric Biederman | d1ea539 | 2003-06-28 06:49:45 +0000 | [diff] [blame] | 29 | __builtin_outb(address & 0xFF, 0x10e8); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame^] | 30 | |
Eric Biederman | d1ea539 | 2003-06-28 06:49:45 +0000 | [diff] [blame] | 31 | loops = 1000000; |
| 32 | while(--loops) |
| 33 | ; |
| 34 | } |
| 35 | |
| 36 | if (new_cycle_time > min_cycle_time) { |
| 37 | min_cycle_time = new_cycle_time; |
| 38 | } |
| 39 | if (new_latency > min_latency) { |
| 40 | min_latency = new_latency; |
| 41 | } |
| 42 | } |
| 43 | |