/* EP80579 LEB: configuration and access to an XHFC-4SU via CS0. * * Copyright (C) 2010,2012 Avencall * Authors: * Noe Rubinstein * Guillaume Knispel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /*****************************************************************************/ #ifndef _XHFC_LEB_H_ #define _XHFC_LEB_H_ #include #include #include "xhfc.h" #define LEB_CSRBAR 0 #define LEB_MMBAR 1 void leb_init(struct xhfc_pi *leb); static inline u8 read_xhfc(struct xhfc *xhfc, u8 reg_addr) { u8 __iomem *cs_n0 = xhfc->pi->cs_n0; return readb(&cs_n0[reg_addr]); } static inline void write_xhfc(struct xhfc *xhfc, u8 reg_addr, u8 value) { u8 __iomem *cs_n0 = xhfc->pi->cs_n0; writeb(value, &cs_n0[reg_addr]); } static inline void write_xhfc_soft_conf(struct xhfc *xhfc, u8 soft_conf) { u8 __iomem *cs_n1 = xhfc->pi->cs_n1; if (DBG_REGS) printk(KERN_INFO "SOFTCONF: %02x\n", soft_conf); writeb(soft_conf, &cs_n1[0]); /* ensure the write has been completed: */ (void)readb(&cs_n1[0]); } #define read_xhfc(x, reg) ({ \ u8 _res = read_xhfc(x, reg); \ if (DBG_REGS) printk(KERN_DEBUG #reg " -> %02x\n", _res);\ _res; \ }) #define write_xhfc(x, reg, val) ({ \ if (DBG_REGS) printk(KERN_DEBUG #reg " <- %02x\n", val); \ write_xhfc(x, reg, val); \ }) struct tlp_leb_regs { u32 timing_cs[8]; u32 cnfg0; u32 _rsvd1[63]; u32 parity_status; }; #endif /* _XHFC_LEB_H_ */