25 #include <linux/kernel.h>
27 #include <linux/types.h>
29 #include <asm/machdep.h>
30 #include <asm/nvram.h>
33 static void __iomem *mmio_nvram_start;
34 static long mmio_nvram_len;
41 if (*index >= mmio_nvram_len)
43 if (*index + count > mmio_nvram_len)
44 count = mmio_nvram_len - *
index;
50 spin_unlock_irqrestore(&mmio_nvram_lock, flags);
56 static unsigned char mmio_nvram_read_val(
int addr)
61 if (addr >= mmio_nvram_len)
66 val =
ioread8(mmio_nvram_start + addr);
68 spin_unlock_irqrestore(&mmio_nvram_lock, flags);
73 static ssize_t mmio_nvram_write(
char *buf,
size_t count, loff_t *index)
77 if (*index >= mmio_nvram_len)
79 if (*index + count > mmio_nvram_len)
80 count = mmio_nvram_len - *
index;
86 spin_unlock_irqrestore(&mmio_nvram_lock, flags);
96 if (addr < mmio_nvram_len) {
99 iowrite8(val, mmio_nvram_start + addr);
101 spin_unlock_irqrestore(&mmio_nvram_lock, flags);
105 static ssize_t mmio_nvram_get_size(
void)
107 return mmio_nvram_len;
113 unsigned long nvram_addr;
131 nvram_addr = r.
start;
132 mmio_nvram_len = resource_size(&r);
133 if ( (!mmio_nvram_len) || (!nvram_addr) ) {
139 mmio_nvram_start =
ioremap(nvram_addr, mmio_nvram_len);
140 if (!mmio_nvram_start) {
147 mmio_nvram_len >> 10, nvram_addr, mmio_nvram_start);
149 ppc_md.nvram_read_val = mmio_nvram_read_val;
151 ppc_md.nvram_read = mmio_nvram_read;
152 ppc_md.nvram_write = mmio_nvram_write;
153 ppc_md.nvram_size = mmio_nvram_get_size;
156 of_node_put(nvram_node);