From f862a82a2da9c7d15912d99264ab211863e16bec Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Mon, 28 Jan 2013 21:06:00 -0300 Subject: [PATCH] ubb-la/ubb-la.c: new option -F freq_MHz to select "unsafe" frequencies --- ubb-la/README | 4 ++++ ubb-la/ubb-la.c | 16 +++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ubb-la/README b/ubb-la/README index fd375ab..be6f75f 100644 --- a/ubb-la/README +++ b/ubb-la/README @@ -26,6 +26,10 @@ Note that - unlike ubb-patgen - there are no SI prefixes or rounding modes to select. ubb-la simply picks the frequency closest to the one specified. +The option -F works like -f but also allows frequencies that may +exceed the hardware's capabilities. As a consequence, the MMC +controller may hang. + A list of available frequencies can be obtained with # ubb-patgen -q diff --git a/ubb-la/ubb-la.c b/ubb-la/ubb-la.c index 2bf259b..7a70e8d 100644 --- a/ubb-la/ubb-la.c +++ b/ubb-la/ubb-la.c @@ -331,11 +331,12 @@ static void do_bufs(int n_bufs, int nibbles) * It'll save a few nanoseconds. */ -static void frequency(struct mmcclk *clk, int hz) +static void frequency(struct mmcclk *clk, int hz, int all) { struct mmcclk mmc; - mmcclk_first(&mmc, 0, MMCCLK_FLAG_RD_ONLY); + mmcclk_first(&mmc, 0, + MMCCLK_FLAG_RD_ONLY | (all ? MMCCLK_FLAG_ALL : 0)); *clk = mmc; while (mmcclk_next(&mmc)) if (fabs(clk->bus_clk_hz-hz) > fabs(mmc.bus_clk_hz-hz) || @@ -361,9 +362,10 @@ static unsigned long xlat_pins(unsigned long pins) static void usage(const char *name) { fprintf(stderr, -"usage: %s [-C] [-t pattern/mask] [-f frequency_MHz] [-n N]\n\n" +"usage: %s [-C] [-t pattern/mask] [(-f|-F) frequency_MHz] [-n N]\n\n" " -C output the MMC clock on CLK/TRIG (for debugging)\n" " -f freq_MHz select the specified frequency (default; 1 MHz)\n" +" -F freq_MHz like -f, but also allow \"overclocking\"\n" " -n N capture N buffers worth of samples without waiting for a\n" " trigger\n" " -t pattern/mask start capture at the specified pattern (DAT0 = 1, etc.,\n" @@ -376,6 +378,7 @@ static void usage(const char *name) int main(int argc, char **argv) { double freq_mhz = 1; + int all = 0; unsigned long trigger = 1, mask = 0; unsigned long multi = 0; int clkout = 0; @@ -383,11 +386,14 @@ int main(int argc, char **argv) char *end; int c, res; - while ((c = getopt(argc, argv, "Cf:n:t:")) != EOF) + while ((c = getopt(argc, argv, "Cf:F:n:t:")) != EOF) switch (c) { case 'C': clkout = 1; break; + case 'F': + all = 1; + /* fall through */ case 'f': freq_mhz = strtod(optarg, &end); if (*end) @@ -423,7 +429,7 @@ int main(int argc, char **argv) CLR(UBB_CMD); PDFUNC = UBB_CMD; - frequency(&clk, 1e6*freq_mhz); + frequency(&clk, 1e6*freq_mhz, all); fprintf(stderr, "bus %g MHz controller %g MHz\n", clk.bus_clk_hz/1e6, clk.sys_clk_hz/(clk.clkdiv+1.0)/1e6); mmcclk_start(&clk);