.. | .. |
---|
1 | | -/* |
---|
2 | | - * Copyright (C) 2015-2017 Netronome Systems, Inc. |
---|
3 | | - * |
---|
4 | | - * This software is dual licensed under the GNU General License Version 2, |
---|
5 | | - * June 1991 as shown in the file COPYING in the top-level directory of this |
---|
6 | | - * source tree or the BSD 2-Clause License provided below. You have the |
---|
7 | | - * option to license this software under the complete terms of either license. |
---|
8 | | - * |
---|
9 | | - * The BSD 2-Clause License: |
---|
10 | | - * |
---|
11 | | - * Redistribution and use in source and binary forms, with or |
---|
12 | | - * without modification, are permitted provided that the following |
---|
13 | | - * conditions are met: |
---|
14 | | - * |
---|
15 | | - * 1. Redistributions of source code must retain the above |
---|
16 | | - * copyright notice, this list of conditions and the following |
---|
17 | | - * disclaimer. |
---|
18 | | - * |
---|
19 | | - * 2. Redistributions in binary form must reproduce the above |
---|
20 | | - * copyright notice, this list of conditions and the following |
---|
21 | | - * disclaimer in the documentation and/or other materials |
---|
22 | | - * provided with the distribution. |
---|
23 | | - * |
---|
24 | | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
---|
25 | | - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
---|
26 | | - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
---|
27 | | - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
---|
28 | | - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
---|
29 | | - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
---|
30 | | - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
---|
31 | | - * SOFTWARE. |
---|
32 | | - */ |
---|
| 1 | +// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) |
---|
| 2 | +/* Copyright (C) 2015-2018 Netronome Systems, Inc. */ |
---|
33 | 3 | |
---|
34 | 4 | /* |
---|
35 | 5 | * nfp_cpplib.c |
---|
.. | .. |
---|
54 | 24 | /* NFP6000 PL */ |
---|
55 | 25 | #define NFP_PL_DEVICE_ID 0x00000004 |
---|
56 | 26 | #define NFP_PL_DEVICE_ID_MASK GENMASK(7, 0) |
---|
57 | | - |
---|
58 | | -#define NFP6000_ARM_GCSR_SOFTMODEL0 0x00400144 |
---|
| 27 | +#define NFP_PL_DEVICE_PART_MASK GENMASK(31, 16) |
---|
| 28 | +#define NFP_PL_DEVICE_MODEL_MASK (NFP_PL_DEVICE_PART_MASK | \ |
---|
| 29 | + NFP_PL_DEVICE_ID_MASK) |
---|
59 | 30 | |
---|
60 | 31 | /** |
---|
61 | 32 | * nfp_cpp_readl() - Read a u32 word from a CPP location |
---|
.. | .. |
---|
150 | 121 | */ |
---|
151 | 122 | int nfp_cpp_model_autodetect(struct nfp_cpp *cpp, u32 *model) |
---|
152 | 123 | { |
---|
153 | | - const u32 arm_id = NFP_CPP_ID(NFP_CPP_TARGET_ARM, 0, 0); |
---|
154 | 124 | u32 reg; |
---|
155 | 125 | int err; |
---|
156 | 126 | |
---|
157 | | - err = nfp_cpp_readl(cpp, arm_id, NFP6000_ARM_GCSR_SOFTMODEL0, model); |
---|
158 | | - if (err < 0) |
---|
159 | | - return err; |
---|
160 | | - |
---|
161 | | - /* The PL's PluDeviceID revision code is authoratative */ |
---|
162 | | - *model &= ~0xff; |
---|
163 | 127 | err = nfp_xpb_readl(cpp, NFP_XPB_DEVICE(1, 1, 16) + NFP_PL_DEVICE_ID, |
---|
164 | 128 | ®); |
---|
165 | 129 | if (err < 0) |
---|
166 | 130 | return err; |
---|
167 | 131 | |
---|
168 | | - *model |= (NFP_PL_DEVICE_ID_MASK & reg) - 0x10; |
---|
| 132 | + *model = reg & NFP_PL_DEVICE_MODEL_MASK; |
---|
| 133 | + if (*model & NFP_PL_DEVICE_ID_MASK) |
---|
| 134 | + *model -= 0x10; |
---|
169 | 135 | |
---|
170 | 136 | return 0; |
---|
171 | 137 | } |
---|
.. | .. |
---|
294 | 260 | * nfp_cpp_map_area() - Helper function to map an area |
---|
295 | 261 | * @cpp: NFP CPP handler |
---|
296 | 262 | * @name: Name for the area |
---|
297 | | - * @domain: CPP domain |
---|
298 | | - * @target: CPP target |
---|
| 263 | + * @cpp_id: CPP ID for operation |
---|
299 | 264 | * @addr: CPP address |
---|
300 | 265 | * @size: Size of the area |
---|
301 | 266 | * @area: Area handle (output) |
---|
.. | .. |
---|
306 | 271 | * Return: Pointer to memory mapped area or ERR_PTR |
---|
307 | 272 | */ |
---|
308 | 273 | u8 __iomem * |
---|
309 | | -nfp_cpp_map_area(struct nfp_cpp *cpp, const char *name, int domain, int target, |
---|
310 | | - u64 addr, unsigned long size, struct nfp_cpp_area **area) |
---|
| 274 | +nfp_cpp_map_area(struct nfp_cpp *cpp, const char *name, u32 cpp_id, u64 addr, |
---|
| 275 | + unsigned long size, struct nfp_cpp_area **area) |
---|
311 | 276 | { |
---|
312 | 277 | u8 __iomem *res; |
---|
313 | | - u32 dest; |
---|
314 | 278 | |
---|
315 | | - dest = NFP_CPP_ISLAND_ID(target, NFP_CPP_ACTION_RW, 0, domain); |
---|
316 | | - |
---|
317 | | - *area = nfp_cpp_area_alloc_acquire(cpp, name, dest, addr, size); |
---|
| 279 | + *area = nfp_cpp_area_alloc_acquire(cpp, name, cpp_id, addr, size); |
---|
318 | 280 | if (!*area) |
---|
319 | 281 | goto err_eio; |
---|
320 | 282 | |
---|