00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00035
00036
00037 #ifndef __EC_SLAVE_H__
00038 #define __EC_SLAVE_H__
00039
00040 #include <linux/list.h>
00041 #include <linux/kobject.h>
00042
00043 #include "globals.h"
00044 #include "datagram.h"
00045 #include "pdo.h"
00046 #include "sync.h"
00047 #include "sdo.h"
00048 #include "fsm_slave.h"
00049
00050
00051
00062 #define EC_SLAVE_INFO(slave, fmt, args...) \
00063 printk(KERN_INFO "EtherCAT %u-%u: " fmt, slave->master->index, \
00064 slave->ring_position, ##args)
00065
00076 #define EC_SLAVE_ERR(slave, fmt, args...) \
00077 printk(KERN_ERR "EtherCAT ERROR %u-%u: " fmt, slave->master->index, \
00078 slave->ring_position, ##args)
00079
00090 #define EC_SLAVE_WARN(slave, fmt, args...) \
00091 printk(KERN_WARNING "EtherCAT WARNING %u-%u: " fmt, \
00092 slave->master->index, slave->ring_position, ##args)
00093
00106 #define EC_SLAVE_DBG(slave, level, fmt, args...) \
00107 do { \
00108 if (slave->master->debug_level >= level) { \
00109 printk(KERN_DEBUG "EtherCAT DEBUG %u-%u: " fmt, \
00110 slave->master->index, slave->ring_position, ##args); \
00111 } \
00112 } while (0)
00113
00114
00115
00118 typedef struct {
00119 ec_slave_port_desc_t desc;
00120 ec_slave_port_link_t link;
00121 ec_slave_t *next_slave;
00122 uint32_t receive_time;
00124 uint32_t delay_to_next_dc;
00126 } ec_slave_port_t;
00127
00128
00129
00132 typedef struct {
00133
00134 uint16_t alias;
00135 uint32_t vendor_id;
00136 uint32_t product_code;
00137 uint32_t revision_number;
00138 uint32_t serial_number;
00139 uint16_t boot_rx_mailbox_offset;
00140 uint16_t boot_rx_mailbox_size;
00141 uint16_t boot_tx_mailbox_offset;
00142 uint16_t boot_tx_mailbox_size;
00143 uint16_t std_rx_mailbox_offset;
00144 uint16_t std_rx_mailbox_size;
00145 uint16_t std_tx_mailbox_offset;
00146 uint16_t std_tx_mailbox_size;
00147 uint16_t mailbox_protocols;
00149
00150 char **strings;
00151 unsigned int string_count;
00153
00154 unsigned int has_general;
00155 char *group;
00156 char *image;
00157 char *order;
00158 char *name;
00159 uint8_t physical_layer[EC_MAX_PORTS];
00160 ec_sii_coe_details_t coe_details;
00161 ec_sii_general_flags_t general_flags;
00162 int16_t current_on_ebus;
00164
00165 ec_sync_t *syncs;
00166 unsigned int sync_count;
00168
00169 struct list_head pdos;
00170 } ec_sii_t;
00171
00172
00173
00176 struct ec_slave
00177 {
00178 ec_master_t *master;
00179 ec_device_index_t device_index;
00182
00183 uint16_t ring_position;
00184 uint16_t station_address;
00185 uint16_t effective_alias;
00187 ec_slave_port_t ports[EC_MAX_PORTS];
00189
00190 ec_slave_config_t *config;
00191 ec_slave_state_t requested_state;
00192 ec_slave_state_t current_state;
00193 unsigned int error_flag;
00194 unsigned int force_config;
00195 uint16_t configured_rx_mailbox_offset;
00197 uint16_t configured_rx_mailbox_size;
00199 uint16_t configured_tx_mailbox_offset;
00201 uint16_t configured_tx_mailbox_size;
00203
00204 uint8_t base_type;
00205 uint8_t base_revision;
00206 uint16_t base_build;
00207 uint8_t base_fmmu_count;
00208 uint8_t base_sync_count;
00209 uint8_t base_fmmu_bit_operation;
00210 uint8_t base_dc_supported;
00211 ec_slave_dc_range_t base_dc_range;
00212 uint8_t has_dc_system_time;
00215 uint32_t transmission_delay;
00218
00219 uint16_t *sii_words;
00220 size_t sii_nwords;
00222
00223 ec_sii_t sii;
00225 struct list_head sdo_dictionary;
00226 uint8_t sdo_dictionary_fetched;
00227 unsigned long jiffies_preop;
00229 struct list_head sdo_requests;
00230 struct list_head reg_requests;
00231 struct list_head foe_requests;
00232 struct list_head soe_requests;
00234 ec_fsm_slave_t fsm;
00235 };
00236
00237
00238
00239
00240 void ec_slave_init(ec_slave_t *, ec_master_t *, ec_device_index_t,
00241 uint16_t, uint16_t);
00242 void ec_slave_clear(ec_slave_t *);
00243
00244 void ec_slave_clear_sync_managers(ec_slave_t *);
00245
00246 void ec_slave_request_state(ec_slave_t *, ec_slave_state_t);
00247 void ec_slave_set_state(ec_slave_t *, ec_slave_state_t);
00248
00249
00250 int ec_slave_fetch_sii_strings(ec_slave_t *, const uint8_t *, size_t);
00251 int ec_slave_fetch_sii_general(ec_slave_t *, const uint8_t *, size_t);
00252 int ec_slave_fetch_sii_syncs(ec_slave_t *, const uint8_t *, size_t);
00253 int ec_slave_fetch_sii_pdos(ec_slave_t *, const uint8_t *, size_t,
00254 ec_direction_t);
00255
00256
00257 ec_sync_t *ec_slave_get_sync(ec_slave_t *, uint8_t);
00258
00259 void ec_slave_sdo_dict_info(const ec_slave_t *,
00260 unsigned int *, unsigned int *);
00261 ec_sdo_t *ec_slave_get_sdo(ec_slave_t *, uint16_t);
00262 const ec_sdo_t *ec_slave_get_sdo_const(const ec_slave_t *, uint16_t);
00263 const ec_sdo_t *ec_slave_get_sdo_by_pos_const(const ec_slave_t *, uint16_t);
00264 uint16_t ec_slave_sdo_count(const ec_slave_t *);
00265 const ec_pdo_t *ec_slave_find_pdo(const ec_slave_t *, uint16_t);
00266 void ec_slave_attach_pdo_names(ec_slave_t *);
00267
00268 void ec_slave_calc_port_delays(ec_slave_t *);
00269 void ec_slave_calc_transmission_delays_rec(ec_slave_t *, uint32_t *);
00270
00271
00272
00273 #endif