drm/amd/display: add aux arbitration logic
authorCharlene Liu <charlene.liu@amd.com>
Thu, 24 Aug 2017 21:12:48 +0000 (17:12 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 26 Sep 2017 22:17:15 +0000 (18:17 -0400)
Signed-off-by: Charlene Liu <charlene.liu@amd.com>
Reviewed-by: Tony Cheng <Tony.Cheng@amd.com>
Acked-by: Harry Wentland <Harry.Wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/i2caux/aux_engine.c
drivers/gpu/drm/amd/display/dc/i2caux/aux_engine.h
drivers/gpu/drm/amd/display/dc/i2caux/dce110/aux_engine_dce110.c

index 667660f3fa26135388ccecadcced2af4fbacc13b..3c9608ce94b88bff42ca7a89df491fd93159a01c 100644 (file)
@@ -69,6 +69,12 @@ bool dal_aux_engine_acquire(
        struct aux_engine *aux_engine = FROM_ENGINE(engine);
 
        enum gpio_result result;
+       if (aux_engine->funcs->is_engine_available) {
+               /*check whether SW could use the engine*/
+               if (!aux_engine->funcs->is_engine_available(aux_engine)) {
+                       return false;
+               }
+       }
 
        result = dal_ddc_open(ddc, GPIO_MODE_HARDWARE,
                GPIO_DDC_CONFIG_TYPE_MODE_AUX);
index b5d6c79eb029a516c8727198273282b87e829eb6..40b202893772bebedf4df22a96b104f49ebb3fc0 100644 (file)
@@ -86,6 +86,8 @@ struct aux_engine_funcs {
        enum aux_channel_operation_result (*get_channel_status)(
                struct aux_engine *engine,
                uint8_t *returned_bytes);
+       bool (*is_engine_available) (
+               struct aux_engine *engine);
 };
 
 struct aux_engine {
index f49fd1ad380721cc23ad0ecaf882af4b5b9e910f..98ce0fe5ac3739085bbd51fb9c66e2bee28e4d41 100644 (file)
@@ -93,15 +93,36 @@ static void destroy(
 }
 
 #define SW_CAN_ACCESS_AUX 1
+#define DMCU_CAN_ACCESS_AUX 2
 
+static bool is_engine_available(
+       struct aux_engine *engine)
+{
+       struct aux_engine_dce110 *aux110 = FROM_AUX_ENGINE(engine);
+
+       uint32_t value = REG_READ(AUX_ARB_CONTROL);
+       uint32_t field = get_reg_field_value(
+                       value,
+                       AUX_ARB_CONTROL,
+                       AUX_REG_RW_CNTL_STATUS);
+
+       return (field != DMCU_CAN_ACCESS_AUX);
+}
 static bool acquire_engine(
        struct aux_engine *engine)
 {
        struct aux_engine_dce110 *aux110 = FROM_AUX_ENGINE(engine);
 
+       uint32_t value = REG_READ(AUX_ARB_CONTROL);
+       uint32_t field = get_reg_field_value(
+                       value,
+                       AUX_ARB_CONTROL,
+                       AUX_REG_RW_CNTL_STATUS);
+       if (field == DMCU_CAN_ACCESS_AUX)
+        return false;
        /* enable AUX before request SW to access AUX */
-       uint32_t value = REG_READ(AUX_CONTROL);
-       uint32_t field = get_reg_field_value(value,
+       value = REG_READ(AUX_CONTROL);
+       field = get_reg_field_value(value,
                                AUX_CONTROL,
                                AUX_EN);
 
@@ -395,6 +416,7 @@ static const struct aux_engine_funcs aux_engine_funcs = {
        .submit_channel_request = submit_channel_request,
        .process_channel_reply = process_channel_reply,
        .get_channel_status = get_channel_status,
+       .is_engine_available = is_engine_available,
 };
 
 static const struct engine_funcs engine_funcs = {
@@ -425,6 +447,10 @@ static bool construct(
 static void destruct(
        struct aux_engine_dce110 *engine)
 {
+       struct aux_engine_dce110 *aux110 = engine;
+/*temp w/a, to do*/
+       REG_UPDATE(AUX_ARB_CONTROL, AUX_DMCU_DONE_USING_AUX_REG, 1);
+       REG_UPDATE(AUX_ARB_CONTROL, AUX_SW_DONE_USING_AUX_REG, 1);
        dal_aux_engine_destruct(&engine->base);
 }