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

TOMOYO Linux Cross Reference
Linux/arch/powerpc/platforms/powernv/opal-nvram.c

Version: ~ [ linux-5.11-rc3 ] ~ [ linux-5.10.7 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.89 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.167 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.215 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.251 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.251 ] ~ [ 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.85 ] ~ [ 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-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  * PowerNV nvram code.
  3  *
  4  * Copyright 2011 IBM Corp.
  5  *
  6  * This program is free software; you can redistribute it and/or
  7  * modify it under the terms of the GNU General Public License
  8  * as published by the Free Software Foundation; either version
  9  * 2 of the License, or (at your option) any later version.
 10  */
 11 
 12 #define DEBUG
 13 
 14 #include <linux/kernel.h>
 15 #include <linux/init.h>
 16 #include <linux/of.h>
 17 
 18 #include <asm/opal.h>
 19 #include <asm/nvram.h>
 20 #include <asm/machdep.h>
 21 
 22 static unsigned int nvram_size;
 23 
 24 static ssize_t opal_nvram_size(void)
 25 {
 26         return nvram_size;
 27 }
 28 
 29 static ssize_t opal_nvram_read(char *buf, size_t count, loff_t *index)
 30 {
 31         s64 rc;
 32         int off;
 33 
 34         if (*index >= nvram_size)
 35                 return 0;
 36         off = *index;
 37         if ((off + count) > nvram_size)
 38                 count = nvram_size - off;
 39         rc = opal_read_nvram(__pa(buf), count, off);
 40         if (rc != OPAL_SUCCESS)
 41                 return -EIO;
 42         *index += count;
 43         return count;
 44 }
 45 
 46 static ssize_t opal_nvram_write(char *buf, size_t count, loff_t *index)
 47 {
 48         s64 rc = OPAL_BUSY;
 49         int off;
 50 
 51         if (*index >= nvram_size)
 52                 return 0;
 53         off = *index;
 54         if ((off + count) > nvram_size)
 55                 count = nvram_size - off;
 56 
 57         while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) {
 58                 rc = opal_write_nvram(__pa(buf), count, off);
 59                 if (rc == OPAL_BUSY_EVENT)
 60                         opal_poll_events(NULL);
 61         }
 62         *index += count;
 63         return count;
 64 }
 65 
 66 static int __init opal_nvram_init_log_partitions(void)
 67 {
 68         /* Scan nvram for partitions */
 69         nvram_scan_partitions();
 70         nvram_init_oops_partition(0);
 71         return 0;
 72 }
 73 machine_arch_initcall(powernv, opal_nvram_init_log_partitions);
 74 
 75 void __init opal_nvram_init(void)
 76 {
 77         struct device_node *np;
 78         const __be32 *nbytes_p;
 79 
 80         np = of_find_compatible_node(NULL, NULL, "ibm,opal-nvram");
 81         if (np == NULL)
 82                 return;
 83 
 84         nbytes_p = of_get_property(np, "#bytes", NULL);
 85         if (!nbytes_p) {
 86                 of_node_put(np);
 87                 return;
 88         }
 89         nvram_size = be32_to_cpup(nbytes_p);
 90 
 91         pr_info("OPAL nvram setup, %u bytes\n", nvram_size);
 92         of_node_put(np);
 93 
 94         ppc_md.nvram_read = opal_nvram_read;
 95         ppc_md.nvram_write = opal_nvram_write;
 96         ppc_md.nvram_size = opal_nvram_size;
 97 }
 98 
 99 

~ [ 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