mbgtools-lx  4.2.8
mbggenio.h File Reference
#include <mbg_arch.h>
#include <mbgddmsg.h>

Go to the source code of this file.

Data Structures

struct  MBG_IOMEM_RSRC
 Bus memory resource information for a device. More...
 
struct  MBG_IOPORT_RSRC
 I/O port resource information for a device. More...
 
struct  MBG_IRQ_RSRC
 IRQ resource information for a device. More...
 

Macros

#define MBG_USE_MM_IO_FOR_PCI   0
 
#define FAR
 
#define _MBG_IOMEM   volatile __iomem
 
#define _mbg_ioremap(_base, _num)   ( _base )
 
#define _mbg_iounmap(_base, _num)   _nop_macro_fnc()
 
#define _mbg_mmiowb()   _mmiowb()
 
#define _mbg_rmb()   _nop_macro_fnc()
 
#define _mbg_wmb()   _nop_macro_fnc()
 
#define _mbg_mmrd8(_iomem_addr)   readb( (_iomem_addr) )
 
#define _mbg_mmrd16_native(_iomem_addr)   _cpu_to_mbg16( readw( (_iomem_addr) ) )
 
#define _mbg_mmrd32_native(_iomem_addr)   _cpu_to_mbg32( readl( (_iomem_addr) ) )
 
#define _mbg_mmrd16_to_cpu(_iomem_addr)   readw( (_iomem_addr) )
 
#define _mbg_mmrd32_to_cpu(_iomem_addr)   readl( (_iomem_addr) )
 
#define _mbg_mmwr8(_iomem_addr, _val)   writeb( (_val), (_iomem_addr) )
 
#define _mbg_mmwr16_native(_iomem_addr, _val)   writew( _mbg_to_cpu16( (_val) ), (_iomem_addr) )
 
#define _mbg_mmwr32_native(_iomem_addr, _val)   writel( _mbg_to_cpu32( (_val) ), (_iomem_addr) )
 
#define _mbg_mmwr16_to_mbg(_iomem_addr, _val)   writew( (_val), (_iomem_addr) )
 
#define _mbg_mmwr32_to_mbg(_iomem_addr, _val)   writel( (_val), (_iomem_addr) )
 
#define _mbg_mmrd8_offs(_dev, _rsrc_idx, _iomem_offs)   _mbg_mmrd8( (uint8_t _MBG_IOMEM *) (_dev)->mm_asic_addr + (_iomem_offs) )
 
#define _mbg_mmrd32_to_cpu_offs(_dev, _rsrc_idx, _iomem_offs)   _mbg_mmrd32_to_cpu( (uint8_t _MBG_IOMEM *) (_dev)->mm_addr_asic + (_iomem_offs) )
 
#define _mbg_inp8(_dev, _rsrc_idx, _port_addr)   ( (uint8_t) inb( (_port_addr) ) )
 
#define _mbg_inp16_native(_dev, _rsrc_idx, _port_addr)   _cpu_to_mbg16( inw( (_port_addr) ) )
 
#define _mbg_inp32_native(_dev, _rsrc_idx, _port_addr)   _cpu_to_mbg32( inl( (_port_addr) ) )
 
#define _mbg_inp16_to_cpu(_dev, _rsrc_idx, _port_addr)   ( (uint16_t) inw( (_port_addr) ) )
 
#define _mbg_inp32_to_cpu(_dev, _rsrc_idx, _port_addr)   ( (uint32_t) inl( (_port_addr) ) )
 
#define _mbg_outp8(_dev, _rsrc_idx, _port_addr, _val)   outb( (_val), (_port_addr) )
 
#define _mbg_outp16_native(_dev, _rsrc_idx, _port_addr, _val)   outw( _mbg_to_cpu16( (_val) ), (_port_addr) )
 
#define _mbg_outp32_native(_dev, _rsrc_idx, _port_addr, _val)   outl( _mbg_to_cpu32( (_val) ), (_port_addr) )
 
#define _mbg_outp16_to_mbg(_dev, _rsrc_idx, _port_addr, _val)   outw( (_val), (_port_addr) )
 
#define _mbg_outp32_to_mbg(_dev, _rsrc_idx, _port_addr, _val)   outl( (_val), (_port_addr) )
 

Typedefs

typedef uint64_t MBG_IOMEM_ADDR_RAW
 
typedef void volatile __iomem * MBG_IOMEM_ADDR_MAPPED
 
