~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/arm/mach-imx/cpuidle-imx6q.c

Version: ~ [ linux-5.6-rc3 ] ~ [ linux-5.5.6 ] ~ [ linux-5.4.22 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.106 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.171 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.214 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.214 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.82 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Copyright (C) 2012 Freescale Semiconductor, Inc.
  3  *
  4  * This program is free software; you can redistribute it and/or modify
  5  * it under the terms of the GNU General Public License version 2 as
  6  * published by the Free Software Foundation.
  7  */
  8 
  9 #include <linux/cpuidle.h>
 10 #include <linux/module.h>
 11 #include <asm/cpuidle.h>
 12 #include <asm/proc-fns.h>
 13 
 14 #include "common.h"
 15 #include "cpuidle.h"
 16 #include "hardware.h"
 17 
 18 static atomic_t master = ATOMIC_INIT(0);
 19 static DEFINE_SPINLOCK(master_lock);
 20 
 21 static int imx6q_enter_wait(struct cpuidle_device *dev,
 22                             struct cpuidle_driver *drv, int index)
 23 {
 24         if (atomic_inc_return(&master) == num_online_cpus()) {
 25                 /*
 26                  * With this lock, we prevent other cpu to exit and enter
 27                  * this function again and become the master.
 28                  */
 29                 if (!spin_trylock(&master_lock))
 30                         goto idle;
 31                 imx6q_set_lpm(WAIT_UNCLOCKED);
 32                 cpu_do_idle();
 33                 imx6q_set_lpm(WAIT_CLOCKED);
 34                 spin_unlock(&master_lock);
 35                 goto done;
 36         }
 37 
 38 idle:
 39         cpu_do_idle();
 40 done:
 41         atomic_dec(&master);
 42 
 43         return index;
 44 }
 45 
 46 static struct cpuidle_driver imx6q_cpuidle_driver = {
 47         .name = "imx6q_cpuidle",
 48         .owner = THIS_MODULE,
 49         .states = {
 50                 /* WFI */
 51                 ARM_CPUIDLE_WFI_STATE,
 52                 /* WAIT */
 53                 {
 54                         .exit_latency = 50,
 55                         .target_residency = 75,
 56                         .flags = CPUIDLE_FLAG_TIMER_STOP,
 57                         .enter = imx6q_enter_wait,
 58                         .name = "WAIT",
 59                         .desc = "Clock off",
 60                 },
 61         },
 62         .state_count = 2,
 63         .safe_state_index = 0,
 64 };
 65 
 66 int __init imx6q_cpuidle_init(void)
 67 {
 68         /* Set INT_MEM_CLK_LPM bit to get a reliable WAIT mode support */
 69         imx6q_set_int_mem_clk_lpm(true);
 70 
 71         return cpuidle_register(&imx6q_cpuidle_driver, NULL);
 72 }
 73 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp