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

m68k: Dispatch nvram_ops calls to Atari or Mac functions

A multi-platform kernel binary has to decide at run-time how to dispatch
the arch_nvram_ops calls. Add a platform-independent arch_nvram_ops
struct for this, to replace the atari-specific one.

Enable CONFIG_HAVE_ARCH_NVRAM_OPS for Macs.
Acked-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
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 458c77f3
...@@ -27,6 +27,7 @@ config MAC ...@@ -27,6 +27,7 @@ config MAC
bool "Macintosh support" bool "Macintosh support"
depends on MMU depends on MMU
select MMU_MOTOROLA if MMU select MMU_MOTOROLA if MMU
select HAVE_ARCH_NVRAM_OPS
help help
This option enables support for the Apple Macintosh series of This option enables support for the Apple Macintosh series of
computers (yes, there is experimental support now, at least for part computers (yes, there is experimental support now, at least for part
......
...@@ -74,7 +74,7 @@ static void __nvram_set_checksum(void) ...@@ -74,7 +74,7 @@ static void __nvram_set_checksum(void)
__nvram_write_byte(sum, ATARI_CKS_LOC + 1); __nvram_write_byte(sum, ATARI_CKS_LOC + 1);
} }
static long atari_nvram_set_checksum(void) long atari_nvram_set_checksum(void)
{ {
spin_lock_irq(&rtc_lock); spin_lock_irq(&rtc_lock);
__nvram_set_checksum(); __nvram_set_checksum();
...@@ -82,7 +82,7 @@ static long atari_nvram_set_checksum(void) ...@@ -82,7 +82,7 @@ static long atari_nvram_set_checksum(void)
return 0; return 0;
} }
static long atari_nvram_initialize(void) long atari_nvram_initialize(void)
{ {
loff_t i; loff_t i;
...@@ -94,7 +94,7 @@ static long atari_nvram_initialize(void) ...@@ -94,7 +94,7 @@ static long atari_nvram_initialize(void)
return 0; return 0;
} }
static ssize_t atari_nvram_read(char *buf, size_t count, loff_t *ppos) ssize_t atari_nvram_read(char *buf, size_t count, loff_t *ppos)
{ {
char *p = buf; char *p = buf;
loff_t i; loff_t i;
...@@ -112,7 +112,7 @@ static ssize_t atari_nvram_read(char *buf, size_t count, loff_t *ppos) ...@@ -112,7 +112,7 @@ static ssize_t atari_nvram_read(char *buf, size_t count, loff_t *ppos)
return p - buf; return p - buf;
} }
static ssize_t atari_nvram_write(char *buf, size_t count, loff_t *ppos) ssize_t atari_nvram_write(char *buf, size_t count, loff_t *ppos)
{ {
char *p = buf; char *p = buf;
loff_t i; loff_t i;
...@@ -131,22 +131,11 @@ static ssize_t atari_nvram_write(char *buf, size_t count, loff_t *ppos) ...@@ -131,22 +131,11 @@ static ssize_t atari_nvram_write(char *buf, size_t count, loff_t *ppos)
return p - buf; return p - buf;
} }
static ssize_t atari_nvram_get_size(void) ssize_t atari_nvram_get_size(void)
{ {
if (!MACH_IS_ATARI)
return -ENODEV;
return NVRAM_BYTES; return NVRAM_BYTES;
} }
const struct nvram_ops arch_nvram_ops = {
.read = atari_nvram_read,
.write = atari_nvram_write,
.get_size = atari_nvram_get_size,
.set_checksum = atari_nvram_set_checksum,
.initialize = atari_nvram_initialize,
};
EXPORT_SYMBOL(arch_nvram_ops);
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
static struct { static struct {
unsigned char val; unsigned char val;
......
...@@ -33,6 +33,12 @@ extern int atari_dont_touch_floppy_select; ...@@ -33,6 +33,12 @@ extern int atari_dont_touch_floppy_select;
extern int atari_SCC_reset_done; extern int atari_SCC_reset_done;
extern ssize_t atari_nvram_read(char *, size_t, loff_t *);
extern ssize_t atari_nvram_write(char *, size_t, loff_t *);
extern ssize_t atari_nvram_get_size(void);
extern long atari_nvram_set_checksum(void);
extern long atari_nvram_initialize(void);
/* convenience macros for testing machine type */ /* convenience macros for testing machine type */
#define MACH_IS_ST ((atari_mch_cookie >> 16) == ATARI_MCH_ST) #define MACH_IS_ST ((atari_mch_cookie >> 16) == ATARI_MCH_ST)
#define MACH_IS_STE ((atari_mch_cookie >> 16) == ATARI_MCH_STE && \ #define MACH_IS_STE ((atari_mch_cookie >> 16) == ATARI_MCH_STE && \
......
...@@ -19,6 +19,10 @@ extern void mac_init_IRQ(void); ...@@ -19,6 +19,10 @@ extern void mac_init_IRQ(void);
extern void mac_irq_enable(struct irq_data *data); extern void mac_irq_enable(struct irq_data *data);
extern void mac_irq_disable(struct irq_data *data); extern void mac_irq_disable(struct irq_data *data);
extern unsigned char mac_pram_read_byte(int);
extern void mac_pram_write_byte(unsigned char, int);
extern ssize_t mac_pram_get_size(void);
/* /*
* Macintosh Table * Macintosh Table
*/ */
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/nvram.h>
#include <linux/initrd.h> #include <linux/initrd.h>
#include <asm/bootinfo.h> #include <asm/bootinfo.h>
...@@ -37,13 +38,14 @@ ...@@ -37,13 +38,14 @@
#ifdef CONFIG_AMIGA #ifdef CONFIG_AMIGA
#include <asm/amigahw.h> #include <asm/amigahw.h>
#endif #endif
#ifdef CONFIG_ATARI
#include <asm/atarihw.h> #include <asm/atarihw.h>
#ifdef CONFIG_ATARI
#include <asm/atari_stram.h> #include <asm/atari_stram.h>
#endif #endif
#ifdef CONFIG_SUN3X #ifdef CONFIG_SUN3X
#include <asm/dvma.h> #include <asm/dvma.h>
#endif #endif
#include <asm/macintosh.h>
#include <asm/natfeat.h> #include <asm/natfeat.h>
#if !FPSTATESIZE || !NR_IRQS #if !FPSTATESIZE || !NR_IRQS
...@@ -547,3 +549,81 @@ static int __init adb_probe_sync_enable (char *str) { ...@@ -547,3 +549,81 @@ static int __init adb_probe_sync_enable (char *str) {
__setup("adb_sync", adb_probe_sync_enable); __setup("adb_sync", adb_probe_sync_enable);
#endif /* CONFIG_ADB */ #endif /* CONFIG_ADB */
#if IS_ENABLED(CONFIG_NVRAM)
#ifdef CONFIG_MAC
static unsigned char m68k_nvram_read_byte(int addr)
{
if (MACH_IS_MAC)
return mac_pram_read_byte(addr);
return 0xff;
}
static void m68k_nvram_write_byte(unsigned char val, int addr)
{
if (MACH_IS_MAC)
mac_pram_write_byte(val, addr);
}
#endif /* CONFIG_MAC */
#ifdef CONFIG_ATARI
static ssize_t m68k_nvram_read(char *buf, size_t count, loff_t *ppos)
{
if (MACH_IS_ATARI)
return atari_nvram_read(buf, count, ppos);
else if (MACH_IS_MAC)
return nvram_read_bytes(buf, count, ppos);
return -EINVAL;
}
static ssize_t m68k_nvram_write(char *buf, size_t count, loff_t *ppos)
{
if (MACH_IS_ATARI)
return atari_nvram_write(buf, count, ppos);
else if (MACH_IS_MAC)
return nvram_write_bytes(buf, count, ppos);
return -EINVAL;
}
static long m68k_nvram_set_checksum(void)
{
if (MACH_IS_ATARI)
return atari_nvram_set_checksum();
return -EINVAL;
}
static long m68k_nvram_initialize(void)
{
if (MACH_IS_ATARI)
return atari_nvram_initialize();
return -EINVAL;
}
#endif /* CONFIG_ATARI */
static ssize_t m68k_nvram_get_size(void)
{
if (MACH_IS_ATARI)
return atari_nvram_get_size();
else if (MACH_IS_MAC)
return mac_pram_get_size();
return -ENODEV;
}
/* Atari device drivers call .read (to get checksum validation) whereas
* Mac and PowerMac device drivers just use .read_byte.
*/
const struct nvram_ops arch_nvram_ops = {
#ifdef CONFIG_MAC
.read_byte = m68k_nvram_read_byte,
.write_byte = m68k_nvram_write_byte,
#endif
#ifdef CONFIG_ATARI
.read = m68k_nvram_read,
.write = m68k_nvram_write,
.set_checksum = m68k_nvram_set_checksum,
.initialize = m68k_nvram_initialize,
#endif
.get_size = m68k_nvram_get_size,
};
EXPORT_SYMBOL(arch_nvram_ops);
#endif /* CONFIG_NVRAM */
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
static void (*rom_reset)(void); static void (*rom_reset)(void);
#if IS_ENABLED(CONFIG_NVRAM)
#ifdef CONFIG_ADB_CUDA #ifdef CONFIG_ADB_CUDA
static unsigned char cuda_pram_read_byte(int offset) static unsigned char cuda_pram_read_byte(int offset)
{ {
...@@ -84,6 +85,7 @@ static void pmu_pram_write_byte(unsigned char data, int offset) ...@@ -84,6 +85,7 @@ static void pmu_pram_write_byte(unsigned char data, int offset)
pmu_wait_complete(&req); pmu_wait_complete(&req);
} }
#endif /* CONFIG_ADB_PMU */ #endif /* CONFIG_ADB_PMU */
#endif /* CONFIG_NVRAM */
/* /*
* VIA PRAM/RTC access routines * VIA PRAM/RTC access routines
...@@ -205,6 +207,7 @@ static void via_rtc_command(int command, __u8 *data) ...@@ -205,6 +207,7 @@ static void via_rtc_command(int command, __u8 *data)
local_irq_restore(flags); local_irq_restore(flags);
} }
#if IS_ENABLED(CONFIG_NVRAM)
static unsigned char via_pram_read_byte(int offset) static unsigned char via_pram_read_byte(int offset)
{ {
unsigned char temp; unsigned char temp;
...@@ -227,6 +230,7 @@ static void via_pram_write_byte(unsigned char data, int offset) ...@@ -227,6 +230,7 @@ static void via_pram_write_byte(unsigned char data, int offset)
temp = 0x55 | RTC_FLG_WRITE_PROTECT; temp = 0x55 | RTC_FLG_WRITE_PROTECT;
via_rtc_command(RTC_CMD_WRITE(RTC_REG_WRITE_PROTECT), &temp); via_rtc_command(RTC_CMD_WRITE(RTC_REG_WRITE_PROTECT), &temp);
} }
#endif /* CONFIG_NVRAM */
/* /*
* Return the current time in seconds since January 1, 1904. * Return the current time in seconds since January 1, 1904.
...@@ -372,6 +376,7 @@ static void cuda_shutdown(void) ...@@ -372,6 +376,7 @@ static void cuda_shutdown(void)
*------------------------------------------------------------------- *-------------------------------------------------------------------
*/ */
#if IS_ENABLED(CONFIG_NVRAM)
unsigned char mac_pram_read_byte(int addr) unsigned char mac_pram_read_byte(int addr)
{ {
switch (macintosh_config->adb_type) { switch (macintosh_config->adb_type) {
...@@ -417,6 +422,12 @@ void mac_pram_write_byte(unsigned char val, int addr) ...@@ -417,6 +422,12 @@ void mac_pram_write_byte(unsigned char val, int addr)
} }
} }
ssize_t mac_pram_get_size(void)
{
return 256;
}
#endif /* CONFIG_NVRAM */
void mac_poweroff(void) void mac_poweroff(void)
{ {
if (oss_present) { if (oss_present) {
......
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