1/* 2 * Copyright (c) 2016 ARM Limited 3 * All rights reserved 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 * Authors: Andreas Sandberg 18 */ 19 20#include <libnomali/nomali.h> 21#include <inttypes.h> 22 23#include "nomali_test_helpers.h" 24#include "../lib/mali_midg_regmap.h" 25 26#define TEST_ASn_STATUS(n) \ 27 E_NOMALI_TEST_REG("AS" # n "_STATUS", h, MMU_AS_REG(n, ASn_STATUS), \ 28 value == 0) 29 30static void 31on_reset(nomali_handle_t h, void *usr) 32{ 33 E_NOMALI_BAIL(nomali_reg_write_raw(h, 0x0000, 0xC0FFEE)); 34} 35 36int 37main(int argc, char **argv) 38{ 39 const nomali_config_t cfg = { 40 .type = NOMALI_GPU_T60X, 41 .ver_maj = 0, 42 .ver_min = 1, 43 .ver_status = 0, 44 }; 45 46 nomali_callback_t reset_callback = { 47 .type = NOMALI_CALLBACK_RESET, 48 .usr = NULL, 49 .func.reset = &on_reset, 50 }; 51 52 nomali_handle_t h; 53 nomali_error_t error; 54 55 E_NOMALI_BAIL(nomali_create(&h, &cfg)); 56 57 NOMALI_TEST_REG("gpu_id", h, 0x0000, value == 0x69560010); 58 59 E_NOMALI_TEST("reg_callback", nomali_set_callback(h, &reset_callback)); 60 E_NOMALI_BAIL(nomali_reset(h)); 61 62 NOMALI_TEST_REG("custom_gpu_id", h, 0x0000, value == 0xC0FFEE); 63 64 E_NOMALI_BAIL(nomali_destroy(h)); 65 66 67 return 0; 68} 69