summaryrefslogtreecommitdiff
path: root/mtac.h
diff options
context:
space:
mode:
authorJohn Klug <john.klug@multitech.com>2018-10-15 14:20:09 -0500
committerJohn Klug <john.klug@multitech.com>2018-10-15 14:20:09 -0500
commita368a57095b7833ff8155412bb379b75a69dfbd5 (patch)
tree5d0f1780d3d357d7af22d2262cf831d32b6250e8 /mtac.h
downloadmtac-a368a57095b7833ff8155412bb379b75a69dfbd5.tar.gz
mtac-a368a57095b7833ff8155412bb379b75a69dfbd5.tar.bz2
mtac-a368a57095b7833ff8155412bb379b75a69dfbd5.zip
mtac driver derived from mts-io 2.2.2
Diffstat (limited to 'mtac.h')
-rw-r--r--mtac.h95
1 files changed, 95 insertions, 0 deletions
diff --git a/mtac.h b/mtac.h
new file mode 100644
index 0000000..1faa104
--- /dev/null
+++ b/mtac.h
@@ -0,0 +1,95 @@
+#ifndef IO_MODULE_MTAC_H_
+#define IO_MODULE_MTAC_H_
+
+// NUM_AP should be defined from the board code
+// it should be set to the value of CONFIG_MTS_NUM_ACCESSORY_PORTS
+// arch/arm/mach-at91/board-dt-sam9.c
+// if it is 0 or undefined, there is no accessory card support on this HW
+#ifdef CONFIG_MTS_NUM_ACCESSORY_PORTS
+
+#ifndef NUM_AP
+#define NUM_AP CONFIG_MTS_NUM_ACCESSORY_PORTS
+#endif
+
+#else
+#define NUM_AP 0
+#endif
+
+
+#define PRODUCT_ID_MTAC_GPIOB "MTAC-GPIOB"
+#define PRODUCT_ID_MTAC_MFSER "MTAC-MFSER"
+#define PRODUCT_ID_MTAC_ETH "MTAC-ETH"
+#define PRODUCT_ID_MTAC_LORA "MTAC-LORA"
+#define PRODUCT_ID_MTAC_PULSE "MTAC-PULSE"
+#define PRODUCT_ID_MTAC_XDOT "MTAC-XDOT"
+
+
+#define DEBUG 1
+
+/* Hardware version must be fewer characters than hw_version
+ in struct mts_ap_eeprom_layout */
+/* MTAC-LORA with native SPI or FTDI FT4222 */
+#define HW_VERSION_MTAC_LORA_0_0 "MTAC-LORA-0.0"
+/* MTAC-LORA2 with FTDI FT232H */
+#define HW_VERSION_MTAC_LORA_1_0 "MTAC-LORA-1.0"
+#define HW_VERSION_MTAC_LORA_1_1 "MTAC-LORA-1.1"
+#define HW_VERSION_MTAC_LORA_1_5 "MTAC-LORA-1.5"
+/* Code assumes CRESET/CDONE (SPI programming) cases will not
+ * exactly match MTAC-LORA-0.0, 1.0, or 1.1. Also levels before
+ * 1.5 must be the same length.
+ */
+
+enum {
+ MTAC_NONE,
+ MTAC_GPIOB_0_0,
+ MTAC_MFSER_0_0,
+ MTAC_ETH_0_0,
+ MTAC_LORA_0_0,
+ MTAC_LORA_1_0,
+ MTAC_LORA_1_1,
+ MTAC_LORA_1_5,
+ MTAC_PULSE_1_0,
+ MTAC_XDOT_0_0,
+};
+
+enum ap {
+ port_1 = 1,
+ port_2,
+};
+
+// info for accessory port
+// contains function pointers for setup and teardown and useful info
+// each type of accessory card should have one of these
+struct ap_info {
+ char product_id[32];
+ bool (*setup)(enum ap port);
+ bool (*teardown)(enum ap port);
+ char* (*gpio_pin_name_by_attr_name)(const char* name, int port);
+ struct gpio_pin *gpio_pins;
+ struct kobject *subdirs;
+ struct attribute_group attr_group;
+};
+
+extern struct platform_device *mts_io_platform_device;
+
+extern uint8_t mts_ap_eeprom[NUM_AP][512];
+extern struct mutex mtac_mutex;
+
+extern void mtac_clear_port_pins(int port_index);
+extern void mtac_set_port_pins(int port_index, struct gpio_pin *pins, struct kobject *subdir);
+extern struct kobj_attribute* mtac_create_attribute(const char* _name, umode_t _mode);
+extern int mtac_port_from_kobject(struct kobject *kobj);
+extern ssize_t mtac_show_product_info(struct kobject *kobj, struct kobj_attribute *attr, char *buf);
+extern bool mtac_add_product_info_attributes(int port, struct attribute** attrs, int* index);
+extern struct gpio_pin *mtac_gpio_pin_by_attr_name(const char *name, int port);
+extern ssize_t mtac_attr_show_ap_gpio_pin(struct kobject *kobj,
+ struct kobj_attribute *attr,
+ char *buf);
+extern ssize_t mtac_attr_store_ap_gpio_pin(struct kobject *kobj,
+ struct kobj_attribute *attr, const char *buf, size_t count);
+extern struct gpio_pin *mtac_gpio_pin_by_num(unsigned num, int port_index);
+extern struct gpio_pin *mtac_gpio_pin_by_name(const char *name, int port_index);
+extern void mtac_clear_port_pins(int port_index);
+extern int mtac_find(void(*set_info)(struct ap_info* info), const char *target_product_id);
+extern struct ap_info *mtac_port_info[];
+#endif /* IO_MODULE_MTAC_H_ */