Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

m68k/mac: Fix PRAM accessors

PMU-based m68k Macs pre-date PowerMac-style NVRAM. Use the appropriate
PMU commands. Also implement the missing XPRAM accessors for VIA-based
Macs.

Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Tested-by: Stan Johnson <userm57@yahoo.com>
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Finn Thain and committed by
Greg Kroah-Hartman
aefcb746 a71fa0e3

+35 -10
+33 -10
arch/m68k/mac/misc.c
··· 66 66 { 67 67 struct adb_request req; 68 68 69 - if (pmu_request(&req, NULL, 3, PMU_READ_NVRAM, 70 - (offset >> 8) & 0xFF, offset & 0xFF) < 0) 69 + if (pmu_request(&req, NULL, 3, PMU_READ_XPRAM, 70 + offset & 0xFF, 1) < 0) 71 71 return 0; 72 - while (!req.complete) 73 - pmu_poll(); 74 - return req.reply[3]; 72 + pmu_wait_complete(&req); 73 + 74 + return req.reply[0]; 75 75 } 76 76 77 77 static void pmu_pram_write_byte(unsigned char data, int offset) 78 78 { 79 79 struct adb_request req; 80 80 81 - if (pmu_request(&req, NULL, 4, PMU_WRITE_NVRAM, 82 - (offset >> 8) & 0xFF, offset & 0xFF, data) < 0) 81 + if (pmu_request(&req, NULL, 4, PMU_WRITE_XPRAM, 82 + offset & 0xFF, 1, data) < 0) 83 83 return; 84 - while (!req.complete) 85 - pmu_poll(); 84 + pmu_wait_complete(&req); 86 85 } 87 86 #endif /* CONFIG_ADB_PMU */ 88 87 ··· 151 152 #define RTC_REG_WRITE_PROTECT 13 152 153 153 154 /* 155 + * Inside Mac has no information about two-byte RTC commands but 156 + * the MAME/MESS source code has the essentials. 157 + */ 158 + 159 + #define RTC_REG_XPRAM 14 160 + #define RTC_CMD_XPRAM_READ (RTC_CMD_READ(RTC_REG_XPRAM) << 8) 161 + #define RTC_CMD_XPRAM_WRITE (RTC_CMD_WRITE(RTC_REG_XPRAM) << 8) 162 + #define RTC_CMD_XPRAM_ARG(a) (((a & 0xE0) << 3) | ((a & 0x1F) << 2)) 163 + 164 + /* 154 165 * Execute a VIA PRAM/RTC command. For read commands 155 166 * data should point to a one-byte buffer for the 156 167 * resulting data. For write commands it should point ··· 207 198 208 199 static unsigned char via_pram_read_byte(int offset) 209 200 { 210 - return 0; 201 + unsigned char temp; 202 + 203 + via_rtc_command(RTC_CMD_XPRAM_READ | RTC_CMD_XPRAM_ARG(offset), &temp); 204 + 205 + return temp; 211 206 } 212 207 213 208 static void via_pram_write_byte(unsigned char data, int offset) 214 209 { 210 + unsigned char temp; 211 + 212 + temp = 0x55; 213 + via_rtc_command(RTC_CMD_WRITE(RTC_REG_WRITE_PROTECT), &temp); 214 + 215 + temp = data; 216 + via_rtc_command(RTC_CMD_XPRAM_WRITE | RTC_CMD_XPRAM_ARG(offset), &temp); 217 + 218 + temp = 0x55 | RTC_FLG_WRITE_PROTECT; 219 + via_rtc_command(RTC_CMD_WRITE(RTC_REG_WRITE_PROTECT), &temp); 215 220 } 216 221 217 222 /*
+2
include/uapi/linux/pmu.h
··· 19 19 #define PMU_POWER_CTRL 0x11 /* control power of some devices */ 20 20 #define PMU_ADB_CMD 0x20 /* send ADB packet */ 21 21 #define PMU_ADB_POLL_OFF 0x21 /* disable ADB auto-poll */ 22 + #define PMU_WRITE_XPRAM 0x32 /* write eXtended Parameter RAM */ 22 23 #define PMU_WRITE_NVRAM 0x33 /* write non-volatile RAM */ 24 + #define PMU_READ_XPRAM 0x3a /* read eXtended Parameter RAM */ 23 25 #define PMU_READ_NVRAM 0x3b /* read non-volatile RAM */ 24 26 #define PMU_SET_RTC 0x30 /* set real-time clock */ 25 27 #define PMU_READ_RTC 0x38 /* read real-time clock */