examples/tty/serial.c
author Florian Pose <fp@igh-essen.com>
Wed, 06 Feb 2013 17:25:08 +0100
branchstable-1.5
changeset 2508 6b21b3f88a9a
parent 2421 bc2d4bf9cbe5
permissions -rw-r--r--
Introduced --enable-sii-assign.
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/******************************************************************************
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
 *  $Id$
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
 *  Copyright (C) 2006-2008  Florian Pose, Ingenieurgemeinschaft IgH
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
 *
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
 *  This file is part of the IgH EtherCAT Master.
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
 *
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
 *  The IgH EtherCAT Master is free software; you can redistribute it and/or
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
 *  modify it under the terms of the GNU General Public License version 2, as
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
 *  published by the Free Software Foundation.
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
 *
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
 *  The IgH EtherCAT Master is distributed in the hope that it will be useful,
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
 *  Public License for more details.
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
 *
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
 *  You should have received a copy of the GNU General Public License along
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
 *  with the IgH EtherCAT Master; if not, write to the Free Software
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
 *
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
 *  ---
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
 *
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
 *  The license mentioned above concerns the source code only. Using the
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
 *  EtherCAT technology and brand is only permitted in compliance with the
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
 *  industrial property and similar rights of Beckhoff Automation GmbH.
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
 *
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
 *****************************************************************************/
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
#include <linux/module.h>
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
#include <linux/err.h>
1779
9fab229d6ca9 Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents: 1615
diff changeset
    32
#include <linux/termios.h>
1975
8e173dddd183 Improved compiling on 2.6.34 (thanks to Malcolm Lewis).
Florian Pose <fp@igh-essen.com>
parents: 1788
diff changeset
    33
#include <linux/slab.h>
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
#include "../../include/ecrt.h" // EtherCAT realtime interface
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
#include "../../include/ectty.h" // EtherCAT TTY interface
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
/*****************************************************************************/
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
// Optional features
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
#define PFX "ec_tty_example: "
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
1782
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
    43
#define DEBUG 0
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
    44
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
/*****************************************************************************/
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
#define VendorIdBeckhoff 0x00000002
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
#define ProductCodeBeckhoffEL6002 0x17723052
1783
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
    49
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
    50
#define VendorIdIds 0x000012ad
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
    51
#define ProductCodeIdsCSI71A 0x17723052
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
    52
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
    53
/*****************************************************************************/
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
typedef enum {
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
    SER_REQUEST_INIT,
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
    SER_WAIT_FOR_INIT_RESPONSE,
1782
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
    58
    SER_READY,
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
    59
    SER_SET_RTSCTS,
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
    60
    SER_SET_BAUD_RATE,
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
    61
    SER_SET_DATA_FRAME,
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
    62
} el60xx_port_state;
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
    64
