Date:2013-01-29 01:14:53 (11 years 1 month ago)
Author:Werner Almesberger
Commit:04b235cedfcce2088a8e04e4de3def014c3c0760
Message:ubb-patgen/ubb-patgen.c: new option -F freq_Hz to select "unsafe" frequencies

Files: ubb-patgen/README (1 diff)
ubb-patgen/ubb-patgen.c (10 diffs)

Change Details

ubb-patgen/README
6363
6464This warning can be suppressed with the option -q.
6565
66The option -F works like -f but also allows frequencies that may
67exceed the hardware's capabilities. As a consequence, the MMC
68controller may hang.
69
6670The frequency can also be specified as the cycle time with the
6771option -i:
6872
ubb-patgen/ubb-patgen.c
4646}
4747
4848
49static struct mmcclk *frequencies(int *n)
49static struct mmcclk *frequencies(int *n, int all)
5050{
5151    struct mmcclk mmc;
5252    struct mmcclk *clks = malloc(sizeof(struct mmcclk));
...... 
5757        exit(1);
5858    }
5959
60    mmcclk_first(&mmc, 0, MMCCLK_FLAG_WR_ONLY);
60    mmcclk_first(&mmc, 0,
61        MMCCLK_FLAG_WR_ONLY | (all ? MMCCLK_FLAG_ALL : 0));
6162    clks[0] = mmc;
6263    while (mmcclk_next(&mmc)) {
6364        clks = realloc(clks, sizeof(struct mmcclk)*(n_clks+1));
...... 
9697    int n, i;
9798    double last = 0;
9899
99    clks = frequencies(&n);
100    clks = frequencies(&n, 0);
100101    for (i = 0; i != n; i++) {
101102        if (quiet) {
102103            if (clks[i].bus_clk_hz != last)
...... 
113114}
114115
115116
116static int select_freq(struct mmcclk *res, int hz, int rel, int quiet)
117static int select_freq(struct mmcclk *res, int hz, int rel, int quiet, int all)
117118{
118119    const struct mmcclk *clks, *p, *best = NULL;
119120    double d, best_d = 0;
120121    int n;
121122    double err;
122123
123    clks = frequencies(&n);
124    clks = frequencies(&n, all);
124125    for (p = clks; p != clks+n; p++) {
125126        if (rel > 0 && p->bus_clk_hz < hz)
126127            continue;
...... 
690691{
691692        fprintf(stderr,
692693"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"
697699" -c output bus clock on CLK without sending a pattern\n"
698700" -C temporarily output bus clock on CLK (for debugging)\n"
699701" -d deb_s trigger debounce time (default: no debouncing)\n"
700702" -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"
701704" -i inter_s set bus clock such that one cycle equals the specified "
702705  "interval\n"
703706" -m mask use only the DATx lines specified in the mask (default: 0xf)\n"
...... 
728731int main(int argc, char **argv)
729732{
730733    struct mmcclk clk;
734    int all = 0;
731735    int bus_hz = 0, clk_only = 0, clkout = 0, bus_rel = 0;
732736    const char *pattern = NULL;
733737    int quiet = 0, force_pattern = 0;
...... 
745749    unsigned long tmp;
746750    const char *p;
747751
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)
749753        switch (c) {
750754        case 'c':
751755            clk_only = 1;
...... 
761765                usage(*argv);
762766            debounce = 1;
763767            break;
768        case 'F':
769            all = 1;
770            /* fall through */
764771        case 'f':
765772            if (!frequency(optarg, &bus_hz, &bus_rel))
766773                usage(*argv);
...... 
818825
819826        ubb_open(UBB_ALL);
820827        if (bus_hz) {
821            if (!select_freq(&clk, bus_hz, bus_rel, quiet)) {
828            if (!select_freq(&clk, bus_hz, bus_rel, quiet, all)) {
822829                fprintf(stderr,
823830                    "no suitable frequency found\n");
824831                exit(1);
...... 
856863    if (!bus_hz)
857864        bus_hz = 1000000;
858865
859    if (!select_freq(&clk, bus_hz, bus_rel, quiet)) {
866    if (!select_freq(&clk, bus_hz, bus_rel, quiet, all)) {
860867        fprintf(stderr, "no suitable frequency found\n");
861868        exit(1);
862869    }

Archive Download the corresponding diff file

Branches:
master



interactive