You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

825 lines
18 KiB

  1. /***************************************************************************
  2. * Copyright (C) 2007-2009 by Øyvind Harboe *
  3. * *
  4. * This program is free software; you can redistribute it and/or modify *
  5. * it under the terms of the GNU General Public License as published by *
  6. * the Free Software Foundation; either version 2 of the License, or *
  7. * (at your option) any later version. *
  8. * *
  9. * This program is distributed in the hope that it will be useful, *
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  12. * GNU General Public License for more details. *
  13. * *
  14. * You should have received a copy of the GNU General Public License *
  15. * along with this program; if not, write to the *
  16. * Free Software Foundation, Inc., *
  17. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
  18. ***************************************************************************/
  19. #ifdef HAVE_CONFIG_H
  20. #include "config.h"
  21. #endif
  22. #include "embeddedice.h"
  23. #include <jtag/minidriver.h>
  24. #include <jtag/interface.h>
  25. #include "zy1000_version.h"
  26. #include <cyg/hal/hal_io.h> // low level i/o
  27. #include <cyg/hal/hal_diag.h>
  28. #include <time.h>
  29. #define ZYLIN_VERSION GIT_ZY1000_VERSION
  30. #define ZYLIN_DATE __DATE__
  31. #define ZYLIN_TIME __TIME__
  32. #define ZYLIN_OPENOCD GIT_OPENOCD_VERSION
  33. #define ZYLIN_OPENOCD_VERSION "ZY1000 " ZYLIN_VERSION " " ZYLIN_DATE
  34. static int zy1000_khz(int khz, int *jtag_speed)
  35. {
  36. if (khz == 0)
  37. {
  38. *jtag_speed = 0;
  39. }
  40. else
  41. {
  42. *jtag_speed = 64000/khz;
  43. }
  44. return ERROR_OK;
  45. }
  46. static int zy1000_speed_div(int speed, int *khz)
  47. {
  48. if (speed == 0)
  49. {
  50. *khz = 0;
  51. }
  52. else
  53. {
  54. *khz = 64000/speed;
  55. }
  56. return ERROR_OK;
  57. }
  58. static bool readPowerDropout(void)
  59. {
  60. cyg_uint32 state;
  61. // sample and clear power dropout
  62. HAL_WRITE_UINT32(ZY1000_JTAG_BASE + 0x10, 0x80);
  63. HAL_READ_UINT32(ZY1000_JTAG_BASE + 0x10, state);
  64. bool powerDropout;
  65. powerDropout = (state & 0x80) != 0;
  66. return powerDropout;
  67. }
  68. static bool readSRST(void)
  69. {
  70. cyg_uint32 state;
  71. // sample and clear SRST sensing
  72. HAL_WRITE_UINT32(ZY1000_JTAG_BASE + 0x10, 0x00000040);
  73. HAL_READ_UINT32(ZY1000_JTAG_BASE + 0x10, state);
  74. bool srstAsserted;
  75. srstAsserted = (state & 0x40) != 0;
  76. return srstAsserted;
  77. }
  78. static int zy1000_srst_asserted(int *srst_asserted)
  79. {
  80. *srst_asserted = readSRST();
  81. return ERROR_OK;
  82. }
  83. static int zy1000_power_dropout(int *dropout)
  84. {
  85. *dropout = readPowerDropout();
  86. return ERROR_OK;
  87. }
  88. void zy1000_reset(int trst, int srst)
  89. {
  90. LOG_DEBUG("zy1000 trst=%d, srst=%d", trst, srst);
  91. if (!srst)
  92. {
  93. ZY1000_POKE(ZY1000_JTAG_BASE + 0x14, 0x00000001);
  94. }
  95. else
  96. {
  97. /* Danger!!! if clk != 0 when in
  98. * idle in TAP_IDLE, reset halt on str912 will fail.
  99. */
  100. ZY1000_POKE(ZY1000_JTAG_BASE + 0x10, 0x00000001);
  101. }
  102. if (!trst)
  103. {
  104. ZY1000_POKE(ZY1000_JTAG_BASE + 0x14, 0x00000002);
  105. }
  106. else
  107. {
  108. /* assert reset */
  109. ZY1000_POKE(ZY1000_JTAG_BASE + 0x10, 0x00000002);
  110. }
  111. if (trst||(srst && (jtag_get_reset_config() & RESET_SRST_PULLS_TRST)))
  112. {
  113. waitIdle();
  114. /* we're now in the RESET state until trst is deasserted */
  115. ZY1000_POKE(ZY1000_JTAG_BASE + 0x20, TAP_RESET);
  116. } else
  117. {
  118. /* We'll get RCLK failure when we assert TRST, so clear any false positives here */
  119. ZY1000_POKE(ZY1000_JTAG_BASE + 0x14, 0x400);
  120. }
  121. /* wait for srst to float back up */
  122. if (!srst)
  123. {
  124. int i;
  125. for (i = 0; i < 1000; i++)
  126. {
  127. // We don't want to sense our own reset, so we clear here.
  128. // There is of course a timing hole where we could loose
  129. // a "real" reset.
  130. if (!readSRST())
  131. break;
  132. /* wait 1ms */
  133. alive_sleep(1);
  134. }
  135. if (i == 1000)
  136. {
  137. LOG_USER("SRST didn't deassert after %dms", i);
  138. } else if (i > 1)
  139. {
  140. LOG_USER("SRST took %dms to deassert", i);
  141. }
  142. }
  143. }
  144. int zy1000_speed(int speed)
  145. {
  146. if (speed == 0)
  147. {
  148. /*0 means RCLK*/
  149. speed = 0;
  150. ZY1000_POKE(ZY1000_JTAG_BASE + 0x10, 0x100);
  151. LOG_DEBUG("jtag_speed using RCLK");
  152. }
  153. else
  154. {
  155. if (speed > 8190 || speed < 2)
  156. {
  157. LOG_USER("valid ZY1000 jtag_speed=[8190,2]. Divisor is 64MHz / even values between 8190-2, i.e. min 7814Hz, max 32MHz");
  158. return ERROR_INVALID_ARGUMENTS;
  159. }
  160. LOG_USER("jtag_speed %d => JTAG clk=%f", speed, 64.0/(float)speed);
  161. ZY1000_POKE(ZY1000_JTAG_BASE + 0x14, 0x100);
  162. ZY1000_POKE(ZY1000_JTAG_BASE + 0x1c, speed&~1);
  163. }
  164. return ERROR_OK;
  165. }
  166. static bool savePower;
  167. static void setPower(bool power)
  168. {
  169. savePower = power;
  170. if (power)
  171. {
  172. HAL_WRITE_UINT32(ZY1000_JTAG_BASE + 0x14, 0x8);
  173. } else
  174. {
  175. HAL_WRITE_UINT32(ZY1000_JTAG_BASE + 0x10, 0x8);
  176. }
  177. }
  178. COMMAND_HANDLER(handle_power_command)
  179. {
  180. switch (CMD_ARGC)
  181. {
  182. case 1: {
  183. bool enable;
  184. COMMAND_PARSE_ON_OFF(CMD_ARGV[0], enable);
  185. setPower(enable);
  186. // fall through
  187. }
  188. case 0:
  189. LOG_INFO("Target power %s", savePower ? "on" : "off");
  190. break;
  191. default:
  192. return ERROR_INVALID_ARGUMENTS;
  193. }
  194. return ERROR_OK;
  195. }
  196. /* Give TELNET a way to find out what version this is */
  197. static int jim_zy1000_version(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
  198. {
  199. if ((argc < 1) || (argc > 3))
  200. return JIM_ERR;
  201. const char *version_str = NULL;
  202. if (argc == 1)
  203. {
  204. version_str = ZYLIN_OPENOCD_VERSION;
  205. } else
  206. {
  207. const char *str = Jim_GetString(argv[1], NULL);
  208. const char *str2 = NULL;
  209. if (argc > 2)
  210. str2 = Jim_GetString(argv[2], NULL);
  211. if (strcmp("openocd", str) == 0)
  212. {
  213. version_str = ZYLIN_OPENOCD;
  214. }
  215. else if (strcmp("zy1000", str) == 0)
  216. {
  217. version_str = ZYLIN_VERSION;
  218. }
  219. else if (strcmp("date", str) == 0)
  220. {
  221. version_str = ZYLIN_DATE;
  222. }
  223. else if (strcmp("time", str) == 0)
  224. {
  225. version_str = ZYLIN_TIME;
  226. }
  227. else if (strcmp("pcb", str) == 0)
  228. {
  229. #ifdef CYGPKG_HAL_NIOS2
  230. version_str="c";
  231. #else
  232. version_str="b";
  233. #endif
  234. }
  235. #ifdef CYGPKG_HAL_NIOS2
  236. else if (strcmp("fpga", str) == 0)
  237. {
  238. /* return a list of 32 bit integers to describe the expected
  239. * and actual FPGA
  240. */
  241. static char *fpga_id = "0x12345678 0x12345678 0x12345678 0x12345678";
  242. cyg_uint32 id, timestamp;
  243. HAL_READ_UINT32(SYSID_BASE, id);
  244. HAL_READ_UINT32(SYSID_BASE+4, timestamp);
  245. sprintf(fpga_id, "0x%08x 0x%08x 0x%08x 0x%08x", id, timestamp, SYSID_ID, SYSID_TIMESTAMP);
  246. version_str = fpga_id;
  247. if ((argc>2) && (strcmp("time", str2) == 0))
  248. {
  249. time_t last_mod = timestamp;
  250. char * t = ctime (&last_mod) ;
  251. t[strlen(t)-1] = 0;
  252. version_str = t;
  253. }
  254. }
  255. #endif
  256. else
  257. {
  258. return JIM_ERR;
  259. }
  260. }
  261. Jim_SetResult(interp, Jim_NewStringObj(interp, version_str, -1));
  262. return JIM_OK;
  263. }
  264. #ifdef CYGPKG_HAL_NIOS2
  265. static int jim_zy1000_writefirmware(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
  266. {
  267. if (argc != 2)
  268. return JIM_ERR;
  269. int length;
  270. int stat;
  271. const char *str = Jim_GetString(argv[1], &length);
  272. /* BUG!!!! skip header! */
  273. void *firmware_address=0x4000000;
  274. int firmware_length=0x100000;
  275. if (length>firmware_length)
  276. return JIM_ERR;
  277. void *err_addr;
  278. if ((stat = flash_erase((void *)firmware_address, firmware_length, (void **)&err_addr)) != 0)
  279. {
  280. return JIM_ERR;
  281. }
  282. if ((stat = flash_program(firmware_address, str, length, (void **)&err_addr)) != 0)
  283. return JIM_ERR;
  284. return JIM_OK;
  285. }
  286. #endif
  287. static int
  288. zylinjtag_Jim_Command_powerstatus(Jim_Interp *interp,
  289. int argc,
  290. Jim_Obj * const *argv)
  291. {
  292. if (argc != 1)
  293. {
  294. Jim_WrongNumArgs(interp, 1, argv, "powerstatus");
  295. return JIM_ERR;
  296. }
  297. cyg_uint32 status;
  298. ZY1000_PEEK(ZY1000_JTAG_BASE + 0x10, status);
  299. Jim_SetResult(interp, Jim_NewIntObj(interp, (status&0x80) != 0));
  300. return JIM_OK;
  301. }
  302. int zy1000_init(void)
  303. {
  304. LOG_USER("%s", ZYLIN_OPENOCD_VERSION);
  305. ZY1000_POKE(ZY1000_JTAG_BASE + 0x10, 0x30); // Turn on LED1 & LED2
  306. setPower(true); // on by default
  307. /* deassert resets. Important to avoid infinite loop waiting for SRST to deassert */
  308. zy1000_reset(0, 0);
  309. zy1000_speed(jtag_get_speed());
  310. return ERROR_OK;
  311. }
  312. int zy1000_quit(void)
  313. {
  314. return ERROR_OK;
  315. }
  316. int interface_jtag_execute_queue(void)
  317. {
  318. cyg_uint32 empty;
  319. waitIdle();
  320. ZY1000_PEEK(ZY1000_JTAG_BASE + 0x10, empty);
  321. /* clear JTAG error register */
  322. ZY1000_POKE(ZY1000_JTAG_BASE + 0x14, 0x400);
  323. if ((empty&0x400) != 0)
  324. {
  325. LOG_WARNING("RCLK timeout");
  326. /* the error is informative only as we don't want to break the firmware if there
  327. * is a false positive.
  328. */
  329. // return ERROR_FAIL;
  330. }
  331. return ERROR_OK;
  332. }
  333. static cyg_uint32 getShiftValue(void)
  334. {
  335. cyg_uint32 value;
  336. waitIdle();
  337. ZY1000_PEEK(ZY1000_JTAG_BASE + 0xc, value);
  338. VERBOSE(LOG_INFO("getShiftValue %08x", value));
  339. return value;
  340. }
  341. #if 0
  342. static cyg_uint32 getShiftValueFlip(void)
  343. {
  344. cyg_uint32 value;
  345. waitIdle();
  346. ZY1000_PEEK(ZY1000_JTAG_BASE + 0x18, value);
  347. VERBOSE(LOG_INFO("getShiftValue %08x (flipped)", value));
  348. return value;
  349. }
  350. #endif
  351. #if 0
  352. static void shiftValueInnerFlip(const tap_state_t state, const tap_state_t endState, int repeat, cyg_uint32 value)
  353. {
  354. VERBOSE(LOG_INFO("shiftValueInner %s %s %d %08x (flipped)", tap_state_name(state), tap_state_name(endState), repeat, value));
  355. cyg_uint32 a,b;
  356. a = state;
  357. b = endState;
  358. ZY1000_POKE(ZY1000_JTAG_BASE + 0xc, value);
  359. ZY1000_POKE(ZY1000_JTAG_BASE + 0x8, (1 << 15) | (repeat << 8) | (a << 4) | b);
  360. VERBOSE(getShiftValueFlip());
  361. }
  362. #endif
  363. static void gotoEndState(tap_state_t end_state)
  364. {
  365. setCurrentState(end_state);
  366. }
  367. static __inline void scanFields(int num_fields, const struct scan_field *fields, tap_state_t shiftState, int pause)
  368. {
  369. int i;
  370. int j;
  371. int k;
  372. for (i = 0; i < num_fields; i++)
  373. {
  374. cyg_uint32 value;
  375. uint8_t *inBuffer = NULL;
  376. // figure out where to store the input data
  377. int num_bits = fields[i].num_bits;
  378. if (fields[i].in_value != NULL)
  379. {
  380. inBuffer = fields[i].in_value;
  381. }
  382. // here we shuffle N bits out/in
  383. j = 0;
  384. while (j < num_bits)
  385. {
  386. tap_state_t pause_state;
  387. int l;
  388. k = num_bits-j;
  389. pause_state = (shiftState == TAP_DRSHIFT)?TAP_DRSHIFT:TAP_IRSHIFT;
  390. if (k > 32)
  391. {
  392. k = 32;
  393. /* we have more to shift out */
  394. } else if (pause&&(i == num_fields-1))
  395. {
  396. /* this was the last to shift out this time */
  397. pause_state = (shiftState==TAP_DRSHIFT)?TAP_DRPAUSE:TAP_IRPAUSE;
  398. }
  399. // we have (num_bits + 7)/8 bytes of bits to toggle out.
  400. // bits are pushed out LSB to MSB
  401. value = 0;
  402. if (fields[i].out_value != NULL)
  403. {
  404. for (l = 0; l < k; l += 8)
  405. {
  406. value|=fields[i].out_value[(j + l)/8]<<l;
  407. }
  408. }
  409. /* mask away unused bits for easier debugging */
  410. if (k < 32)
  411. {
  412. value&=~(((uint32_t)0xffffffff) << k);
  413. } else
  414. {
  415. /* Shifting by >= 32 is not defined by the C standard
  416. * and will in fact shift by &0x1f bits on nios */
  417. }
  418. shiftValueInner(shiftState, pause_state, k, value);
  419. if (inBuffer != NULL)
  420. {
  421. // data in, LSB to MSB
  422. value = getShiftValue();
  423. // we're shifting in data to MSB, shift data to be aligned for returning the value
  424. value >>= 32-k;
  425. for (l = 0; l < k; l += 8)
  426. {
  427. inBuffer[(j + l)/8]=(value >> l)&0xff;
  428. }
  429. }
  430. j += k;
  431. }
  432. }
  433. }
  434. int interface_jtag_add_ir_scan(int num_fields, const struct scan_field *fields, tap_state_t state)
  435. {
  436. int j;
  437. int scan_size = 0;
  438. struct jtag_tap *tap, *nextTap;
  439. for (tap = jtag_tap_next_enabled(NULL); tap!= NULL; tap = nextTap)
  440. {
  441. nextTap = jtag_tap_next_enabled(tap);
  442. int pause = (nextTap==NULL);
  443. int found = 0;
  444. scan_size = tap->ir_length;
  445. /* search the list */
  446. for (j = 0; j < num_fields; j++)
  447. {
  448. if (tap == fields[j].tap)
  449. {
  450. found = 1;
  451. scanFields(1, fields + j, TAP_IRSHIFT, pause);
  452. /* update device information */
  453. buf_cpy(fields[j].out_value, tap->cur_instr, scan_size);
  454. tap->bypass = 0;
  455. break;
  456. }
  457. }
  458. if (!found)
  459. {
  460. /* if a device isn't listed, set it to BYPASS */
  461. uint8_t ones[]={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
  462. struct scan_field tmp;
  463. memset(&tmp, 0, sizeof(tmp));
  464. tmp.out_value = ones;
  465. tmp.num_bits = scan_size;
  466. scanFields(1, &tmp, TAP_IRSHIFT, pause);
  467. /* update device information */
  468. buf_cpy(tmp.out_value, tap->cur_instr, scan_size);
  469. tap->bypass = 1;
  470. }
  471. }
  472. gotoEndState(state);
  473. return ERROR_OK;
  474. }
  475. int interface_jtag_add_plain_ir_scan(int num_fields, const struct scan_field *fields, tap_state_t state)
  476. {
  477. scanFields(num_fields, fields, TAP_IRSHIFT, 1);
  478. gotoEndState(state);
  479. return ERROR_OK;
  480. }
  481. int interface_jtag_add_dr_scan(int num_fields, const struct scan_field *fields, tap_state_t state)
  482. {
  483. int j;
  484. struct jtag_tap *tap, *nextTap;
  485. for (tap = jtag_tap_next_enabled(NULL); tap!= NULL; tap = nextTap)
  486. {
  487. nextTap = jtag_tap_next_enabled(tap);
  488. int found = 0;
  489. int pause = (nextTap==NULL);
  490. for (j = 0; j < num_fields; j++)
  491. {
  492. if (tap == fields[j].tap)
  493. {
  494. found = 1;
  495. scanFields(1, fields+j, TAP_DRSHIFT, pause);
  496. }
  497. }
  498. if (!found)
  499. {
  500. struct scan_field tmp;
  501. /* program the scan field to 1 bit length, and ignore it's value */
  502. tmp.num_bits = 1;
  503. tmp.out_value = NULL;
  504. tmp.in_value = NULL;
  505. scanFields(1, &tmp, TAP_DRSHIFT, pause);
  506. }
  507. else
  508. {
  509. }
  510. }
  511. gotoEndState(state);
  512. return ERROR_OK;
  513. }
  514. int interface_jtag_add_plain_dr_scan(int num_fields, const struct scan_field *fields, tap_state_t state)
  515. {
  516. scanFields(num_fields, fields, TAP_DRSHIFT, 1);
  517. gotoEndState(state);
  518. return ERROR_OK;
  519. }
  520. int interface_jtag_add_tlr()
  521. {
  522. setCurrentState(TAP_RESET);
  523. return ERROR_OK;
  524. }
  525. int interface_jtag_add_reset(int req_trst, int req_srst)
  526. {
  527. zy1000_reset(req_trst, req_srst);
  528. return ERROR_OK;
  529. }
  530. static int zy1000_jtag_add_clocks(int num_cycles, tap_state_t state, tap_state_t clockstate)
  531. {
  532. /* num_cycles can be 0 */
  533. setCurrentState(clockstate);
  534. /* execute num_cycles, 32 at the time. */
  535. int i;
  536. for (i = 0; i < num_cycles; i += 32)
  537. {
  538. int num;
  539. num = 32;
  540. if (num_cycles-i < num)
  541. {
  542. num = num_cycles-i;
  543. }
  544. shiftValueInner(clockstate, clockstate, num, 0);
  545. }
  546. #if !TEST_MANUAL()
  547. /* finish in end_state */
  548. setCurrentState(state);
  549. #else
  550. tap_state_t t = TAP_IDLE;
  551. /* test manual drive code on any target */
  552. int tms;
  553. uint8_t tms_scan = tap_get_tms_path(t, state);
  554. int tms_count = tap_get_tms_path_len(tap_get_state(), tap_get_end_state());
  555. for (i = 0; i < tms_count; i++)
  556. {
  557. tms = (tms_scan >> i) & 1;
  558. waitIdle();
  559. ZY1000_POKE(ZY1000_JTAG_BASE + 0x28, tms);
  560. }
  561. waitIdle();
  562. ZY1000_POKE(ZY1000_JTAG_BASE + 0x20, state);
  563. #endif
  564. return ERROR_OK;
  565. }
  566. int interface_jtag_add_runtest(int num_cycles, tap_state_t state)
  567. {
  568. return zy1000_jtag_add_clocks(num_cycles, state, TAP_IDLE);
  569. }
  570. int interface_jtag_add_clocks(int num_cycles)
  571. {
  572. return zy1000_jtag_add_clocks(num_cycles, cmd_queue_cur_state, cmd_queue_cur_state);
  573. }
  574. int interface_jtag_add_sleep(uint32_t us)
  575. {
  576. jtag_sleep(us);
  577. return ERROR_OK;
  578. }
  579. int interface_jtag_add_pathmove(int num_states, const tap_state_t *path)
  580. {
  581. int state_count;
  582. int tms = 0;
  583. /*wait for the fifo to be empty*/
  584. waitIdle();
  585. state_count = 0;
  586. tap_state_t cur_state = cmd_queue_cur_state;
  587. while (num_states)
  588. {
  589. if (tap_state_transition(cur_state, false) == path[state_count])
  590. {
  591. tms = 0;
  592. }
  593. else if (tap_state_transition(cur_state, true) == path[state_count])
  594. {
  595. tms = 1;
  596. }
  597. else
  598. {
  599. LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_name(cur_state), tap_state_name(path[state_count]));
  600. exit(-1);
  601. }
  602. waitIdle();
  603. ZY1000_POKE(ZY1000_JTAG_BASE + 0x28, tms);
  604. cur_state = path[state_count];
  605. state_count++;
  606. num_states--;
  607. }
  608. waitIdle();
  609. ZY1000_POKE(ZY1000_JTAG_BASE + 0x20, cur_state);
  610. return ERROR_OK;
  611. }
  612. void embeddedice_write_dcc(struct jtag_tap *tap, int reg_addr, uint8_t *buffer, int little, int count)
  613. {
  614. // static int const reg_addr = 0x5;
  615. tap_state_t end_state = jtag_get_end_state();
  616. if (jtag_tap_next_enabled(jtag_tap_next_enabled(NULL)) == NULL)
  617. {
  618. /* better performance via code duplication */
  619. if (little)
  620. {
  621. int i;
  622. for (i = 0; i < count; i++)
  623. {
  624. shiftValueInner(TAP_DRSHIFT, TAP_DRSHIFT, 32, fast_target_buffer_get_u32(buffer, 1));
  625. shiftValueInner(TAP_DRSHIFT, end_state, 6, reg_addr | (1 << 5));
  626. buffer += 4;
  627. }
  628. } else
  629. {
  630. int i;
  631. for (i = 0; i < count; i++)
  632. {
  633. shiftValueInner(TAP_DRSHIFT, TAP_DRSHIFT, 32, fast_target_buffer_get_u32(buffer, 0));
  634. shiftValueInner(TAP_DRSHIFT, end_state, 6, reg_addr | (1 << 5));
  635. buffer += 4;
  636. }
  637. }
  638. }
  639. else
  640. {
  641. int i;
  642. for (i = 0; i < count; i++)
  643. {
  644. embeddedice_write_reg_inner(tap, reg_addr, fast_target_buffer_get_u32(buffer, little));
  645. buffer += 4;
  646. }
  647. }
  648. }
  649. static const struct command_registration zy1000_commands[] = {
  650. {
  651. .name = "power",
  652. .handler = &handle_power_command,
  653. .mode = COMMAND_ANY,
  654. .help = "turn power switch to target on/off. No arguments - print status.",
  655. .usage = "power <on/off>",
  656. },
  657. {
  658. .name = "zy1000_version",
  659. .mode = COMMAND_ANY,
  660. .jim_handler = &jim_zy1000_version,
  661. .help = "print version info for zy1000",
  662. },
  663. {
  664. .name = "powerstatus",
  665. .mode = COMMAND_ANY,
  666. .jim_handler = & zylinjtag_Jim_Command_powerstatus,
  667. .help = "print power status of target",
  668. },
  669. #ifdef CYGPKG_HAL_NIOS2
  670. {
  671. .name = "updatezy1000firmware",
  672. .mode = COMMAND_ANY,
  673. .jim_handler = &jim_zy1000_writefirmware,
  674. .help = "writes firmware to flash",
  675. },
  676. #endif
  677. COMMAND_REGISTRATION_DONE
  678. };
  679. struct jtag_interface zy1000_interface =
  680. {
  681. .name = "ZY1000",
  682. .execute_queue = NULL,
  683. .speed = zy1000_speed,
  684. .commands = zy1000_commands,
  685. .init = zy1000_init,
  686. .quit = zy1000_quit,
  687. .khz = zy1000_khz,
  688. .speed_div = zy1000_speed_div,
  689. .power_dropout = zy1000_power_dropout,
  690. .srst_asserted = zy1000_srst_asserted,
  691. };