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

TOMOYO Linux Cross Reference
Linux/arch/sparc/kernel/leon_pmc.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 /* leon_pmc.c: LEON Power-down cpu_idle() handler
  3  *
  4  * Copyright (C) 2011 Daniel Hellstrom (daniel@gaisler.com) Aeroflex Gaisler AB
  5  */
  6 
  7 #include <linux/init.h>
  8 #include <linux/pm.h>
  9 
 10 #include <asm/leon_amba.h>
 11 #include <asm/cpu_type.h>
 12 #include <asm/leon.h>
 13 #include <asm/processor.h>
 14 
 15 /* List of Systems that need fixup instructions around power-down instruction */
 16 static unsigned int pmc_leon_fixup_ids[] = {
 17         AEROFLEX_UT699,
 18         GAISLER_GR712RC,
 19         LEON4_NEXTREME1,
 20         0
 21 };
 22 
 23 static int pmc_leon_need_fixup(void)
 24 {
 25         unsigned int systemid = amba_system_id >> 16;
 26         unsigned int *id;
 27 
 28         id = &pmc_leon_fixup_ids[0];
 29         while (*id != 0) {
 30                 if (*id == systemid)
 31                         return 1;
 32                 id++;
 33         }
 34 
 35         return 0;
 36 }
 37 
 38 /*
 39  * CPU idle callback function for systems that need some extra handling
 40  * See .../arch/sparc/kernel/process.c
 41  */
 42 static void pmc_leon_idle_fixup(void)
 43 {
 44         /* Prepare an address to a non-cachable region. APB is always
 45          * none-cachable. One instruction is executed after the Sleep
 46          * instruction, we make sure to read the bus and throw away the
 47          * value by accessing a non-cachable area, also we make sure the
 48          * MMU does not get a TLB miss here by using the MMU BYPASS ASI.
 49          */
 50         register unsigned int address = (unsigned int)leon3_irqctrl_regs;
 51 
 52         /* Interrupts need to be enabled to not hang the CPU */
 53         raw_local_irq_enable();
 54 
 55         __asm__ __volatile__ (
 56                 "wr     %%g0, %%asr19\n"
 57                 "lda    [%0] %1, %%g0\n"
 58                 :
 59                 : "r"(address), "i"(ASI_LEON_BYPASS));
 60 
 61         raw_local_irq_disable();
 62 }
 63 
 64 /*
 65  * CPU idle callback function
 66  * See .../arch/sparc/kernel/process.c
 67  */
 68 static void pmc_leon_idle(void)
 69 {
 70         /* Interrupts need to be enabled to not hang the CPU */
 71         raw_local_irq_enable();
 72 
 73         /* For systems without power-down, this will be no-op */
 74         __asm__ __volatile__ ("wr       %g0, %asr19\n\t");
 75 
 76         raw_local_irq_disable();
 77 }
 78 
 79 /* Install LEON Power Down function */
 80 static int __init leon_pmc_install(void)
 81 {
 82         if (sparc_cpu_model == sparc_leon) {
 83                 /* Assign power management IDLE handler */
 84                 if (pmc_leon_need_fixup())
 85                         sparc_idle = pmc_leon_idle_fixup;
 86                 else
 87                         sparc_idle = pmc_leon_idle;
 88 
 89                 printk(KERN_INFO "leon: power management initialized\n");
 90         }
 91 
 92         return 0;
 93 }
 94 
 95 /* This driver is not critical to the boot process, don't care
 96  * if initialized late.
 97  */
 98 late_initcall(leon_pmc_install);
 99 

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

kernel.org | git.kernel.org | LWN.net | Project Home | 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.

sflogo.php