@@ -431,6 +431,44 @@ static int etm4x_wait_status(struct csdev_access *csa, int pos, int val)
431
431
return coresight_timeout (csa , TRCSTATR , pos , val );
432
432
}
433
433
434
+ static int etm4_enable_trace_unit (struct etmv4_drvdata * drvdata )
435
+ {
436
+ struct coresight_device * csdev = drvdata -> csdev ;
437
+ struct device * etm_dev = & csdev -> dev ;
438
+ struct csdev_access * csa = & csdev -> access ;
439
+
440
+ /*
441
+ * ETE mandates that the TRCRSR is written to before
442
+ * enabling it.
443
+ */
444
+ if (etm4x_is_ete (drvdata ))
445
+ etm4x_relaxed_write32 (csa , TRCRSR_TA , TRCRSR );
446
+
447
+ etm4x_allow_trace (drvdata );
448
+ /* Enable the trace unit */
449
+ etm4x_relaxed_write32 (csa , 1 , TRCPRGCTLR );
450
+
451
+ /* Synchronize the register updates for sysreg access */
452
+ if (!csa -> io_mem )
453
+ isb ();
454
+
455
+ /* wait for TRCSTATR.IDLE to go back down to '0' */
456
+ if (etm4x_wait_status (csa , TRCSTATR_IDLE_BIT , 0 )) {
457
+ dev_err (etm_dev ,
458
+ "timeout while waiting for Idle Trace Status\n" );
459
+ return - ETIME ;
460
+ }
461
+
462
+ /*
463
+ * As recommended by section 4.3.7 ("Synchronization when using the
464
+ * memory-mapped interface") of ARM IHI 0064D
465
+ */
466
+ dsb (sy );
467
+ isb ();
468
+
469
+ return 0 ;
470
+ }
471
+
434
472
static int etm4_enable_hw (struct etmv4_drvdata * drvdata )
435
473
{
436
474
int i , rc ;
@@ -539,33 +577,7 @@ static int etm4_enable_hw(struct etmv4_drvdata *drvdata)
539
577
etm4x_relaxed_write32 (csa , trcpdcr | TRCPDCR_PU , TRCPDCR );
540
578
}
541
579
542
- /*
543
- * ETE mandates that the TRCRSR is written to before
544
- * enabling it.
545
- */
546
- if (etm4x_is_ete (drvdata ))
547
- etm4x_relaxed_write32 (csa , TRCRSR_TA , TRCRSR );
548
-
549
- etm4x_allow_trace (drvdata );
550
- /* Enable the trace unit */
551
- etm4x_relaxed_write32 (csa , 1 , TRCPRGCTLR );
552
-
553
- /* Synchronize the register updates for sysreg access */
554
- if (!csa -> io_mem )
555
- isb ();
556
-
557
- /* wait for TRCSTATR.IDLE to go back down to '0' */
558
- if (etm4x_wait_status (csa , TRCSTATR_IDLE_BIT , 0 ))
559
- dev_err (etm_dev ,
560
- "timeout while waiting for Idle Trace Status\n" );
561
-
562
- /*
563
- * As recommended by section 4.3.7 ("Synchronization when using the
564
- * memory-mapped interface") of ARM IHI 0064D
565
- */
566
- dsb (sy );
567
- isb ();
568
-
580
+ rc = etm4_enable_trace_unit (drvdata );
569
581
done :
570
582
etm4_cs_lock (drvdata , csa );
571
583
@@ -884,25 +896,12 @@ static int etm4_enable(struct coresight_device *csdev, struct perf_event *event,
884
896
return ret ;
885
897
}
886
898
887
- static void etm4_disable_hw ( void * info )
899
+ static void etm4_disable_trace_unit ( struct etmv4_drvdata * drvdata )
888
900
{
889
901
u32 control ;
890
- struct etmv4_drvdata * drvdata = info ;
891
- struct etmv4_config * config = & drvdata -> config ;
892
902
struct coresight_device * csdev = drvdata -> csdev ;
893
903
struct device * etm_dev = & csdev -> dev ;
894
904
struct csdev_access * csa = & csdev -> access ;
895
- int i ;
896
-
897
- etm4_cs_unlock (drvdata , csa );
898
- etm4_disable_arch_specific (drvdata );
899
-
900
- if (!drvdata -> skip_power_up ) {
901
- /* power can be removed from the trace unit now */
902
- control = etm4x_relaxed_read32 (csa , TRCPDCR );
903
- control &= ~TRCPDCR_PU ;
904
- etm4x_relaxed_write32 (csa , control , TRCPDCR );
905
- }
906
905
907
906
control = etm4x_relaxed_read32 (csa , TRCPRGCTLR );
908
907
@@ -943,6 +942,28 @@ static void etm4_disable_hw(void *info)
943
942
* of ARM IHI 0064H.b.
944
943
*/
945
944
isb ();
945
+ }
946
+
947
+ static void etm4_disable_hw (void * info )
948
+ {
949
+ u32 control ;
950
+ struct etmv4_drvdata * drvdata = info ;
951
+ struct etmv4_config * config = & drvdata -> config ;
952
+ struct coresight_device * csdev = drvdata -> csdev ;
953
+ struct csdev_access * csa = & csdev -> access ;
954
+ int i ;
955
+
956
+ etm4_cs_unlock (drvdata , csa );
957
+ etm4_disable_arch_specific (drvdata );
958
+
959
+ if (!drvdata -> skip_power_up ) {
960
+ /* power can be removed from the trace unit now */
961
+ control = etm4x_relaxed_read32 (csa , TRCPDCR );
962
+ control &= ~TRCPDCR_PU ;
963
+ etm4x_relaxed_write32 (csa , control , TRCPDCR );
964
+ }
965
+
966
+ etm4_disable_trace_unit (drvdata );
946
967
947
968
/* read the status of the single shot comparators */
948
969
for (i = 0 ; i < drvdata -> nr_ss_cmp ; i ++ ) {
0 commit comments