4 * driver for the carrier TEWS TPCI-200
5 * Copyright (c) 2009 Nicolas Serafini, EIC2 SA
6 * Copyright (c) 2010,2011 Samuel Iglesias Gonsalvez <siglesia@cern.ch>, CERN
7 * Copyright (c) 2012 Samuel Iglesias Gonsalvez <siglesias@igalia.com>, Igalia
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the Free
11 * Software Foundation; version 2 of the License.
17 #include <linux/limits.h>
18 #include <linux/pci.h>
19 #include <linux/spinlock.h>
20 #include <linux/interrupt.h>
21 #include <linux/swab.h>
26 #define TPCI200_NB_SLOT 0x4
27 #define TPCI200_NB_BAR 0x6
29 #define TPCI200_VENDOR_ID 0x1498
30 #define TPCI200_DEVICE_ID 0x30C8
31 #define TPCI200_SUBVENDOR_ID 0x1498
32 #define TPCI200_SUBDEVICE_ID 0x300A
34 #define TPCI200_IP_INTERFACE_BAR 2
35 #define TPCI200_IO_ID_INT_SPACES_BAR 3
36 #define TPCI200_MEM16_SPACE_BAR 4
37 #define TPCI200_MEM8_SPACE_BAR 5
39 #define TPCI200_REVISION_REG 0x00
40 #define TPCI200_CONTROL_A_REG 0x02
41 #define TPCI200_CONTROL_B_REG 0x04
42 #define TPCI200_CONTROL_C_REG 0x06
43 #define TPCI200_CONTROL_D_REG 0x08
44 #define TPCI200_RESET_REG 0x0A
45 #define TPCI200_STATUS_REG 0x0C
47 #define TPCI200_IFACE_SIZE 0x100
49 #define TPCI200_IO_SPACE_OFF 0x0000
50 #define TPCI200_IO_SPACE_GAP 0x0100
51 #define TPCI200_IO_SPACE_SIZE 0x0080
52 #define TPCI200_ID_SPACE_OFF 0x0080
53 #define TPCI200_ID_SPACE_GAP 0x0100
54 #define TPCI200_ID_SPACE_SIZE 0x0040
55 #define TPCI200_INT_SPACE_OFF 0x00C0
56 #define TPCI200_INT_SPACE_GAP 0x0100
57 #define TPCI200_INT_SPACE_SIZE 0x0040
58 #define TPCI200_IOIDINT_SIZE 0x0400
60 #define TPCI200_MEM8_GAP 0x00400000
61 #define TPCI200_MEM8_SIZE 0x00400000
62 #define TPCI200_MEM16_GAP 0x00800000
63 #define TPCI200_MEM16_SIZE 0x00800000
65 #define TPCI200_INT0_EN 0x0040
66 #define TPCI200_INT1_EN 0x0080
67 #define TPCI200_INT0_EDGE 0x0010
68 #define TPCI200_INT1_EDGE 0x0020
69 #define TPCI200_ERR_INT_EN 0x0008
70 #define TPCI200_TIME_INT_EN 0x0004
71 #define TPCI200_RECOVER_EN 0x0002
72 #define TPCI200_CLK32 0x0001
74 #define TPCI200_A_RESET 0x0001
75 #define TPCI200_B_RESET 0x0002
76 #define TPCI200_C_RESET 0x0004
77 #define TPCI200_D_RESET 0x0008
79 #define TPCI200_A_TIMEOUT 0x1000
80 #define TPCI200_B_TIMEOUT 0x2000
81 #define TPCI200_C_TIMEOUT 0x4000
82 #define TPCI200_D_TIMEOUT 0x8000
84 #define TPCI200_A_ERROR 0x0100
85 #define TPCI200_B_ERROR 0x0200
86 #define TPCI200_C_ERROR 0x0400
87 #define TPCI200_D_ERROR 0x0800
89 #define TPCI200_A_INT0 0x0001
90 #define TPCI200_A_INT1 0x0002
91 #define TPCI200_B_INT0 0x0004
92 #define TPCI200_B_INT1 0x0008
93 #define TPCI200_C_INT0 0x0010
94 #define TPCI200_C_INT1 0x0020
95 #define TPCI200_D_INT0 0x0040
96 #define TPCI200_D_INT1 0x0080
98 #define TPCI200_SLOT_INT_MASK 0x00FF
100 #define VME_IOID_SPACE "IOID"
101 #define VME_MEM_SPACE "MEM"
104 * struct slot_irq - slot IRQ definition.
105 * @vector Vector number
106 * @handler Handler called when IRQ arrives
107 * @arg Handler argument
112 int (*handler)(void *);
117 * struct tpci200_slot - data specific to the tpci200 slot.
118 * @slot_id Slot identification gived to external interface
119 * @irq Slot IRQ infos
120 * @io_phys IO physical base address register of the slot
121 * @id_phys ID physical base address register of the slot
122 * @mem_phys MEM physical base address register of the slot
125 struct tpci200_slot {
126 struct ipack_device *dev;
127 struct slot_irq *irq;
128 struct ipack_addr_space io_phys;
129 struct ipack_addr_space id_phys;
130 struct ipack_addr_space mem_phys;
134 * struct tpci200_infos - informations specific of the TPCI200 tpci200.
135 * @pci_dev PCI device
136 * @interface_regs Pointer to IP interface space (Bar 2)
137 * @ioidint_space Pointer to IP ID, IO and INT space (Bar 3)
138 * @mem8_space Pointer to MEM space (Bar 4)
141 struct tpci200_infos {
142 struct pci_dev *pdev;
143 struct pci_device_id *id_table;
144 void __iomem *interface_regs;
145 void __iomem *ioidint_space;
146 void __iomem *mem8_space;
147 struct ipack_bus_device *ipack_bus;
149 struct tpci200_board {
150 struct list_head list;
153 struct tpci200_slot *slots;
154 struct tpci200_infos *info;
157 #endif /* _TPCI200_H_ */