ubb-patgen/ubb-patgen.c |
46 | 46 | } |
47 | 47 | |
48 | 48 | |
49 | | static struct mmcclk *frequencies(int *n) |
| 49 | static struct mmcclk *frequencies(int *n, int all) |
50 | 50 | { |
51 | 51 | struct mmcclk mmc; |
52 | 52 | struct mmcclk *clks = malloc(sizeof(struct mmcclk)); |
... | ... | |
57 | 57 | exit(1); |
58 | 58 | } |
59 | 59 | |
60 | | mmcclk_first(&mmc, 0, MMCCLK_FLAG_WR_ONLY); |
| 60 | mmcclk_first(&mmc, 0, |
| 61 | MMCCLK_FLAG_WR_ONLY | (all ? MMCCLK_FLAG_ALL : 0)); |
61 | 62 | clks[0] = mmc; |
62 | 63 | while (mmcclk_next(&mmc)) { |
63 | 64 | clks = realloc(clks, sizeof(struct mmcclk)*(n_clks+1)); |
... | ... | |
96 | 97 | int n, i; |
97 | 98 | double last = 0; |
98 | 99 | |
99 | | clks = frequencies(&n); |
| 100 | clks = frequencies(&n, 0); |
100 | 101 | for (i = 0; i != n; i++) { |
101 | 102 | if (quiet) { |
102 | 103 | if (clks[i].bus_clk_hz != last) |
... | ... | |
113 | 114 | } |
114 | 115 | |
115 | 116 | |
116 | | static int select_freq(struct mmcclk *res, int hz, int rel, int quiet) |
| 117 | static int select_freq(struct mmcclk *res, int hz, int rel, int quiet, int all) |
117 | 118 | { |
118 | 119 | const struct mmcclk *clks, *p, *best = NULL; |
119 | 120 | double d, best_d = 0; |
120 | 121 | int n; |
121 | 122 | double err; |
122 | 123 | |
123 | | clks = frequencies(&n); |
| 124 | clks = frequencies(&n, all); |
124 | 125 | for (p = clks; p != clks+n; p++) { |
125 | 126 | if (rel > 0 && p->bus_clk_hz < hz) |
126 | 127 | continue; |
... | ... | |
690 | 691 | { |
691 | 692 | fprintf(stderr, |
692 | 693 | "usage: %s\n" |
693 | | " %s [-q] -f freq_hz|-i interval_s\n" |
694 | | " %s [-q] [-f freq_hz|-i interval_s] -c [active_s]\n" |
695 | | " %s [-q] [-f freq_hz|-i interval_s] [-C|-t 0|1... [-d debounce_s]]\n" |
696 | | " [-w wait_s] [-m mask] [-p] file|pattern\n\n" |
| 694 | " %s [-q] (-f|-F) freq_hz|-i interval_s\n" |
| 695 | " %s [-q] [(-f|-F) freq_hz|-i interval_s] -c [active_s]\n" |
| 696 | " %s [-q] [(-f|-F) freq_hz|-i interval_s]\n" |
| 697 | " [-C|-t 0|1... [-d debounce_s]] [-w wait_s] [-m mask] [-p]\n" |
| 698 | " file|pattern\n\n" |
697 | 699 | " -c output bus clock on CLK without sending a pattern\n" |
698 | 700 | " -C temporarily output bus clock on CLK (for debugging)\n" |
699 | 701 | " -d deb_s trigger debounce time (default: no debouncing)\n" |
700 | 702 | " -f freq_hz set bus clock to the specified frequency (default: 1 MHz)\n" |
| 703 | " -F freq_hz like -f, but also allow \"overclocking\"\n" |
701 | 704 | " -i inter_s set bus clock such that one cycle equals the specified " |
702 | 705 | "interval\n" |
703 | 706 | " -m mask use only the DATx lines specified in the mask (default: 0xf)\n" |
... | ... | |
728 | 731 | int main(int argc, char **argv) |
729 | 732 | { |
730 | 733 | struct mmcclk clk; |
| 734 | int all = 0; |
731 | 735 | int bus_hz = 0, clk_only = 0, clkout = 0, bus_rel = 0; |
732 | 736 | const char *pattern = NULL; |
733 | 737 | int quiet = 0, force_pattern = 0; |
... | ... | |
745 | 749 | unsigned long tmp; |
746 | 750 | const char *p; |
747 | 751 | |
748 | | while ((c = getopt(argc, argv, "cCd:f:i:m:pqt:w:")) != EOF) |
| 752 | while ((c = getopt(argc, argv, "cCd:f:F:i:m:pqt:w:")) != EOF) |
749 | 753 | switch (c) { |
750 | 754 | case 'c': |
751 | 755 | clk_only = 1; |
... | ... | |
761 | 765 | usage(*argv); |
762 | 766 | debounce = 1; |
763 | 767 | break; |
| 768 | case 'F': |
| 769 | all = 1; |
| 770 | /* fall through */ |
764 | 771 | case 'f': |
765 | 772 | if (!frequency(optarg, &bus_hz, &bus_rel)) |
766 | 773 | usage(*argv); |
... | ... | |
818 | 825 | |
819 | 826 | ubb_open(UBB_ALL); |
820 | 827 | if (bus_hz) { |
821 | | if (!select_freq(&clk, bus_hz, bus_rel, quiet)) { |
| 828 | if (!select_freq(&clk, bus_hz, bus_rel, quiet, all)) { |
822 | 829 | fprintf(stderr, |
823 | 830 | "no suitable frequency found\n"); |
824 | 831 | exit(1); |
... | ... | |
856 | 863 | if (!bus_hz) |
857 | 864 | bus_hz = 1000000; |
858 | 865 | |
859 | | if (!select_freq(&clk, bus_hz, bus_rel, quiet)) { |
| 866 | if (!select_freq(&clk, bus_hz, bus_rel, quiet, all)) { |
860 | 867 | fprintf(stderr, "no suitable frequency found\n"); |
861 | 868 | exit(1); |
862 | 869 | } |