diff options
| author | Martyn Welch <martyn.welch@gefanuc.com> | 2009-07-02 02:12:18 -0400 |
|---|---|---|
| committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2009-08-19 20:29:22 -0400 |
| commit | 690a2d074ead1867ca5a1976284ca1c89ebc04c6 (patch) | |
| tree | 2d82a04036c49e01c7de1d57bdc976b6878c6347 | |
| parent | ae142e0c52b38e44d28b12f77c6e7faa96f7a069 (diff) | |
powerpc/nvram: Allow byte length reads from mmio NVRAM driver
Add a byte length read and write interface compatible with the
nvram_generic driver interface to the mmio driver.
Signed-off-by: Martyn Welch <martyn.welch@gefanuc.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
| -rw-r--r-- | arch/powerpc/sysdev/mmio_nvram.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/arch/powerpc/sysdev/mmio_nvram.c b/arch/powerpc/sysdev/mmio_nvram.c index 7b49633a4bd0..207324209065 100644 --- a/arch/powerpc/sysdev/mmio_nvram.c +++ b/arch/powerpc/sysdev/mmio_nvram.c | |||
| @@ -53,6 +53,23 @@ static ssize_t mmio_nvram_read(char *buf, size_t count, loff_t *index) | |||
| 53 | return count; | 53 | return count; |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | static unsigned char mmio_nvram_read_val(int addr) | ||
| 57 | { | ||
| 58 | unsigned long flags; | ||
| 59 | unsigned char val; | ||
| 60 | |||
| 61 | if (addr >= mmio_nvram_len) | ||
| 62 | return 0xff; | ||
| 63 | |||
| 64 | spin_lock_irqsave(&mmio_nvram_lock, flags); | ||
| 65 | |||
| 66 | val = ioread8(mmio_nvram_start + addr); | ||
| 67 | |||
| 68 | spin_unlock_irqrestore(&mmio_nvram_lock, flags); | ||
| 69 | |||
| 70 | return val; | ||
| 71 | } | ||
| 72 | |||
| 56 | static ssize_t mmio_nvram_write(char *buf, size_t count, loff_t *index) | 73 | static ssize_t mmio_nvram_write(char *buf, size_t count, loff_t *index) |
| 57 | { | 74 | { |
| 58 | unsigned long flags; | 75 | unsigned long flags; |
| @@ -72,6 +89,19 @@ static ssize_t mmio_nvram_write(char *buf, size_t count, loff_t *index) | |||
| 72 | return count; | 89 | return count; |
| 73 | } | 90 | } |
| 74 | 91 | ||
| 92 | void mmio_nvram_write_val(int addr, unsigned char val) | ||
| 93 | { | ||
| 94 | unsigned long flags; | ||
| 95 | |||
| 96 | if (addr < mmio_nvram_len) { | ||
| 97 | spin_lock_irqsave(&mmio_nvram_lock, flags); | ||
| 98 | |||
| 99 | iowrite8(val, mmio_nvram_start + addr); | ||
| 100 | |||
| 101 | spin_unlock_irqrestore(&mmio_nvram_lock, flags); | ||
| 102 | } | ||
| 103 | } | ||
| 104 | |||
| 75 | static ssize_t mmio_nvram_get_size(void) | 105 | static ssize_t mmio_nvram_get_size(void) |
| 76 | { | 106 | { |
| 77 | return mmio_nvram_len; | 107 | return mmio_nvram_len; |
| @@ -114,6 +144,8 @@ int __init mmio_nvram_init(void) | |||
| 114 | printk(KERN_INFO "mmio NVRAM, %luk at 0x%lx mapped to %p\n", | 144 | printk(KERN_INFO "mmio NVRAM, %luk at 0x%lx mapped to %p\n", |
| 115 | mmio_nvram_len >> 10, nvram_addr, mmio_nvram_start); | 145 | mmio_nvram_len >> 10, nvram_addr, mmio_nvram_start); |
| 116 | 146 | ||
| 147 | ppc_md.nvram_read_val = mmio_nvram_read_val; | ||
| 148 | ppc_md.nvram_write_val = mmio_nvram_write_val; | ||
| 117 | ppc_md.nvram_read = mmio_nvram_read; | 149 | ppc_md.nvram_read = mmio_nvram_read; |
| 118 | ppc_md.nvram_write = mmio_nvram_write; | 150 | ppc_md.nvram_write = mmio_nvram_write; |
| 119 | ppc_md.nvram_size = mmio_nvram_get_size; | 151 | ppc_md.nvram_size = mmio_nvram_get_size; |
