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
00030
00031
00032
00033
00039
00040
00041 #ifndef _EC_MASTER_H_
00042 #define _EC_MASTER_H_
00043
00044 #include <linux/list.h>
00045 #include <linux/sysfs.h>
00046 #include <linux/timer.h>
00047
00048 #include "device.h"
00049 #include "domain.h"
00050 #include "fsm.h"
00051
00052
00053
00058 typedef enum
00059 {
00060 EC_MASTER_MODE_ORPHANED,
00061 EC_MASTER_MODE_IDLE,
00062 EC_MASTER_MODE_OPERATION
00063 }
00064 ec_master_mode_t;
00065
00066
00067
00072 typedef struct
00073 {
00074 unsigned int timeouts;
00075 unsigned int corrupted;
00076 unsigned int skipped;
00078 unsigned int unmatched;
00080 unsigned long output_jiffies;
00081 }
00082 ec_stats_t;
00083
00084
00085
00091 struct ec_master
00092 {
00093 struct list_head list;
00094 unsigned int reserved;
00095 unsigned int index;
00097 struct kobject kobj;
00099 ec_device_t *device;
00101 ec_fsm_t fsm;
00102 ec_master_mode_t mode;
00104 struct list_head slaves;
00105 unsigned int slave_count;
00107 struct list_head datagram_queue;
00108 uint8_t datagram_index;
00110 struct list_head domains;
00112 int debug_level;
00113 ec_stats_t stats;
00115 struct workqueue_struct *workqueue;
00116 struct work_struct idle_work;
00117 uint32_t idle_cycle_times[HZ];
00118 unsigned int idle_cycle_time_pos;
00120 struct timer_list eoe_timer;
00121 uint32_t eoe_cycle_times[HZ];
00122 unsigned int eoe_cycle_time_pos;
00123 unsigned int eoe_running;
00124 unsigned int eoe_checked;
00126 struct list_head eoe_handlers;
00128 spinlock_t internal_lock;
00129 int (*request_cb)(void *);
00130 void (*release_cb)(void *);
00131 void *cb_data;
00133 uint8_t eeprom_write_enable;
00134 };
00135
00136
00137
00138
00139 int ec_master_init(ec_master_t *, unsigned int, unsigned int);
00140 void ec_master_clear(struct kobject *);
00141 void ec_master_reset(ec_master_t *);
00142
00143
00144 void ec_master_idle_start(ec_master_t *);
00145 void ec_master_idle_stop(ec_master_t *);
00146
00147
00148 void ec_master_eoe_start(ec_master_t *);
00149 void ec_master_eoe_stop(ec_master_t *);
00150
00151
00152 void ec_master_receive_datagrams(ec_master_t *, const uint8_t *, size_t);
00153 void ec_master_queue_datagram(ec_master_t *, ec_datagram_t *);
00154
00155
00156 int ec_master_bus_scan(ec_master_t *);
00157
00158
00159 void ec_master_output_stats(ec_master_t *);
00160 void ec_master_clear_slaves(ec_master_t *);
00161 void ec_master_measure_bus_time(ec_master_t *);
00162
00163
00164 void ec_sync_config(const ec_sii_sync_t *, const ec_slave_t *, uint8_t *);
00165 void ec_fmmu_config(const ec_fmmu_t *, const ec_slave_t *, uint8_t *);
00166 void ec_master_calc_addressing(ec_master_t *);
00167
00168
00169
00170 #endif