nvram.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. /*
  2. * Copyright (C) 2002 Benjamin Herrenschmidt (benh@kernel.crashing.org)
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version
  7. * 2 of the License, or (at your option) any later version.
  8. *
  9. * Todo: - add support for the OF persistent properties
  10. */
  11. #include <linux/export.h>
  12. #include <linux/kernel.h>
  13. #include <linux/stddef.h>
  14. #include <linux/string.h>
  15. #include <linux/nvram.h>
  16. #include <linux/init.h>
  17. #include <linux/delay.h>
  18. #include <linux/errno.h>
  19. #include <linux/adb.h>
  20. #include <linux/pmu.h>
  21. #include <linux/bootmem.h>
  22. #include <linux/completion.h>
  23. #include <linux/spinlock.h>
  24. #include <asm/sections.h>
  25. #include <asm/io.h>
  26. #include <asm/prom.h>
  27. #include <asm/machdep.h>
  28. #include <asm/nvram.h>
  29. #include "pmac.h"
  30. #define DEBUG
  31. #ifdef DEBUG
  32. #define DBG(x...) printk(x)
  33. #else
  34. #define DBG(x...)
  35. #endif
  36. #define NVRAM_SIZE 0x2000 /* 8kB of non-volatile RAM */
  37. #define CORE99_SIGNATURE 0x5a
  38. #define CORE99_ADLER_START 0x14
  39. /* On Core99, nvram is either a sharp, a micron or an AMD flash */
  40. #define SM_FLASH_STATUS_DONE 0x80
  41. #define SM_FLASH_STATUS_ERR 0x38
  42. #define SM_FLASH_CMD_ERASE_CONFIRM 0xd0
  43. #define SM_FLASH_CMD_ERASE_SETUP 0x20
  44. #define SM_FLASH_CMD_RESET 0xff
  45. #define SM_FLASH_CMD_WRITE_SETUP 0x40
  46. #define SM_FLASH_CMD_CLEAR_STATUS 0x50
  47. #define SM_FLASH_CMD_READ_STATUS 0x70
  48. /* CHRP NVRAM header */
  49. struct chrp_header {
  50. u8 signature;
  51. u8 cksum;
  52. u16 len;
  53. char name[12];
  54. u8 data[0];
  55. };
  56. struct core99_header {
  57. struct chrp_header hdr;
  58. u32 adler;
  59. u32 generation;
  60. u32 reserved[2];
  61. };
  62. /*
  63. * Read and write the non-volatile RAM on PowerMacs and CHRP machines.
  64. */
  65. static int nvram_naddrs;
  66. static volatile unsigned char __iomem *nvram_data;
  67. static int is_core_99;
  68. static int core99_bank = 0;
  69. static int nvram_partitions[3];
  70. // XXX Turn that into a sem
  71. static DEFINE_RAW_SPINLOCK(nv_lock);
  72. static int (*core99_write_bank)(int bank, u8* datas);
  73. static int (*core99_erase_bank)(int bank);
  74. static char *nvram_image;
  75. static unsigned char core99_nvram_read_byte(int addr)
  76. {
  77. if (nvram_image == NULL)
  78. return 0xff;
  79. return nvram_image[addr];
  80. }
  81. static void core99_nvram_write_byte(int addr, unsigned char val)
  82. {
  83. if (nvram_image == NULL)
  84. return;
  85. nvram_image[addr] = val;
  86. }
  87. static ssize_t core99_nvram_read(char *buf, size_t count, loff_t *index)
  88. {
  89. int i;
  90. if (nvram_image == NULL)
  91. return -ENODEV;
  92. if (*index > NVRAM_SIZE)
  93. return 0;
  94. i = *index;
  95. if (i + count > NVRAM_SIZE)
  96. count = NVRAM_SIZE - i;
  97. memcpy(buf, &nvram_image[i], count);
  98. *index = i + count;
  99. return count;
  100. }
  101. static ssize_t core99_nvram_write(char *buf, size_t count, loff_t *index)
  102. {
  103. int i;
  104. if (nvram_image == NULL)
  105. return -ENODEV;
  106. if (*index > NVRAM_SIZE)
  107. return 0;
  108. i = *index;
  109. if (i + count > NVRAM_SIZE)
  110. count = NVRAM_SIZE - i;
  111. memcpy(&nvram_image[i], buf, count);
  112. *index = i + count;
  113. return count;
  114. }
  115. static ssize_t core99_nvram_size(void)
  116. {
  117. if (nvram_image == NULL)
  118. return -ENODEV;
  119. return NVRAM_SIZE;
  120. }
  121. #ifdef CONFIG_PPC32
  122. static volatile unsigned char __iomem *nvram_addr;
  123. static int nvram_mult;
  124. static unsigned char direct_nvram_read_byte(int addr)
  125. {
  126. return in_8(&nvram_data[(addr & (NVRAM_SIZE - 1)) * nvram_mult]);
  127. }
  128. static void direct_nvram_write_byte(int addr, unsigned char val)
  129. {
  130. out_8(&nvram_data[(addr & (NVRAM_SIZE - 1)) * nvram_mult], val);
  131. }
  132. static unsigned char indirect_nvram_read_byte(int addr)
  133. {
  134. unsigned char val;
  135. unsigned long flags;
  136. raw_spin_lock_irqsave(&nv_lock, flags);
  137. out_8(nvram_addr, addr >> 5);
  138. val = in_8(&nvram_data[(addr & 0x1f) << 4]);
  139. raw_spin_unlock_irqrestore(&nv_lock, flags);
  140. return val;
  141. }
  142. static void indirect_nvram_write_byte(int addr, unsigned char val)
  143. {
  144. unsigned long flags;
  145. raw_spin_lock_irqsave(&nv_lock, flags);
  146. out_8(nvram_addr, addr >> 5);
  147. out_8(&nvram_data[(addr & 0x1f) << 4], val);
  148. raw_spin_unlock_irqrestore(&nv_lock, flags);
  149. }
  150. #ifdef CONFIG_ADB_PMU
  151. static void pmu_nvram_complete(struct adb_request *req)
  152. {
  153. if (req->arg)
  154. complete((struct completion *)req->arg);
  155. }
  156. static unsigned char pmu_nvram_read_byte(int addr)
  157. {
  158. struct adb_request req;
  159. DECLARE_COMPLETION_ONSTACK(req_complete);
  160. req.arg = system_state == SYSTEM_RUNNING ? &req_complete : NULL;
  161. if (pmu_request(&req, pmu_nvram_complete, 3, PMU_READ_NVRAM,
  162. (addr >> 8) & 0xff, addr & 0xff))
  163. return 0xff;
  164. if (system_state == SYSTEM_RUNNING)
  165. wait_for_completion(&req_complete);
  166. while (!req.complete)
  167. pmu_poll();
  168. return req.reply[0];
  169. }
  170. static void pmu_nvram_write_byte(int addr, unsigned char val)
  171. {
  172. struct adb_request req;
  173. DECLARE_COMPLETION_ONSTACK(req_complete);
  174. req.arg = system_state == SYSTEM_RUNNING ? &req_complete : NULL;
  175. if (pmu_request(&req, pmu_nvram_complete, 4, PMU_WRITE_NVRAM,
  176. (addr >> 8) & 0xff, addr & 0xff, val))
  177. return;
  178. if (system_state == SYSTEM_RUNNING)
  179. wait_for_completion(&req_complete);
  180. while (!req.complete)
  181. pmu_poll();
  182. }
  183. #endif /* CONFIG_ADB_PMU */
  184. #endif /* CONFIG_PPC32 */
  185. static u8 chrp_checksum(struct chrp_header* hdr)
  186. {
  187. u8 *ptr;
  188. u16 sum = hdr->signature;
  189. for (ptr = (u8 *)&hdr->len; ptr < hdr->data; ptr++)
  190. sum += *ptr;
  191. while (sum > 0xFF)
  192. sum = (sum & 0xFF) + (sum>>8);
  193. return sum;
  194. }
  195. static u32 core99_calc_adler(u8 *buffer)
  196. {
  197. int cnt;
  198. u32 low, high;
  199. buffer += CORE99_ADLER_START;
  200. low = 1;
  201. high = 0;
  202. for (cnt=0; cnt<(NVRAM_SIZE-CORE99_ADLER_START); cnt++) {
  203. if ((cnt % 5000) == 0) {
  204. high %= 65521UL;
  205. high %= 65521UL;
  206. }
  207. low += buffer[cnt];
  208. high += low;
  209. }
  210. low %= 65521UL;
  211. high %= 65521UL;
  212. return (high << 16) | low;
  213. }
  214. static u32 core99_check(u8* datas)
  215. {
  216. struct core99_header* hdr99 = (struct core99_header*)datas;
  217. if (hdr99->hdr.signature != CORE99_SIGNATURE) {
  218. DBG("Invalid signature\n");
  219. return 0;
  220. }
  221. if (hdr99->hdr.cksum != chrp_checksum(&hdr99->hdr)) {
  222. DBG("Invalid checksum\n");
  223. return 0;
  224. }
  225. if (hdr99->adler != core99_calc_adler(datas)) {
  226. DBG("Invalid adler\n");
  227. return 0;
  228. }
  229. return hdr99->generation;
  230. }
  231. static int sm_erase_bank(int bank)
  232. {
  233. int stat;
  234. unsigned long timeout;
  235. u8 __iomem *base = (u8 __iomem *)nvram_data + core99_bank*NVRAM_SIZE;
  236. DBG("nvram: Sharp/Micron Erasing bank %d...\n", bank);
  237. out_8(base, SM_FLASH_CMD_ERASE_SETUP);
  238. out_8(base, SM_FLASH_CMD_ERASE_CONFIRM);
  239. timeout = 0;
  240. do {
  241. if (++timeout > 1000000) {
  242. printk(KERN_ERR "nvram: Sharp/Micron flash erase timeout !\n");
  243. break;
  244. }
  245. out_8(base, SM_FLASH_CMD_READ_STATUS);
  246. stat = in_8(base);
  247. } while (!(stat & SM_FLASH_STATUS_DONE));
  248. out_8(base, SM_FLASH_CMD_CLEAR_STATUS);
  249. out_8(base, SM_FLASH_CMD_RESET);
  250. if (memchr_inv(base, 0xff, NVRAM_SIZE)) {
  251. printk(KERN_ERR "nvram: Sharp/Micron flash erase failed !\n");
  252. return -ENXIO;
  253. }
  254. return 0;
  255. }
  256. static int sm_write_bank(int bank, u8* datas)
  257. {
  258. int i, stat = 0;
  259. unsigned long timeout;
  260. u8 __iomem *base = (u8 __iomem *)nvram_data + core99_bank*NVRAM_SIZE;
  261. DBG("nvram: Sharp/Micron Writing bank %d...\n", bank);
  262. for (i=0; i<NVRAM_SIZE; i++) {
  263. out_8(base+i, SM_FLASH_CMD_WRITE_SETUP);
  264. udelay(1);
  265. out_8(base+i, datas[i]);
  266. timeout = 0;
  267. do {
  268. if (++timeout > 1000000) {
  269. printk(KERN_ERR "nvram: Sharp/Micron flash write timeout !\n");
  270. break;
  271. }
  272. out_8(base, SM_FLASH_CMD_READ_STATUS);
  273. stat = in_8(base);
  274. } while (!(stat & SM_FLASH_STATUS_DONE));
  275. if (!(stat & SM_FLASH_STATUS_DONE))
  276. break;
  277. }
  278. out_8(base, SM_FLASH_CMD_CLEAR_STATUS);
  279. out_8(base, SM_FLASH_CMD_RESET);
  280. if (memcmp(base, datas, NVRAM_SIZE)) {
  281. printk(KERN_ERR "nvram: Sharp/Micron flash write failed !\n");
  282. return -ENXIO;
  283. }
  284. return 0;
  285. }
  286. static int amd_erase_bank(int bank)
  287. {
  288. int stat = 0;
  289. unsigned long timeout;
  290. u8 __iomem *base = (u8 __iomem *)nvram_data + core99_bank*NVRAM_SIZE;
  291. DBG("nvram: AMD Erasing bank %d...\n", bank);
  292. /* Unlock 1 */
  293. out_8(base+0x555, 0xaa);
  294. udelay(1);
  295. /* Unlock 2 */
  296. out_8(base+0x2aa, 0x55);
  297. udelay(1);
  298. /* Sector-Erase */
  299. out_8(base+0x555, 0x80);
  300. udelay(1);
  301. out_8(base+0x555, 0xaa);
  302. udelay(1);
  303. out_8(base+0x2aa, 0x55);
  304. udelay(1);
  305. out_8(base, 0x30);
  306. udelay(1);
  307. timeout = 0;
  308. do {
  309. if (++timeout > 1000000) {
  310. printk(KERN_ERR "nvram: AMD flash erase timeout !\n");
  311. break;
  312. }
  313. stat = in_8(base) ^ in_8(base);
  314. } while (stat != 0);
  315. /* Reset */
  316. out_8(base, 0xf0);
  317. udelay(1);
  318. if (memchr_inv(base, 0xff, NVRAM_SIZE)) {
  319. printk(KERN_ERR "nvram: AMD flash erase failed !\n");
  320. return -ENXIO;
  321. }
  322. return 0;
  323. }
  324. static int amd_write_bank(int bank, u8* datas)
  325. {
  326. int i, stat = 0;
  327. unsigned long timeout;
  328. u8 __iomem *base = (u8 __iomem *)nvram_data + core99_bank*NVRAM_SIZE;
  329. DBG("nvram: AMD Writing bank %d...\n", bank);
  330. for (i=0; i<NVRAM_SIZE; i++) {
  331. /* Unlock 1 */
  332. out_8(base+0x555, 0xaa);
  333. udelay(1);
  334. /* Unlock 2 */
  335. out_8(base+0x2aa, 0x55);
  336. udelay(1);
  337. /* Write single word */
  338. out_8(base+0x555, 0xa0);
  339. udelay(1);
  340. out_8(base+i, datas[i]);
  341. timeout = 0;
  342. do {
  343. if (++timeout > 1000000) {
  344. printk(KERN_ERR "nvram: AMD flash write timeout !\n");
  345. break;
  346. }
  347. stat = in_8(base) ^ in_8(base);
  348. } while (stat != 0);
  349. if (stat != 0)
  350. break;
  351. }
  352. /* Reset */
  353. out_8(base, 0xf0);
  354. udelay(1);
  355. if (memcmp(base, datas, NVRAM_SIZE)) {
  356. printk(KERN_ERR "nvram: AMD flash write failed !\n");
  357. return -ENXIO;
  358. }
  359. return 0;
  360. }
  361. static void __init lookup_partitions(void)
  362. {
  363. u8 buffer[17];
  364. int i, offset;
  365. struct chrp_header* hdr;
  366. if (pmac_newworld) {
  367. nvram_partitions[pmac_nvram_OF] = -1;
  368. nvram_partitions[pmac_nvram_XPRAM] = -1;
  369. nvram_partitions[pmac_nvram_NR] = -1;
  370. hdr = (struct chrp_header *)buffer;
  371. offset = 0;
  372. buffer[16] = 0;
  373. do {
  374. for (i=0;i<16;i++)
  375. buffer[i] = ppc_md.nvram_read_val(offset+i);
  376. if (!strcmp(hdr->name, "common"))
  377. nvram_partitions[pmac_nvram_OF] = offset + 0x10;
  378. if (!strcmp(hdr->name, "APL,MacOS75")) {
  379. nvram_partitions[pmac_nvram_XPRAM] = offset + 0x10;
  380. nvram_partitions[pmac_nvram_NR] = offset + 0x110;
  381. }
  382. offset += (hdr->len * 0x10);
  383. } while(offset < NVRAM_SIZE);
  384. } else {
  385. nvram_partitions[pmac_nvram_OF] = 0x1800;
  386. nvram_partitions[pmac_nvram_XPRAM] = 0x1300;
  387. nvram_partitions[pmac_nvram_NR] = 0x1400;
  388. }
  389. DBG("nvram: OF partition at 0x%x\n", nvram_partitions[pmac_nvram_OF]);
  390. DBG("nvram: XP partition at 0x%x\n", nvram_partitions[pmac_nvram_XPRAM]);
  391. DBG("nvram: NR partition at 0x%x\n", nvram_partitions[pmac_nvram_NR]);
  392. }
  393. static void core99_nvram_sync(void)
  394. {
  395. struct core99_header* hdr99;
  396. unsigned long flags;
  397. if (!is_core_99 || !nvram_data || !nvram_image)
  398. return;
  399. raw_spin_lock_irqsave(&nv_lock, flags);
  400. if (!memcmp(nvram_image, (u8*)nvram_data + core99_bank*NVRAM_SIZE,
  401. NVRAM_SIZE))
  402. goto bail;
  403. DBG("Updating nvram...\n");
  404. hdr99 = (struct core99_header*)nvram_image;
  405. hdr99->generation++;
  406. hdr99->hdr.signature = CORE99_SIGNATURE;
  407. hdr99->hdr.cksum = chrp_checksum(&hdr99->hdr);
  408. hdr99->adler = core99_calc_adler(nvram_image);
  409. core99_bank = core99_bank ? 0 : 1;
  410. if (core99_erase_bank)
  411. if (core99_erase_bank(core99_bank)) {
  412. printk("nvram: Error erasing bank %d\n", core99_bank);
  413. goto bail;
  414. }
  415. if (core99_write_bank)
  416. if (core99_write_bank(core99_bank, nvram_image))
  417. printk("nvram: Error writing bank %d\n", core99_bank);
  418. bail:
  419. raw_spin_unlock_irqrestore(&nv_lock, flags);
  420. #ifdef DEBUG
  421. mdelay(2000);
  422. #endif
  423. }
  424. static int __init core99_nvram_setup(struct device_node *dp, unsigned long addr)
  425. {
  426. int i;
  427. u32 gen_bank0, gen_bank1;
  428. if (nvram_naddrs < 1) {
  429. printk(KERN_ERR "nvram: no address\n");
  430. return -EINVAL;
  431. }
  432. nvram_image = memblock_virt_alloc(NVRAM_SIZE, 0);
  433. nvram_data = ioremap(addr, NVRAM_SIZE*2);
  434. nvram_naddrs = 1; /* Make sure we get the correct case */
  435. DBG("nvram: Checking bank 0...\n");
  436. gen_bank0 = core99_check((u8 *)nvram_data);
  437. gen_bank1 = core99_check((u8 *)nvram_data + NVRAM_SIZE);
  438. core99_bank = (gen_bank0 < gen_bank1) ? 1 : 0;
  439. DBG("nvram: gen0=%d, gen1=%d\n", gen_bank0, gen_bank1);
  440. DBG("nvram: Active bank is: %d\n", core99_bank);
  441. for (i=0; i<NVRAM_SIZE; i++)
  442. nvram_image[i] = nvram_data[i + core99_bank*NVRAM_SIZE];
  443. ppc_md.nvram_read_val = core99_nvram_read_byte;
  444. ppc_md.nvram_write_val = core99_nvram_write_byte;
  445. ppc_md.nvram_read = core99_nvram_read;
  446. ppc_md.nvram_write = core99_nvram_write;
  447. ppc_md.nvram_size = core99_nvram_size;
  448. ppc_md.nvram_sync = core99_nvram_sync;
  449. ppc_md.machine_shutdown = core99_nvram_sync;
  450. /*
  451. * Maybe we could be smarter here though making an exclusive list
  452. * of known flash chips is a bit nasty as older OF didn't provide us
  453. * with a useful "compatible" entry. A solution would be to really
  454. * identify the chip using flash id commands and base ourselves on
  455. * a list of known chips IDs
  456. */
  457. if (of_device_is_compatible(dp, "amd-0137")) {
  458. core99_erase_bank = amd_erase_bank;
  459. core99_write_bank = amd_write_bank;
  460. } else {
  461. core99_erase_bank = sm_erase_bank;
  462. core99_write_bank = sm_write_bank;
  463. }
  464. return 0;
  465. }
  466. int __init pmac_nvram_init(void)
  467. {
  468. struct device_node *dp;
  469. struct resource r1, r2;
  470. unsigned int s1 = 0, s2 = 0;
  471. int err = 0;
  472. nvram_naddrs = 0;
  473. dp = of_find_node_by_name(NULL, "nvram");
  474. if (dp == NULL) {
  475. printk(KERN_ERR "Can't find NVRAM device\n");
  476. return -ENODEV;
  477. }
  478. /* Try to obtain an address */
  479. if (of_address_to_resource(dp, 0, &r1) == 0) {
  480. nvram_naddrs = 1;
  481. s1 = resource_size(&r1);
  482. if (of_address_to_resource(dp, 1, &r2) == 0) {
  483. nvram_naddrs = 2;
  484. s2 = resource_size(&r2);
  485. }
  486. }
  487. is_core_99 = of_device_is_compatible(dp, "nvram,flash");
  488. if (is_core_99) {
  489. err = core99_nvram_setup(dp, r1.start);
  490. goto bail;
  491. }
  492. #ifdef CONFIG_PPC32
  493. if (machine_is(chrp) && nvram_naddrs == 1) {
  494. nvram_data = ioremap(r1.start, s1);
  495. nvram_mult = 1;
  496. ppc_md.nvram_read_val = direct_nvram_read_byte;
  497. ppc_md.nvram_write_val = direct_nvram_write_byte;
  498. } else if (nvram_naddrs == 1) {
  499. nvram_data = ioremap(r1.start, s1);
  500. nvram_mult = (s1 + NVRAM_SIZE - 1) / NVRAM_SIZE;
  501. ppc_md.nvram_read_val = direct_nvram_read_byte;
  502. ppc_md.nvram_write_val = direct_nvram_write_byte;
  503. } else if (nvram_naddrs == 2) {
  504. nvram_addr = ioremap(r1.start, s1);
  505. nvram_data = ioremap(r2.start, s2);
  506. ppc_md.nvram_read_val = indirect_nvram_read_byte;
  507. ppc_md.nvram_write_val = indirect_nvram_write_byte;
  508. } else if (nvram_naddrs == 0 && sys_ctrler == SYS_CTRLER_PMU) {
  509. #ifdef CONFIG_ADB_PMU
  510. nvram_naddrs = -1;
  511. ppc_md.nvram_read_val = pmu_nvram_read_byte;
  512. ppc_md.nvram_write_val = pmu_nvram_write_byte;
  513. #endif /* CONFIG_ADB_PMU */
  514. } else {
  515. printk(KERN_ERR "Incompatible type of NVRAM\n");
  516. err = -ENXIO;
  517. }
  518. #endif /* CONFIG_PPC32 */
  519. bail:
  520. of_node_put(dp);
  521. if (err == 0)
  522. lookup_partitions();
  523. return err;
  524. }
  525. int pmac_get_partition(int partition)
  526. {
  527. return nvram_partitions[partition];
  528. }
  529. u8 pmac_xpram_read(int xpaddr)
  530. {
  531. int offset = pmac_get_partition(pmac_nvram_XPRAM);
  532. if (offset < 0 || xpaddr < 0 || xpaddr > 0x100)
  533. return 0xff;
  534. return ppc_md.nvram_read_val(xpaddr + offset);
  535. }
  536. void pmac_xpram_write(int xpaddr, u8 data)
  537. {
  538. int offset = pmac_get_partition(pmac_nvram_XPRAM);
  539. if (offset < 0 || xpaddr < 0 || xpaddr > 0x100)
  540. return;
  541. ppc_md.nvram_write_val(xpaddr + offset, data);
  542. }
  543. EXPORT_SYMBOL(pmac_get_partition);
  544. EXPORT_SYMBOL(pmac_xpram_read);
  545. EXPORT_SYMBOL(pmac_xpram_write);