]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/staging/ipack/bridges/tpci200.h
Merge branch 'pm-acpi' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
[karo-tx-linux.git] / drivers / staging / ipack / bridges / tpci200.h
1 /**
2  * tpci200.h
3  *
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
8  *
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.
12  */
13
14 #ifndef _TPCI200_H_
15 #define _TPCI200_H_
16
17 #include <linux/version.h>
18 #include <linux/limits.h>
19 #include <linux/pci.h>
20 #include <linux/spinlock.h>
21 #include <linux/interrupt.h>
22 #include <linux/swab.h>
23 #include <linux/io.h>
24
25 #include "../ipack.h"
26
27 #define TPCI200_NB_SLOT               0x4
28 #define TPCI200_NB_BAR                0x6
29
30 #define TPCI200_VENDOR_ID             0x1498
31 #define TPCI200_DEVICE_ID             0x30C8
32 #define TPCI200_SUBVENDOR_ID          0x1498
33 #define TPCI200_SUBDEVICE_ID          0x300A
34
35 #define TPCI200_IP_INTERFACE_BAR      2
36 #define TPCI200_IO_ID_INT_SPACES_BAR  3
37 #define TPCI200_MEM16_SPACE_BAR       4
38 #define TPCI200_MEM8_SPACE_BAR        5
39
40 #define TPCI200_REVISION_REG          0x00
41 #define TPCI200_CONTROL_A_REG         0x02
42 #define TPCI200_CONTROL_B_REG         0x04
43 #define TPCI200_CONTROL_C_REG         0x06
44 #define TPCI200_CONTROL_D_REG         0x08
45 #define TPCI200_RESET_REG             0x0A
46 #define TPCI200_STATUS_REG            0x0C
47
48 #define TPCI200_IFACE_SIZE            0x100
49
50 #define TPCI200_IO_SPACE_OFF          0x0000
51 #define TPCI200_IO_SPACE_GAP          0x0100
52 #define TPCI200_IO_SPACE_SIZE         0x0080
53 #define TPCI200_ID_SPACE_OFF          0x0080
54 #define TPCI200_ID_SPACE_GAP          0x0100
55 #define TPCI200_ID_SPACE_SIZE         0x0040
56 #define TPCI200_INT_SPACE_OFF         0x00C0
57 #define TPCI200_INT_SPACE_GAP         0x0100
58 #define TPCI200_INT_SPACE_SIZE        0x0040
59 #define TPCI200_IOIDINT_SIZE          0x0400
60
61 #define TPCI200_MEM8_GAP              0x00400000
62 #define TPCI200_MEM8_SIZE             0x00400000
63 #define TPCI200_MEM16_GAP             0x00800000
64 #define TPCI200_MEM16_SIZE            0x00800000
65
66 #define TPCI200_INT0_EN               0x0040
67 #define TPCI200_INT1_EN               0x0080
68 #define TPCI200_INT0_EDGE             0x0010
69 #define TPCI200_INT1_EDGE             0x0020
70 #define TPCI200_ERR_INT_EN            0x0008
71 #define TPCI200_TIME_INT_EN           0x0004
72 #define TPCI200_RECOVER_EN            0x0002
73 #define TPCI200_CLK32                 0x0001
74
75 #define TPCI200_A_RESET               0x0001
76 #define TPCI200_B_RESET               0x0002
77 #define TPCI200_C_RESET               0x0004
78 #define TPCI200_D_RESET               0x0008
79
80 #define TPCI200_A_TIMEOUT             0x1000
81 #define TPCI200_B_TIMEOUT             0x2000
82 #define TPCI200_C_TIMEOUT             0x4000
83 #define TPCI200_D_TIMEOUT             0x8000
84
85 #define TPCI200_A_ERROR               0x0100
86 #define TPCI200_B_ERROR               0x0200
87 #define TPCI200_C_ERROR               0x0400
88 #define TPCI200_D_ERROR               0x0800
89
90 #define TPCI200_A_INT0                0x0001
91 #define TPCI200_A_INT1                0x0002
92 #define TPCI200_B_INT0                0x0004
93 #define TPCI200_B_INT1                0x0008
94 #define TPCI200_C_INT0                0x0010
95 #define TPCI200_C_INT1                0x0020
96 #define TPCI200_D_INT0                0x0040
97 #define TPCI200_D_INT1                0x0080
98
99 #define TPCI200_SLOT_INT_MASK         0x00FF
100
101 #define VME_IOID_SPACE  "IOID"
102 #define VME_MEM_SPACE  "MEM"
103
104 /**
105  * struct slot_irq - slot IRQ definition.
106  * @vector      Vector number
107  * @handler     Handler called when IRQ arrives
108  * @arg         Handler argument
109  * @name        IRQ name
110  *
111  */
112 struct slot_irq {
113         int             vector;
114         int             (*handler)(void *);
115         void            *arg;
116         const char      *name;
117 };
118
119 /**
120  * struct tpci200_slot - data specific to the tpci200 slot.
121  * @slot_id     Slot identification gived to external interface
122  * @irq         Slot IRQ infos
123  * @io_phys     IO physical base address register of the slot
124  * @id_phys     ID physical base address register of the slot
125  * @mem_phys    MEM physical base address register of the slot
126  *
127  */
128 struct tpci200_slot {
129         struct ipack_device     *dev;
130         struct slot_irq         *irq;
131         struct ipack_addr_space io_phys;
132         struct ipack_addr_space id_phys;
133         struct ipack_addr_space mem_phys;
134 };
135
136 /**
137  * struct tpci200_infos - informations specific of the TPCI200 tpci200.
138  * @pci_dev             PCI device
139  * @interface_regs      Pointer to IP interface space (Bar 2)
140  * @ioidint_space       Pointer to IP ID, IO and INT space (Bar 3)
141  * @mem8_space          Pointer to MEM space (Bar 4)
142  * @access_lock         Mutex lock for simultaneous access
143  *
144  */
145 struct tpci200_infos {
146         struct pci_dev                  *pdev;
147         struct pci_device_id            *id_table;
148         void __iomem                    *interface_regs;
149         void __iomem                    *ioidint_space;
150         void __iomem                    *mem8_space;
151         spinlock_t                      access_lock;
152         struct ipack_bus_device         *ipack_bus;
153 };
154 struct tpci200_board {
155         struct list_head        list;
156         unsigned int            number;
157         struct mutex            mutex;
158         struct tpci200_slot     *slots;
159         struct tpci200_infos    *info;
160 };
161
162 #endif /* _TPCI200_H_ */