Files
twx-linux/include/linux/platform_data/pfc-modbus-rtu.h
Heinrich Toews 55478b0c37 tty: omap-serial: add support for omap-serial-rtu and pfc-modbus-rtu
This is a port of Modbus-RTU / RS485 related changes from 4.9.146 (9520ad8)

Signed-off-by: Heinrich Toews <heinrich.toews@wago.com>
2024-02-22 13:08:24 +01:00

67 lines
1.7 KiB
C

/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* WAGO Serial Modbus RTU Driver
*
* Copyright (c) 2013 WAGO GmbH & Co. KG
*
* Author: Timur Celik <timur.celik@wago.com>
*
*/
#ifndef PFC_MODBUS_RTU_H_
#define PFC_MODBUS_RTU_H_
#ifdef CONFIG_SERIAL_OMAP_MODBUS
#include <asm/atomic.h>
#include <linux/kfifo.h>
#include <linux/hrtimer.h>
#include <linux/interrupt.h>
#define MB_TIMESTAMP_LENGTH 8
#define MB_FRAME_MAX 256
#define MB_FRAME_MIN 4
/* State machine definition */
typedef enum { ERR, IF, IC } MB_STATE;
/* Modbus specific data of the uart port */
struct modbus_port
{
MB_STATE state;
struct hrtimer timer;
struct kfifo frame;
struct kfifo length; /* contains frame length */
atomic_t ch_cnt;
atomic_t frame_cnt;
u8 slave_id; /* if zero all frames are received
(master mode) */
u64 to_15;
u64 to_35;
u64 to_15_override;
u64 to_35_override;
bool activated;
unsigned int modem_status;
struct tasklet_struct rx_tsklt;
struct tasklet_struct tx_tsklt;
struct tasklet_struct mdr_tsklt;
bool timestamp_enabled;
};
struct uart_omap_port;
enum hrtimer_restart modbus_omap_to_handler(struct hrtimer* hrt);
int modbus_omap_rhr_handler(struct uart_omap_port *up);
int modbus_omap_rlsi_handler(struct uart_omap_port *up, unsigned int lsr);
void modbus_omap_calc_to(struct uart_omap_port *up, unsigned int baud);
int modbus_omap_enable(struct uart_omap_port *up);
int modbus_omap_disable(struct uart_omap_port *up);
int modbus_omap_startup(struct uart_omap_port *up);
void modbus_omap_shutdown(struct uart_omap_port *up);
void modbus_omap_timestamp_enable(struct uart_omap_port *up);
void modbus_omap_timestamp_disable(struct uart_omap_port *up);
#endif
#endif /* PFC_MODBUS_RTU_H_ */