hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_cpplib.c
....@@ -1,35 +1,5 @@
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. */
333
344 /*
355 * nfp_cpplib.c
....@@ -54,8 +24,9 @@
5424 /* NFP6000 PL */
5525 #define NFP_PL_DEVICE_ID 0x00000004
5626 #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)
5930
6031 /**
6132 * nfp_cpp_readl() - Read a u32 word from a CPP location
....@@ -150,22 +121,17 @@
150121 */
151122 int nfp_cpp_model_autodetect(struct nfp_cpp *cpp, u32 *model)
152123 {
153
- const u32 arm_id = NFP_CPP_ID(NFP_CPP_TARGET_ARM, 0, 0);
154124 u32 reg;
155125 int err;
156126
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;
163127 err = nfp_xpb_readl(cpp, NFP_XPB_DEVICE(1, 1, 16) + NFP_PL_DEVICE_ID,
164128 &reg);
165129 if (err < 0)
166130 return err;
167131
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;
169135
170136 return 0;
171137 }
....@@ -294,8 +260,7 @@
294260 * nfp_cpp_map_area() - Helper function to map an area
295261 * @cpp: NFP CPP handler
296262 * @name: Name for the area
297
- * @domain: CPP domain
298
- * @target: CPP target
263
+ * @cpp_id: CPP ID for operation
299264 * @addr: CPP address
300265 * @size: Size of the area
301266 * @area: Area handle (output)
....@@ -306,15 +271,12 @@
306271 * Return: Pointer to memory mapped area or ERR_PTR
307272 */
308273 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)
311276 {
312277 u8 __iomem *res;
313
- u32 dest;
314278
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);
318280 if (!*area)
319281 goto err_eio;
320282