target: Added target clock tristating to the target attach and detach functions

This commit is contained in:
dragonmux 2022-08-10 01:30:05 +01:00 committed by Piotr Esden-Tempski
parent d4d6218234
commit 8cf1d2f09c
1 changed files with 6 additions and 3 deletions

View File

@ -185,9 +185,12 @@ target *target_attach(target *t, struct target_controller *tc)
t->tc->destroy_callback(t->tc, t); t->tc->destroy_callback(t->tc, t);
t->tc = tc; t->tc = tc;
platform_target_clk_output_enable(true);
if (!t->attach(t)) if (!t->attach(t)) {
platform_target_clk_output_enable(false);
return NULL; return NULL;
}
t->attached = true; t->attached = true;
return t; return t;
@ -378,6 +381,7 @@ void target_print_progress(platform_timeout *const timeout)
void target_detach(target *t) void target_detach(target *t)
{ {
t->detach(t); t->detach(t);
platform_target_clk_output_enable(false);
t->attached = false; t->attached = false;
#if PC_HOSTED == 1 #if PC_HOSTED == 1
platform_buffer_flush(); platform_buffer_flush();
@ -387,7 +391,6 @@ void target_detach(target *t)
bool target_check_error(target *t) { bool target_check_error(target *t) {
if (t) if (t)
return t->check_error(t); return t->check_error(t);
else
return false; return false;
} }