blob: a93a881cac6ee77591ec4244188fcaf35fdbc453 [file] [log] [blame]
Sylvain Munautbc9f5c42020-09-14 10:22:29 +02001/*
2 * e1.h
3 *
4 * Copyright (C) 2019-2020 Sylvain Munaut <tnt@246tNt.com>
5 * SPDX-License-Identifier: GPL-3.0-or-later
6 */
7
8#pragma once
9
Sylvain Munaut2c0c1362022-01-03 18:48:08 +010010
11/* control */
12
Sylvain Munaut3da51512022-01-03 22:12:59 +010013void e1_init(int port, uint16_t rx_cr, uint16_t tx_cr);
14void e1_poll(int port);
15void e1_debug_print(int port, bool data);
Sylvain Munautbc9f5c42020-09-14 10:22:29 +020016
Sylvain Munaut3da51512022-01-03 22:12:59 +010017void e1_tx_config(int port, uint16_t cr);
18void e1_rx_config(int port, uint16_t cr);
Harald Welte6add0aa2020-12-16 00:02:11 +010019
Sylvain Munaut2c0c1362022-01-03 18:48:08 +010020
21/* data flow */
22
Sylvain Munaut3da51512022-01-03 22:12:59 +010023unsigned int e1_rx_need_data(int port, unsigned int usb_addr, unsigned int max_len, unsigned int *pos);
24unsigned int e1_tx_feed_data(int port, unsigned int usb_addr, unsigned int len);
25unsigned int e1_tx_level(int port);
26unsigned int e1_rx_level(int port);
Sylvain Munaut2c0c1362022-01-03 18:48:08 +010027
28
29/* error reporting */
30
Harald Welte805f2cf2020-12-14 17:31:03 +010031#define E1_ERR_F_ALIGN_ERR 0x01
32#define E1_ERR_F_LOS 0x02
Harald Welte51baa362022-01-01 15:22:25 +010033#define E1_ERR_F_RAI 0x04
Harald Welte805f2cf2020-12-14 17:31:03 +010034
35struct e1_error_count {
36 uint16_t crc;
37 uint16_t align;
38 uint16_t ovfl;
39 uint16_t unfl;
40 uint8_t flags;
41};
42
Sylvain Munaut3da51512022-01-03 22:12:59 +010043const struct e1_error_count *e1_get_error_count(int port);
Harald Welte805f2cf2020-12-14 17:31:03 +010044
Sylvain Munaut2c0c1362022-01-03 18:48:08 +010045
46/* external function provided by the platform; used by E1 driver to control LEDs */
47
Harald Welte52765672020-12-15 18:35:42 +010048enum e1_platform_led {
49 E1P_LED_GREEN = 0,
50 E1P_LED_YELLOW = 1,
51};
52
53enum e1_platform_led_state {
54 E1P_LED_ST_OFF = 0,
55 E1P_LED_ST_ON = 1,
56 E1P_LED_ST_BLINK = 2,
57 E1P_LED_ST_BLINK_FAST = 3
58};
59
Sylvain Munaut8f31a9e2022-01-03 22:09:03 +010060extern void e1_platform_led_set(int port, enum e1_platform_led led,
Harald Welte52765672020-12-15 18:35:42 +010061 enum e1_platform_led_state state);