#define EL6002_PORT_NAME_SIZE 16
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
    65
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
typedef struct {
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    67
    ec_tty_t *tty;
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
    68
    char name[EL6002_PORT_NAME_SIZE];
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
    size_t max_tx_data_size;
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
    size_t max_rx_data_size;
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
    u8 *tx_data;
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
    u8 tx_data_size;
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
    76
    el60xx_port_state state;
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
    u8 tx_request_toggle;
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
    u8 tx_accepted_toggle;
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
    u8 rx_request_toggle;
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
    u8 rx_accepted_toggle;
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
    u16 control;
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
    u32 off_ctrl;
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    87
    u32 off_tx;
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    88
    u32 off_status;
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    89
    u32 off_rx;
1780
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
    90
1782
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
    91
    ec_sdo_request_t *rtscts_sdo;
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
    92
    u8 requested_rtscts;
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
    93
    u8 current_rtscts;
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
    94
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
    95
    ec_sdo_request_t *baud_sdo;
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
    96
    u8 requested_baud_rate;
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
    97
    u8 current_baud_rate;
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
    98
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
    99
    ec_sdo_request_t *frame_sdo;
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   100
    u8 requested_data_frame;
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   101
    u8 current_data_frame;
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   102
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   103
    unsigned int config_error;
1780
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   104
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   105
} el60xx_port_t;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   106
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   107
#define EL6002_PORTS 2
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   108
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   109
typedef struct {
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   110
    struct list_head list;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   111
    ec_slave_config_t *sc;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   112
    el60xx_port_t port[EL6002_PORTS];
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   113
} el6002_t;
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   114
1615
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   115
LIST_HEAD(handlers);
2421
bc2d4bf9cbe5 Removed trailing spaces.
Florian Pose <fp@igh-essen.com>
parents: 2384
diff changeset
   116
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   117
/*****************************************************************************/
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   118
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   119
/* Beckhoff EL6002
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   120
 * Vendor ID:       0x00000002
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   121
 * Product code:    0x17723052
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   122
 * Revision number: 0x00100000
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   123
 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   124
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   125
ec_pdo_entry_info_t el6002_pdo_entries[] = {
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   126
   {0x7001, 0x01, 16}, /* Ctrl */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   127
   {0x7000, 0x11, 8}, /* Data Out 0 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   128
   {0x7000, 0x12, 8}, /* Data Out 1 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   129
   {0x7000, 0x13, 8}, /* Data Out 2 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   130
   {0x7000, 0x14, 8}, /* Data Out 3 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   131
   {0x7000, 0x15, 8}, /* Data Out 4 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   132
   {0x7000, 0x16, 8}, /* Data Out 5 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   133
   {0x7000, 0x17, 8}, /* Data Out 6 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   134
   {0x7000, 0x18, 8}, /* Data Out 7 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   135
   {0x7000, 0x19, 8}, /* Data Out 8 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   136
   {0x7000, 0x1a, 8}, /* Data Out 9 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   137
   {0x7000, 0x1b, 8}, /* Data Out 10 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   138
   {0x7000, 0x1c, 8}, /* Data Out 11 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   139
   {0x7000, 0x1d, 8}, /* Data Out 12 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   140
   {0x7000, 0x1e, 8}, /* Data Out 13 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   141
   {0x7000, 0x1f, 8}, /* Data Out 14 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   142
   {0x7000, 0x20, 8}, /* Data Out 15 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   143
   {0x7000, 0x21, 8}, /* Data Out 16 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   144
   {0x7000, 0x22, 8}, /* Data Out 17 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   145
   {0x7000, 0x23, 8}, /* Data Out 18 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   146
   {0x7000, 0x24, 8}, /* Data Out 19 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   147
   {0x7000, 0x25, 8}, /* Data Out 20 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   148
   {0x7000, 0x26, 8}, /* Data Out 21 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   149
   {0x7011, 0x01, 16}, /* Ctrl */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   150
   {0x7010, 0x11, 8}, /* Data Out 0 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   151
   {0x7010, 0x12, 8}, /* Data Out 1 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   152
   {0x7010, 0x13, 8}, /* Data Out 2 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   153
   {0x7010, 0x14, 8}, /* Data Out 3 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   154
   {0x7010, 0x15, 8}, /* Data Out 4 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   155
   {0x7010, 0x16, 8}, /* Data Out 5 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   156
   {0x7010, 0x17, 8}, /* Data Out 6 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   157
   {0x7010, 0x18, 8}, /* Data Out 7 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   158
   {0x7010, 0x19, 8}, /* Data Out 8 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   159
   {0x7010, 0x1a, 8}, /* Data Out 9 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   160
   {0x7010, 0x1b, 8}, /* Data Out 10 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   161
   {0x7010, 0x1c, 8}, /* Data Out 11 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   162
   {0x7010, 0x1d, 8}, /* Data Out 12 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   163
   {0x7010, 0x1e, 8}, /* Data Out 13 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   164
   {0x7010, 0x1f, 8}, /* Data Out 14 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   165
   {0x7010, 0x20, 8}, /* Data Out 15 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   166
   {0x7010, 0x21, 8}, /* Data Out 16 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   167
   {0x7010, 0x22, 8}, /* Data Out 17 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   168
   {0x7010, 0x23, 8}, /* Data Out 18 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   169
   {0x7010, 0x24, 8}, /* Data Out 19 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   170
   {0x7010, 0x25, 8}, /* Data Out 20 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   171
   {0x7010, 0x26, 8}, /* Data Out 21 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   172
   {0x6001, 0x01, 16}, /* Status */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   173
   {0x6000, 0x11, 8}, /* Data In 0 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   174
   {0x6000, 0x12, 8}, /* Data In 1 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   175
   {0x6000, 0x13, 8}, /* Data In 2 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   176
   {0x6000, 0x14, 8}, /* Data In 3 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   177
   {0x6000, 0x15, 8}, /* Data In 4 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   178
   {0x6000, 0x16, 8}, /* Data In 5 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   179
   {0x6000, 0x17, 8}, /* Data In 6 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   180
   {0x6000, 0x18, 8}, /* Data In 7 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   181
   {0x6000, 0x19, 8}, /* Data In 8 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   182
   {0x6000, 0x1a, 8}, /* Data In 9 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   183
   {0x6000, 0x1b, 8}, /* Data In 10 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   184
   {0x6000, 0x1c, 8}, /* Data In 11 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   185
   {0x6000, 0x1d, 8}, /* Data In 12 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   186
   {0x6000, 0x1e, 8}, /* Data In 13 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   187
   {0x6000, 0x1f, 8}, /* Data In 14 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   188
   {0x6000, 0x20, 8}, /* Data In 15 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   189
   {0x6000, 0x21, 8}, /* Data In 16 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   190
   {0x6000, 0x22, 8}, /* Data In 17 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   191
   {0x6000, 0x23, 8}, /* Data In 18 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   192
   {0x6000, 0x24, 8}, /* Data In 19 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   193
   {0x6000, 0x25, 8}, /* Data In 20 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   194
   {0x6000, 0x26, 8}, /* Data In 21 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   195
   {0x6011, 0x01, 16}, /* Status */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   196
   {0x6010, 0x11, 8}, /* Data In 0 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   197
   {0x6010, 0x12, 8}, /* Data In 1 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   198
   {0x6010, 0x13, 8}, /* Data In 2 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   199
   {0x6010, 0x14, 8}, /* Data In 3 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   200
   {0x6010, 0x15, 8}, /* Data In 4 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   201
   {0x6010, 0x16, 8}, /* Data In 5 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   202
   {0x6010, 0x17, 8}, /* Data In 6 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   203
   {0x6010, 0x18, 8}, /* Data In 7 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   204
   {0x6010, 0x19, 8}, /* Data In 8 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   205
   {0x6010, 0x1a, 8}, /* Data In 9 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   206
   {0x6010, 0x1b, 8}, /* Data In 10 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   207
   {0x6010, 0x1c, 8}, /* Data In 11 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   208
   {0x6010, 0x1d, 8}, /* Data In 12 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   209
   {0x6010, 0x1e, 8}, /* Data In 13 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   210
   {0x6010, 0x1f, 8}, /* Data In 14 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   211
   {0x6010, 0x20, 8}, /* Data In 15 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   212
   {0x6010, 0x21, 8}, /* Data In 16 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   213
   {0x6010, 0x22, 8}, /* Data In 17 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   214
   {0x6010, 0x23, 8}, /* Data In 18 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   215
   {0x6010, 0x24, 8}, /* Data In 19 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   216
   {0x6010, 0x25, 8}, /* Data In 20 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   217
   {0x6010, 0x26, 8}, /* Data In 21 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   218
};
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   219
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   220
ec_pdo_info_t el6002_pdos[] = {
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   221
   {0x1604, 23, el6002_pdo_entries + 0}, /* COM RxPDO-Map Outputs Ch.1 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   222
   {0x1605, 23, el6002_pdo_entries + 23}, /* COM RxPDO-Map Outputs Ch.2 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   223
   {0x1a04, 23, el6002_pdo_entries + 46}, /* COM TxPDO-Map Inputs Ch.1 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   224
   {0x1a05, 23, el6002_pdo_entries + 69}, /* COM TxPDO-Map Inputs Ch.2 */
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   225
};
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   226
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   227
ec_sync_info_t el6002_syncs[] = {
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   228
   {0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   229
   {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   230
   {2, EC_DIR_OUTPUT, 2, el6002_pdos + 0, EC_WD_DISABLE},
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   231
   {3, EC_DIR_INPUT, 2, el6002_pdos + 2, EC_WD_DISABLE},
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   232
   {0xff}
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   233
};
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   234
1780
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   235
typedef enum {
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   236
    PAR_NONE,
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   237
    PAR_ODD,
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   238
    PAR_EVEN
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   239
} parity_t;
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   240
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   241
typedef struct {
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   242
    u8 value;
1782
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   243
    unsigned int data_bits;
1780
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   244
    parity_t parity;
1782
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   245
    unsigned int stop_bits;
1780
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   246
} el600x_data_frame_t;
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   247
1782
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   248
/** EL600x supported values for data frame SDO.
1780
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   249
 */
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   250
el600x_data_frame_t el600x_data_frame[] = {
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   251
    {0x01, 7, PAR_EVEN, 1},
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   252
    {0x09, 7, PAR_EVEN, 2},
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   253
    {0x02, 7, PAR_ODD,  1},
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   254
    {0x0a, 7, PAR_ODD,  2},
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   255
    {0x03, 8, PAR_NONE, 1},
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   256
    {0x0b, 8, PAR_NONE, 2},
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   257
    {0x04, 8, PAR_EVEN, 1},
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   258
    {0x0c, 8, PAR_EVEN, 2},
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   259
    {0x05, 8, PAR_ODD,  1},
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   260
    {0x0d, 8, PAR_ODD,  2},
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   261
};
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   262
1782
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   263
typedef struct {
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   264
    u8 value;
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   265
    unsigned int baud;
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   266
    tcflag_t cbaud;
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   267
} el600x_baud_rate_t;
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   268
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   269
/** EL600x supported values for baud rate SDO.
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   270
 */
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   271
el600x_baud_rate_t el600x_baud_rate[] = {
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   272
    {1,   300,    B300},
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   273
    {2,   600,    B600},
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   274
    {3,   1200,   B1200},
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   275
    {4,   2400,   B2400},
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   276
    {5,   4800,   B4800},
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   277
    {6,   9600,   B9600},
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   278
    {7,   19200,  B19200},
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   279
    {8,   38400,  B38400},
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   280
    {9,   57600,  B57600},
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   281
    {10,  115200, B115200}
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   282
};
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   283
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   284
/****************************************************************************/
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   285
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   286
int el60xx_cflag_changed(void *data, tcflag_t cflag)
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   287
{
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   288
    el60xx_port_t *port = (el60xx_port_t *) data;
1782
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   289
    unsigned int data_bits, stop_bits;
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   290
    tcflag_t cbaud, rtscts;
1780
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   291
    parity_t par;
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   292
    unsigned int i;
1782
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   293
    el600x_baud_rate_t *b_to_use = NULL;
1780
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   294
    el600x_data_frame_t *df_to_use = NULL;
1779
9fab229d6ca9 Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents: 1615
diff changeset
   295
1782
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   296
#if DEBUG
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   297
    printk(KERN_INFO PFX "%s(%s, cflag=%x).\n", __func__, port->name, cflag);
1782
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   298
#endif
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   299
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   300
    rtscts = cflag & CRTSCTS;
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   301
    printk(KERN_INFO PFX "%s: Requested RTS/CTS: %s.\n",
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   302
            port->name, rtscts ? "yes" : "no");
2421
bc2d4bf9cbe5 Removed trailing spaces.
Florian Pose <fp@igh-essen.com>
parents: 2384
diff changeset
   303
1782
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   304
    cbaud = cflag & CBAUD;
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   305
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   306
    for (i = 0; i < sizeof(el600x_baud_rate) / sizeof(el600x_baud_rate_t);
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   307
            i++) {
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   308
        el600x_baud_rate_t *b = el600x_baud_rate + i;
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   309
        if (b->cbaud == cbaud) {
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   310
            b_to_use = b;
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   311
            break;
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   312
        }
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   313
    }
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   314
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   315
    if (b_to_use) {
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   316
        printk(KERN_INFO PFX "%s: Requested baud rate: %u.\n",
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   317
                port->name, b_to_use->baud);
1782
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   318
    } else {
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   319
        printk(KERN_ERR PFX "Error: %s does not support"
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   320
                " baud rate index %x.\n", port->name, cbaud);
1782
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   321
        return -EINVAL;
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   322
    }
1779
9fab229d6ca9 Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents: 1615
diff changeset
   323
9fab229d6ca9 Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents: 1615
diff changeset
   324
    switch (cflag & CSIZE) {
1780
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   325
        case CS5:
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   326
            data_bits = 5;
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   327
            break;
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   328
        case CS6:
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   329
            data_bits = 6;
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   330
            break;
1779
9fab229d6ca9 Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents: 1615
diff changeset
   331
        case CS7:
1780
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   332
            data_bits = 7;
1779
9fab229d6ca9 Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents: 1615
diff changeset
   333
            break;
9fab229d6ca9 Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents: 1615
diff changeset
   334
        case CS8:
1780
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   335
            data_bits = 8;
1779
9fab229d6ca9 Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents: 1615
diff changeset
   336
            break;
9fab229d6ca9 Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents: 1615
diff changeset
   337
        default: /* CS5 or CS6 */
1780
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   338
            data_bits = 0;
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   339
    }
1779
9fab229d6ca9 Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents: 1615
diff changeset
   340
9fab229d6ca9 Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents: 1615
diff changeset
   341
    if (cflag & PARENB) {
1780
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   342
        par = (cflag & PARODD) ? PAR_ODD : PAR_EVEN;
1779
9fab229d6ca9 Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents: 1615
diff changeset
   343
    } else {
1780
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   344
        par = PAR_NONE;
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   345
    }
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   346
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   347
    stop_bits = (cflag & CSTOPB) ? 2 : 1;
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   348
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   349
    printk(KERN_INFO PFX "%s: Requested Data frame: %u%c%u.\n",
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   350
            port->name, data_bits,
1780
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   351
            (par == PAR_NONE ? 'N' : (par == PAR_ODD ? 'O' : 'E')),
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   352
            stop_bits);
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   353
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   354
    for (i = 0; i < sizeof(el600x_data_frame) / sizeof(el600x_data_frame_t);
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   355
            i++) {
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   356
        el600x_data_frame_t *df = el600x_data_frame + i;
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   357
        if (df->data_bits == data_bits &&
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   358
                df->parity == par &&
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   359
                df->stop_bits == stop_bits) {
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   360
            df_to_use = df;
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   361
            break;
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   362
        }
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   363
    }
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   364
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   365
    if (!df_to_use) {
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   366
        printk(KERN_ERR PFX "Error: %s does not support data frame type.\n",
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   367
                port->name);
1780
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   368
        return -EINVAL;
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   369
    }
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   370
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   371
    port->requested_rtscts = rtscts != 0;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   372
    port->requested_baud_rate = b_to_use->value;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   373
    port->requested_data_frame = df_to_use->value;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   374
    port->config_error = 0;
1779
9fab229d6ca9 Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents: 1615
diff changeset
   375
    return 0;
9fab229d6ca9 Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents: 1615
diff changeset
   376
}
9fab229d6ca9 Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents: 1615
diff changeset
   377
9fab229d6ca9 Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents: 1615
diff changeset
   378
/****************************************************************************/
9fab229d6ca9 Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents: 1615
diff changeset
   379
1787
439f186185be Callback set via own structure.
Florian Pose <fp@igh-essen.com>
parents: 1785
diff changeset
   380
static ec_tty_operations_t el60xx_tty_ops = {
439f186185be Callback set via own structure.
Florian Pose <fp@igh-essen.com>
parents: 1785
diff changeset
   381
    .cflag_changed = el60xx_cflag_changed,
439f186185be Callback set via own structure.
Florian Pose <fp@igh-essen.com>
parents: 1785
diff changeset
   382
};
439f186185be Callback set via own structure.
Florian Pose <fp@igh-essen.com>
parents: 1785
diff changeset
   383
439f186185be Callback set via own structure.
Florian Pose <fp@igh-essen.com>
parents: 1785
diff changeset
   384
/****************************************************************************/
439f186185be Callback set via own structure.
Florian Pose <fp@igh-essen.com>
parents: 1785
diff changeset
   385
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   386
int el60xx_port_init(el60xx_port_t *port, ec_slave_config_t *sc,
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   387
        ec_domain_t *domain, unsigned int slot_offset, const char *name)
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   388
{
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   389
    int ret = 0;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   390
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   391
    strncpy(port->name, name, EL6002_PORT_NAME_SIZE);
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   392
1787
439f186185be Callback set via own structure.
Florian Pose <fp@igh-essen.com>
parents: 1785
diff changeset
   393
    port->tty = ectty_create(&el60xx_tty_ops, port);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   394
    if (IS_ERR(port->tty)) {
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   395
        printk(KERN_ERR PFX "Failed to create tty for %s.\n",
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   396
                port->name);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   397
        ret = PTR_ERR(port->tty);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   398
        goto out_return;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   399
    }
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   400
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   401
    port->max_tx_data_size = 22;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   402
    port->max_rx_data_size = 22;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   403
    port->tx_data = NULL;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   404
    port->tx_data_size = 0;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   405
    port->state = SER_REQUEST_INIT;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   406
    port->tx_request_toggle = 0;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   407
    port->rx_accepted_toggle = 0;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   408
    port->control = 0x0000;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   409
    port->off_ctrl = 0;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   410
    port->off_tx = 0;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   411
    port->off_status = 0;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   412
    port->off_rx = 0;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   413
    port->requested_rtscts = 0x00; // no hardware handshake
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   414
    port->current_rtscts = 0xff;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   415
    port->requested_baud_rate = 6; // 9600
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   416
    port->current_baud_rate = 0;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   417
    port->requested_data_frame = 0x03; // 8N1
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   418
    port->current_data_frame = 0x00;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   419
    port->config_error = 0;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   420
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   421
    if (!(port->rtscts_sdo = ecrt_slave_config_create_sdo_request(sc,
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   422
                    0x8000 + slot_offset, 0x01, 1))) {
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   423
        printk(KERN_ERR PFX "Failed to create SDO request for %s.\n",
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   424
                port->name);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   425
        ret = -ENOMEM;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   426
        goto out_free_tty;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   427
    }
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   428
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   429
    if (!(port->baud_sdo = ecrt_slave_config_create_sdo_request(sc,
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   430
                    0x8000 + slot_offset, 0x11, 1))) {
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   431
        printk(KERN_ERR PFX "Failed to create SDO request for %s.\n",
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   432
                port->name);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   433
        ret = -ENOMEM;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   434
        goto out_free_tty;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   435
    }
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   436
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   437
    if (!(port->frame_sdo = ecrt_slave_config_create_sdo_request(sc,
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   438
                    0x8000 + slot_offset, 0x15, 1))) {
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   439
        printk(KERN_ERR PFX "Failed to create SDO request for %s\n",
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   440
                port->name);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   441
        ret = -ENOMEM;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   442
        goto out_free_tty;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   443
    }
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   444
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   445
    ret = ecrt_slave_config_reg_pdo_entry(
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   446
            sc, 0x7001 + slot_offset, 0x01, domain, NULL);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   447
    if (ret < 0) {
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   448
        printk(KERN_ERR PFX "Failed to register PDO entry of %s\n",
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   449
                port->name);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   450
        goto out_free_tty;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   451
    }
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   452
    port->off_ctrl = ret;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   453
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   454
    ret = ecrt_slave_config_reg_pdo_entry(
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   455
            sc, 0x7000 + slot_offset, 0x11, domain, NULL);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   456
    if (ret < 0) {
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   457
        printk(KERN_ERR PFX "Failed to register PDO entry of %s.\n",
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   458
                port->name);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   459
        goto out_free_tty;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   460
    }
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   461
    port->off_tx = ret;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   462
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   463
    ret = ecrt_slave_config_reg_pdo_entry(
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   464
            sc, 0x6001 + slot_offset, 0x01, domain, NULL);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   465
    if (ret < 0) {
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   466
        printk(KERN_ERR PFX "Failed to register PDO entry of %s.\n",
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   467
                port->name);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   468
        goto out_free_tty;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   469
    }
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   470
    port->off_status = ret;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   471
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   472
    ret = ecrt_slave_config_reg_pdo_entry(
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   473
            sc, 0x6000 + slot_offset, 0x11, domain, NULL);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   474
    if (ret < 0) {
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   475
        printk(KERN_ERR PFX "Failed to register PDO entry of %s.\n",
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   476
                port->name);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   477
        goto out_free_tty;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   478
    }
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   479
    port->off_rx = ret;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   480
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   481
    if (port->max_tx_data_size > 0) {
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   482
        port->tx_data = kmalloc(port->max_tx_data_size, GFP_KERNEL);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   483
        if (port->tx_data == NULL) {
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   484
            printk(KERN_ERR PFX "Failed to allocate %u bytes of TX"
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   485
                    " memory for %s.\n", port->max_tx_data_size, port->name);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   486
            ret = -ENOMEM;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   487
            goto out_free_tty;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   488
        }
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   489
    }
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   490
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   491
    return 0;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   492
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   493
out_free_tty:
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   494
    ectty_free(port->tty);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   495
out_return:
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   496
    return ret;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   497
}
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   498
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   499
/****************************************************************************/
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   500
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   501
void el60xx_port_clear(el60xx_port_t *port)
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   502
{
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   503
    ectty_free(port->tty);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   504
    if (port->tx_data) {
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   505
        kfree(port->tx_data);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   506
    }
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   507
}
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   508
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   509
/****************************************************************************/
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   510
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   511
void el60xx_port_run(el60xx_port_t *port, u8 *pd)
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   512
{
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   513
    u16 status = EC_READ_U16(pd + port->off_status);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   514
    u8 *rx_data = pd + port->off_rx;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   515
    uint8_t tx_accepted_toggle, rx_request_toggle;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   516
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   517
    switch (port->state) {
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   518
        case SER_READY:
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   519
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   520
            /* Check, if hardware handshaking has to be configured. */
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   521
            if (!port->config_error &&
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   522
                    port->requested_rtscts != port->current_rtscts) {
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   523
                EC_WRITE_U8(ecrt_sdo_request_data(port->rtscts_sdo),
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   524
                        port->requested_rtscts);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   525
                ecrt_sdo_request_write(port->rtscts_sdo);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   526
                port->state = SER_SET_RTSCTS;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   527
                break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   528
            }
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   529
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   530
            /* Check, if the baud rate has to be configured. */
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   531
            if (!port->config_error &&
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   532
                    port->requested_baud_rate != port->current_baud_rate) {
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   533
                EC_WRITE_U8(ecrt_sdo_request_data(port->baud_sdo),
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   534
                        port->requested_baud_rate);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   535
                ecrt_sdo_request_write(port->baud_sdo);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   536
                port->state = SER_SET_BAUD_RATE;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   537
                break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   538
            }
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   539
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   540
            /* Check, if the data frame has to be configured. */
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   541
            if (!port->config_error &&
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   542
                    port->requested_data_frame != port->current_data_frame) {
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   543
                EC_WRITE_U8(ecrt_sdo_request_data(port->frame_sdo),
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   544
                        port->requested_data_frame);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   545
                ecrt_sdo_request_write(port->frame_sdo);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   546
                port->state = SER_SET_DATA_FRAME;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   547
                break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   548
            }
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   549
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   550
            /* Send data */
2384
b068951506d9 Removed whitespace.
Florian Pose <fp@igh-essen.com>
parents: 1975
diff changeset
   551
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   552
            tx_accepted_toggle = status & 0x0001;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   553
            if (tx_accepted_toggle != port->tx_accepted_toggle) { // ready
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   554
                port->tx_data_size =
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   555
                    ectty_tx_data(port->tty, port->tx_data, port->max_tx_data_size);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   556
                if (port->tx_data_size) {
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   557
#if DEBUG
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   558
                    printk(KERN_INFO PFX "%s: Sending %u bytes.\n",
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   559
                            port->name, port->tx_data_size);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   560
#endif
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   561
                    port->tx_request_toggle = !port->tx_request_toggle;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   562
                    port->tx_accepted_toggle = tx_accepted_toggle;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   563
                }
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   564
            }
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   565
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   566
            /* Receive data */
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   567
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   568
            rx_request_toggle = status & 0x0002;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   569
            if (rx_request_toggle != port->rx_request_toggle) {
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   570
                uint8_t rx_data_size = status >> 8;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   571
                port->rx_request_toggle = rx_request_toggle;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   572
#if DEBUG
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   573
                printk(KERN_INFO PFX "%s: Received %u bytes.\n",
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   574
                        port->name, rx_data_size);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   575
#endif
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   576
                ectty_rx_data(port->tty, rx_data, rx_data_size);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   577
                port->rx_accepted_toggle = !port->rx_accepted_toggle;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   578
            }
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   579
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   580
            port->control =
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   581
                port->tx_request_toggle |
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   582
                port->rx_accepted_toggle << 1 |
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   583
                port->tx_data_size << 8;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   584
            break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   585
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   586
        case SER_REQUEST_INIT:
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   587
            if (status & (1 << 2)) {
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   588
                port->control = 0x0000;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   589
                port->state = SER_WAIT_FOR_INIT_RESPONSE;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   590
            } else {
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   591
                port->control = 1 << 2; // CW.2, request initialization
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   592
            }
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   593
            break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   594
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   595
        case SER_WAIT_FOR_INIT_RESPONSE:
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   596
            if (!(status & (1 << 2))) {
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   597
                printk(KERN_INFO PFX "%s: Init successful.\n", port->name);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   598
                port->tx_accepted_toggle = 1;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   599
                port->control = 0x0000;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   600
                port->state = SER_READY;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   601
            }
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   602
            break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   603
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   604
        case SER_SET_RTSCTS:
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   605
            switch (ecrt_sdo_request_state(port->rtscts_sdo)) {
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   606
                case EC_REQUEST_SUCCESS:
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   607
                    printk(KERN_INFO PFX "%s: Accepted RTS/CTS.\n",
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   608
                            port->name);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   609
                    port->current_rtscts = port->requested_rtscts;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   610
                    port->state = SER_REQUEST_INIT;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   611
                    break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   612
                case EC_REQUEST_ERROR:
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   613
                    printk(KERN_ERR PFX "Failed to set RTS/CTS on %s!\n",
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   614
                            port->name);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   615
                    port->state = SER_REQUEST_INIT;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   616
                    port->config_error = 1;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   617
                    break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   618
                default:
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   619
                    break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   620
            }
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   621
            break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   622
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   623
        case SER_SET_BAUD_RATE:
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   624
            switch (ecrt_sdo_request_state(port->baud_sdo)) {
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   625
                case EC_REQUEST_SUCCESS:
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   626
                    printk(KERN_INFO PFX "%s: Accepted baud rate.\n",
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   627
                            port->name);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   628
                    port->current_baud_rate = port->requested_baud_rate;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   629
                    port->state = SER_REQUEST_INIT;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   630
                    break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   631
                case EC_REQUEST_ERROR:
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   632
                    printk(KERN_ERR PFX "Failed to set baud rate on %s!\n",
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   633
                            port->name);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   634
                    port->state = SER_REQUEST_INIT;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   635
                    port->config_error = 1;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   636
                    break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   637
                default:
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   638
                    break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   639
            }
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   640
            break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   641
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   642
        case SER_SET_DATA_FRAME:
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   643
            switch (ecrt_sdo_request_state(port->frame_sdo)) {
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   644
                case EC_REQUEST_SUCCESS:
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   645
                    printk(KERN_INFO PFX "%s: Accepted data frame.\n",
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   646
                            port->name);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   647
                    port->current_data_frame = port->requested_data_frame;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   648
                    port->state = SER_REQUEST_INIT;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   649
                    break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   650
                case EC_REQUEST_ERROR:
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   651
                    printk(KERN_ERR PFX "Failed to set data frame on %s!\n",
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   652
                            port->name);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   653
                    port->state = SER_REQUEST_INIT;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   654
                    port->config_error = 1;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   655
                    break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   656
                default:
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   657
                    break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   658
            }
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   659
            break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   660
    }
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   661
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   662
    EC_WRITE_U16(pd + port->off_ctrl, port->control);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   663
    memcpy(pd + port->off_tx, port->tx_data, port->tx_data_size);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   664
}
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   665
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   666
/****************************************************************************/
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   667
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   668
int el6002_init(el6002_t *el6002, ec_master_t *master, u16 position,
1783
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   669
        ec_domain_t *domain, u32 vendor, u32 product)
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   670
{
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   671
    int ret = 0, i;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   672
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   673
    if (!(el6002->sc = ecrt_master_slave_config(
1783
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   674
                    master, 0, position, vendor, product))) {
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   675
        printk(KERN_ERR PFX "EL6002(%u): Failed to create"
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   676
                " slave configuration.\n", position);
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   677
        ret = -EBUSY;
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   678
        goto out_return;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   679
    }
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   680
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   681
    if (ecrt_slave_config_pdos(el6002->sc, EC_END, el6002_syncs)) {
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   682
        printk(KERN_ERR PFX "EL6002(%u): Failed to configure PDOs.\n",
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   683
                position);
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   684
        ret = -ENOMEM;
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   685
        goto out_return;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   686
    }
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   687
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   688
    for (i = 0; i < EL6002_PORTS; i++) {
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   689
        char name[EL6002_PORT_NAME_SIZE];
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   690
        snprintf(name, EL6002_PORT_NAME_SIZE, "EL6002(%u) X%u",
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   691
                position, i + 1);
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   692
        if (el60xx_port_init(el6002->port + i, el6002->sc, domain, i * 0x10,
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   693
                    name)) {
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   694
            printk(KERN_ERR PFX "EL6002(%u): Failed to init port X%u.\n",
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   695
                    position, i);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   696
            goto out_ports;
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   697
        }
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   698
    }
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   699
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   700
    return 0;
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   701
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   702
out_ports:
1788
af61953c3ba4 Fixed segfault if creation of TTY devices fails.
Florian Pose <fp@igh-essen.com>
parents: 1787
diff changeset
   703
    for (i--; i >= 0; i--) {
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   704
        el60xx_port_clear(el6002->port + i);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   705
    }
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   706
out_return:
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   707
    return ret;
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   708
}
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   709
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   710
/****************************************************************************/
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   711
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   712
void el6002_clear(el6002_t *el6002)
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   713
{
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   714
    int i;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   715
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   716
    for (i = 0; i < EL6002_PORTS; i++) {
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   717
        el60xx_port_clear(el6002->port + i);
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   718
    }
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   719
}
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   720
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   721
/****************************************************************************/
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   722
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   723
void el6002_run(el6002_t *el6002, u8 *pd)
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   724
{
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   725
    int i;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   726
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   727
    for (i = 0; i < EL6002_PORTS; i++) {
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   728
        el60xx_port_run(el6002->port + i, pd);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   729
    }
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   730
}
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   731
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   732
/*****************************************************************************/
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   733
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   734
void run_serial_devices(u8 *pd)
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   735
{
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   736
    el6002_t *el6002;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   737
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   738
    list_for_each_entry(el6002, &handlers, list) {
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   739
        el6002_run(el6002, pd);
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   740
    }
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   741
}
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   742
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   743
/*****************************************************************************/
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   744
1783
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   745
int create_el6002_handler(ec_master_t *master, ec_domain_t *domain,
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   746
        u16 position, u32 vendor, u32 product)
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   747
{
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   748
    el6002_t *el6002;
1783
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   749
    int ret;
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   750
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   751
    printk(KERN_INFO PFX "Creating handler for EL6002 at position %u\n",
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   752
            position);
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   753
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   754
    el6002 = kmalloc(sizeof(*el6002), GFP_KERNEL);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   755
    if (!el6002) {
1783
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   756
        printk(KERN_ERR PFX "Failed to allocate serial device object.\n");
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   757
        return -ENOMEM;
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   758
    }
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   759
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   760
    ret = el6002_init(el6002, master, position, domain, vendor, product);
1783
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   761
    if (ret) {
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   762
        kfree(el6002);
1783
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   763
        return ret;
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   764
    }
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   765
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   766
    list_add_tail(&el6002->list, &handlers);
1783
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   767
    return 0;
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   768
}
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   769
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   770
/*****************************************************************************/
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   771
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   772
int create_serial_devices(ec_master_t *master, ec_domain_t *domain)
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   773
{
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   774
    int i, ret;
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   775
    ec_master_info_t master_info;
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   776
    ec_slave_info_t slave_info;
1615
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   777
    el6002_t *ser, *next;
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   778
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   779
    printk(KERN_INFO PFX "Registering serial devices...\n");
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   780
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   781
    ret = ecrt_master(master, &master_info);
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   782
    if (ret) {
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   783
        printk(KERN_ERR PFX "Failed to obtain master information.\n");
1615
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   784
        goto out_return;
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   785
    }
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   786
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   787
    for (i = 0; i < master_info.slave_count; i++) {
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   788
        ret = ecrt_master_get_slave(master, i, &slave_info);
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   789
        if (ret) {
1615
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   790
            printk(KERN_ERR PFX "Failed to obtain slave information.\n");
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   791
            goto out_free_handlers;
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   792
        }
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   793
1783
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   794
        if (slave_info.vendor_id == VendorIdBeckhoff
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   795
                && slave_info.product_code == ProductCodeBeckhoffEL6002) {
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   796
            if (create_el6002_handler(master, domain, i,
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   797
                    slave_info.vendor_id, slave_info.product_code)) {
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   798
                goto out_free_handlers;
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   799
            }
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   800
        }
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   801
1783
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   802
        if (slave_info.vendor_id == VendorIdIds
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   803
                && slave_info.product_code == ProductCodeIdsCSI71A) {
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   804
            if (create_el6002_handler(master, domain, i,
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   805
                    slave_info.vendor_id, slave_info.product_code)) {
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   806
                goto out_free_handlers;
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   807
            }
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   808
        }
1783
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   809
    }
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   810
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   811
    printk(KERN_INFO PFX "Finished registering serial devices.\n");
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   812
    return 0;
1615
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   813
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   814
out_free_handlers:
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   815
    list_for_each_entry_safe(ser, next, &handlers, list) {
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   816
        list_del(&ser->list);
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   817
        el6002_clear(ser);
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   818
        kfree(ser);
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   819
    }
1615
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   820
out_return:
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   821
    return ret;
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   822
}
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   823
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   824
/*****************************************************************************/
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   825
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   826
void free_serial_devices(void)
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   827
{
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   828
    el6002_t *ser, *next;
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   829
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   830
    printk(KERN_INFO PFX "Cleaning up serial devices...\n");
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   831
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   832
    list_for_each_entry_safe(ser, next, &handlers, list) {
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   833
        list_del(&ser->list);
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   834
        el6002_clear(ser);
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   835
        kfree(ser);
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   836
    }
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   837
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   838
    printk(KERN_INFO PFX "Finished cleaning up serial devices.\n");
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   839
}
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   840
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   841
/*****************************************************************************/