sysfsgpio: give time to udev to change gpio permission
[fw/openocd] / src / jtag / drivers / usbprog.c
index 156edf0223703445c70df6fd8d55cc39afd772b2..35a95202ea27051aa08191ba657aab202b957bfe 100644 (file)
@@ -13,9 +13,7 @@
  *   GNU General Public License for more details.                          *
  *                                                                         *
  *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.           *
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
  ***************************************************************************/
 
 /*
@@ -105,62 +103,50 @@ static int usbprog_execute_queue(void)
 
        while (cmd) {
                switch (cmd->type) {
-                   case JTAG_RESET:
-#ifdef _DEBUG_JTAG_IO_
-                           LOG_DEBUG("reset trst: %i srst %i",
-                               cmd->cmd.reset->trst,
-                               cmd->cmd.reset->srst);
-#endif
-                           if (cmd->cmd.reset->trst == 1)
-                                   tap_set_state(TAP_RESET);
-                           usbprog_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
-                           break;
-                   case JTAG_RUNTEST:
-#ifdef _DEBUG_JTAG_IO_
-                           LOG_DEBUG("runtest %i cycles, end in %i",
-                               cmd->cmd.runtest->num_cycles,
-                               cmd->cmd.runtest->end_state);
-#endif
-                           usbprog_end_state(cmd->cmd.runtest->end_state);
-                           usbprog_runtest(cmd->cmd.runtest->num_cycles);
-                           break;
-                   case JTAG_TLR_RESET:
-#ifdef _DEBUG_JTAG_IO_
-                           LOG_DEBUG("statemove end in %i", cmd->cmd.statemove->end_state);
-#endif
-                           usbprog_end_state(cmd->cmd.statemove->end_state);
-                           usbprog_state_move();
-                           break;
-                   case JTAG_PATHMOVE:
-#ifdef _DEBUG_JTAG_IO_
-                           LOG_DEBUG("pathmove: %i states, end in %i",
-                               cmd->cmd.pathmove->num_states,
-                               cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
-#endif
-                           usbprog_path_move(cmd->cmd.pathmove);
-                           break;
-                   case JTAG_SCAN:
-#ifdef _DEBUG_JTAG_IO_
-                           LOG_DEBUG("scan end in %i", cmd->cmd.scan->end_state);
-#endif
-                           usbprog_end_state(cmd->cmd.scan->end_state);
-                           scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
-                           type = jtag_scan_type(cmd->cmd.scan);
-                           usbprog_scan(cmd->cmd.scan->ir_scan, type, buffer, scan_size);
-                           if (jtag_read_buffer(buffer, cmd->cmd.scan) != ERROR_OK)
-                                   return ERROR_JTAG_QUEUE_FAILED;
-                           if (buffer)
-                                   free(buffer);
-                           break;
-                   case JTAG_SLEEP:
-#ifdef _DEBUG_JTAG_IO_
-                           LOG_DEBUG("sleep %i", cmd->cmd.sleep->us);
-#endif
-                           jtag_sleep(cmd->cmd.sleep->us);
-                           break;
-                   default:
-                           LOG_ERROR("BUG: unknown JTAG command type encountered");
-                           exit(-1);
+               case JTAG_RESET:
+                       LOG_DEBUG_IO("reset trst: %i srst %i",
+                                       cmd->cmd.reset->trst,
+                                       cmd->cmd.reset->srst);
+                       if (cmd->cmd.reset->trst == 1)
+                               tap_set_state(TAP_RESET);
+                       usbprog_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
+                       break;
+               case JTAG_RUNTEST:
+                       LOG_DEBUG_IO("runtest %i cycles, end in %i",
+                                       cmd->cmd.runtest->num_cycles,
+                                       cmd->cmd.runtest->end_state);
+                       usbprog_end_state(cmd->cmd.runtest->end_state);
+                       usbprog_runtest(cmd->cmd.runtest->num_cycles);
+                       break;
+               case JTAG_TLR_RESET:
+                       LOG_DEBUG_IO("statemove end in %i", cmd->cmd.statemove->end_state);
+                       usbprog_end_state(cmd->cmd.statemove->end_state);
+                       usbprog_state_move();
+                       break;
+               case JTAG_PATHMOVE:
+                       LOG_DEBUG_IO("pathmove: %i states, end in %i",
+                                       cmd->cmd.pathmove->num_states,
+                                       cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
+                       usbprog_path_move(cmd->cmd.pathmove);
+                       break;
+               case JTAG_SCAN:
+                       LOG_DEBUG_IO("scan end in %i", cmd->cmd.scan->end_state);
+                       usbprog_end_state(cmd->cmd.scan->end_state);
+                       scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
+                       type = jtag_scan_type(cmd->cmd.scan);
+                       usbprog_scan(cmd->cmd.scan->ir_scan, type, buffer, scan_size);
+                       if (jtag_read_buffer(buffer, cmd->cmd.scan) != ERROR_OK)
+                               return ERROR_JTAG_QUEUE_FAILED;
+                       if (buffer)
+                               free(buffer);
+                       break;
+               case JTAG_SLEEP:
+                       LOG_DEBUG_IO("sleep %i", cmd->cmd.sleep->us);
+                       jtag_sleep(cmd->cmd.sleep->us);
+                       break;
+               default:
+                       LOG_ERROR("BUG: unknown JTAG command type encountered");
+                       exit(-1);
                }
 
                cmd = cmd->next;
@@ -272,10 +258,8 @@ static void usbprog_runtest(int num_cycles)
                usbprog_write(0, 0, 0);
        }
 
-#ifdef _DEBUG_JTAG_IO_
-       LOG_DEBUG("runtest: cur_state %s end_state %s", tap_state_name(
+       LOG_DEBUG_IO("runtest: cur_state %s end_state %s", tap_state_name(
                        tap_get_state()), tap_state_name(tap_get_end_state()));
-#endif
 
        /* finish in end_state */
        /*
@@ -614,6 +598,7 @@ static void usbprog_jtag_tms_send(struct usbprog_jtag *usbprog_jtag)
 
 struct jtag_interface usbprog_interface = {
        .name = "usbprog",
+       .transports = jtag_only,
 
        .execute_queue = usbprog_execute_queue,
        .init = usbprog_init,