examples/tty/serial.c
author Florian Pose <fp@igh-essen.com>
Wed, 14 Apr 2010 15:24:58 +0200
changeset 1891 dd7879e2e72b
parent 1788 af61953c3ba4
child 1975 8e173dddd183
permissions -rw-r--r--
Added api doc.
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>
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
#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
    35
#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
    36
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
// Optional features
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
#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
    41
1782
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
    42
#define DEBUG 0
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
    43
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
/*****************************************************************************/
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
#define VendorIdBeckhoff 0x00000002
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
#define ProductCodeBeckhoffEL6002 0x17723052
1783
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
    48
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
    49
#define VendorIdIds 0x000012ad
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
    50
#define ProductCodeIdsCSI71A 0x17723052
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
    51
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
    52
/*****************************************************************************/
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
typedef enum {
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
    SER_REQUEST_INIT,
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
    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
    57
    SER_READY,
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
    58
    SER_SET_RTSCTS,
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
    59
    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
    60
    SER_SET_DATA_FRAME,
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
    61
} 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
    62
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
    63
#define EL6002_PORT_NAME_SIZE 16
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
    64
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
typedef struct {
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
    ec_tty_t *tty;
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
    67
    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
    68
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
    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
    70
    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
    71
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
    u8 *tx_data;
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_size;
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
    75
    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
    76
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
    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
    78
    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
    79
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
    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
    81
    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
    82
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
    u16 control;
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
    u32 off_ctrl;
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
    u32 off_tx;
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    87
    u32 off_status;
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    88
    u32 off_rx;
1780
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
    89
1782
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
    90
    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
    91
    u8 requested_rtscts;
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
    92
    u8 current_rtscts;
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
    93
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
    94
    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
    95
    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
    96
    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
    97
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
    98
    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
    99
    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
   100
    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
   101
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   102
    unsigned int config_error;
1780
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   103
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   104
} el60xx_port_t;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   105
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   106
#define EL6002_PORTS 2
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   107
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   108
typedef struct {
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   109
    struct list_head list;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   110
    ec_slave_config_t *sc;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   111
    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
   112
} el6002_t;
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   113
1615
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   114
LIST_HEAD(handlers);
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   115
        
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   116
/*****************************************************************************/
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
/* Beckhoff EL6002
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   119
 * Vendor ID:       0x00000002
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   120
 * Product code:    0x17723052
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   121
 * Revision number: 0x00100000
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   122
 */
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
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
   125
   {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
   126
   {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
   127
   {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
   128
   {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
   129
   {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
   130
   {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
   131
   {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
   132
   {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
   133
   {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
   134
   {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
   135
   {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
   136
   {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
   137
   {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
   138
   {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
   139
   {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
   140
   {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
   141
   {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
   142
   {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
   143
   {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
   144
   {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
   145
   {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
   146
   {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
   147
   {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
   148
   {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
   149
   {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
   150
   {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
   151
   {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
   152
   {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
   153
   {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
   154
   {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
   155
   {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
   156
   {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
   157
   {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
   158
   {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
   159
   {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
   160
   {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
   161
   {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
   162
   {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
   163
   {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
   164
   {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
   165
   {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
   166
   {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
   167
   {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
   168
   {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
   169
   {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
   170
   {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
   171
   {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
   172
   {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
   173
   {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
   174
   {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
   175
   {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
   176
   {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
   177
   {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
   178
   {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
   179
   {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
   180
   {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
   181
   {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
   182
   {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
   183
   {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
   184
   {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
   185
   {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
   186
   {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
   187
   {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
   188
   {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
   189
   {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
   190
   {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
   191
   {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
   192
   {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
   193
   {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
   194
   {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
   195
   {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
   196
   {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
   197
   {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
   198
   {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
   199
   {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
   200
   {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
   201
   {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
   202
   {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
   203
   {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
   204
   {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
   205
   {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
   206
   {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
   207
   {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
   208
   {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
   209
   {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
   210
   {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
   211
   {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
   212
   {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
   213
   {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
   214
   {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
   215
   {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
   216
   {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
   217
};
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
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
   220
   {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
   221
   {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
   222
   {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
   223
   {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
   224
};
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
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
   227
   {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
   228
   {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
   229
   {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
   230
   {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
   231
   {0xff}
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   232
};
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   233
1780
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   234
typedef enum {
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   235
    PAR_NONE,
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   236
    PAR_ODD,
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   237
    PAR_EVEN
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   238
} parity_t;
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   239
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   240
typedef struct {
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   241
    u8 value;
1782
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   242
    unsigned int data_bits;
1780
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   243
    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
   244
    unsigned int stop_bits;
1780
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   245
} el600x_data_frame_t;
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   246
1782
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   247
/** EL600x supported values for data frame SDO.
1780
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   248
 */
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   249
el600x_data_frame_t el600x_data_frame[] = {
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   250
    {0x01, 7, PAR_EVEN, 1},
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   251
    {0x09, 7, PAR_EVEN, 2},
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   252
    {0x02, 7, PAR_ODD,  1},
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   253
    {0x0a, 7, PAR_ODD,  2},
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   254
    {0x03, 8, PAR_NONE, 1},
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   255
    {0x0b, 8, PAR_NONE, 2},
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   256
    {0x04, 8, PAR_EVEN, 1},
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   257
    {0x0c, 8, PAR_EVEN, 2},
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   258
    {0x05, 8, PAR_ODD,  1},
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   259
    {0x0d, 8, PAR_ODD,  2},
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   260
};
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   261
1782
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   262
typedef struct {
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   263
    u8 value;
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   264
    unsigned int baud;
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   265
    tcflag_t cbaud;
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   266
} 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
   267
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   268
/** 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
   269
 */
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   270
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
   271
    {1,   300,    B300},
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   272
    {2,   600,    B600},
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   273
    {3,   1200,   B1200},
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   274
    {4,   2400,   B2400},
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   275
    {5,   4800,   B4800},
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   276
    {6,   9600,   B9600},
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   277
    {7,   19200,  B19200},
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   278
    {8,   38400,  B38400},
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   279
    {9,   57600,  B57600},
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   280
    {10,  115200, B115200}
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   281
};
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   282
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   283
/****************************************************************************/
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   284
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   285
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
   286
{
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   287
    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
   288
    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
   289
    tcflag_t cbaud, rtscts;
1780
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   290
    parity_t par;
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   291
    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
   292
    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
   293
    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
   294
1782
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   295
#if DEBUG
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   296
    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
   297
#endif
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   298
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   299
    rtscts = cflag & CRTSCTS;
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   300
    printk(KERN_INFO PFX "%s: Requested RTS/CTS: %s.\n",
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   301
            port->name, rtscts ? "yes" : "no");
1782
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   302
    
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   303
    cbaud = cflag & CBAUD;
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   304
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   305
    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
   306
            i++) {
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   307
        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
   308
        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
   309
            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
   310
            break;
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   311
        }
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
    if (b_to_use) {
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   315
        printk(KERN_INFO PFX "%s: Requested baud rate: %u.\n",
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   316
                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
   317
    } else {
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   318
        printk(KERN_ERR PFX "Error: %s does not support"
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   319
                " 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
   320
        return -EINVAL;
2ba454c790c5 Implemented setting of baud rate, data frame and RTS/CTS.
Florian Pose <fp@igh-essen.com>
parents: 1780
diff changeset
   321
    }
1779
9fab229d6ca9 Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents: 1615
diff changeset
   322
9fab229d6ca9 Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents: 1615
diff changeset
   323
    switch (cflag & CSIZE) {
1780
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   324
        case CS5:
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   325
            data_bits = 5;
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   326
            break;
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   327
        case CS6:
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   328
            data_bits = 6;
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   329
            break;
1779
9fab229d6ca9 Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents: 1615
diff changeset
   330
        case CS7:
1780
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   331
            data_bits = 7;
1779
9fab229d6ca9 Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents: 1615
diff changeset
   332
            break;
9fab229d6ca9 Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents: 1615
diff changeset
   333
        case CS8:
1780
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   334
            data_bits = 8;
1779
9fab229d6ca9 Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents: 1615
diff changeset
   335
            break;
9fab229d6ca9 Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents: 1615
diff changeset
   336
        default: /* CS5 or CS6 */
1780
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   337
            data_bits = 0;
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   338
    }
1779
9fab229d6ca9 Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents: 1615
diff changeset
   339
9fab229d6ca9 Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents: 1615
diff changeset
   340
    if (cflag & PARENB) {
1780
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   341
        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
   342
    } else {
1780
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   343
        par = PAR_NONE;
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   344
    }
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
    stop_bits = (cflag & CSTOPB) ? 2 : 1;
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   347
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   348
    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
   349
            port->name, data_bits,
1780
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   350
            (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
   351
            stop_bits);
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   352
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   353
    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
   354
            i++) {
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   355
        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
   356
        if (df->data_bits == data_bits &&
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   357
                df->parity == par &&
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   358
                df->stop_bits == stop_bits) {
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   359
            df_to_use = df;
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   360
            break;
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   361
        }
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
    if (!df_to_use) {
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   365
        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
   366
                port->name);
1780
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   367
        return -EINVAL;
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   368
    }
11f452ca4d7a Check EL600x frame data configuration.
Florian Pose <fp@igh-essen.com>
parents: 1779
diff changeset
   369
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   370
    port->requested_rtscts = rtscts != 0;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   371
    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
   372
    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
   373
    port->config_error = 0;
1779
9fab229d6ca9 Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents: 1615
diff changeset
   374
    return 0;
9fab229d6ca9 Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents: 1615
diff changeset
   375
}
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
1787
439f186185be Callback set via own structure.
Florian Pose <fp@igh-essen.com>
parents: 1785
diff changeset
   379
static ec_tty_operations_t el60xx_tty_ops = {
439f186185be Callback set via own structure.
Florian Pose <fp@igh-essen.com>
parents: 1785
diff changeset
   380
    .cflag_changed = el60xx_cflag_changed,
439f186185be Callback set via own structure.
Florian Pose <fp@igh-essen.com>
parents: 1785
diff changeset
   381
};
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
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   385
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
   386
        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
   387
{
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   388
    int ret = 0;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   389
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   390
    strncpy(port->name, name, EL6002_PORT_NAME_SIZE);
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   391
1787
439f186185be Callback set via own structure.
Florian Pose <fp@igh-essen.com>
parents: 1785
diff changeset
   392
    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
   393
    if (IS_ERR(port->tty)) {
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   394
        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
   395
                port->name);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   396
        ret = PTR_ERR(port->tty);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   397
        goto out_return;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   398
    }
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
    port->max_tx_data_size = 22;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   401
    port->max_rx_data_size = 22;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   402
    port->tx_data = NULL;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   403
    port->tx_data_size = 0;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   404
    port->state = SER_REQUEST_INIT;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   405
    port->tx_request_toggle = 0;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   406
    port->rx_accepted_toggle = 0;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   407
    port->control = 0x0000;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   408
    port->off_ctrl = 0;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   409
    port->off_tx = 0;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   410
    port->off_status = 0;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   411
    port->off_rx = 0;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   412
    port->requested_rtscts = 0x00; // no hardware handshake
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   413
    port->current_rtscts = 0xff;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   414
    port->requested_baud_rate = 6; // 9600
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   415
    port->current_baud_rate = 0;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   416
    port->requested_data_frame = 0x03; // 8N1
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   417
    port->current_data_frame = 0x00;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   418
    port->config_error = 0;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   419
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   420
    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
   421
                    0x8000 + slot_offset, 0x01, 1))) {
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   422
        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
   423
                port->name);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   424
        ret = -ENOMEM;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   425
        goto out_free_tty;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   426
    }
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
    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
   429
                    0x8000 + slot_offset, 0x11, 1))) {
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   430
        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
   431
                port->name);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   432
        ret = -ENOMEM;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   433
        goto out_free_tty;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   434
    }
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
    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
   437
                    0x8000 + slot_offset, 0x15, 1))) {
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   438
        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
   439
                port->name);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   440
        ret = -ENOMEM;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   441
        goto out_free_tty;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   442
    }
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
    ret = ecrt_slave_config_reg_pdo_entry(
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   445
            sc, 0x7001 + slot_offset, 0x01, domain, NULL);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   446
    if (ret < 0) {
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   447
        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
   448
                port->name);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   449
        goto out_free_tty;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   450
    }
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   451
    port->off_ctrl = ret;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   452
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   453
    ret = ecrt_slave_config_reg_pdo_entry(
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   454
            sc, 0x7000 + slot_offset, 0x11, domain, NULL);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   455
    if (ret < 0) {
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   456
        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
   457
                port->name);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   458
        goto out_free_tty;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   459
    }
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   460
    port->off_tx = ret;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   461
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   462
    ret = ecrt_slave_config_reg_pdo_entry(
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   463
            sc, 0x6001 + slot_offset, 0x01, domain, NULL);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   464
    if (ret < 0) {
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   465
        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
   466
                port->name);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   467
        goto out_free_tty;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   468
    }
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   469
    port->off_status = ret;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   470
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   471
    ret = ecrt_slave_config_reg_pdo_entry(
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   472
            sc, 0x6000 + slot_offset, 0x11, domain, NULL);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   473
    if (ret < 0) {
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   474
        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
   475
                port->name);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   476
        goto out_free_tty;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   477
    }
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   478
    port->off_rx = ret;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   479
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   480
    if (port->max_tx_data_size > 0) {
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   481
        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
   482
        if (port->tx_data == NULL) {
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   483
            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
   484
                    " 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
   485
            ret = -ENOMEM;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   486
            goto out_free_tty;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   487
        }
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
    return 0;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   491
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   492
out_free_tty:
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   493
    ectty_free(port->tty);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   494
out_return:
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   495
    return ret;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   496
}
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
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
   501
{
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   502
    ectty_free(port->tty);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   503
    if (port->tx_data) {
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   504
        kfree(port->tx_data);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   505
    }
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
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
   511
{
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   512
    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
   513
    u8 *rx_data = pd + port->off_rx;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   514
    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
   515
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   516
    switch (port->state) {
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   517
        case SER_READY:
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   518
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   519
            /* 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
   520
            if (!port->config_error &&
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   521
                    port->requested_rtscts != port->current_rtscts) {
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   522
                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
   523
                        port->requested_rtscts);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   524
                ecrt_sdo_request_write(port->rtscts_sdo);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   525
                port->state = SER_SET_RTSCTS;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   526
                break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   527
            }
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
            /* 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
   530
            if (!port->config_error &&
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   531
                    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
   532
                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
   533
                        port->requested_baud_rate);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   534
                ecrt_sdo_request_write(port->baud_sdo);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   535
                port->state = SER_SET_BAUD_RATE;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   536
                break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   537
            }
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
            /* 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
   540
            if (!port->config_error &&
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   541
                    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
   542
                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
   543
                        port->requested_data_frame);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   544
                ecrt_sdo_request_write(port->frame_sdo);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   545
                port->state = SER_SET_DATA_FRAME;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   546
                break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   547
            }
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
            /* Send data */
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   550
            
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   551
            tx_accepted_toggle = status & 0x0001;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   552
            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
   553
                port->tx_data_size =
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   554
                    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
   555
                if (port->tx_data_size) {
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   556
#if DEBUG
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   557
                    printk(KERN_INFO PFX "%s: Sending %u bytes.\n",
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   558
                            port->name, port->tx_data_size);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   559
#endif
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   560
                    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
   561
                    port->tx_accepted_toggle = tx_accepted_toggle;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   562
                }
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
            /* Receive data */
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   566
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   567
            rx_request_toggle = status & 0x0002;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   568
            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
   569
                uint8_t rx_data_size = status >> 8;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   570
                port->rx_request_toggle = rx_request_toggle;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   571
#if DEBUG
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   572
                printk(KERN_INFO PFX "%s: Received %u bytes.\n",
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   573
                        port->name, rx_data_size);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   574
#endif
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   575
                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
   576
                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
   577
            }
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
            port->control =
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   580
                port->tx_request_toggle |
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   581
                port->rx_accepted_toggle << 1 |
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   582
                port->tx_data_size << 8;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   583
            break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   584
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   585
        case SER_REQUEST_INIT:
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   586
            if (status & (1 << 2)) {
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   587
                port->control = 0x0000;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   588
                port->state = SER_WAIT_FOR_INIT_RESPONSE;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   589
            } else {
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   590
                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
   591
            }
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   592
            break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   593
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   594
        case SER_WAIT_FOR_INIT_RESPONSE:
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   595
            if (!(status & (1 << 2))) {
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   596
                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
   597
                port->tx_accepted_toggle = 1;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   598
                port->control = 0x0000;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   599
                port->state = SER_READY;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   600
            }
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   601
            break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   602
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   603
        case SER_SET_RTSCTS:
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   604
            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
   605
                case EC_REQUEST_SUCCESS:
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   606
                    printk(KERN_INFO PFX "%s: Accepted RTS/CTS.\n",
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   607
                            port->name);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   608
                    port->current_rtscts = port->requested_rtscts;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   609
                    port->state = SER_REQUEST_INIT;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   610
                    break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   611
                case EC_REQUEST_ERROR:
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   612
                    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
   613
                            port->name);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   614
                    port->state = SER_REQUEST_INIT;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   615
                    port->config_error = 1;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   616
                    break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   617
                default:
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   618
                    break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   619
            }
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   620
            break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   621
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   622
        case SER_SET_BAUD_RATE:
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   623
            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
   624
                case EC_REQUEST_SUCCESS:
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   625
                    printk(KERN_INFO PFX "%s: Accepted baud rate.\n",
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   626
                            port->name);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   627
                    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
   628
                    port->state = SER_REQUEST_INIT;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   629
                    break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   630
                case EC_REQUEST_ERROR:
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   631
                    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
   632
                            port->name);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   633
                    port->state = SER_REQUEST_INIT;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   634
                    port->config_error = 1;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   635
                    break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   636
                default:
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   637
                    break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   638
            }
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   639
            break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   640
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   641
        case SER_SET_DATA_FRAME:
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   642
            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
   643
                case EC_REQUEST_SUCCESS:
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   644
                    printk(KERN_INFO PFX "%s: Accepted data frame.\n",
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   645
                            port->name);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   646
                    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
   647
                    port->state = SER_REQUEST_INIT;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   648
                    break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   649
                case EC_REQUEST_ERROR:
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   650
                    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
   651
                            port->name);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   652
                    port->state = SER_REQUEST_INIT;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   653
                    port->config_error = 1;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   654
                    break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   655
                default:
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   656
                    break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   657
            }
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   658
            break;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   659
    }
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
    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
   662
    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
   663
}
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
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
   668
        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
   669
{
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   670
    int ret = 0, i;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   671
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   672
    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
   673
                    master, 0, position, vendor, product))) {
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   674
        printk(KERN_ERR PFX "EL6002(%u): Failed to create"
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   675
                " 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
   676
        ret = -EBUSY;
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   677
        goto out_return;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   678
    }
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
    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
   681
        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
   682
                position);
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   683
        ret = -ENOMEM;
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   684
        goto out_return;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   685
    }
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
    for (i = 0; i < EL6002_PORTS; i++) {
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   688
        char name[EL6002_PORT_NAME_SIZE];
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   689
        snprintf(name, EL6002_PORT_NAME_SIZE, "EL6002(%u) X%u",
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   690
                position, i + 1);
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   691
        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
   692
                    name)) {
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   693
            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
   694
                    position, i);
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   695
            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
   696
        }
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
    return 0;
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   700
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   701
out_ports:
1788
af61953c3ba4 Fixed segfault if creation of TTY devices fails.
Florian Pose <fp@igh-essen.com>
parents: 1787
diff changeset
   702
    for (i--; i >= 0; i--) {
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   703
        el60xx_port_clear(el6002->port + i);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   704
    }
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   705
out_return:
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   706
    return ret;
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   707
}
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
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   711
void el6002_clear(el6002_t *el6002)
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   712
{
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   713
    int i;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   714
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   715
    for (i = 0; i < EL6002_PORTS; i++) {
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   716
        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
   717
    }
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
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   722
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
   723
{
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   724
    int i;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   725
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   726
    for (i = 0; i < EL6002_PORTS; i++) {
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   727
        el60xx_port_run(el6002->port + i, pd);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   728
    }
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   729
}
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
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
   734
{
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   735
    el6002_t *el6002;
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   736
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   737
    list_for_each_entry(el6002, &handlers, list) {
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   738
        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
   739
    }
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
1783
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   744
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
   745
        u16 position, u32 vendor, u32 product)
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   746
{
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   747
    el6002_t *el6002;
1783
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   748
    int ret;
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   749
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   750
    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
   751
            position);
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   752
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   753
    el6002 = kmalloc(sizeof(*el6002), GFP_KERNEL);
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   754
    if (!el6002) {
1783
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   755
        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
   756
        return -ENOMEM;
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   757
    }
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   758
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   759
    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
   760
    if (ret) {
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   761
        kfree(el6002);
1783
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   762
        return ret;
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   763
    }
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   764
1784
bc2aff866a5b Implemented all 2 ports of EL6002.
Florian Pose <fp@igh-essen.com>
parents: 1783
diff changeset
   765
    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
   766
    return 0;
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   767
}
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
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   771
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
   772
{
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   773
    int i, ret;
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   774
    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
   775
    ec_slave_info_t slave_info;
1615
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   776
    el6002_t *ser, *next;
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   777
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   778
    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
   779
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   780
    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
   781
    if (ret) {
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   782
        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
   783
        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
   784
    }
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
    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
   787
        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
   788
        if (ret) {
1615
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   789
            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
   790
            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
   791
        }
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   792
1783
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   793
        if (slave_info.vendor_id == VendorIdBeckhoff
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   794
                && slave_info.product_code == ProductCodeBeckhoffEL6002) {
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   795
            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
   796
                    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
   797
                goto out_free_handlers;
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   798
            }
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   799
        }
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   800
1783
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   801
        if (slave_info.vendor_id == VendorIdIds
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   802
                && slave_info.product_code == ProductCodeIdsCSI71A) {
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   803
            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
   804
                    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
   805
                goto out_free_handlers;
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   806
            }
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   807
        }
1783
8fd654d9ed5c Also accept ids 2-port serial slave.
Florian Pose <fp@igh-essen.com>
parents: 1782
diff changeset
   808
    }
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   809
1785
9ed0334edaf9 Named serial ports.
Florian Pose <fp@igh-essen.com>
parents: 1784
diff changeset
   810
    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
   811
    return 0;
1615
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   812
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   813
out_free_handlers:
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   814
    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
   815
        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
   816
        el6002_clear(ser);
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   817
        kfree(ser);
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   818
    }
1615
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   819
out_return:
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   820
    return ret;
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   821
}
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
void free_serial_devices(void)
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   826
{
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   827
    el6002_t *ser, *next;
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   828
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   829
    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
   830
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   831
    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
   832
        list_del(&ser->list);
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   833
        el6002_clear(ser);
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   834
        kfree(ser);
020ad9ad3afb TTY example: Auto-create multiple handlers.
Florian Pose <fp@igh-essen.com>
parents: 1614
diff changeset
   835
    }
1613
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   836
070b4b420ab1 TTY: Sourced serial device functions out into serial.c/serial.h.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   837
    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
   838
}
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
/*****************************************************************************/