.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * 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 | 4 | * |
---|
9 | 5 | * Todo: - add support for the OF persistent properties |
---|
10 | 6 | */ |
---|
.. | .. |
---|
18 | 14 | #include <linux/errno.h> |
---|
19 | 15 | #include <linux/adb.h> |
---|
20 | 16 | #include <linux/pmu.h> |
---|
21 | | -#include <linux/bootmem.h> |
---|
| 17 | +#include <linux/memblock.h> |
---|
22 | 18 | #include <linux/completion.h> |
---|
23 | 19 | #include <linux/spinlock.h> |
---|
24 | 20 | #include <asm/sections.h> |
---|
.. | .. |
---|
59 | 55 | u8 cksum; |
---|
60 | 56 | u16 len; |
---|
61 | 57 | char name[12]; |
---|
62 | | - u8 data[0]; |
---|
| 58 | + u8 data[]; |
---|
63 | 59 | }; |
---|
64 | 60 | |
---|
65 | 61 | struct core99_header { |
---|
.. | .. |
---|
146 | 142 | #ifdef CONFIG_PPC32 |
---|
147 | 143 | static volatile unsigned char __iomem *nvram_addr; |
---|
148 | 144 | static int nvram_mult; |
---|
| 145 | + |
---|
| 146 | +static ssize_t ppc32_nvram_size(void) |
---|
| 147 | +{ |
---|
| 148 | + return NVRAM_SIZE; |
---|
| 149 | +} |
---|
149 | 150 | |
---|
150 | 151 | static unsigned char direct_nvram_read_byte(int addr) |
---|
151 | 152 | { |
---|
.. | .. |
---|
513 | 514 | printk(KERN_ERR "nvram: no address\n"); |
---|
514 | 515 | return -EINVAL; |
---|
515 | 516 | } |
---|
516 | | - nvram_image = memblock_virt_alloc(NVRAM_SIZE, 0); |
---|
| 517 | + nvram_image = memblock_alloc(NVRAM_SIZE, SMP_CACHE_BYTES); |
---|
| 518 | + if (!nvram_image) |
---|
| 519 | + panic("%s: Failed to allocate %u bytes\n", __func__, |
---|
| 520 | + NVRAM_SIZE); |
---|
517 | 521 | nvram_data = ioremap(addr, NVRAM_SIZE*2); |
---|
518 | 522 | nvram_naddrs = 1; /* Make sure we get the correct case */ |
---|
519 | 523 | |
---|
.. | .. |
---|
590 | 594 | nvram_mult = 1; |
---|
591 | 595 | ppc_md.nvram_read_val = direct_nvram_read_byte; |
---|
592 | 596 | ppc_md.nvram_write_val = direct_nvram_write_byte; |
---|
| 597 | + ppc_md.nvram_size = ppc32_nvram_size; |
---|
593 | 598 | } else if (nvram_naddrs == 1) { |
---|
594 | 599 | nvram_data = ioremap(r1.start, s1); |
---|
595 | 600 | nvram_mult = (s1 + NVRAM_SIZE - 1) / NVRAM_SIZE; |
---|
596 | 601 | ppc_md.nvram_read_val = direct_nvram_read_byte; |
---|
597 | 602 | ppc_md.nvram_write_val = direct_nvram_write_byte; |
---|
| 603 | + ppc_md.nvram_size = ppc32_nvram_size; |
---|
598 | 604 | } else if (nvram_naddrs == 2) { |
---|
599 | 605 | nvram_addr = ioremap(r1.start, s1); |
---|
600 | 606 | nvram_data = ioremap(r2.start, s2); |
---|
601 | 607 | ppc_md.nvram_read_val = indirect_nvram_read_byte; |
---|
602 | 608 | ppc_md.nvram_write_val = indirect_nvram_write_byte; |
---|
| 609 | + ppc_md.nvram_size = ppc32_nvram_size; |
---|
603 | 610 | } else if (nvram_naddrs == 0 && sys_ctrler == SYS_CTRLER_PMU) { |
---|
604 | 611 | #ifdef CONFIG_ADB_PMU |
---|
605 | 612 | nvram_naddrs = -1; |
---|
606 | 613 | ppc_md.nvram_read_val = pmu_nvram_read_byte; |
---|
607 | 614 | ppc_md.nvram_write_val = pmu_nvram_write_byte; |
---|
| 615 | + ppc_md.nvram_size = ppc32_nvram_size; |
---|
608 | 616 | #endif /* CONFIG_ADB_PMU */ |
---|
609 | 617 | } else { |
---|
610 | 618 | printk(KERN_ERR "Incompatible type of NVRAM\n"); |
---|