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

powerpc: Remove DCR_MMIO and the DCR generic layer

The Cell blade support was the last user of DCR_MMIO, so it can now
be removed.

That only leaves DCR_NATIVE, meaning the DCR generic layer which allows
using either DCR_NATIVE or DCR_MMIO is also unnecessary, remove it too.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20241218105523.416573-7-mpe@ellerman.id.au

authored by

Michael Ellerman and committed by
Madhavan Srinivasan
bd4a8342 41cc49ef

+1 -298
+1 -4
arch/powerpc/Kconfig
··· 412 412 config PPC_DCR_NATIVE 413 413 bool 414 414 415 - config PPC_DCR_MMIO 416 - bool 417 - 418 415 config PPC_DCR 419 416 bool 420 - depends on PPC_DCR_NATIVE || PPC_DCR_MMIO 417 + depends on PPC_DCR_NATIVE 421 418 default y 422 419 423 420 config PPC_PCI_OF_BUS_MAP
-36
arch/powerpc/include/asm/dcr-generic.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 - /* 3 - * (c) Copyright 2006 Benjamin Herrenschmidt, IBM Corp. 4 - * <benh@kernel.crashing.org> 5 - */ 6 - 7 - #ifndef _ASM_POWERPC_DCR_GENERIC_H 8 - #define _ASM_POWERPC_DCR_GENERIC_H 9 - #ifdef __KERNEL__ 10 - #ifndef __ASSEMBLY__ 11 - 12 - enum host_type_t {DCR_HOST_MMIO, DCR_HOST_NATIVE, DCR_HOST_INVALID}; 13 - 14 - typedef struct { 15 - enum host_type_t type; 16 - union { 17 - dcr_host_mmio_t mmio; 18 - dcr_host_native_t native; 19 - } host; 20 - } dcr_host_t; 21 - 22 - extern bool dcr_map_ok_generic(dcr_host_t host); 23 - 24 - extern dcr_host_t dcr_map_generic(struct device_node *dev, unsigned int dcr_n, 25 - unsigned int dcr_c); 26 - extern void dcr_unmap_generic(dcr_host_t host, unsigned int dcr_c); 27 - 28 - extern u32 dcr_read_generic(dcr_host_t host, unsigned int dcr_n); 29 - 30 - extern void dcr_write_generic(dcr_host_t host, unsigned int dcr_n, u32 value); 31 - 32 - #endif /* __ASSEMBLY__ */ 33 - #endif /* __KERNEL__ */ 34 - #endif /* _ASM_POWERPC_DCR_GENERIC_H */ 35 - 36 -
-44
arch/powerpc/include/asm/dcr-mmio.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 - /* 3 - * (c) Copyright 2006 Benjamin Herrenschmidt, IBM Corp. 4 - * <benh@kernel.crashing.org> 5 - */ 6 - 7 - #ifndef _ASM_POWERPC_DCR_MMIO_H 8 - #define _ASM_POWERPC_DCR_MMIO_H 9 - #ifdef __KERNEL__ 10 - 11 - #include <asm/io.h> 12 - 13 - typedef struct { 14 - void __iomem *token; 15 - unsigned int stride; 16 - unsigned int base; 17 - } dcr_host_mmio_t; 18 - 19 - static inline bool dcr_map_ok_mmio(dcr_host_mmio_t host) 20 - { 21 - return host.token != NULL; 22 - } 23 - 24 - extern dcr_host_mmio_t dcr_map_mmio(struct device_node *dev, 25 - unsigned int dcr_n, 26 - unsigned int dcr_c); 27 - extern void dcr_unmap_mmio(dcr_host_mmio_t host, unsigned int dcr_c); 28 - 29 - static inline u32 dcr_read_mmio(dcr_host_mmio_t host, unsigned int dcr_n) 30 - { 31 - return in_be32(host.token + ((host.base + dcr_n) * host.stride)); 32 - } 33 - 34 - static inline void dcr_write_mmio(dcr_host_mmio_t host, 35 - unsigned int dcr_n, 36 - u32 value) 37 - { 38 - out_be32(host.token + ((host.base + dcr_n) * host.stride), value); 39 - } 40 - 41 - #endif /* __KERNEL__ */ 42 - #endif /* _ASM_POWERPC_DCR_MMIO_H */ 43 - 44 -
-32
arch/powerpc/include/asm/dcr.h
··· 10 10 #ifndef __ASSEMBLY__ 11 11 #ifdef CONFIG_PPC_DCR 12 12 13 - #ifdef CONFIG_PPC_DCR_NATIVE 14 13 #include <asm/dcr-native.h> 15 - #endif 16 14 17 - #ifdef CONFIG_PPC_DCR_MMIO 18 - #include <asm/dcr-mmio.h> 19 - #endif 20 - 21 - 22 - /* Indirection layer for providing both NATIVE and MMIO support. */ 23 - 24 - #if defined(CONFIG_PPC_DCR_NATIVE) && defined(CONFIG_PPC_DCR_MMIO) 25 - 26 - #include <asm/dcr-generic.h> 27 - 28 - #define DCR_MAP_OK(host) dcr_map_ok_generic(host) 29 - #define dcr_map(dev, dcr_n, dcr_c) dcr_map_generic(dev, dcr_n, dcr_c) 30 - #define dcr_unmap(host, dcr_c) dcr_unmap_generic(host, dcr_c) 31 - #define dcr_read(host, dcr_n) dcr_read_generic(host, dcr_n) 32 - #define dcr_write(host, dcr_n, value) dcr_write_generic(host, dcr_n, value) 33 - 34 - #else 35 - 36 - #ifdef CONFIG_PPC_DCR_NATIVE 37 15 typedef dcr_host_native_t dcr_host_t; 38 16 #define DCR_MAP_OK(host) dcr_map_ok_native(host) 39 17 #define dcr_map(dev, dcr_n, dcr_c) dcr_map_native(dev, dcr_n, dcr_c) 40 18 #define dcr_unmap(host, dcr_c) dcr_unmap_native(host, dcr_c) 41 19 #define dcr_read(host, dcr_n) dcr_read_native(host, dcr_n) 42 20 #define dcr_write(host, dcr_n, value) dcr_write_native(host, dcr_n, value) 43 - #else 44 - typedef dcr_host_mmio_t dcr_host_t; 45 - #define DCR_MAP_OK(host) dcr_map_ok_mmio(host) 46 - #define dcr_map(dev, dcr_n, dcr_c) dcr_map_mmio(dev, dcr_n, dcr_c) 47 - #define dcr_unmap(host, dcr_c) dcr_unmap_mmio(host, dcr_c) 48 - #define dcr_read(host, dcr_n) dcr_read_mmio(host, dcr_n) 49 - #define dcr_write(host, dcr_n, value) dcr_write_mmio(host, dcr_n, value) 50 - #endif 51 - 52 - #endif /* defined(CONFIG_PPC_DCR_NATIVE) && defined(CONFIG_PPC_DCR_MMIO) */ 53 21 54 22 /* 55 23 * additional helpers to read the DCR * base from the device-tree
-182
arch/powerpc/sysdev/dcr.c
··· 11 11 #include <linux/of_address.h> 12 12 #include <asm/dcr.h> 13 13 14 - #ifdef CONFIG_PPC_DCR_MMIO 15 - static struct device_node *find_dcr_parent(struct device_node *node) 16 - { 17 - struct device_node *par, *tmp; 18 - const u32 *p; 19 - 20 - for (par = of_node_get(node); par;) { 21 - if (of_property_read_bool(par, "dcr-controller")) 22 - break; 23 - p = of_get_property(par, "dcr-parent", NULL); 24 - tmp = par; 25 - if (p == NULL) 26 - par = of_get_parent(par); 27 - else 28 - par = of_find_node_by_phandle(*p); 29 - of_node_put(tmp); 30 - } 31 - return par; 32 - } 33 - #endif 34 - 35 - #if defined(CONFIG_PPC_DCR_NATIVE) && defined(CONFIG_PPC_DCR_MMIO) 36 - 37 - bool dcr_map_ok_generic(dcr_host_t host) 38 - { 39 - if (host.type == DCR_HOST_NATIVE) 40 - return dcr_map_ok_native(host.host.native); 41 - else if (host.type == DCR_HOST_MMIO) 42 - return dcr_map_ok_mmio(host.host.mmio); 43 - else 44 - return false; 45 - } 46 - EXPORT_SYMBOL_GPL(dcr_map_ok_generic); 47 - 48 - dcr_host_t dcr_map_generic(struct device_node *dev, 49 - unsigned int dcr_n, 50 - unsigned int dcr_c) 51 - { 52 - dcr_host_t host; 53 - struct device_node *dp; 54 - const char *prop; 55 - 56 - host.type = DCR_HOST_INVALID; 57 - 58 - dp = find_dcr_parent(dev); 59 - if (dp == NULL) 60 - return host; 61 - 62 - prop = of_get_property(dp, "dcr-access-method", NULL); 63 - 64 - pr_debug("dcr_map_generic(dcr-access-method = %s)\n", prop); 65 - 66 - if (!strcmp(prop, "native")) { 67 - host.type = DCR_HOST_NATIVE; 68 - host.host.native = dcr_map_native(dev, dcr_n, dcr_c); 69 - } else if (!strcmp(prop, "mmio")) { 70 - host.type = DCR_HOST_MMIO; 71 - host.host.mmio = dcr_map_mmio(dev, dcr_n, dcr_c); 72 - } 73 - 74 - of_node_put(dp); 75 - return host; 76 - } 77 - EXPORT_SYMBOL_GPL(dcr_map_generic); 78 - 79 - void dcr_unmap_generic(dcr_host_t host, unsigned int dcr_c) 80 - { 81 - if (host.type == DCR_HOST_NATIVE) 82 - dcr_unmap_native(host.host.native, dcr_c); 83 - else if (host.type == DCR_HOST_MMIO) 84 - dcr_unmap_mmio(host.host.mmio, dcr_c); 85 - else /* host.type == DCR_HOST_INVALID */ 86 - WARN_ON(true); 87 - } 88 - EXPORT_SYMBOL_GPL(dcr_unmap_generic); 89 - 90 - u32 dcr_read_generic(dcr_host_t host, unsigned int dcr_n) 91 - { 92 - if (host.type == DCR_HOST_NATIVE) 93 - return dcr_read_native(host.host.native, dcr_n); 94 - else if (host.type == DCR_HOST_MMIO) 95 - return dcr_read_mmio(host.host.mmio, dcr_n); 96 - else /* host.type == DCR_HOST_INVALID */ 97 - WARN_ON(true); 98 - return 0; 99 - } 100 - EXPORT_SYMBOL_GPL(dcr_read_generic); 101 - 102 - void dcr_write_generic(dcr_host_t host, unsigned int dcr_n, u32 value) 103 - { 104 - if (host.type == DCR_HOST_NATIVE) 105 - dcr_write_native(host.host.native, dcr_n, value); 106 - else if (host.type == DCR_HOST_MMIO) 107 - dcr_write_mmio(host.host.mmio, dcr_n, value); 108 - else /* host.type == DCR_HOST_INVALID */ 109 - WARN_ON(true); 110 - } 111 - EXPORT_SYMBOL_GPL(dcr_write_generic); 112 - 113 - #endif /* defined(CONFIG_PPC_DCR_NATIVE) && defined(CONFIG_PPC_DCR_MMIO) */ 114 - 115 14 unsigned int dcr_resource_start(const struct device_node *np, 116 15 unsigned int index) 117 16 { ··· 36 137 } 37 138 EXPORT_SYMBOL_GPL(dcr_resource_len); 38 139 39 - #ifdef CONFIG_PPC_DCR_MMIO 40 - 41 - static u64 of_translate_dcr_address(struct device_node *dev, 42 - unsigned int dcr_n, 43 - unsigned int *out_stride) 44 - { 45 - struct device_node *dp; 46 - const u32 *p; 47 - unsigned int stride; 48 - u64 ret = OF_BAD_ADDR; 49 - 50 - dp = find_dcr_parent(dev); 51 - if (dp == NULL) 52 - return OF_BAD_ADDR; 53 - 54 - /* Stride is not properly defined yet, default to 0x10 for Axon */ 55 - p = of_get_property(dp, "dcr-mmio-stride", NULL); 56 - stride = (p == NULL) ? 0x10 : *p; 57 - 58 - /* XXX FIXME: Which property name is to use of the 2 following ? */ 59 - p = of_get_property(dp, "dcr-mmio-range", NULL); 60 - if (p == NULL) 61 - p = of_get_property(dp, "dcr-mmio-space", NULL); 62 - if (p == NULL) 63 - goto done; 64 - 65 - /* Maybe could do some better range checking here */ 66 - ret = of_translate_address(dp, p); 67 - if (ret != OF_BAD_ADDR) 68 - ret += (u64)(stride) * (u64)dcr_n; 69 - if (out_stride) 70 - *out_stride = stride; 71 - 72 - done: 73 - of_node_put(dp); 74 - return ret; 75 - } 76 - 77 - dcr_host_mmio_t dcr_map_mmio(struct device_node *dev, 78 - unsigned int dcr_n, 79 - unsigned int dcr_c) 80 - { 81 - dcr_host_mmio_t ret = { .token = NULL, .stride = 0, .base = dcr_n }; 82 - u64 addr; 83 - 84 - pr_debug("dcr_map(%pOF, 0x%x, 0x%x)\n", 85 - dev, dcr_n, dcr_c); 86 - 87 - addr = of_translate_dcr_address(dev, dcr_n, &ret.stride); 88 - pr_debug("translates to addr: 0x%llx, stride: 0x%x\n", 89 - (unsigned long long) addr, ret.stride); 90 - if (addr == OF_BAD_ADDR) 91 - return ret; 92 - pr_debug("mapping 0x%x bytes\n", dcr_c * ret.stride); 93 - ret.token = ioremap(addr, dcr_c * ret.stride); 94 - if (ret.token == NULL) 95 - return ret; 96 - pr_debug("mapped at 0x%p -> base is 0x%p\n", 97 - ret.token, ret.token - dcr_n * ret.stride); 98 - ret.token -= dcr_n * ret.stride; 99 - return ret; 100 - } 101 - EXPORT_SYMBOL_GPL(dcr_map_mmio); 102 - 103 - void dcr_unmap_mmio(dcr_host_mmio_t host, unsigned int dcr_c) 104 - { 105 - dcr_host_mmio_t h = host; 106 - 107 - if (h.token == NULL) 108 - return; 109 - h.token += host.base * h.stride; 110 - iounmap(h.token); 111 - h.token = NULL; 112 - } 113 - EXPORT_SYMBOL_GPL(dcr_unmap_mmio); 114 - 115 - #endif /* defined(CONFIG_PPC_DCR_MMIO) */ 116 - 117 - #ifdef CONFIG_PPC_DCR_NATIVE 118 140 DEFINE_SPINLOCK(dcr_ind_lock); 119 141 EXPORT_SYMBOL_GPL(dcr_ind_lock); 120 - #endif /* defined(CONFIG_PPC_DCR_NATIVE) */ 121 -