return 0;
}
+int carlu_cmd_mem_watch(struct carlu *ar, const uint32_t mem,
+ const unsigned int len, void *_buf)
+{
+#define RW 8 /* number of words to read at once */
+#define RB (sizeof(uint32_t) * RW)
+ uint8_t *buf = _buf;
+ unsigned int i, j, block;
+ int err;
+ __le32 offsets[RW];
+
+ for (i = 0; i < (len + RB - 1) / RB; i++) {
+ block = min_t(unsigned int, (len - RB * i) / sizeof(uint32_t), RW);
+ for (j = 0; j < block; j++)
+ offsets[j] = cpu_to_le32(mem);
+
+ err = carlusb_cmd(ar, CARL9170_CMD_RREG,
+ (void *) &offsets, block * sizeof(uint32_t),
+ (void *) buf + RB * i, RB);
+
+ if (err)
+ return err;
+ }
+
+#undef RW
+#undef RB
+
+ return 0;
+}
+
int carlu_cmd_write_mem(struct carlu *ar, const uint32_t addr,
const uint32_t val)
{
const unsigned int len, void *_buf);
int carlu_cmd_write_mem(struct carlu *ar, const uint32_t addr,
const uint32_t val);
+int carlu_cmd_mem_watch(struct carlu *ar, const uint32_t mem,
+ const unsigned int len, void *_buf);
struct carl9170_cmd *carlu_cmd_buf(struct carlu *ar,
const enum carl9170_cmd_oids cmd, const unsigned int len);
return err ? EXIT_FAILURE : EXIT_SUCCESS;
}
+static int carlu_run_random_test(void)
+{
+ struct carlu *carl = NULL;
+ int err;
+
+ err = carlu_init();
+ if (err)
+ goto out;
+
+ carl = carlusb_probe();
+ if (IS_ERR_OR_NULL(carl)) {
+ err = PTR_ERR(carl);
+ goto out;
+ }
+
+ err = carlu_random_test(carl);
+ if (err)
+ goto out_close;
+
+out_close:
+ carlusb_close(carl);
+
+out:
+ carlu_exit();
+ return err ? EXIT_FAILURE : EXIT_SUCCESS;
+}
+
static int carlu_run_loop_test(void)
{
struct carlu *carl;
MENU_ITEM('p', carlu_probe_all, "probe all possible devices."),
MENU_ITEM('t', carlu_run_loop_test, "run tx/rx test."),
MENU_ITEM('g', carlu_run_gpio_test, "flash the leds."),
+ MENU_ITEM('r', carlu_run_random_test, "get random numbers."),
};
static int show_help(void)
CHK(carlu_cmd_read_mem(ar, AR9170_GPIO_REG_PORT_DATA, &gpio));
info("GPIO state:%x\n", gpio);
}
+
+int carlu_random_test(struct carlu *ar)
+{
+ uint32_t buf[4096];
+ int err, i;
+
+ err = carlu_cmd_mem_watch(ar, AR9170_RAND_REG_NUM, sizeof(buf), buf);
+ if (err)
+ return err;
+
+ for (i = 0; i < ARRAY_SIZE(buf); i++)
+ info("%.2x %.2x ", buf[i] & 0xff, buf[i] >> 8);
+
+ info("\n");
+}
const unsigned int max_len);
int carlu_gpio_test(struct carlu *ar);
+int carlu_random_test(struct carlu *ar);
#endif /* __CARL9170USER_TEST_H */