]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/blob - rpp/src/drv/_tms570_rpp/port_def.c
Add SPI chip name to port configuration
[pes-rpp/rpp-lib.git] / rpp / src / drv / _tms570_rpp / port_def.c
1 /*
2  * Copyright (C) 2015 Czech Technical University in Prague
3  *
4  * Authors:
5  *     - Michal Horn <hornmich@fel.cvut.cz>
6  *     - Michal Sojka <sojkam1@fel.cvut.cz>
7  *
8  * This document contains proprietary information belonging to Czech
9  * Technical University in Prague. Passing on and copying of this
10  * document, and communication of its contents is not permitted
11  * without prior written authorization.
12  *
13  */
14
15 #include "drv/port.h"
16 #include "drv/gio_names.h"
17 #include "drv/gio_tab.h"
18 #include "drv/spi.h"
19 #include "drv/adc.h"
20
21 // Lists of pins assigned to the gio ports
22 static enum pin_name pins_dinmcu[] = {
23         PIN_DIN8, PIN_DIN9, PIN_DIN10, PIN_DIN11,
24         PIN_DIN12, PIN_DIN13, PIN_DIN14, PIN_DIN15
25 };
26 static enum pin_name pins_houtin[] = {
27         PIN_HOUT1IN, PIN_HOUT2IN, PIN_HOUT3IN,
28         PIN_HOUT4IN, PIN_HOUT5IN, PIN_HOUT6IN
29 };
30 static enum pin_name pins_houtdiag[] = {
31         PIN_HOUT1DIAG, PIN_HOUT2DIAG, PIN_HOUT3DIAG,
32         PIN_HOUT4DIAG, PIN_HOUT5DIAG, PIN_HOUT6DIAG
33 };
34 static enum pin_name pins_mouten[] = {
35         PIN_MOUT1EN, PIN_MOUT2EN, PIN_MOUT3EN,
36         PIN_MOUT4EN, PIN_MOUT5EN, PIN_MOUT6EN
37 };
38 static enum pin_name pins_moutin[] = {
39         PIN_MOUT1IN, PIN_MOUT2IN, PIN_MOUT3IN,
40         PIN_MOUT4IN, PIN_MOUT5IN, PIN_MOUT6IN
41 };
42
43 const struct port_desc port_desc[] = {
44         [PORT_ID_DINMCU] = {
45                 .name = "DINMCU",
46                 .numchn = ARRAY_SIZE(pins_dinmcu),
47                 .bpch = 1,
48                 .get = port_gioset_get,
49                 .set = NULL,
50                 .cfg = { .gioset = { .pins = pins_dinmcu } },
51         },
52         [PORT_ID_DINSPI] = {
53                 .name = "DINSPI",
54                 .numchn = 1,
55                 .bpch = 24,
56                 .set = port_spi_set,
57                 .cfg = { .spi = { .dev = SPIDEV_MC33972, .chip = "MC33972" } },
58         },
59         [PORT_ID_HOUTDIAG] = {
60                 .name = "HOUTDIAG",
61                 .numchn = ARRAY_SIZE(pins_houtdiag),
62                 .bpch = 1,
63                 .get = port_gioset_get,
64                 .set = NULL,
65                 .cfg = { .gioset = { .pins = pins_houtdiag } },
66         },
67         [PORT_ID_HOUTIN] = {
68                 .name = "HOUTIN",
69                 .numchn = ARRAY_SIZE(pins_houtin),
70                 .bpch = 1,
71                 .get = port_gioset_get,
72                 .set = port_gioset_set,
73                 .cfg = { .gioset = { .pins = pins_houtin } },
74         },
75         [PORT_ID_HOUTIFBK] = {
76                 .name = "HOUTIFBK",
77                 .numchn = 6,
78                 .bpch = 16,
79                 .get = port_adc_get,
80                 .set = NULL,
81                 .cfg = { .adc = { .reg = adcREG2, .group = adcGROUP1 } },
82         },
83         [PORT_ID_ADC] = {
84                 .name = "ADC",
85                 .numchn = PORT_ADC_CHANNELS,
86                 .bpch = 16,
87                 .get = port_adc_get,
88                 .set = NULL,
89                 .cfg = { .adc = { .reg = adcREG1, .group = adcGROUP1 } },
90         },
91         [PORT_ID_LOUT] = {
92                 .name = "LOUT",
93                 .numchn = 1,
94                 .bpch = 32,
95                 .get = NULL,
96                 .set = port_spi_set,
97                 .cfg = { .spi = { .dev = SPIDEV_NCV7608_2x, .chip = "NCV7608" }, },
98         },
99         [PORT_ID_DAC1_2] = {
100                 .name = "DAC12",
101                 .numchn = 1,
102                 .bpch = 16,
103                 .get = NULL,
104                 .set = port_spi_set,
105                 .cfg = { .spi = { .dev = SPIDEV_MCP4922_1, .chip = "MCP4922" }, },
106         },
107         [PORT_ID_DAC3_4] = {
108                 .name = "DAC34",
109                 .numchn = 1,
110                 .bpch = 16,
111                 .get = NULL,
112                 .set = port_spi_set,
113                 .cfg = { .spi = { .dev = SPIDEV_MCP4922_2, .chip = "MCP4922" }, },
114         },
115         [PORT_ID_DACDREF] = {
116                 .name = "DACDREF",      /* Reference voltage for DIN */
117                 .numchn = 1,
118                 .bpch = 16,
119                 .get = NULL,
120                 .set = port_spi_set,
121                 .cfg = { .spi = { .dev = SPIDEV_MCP4922_3, .chip = "MCP4922" }, },
122         },
123         [PORT_ID_HBR] = {
124                 .name = "HBR",
125                 .numchn = 1,
126                 .bpch = 16,
127                 .get = NULL,
128                 .set = port_spi_set,
129                 .cfg = { .spi = { .dev = SPIDEV_L99H01, .chip = "L99H01" }, },
130         },
131         [PORT_ID_FRAY1] = {
132                 .name = "FRAY1",
133                 .numchn = 1,
134                 .bpch = 16,
135                 .get = NULL,
136                 .set = port_spi_set,
137                 .cfg = { .spi = { .dev = SPIDEV_TJA1082_1, .chip = "TJA1082" }, },
138         },
139         [PORT_ID_FRAY2] = {
140                 .name = "FRAY2",
141                 .numchn = 1,
142                 .bpch = 16,
143                 .get = NULL,
144                 .set = port_spi_set,
145                 .cfg = { .spi = { .dev = SPIDEV_TJA1082_2, .chip = "TJA1082" }, },
146         },
147         [PORT_ID_MOUTEN] = {
148                 .name = "MOUTEN",
149                 .numchn = ARRAY_SIZE(pins_mouten),
150                 .bpch = 1,
151                 .get = port_gioset_get,
152                 .set = NULL,
153                 .cfg = { .gioset = { .pins = pins_mouten } },
154         },
155         [PORT_ID_MOUTIN] = {
156                 .name = "MOUTIN",
157                 .numchn = ARRAY_SIZE(pins_moutin),
158                 .bpch = 1,
159                 .get = port_gioset_get,
160                 .set = port_gioset_set,
161                 .cfg = { .gioset = { .pins = pins_moutin } },
162         }
163 };