mirror of
git://projects.qi-hardware.com/ben-blinkenlights.git
synced 2024-11-23 20:33:45 +02:00
ubb-la/ubb-la.c: new option -F freq_MHz to select "unsafe" frequencies
This commit is contained in:
parent
85bda4c41d
commit
f862a82a2d
@ -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
|
modes to select. ubb-la simply picks the frequency closest to the one
|
||||||
specified.
|
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
|
A list of available frequencies can be obtained with
|
||||||
|
|
||||||
# ubb-patgen -q
|
# ubb-patgen -q
|
||||||
|
@ -331,11 +331,12 @@ static void do_bufs(int n_bufs, int nibbles)
|
|||||||
* It'll save a few nanoseconds.
|
* 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;
|
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;
|
*clk = mmc;
|
||||||
while (mmcclk_next(&mmc))
|
while (mmcclk_next(&mmc))
|
||||||
if (fabs(clk->bus_clk_hz-hz) > fabs(mmc.bus_clk_hz-hz) ||
|
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)
|
static void usage(const char *name)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
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"
|
" -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 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"
|
" -n N capture N buffers worth of samples without waiting for a\n"
|
||||||
" trigger\n"
|
" trigger\n"
|
||||||
" -t pattern/mask start capture at the specified pattern (DAT0 = 1, etc.,\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)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
double freq_mhz = 1;
|
double freq_mhz = 1;
|
||||||
|
int all = 0;
|
||||||
unsigned long trigger = 1, mask = 0;
|
unsigned long trigger = 1, mask = 0;
|
||||||
unsigned long multi = 0;
|
unsigned long multi = 0;
|
||||||
int clkout = 0;
|
int clkout = 0;
|
||||||
@ -383,11 +386,14 @@ int main(int argc, char **argv)
|
|||||||
char *end;
|
char *end;
|
||||||
int c, res;
|
int c, res;
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "Cf:n:t:")) != EOF)
|
while ((c = getopt(argc, argv, "Cf:F:n:t:")) != EOF)
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'C':
|
case 'C':
|
||||||
clkout = 1;
|
clkout = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'F':
|
||||||
|
all = 1;
|
||||||
|
/* fall through */
|
||||||
case 'f':
|
case 'f':
|
||||||
freq_mhz = strtod(optarg, &end);
|
freq_mhz = strtod(optarg, &end);
|
||||||
if (*end)
|
if (*end)
|
||||||
@ -423,7 +429,7 @@ int main(int argc, char **argv)
|
|||||||
CLR(UBB_CMD);
|
CLR(UBB_CMD);
|
||||||
PDFUNC = 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,
|
fprintf(stderr, "bus %g MHz controller %g MHz\n", clk.bus_clk_hz/1e6,
|
||||||
clk.sys_clk_hz/(clk.clkdiv+1.0)/1e6);
|
clk.sys_clk_hz/(clk.clkdiv+1.0)/1e6);
|
||||||
mmcclk_start(&clk);
|
mmcclk_start(&clk);
|
||||||
|
Loading…
Reference in New Issue
Block a user