typedef ulong MBG_IOPORT_ADDR_RAW
 
typedef ulong MBG_IOPORT_ADDR_MAPPED
 

Functions

static __mbg_inline int mbg_map_iomem_rsrc (MBG_IOMEM_RSRC *p)
 Map I/O memory resource to get a virtual address. More...
 
static __mbg_inline void mbg_unmap_iomem_rsrc (MBG_IOMEM_RSRC *p)
 Unmap an I/O memory resource to release the virtual address. More...
 
static __mbg_inline int mbg_map_ioport_rsrc (MBG_IOPORT_RSRC *p)
 Map an I/O port resource to get a virtual address. More...
 
static __mbg_inline void mbg_unmap_ioport_rsrc (MBG_IOPORT_RSRC *p)
 Unmap an I/O port resource to release the virtual address. More...
 
static __mbg_inline uint8_t mbg_mmrd8_native (uint8_t volatile __iomem *p)
 
static __mbg_inline uint16_t mbg_mmrd16_native (uint16_t volatile __iomem *p)
 
static __mbg_inline uint32_t mbg_mmrd32_native (uint32_t volatile __iomem *p)
 
static __mbg_inline void mbg_wrmm8_native (uint8_t val, uint8_t volatile __iomem *p)
 
static __mbg_inline void mbg_wrmm16_native (uint16_t val, uint16_t volatile __iomem *p)
 
static __mbg_inline void mbg_wrmm32_native (uint32_t val, uint32_t volatile __iomem *p)
 

Macro Definition Documentation

◆ _mbg_inp16_native

#define _mbg_inp16_native (   _dev,
  _rsrc_idx,
  _port_addr 
)    _cpu_to_mbg16( inw( (_port_addr) ) )

Definition at line 611 of file mbggenio.h.

◆ _mbg_inp16_to_cpu

#define _mbg_inp16_to_cpu (   _dev,
  _rsrc_idx,
  _port_addr 
)    ( (uint16_t) inw( (_port_addr) ) )

Definition at line 613 of file mbggenio.h.

Referenced by pcps_probe_device(), and pcps_read_amcc_s5933().

◆ _mbg_inp32_native

#define _mbg_inp32_native (   _dev,
  _rsrc_idx,
  _port_addr 
)    _cpu_to_mbg32( inl( (_port_addr) ) )

Definition at line 612 of file mbggenio.h.

Referenced by pcps_read_amcc_s5920(), and pcps_read_asic().

◆ _mbg_inp32_to_cpu

#define _mbg_inp32_to_cpu (   _dev,
  _rsrc_idx,
  _port_addr 
)    ( (uint32_t) inl( (_port_addr) ) )

◆ _mbg_inp8

#define _mbg_inp8 (   _dev,
  _rsrc_idx,
  _port_addr 
)    ( (uint8_t) inb( (_port_addr) ) )

◆ _MBG_IOMEM

#define _MBG_IOMEM   volatile __iomem

◆ _mbg_ioremap

#define _mbg_ioremap (   _base,
  _num 
)    ( _base )

Definition at line 189 of file mbggenio.h.

Referenced by ioctl_switch(), and mbg_map_ioport_rsrc().

◆ _mbg_iounmap

#define _mbg_iounmap (   _base,
  _num 
)    _nop_macro_fnc()

Definition at line 190 of file mbggenio.h.

Referenced by mbg_unmap_ioport_rsrc().

◆ _mbg_mmiowb

#define _mbg_mmiowb ( )    _mmiowb()

Definition at line 480 of file mbggenio.h.

◆ _mbg_mmrd16_native

#define _mbg_mmrd16_native (   _iomem_addr)    _cpu_to_mbg16( readw( (_iomem_addr) ) )

Definition at line 573 of file mbggenio.h.

◆ _mbg_mmrd16_to_cpu

#define _mbg_mmrd16_to_cpu (   _iomem_addr)    readw( (_iomem_addr) )

Definition at line 575 of file mbggenio.h.

◆ _mbg_mmrd32_native

#define _mbg_mmrd32_native (   _iomem_addr)    _cpu_to_mbg32( readl( (_iomem_addr) ) )

Definition at line 574 of file mbggenio.h.

◆ _mbg_mmrd32_to_cpu

#define _mbg_mmrd32_to_cpu (   _iomem_addr)    readl( (_iomem_addr) )

