summaryrefslogtreecommitdiff
path: root/xhfc/xhfc_leb.h
blob: ac56ee2d6457fa0c441d5eb09acae8bff0b767e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/* 
 * (C) 2007 Copyright Cologne Chip AG
 * Authors : Martin Bachem, Joerg Ciesielski
 * Contact : info@colognechip.com
 *
 * 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, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */


/*****************************************************************************/

#ifndef _XHFC_LEB_H_
#define _XHFC_LEB_H_

#include <linux/kernel.h>
#include <linux/pci.h>

#include "xhfc.h"

#define LEB_CSRBAR      0
#define LEB_MMBAR       1

#define IRQ_TLP_GPIO_30		31

extern uint trigger;
extern uint debug;

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[(trigger << 8) + 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[(trigger << 8) + reg_addr]);
}

#ifdef DEBUG
#define read_xhfc(x, reg) ({						\
		u8 _res = read_xhfc(x, reg);				\
		if(DBG_REGS) printk(KERN_INFO #reg " -> %02x\n", _res);	\
		_res;							\
	})

#define write_xhfc(x, reg, val) ({						\
		if(DBG_REGS) printk(KERN_INFO #reg " <- %02x\n", val);		\
		write_xhfc(x, reg, val);					\
	})
#endif

struct tlp_leb_regs {
	u32     timing_cs[8];
	u32     cnfg0;
	u32     _rsvd1[63];
	u32     parity_status;
};

#endif	/* _XHFC_LEB_H_ */