2011-09-04 21:24:27 +02:00
|
|
|
/****************************************************************************
|
2012-01-22 17:42:49 +01:00
|
|
|
* drivers/power/pm_initialize.c
|
2011-09-04 21:24:27 +02:00
|
|
|
*
|
2021-03-31 11:15:31 +02:00
|
|
|
* 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
|
2011-09-04 21:24:27 +02:00
|
|
|
*
|
2021-03-31 11:15:31 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2011-09-04 21:24:27 +02:00
|
|
|
*
|
2021-03-31 11:15:31 +02:00
|
|
|
* 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.
|
2011-09-04 21:24:27 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
2012-01-22 17:42:49 +01:00
|
|
|
#include <nuttx/power/pm.h>
|
2011-09-04 21:24:27 +02:00
|
|
|
|
2015-12-30 01:29:24 +01:00
|
|
|
#include "pm.h"
|
2011-09-04 21:24:27 +02:00
|
|
|
|
2019-11-09 16:09:33 +01:00
|
|
|
#if defined(CONFIG_PM_GOVERNOR_ACTIVITY)
|
|
|
|
# include "activity_governor.h"
|
|
|
|
#elif defined(CONFIG_PM_GOVERNOR_GREEDY)
|
|
|
|
# include "greedy_governor.h"
|
|
|
|
#endif
|
|
|
|
|
2011-09-04 21:24:27 +02:00
|
|
|
#ifdef CONFIG_PM
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Data
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/* All PM global data: */
|
|
|
|
|
2018-08-27 21:24:13 +02:00
|
|
|
/* Initialize the registry and the PM global data structures. The PM
|
|
|
|
* global data structure resides in .data which is zeroed at boot time. So
|
|
|
|
* it is only required to initialize non-zero elements of the PM global
|
|
|
|
* data structure here.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct pm_global_s g_pmglobals =
|
|
|
|
{
|
2022-03-26 21:51:22 +01:00
|
|
|
SEM_INITIALIZER(1)
|
2018-08-27 21:24:13 +02:00
|
|
|
};
|
2011-09-04 21:24:27 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: pm_initialize
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This function is called by MCU-specific one-time at power on reset in
|
|
|
|
* order to initialize the power management capabilities. This function
|
2018-08-19 19:19:43 +02:00
|
|
|
* must be called *very* early in the initialization sequence *before* any
|
2011-09-04 21:24:27 +02:00
|
|
|
* other device drivers are initialize (since they may attempt to register
|
|
|
|
* with the power management subsystem).
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Input Parameters:
|
2011-09-04 21:24:27 +02:00
|
|
|
* None.
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2011-09-04 21:24:27 +02:00
|
|
|
* None.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void pm_initialize(void)
|
|
|
|
{
|
2022-02-14 08:32:40 +01:00
|
|
|
FAR const struct pm_governor_s *gov;
|
|
|
|
int i;
|
2019-11-09 16:09:33 +01:00
|
|
|
|
2022-02-14 08:32:40 +01:00
|
|
|
/* Select governor */
|
2018-11-10 14:20:34 +01:00
|
|
|
|
2022-02-14 08:32:40 +01:00
|
|
|
for (i = 0; i < CONFIG_PM_NDOMAINS; i++)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_PM_GOVERNOR_GREEDY)
|
|
|
|
gov = pm_greedy_governor_initialize();
|
|
|
|
#elif defined(CONFIG_PM_GOVERNOR_ACTIVITY)
|
|
|
|
gov = pm_activity_governor_initialize();
|
|
|
|
#else
|
|
|
|
static struct pm_governor_s null;
|
|
|
|
gov = &null;
|
2019-11-09 16:09:33 +01:00
|
|
|
#endif
|
2022-02-14 08:32:40 +01:00
|
|
|
pm_set_governor(i, gov);
|
|
|
|
}
|
2011-09-04 21:24:27 +02:00
|
|
|
}
|
|
|
|
|
2015-12-30 01:29:24 +01:00
|
|
|
#endif /* CONFIG_PM */
|