1131a75b6SHemant Agrawal /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0) 23af733baSHemant Agrawal * 33af733baSHemant Agrawal * Copyright 2013-2015 Freescale Semiconductor Inc. 4131a75b6SHemant Agrawal * Copyright 2017 NXP 53af733baSHemant Agrawal * 63af733baSHemant Agrawal */ 73af733baSHemant Agrawal #ifndef _FSL_MC_SYS_H 83af733baSHemant Agrawal #define _FSL_MC_SYS_H 93af733baSHemant Agrawal 103af733baSHemant Agrawal #ifdef __linux_driver__ 113af733baSHemant Agrawal 123af733baSHemant Agrawal #include <linux/errno.h> 133af733baSHemant Agrawal #include <asm/io.h> 143af733baSHemant Agrawal #include <linux/slab.h> 153af733baSHemant Agrawal 163af733baSHemant Agrawal struct fsl_mc_io { 173af733baSHemant Agrawal void *regs; 183af733baSHemant Agrawal }; 193af733baSHemant Agrawal 203af733baSHemant Agrawal #ifndef ENOTSUP 213af733baSHemant Agrawal #define ENOTSUP 95 223af733baSHemant Agrawal #endif 233af733baSHemant Agrawal 243af733baSHemant Agrawal #define ioread64(_p) readq(_p) 253af733baSHemant Agrawal #define iowrite64(_v, _p) writeq(_v, _p) 263af733baSHemant Agrawal 273af733baSHemant Agrawal #else /* __linux_driver__ */ 283af733baSHemant Agrawal 293af733baSHemant Agrawal #include <stdio.h> 303af733baSHemant Agrawal #include <stdint.h> 313af733baSHemant Agrawal #include <errno.h> 323af733baSHemant Agrawal #include <sys/uio.h> 333af733baSHemant Agrawal #include <linux/byteorder/little_endian.h> 343af733baSHemant Agrawal 3524ffb8c5SGavin Hu #include <rte_atomic.h> 3624ffb8c5SGavin Hu 3724ffb8c5SGavin Hu #define __iormb() rte_io_rmb() 3824ffb8c5SGavin Hu #define __iowmb() rte_io_wmb() 3916bbc98aSShreyansh Jain #define __arch_getq(a) (*(volatile uint64_t *)(a)) 4016bbc98aSShreyansh Jain #define __arch_putq(v, a) (*(volatile uint64_t *)(a) = (v)) 4116bbc98aSShreyansh Jain #define __arch_putq32(v, a) (*(volatile uint32_t *)(a) = (v)) 423af733baSHemant Agrawal #define readq(c) \ 43*93998f3cSTyler Retzlaff __extension__ ({ uint64_t __v = __arch_getq(c); __iormb(); __v; }) 443af733baSHemant Agrawal #define writeq(v, c) \ 45*93998f3cSTyler Retzlaff __extension__ ({ uint64_t __v = v; __iowmb(); __arch_putq(__v, c); __v; }) 463af733baSHemant Agrawal #define writeq32(v, c) \ 47*93998f3cSTyler Retzlaff __extension__ ({ uint32_t __v = v; __iowmb(); __arch_putq32(__v, c); __v; }) 483af733baSHemant Agrawal #define ioread64(_p) readq(_p) 493af733baSHemant Agrawal #define iowrite64(_v, _p) writeq(_v, _p) 503af733baSHemant Agrawal #define iowrite32(_v, _p) writeq32(_v, _p) 513af733baSHemant Agrawal #define __iomem 523af733baSHemant Agrawal 533af733baSHemant Agrawal /*GPP is supposed to use MC commands with low priority*/ 543af733baSHemant Agrawal #define CMD_PRI_LOW 0 /*!< Low Priority command indication */ 553af733baSHemant Agrawal 5616bbc98aSShreyansh Jain struct fsl_mc_io { 5716bbc98aSShreyansh Jain void *regs; 5816bbc98aSShreyansh Jain }; 593af733baSHemant Agrawal 603af733baSHemant Agrawal #endif /* __linux_driver__ */ 613af733baSHemant Agrawal 623af733baSHemant Agrawal #endif /* _FSL_MC_SYS_H */ 63