Path: blob/main/sys/contrib/vchiq/interface/vchiq_arm/vchiq_arm.h
48383 views
/**1* Copyright (c) 2014 Raspberry Pi (Trading) Ltd. All rights reserved.2* Copyright (c) 2010-2012 Broadcom. All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions, and the following disclaimer,9* without modification.10* 2. Redistributions in binary form must reproduce the above copyright11* notice, this list of conditions and the following disclaimer in the12* documentation and/or other materials provided with the distribution.13* 3. The names of the above-listed copyright holders may not be used14* to endorse or promote products derived from this software without15* specific prior written permission.16*17* ALTERNATIVELY, this software may be distributed under the terms of the18* GNU General Public License ("GPL") version 2, as published by the Free19* Software Foundation.20*21* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS22* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,23* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR24* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR25* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,26* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,27* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR28* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF29* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING30* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS31* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.32*/3334#ifndef VCHIQ_ARM_H35#define VCHIQ_ARM_H3637#include "vchiq_core.h"383940enum vc_suspend_status {41VC_SUSPEND_FORCE_CANCELED = -3, /* Force suspend canceled, too busy */42VC_SUSPEND_REJECTED = -2, /* Videocore rejected suspend request */43VC_SUSPEND_FAILED = -1, /* Videocore suspend failed */44VC_SUSPEND_IDLE = 0, /* VC active, no suspend actions */45VC_SUSPEND_REQUESTED, /* User has requested suspend */46VC_SUSPEND_IN_PROGRESS, /* Slot handler has recvd suspend request */47VC_SUSPEND_SUSPENDED /* Videocore suspend succeeded */48};4950enum vc_resume_status {51VC_RESUME_FAILED = -1, /* Videocore resume failed */52VC_RESUME_IDLE = 0, /* VC suspended, no resume actions */53VC_RESUME_REQUESTED, /* User has requested resume */54VC_RESUME_IN_PROGRESS, /* Slot handler has received resume request */55VC_RESUME_RESUMED /* Videocore resumed successfully (active) */56};575859enum USE_TYPE_E {60USE_TYPE_SERVICE,61USE_TYPE_SERVICE_NO_RESUME,62USE_TYPE_VCHIQ63};64656667typedef struct vchiq_arm_state_struct {68/* Keepalive-related data */69VCHIQ_THREAD_T ka_thread;70struct completion ka_evt;71atomic_t ka_use_count;72atomic_t ka_use_ack_count;73atomic_t ka_release_count;7475struct completion vc_suspend_complete;76struct completion vc_resume_complete;7778rwlock_t susp_res_lock;79enum vc_suspend_status vc_suspend_state;80enum vc_resume_status vc_resume_state;8182unsigned int wake_address;8384struct timer_list suspend_timer;85int suspend_timer_timeout;86int suspend_timer_running;8788/* Global use count for videocore.89** This is equal to the sum of the use counts for all services. When90** this hits zero the videocore suspend procedure will be initiated.91*/92int videocore_use_count;9394/* Use count to track requests from videocore peer.95** This use count is not associated with a service, so needs to be96** tracked separately with the state.97*/98int peer_use_count;99100/* Flag to indicate whether resume is blocked. This happens when the101** ARM is suspending102*/103struct completion resume_blocker;104int resume_blocked;105struct completion blocked_blocker;106int blocked_count;107108int autosuspend_override;109110/* Flag to indicate that the first vchiq connect has made it through.111** This means that both sides should be fully ready, and we should112** be able to suspend after this point.113*/114int first_connect;115116unsigned long long suspend_start_time;117unsigned long long sleep_start_time;118unsigned long long resume_start_time;119unsigned long long last_wake_time;120121} VCHIQ_ARM_STATE_T;122123extern int vchiq_arm_log_level;124extern int vchiq_susp_log_level;125126extern int __init127vchiq_platform_init(VCHIQ_STATE_T *state);128129extern void __exit130vchiq_platform_exit(VCHIQ_STATE_T *state);131132extern VCHIQ_STATE_T *133vchiq_get_state(void);134135extern VCHIQ_STATUS_T136vchiq_arm_vcsuspend(VCHIQ_STATE_T *state);137138extern VCHIQ_STATUS_T139vchiq_arm_force_suspend(VCHIQ_STATE_T *state);140141extern int142vchiq_arm_allow_resume(VCHIQ_STATE_T *state);143144extern VCHIQ_STATUS_T145vchiq_arm_vcresume(VCHIQ_STATE_T *state);146147extern VCHIQ_STATUS_T148vchiq_arm_init_state(VCHIQ_STATE_T *state, VCHIQ_ARM_STATE_T *arm_state);149150extern int151vchiq_check_resume(VCHIQ_STATE_T *state);152153extern void154vchiq_check_suspend(VCHIQ_STATE_T *state);155156VCHIQ_STATUS_T157vchiq_use_service(VCHIQ_SERVICE_HANDLE_T handle);158159extern VCHIQ_STATUS_T160vchiq_platform_suspend(VCHIQ_STATE_T *state);161162extern int163vchiq_platform_videocore_wanted(VCHIQ_STATE_T *state);164165extern int166vchiq_platform_use_suspend_timer(void);167168extern void169vchiq_dump_platform_use_state(VCHIQ_STATE_T *state);170171extern void172vchiq_dump_service_use_state(VCHIQ_STATE_T *state);173174extern VCHIQ_ARM_STATE_T*175vchiq_platform_get_arm_state(VCHIQ_STATE_T *state);176177extern int178vchiq_videocore_wanted(VCHIQ_STATE_T *state);179180extern VCHIQ_STATUS_T181vchiq_use_internal(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service,182enum USE_TYPE_E use_type);183extern VCHIQ_STATUS_T184vchiq_release_internal(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service);185186#ifdef notyet187extern VCHIQ_DEBUGFS_NODE_T *188vchiq_instance_get_debugfs_node(VCHIQ_INSTANCE_T instance);189#endif190191extern int192vchiq_instance_get_use_count(VCHIQ_INSTANCE_T instance);193194extern int195vchiq_instance_get_pid(VCHIQ_INSTANCE_T instance);196197extern int198vchiq_instance_get_trace(VCHIQ_INSTANCE_T instance);199200extern void201vchiq_instance_set_trace(VCHIQ_INSTANCE_T instance, int trace);202203extern void204set_suspend_state(VCHIQ_ARM_STATE_T *arm_state,205enum vc_suspend_status new_state);206207extern void208set_resume_state(VCHIQ_ARM_STATE_T *arm_state,209enum vc_resume_status new_state);210211extern void212start_suspend_timer(VCHIQ_ARM_STATE_T *arm_state);213214#endif /* VCHIQ_ARM_H */215216217