| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * PowerMac G5 SMU driver |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright 2004 J. Mayer <l_indien@magic.fr> |
|---|
| 5 | 6 | * Copyright 2005 Benjamin Herrenschmidt, IBM Corp. |
|---|
| 6 | | - * |
|---|
| 7 | | - * Released under the term of the GNU GPL v2. |
|---|
| 8 | 7 | */ |
|---|
| 9 | 8 | |
|---|
| 10 | 9 | /* |
|---|
| .. | .. |
|---|
| 23 | 22 | #include <linux/kernel.h> |
|---|
| 24 | 23 | #include <linux/device.h> |
|---|
| 25 | 24 | #include <linux/dmapool.h> |
|---|
| 26 | | -#include <linux/bootmem.h> |
|---|
| 25 | +#include <linux/memblock.h> |
|---|
| 27 | 26 | #include <linux/vmalloc.h> |
|---|
| 28 | 27 | #include <linux/highmem.h> |
|---|
| 29 | 28 | #include <linux/jiffies.h> |
|---|
| .. | .. |
|---|
| 38 | 37 | #include <linux/of_irq.h> |
|---|
| 39 | 38 | #include <linux/of_platform.h> |
|---|
| 40 | 39 | #include <linux/slab.h> |
|---|
| 41 | | -#include <linux/memblock.h> |
|---|
| 42 | 40 | #include <linux/sched/signal.h> |
|---|
| 43 | 41 | |
|---|
| 44 | 42 | #include <asm/byteorder.h> |
|---|
| .. | .. |
|---|
| 134 | 132 | /* Flush command and data to RAM */ |
|---|
| 135 | 133 | faddr = (unsigned long)smu->cmd_buf; |
|---|
| 136 | 134 | fend = faddr + smu->cmd_buf->length + 2; |
|---|
| 137 | | - flush_inval_dcache_range(faddr, fend); |
|---|
| 135 | + flush_dcache_range(faddr, fend); |
|---|
| 138 | 136 | |
|---|
| 139 | 137 | |
|---|
| 140 | 138 | /* We also disable NAP mode for the duration of the command |
|---|
| .. | .. |
|---|
| 196 | 194 | * reply length (it's only 2 cache lines anyway) |
|---|
| 197 | 195 | */ |
|---|
| 198 | 196 | faddr = (unsigned long)smu->cmd_buf; |
|---|
| 199 | | - flush_inval_dcache_range(faddr, faddr + 256); |
|---|
| 197 | + flush_dcache_range(faddr, faddr + 256); |
|---|
| 200 | 198 | |
|---|
| 201 | 199 | /* Now check ack */ |
|---|
| 202 | 200 | ack = (~cmd->cmd) & 0xff; |
|---|
| .. | .. |
|---|
| 486 | 484 | * SMU based G5s need some memory below 2Gb. Thankfully this is |
|---|
| 487 | 485 | * called at a time where memblock is still available. |
|---|
| 488 | 486 | */ |
|---|
| 489 | | - smu_cmdbuf_abs = memblock_alloc_base(4096, 4096, 0x80000000UL); |
|---|
| 487 | + smu_cmdbuf_abs = memblock_phys_alloc_range(4096, 4096, 0, 0x80000000UL); |
|---|
| 490 | 488 | if (smu_cmdbuf_abs == 0) { |
|---|
| 491 | 489 | printk(KERN_ERR "SMU: Command buffer allocation failed !\n"); |
|---|
| 492 | 490 | ret = -EINVAL; |
|---|
| 493 | 491 | goto fail_np; |
|---|
| 494 | 492 | } |
|---|
| 495 | 493 | |
|---|
| 496 | | - smu = alloc_bootmem(sizeof(struct smu_device)); |
|---|
| 494 | + smu = memblock_alloc(sizeof(struct smu_device), SMP_CACHE_BYTES); |
|---|
| 495 | + if (!smu) |
|---|
| 496 | + panic("%s: Failed to allocate %zu bytes\n", __func__, |
|---|
| 497 | + sizeof(struct smu_device)); |
|---|
| 497 | 498 | |
|---|
| 498 | 499 | spin_lock_init(&smu->lock); |
|---|
| 499 | 500 | INIT_LIST_HEAD(&smu->cmd_list); |
|---|
| .. | .. |
|---|
| 569 | 570 | fail_db_node: |
|---|
| 570 | 571 | of_node_put(smu->db_node); |
|---|
| 571 | 572 | fail_bootmem: |
|---|
| 572 | | - free_bootmem(__pa(smu), sizeof(struct smu_device)); |
|---|
| 573 | + memblock_free(__pa(smu), sizeof(struct smu_device)); |
|---|
| 573 | 574 | smu = NULL; |
|---|
| 574 | 575 | fail_np: |
|---|
| 575 | 576 | of_node_put(np); |
|---|
| .. | .. |
|---|
| 637 | 638 | { |
|---|
| 638 | 639 | struct device_node *np; |
|---|
| 639 | 640 | |
|---|
| 640 | | - for (np = NULL; (np = of_get_next_child(smu->of_node, np)) != NULL;) |
|---|
| 641 | + for_each_child_of_node(smu->of_node, np) |
|---|
| 641 | 642 | if (of_device_is_compatible(np, "smu-sensors")) |
|---|
| 642 | 643 | of_platform_device_create(np, "smu-sensors", |
|---|
| 643 | 644 | &smu->of_dev->dev); |
|---|
| .. | .. |
|---|
| 851 | 852 | break; |
|---|
| 852 | 853 | case SMU_I2C_TRANSFER_COMBINED: |
|---|
| 853 | 854 | cmd->info.devaddr &= 0xfe; |
|---|
| 855 | + fallthrough; |
|---|
| 854 | 856 | case SMU_I2C_TRANSFER_STDSUB: |
|---|
| 855 | 857 | if (cmd->info.sublen > 3) |
|---|
| 856 | 858 | return -EINVAL; |
|---|
| .. | .. |
|---|
| 1013 | 1015 | /* Note: Only allowed to return error code in pointers (using ERR_PTR) |
|---|
| 1014 | 1016 | * when interruptible is 1 |
|---|
| 1015 | 1017 | */ |
|---|
| 1016 | | -const struct smu_sdbp_header *__smu_get_sdb_partition(int id, |
|---|
| 1018 | +static const struct smu_sdbp_header *__smu_get_sdb_partition(int id, |
|---|
| 1017 | 1019 | unsigned int *size, int interruptible) |
|---|
| 1018 | 1020 | { |
|---|
| 1019 | 1021 | char pname[32]; |
|---|