◆ _mbg_mmrd32_to_cpu_offs

#define _mbg_mmrd32_to_cpu_offs (   _dev,
  _rsrc_idx,
  _iomem_offs 
)    _mbg_mmrd32_to_cpu( (uint8_t _MBG_IOMEM *) (_dev)->mm_addr_asic + (_iomem_offs) )

Definition at line 590 of file mbggenio.h.

◆ _mbg_mmrd8

#define _mbg_mmrd8 (   _iomem_addr)    readb( (_iomem_addr) )

Definition at line 572 of file mbggenio.h.

◆ _mbg_mmrd8_offs

#define _mbg_mmrd8_offs (   _dev,
  _rsrc_idx,
  _iomem_offs 
)    _mbg_mmrd8( (uint8_t _MBG_IOMEM *) (_dev)->mm_asic_addr + (_iomem_offs) )

Definition at line 587 of file mbggenio.h.

Referenced by _pcps_ddev_read_status_port().

◆ _mbg_mmwr16_native

#define _mbg_mmwr16_native (   _iomem_addr,
  _val 
)    writew( _mbg_to_cpu16( (_val) ), (_iomem_addr) )

Definition at line 579 of file mbggenio.h.

◆ _mbg_mmwr16_to_mbg

#define _mbg_mmwr16_to_mbg (   _iomem_addr,
  _val 
)    writew( (_val), (_iomem_addr) )

Definition at line 581 of file mbggenio.h.

◆ _mbg_mmwr32_native

#define _mbg_mmwr32_native (   _iomem_addr,
  _val 
)    writel( _mbg_to_cpu32( (_val) ), (_iomem_addr) )

Definition at line 580 of file mbggenio.h.

◆ _mbg_mmwr32_to_mbg

#define _mbg_mmwr32_to_mbg (   _iomem_addr,
  _val 
)    writel( (_val), (_iomem_addr) )

Definition at line 582 of file mbggenio.h.

◆ _mbg_mmwr8

#define _mbg_mmwr8 (   _iomem_addr,
  _val 
)    writeb( (_val), (_iomem_addr) )

Definition at line 578 of file mbggenio.h.

◆ _mbg_outp16_native

#define _mbg_outp16_native (   _dev,
  _rsrc_idx,
  _port_addr,
  _val 
)    outw( _mbg_to_cpu16( (_val) ), (_port_addr) )

Definition at line 617 of file mbggenio.h.

◆ _mbg_outp16_to_mbg

#define _mbg_outp16_to_mbg (   _dev,
  _rsrc_idx,
  _port_addr,
  _val 
)    outw( (_val), (_port_addr) )

Definition at line 619 of file mbggenio.h.

◆ _mbg_outp32_native

#define _mbg_outp32_native (   _dev,
  _rsrc_idx,
  _port_addr,
  _val 
)    outl( _mbg_to_cpu32( (_val) ), (_port_addr) )

Definition at line 618 of file mbggenio.h.

◆ _mbg_outp32_to_mbg

#define _mbg_outp32_to_mbg (   _dev,
  _rsrc_idx,
  _port_addr,
  _val 
)    outl( (_val), (_port_addr) )

Definition at line 620 of file mbggenio.h.

Referenced by pcps_read_asic().

◆ _mbg_outp8

#define _mbg_outp8 (   _dev,
  _rsrc_idx,
  _port_addr,
  _val 
)    outb( (_val), (_port_addr) )

Definition at line 616 of file mbggenio.h.

Referenced by pcps_read_amcc_s5920(), pcps_read_amcc_s5933(), and pcps_read_std().

◆ _mbg_rmb

#define _mbg_rmb ( )    _nop_macro_fnc()

Definition at line 486 of file mbggenio.h.

Referenced by mbg_mmrd16_native(), mbg_mmrd32_native(), and mbg_mmrd8_native().

◆ _mbg_wmb

#define _mbg_wmb ( )    _nop_macro_fnc()

Definition at line 490 of file mbggenio.h.

Referenced by mbg_wrmm16_native(), mbg_wrmm32_native(), and mbg_wrmm8_native().

◆ FAR

◆ MBG_USE_MM_IO_FOR_PCI

#define MBG_USE_MM_IO_FOR_PCI   0

Definition at line 125 of file mbggenio.h.

Typedef Documentation

◆ MBG_IOMEM_ADDR_MAPPED

