12c2e6ecfSDeepthi Dharwar /* 22c2e6ecfSDeepthi Dharwar * cpuidle-powernv - idle state cpuidle driver. 32c2e6ecfSDeepthi Dharwar * Adapted from drivers/cpuidle/cpuidle-pseries 42c2e6ecfSDeepthi Dharwar * 52c2e6ecfSDeepthi Dharwar */ 62c2e6ecfSDeepthi Dharwar 72c2e6ecfSDeepthi Dharwar #include <linux/kernel.h> 82c2e6ecfSDeepthi Dharwar #include <linux/module.h> 92c2e6ecfSDeepthi Dharwar #include <linux/init.h> 102c2e6ecfSDeepthi Dharwar #include <linux/moduleparam.h> 112c2e6ecfSDeepthi Dharwar #include <linux/cpuidle.h> 122c2e6ecfSDeepthi Dharwar #include <linux/cpu.h> 132c2e6ecfSDeepthi Dharwar #include <linux/notifier.h> 140d948730SPreeti U Murthy #include <linux/clockchips.h> 150888839cSPreeti U Murthy #include <linux/of.h> 1692c83ff5SPreeti U Murthy #include <linux/slab.h> 172c2e6ecfSDeepthi Dharwar 182c2e6ecfSDeepthi Dharwar #include <asm/machdep.h> 192c2e6ecfSDeepthi Dharwar #include <asm/firmware.h> 208eb8ac89SShreyas B. Prabhu #include <asm/opal.h> 21591ac0cbSNicolas Pitre #include <asm/runlatch.h> 222c2e6ecfSDeepthi Dharwar 233005c597SShreyas B. Prabhu #define POWERNV_THRESHOLD_LATENCY_NS 200000 243005c597SShreyas B. Prabhu 252c2e6ecfSDeepthi Dharwar struct cpuidle_driver powernv_idle_driver = { 262c2e6ecfSDeepthi Dharwar .name = "powernv_idle", 272c2e6ecfSDeepthi Dharwar .owner = THIS_MODULE, 282c2e6ecfSDeepthi Dharwar }; 292c2e6ecfSDeepthi Dharwar 302c2e6ecfSDeepthi Dharwar static int max_idle_state; 312c2e6ecfSDeepthi Dharwar static struct cpuidle_state *cpuidle_state_table; 323005c597SShreyas B. Prabhu 333005c597SShreyas B. Prabhu static u64 stop_psscr_table[CPUIDLE_STATE_MAX]; 343005c597SShreyas B. Prabhu 3578eaa10fSShilpasri G Bhat static u64 snooze_timeout; 3678eaa10fSShilpasri G Bhat static bool snooze_timeout_en; 372c2e6ecfSDeepthi Dharwar 382c2e6ecfSDeepthi Dharwar static int snooze_loop(struct cpuidle_device *dev, 392c2e6ecfSDeepthi Dharwar struct cpuidle_driver *drv, 402c2e6ecfSDeepthi Dharwar int index) 412c2e6ecfSDeepthi Dharwar { 4278eaa10fSShilpasri G Bhat u64 snooze_exit_time; 4378eaa10fSShilpasri G Bhat 442c2e6ecfSDeepthi Dharwar local_irq_enable(); 452c2e6ecfSDeepthi Dharwar set_thread_flag(TIF_POLLING_NRFLAG); 462c2e6ecfSDeepthi Dharwar 4778eaa10fSShilpasri G Bhat snooze_exit_time = get_tb() + snooze_timeout; 48591ac0cbSNicolas Pitre ppc64_runlatch_off(); 492c2e6ecfSDeepthi Dharwar while (!need_resched()) { 502c2e6ecfSDeepthi Dharwar HMT_low(); 512c2e6ecfSDeepthi Dharwar HMT_very_low(); 5278eaa10fSShilpasri G Bhat if (snooze_timeout_en && get_tb() > snooze_exit_time) 5378eaa10fSShilpasri G Bhat break; 542c2e6ecfSDeepthi Dharwar } 552c2e6ecfSDeepthi Dharwar 562c2e6ecfSDeepthi Dharwar HMT_medium(); 57591ac0cbSNicolas Pitre ppc64_runlatch_on(); 582c2e6ecfSDeepthi Dharwar clear_thread_flag(TIF_POLLING_NRFLAG); 592c2e6ecfSDeepthi Dharwar smp_mb(); 602c2e6ecfSDeepthi Dharwar return index; 612c2e6ecfSDeepthi Dharwar } 622c2e6ecfSDeepthi Dharwar 632c2e6ecfSDeepthi Dharwar static int nap_loop(struct cpuidle_device *dev, 642c2e6ecfSDeepthi Dharwar struct cpuidle_driver *drv, 652c2e6ecfSDeepthi Dharwar int index) 662c2e6ecfSDeepthi Dharwar { 67591ac0cbSNicolas Pitre ppc64_runlatch_off(); 682c2e6ecfSDeepthi Dharwar power7_idle(); 69591ac0cbSNicolas Pitre ppc64_runlatch_on(); 702c2e6ecfSDeepthi Dharwar return index; 712c2e6ecfSDeepthi Dharwar } 722c2e6ecfSDeepthi Dharwar 73cc5a2f7bSpreeti /* Register for fastsleep only in oneshot mode of broadcast */ 74cc5a2f7bSpreeti #ifdef CONFIG_TICK_ONESHOT 750d948730SPreeti U Murthy static int fastsleep_loop(struct cpuidle_device *dev, 760d948730SPreeti U Murthy struct cpuidle_driver *drv, 770d948730SPreeti U Murthy int index) 780d948730SPreeti U Murthy { 790d948730SPreeti U Murthy unsigned long old_lpcr = mfspr(SPRN_LPCR); 800d948730SPreeti U Murthy unsigned long new_lpcr; 810d948730SPreeti U Murthy 820d948730SPreeti U Murthy if (unlikely(system_state < SYSTEM_RUNNING)) 830d948730SPreeti U Murthy return index; 840d948730SPreeti U Murthy 850d948730SPreeti U Murthy new_lpcr = old_lpcr; 869b6a68d9SMichael Neuling /* Do not exit powersave upon decrementer as we've setup the timer 879b6a68d9SMichael Neuling * offload. 880d948730SPreeti U Murthy */ 899b6a68d9SMichael Neuling new_lpcr &= ~LPCR_PECE1; 900d948730SPreeti U Murthy 910d948730SPreeti U Murthy mtspr(SPRN_LPCR, new_lpcr); 920d948730SPreeti U Murthy power7_sleep(); 930d948730SPreeti U Murthy 940d948730SPreeti U Murthy mtspr(SPRN_LPCR, old_lpcr); 950d948730SPreeti U Murthy 960d948730SPreeti U Murthy return index; 970d948730SPreeti U Murthy } 98cc5a2f7bSpreeti #endif 993005c597SShreyas B. Prabhu 1003005c597SShreyas B. Prabhu static int stop_loop(struct cpuidle_device *dev, 1013005c597SShreyas B. Prabhu struct cpuidle_driver *drv, 1023005c597SShreyas B. Prabhu int index) 1033005c597SShreyas B. Prabhu { 1043005c597SShreyas B. Prabhu ppc64_runlatch_off(); 1053005c597SShreyas B. Prabhu power9_idle_stop(stop_psscr_table[index]); 1063005c597SShreyas B. Prabhu ppc64_runlatch_on(); 1073005c597SShreyas B. Prabhu return index; 1083005c597SShreyas B. Prabhu } 1093005c597SShreyas B. Prabhu 1102c2e6ecfSDeepthi Dharwar /* 1112c2e6ecfSDeepthi Dharwar * States for dedicated partition case. 1122c2e6ecfSDeepthi Dharwar */ 113169f3faeSShreyas B. Prabhu static struct cpuidle_state powernv_states[CPUIDLE_STATE_MAX] = { 1142c2e6ecfSDeepthi Dharwar { /* Snooze */ 1152c2e6ecfSDeepthi Dharwar .name = "snooze", 1162c2e6ecfSDeepthi Dharwar .desc = "snooze", 1172c2e6ecfSDeepthi Dharwar .exit_latency = 0, 1182c2e6ecfSDeepthi Dharwar .target_residency = 0, 119957efcedSShreyas B. Prabhu .enter = snooze_loop }, 1202c2e6ecfSDeepthi Dharwar }; 1212c2e6ecfSDeepthi Dharwar 1222c2e6ecfSDeepthi Dharwar static int powernv_cpuidle_add_cpu_notifier(struct notifier_block *n, 1232c2e6ecfSDeepthi Dharwar unsigned long action, void *hcpu) 1242c2e6ecfSDeepthi Dharwar { 1252c2e6ecfSDeepthi Dharwar int hotcpu = (unsigned long)hcpu; 1262c2e6ecfSDeepthi Dharwar struct cpuidle_device *dev = 1272c2e6ecfSDeepthi Dharwar per_cpu(cpuidle_devices, hotcpu); 1282c2e6ecfSDeepthi Dharwar 1292c2e6ecfSDeepthi Dharwar if (dev && cpuidle_get_driver()) { 1302c2e6ecfSDeepthi Dharwar switch (action) { 1312c2e6ecfSDeepthi Dharwar case CPU_ONLINE: 1322c2e6ecfSDeepthi Dharwar case CPU_ONLINE_FROZEN: 1332c2e6ecfSDeepthi Dharwar cpuidle_pause_and_lock(); 1342c2e6ecfSDeepthi Dharwar cpuidle_enable_device(dev); 1352c2e6ecfSDeepthi Dharwar cpuidle_resume_and_unlock(); 1362c2e6ecfSDeepthi Dharwar break; 1372c2e6ecfSDeepthi Dharwar 1382c2e6ecfSDeepthi Dharwar case CPU_DEAD: 1392c2e6ecfSDeepthi Dharwar case CPU_DEAD_FROZEN: 1402c2e6ecfSDeepthi Dharwar cpuidle_pause_and_lock(); 1412c2e6ecfSDeepthi Dharwar cpuidle_disable_device(dev); 1422c2e6ecfSDeepthi Dharwar cpuidle_resume_and_unlock(); 1432c2e6ecfSDeepthi Dharwar break; 1442c2e6ecfSDeepthi Dharwar 1452c2e6ecfSDeepthi Dharwar default: 1462c2e6ecfSDeepthi Dharwar return NOTIFY_DONE; 1472c2e6ecfSDeepthi Dharwar } 1482c2e6ecfSDeepthi Dharwar } 1492c2e6ecfSDeepthi Dharwar return NOTIFY_OK; 1502c2e6ecfSDeepthi Dharwar } 1512c2e6ecfSDeepthi Dharwar 1522c2e6ecfSDeepthi Dharwar static struct notifier_block setup_hotplug_notifier = { 1532c2e6ecfSDeepthi Dharwar .notifier_call = powernv_cpuidle_add_cpu_notifier, 1542c2e6ecfSDeepthi Dharwar }; 1552c2e6ecfSDeepthi Dharwar 1562c2e6ecfSDeepthi Dharwar /* 1572c2e6ecfSDeepthi Dharwar * powernv_cpuidle_driver_init() 1582c2e6ecfSDeepthi Dharwar */ 1592c2e6ecfSDeepthi Dharwar static int powernv_cpuidle_driver_init(void) 1602c2e6ecfSDeepthi Dharwar { 1612c2e6ecfSDeepthi Dharwar int idle_state; 1622c2e6ecfSDeepthi Dharwar struct cpuidle_driver *drv = &powernv_idle_driver; 1632c2e6ecfSDeepthi Dharwar 1642c2e6ecfSDeepthi Dharwar drv->state_count = 0; 1652c2e6ecfSDeepthi Dharwar 1662c2e6ecfSDeepthi Dharwar for (idle_state = 0; idle_state < max_idle_state; ++idle_state) { 1672c2e6ecfSDeepthi Dharwar /* Is the state not enabled? */ 1682c2e6ecfSDeepthi Dharwar if (cpuidle_state_table[idle_state].enter == NULL) 1692c2e6ecfSDeepthi Dharwar continue; 1702c2e6ecfSDeepthi Dharwar 1712c2e6ecfSDeepthi Dharwar drv->states[drv->state_count] = /* structure copy */ 1722c2e6ecfSDeepthi Dharwar cpuidle_state_table[idle_state]; 1732c2e6ecfSDeepthi Dharwar 1742c2e6ecfSDeepthi Dharwar drv->state_count += 1; 1752c2e6ecfSDeepthi Dharwar } 1762c2e6ecfSDeepthi Dharwar 1772c2e6ecfSDeepthi Dharwar return 0; 1782c2e6ecfSDeepthi Dharwar } 1792c2e6ecfSDeepthi Dharwar 1800888839cSPreeti U Murthy static int powernv_add_idle_states(void) 1810888839cSPreeti U Murthy { 1820888839cSPreeti U Murthy struct device_node *power_mgt; 1830888839cSPreeti U Murthy int nr_idle_states = 1; /* Snooze */ 1840888839cSPreeti U Murthy int dt_idle_states; 185957efcedSShreyas B. Prabhu u32 latency_ns[CPUIDLE_STATE_MAX]; 186957efcedSShreyas B. Prabhu u32 residency_ns[CPUIDLE_STATE_MAX]; 187957efcedSShreyas B. Prabhu u32 flags[CPUIDLE_STATE_MAX]; 1883005c597SShreyas B. Prabhu u64 psscr_val[CPUIDLE_STATE_MAX]; 1893005c597SShreyas B. Prabhu const char *names[CPUIDLE_STATE_MAX]; 19092c83ff5SPreeti U Murthy int i, rc; 1910888839cSPreeti U Murthy 1920888839cSPreeti U Murthy /* Currently we have snooze statically defined */ 1930888839cSPreeti U Murthy 1940888839cSPreeti U Murthy power_mgt = of_find_node_by_path("/ibm,opal/power-mgt"); 1950888839cSPreeti U Murthy if (!power_mgt) { 1960888839cSPreeti U Murthy pr_warn("opal: PowerMgmt Node not found\n"); 19792c83ff5SPreeti U Murthy goto out; 1980888839cSPreeti U Murthy } 1990888839cSPreeti U Murthy 20070734a78SPreeti U Murthy /* Read values of any property to determine the num of idle states */ 20170734a78SPreeti U Murthy dt_idle_states = of_property_count_u32_elems(power_mgt, "ibm,cpu-idle-state-flags"); 20270734a78SPreeti U Murthy if (dt_idle_states < 0) { 20370734a78SPreeti U Murthy pr_warn("cpuidle-powernv: no idle states found in the DT\n"); 20492c83ff5SPreeti U Murthy goto out; 20574aa51b5SPreeti U. Murthy } 20674aa51b5SPreeti U. Murthy 207957efcedSShreyas B. Prabhu /* 208957efcedSShreyas B. Prabhu * Since snooze is used as first idle state, max idle states allowed is 209957efcedSShreyas B. Prabhu * CPUIDLE_STATE_MAX -1 210957efcedSShreyas B. Prabhu */ 211957efcedSShreyas B. Prabhu if (dt_idle_states > CPUIDLE_STATE_MAX - 1) { 212957efcedSShreyas B. Prabhu pr_warn("cpuidle-powernv: discovered idle states more than allowed"); 213957efcedSShreyas B. Prabhu dt_idle_states = CPUIDLE_STATE_MAX - 1; 214957efcedSShreyas B. Prabhu } 215957efcedSShreyas B. Prabhu 21670734a78SPreeti U Murthy if (of_property_read_u32_array(power_mgt, 21770734a78SPreeti U Murthy "ibm,cpu-idle-state-flags", flags, dt_idle_states)) { 21870734a78SPreeti U Murthy pr_warn("cpuidle-powernv : missing ibm,cpu-idle-state-flags in DT\n"); 219957efcedSShreyas B. Prabhu goto out; 22070734a78SPreeti U Murthy } 2210888839cSPreeti U Murthy 222957efcedSShreyas B. Prabhu if (of_property_read_u32_array(power_mgt, 223957efcedSShreyas B. Prabhu "ibm,cpu-idle-state-latencies-ns", latency_ns, 224957efcedSShreyas B. Prabhu dt_idle_states)) { 22592c83ff5SPreeti U Murthy pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-latencies-ns in DT\n"); 226957efcedSShreyas B. Prabhu goto out; 22792c83ff5SPreeti U Murthy } 2283005c597SShreyas B. Prabhu if (of_property_read_string_array(power_mgt, 2293005c597SShreyas B. Prabhu "ibm,cpu-idle-state-names", names, dt_idle_states) < 0) { 2303005c597SShreyas B. Prabhu pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-names in DT\n"); 2313005c597SShreyas B. Prabhu goto out; 2323005c597SShreyas B. Prabhu } 2333005c597SShreyas B. Prabhu 2343005c597SShreyas B. Prabhu /* 2353005c597SShreyas B. Prabhu * If the idle states use stop instruction, probe for psscr values 2363005c597SShreyas B. Prabhu * which are necessary to specify required stop level. 2373005c597SShreyas B. Prabhu */ 2383005c597SShreyas B. Prabhu if (flags[0] & (OPAL_PM_STOP_INST_FAST | OPAL_PM_STOP_INST_DEEP)) 2393005c597SShreyas B. Prabhu if (of_property_read_u64_array(power_mgt, 2403005c597SShreyas B. Prabhu "ibm,cpu-idle-state-psscr", psscr_val, dt_idle_states)) { 2413005c597SShreyas B. Prabhu pr_warn("cpuidle-powernv: missing ibm,cpu-idle-states-psscr in DT\n"); 2423005c597SShreyas B. Prabhu goto out; 2433005c597SShreyas B. Prabhu } 24492c83ff5SPreeti U Murthy 24592c83ff5SPreeti U Murthy rc = of_property_read_u32_array(power_mgt, 24692c83ff5SPreeti U Murthy "ibm,cpu-idle-state-residency-ns", residency_ns, dt_idle_states); 24792c83ff5SPreeti U Murthy 2480888839cSPreeti U Murthy for (i = 0; i < dt_idle_states; i++) { 2493005c597SShreyas B. Prabhu /* 2503005c597SShreyas B. Prabhu * If an idle state has exit latency beyond 2513005c597SShreyas B. Prabhu * POWERNV_THRESHOLD_LATENCY_NS then don't use it 2523005c597SShreyas B. Prabhu * in cpu-idle. 2533005c597SShreyas B. Prabhu */ 2543005c597SShreyas B. Prabhu if (latency_ns[i] > POWERNV_THRESHOLD_LATENCY_NS) 2553005c597SShreyas B. Prabhu continue; 2560888839cSPreeti U Murthy 25792c83ff5SPreeti U Murthy /* 25892c83ff5SPreeti U Murthy * Cpuidle accepts exit_latency and target_residency in us. 25992c83ff5SPreeti U Murthy * Use default target_residency values if f/w does not expose it. 26074aa51b5SPreeti U. Murthy */ 26170734a78SPreeti U Murthy if (flags[i] & OPAL_PM_NAP_ENABLED) { 2620888839cSPreeti U Murthy /* Add NAP state */ 2630888839cSPreeti U Murthy strcpy(powernv_states[nr_idle_states].name, "Nap"); 2640888839cSPreeti U Murthy strcpy(powernv_states[nr_idle_states].desc, "Nap"); 265b82b6ccaSDaniel Lezcano powernv_states[nr_idle_states].flags = 0; 26692c83ff5SPreeti U Murthy powernv_states[nr_idle_states].target_residency = 100; 267957efcedSShreyas B. Prabhu powernv_states[nr_idle_states].enter = nap_loop; 2683005c597SShreyas B. Prabhu } else if ((flags[i] & OPAL_PM_STOP_INST_FAST) && 2693005c597SShreyas B. Prabhu !(flags[i] & OPAL_PM_TIMEBASE_STOP)) { 2703005c597SShreyas B. Prabhu strncpy(powernv_states[nr_idle_states].name, 2713005c597SShreyas B. Prabhu names[i], CPUIDLE_NAME_LEN); 2723005c597SShreyas B. Prabhu strncpy(powernv_states[nr_idle_states].desc, 2733005c597SShreyas B. Prabhu names[i], CPUIDLE_NAME_LEN); 2743005c597SShreyas B. Prabhu powernv_states[nr_idle_states].flags = 0; 2753005c597SShreyas B. Prabhu 2763005c597SShreyas B. Prabhu powernv_states[nr_idle_states].enter = stop_loop; 2773005c597SShreyas B. Prabhu stop_psscr_table[nr_idle_states] = psscr_val[i]; 278cc5a2f7bSpreeti } 279cc5a2f7bSpreeti 280cc5a2f7bSpreeti /* 281cc5a2f7bSpreeti * All cpuidle states with CPUIDLE_FLAG_TIMER_STOP set must come 282cc5a2f7bSpreeti * within this config dependency check. 283cc5a2f7bSpreeti */ 284cc5a2f7bSpreeti #ifdef CONFIG_TICK_ONESHOT 285cc5a2f7bSpreeti if (flags[i] & OPAL_PM_SLEEP_ENABLED || 28670734a78SPreeti U Murthy flags[i] & OPAL_PM_SLEEP_ENABLED_ER1) { 2870888839cSPreeti U Murthy /* Add FASTSLEEP state */ 2880888839cSPreeti U Murthy strcpy(powernv_states[nr_idle_states].name, "FastSleep"); 2890888839cSPreeti U Murthy strcpy(powernv_states[nr_idle_states].desc, "FastSleep"); 290b82b6ccaSDaniel Lezcano powernv_states[nr_idle_states].flags = CPUIDLE_FLAG_TIMER_STOP; 29192c83ff5SPreeti U Murthy powernv_states[nr_idle_states].target_residency = 300000; 292957efcedSShreyas B. Prabhu powernv_states[nr_idle_states].enter = fastsleep_loop; 2933005c597SShreyas B. Prabhu } else if ((flags[i] & OPAL_PM_STOP_INST_DEEP) && 2943005c597SShreyas B. Prabhu (flags[i] & OPAL_PM_TIMEBASE_STOP)) { 2953005c597SShreyas B. Prabhu strncpy(powernv_states[nr_idle_states].name, 2963005c597SShreyas B. Prabhu names[i], CPUIDLE_NAME_LEN); 2973005c597SShreyas B. Prabhu strncpy(powernv_states[nr_idle_states].desc, 2983005c597SShreyas B. Prabhu names[i], CPUIDLE_NAME_LEN); 2993005c597SShreyas B. Prabhu 3003005c597SShreyas B. Prabhu powernv_states[nr_idle_states].flags = CPUIDLE_FLAG_TIMER_STOP; 3013005c597SShreyas B. Prabhu powernv_states[nr_idle_states].enter = stop_loop; 3023005c597SShreyas B. Prabhu stop_psscr_table[nr_idle_states] = psscr_val[i]; 3030888839cSPreeti U Murthy } 304cc5a2f7bSpreeti #endif 30592c83ff5SPreeti U Murthy powernv_states[nr_idle_states].exit_latency = 30692c83ff5SPreeti U Murthy ((unsigned int)latency_ns[i]) / 1000; 30792c83ff5SPreeti U Murthy 30892c83ff5SPreeti U Murthy if (!rc) { 30992c83ff5SPreeti U Murthy powernv_states[nr_idle_states].target_residency = 31092c83ff5SPreeti U Murthy ((unsigned int)residency_ns[i]) / 1000; 31192c83ff5SPreeti U Murthy } 31292c83ff5SPreeti U Murthy 31392c83ff5SPreeti U Murthy nr_idle_states++; 31492c83ff5SPreeti U Murthy } 31592c83ff5SPreeti U Murthy out: 3160888839cSPreeti U Murthy return nr_idle_states; 3170888839cSPreeti U Murthy } 3180888839cSPreeti U Murthy 3192c2e6ecfSDeepthi Dharwar /* 3202c2e6ecfSDeepthi Dharwar * powernv_idle_probe() 3212c2e6ecfSDeepthi Dharwar * Choose state table for shared versus dedicated partition 3222c2e6ecfSDeepthi Dharwar */ 3232c2e6ecfSDeepthi Dharwar static int powernv_idle_probe(void) 3242c2e6ecfSDeepthi Dharwar { 3252c2e6ecfSDeepthi Dharwar if (cpuidle_disable != IDLE_NO_OVERRIDE) 3262c2e6ecfSDeepthi Dharwar return -ENODEV; 3272c2e6ecfSDeepthi Dharwar 328e4d54f71SStewart Smith if (firmware_has_feature(FW_FEATURE_OPAL)) { 3292c2e6ecfSDeepthi Dharwar cpuidle_state_table = powernv_states; 3300888839cSPreeti U Murthy /* Device tree can indicate more idle states */ 3310888839cSPreeti U Murthy max_idle_state = powernv_add_idle_states(); 33278eaa10fSShilpasri G Bhat if (max_idle_state > 1) { 33378eaa10fSShilpasri G Bhat snooze_timeout_en = true; 33478eaa10fSShilpasri G Bhat snooze_timeout = powernv_states[1].target_residency * 33578eaa10fSShilpasri G Bhat tb_ticks_per_usec; 33678eaa10fSShilpasri G Bhat } 3372c2e6ecfSDeepthi Dharwar } else 3382c2e6ecfSDeepthi Dharwar return -ENODEV; 3392c2e6ecfSDeepthi Dharwar 3402c2e6ecfSDeepthi Dharwar return 0; 3412c2e6ecfSDeepthi Dharwar } 3422c2e6ecfSDeepthi Dharwar 3432c2e6ecfSDeepthi Dharwar static int __init powernv_processor_idle_init(void) 3442c2e6ecfSDeepthi Dharwar { 3452c2e6ecfSDeepthi Dharwar int retval; 3462c2e6ecfSDeepthi Dharwar 3472c2e6ecfSDeepthi Dharwar retval = powernv_idle_probe(); 3482c2e6ecfSDeepthi Dharwar if (retval) 3492c2e6ecfSDeepthi Dharwar return retval; 3502c2e6ecfSDeepthi Dharwar 3512c2e6ecfSDeepthi Dharwar powernv_cpuidle_driver_init(); 3522c2e6ecfSDeepthi Dharwar retval = cpuidle_register(&powernv_idle_driver, NULL); 3532c2e6ecfSDeepthi Dharwar if (retval) { 3542c2e6ecfSDeepthi Dharwar printk(KERN_DEBUG "Registration of powernv driver failed.\n"); 3552c2e6ecfSDeepthi Dharwar return retval; 3562c2e6ecfSDeepthi Dharwar } 3572c2e6ecfSDeepthi Dharwar 3582c2e6ecfSDeepthi Dharwar register_cpu_notifier(&setup_hotplug_notifier); 3592c2e6ecfSDeepthi Dharwar printk(KERN_DEBUG "powernv_idle_driver registered\n"); 3602c2e6ecfSDeepthi Dharwar return 0; 3612c2e6ecfSDeepthi Dharwar } 3622c2e6ecfSDeepthi Dharwar 3632c2e6ecfSDeepthi Dharwar device_initcall(powernv_processor_idle_init); 364