nuttx/drivers/power/pm.h
zhuyanlin 79bcc662d9 power:driver: move pm_auto_update to outer dir
Pm_auto_update maybe called by outter PM users

Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>
2022-04-02 00:11:00 +08:00

147 lines
4.0 KiB
C

/****************************************************************************
* drivers/power/pm.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __DRIVERS_POWER_PM_H
#define __DRIVERS_POWER_PM_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <queue.h>
#include <nuttx/semaphore.h>
#include <nuttx/clock.h>
#include <nuttx/power/pm.h>
#include <nuttx/wdog.h>
#include <nuttx/wqueue.h>
#ifdef CONFIG_PM
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Types
****************************************************************************/
/* This describes the activity and state for one domain */
struct pm_domain_s
{
/* The current state for this PM domain (as determined by an
* explicit call to pm_changestate())
*/
uint8_t state;
/* The power state lock count */
uint16_t stay[PM_COUNT];
/* Auto update or not */
bool auto_update;
#if defined(CONFIG_SCHED_WORKQUEUE)
/* The worker of update callback */
struct work_s update_work;
#endif
/* A pointer to the PM governor instance */
FAR const struct pm_governor_s *governor;
};
/* This structure encapsulates all of the global data used by the PM system */
struct pm_global_s
{
/* This semaphore manages mutually exclusive access to the power management
* registry. It must be initialized to the value 1.
*/
sem_t regsem;
/* registry is a doubly-linked list of registered power management
* callback structures. To ensure mutually exclusive access, this list
* must be locked by calling pm_lock() before it is accessed.
*/
dq_queue_t registry;
/* The state information for each PM domain */
struct pm_domain_s domain[CONFIG_PM_NDOMAINS];
};
/****************************************************************************
* Public Data
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
# define EXTERN extern "C"
extern "C"
{
#else
# define EXTERN extern
#endif
/* All PM global data: */
EXTERN struct pm_global_s g_pmglobals;
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: pm_lock
*
* Description:
* Lock the power management operation.
*
****************************************************************************/
irqstate_t pm_lock(void);
/****************************************************************************
* Name: pm_unlock
*
* Description:
* Unlock the power management operation.
*
****************************************************************************/
void pm_unlock(irqstate_t flags);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* CONFIG_PM */
#endif /* #define __DRIVERS_POWER_PM_H */