typedef void volatile __iomem* MBG_IOMEM_ADDR_MAPPED

Definition at line 176 of file mbggenio.h.

◆ MBG_IOMEM_ADDR_RAW

Definition at line 175 of file mbggenio.h.

◆ MBG_IOPORT_ADDR_MAPPED

Definition at line 187 of file mbggenio.h.

◆ MBG_IOPORT_ADDR_RAW

Definition at line 186 of file mbggenio.h.

Function Documentation

◆ mbg_map_iomem_rsrc()

static __mbg_inline int mbg_map_iomem_rsrc ( MBG_IOMEM_RSRC p)
static

Map I/O memory resource to get a virtual address.

Parameters
[in,out]pPointer to an I/O memory resource structure
Returns
MBG_SUCCESS on success, else one of the MBG_ERROR_CODES

Definition at line 330 of file mbggenio.h.

References _mbg_kdd_msg_2, MBG_IOMEM_RSRC::len, MBG_ERR_NO_MEM, MBG_LOG_WARN, MBG_SUCCESS, MBG_IOMEM_RSRC::start_mapped, and MBG_IOMEM_RSRC::start_raw.

Referenced by pcps_add_rsrc_mem().

◆ mbg_map_ioport_rsrc()

static __mbg_inline int mbg_map_ioport_rsrc ( MBG_IOPORT_RSRC p)
static

Map an I/O port resource to get a virtual address.

Parameters
[in,out]pPointer to an I/O port resource structure
Returns
MBG_SUCCESS on success, else one of the MBG_ERROR_CODES

Definition at line 438 of file mbggenio.h.

References _mbg_ioremap, _mbg_kdd_msg_2, MBG_IOPORT_RSRC::base_mapped, MBG_IOPORT_RSRC::base_raw, MBG_LOG_WARN, MBG_SUCCESS, and MBG_IOPORT_RSRC::num.

Referenced by pcps_add_rsrc_io().

◆ mbg_mmrd16_native()

static __mbg_inline uint16_t mbg_mmrd16_native ( uint16_t volatile __iomem *  p)
static

Definition at line 511 of file mbggenio.h.

References _mbg_rmb.

◆ mbg_mmrd32_native()

static __mbg_inline uint32_t mbg_mmrd32_native ( uint32_t volatile __iomem *  p)
static

Definition at line 521 of file mbggenio.h.

References _mbg_rmb.

◆ mbg_mmrd8_native()

static __mbg_inline uint8_t mbg_mmrd8_native ( uint8_t volatile __iomem *  p)
static

Definition at line 500 of file mbggenio.h.

References _mbg_rmb.

◆ mbg_unmap_iomem_rsrc()

static __mbg_inline void mbg_unmap_iomem_rsrc ( MBG_IOMEM_RSRC p)
static

Unmap an I/O memory resource to release the virtual address.

Parameters
[in,out]pPointer to an I/O memory resource structure

Definition at line 397 of file mbggenio.h.

References MBG_IOMEM_RSRC::len, and MBG_IOMEM_RSRC::start_mapped.

Referenced by pcps_release_rsrcs().

◆ mbg_unmap_ioport_rsrc()

static __mbg_inline void mbg_unmap_ioport_rsrc ( MBG_IOPORT_RSRC p)
static

Unmap an I/O port resource to release the virtual address.

Parameters
[in,out]pPointer to an I/O port resource structure

Definition at line 464 of file mbggenio.h.

References _mbg_iounmap, MBG_IOPORT_RSRC::base_mapped, MBG_IOPORT_RSRC::base_raw, and MBG_IOPORT_RSRC::num.

Referenced by pcps_release_rsrcs().

◆ mbg_wrmm16_native()

static __mbg_inline void mbg_wrmm16_native ( uint16_t  val,
uint16_t volatile __iomem *  p 
)
static

Definition at line 540 of file mbggenio.h.

References _mbg_wmb.

◆ mbg_wrmm32_native()

static __mbg_inline void mbg_wrmm32_native ( uint32_t  val,
uint32_t volatile __iomem *  p 
)
static

Definition at line 549 of file mbggenio.h.

References _mbg_wmb.

◆ mbg_wrmm8_native()

static __mbg_inline void mbg_wrmm8_native ( uint8_t  val,
uint8_t volatile __iomem *  p 
)
static

Definition at line 531 of file mbggenio.h.

References _mbg_wmb.