ubb-la/ubb-la.c: new option -F freq_MHz to select "unsafe" frequencies

This commit is contained in:
Werner Almesberger 2013-01-28 21:06:00 -03:00
parent 85bda4c41d
commit f862a82a2d
2 changed files with 15 additions and 5 deletions

View File

@ -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

View File

@ -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);