Date:2013-01-16 03:48:57 (11 years 2 months ago)
Author:Werner Almesberger
Commit:9930ae6576b7f4d8c01fbf8dad259ef081f4aa1c
Message:ubb-patgen/ubb-patgen.c: move frequency difference warning into select_freq

This way, all frequency selections print a warning when there's a difference.
Files: ubb-patgen/README (2 diffs)
ubb-patgen/ubb-patgen.c (4 diffs)

Change Details

ubb-patgen/README
5555Note that this form of invocation only searches the frequency
5656table but does not produce any output on UBB.
5757
58ubb-patgen warns if the selected frequency does not match the
59requested frequency, e.g.,
60
61# ubb-patgen -f 100kHz
62bus clk = 100.962 kHz (+0.96%)
63
64This warning can be suppressed with the option -q.
65
5866
5967Clock output
6068------------
...... 
7381
7482# ubb-patgen -c 0
7583
76ubb-patgen warns if the selected frequency does not match the
77requested frequency, e.g.,
78
79# ubb-patgen -f 100kHz -c
80bus clk = 100.962 kHz (+0.96%)
81
82This warning can be suppressed with the option -q.
83
8484
8585Pattern output
8686--------------
ubb-patgen/ubb-patgen.c
112112}
113113
114114
115static int select_freq(struct mmcclk *res, int hz, int rel)
115static int select_freq(struct mmcclk *res, int hz, int rel, int quiet)
116116{
117117    const struct mmcclk *clks, *p, *best = NULL;
118118    double d, best_d = 0;
119119    int n;
120    double err;
120121
121122    clks = frequencies(&n);
122123    for (p = clks; p != clks+n; p++) {
...... 
134135        return 0;
135136    *res = *best;
136137    free((void *) clks);
138
139    if (quiet)
140        return 1;
141
142    if (res->bus_clk_hz != hz) {
143        fprintf(stderr, "bus clk = ");
144        print_freq(stderr, res->bus_clk_hz);
145        err = (res->bus_clk_hz-hz)/hz;
146        if (err <= -0.0001 || err >= 0.0001)
147            fprintf(stderr, " (%+.2g%%)\n", err*100);
148        else
149            fprintf(stderr, " (%+d ppm)\n", (int) (err*1000000));
150    }
151
137152    return 1;
138153}
139154
...... 
588603
589604        ubb_open(UBB_ALL);
590605        if (bus_hz) {
591            if (!select_freq(&clk, bus_hz, bus_rel)) {
606            if (!select_freq(&clk, bus_hz, bus_rel, quiet)) {
592607                fprintf(stderr,
593608                    "no suitable frequency found\n");
594609                exit(1);
...... 
626641    if (!bus_hz)
627642        bus_hz = 1000000;
628643
629    if (!select_freq(&clk, bus_hz, bus_rel)) {
644    if (!select_freq(&clk, bus_hz, bus_rel, quiet)) {
630645        fprintf(stderr, "no suitable frequency found\n");
631646        exit(1);
632647    }
633    if (clk.bus_clk_hz != bus_hz && !quiet) {
634        double err;
635
636        fprintf(stderr, "bus clk = ");
637        print_freq(stderr, clk.bus_clk_hz);
638        err = (clk.bus_clk_hz-bus_hz)/bus_hz;
639        if (err <= -0.0001 || err >= 0.0001)
640            fprintf(stderr, " (%+.2g%%)\n", err*100);
641        else
642            fprintf(stderr, " (%+d ppm)\n", (int) (err*1000000));
643    }
644648
645649    if (clkout || clk_only)
646650        PDFUNS = UBB_CLK;

Archive Download the corresponding diff file

Branches:
master



interactive