// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) /* Copyright (C) 2015-2018 Netronome Systems, Inc. */
/* * nfp_cpplib.c * Library of functions to access the NFP's CPP bus * Authors: Jakub Kicinski <jakub.kicinski@netronome.com> * Jason McMullan <jason.mcmullan@netronome.com> * Rolf Neugebauer <rolf.neugebauer@netronome.com>
*/
/** * nfp_cpp_readl() - Read a u32 word from a CPP location * @cpp: CPP device handle * @cpp_id: CPP ID for operation * @address: Address for operation * @value: Pointer to read buffer * * Return: 0 on success, or -ERRNO
*/ int nfp_cpp_readl(struct nfp_cpp *cpp, u32 cpp_id, unsignedlonglong address, u32 *value)
{
u8 tmp[4]; int n;
n = nfp_cpp_read(cpp, cpp_id, address, tmp, sizeof(tmp)); if (n != sizeof(tmp)) return n < 0 ? n : -EIO;
*value = get_unaligned_le32(tmp); return 0;
}
/** * nfp_cpp_writel() - Write a u32 word to a CPP location * @cpp: CPP device handle * @cpp_id: CPP ID for operation * @address: Address for operation * @value: Value to write * * Return: 0 on success, or -ERRNO
*/ int nfp_cpp_writel(struct nfp_cpp *cpp, u32 cpp_id, unsignedlonglong address, u32 value)
{
u8 tmp[4]; int n;
put_unaligned_le32(value, tmp);
n = nfp_cpp_write(cpp, cpp_id, address, tmp, sizeof(tmp));
return n == sizeof(tmp) ? 0 : n < 0 ? n : -EIO;
}
/** * nfp_cpp_readq() - Read a u64 word from a CPP location * @cpp: CPP device handle * @cpp_id: CPP ID for operation * @address: Address for operation * @value: Pointer to read buffer * * Return: 0 on success, or -ERRNO
*/ int nfp_cpp_readq(struct nfp_cpp *cpp, u32 cpp_id, unsignedlonglong address, u64 *value)
{
u8 tmp[8]; int n;
n = nfp_cpp_read(cpp, cpp_id, address, tmp, sizeof(tmp)); if (n != sizeof(tmp)) return n < 0 ? n : -EIO;
*value = get_unaligned_le64(tmp); return 0;
}
/** * nfp_cpp_writeq() - Write a u64 word to a CPP location * @cpp: CPP device handle * @cpp_id: CPP ID for operation * @address: Address for operation * @value: Value to write * * Return: 0 on success, or -ERRNO
*/ int nfp_cpp_writeq(struct nfp_cpp *cpp, u32 cpp_id, unsignedlonglong address, u64 value)
{
u8 tmp[8]; int n;
put_unaligned_le64(value, tmp);
n = nfp_cpp_write(cpp, cpp_id, address, tmp, sizeof(tmp));
return n == sizeof(tmp) ? 0 : n < 0 ? n : -EIO;
}
/* NOTE: This code should not use nfp_xpb_* functions, * as those are model-specific
*/ int nfp_cpp_model_autodetect(struct nfp_cpp *cpp, u32 *model)
{
u32 reg; int err;
/** * nfp_cpp_map_area() - Helper function to map an area * @cpp: NFP CPP handler * @name: Name for the area * @cpp_id: CPP ID for operation * @addr: CPP address * @size: Size of the area * @area: Area handle (output) * * Map an area of IOMEM access. To undo the effect of this function call * @nfp_cpp_area_release_free(*area). * * Return: Pointer to memory mapped area or ERR_PTR
*/
u8 __iomem *
nfp_cpp_map_area(struct nfp_cpp *cpp, constchar *name, u32 cpp_id, u64 addr, unsignedlong size, struct nfp_cpp_area **area)
{
u8 __iomem *res;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.