Commit f9c3a570 authored by Finn Thain's avatar Finn Thain Committed by Greg Kroah-Hartman

powerpc: Enable HAVE_ARCH_NVRAM_OPS and disable GENERIC_NVRAM

Switch PPC32 kernels from the generic_nvram module to the nvram module.

Also fix a theoretical bug where CHRP omits the chrp_nvram_init() call
when CONFIG_NVRAM_MODULE=m.
Tested-by: default avatarStan Johnson <userm57@yahoo.com>
Signed-off-by: default avatarFinn Thain <fthain@telegraphics.com.au>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 066ac5c3
...@@ -178,6 +178,7 @@ config PPC ...@@ -178,6 +178,7 @@ config PPC
select HAVE_ARCH_KGDB select HAVE_ARCH_KGDB
select HAVE_ARCH_MMAP_RND_BITS select HAVE_ARCH_MMAP_RND_BITS
select HAVE_ARCH_MMAP_RND_COMPAT_BITS if COMPAT select HAVE_ARCH_MMAP_RND_COMPAT_BITS if COMPAT
select HAVE_ARCH_NVRAM_OPS if PPC32
select HAVE_ARCH_SECCOMP_FILTER select HAVE_ARCH_SECCOMP_FILTER
select HAVE_ARCH_TRACEHOOK select HAVE_ARCH_TRACEHOOK
select HAVE_CBPF_JIT if !PPC64 select HAVE_CBPF_JIT if !PPC64
...@@ -274,11 +275,6 @@ config SYSVIPC_COMPAT ...@@ -274,11 +275,6 @@ config SYSVIPC_COMPAT
depends on COMPAT && SYSVIPC depends on COMPAT && SYSVIPC
default y default y
# All PPC32s use generic nvram driver through ppc_md
config GENERIC_NVRAM
bool
default y if PPC32
config SCHED_OMIT_FRAME_POINTER config SCHED_OMIT_FRAME_POINTER
bool bool
default y default y
......
...@@ -78,9 +78,6 @@ extern int pmac_get_partition(int partition); ...@@ -78,9 +78,6 @@ extern int pmac_get_partition(int partition);
extern u8 pmac_xpram_read(int xpaddr); extern u8 pmac_xpram_read(int xpaddr);
extern void pmac_xpram_write(int xpaddr, u8 data); extern void pmac_xpram_write(int xpaddr, u8 data);
/* Synchronize NVRAM */
extern void nvram_sync(void);
/* Initialize NVRAM OS partition */ /* Initialize NVRAM OS partition */
extern int __init nvram_init_os_partition(struct nvram_os_partition *part); extern int __init nvram_init_os_partition(struct nvram_os_partition *part);
......
...@@ -148,17 +148,6 @@ static int __init ppc_setup_l3cr(char *str) ...@@ -148,17 +148,6 @@ static int __init ppc_setup_l3cr(char *str)
} }
__setup("l3cr=", ppc_setup_l3cr); __setup("l3cr=", ppc_setup_l3cr);
#ifdef CONFIG_GENERIC_NVRAM
void nvram_sync(void)
{
if (ppc_md.nvram_sync)
ppc_md.nvram_sync();
}
EXPORT_SYMBOL(nvram_sync);
#endif /* CONFIG_NVRAM */
static int __init ppc_init(void) static int __init ppc_init(void)
{ {
/* clear the progress line */ /* clear the progress line */
......
obj-y += setup.o time.o pegasos_eth.o pci.o obj-y += setup.o time.o pegasos_eth.o pci.o
obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_SMP) += smp.o
obj-$(CONFIG_NVRAM) += nvram.o obj-$(CONFIG_NVRAM:m=y) += nvram.o
...@@ -550,7 +550,7 @@ static void __init chrp_init_IRQ(void) ...@@ -550,7 +550,7 @@ static void __init chrp_init_IRQ(void)
static void __init static void __init
chrp_init2(void) chrp_init2(void)
{ {
#ifdef CONFIG_NVRAM #if IS_ENABLED(CONFIG_NVRAM)
chrp_nvram_init(); chrp_nvram_init();
#endif #endif
......
...@@ -316,8 +316,7 @@ static void __init pmac_setup_arch(void) ...@@ -316,8 +316,7 @@ static void __init pmac_setup_arch(void)
find_via_pmu(); find_via_pmu();
smu_init(); smu_init();
#if defined(CONFIG_NVRAM) || defined(CONFIG_NVRAM_MODULE) || \ #if IS_ENABLED(CONFIG_NVRAM) || defined(CONFIG_PPC64)
defined(CONFIG_PPC64)
pmac_nvram_init(); pmac_nvram_init();
#endif #endif
#ifdef CONFIG_PPC32 #ifdef CONFIG_PPC32
......
...@@ -244,25 +244,24 @@ source "drivers/char/hw_random/Kconfig" ...@@ -244,25 +244,24 @@ source "drivers/char/hw_random/Kconfig"
config NVRAM config NVRAM
tristate "/dev/nvram support" tristate "/dev/nvram support"
depends on X86 || GENERIC_NVRAM || HAVE_ARCH_NVRAM_OPS depends on X86 || HAVE_ARCH_NVRAM_OPS
default M68K default M68K || PPC
---help--- ---help---
If you say Y here and create a character special file /dev/nvram If you say Y here and create a character special file /dev/nvram
with major number 10 and minor number 144 using mknod ("man mknod"), with major number 10 and minor number 144 using mknod ("man mknod"),
you get read and write access to the extra bytes of non-volatile you get read and write access to the non-volatile memory.
memory in the real time clock (RTC), which is contained in every PC
and most Ataris. The actual number of bytes varies, depending on the /dev/nvram may be used to view settings in NVRAM or to change them
nvram in the system, but is usually 114 (128-14 for the RTC). (with some utility). It could also be used to frequently
This memory is conventionally called "CMOS RAM" on PCs and "NVRAM"
on Ataris. /dev/nvram may be used to view settings there, or to
change them (with some utility). It could also be used to frequently
save a few bits of very important data that may not be lost over save a few bits of very important data that may not be lost over
power-off and for which writing to disk is too insecure. Note power-off and for which writing to disk is too insecure. Note
however that most NVRAM space in a PC belongs to the BIOS and you however that most NVRAM space in a PC belongs to the BIOS and you
should NEVER idly tamper with it. See Ralf Brown's interrupt list should NEVER idly tamper with it. See Ralf Brown's interrupt list
for a guide to the use of CMOS bytes by your BIOS. for a guide to the use of CMOS bytes by your BIOS.
This memory is conventionally called "NVRAM" on PowerPC machines,
"CMOS RAM" on PCs, "NVRAM" on Ataris and "PRAM" on Macintoshes.
To compile this driver as a module, choose M here: the To compile this driver as a module, choose M here: the
module will be called nvram. module will be called nvram.
......
...@@ -5,6 +5,10 @@ ...@@ -5,6 +5,10 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <uapi/linux/nvram.h> #include <uapi/linux/nvram.h>
#ifdef CONFIG_PPC
#include <asm/machdep.h>
#endif
/** /**
* struct nvram_ops - NVRAM functionality made available to drivers * struct nvram_ops - NVRAM functionality made available to drivers
* @read: validate checksum (if any) then load a range of bytes from NVRAM * @read: validate checksum (if any) then load a range of bytes from NVRAM
...@@ -42,6 +46,8 @@ extern const struct nvram_ops arch_nvram_ops; ...@@ -42,6 +46,8 @@ extern const struct nvram_ops arch_nvram_ops;
static inline ssize_t nvram_get_size(void) static inline ssize_t nvram_get_size(void)
{ {
#ifdef CONFIG_PPC #ifdef CONFIG_PPC
if (ppc_md.nvram_size)
return ppc_md.nvram_size();
#else #else
if (arch_nvram_ops.get_size) if (arch_nvram_ops.get_size)
return arch_nvram_ops.get_size(); return arch_nvram_ops.get_size();
...@@ -52,6 +58,8 @@ static inline ssize_t nvram_get_size(void) ...@@ -52,6 +58,8 @@ static inline ssize_t nvram_get_size(void)
static inline unsigned char nvram_read_byte(int addr) static inline unsigned char nvram_read_byte(int addr)
{ {
#ifdef CONFIG_PPC #ifdef CONFIG_PPC
if (ppc_md.nvram_read_val)
return ppc_md.nvram_read_val(addr);
#else #else
if (arch_nvram_ops.read_byte) if (arch_nvram_ops.read_byte)
return arch_nvram_ops.read_byte(addr); return arch_nvram_ops.read_byte(addr);
...@@ -62,6 +70,8 @@ static inline unsigned char nvram_read_byte(int addr) ...@@ -62,6 +70,8 @@ static inline unsigned char nvram_read_byte(int addr)
static inline void nvram_write_byte(unsigned char val, int addr) static inline void nvram_write_byte(unsigned char val, int addr)
{ {
#ifdef CONFIG_PPC #ifdef CONFIG_PPC
if (ppc_md.nvram_write_val)
ppc_md.nvram_write_val(addr, val);
#else #else
if (arch_nvram_ops.write_byte) if (arch_nvram_ops.write_byte)
arch_nvram_ops.write_byte(val, addr); arch_nvram_ops.write_byte(val, addr);
...@@ -98,15 +108,25 @@ static inline ssize_t nvram_write_bytes(char *buf, size_t count, loff_t *ppos) ...@@ -98,15 +108,25 @@ static inline ssize_t nvram_write_bytes(char *buf, size_t count, loff_t *ppos)
static inline ssize_t nvram_read(char *buf, size_t count, loff_t *ppos) static inline ssize_t nvram_read(char *buf, size_t count, loff_t *ppos)
{ {
#ifdef CONFIG_PPC
if (ppc_md.nvram_read)
return ppc_md.nvram_read(buf, count, ppos);
#else
if (arch_nvram_ops.read) if (arch_nvram_ops.read)
return arch_nvram_ops.read(buf, count, ppos); return arch_nvram_ops.read(buf, count, ppos);
#endif
return nvram_read_bytes(buf, count, ppos); return nvram_read_bytes(buf, count, ppos);
} }
static inline ssize_t nvram_write(char *buf, size_t count, loff_t *ppos) static inline ssize_t nvram_write(char *buf, size_t count, loff_t *ppos)
{ {
#ifdef CONFIG_PPC
if (ppc_md.nvram_write)
return ppc_md.nvram_write(buf, count, ppos);
#else
if (arch_nvram_ops.write) if (arch_nvram_ops.write)
return arch_nvram_ops.write(buf, count, ppos); return arch_nvram_ops.write(buf, count, ppos);
#endif
return nvram_write_bytes(buf, count, ppos); return nvram_write_bytes(buf, count, ppos);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment