Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * Copyright (C) 2000 Andreas E. Bombe | |
3 | * 2001 Ben Collins <bcollins@debian.org> | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation; either version 2 of the License, or | |
8 | * (at your option) any later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with this program; if not, write to the Free Software Foundation, | |
17 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
18 | */ | |
19 | ||
20 | #ifndef _IEEE1394_NODEMGR_H | |
21 | #define _IEEE1394_NODEMGR_H | |
22 | ||
23 | #include <linux/device.h> | |
de4394f1 SR |
24 | #include <asm/types.h> |
25 | ||
1da177e4 | 26 | #include "ieee1394_core.h" |
de4394f1 SR |
27 | #include "ieee1394_types.h" |
28 | ||
29 | struct csr1212_csr; | |
30 | struct csr1212_keyval; | |
31 | struct hpsb_host; | |
32 | struct ieee1394_device_id; | |
1da177e4 | 33 | |
1da177e4 LT |
34 | /* This is the start of a Node entry structure. It should be a stable API |
35 | * for which to gather info from the Node Manager about devices attached | |
36 | * to the bus. */ | |
37 | struct bus_options { | |
38 | u8 irmc; /* Iso Resource Manager Capable */ | |
39 | u8 cmc; /* Cycle Master Capable */ | |
40 | u8 isc; /* Iso Capable */ | |
41 | u8 bmc; /* Bus Master Capable */ | |
42 | u8 pmc; /* Power Manager Capable (PNP spec) */ | |
43 | u8 cyc_clk_acc; /* Cycle clock accuracy */ | |
44 | u8 max_rom; /* Maximum block read supported in the CSR */ | |
45 | u8 generation; /* Incremented when configrom changes */ | |
46 | u8 lnkspd; /* Link speed */ | |
47 | u16 max_rec; /* Maximum packet size node can receive */ | |
48 | }; | |
49 | ||
1da177e4 LT |
50 | #define UNIT_DIRECTORY_VENDOR_ID 0x01 |
51 | #define UNIT_DIRECTORY_MODEL_ID 0x02 | |
52 | #define UNIT_DIRECTORY_SPECIFIER_ID 0x04 | |
53 | #define UNIT_DIRECTORY_VERSION 0x08 | |
54 | #define UNIT_DIRECTORY_HAS_LUN_DIRECTORY 0x10 | |
55 | #define UNIT_DIRECTORY_LUN_DIRECTORY 0x20 | |
56 | #define UNIT_DIRECTORY_HAS_LUN 0x40 | |
57 | ||
58 | /* | |
59 | * A unit directory corresponds to a protocol supported by the | |
60 | * node. If a node supports eg. IP/1394 and AV/C, its config rom has a | |
61 | * unit directory for each of these protocols. | |
62 | */ | |
63 | struct unit_directory { | |
e1d118f1 SR |
64 | struct node_entry *ne; /* The node which this directory belongs to */ |
65 | octlet_t address; /* Address of the unit directory on the node */ | |
1da177e4 LT |
66 | u8 flags; /* Indicates which entries were read */ |
67 | ||
68 | quadlet_t vendor_id; | |
69 | struct csr1212_keyval *vendor_name_kv; | |
1da177e4 LT |
70 | |
71 | quadlet_t model_id; | |
72 | struct csr1212_keyval *model_name_kv; | |
73 | quadlet_t specifier_id; | |
74 | quadlet_t version; | |
d7794c86 | 75 | quadlet_t directory_id; |
1da177e4 LT |
76 | |
77 | unsigned int id; | |
78 | ||
79 | int ignore_driver; | |
80 | ||
81 | int length; /* Number of quadlets */ | |
82 | ||
83 | struct device device; | |
dd7f2928 | 84 | struct device unit_dev; |
1da177e4 LT |
85 | |
86 | struct csr1212_keyval *ud_kv; | |
e1d118f1 | 87 | u32 lun; /* logical unit number immediate value */ |
1da177e4 LT |
88 | }; |
89 | ||
90 | struct node_entry { | |
91 | u64 guid; /* GUID of this node */ | |
92 | u32 guid_vendor_id; /* Top 24bits of guid */ | |
1da177e4 LT |
93 | |
94 | struct hpsb_host *host; /* Host this node is attached to */ | |
95 | nodeid_t nodeid; /* NodeID */ | |
96 | struct bus_options busopt; /* Bus Options */ | |
6848408a | 97 | bool needs_probe; |
1da177e4 LT |
98 | unsigned int generation; /* Synced with hpsb generation */ |
99 | ||
100 | /* The following is read from the config rom */ | |
101 | u32 vendor_id; | |
102 | struct csr1212_keyval *vendor_name_kv; | |
1da177e4 LT |
103 | |
104 | u32 capabilities; | |
1da177e4 LT |
105 | |
106 | struct device device; | |
dd7f2928 | 107 | struct device node_dev; |
1da177e4 LT |
108 | |
109 | /* Means this node is not attached anymore */ | |
fc392fe8 | 110 | bool in_limbo; |
1da177e4 LT |
111 | |
112 | struct csr1212_csr *csr; | |
113 | }; | |
114 | ||
115 | struct hpsb_protocol_driver { | |
116 | /* The name of the driver, e.g. SBP2 or IP1394 */ | |
117 | const char *name; | |
118 | ||
119 | /* | |
120 | * The device id table describing the protocols and/or devices | |
121 | * supported by this driver. This is used by the nodemgr to | |
122 | * decide if a driver could support a given node, but the | |
123 | * probe function below can implement further protocol | |
124 | * dependent or vendor dependent checking. | |
125 | */ | |
126 | struct ieee1394_device_id *id_table; | |
127 | ||
128 | /* | |
129 | * The update function is called when the node has just | |
130 | * survived a bus reset, i.e. it is still present on the bus. | |
131 | * However, it may be necessary to reestablish the connection | |
132 | * or login into the node again, depending on the protocol. If the | |
133 | * probe fails (returns non-zero), we unbind the driver from this | |
134 | * device. | |
135 | */ | |
136 | int (*update)(struct unit_directory *ud); | |
137 | ||
138 | /* Our LDM structure */ | |
139 | struct device_driver driver; | |
140 | }; | |
141 | ||
ed30c26e BC |
142 | int __hpsb_register_protocol(struct hpsb_protocol_driver *, struct module *); |
143 | static inline int hpsb_register_protocol(struct hpsb_protocol_driver *driver) | |
144 | { | |
145 | return __hpsb_register_protocol(driver, THIS_MODULE); | |
146 | } | |
147 | ||
1da177e4 LT |
148 | void hpsb_unregister_protocol(struct hpsb_protocol_driver *driver); |
149 | ||
150 | static inline int hpsb_node_entry_valid(struct node_entry *ne) | |
151 | { | |
152 | return ne->generation == get_hpsb_generation(ne->host); | |
153 | } | |
afd6546d | 154 | void hpsb_node_fill_packet(struct node_entry *ne, struct hpsb_packet *packet); |
1da177e4 LT |
155 | int hpsb_node_write(struct node_entry *ne, u64 addr, |
156 | quadlet_t *buffer, size_t length); | |
afd6546d | 157 | int nodemgr_for_each_host(void *data, int (*cb)(struct hpsb_host *, void *)); |
1da177e4 | 158 | |
1da177e4 LT |
159 | int init_ieee1394_nodemgr(void); |
160 | void cleanup_ieee1394_nodemgr(void); | |
161 | ||
1da177e4 LT |
162 | /* The template for a host device */ |
163 | extern struct device nodemgr_dev_template_host; | |
164 | ||
165 | /* Bus attributes we export */ | |
166 | extern struct bus_attribute *const fw_bus_attrs[]; | |
167 | ||
168 | #endif /* _IEEE1394_NODEMGR_H */ |