summaryrefslogtreecommitdiff
path: root/io-module/mts_io.h
blob: 35bb76e7025fe1749b30f8c7a327d60262492bfa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#ifndef __MTS_IO_H
#define __MTS_IO_H

#include "mts_eeprom.h"
#include <linux/gpio.h>

#define DEBUG		0

#define __log(level, name, format, args...) \
	printk(level "[" name "] " DRIVER_NAME ":%s:%d: " format "\n" , \
			__func__ , __LINE__ , ## args)

#define log_emerg(format, args...)	__log(KERN_EMERG, "EMERG", format , ## args)
#define log_alert(format, args...)	__log(KERN_ALERT, "ALERT", format , ## args)
#define log_crit(format, args...)	__log(KERN_CRIT, "CRIT", format , ## args)
#define log_error(format, args...)	__log(KERN_ERR, "ERROR", format , ## args)
#define log_warning(format, args...)	__log(KERN_WARNING, "WARNING", format , ## args)
#define log_notice(format, args...)	__log(KERN_NOTICE, "NOTICE", format , ## args)
#define log_info(format, args...)	__log(KERN_INFO, "INFO", format , ## args)
#if DEBUG
#  define log_debug(format, args...)	__log(KERN_DEBUG, "DEBUG", format , ## args)
#else
#  define log_debug(format, args...) do {} while (0)
#endif

#define MTS_ATTR_MODE_RW		S_IWUSR | S_IRUGO
#define MTS_ATTR_MODE_RO		S_IRUGO

#define DEVICE_ATTR_MTS(_dev_name, _name, _show, _store) \
struct device_attribute _dev_name = { \
	.attr = { .name = _name, .mode = MTS_ATTR_MODE_RW }, \
	.show = _show, \
	.store = _store, \
}

#define DEVICE_ATTR_RO_MTS(_dev_name, _name, _show) \
struct device_attribute _dev_name = { \
	.attr = { .name = _name, .mode = MTS_ATTR_MODE_RO }, \
	.show = _show, \
}

#define VENDOR_ID_MULTITECH			"Multi-Tech Systems"
#define PRODUCT_ID_MTCDP_E1_DK			"MTCDP-E1-DK"
#define PRODUCT_ID_MT100EOCG			"MT100EOCG"
#define PRODUCT_ID_MTR				"MTR"
#define PRODUCT_ID_MTCDT			"MTCDT"

#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"

/* 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"

#define HW_VERSION_MTCBA2_2_0			"MTCBA2-2.0"
#define HW_VERSION_MTCDP_0_0			"MTCDP-0.0"
#define HW_VERSION_MTCDP_1_0			"MTCDP-1.0"
#define HW_VERSION_MT100EOCG_0_0		"MT100EOCG-0.0"
#define HW_VERSION_MTR_0_0			"MTR-0.0"
#define HW_VERSION_MTR_0_1			"MTR-0.1"
#define HW_VERSION_MTRV1_0_0			"MTRV1-0.0"
#define HW_VERSION_MTRV1_0_1			"MTRV1-0.1"
#define HW_VERSION_MTCDT_0_0			"MTCDT-0.0"
#define HW_VERSION_MTCDT_0_1			"MTCDT-0.1"
#define HW_VERSION_MTCAP_0_0			"MTCAP-0.0"
#define HW_VERSION_MTCAP_0_1			"MTCAP-0.1"


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,
};

struct gpio_pin {
	char name[32];
	struct gpio pin;
	int active_low;
	uint8_t capability;
};

enum {
	LED_OFF,
	LED_ON,
	LED_FLASHING,
};

enum {
	RADIO_UNKNOWN,
	RADIO_LEU1,
	RADIO_LNA3,
};

enum ap {
	port_1 = 1,
	port_2,
};

enum spi_devices {
	din = 0,
	dout = 1,
	adc = 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);
};

#endif /* ~__MTS_IO_H */