18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci  Madge Horizon ATM Adapter driver.
48c2ecf20Sopenharmony_ci  Copyright (C) 1995-1999  Madge Networks Ltd.
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci*/
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci/*
98c2ecf20Sopenharmony_ci  IMPORTANT NOTE: Madge Networks no longer makes the adapters
108c2ecf20Sopenharmony_ci  supported by this driver and makes no commitment to maintain it.
118c2ecf20Sopenharmony_ci*/
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci/* too many macros - change to inline functions */
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#ifndef DRIVER_ATM_HORIZON_H
168c2ecf20Sopenharmony_ci#define DRIVER_ATM_HORIZON_H
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#ifdef CONFIG_ATM_HORIZON_DEBUG
208c2ecf20Sopenharmony_ci#define DEBUG_HORIZON
218c2ecf20Sopenharmony_ci#endif
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#define DEV_LABEL                         "hrz"
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci#ifndef PCI_VENDOR_ID_MADGE
268c2ecf20Sopenharmony_ci#define PCI_VENDOR_ID_MADGE               0x10B6
278c2ecf20Sopenharmony_ci#endif
288c2ecf20Sopenharmony_ci#ifndef PCI_DEVICE_ID_MADGE_HORIZON
298c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_MADGE_HORIZON       0x1000
308c2ecf20Sopenharmony_ci#endif
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci// diagnostic output
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci#define PRINTK(severity,format,args...) \
358c2ecf20Sopenharmony_ci  printk(severity DEV_LABEL ": " format "\n" , ## args)
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci#ifdef DEBUG_HORIZON
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci#define DBG_ERR  0x0001
408c2ecf20Sopenharmony_ci#define DBG_WARN 0x0002
418c2ecf20Sopenharmony_ci#define DBG_INFO 0x0004
428c2ecf20Sopenharmony_ci#define DBG_VCC  0x0008
438c2ecf20Sopenharmony_ci#define DBG_QOS  0x0010
448c2ecf20Sopenharmony_ci#define DBG_TX   0x0020
458c2ecf20Sopenharmony_ci#define DBG_RX   0x0040
468c2ecf20Sopenharmony_ci#define DBG_SKB  0x0080
478c2ecf20Sopenharmony_ci#define DBG_IRQ  0x0100
488c2ecf20Sopenharmony_ci#define DBG_FLOW 0x0200
498c2ecf20Sopenharmony_ci#define DBG_BUS  0x0400
508c2ecf20Sopenharmony_ci#define DBG_REGS 0x0800
518c2ecf20Sopenharmony_ci#define DBG_DATA 0x1000
528c2ecf20Sopenharmony_ci#define DBG_MASK 0x1fff
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci/* the ## prevents the annoying double expansion of the macro arguments */
558c2ecf20Sopenharmony_ci/* KERN_INFO is used since KERN_DEBUG often does not make it to the console */
568c2ecf20Sopenharmony_ci#define PRINTDB(bits,format,args...) \
578c2ecf20Sopenharmony_ci  ( (debug & (bits)) ? printk (KERN_INFO DEV_LABEL ": " format , ## args) : 1 )
588c2ecf20Sopenharmony_ci#define PRINTDM(bits,format,args...) \
598c2ecf20Sopenharmony_ci  ( (debug & (bits)) ? printk (format , ## args) : 1 )
608c2ecf20Sopenharmony_ci#define PRINTDE(bits,format,args...) \
618c2ecf20Sopenharmony_ci  ( (debug & (bits)) ? printk (format "\n" , ## args) : 1 )
628c2ecf20Sopenharmony_ci#define PRINTD(bits,format,args...) \
638c2ecf20Sopenharmony_ci  ( (debug & (bits)) ? printk (KERN_INFO DEV_LABEL ": " format "\n" , ## args) : 1 )
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci#else
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci#define PRINTD(bits,format,args...)
688c2ecf20Sopenharmony_ci#define PRINTDB(bits,format,args...)
698c2ecf20Sopenharmony_ci#define PRINTDM(bits,format,args...)
708c2ecf20Sopenharmony_ci#define PRINTDE(bits,format,args...)
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci#endif
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci#define PRINTDD(sec,fmt,args...)
758c2ecf20Sopenharmony_ci#define PRINTDDB(sec,fmt,args...)
768c2ecf20Sopenharmony_ci#define PRINTDDM(sec,fmt,args...)
778c2ecf20Sopenharmony_ci#define PRINTDDE(sec,fmt,args...)
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci// fixed constants
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci#define SPARE_BUFFER_POOL_SIZE            MAX_VCS
828c2ecf20Sopenharmony_ci#define HRZ_MAX_VPI                       4
838c2ecf20Sopenharmony_ci#define MIN_PCI_LATENCY                   48 // 24 IS TOO SMALL
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci/*  Horizon specific bits */
868c2ecf20Sopenharmony_ci/*  Register offsets */
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci#define HRZ_IO_EXTENT                     0x80
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ci#define DATA_PORT_OFF                     0x00
918c2ecf20Sopenharmony_ci#define TX_CHANNEL_PORT_OFF               0x04
928c2ecf20Sopenharmony_ci#define TX_DESCRIPTOR_PORT_OFF            0x08
938c2ecf20Sopenharmony_ci#define MEMORY_PORT_OFF                   0x0C
948c2ecf20Sopenharmony_ci#define MEM_WR_ADDR_REG_OFF               0x14
958c2ecf20Sopenharmony_ci#define MEM_RD_ADDR_REG_OFF               0x18
968c2ecf20Sopenharmony_ci#define CONTROL_0_REG                     0x1C
978c2ecf20Sopenharmony_ci#define INT_SOURCE_REG_OFF                0x20
988c2ecf20Sopenharmony_ci#define INT_ENABLE_REG_OFF                0x24
998c2ecf20Sopenharmony_ci#define MASTER_RX_ADDR_REG_OFF            0x28
1008c2ecf20Sopenharmony_ci#define MASTER_RX_COUNT_REG_OFF           0x2C
1018c2ecf20Sopenharmony_ci#define MASTER_TX_ADDR_REG_OFF            0x30
1028c2ecf20Sopenharmony_ci#define MASTER_TX_COUNT_REG_OFF           0x34
1038c2ecf20Sopenharmony_ci#define TX_DESCRIPTOR_REG_OFF             0x38
1048c2ecf20Sopenharmony_ci#define TX_CHANNEL_CONFIG_COMMAND_OFF     0x40
1058c2ecf20Sopenharmony_ci#define TX_CHANNEL_CONFIG_DATA_OFF        0x44
1068c2ecf20Sopenharmony_ci#define TX_FREE_BUFFER_COUNT_OFF          0x48
1078c2ecf20Sopenharmony_ci#define RX_FREE_BUFFER_COUNT_OFF          0x4C
1088c2ecf20Sopenharmony_ci#define TX_CONFIG_OFF                     0x50
1098c2ecf20Sopenharmony_ci#define TX_STATUS_OFF                     0x54
1108c2ecf20Sopenharmony_ci#define RX_CONFIG_OFF                     0x58
1118c2ecf20Sopenharmony_ci#define RX_LINE_CONFIG_OFF                0x5C
1128c2ecf20Sopenharmony_ci#define RX_QUEUE_RD_PTR_OFF               0x60
1138c2ecf20Sopenharmony_ci#define RX_QUEUE_WR_PTR_OFF               0x64
1148c2ecf20Sopenharmony_ci#define MAX_AAL5_CELL_COUNT_OFF           0x68
1158c2ecf20Sopenharmony_ci#define RX_CHANNEL_PORT_OFF               0x6C
1168c2ecf20Sopenharmony_ci#define TX_CELL_COUNT_OFF                 0x70
1178c2ecf20Sopenharmony_ci#define RX_CELL_COUNT_OFF                 0x74
1188c2ecf20Sopenharmony_ci#define HEC_ERROR_COUNT_OFF               0x78
1198c2ecf20Sopenharmony_ci#define UNASSIGNED_CELL_COUNT_OFF         0x7C
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci/*  Register bit definitions */
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ci/* Control 0 register */
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_ci#define SEEPROM_DO                        0x00000001
1268c2ecf20Sopenharmony_ci#define SEEPROM_DI                        0x00000002
1278c2ecf20Sopenharmony_ci#define SEEPROM_SK                        0x00000004
1288c2ecf20Sopenharmony_ci#define SEEPROM_CS                        0x00000008
1298c2ecf20Sopenharmony_ci#define DEBUG_BIT_0                       0x00000010
1308c2ecf20Sopenharmony_ci#define DEBUG_BIT_1                       0x00000020
1318c2ecf20Sopenharmony_ci#define DEBUG_BIT_2                       0x00000040
1328c2ecf20Sopenharmony_ci//      RESERVED                          0x00000080
1338c2ecf20Sopenharmony_ci#define DEBUG_BIT_0_OE                    0x00000100
1348c2ecf20Sopenharmony_ci#define DEBUG_BIT_1_OE                    0x00000200
1358c2ecf20Sopenharmony_ci#define DEBUG_BIT_2_OE                    0x00000400
1368c2ecf20Sopenharmony_ci//      RESERVED                          0x00000800
1378c2ecf20Sopenharmony_ci#define DEBUG_BIT_0_STATE                 0x00001000
1388c2ecf20Sopenharmony_ci#define DEBUG_BIT_1_STATE                 0x00002000
1398c2ecf20Sopenharmony_ci#define DEBUG_BIT_2_STATE                 0x00004000
1408c2ecf20Sopenharmony_ci//      RESERVED                          0x00008000
1418c2ecf20Sopenharmony_ci#define GENERAL_BIT_0                     0x00010000
1428c2ecf20Sopenharmony_ci#define GENERAL_BIT_1                     0x00020000
1438c2ecf20Sopenharmony_ci#define GENERAL_BIT_2                     0x00040000
1448c2ecf20Sopenharmony_ci#define GENERAL_BIT_3                     0x00080000
1458c2ecf20Sopenharmony_ci#define RESET_HORIZON                     0x00100000
1468c2ecf20Sopenharmony_ci#define RESET_ATM                         0x00200000
1478c2ecf20Sopenharmony_ci#define RESET_RX                          0x00400000
1488c2ecf20Sopenharmony_ci#define RESET_TX                          0x00800000
1498c2ecf20Sopenharmony_ci#define RESET_HOST                        0x01000000
1508c2ecf20Sopenharmony_ci//      RESERVED                          0x02000000
1518c2ecf20Sopenharmony_ci#define TARGET_RETRY_DISABLE              0x04000000
1528c2ecf20Sopenharmony_ci#define ATM_LAYER_SELECT                  0x08000000
1538c2ecf20Sopenharmony_ci#define ATM_LAYER_STATUS                  0x10000000
1548c2ecf20Sopenharmony_ci//      RESERVED                          0xE0000000
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_ci/* Interrupt source and enable registers */
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_ci#define RX_DATA_AV                        0x00000001
1598c2ecf20Sopenharmony_ci#define RX_DISABLED                       0x00000002
1608c2ecf20Sopenharmony_ci#define TIMING_MARKER                     0x00000004
1618c2ecf20Sopenharmony_ci#define FORCED                            0x00000008
1628c2ecf20Sopenharmony_ci#define RX_BUS_MASTER_COMPLETE            0x00000010
1638c2ecf20Sopenharmony_ci#define TX_BUS_MASTER_COMPLETE            0x00000020
1648c2ecf20Sopenharmony_ci#define ABR_TX_CELL_COUNT_INT             0x00000040
1658c2ecf20Sopenharmony_ci#define DEBUG_INT                         0x00000080
1668c2ecf20Sopenharmony_ci//      RESERVED                          0xFFFFFF00
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_ci/* PIO and Bus Mastering */
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ci#define MAX_PIO_COUNT                     0x000000ff // 255 - make tunable?
1718c2ecf20Sopenharmony_ci// 8188 is a hard limit for bus mastering
1728c2ecf20Sopenharmony_ci#define MAX_TRANSFER_COUNT                0x00001ffc // 8188
1738c2ecf20Sopenharmony_ci#define MASTER_TX_AUTO_APPEND_DESC        0x80000000
1748c2ecf20Sopenharmony_ci
1758c2ecf20Sopenharmony_ci/* TX channel config command port */
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_ci#define PCR_TIMER_ACCESS                      0x0000
1788c2ecf20Sopenharmony_ci#define SCR_TIMER_ACCESS                      0x0001
1798c2ecf20Sopenharmony_ci#define BUCKET_CAPACITY_ACCESS                0x0002
1808c2ecf20Sopenharmony_ci#define BUCKET_FULLNESS_ACCESS                0x0003
1818c2ecf20Sopenharmony_ci#define RATE_TYPE_ACCESS                      0x0004
1828c2ecf20Sopenharmony_ci//      UNUSED                                0x00F8
1838c2ecf20Sopenharmony_ci#define TX_CHANNEL_CONFIG_MULT                0x0100
1848c2ecf20Sopenharmony_ci//      UNUSED                                0xF800
1858c2ecf20Sopenharmony_ci#define BUCKET_MAX_SIZE                       0x003f
1868c2ecf20Sopenharmony_ci
1878c2ecf20Sopenharmony_ci/* TX channel config data port */
1888c2ecf20Sopenharmony_ci
1898c2ecf20Sopenharmony_ci#define CLOCK_SELECT_SHIFT                    4
1908c2ecf20Sopenharmony_ci#define CLOCK_DISABLE                         0x00ff
1918c2ecf20Sopenharmony_ci
1928c2ecf20Sopenharmony_ci#define IDLE_RATE_TYPE                       0x0
1938c2ecf20Sopenharmony_ci#define ABR_RATE_TYPE                        0x1
1948c2ecf20Sopenharmony_ci#define VBR_RATE_TYPE                        0x2
1958c2ecf20Sopenharmony_ci#define CBR_RATE_TYPE                        0x3
1968c2ecf20Sopenharmony_ci
1978c2ecf20Sopenharmony_ci/* TX config register */
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_ci#define DRVR_DRVRBAR_ENABLE                   0x0001
2008c2ecf20Sopenharmony_ci#define TXCLK_MUX_SELECT_RCLK                 0x0002
2018c2ecf20Sopenharmony_ci#define TRANSMIT_TIMING_MARKER                0x0004
2028c2ecf20Sopenharmony_ci#define LOOPBACK_TIMING_MARKER                0x0008
2038c2ecf20Sopenharmony_ci#define TX_TEST_MODE_16MHz                    0x0000
2048c2ecf20Sopenharmony_ci#define TX_TEST_MODE_8MHz                     0x0010
2058c2ecf20Sopenharmony_ci#define TX_TEST_MODE_5_33MHz                  0x0020
2068c2ecf20Sopenharmony_ci#define TX_TEST_MODE_4MHz                     0x0030
2078c2ecf20Sopenharmony_ci#define TX_TEST_MODE_3_2MHz                   0x0040
2088c2ecf20Sopenharmony_ci#define TX_TEST_MODE_2_66MHz                  0x0050
2098c2ecf20Sopenharmony_ci#define TX_TEST_MODE_2_29MHz                  0x0060
2108c2ecf20Sopenharmony_ci#define TX_NORMAL_OPERATION                   0x0070
2118c2ecf20Sopenharmony_ci#define ABR_ROUND_ROBIN                       0x0080
2128c2ecf20Sopenharmony_ci
2138c2ecf20Sopenharmony_ci/* TX status register */
2148c2ecf20Sopenharmony_ci
2158c2ecf20Sopenharmony_ci#define IDLE_CHANNELS_MASK                    0x00FF
2168c2ecf20Sopenharmony_ci#define ABR_CELL_COUNT_REACHED_MULT           0x0100
2178c2ecf20Sopenharmony_ci#define ABR_CELL_COUNT_REACHED_MASK           0xFF
2188c2ecf20Sopenharmony_ci
2198c2ecf20Sopenharmony_ci/* RX config register */
2208c2ecf20Sopenharmony_ci
2218c2ecf20Sopenharmony_ci#define NON_USER_CELLS_IN_ONE_CHANNEL         0x0008
2228c2ecf20Sopenharmony_ci#define RX_ENABLE                             0x0010
2238c2ecf20Sopenharmony_ci#define IGNORE_UNUSED_VPI_VCI_BITS_SET        0x0000
2248c2ecf20Sopenharmony_ci#define NON_USER_UNUSED_VPI_VCI_BITS_SET      0x0020
2258c2ecf20Sopenharmony_ci#define DISCARD_UNUSED_VPI_VCI_BITS_SET       0x0040
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_ci/* RX line config register */
2288c2ecf20Sopenharmony_ci
2298c2ecf20Sopenharmony_ci#define SIGNAL_LOSS                           0x0001
2308c2ecf20Sopenharmony_ci#define FREQUENCY_DETECT_ERROR                0x0002
2318c2ecf20Sopenharmony_ci#define LOCK_DETECT_ERROR                     0x0004
2328c2ecf20Sopenharmony_ci#define SELECT_INTERNAL_LOOPBACK              0x0008
2338c2ecf20Sopenharmony_ci#define LOCK_DETECT_ENABLE                    0x0010
2348c2ecf20Sopenharmony_ci#define FREQUENCY_DETECT_ENABLE               0x0020
2358c2ecf20Sopenharmony_ci#define USER_FRAQ                             0x0040
2368c2ecf20Sopenharmony_ci#define GXTALOUT_SELECT_DIV4                  0x0080
2378c2ecf20Sopenharmony_ci#define GXTALOUT_SELECT_NO_GATING             0x0100
2388c2ecf20Sopenharmony_ci#define TIMING_MARKER_RECEIVED                0x0200
2398c2ecf20Sopenharmony_ci
2408c2ecf20Sopenharmony_ci/* RX channel port */
2418c2ecf20Sopenharmony_ci
2428c2ecf20Sopenharmony_ci#define RX_CHANNEL_MASK                       0x03FF
2438c2ecf20Sopenharmony_ci// UNUSED                                     0x3C00
2448c2ecf20Sopenharmony_ci#define FLUSH_CHANNEL                         0x4000
2458c2ecf20Sopenharmony_ci#define RX_CHANNEL_UPDATE_IN_PROGRESS         0x8000
2468c2ecf20Sopenharmony_ci
2478c2ecf20Sopenharmony_ci/* Receive queue entry */
2488c2ecf20Sopenharmony_ci
2498c2ecf20Sopenharmony_ci#define RX_Q_ENTRY_LENGTH_MASK            0x0000FFFF
2508c2ecf20Sopenharmony_ci#define RX_Q_ENTRY_CHANNEL_SHIFT          16
2518c2ecf20Sopenharmony_ci#define SIMONS_DODGEY_MARKER              0x08000000
2528c2ecf20Sopenharmony_ci#define RX_CONGESTION_EXPERIENCED         0x10000000
2538c2ecf20Sopenharmony_ci#define RX_CRC_10_OK                      0x20000000
2548c2ecf20Sopenharmony_ci#define RX_CRC_32_OK                      0x40000000
2558c2ecf20Sopenharmony_ci#define RX_COMPLETE_FRAME                 0x80000000
2568c2ecf20Sopenharmony_ci
2578c2ecf20Sopenharmony_ci/*  Offsets and constants for use with the buffer memory         */
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_ci/* Buffer pointers and channel types */
2608c2ecf20Sopenharmony_ci
2618c2ecf20Sopenharmony_ci#define BUFFER_PTR_MASK                   0x0000FFFF
2628c2ecf20Sopenharmony_ci#define RX_INT_THRESHOLD_MULT             0x00010000
2638c2ecf20Sopenharmony_ci#define RX_INT_THRESHOLD_MASK             0x07FF
2648c2ecf20Sopenharmony_ci#define INT_EVERY_N_CELLS                 0x08000000
2658c2ecf20Sopenharmony_ci#define CONGESTION_EXPERIENCED            0x10000000
2668c2ecf20Sopenharmony_ci#define FIRST_CELL_OF_AAL5_FRAME          0x20000000
2678c2ecf20Sopenharmony_ci#define CHANNEL_TYPE_AAL5                 0x00000000
2688c2ecf20Sopenharmony_ci#define CHANNEL_TYPE_RAW_CELLS            0x40000000
2698c2ecf20Sopenharmony_ci#define CHANNEL_TYPE_AAL3_4               0x80000000
2708c2ecf20Sopenharmony_ci
2718c2ecf20Sopenharmony_ci/* Buffer status stuff */
2728c2ecf20Sopenharmony_ci
2738c2ecf20Sopenharmony_ci#define BUFF_STATUS_MASK                  0x00030000
2748c2ecf20Sopenharmony_ci#define BUFF_STATUS_EMPTY                 0x00000000
2758c2ecf20Sopenharmony_ci#define BUFF_STATUS_CELL_AV               0x00010000
2768c2ecf20Sopenharmony_ci#define BUFF_STATUS_LAST_CELL_AV          0x00020000
2778c2ecf20Sopenharmony_ci
2788c2ecf20Sopenharmony_ci/* Transmit channel stuff */
2798c2ecf20Sopenharmony_ci
2808c2ecf20Sopenharmony_ci/* Receive channel stuff */
2818c2ecf20Sopenharmony_ci
2828c2ecf20Sopenharmony_ci#define RX_CHANNEL_DISABLED               0x00000000
2838c2ecf20Sopenharmony_ci#define RX_CHANNEL_IDLE                   0x00000001
2848c2ecf20Sopenharmony_ci
2858c2ecf20Sopenharmony_ci/*  General things */
2868c2ecf20Sopenharmony_ci
2878c2ecf20Sopenharmony_ci#define INITIAL_CRC                       0xFFFFFFFF
2888c2ecf20Sopenharmony_ci
2898c2ecf20Sopenharmony_ci// A Horizon u32, a byte! Really nasty. Horizon pointers are (32 bit)
2908c2ecf20Sopenharmony_ci// word addresses and so standard C pointer operations break (as they
2918c2ecf20Sopenharmony_ci// assume byte addresses); so we pretend that Horizon words (and word
2928c2ecf20Sopenharmony_ci// pointers) are bytes (and byte pointers) for the purposes of having
2938c2ecf20Sopenharmony_ci// a memory map that works.
2948c2ecf20Sopenharmony_ci
2958c2ecf20Sopenharmony_citypedef u8 HDW;
2968c2ecf20Sopenharmony_ci
2978c2ecf20Sopenharmony_citypedef struct cell_buf {
2988c2ecf20Sopenharmony_ci  HDW payload[12];
2998c2ecf20Sopenharmony_ci  HDW next;
3008c2ecf20Sopenharmony_ci  HDW cell_count;               // AAL5 rx bufs
3018c2ecf20Sopenharmony_ci  HDW res;
3028c2ecf20Sopenharmony_ci  union {
3038c2ecf20Sopenharmony_ci    HDW partial_crc;            // AAL5 rx bufs
3048c2ecf20Sopenharmony_ci    HDW cell_header;            // RAW     bufs
3058c2ecf20Sopenharmony_ci  } u;
3068c2ecf20Sopenharmony_ci} cell_buf;
3078c2ecf20Sopenharmony_ci
3088c2ecf20Sopenharmony_citypedef struct tx_ch_desc {
3098c2ecf20Sopenharmony_ci  HDW rd_buf_type;
3108c2ecf20Sopenharmony_ci  HDW wr_buf_type;
3118c2ecf20Sopenharmony_ci  HDW partial_crc;
3128c2ecf20Sopenharmony_ci  HDW cell_header;
3138c2ecf20Sopenharmony_ci} tx_ch_desc;
3148c2ecf20Sopenharmony_ci
3158c2ecf20Sopenharmony_citypedef struct rx_ch_desc {
3168c2ecf20Sopenharmony_ci  HDW wr_buf_type;
3178c2ecf20Sopenharmony_ci  HDW rd_buf_type;
3188c2ecf20Sopenharmony_ci} rx_ch_desc;
3198c2ecf20Sopenharmony_ci
3208c2ecf20Sopenharmony_citypedef struct rx_q_entry {
3218c2ecf20Sopenharmony_ci  HDW entry;
3228c2ecf20Sopenharmony_ci} rx_q_entry;
3238c2ecf20Sopenharmony_ci
3248c2ecf20Sopenharmony_ci#define TX_CHANS 8
3258c2ecf20Sopenharmony_ci#define RX_CHANS 1024
3268c2ecf20Sopenharmony_ci#define RX_QS 1024
3278c2ecf20Sopenharmony_ci#define MAX_VCS RX_CHANS
3288c2ecf20Sopenharmony_ci
3298c2ecf20Sopenharmony_ci/* Horizon buffer memory map */
3308c2ecf20Sopenharmony_ci
3318c2ecf20Sopenharmony_ci// TX Channel Descriptors         2
3328c2ecf20Sopenharmony_ci// TX Initial Buffers             8 // TX_CHANS
3338c2ecf20Sopenharmony_ci#define BUFN1_SIZE              118 // (126 - TX_CHANS)
3348c2ecf20Sopenharmony_ci//      RX/TX Start/End Buffers   4
3358c2ecf20Sopenharmony_ci#define BUFN2_SIZE              124
3368c2ecf20Sopenharmony_ci//      RX Queue Entries         64
3378c2ecf20Sopenharmony_ci#define BUFN3_SIZE              192
3388c2ecf20Sopenharmony_ci//      RX Channel Descriptors  128
3398c2ecf20Sopenharmony_ci#define BUFN4_SIZE             1408
3408c2ecf20Sopenharmony_ci//      TOTAL cell_buff chunks 2048
3418c2ecf20Sopenharmony_ci
3428c2ecf20Sopenharmony_ci//    cell_buf             bufs[2048];
3438c2ecf20Sopenharmony_ci//    HDW                  dws[32768];
3448c2ecf20Sopenharmony_ci
3458c2ecf20Sopenharmony_citypedef struct MEMMAP {
3468c2ecf20Sopenharmony_ci  tx_ch_desc  tx_descs[TX_CHANS];     //  8 *    4 =    32 , 0x0020
3478c2ecf20Sopenharmony_ci  cell_buf    inittxbufs[TX_CHANS];   // these are really
3488c2ecf20Sopenharmony_ci  cell_buf    bufn1[BUFN1_SIZE];      // part of this pool
3498c2ecf20Sopenharmony_ci  cell_buf    txfreebufstart;
3508c2ecf20Sopenharmony_ci  cell_buf    txfreebufend;
3518c2ecf20Sopenharmony_ci  cell_buf    rxfreebufstart;
3528c2ecf20Sopenharmony_ci  cell_buf    rxfreebufend;           // 8+118+1+1+1+1+124 = 254
3538c2ecf20Sopenharmony_ci  cell_buf    bufn2[BUFN2_SIZE];      // 16 *  254 =  4064 , 0x1000
3548c2ecf20Sopenharmony_ci  rx_q_entry  rx_q_entries[RX_QS];    //  1 * 1024 =  1024 , 0x1400
3558c2ecf20Sopenharmony_ci  cell_buf    bufn3[BUFN3_SIZE];      // 16 *  192 =  3072 , 0x2000
3568c2ecf20Sopenharmony_ci  rx_ch_desc  rx_descs[MAX_VCS];      //  2 * 1024 =  2048 , 0x2800
3578c2ecf20Sopenharmony_ci  cell_buf    bufn4[BUFN4_SIZE];      // 16 * 1408 = 22528 , 0x8000
3588c2ecf20Sopenharmony_ci} MEMMAP;
3598c2ecf20Sopenharmony_ci
3608c2ecf20Sopenharmony_ci#define memmap ((MEMMAP *)0)
3618c2ecf20Sopenharmony_ci
3628c2ecf20Sopenharmony_ci/* end horizon specific bits */
3638c2ecf20Sopenharmony_ci
3648c2ecf20Sopenharmony_citypedef enum {
3658c2ecf20Sopenharmony_ci  aal0,
3668c2ecf20Sopenharmony_ci  aal34,
3678c2ecf20Sopenharmony_ci  aal5
3688c2ecf20Sopenharmony_ci} hrz_aal;
3698c2ecf20Sopenharmony_ci
3708c2ecf20Sopenharmony_citypedef enum {
3718c2ecf20Sopenharmony_ci  tx_busy,
3728c2ecf20Sopenharmony_ci  rx_busy,
3738c2ecf20Sopenharmony_ci  ultra
3748c2ecf20Sopenharmony_ci} hrz_flags;
3758c2ecf20Sopenharmony_ci
3768c2ecf20Sopenharmony_ci// a single struct pointed to by atm_vcc->dev_data
3778c2ecf20Sopenharmony_ci
3788c2ecf20Sopenharmony_citypedef struct {
3798c2ecf20Sopenharmony_ci  unsigned int        tx_rate;
3808c2ecf20Sopenharmony_ci  unsigned int        rx_rate;
3818c2ecf20Sopenharmony_ci  u16                 channel;
3828c2ecf20Sopenharmony_ci  u16                 tx_xbr_bits;
3838c2ecf20Sopenharmony_ci  u16                 tx_pcr_bits;
3848c2ecf20Sopenharmony_ci#if 0
3858c2ecf20Sopenharmony_ci  u16                 tx_scr_bits;
3868c2ecf20Sopenharmony_ci  u16                 tx_bucket_bits;
3878c2ecf20Sopenharmony_ci#endif
3888c2ecf20Sopenharmony_ci  hrz_aal             aal;
3898c2ecf20Sopenharmony_ci} hrz_vcc;
3908c2ecf20Sopenharmony_ci
3918c2ecf20Sopenharmony_cistruct hrz_dev {
3928c2ecf20Sopenharmony_ci
3938c2ecf20Sopenharmony_ci  u32                 iobase;
3948c2ecf20Sopenharmony_ci  u32 *               membase;
3958c2ecf20Sopenharmony_ci
3968c2ecf20Sopenharmony_ci  struct sk_buff *    rx_skb;     // skb being RXed
3978c2ecf20Sopenharmony_ci  unsigned int        rx_bytes;   // bytes remaining to RX within region
3988c2ecf20Sopenharmony_ci  void *              rx_addr;    // addr to send bytes to (for PIO)
3998c2ecf20Sopenharmony_ci  unsigned int        rx_channel; // channel that the skb is going out on
4008c2ecf20Sopenharmony_ci
4018c2ecf20Sopenharmony_ci  struct sk_buff *    tx_skb;     // skb being TXed
4028c2ecf20Sopenharmony_ci  unsigned int        tx_bytes;   // bytes remaining to TX within region
4038c2ecf20Sopenharmony_ci  void *              tx_addr;    // addr to send bytes from (for PIO)
4048c2ecf20Sopenharmony_ci  struct iovec *      tx_iovec;   // remaining regions
4058c2ecf20Sopenharmony_ci  unsigned int        tx_regions; // number of remaining regions
4068c2ecf20Sopenharmony_ci
4078c2ecf20Sopenharmony_ci  spinlock_t          mem_lock;
4088c2ecf20Sopenharmony_ci  wait_queue_head_t   tx_queue;
4098c2ecf20Sopenharmony_ci
4108c2ecf20Sopenharmony_ci  u8                  irq;
4118c2ecf20Sopenharmony_ci  unsigned long	      flags;
4128c2ecf20Sopenharmony_ci  u8                  tx_last;
4138c2ecf20Sopenharmony_ci  u8                  tx_idle;
4148c2ecf20Sopenharmony_ci
4158c2ecf20Sopenharmony_ci  rx_q_entry *        rx_q_reset;
4168c2ecf20Sopenharmony_ci  rx_q_entry *        rx_q_entry;
4178c2ecf20Sopenharmony_ci  rx_q_entry *        rx_q_wrap;
4188c2ecf20Sopenharmony_ci
4198c2ecf20Sopenharmony_ci  struct atm_dev *    atm_dev;
4208c2ecf20Sopenharmony_ci
4218c2ecf20Sopenharmony_ci  u32                 last_vc;
4228c2ecf20Sopenharmony_ci
4238c2ecf20Sopenharmony_ci  int                 noof_spare_buffers;
4248c2ecf20Sopenharmony_ci  u16                 spare_buffers[SPARE_BUFFER_POOL_SIZE];
4258c2ecf20Sopenharmony_ci
4268c2ecf20Sopenharmony_ci  u16                 tx_channel_record[TX_CHANS];
4278c2ecf20Sopenharmony_ci
4288c2ecf20Sopenharmony_ci  // this is what we follow when we get incoming data
4298c2ecf20Sopenharmony_ci  u32              txer[MAX_VCS/32];
4308c2ecf20Sopenharmony_ci  struct atm_vcc * rxer[MAX_VCS];
4318c2ecf20Sopenharmony_ci
4328c2ecf20Sopenharmony_ci  // cell rate allocation
4338c2ecf20Sopenharmony_ci  spinlock_t       rate_lock;
4348c2ecf20Sopenharmony_ci  unsigned int     rx_avail;
4358c2ecf20Sopenharmony_ci  unsigned int     tx_avail;
4368c2ecf20Sopenharmony_ci
4378c2ecf20Sopenharmony_ci  // dev stats
4388c2ecf20Sopenharmony_ci  unsigned long    tx_cell_count;
4398c2ecf20Sopenharmony_ci  unsigned long    rx_cell_count;
4408c2ecf20Sopenharmony_ci  unsigned long    hec_error_count;
4418c2ecf20Sopenharmony_ci  unsigned long    unassigned_cell_count;
4428c2ecf20Sopenharmony_ci
4438c2ecf20Sopenharmony_ci  struct pci_dev * pci_dev;
4448c2ecf20Sopenharmony_ci  struct timer_list housekeeping;
4458c2ecf20Sopenharmony_ci};
4468c2ecf20Sopenharmony_ci
4478c2ecf20Sopenharmony_citypedef struct hrz_dev hrz_dev;
4488c2ecf20Sopenharmony_ci
4498c2ecf20Sopenharmony_ci/* macros for use later */
4508c2ecf20Sopenharmony_ci
4518c2ecf20Sopenharmony_ci#define BUF_PTR(cbptr) ((cbptr) - (cell_buf *) 0)
4528c2ecf20Sopenharmony_ci
4538c2ecf20Sopenharmony_ci#define INTERESTING_INTERRUPTS \
4548c2ecf20Sopenharmony_ci  (RX_DATA_AV | RX_DISABLED | TX_BUS_MASTER_COMPLETE | RX_BUS_MASTER_COMPLETE)
4558c2ecf20Sopenharmony_ci
4568c2ecf20Sopenharmony_ci// 190 cells by default (192 TX buffers - 2 elbow room, see docs)
4578c2ecf20Sopenharmony_ci#define TX_AAL5_LIMIT (190*ATM_CELL_PAYLOAD-ATM_AAL5_TRAILER) // 9112
4588c2ecf20Sopenharmony_ci
4598c2ecf20Sopenharmony_ci// Have enough RX buffers (unless we allow other buffer splits)
4608c2ecf20Sopenharmony_ci#define RX_AAL5_LIMIT ATM_MAX_AAL5_PDU
4618c2ecf20Sopenharmony_ci
4628c2ecf20Sopenharmony_ci/* multi-statement macro protector */
4638c2ecf20Sopenharmony_ci#define DW(x) do{ x } while(0)
4648c2ecf20Sopenharmony_ci
4658c2ecf20Sopenharmony_ci#define HRZ_DEV(atm_dev) ((hrz_dev *) (atm_dev)->dev_data)
4668c2ecf20Sopenharmony_ci#define HRZ_VCC(atm_vcc) ((hrz_vcc *) (atm_vcc)->dev_data)
4678c2ecf20Sopenharmony_ci
4688c2ecf20Sopenharmony_ci/* Turn the LEDs on and off                                                 */
4698c2ecf20Sopenharmony_ci// The LEDs bits are upside down in that setting the bit in the debug
4708c2ecf20Sopenharmony_ci// register will turn the appropriate LED off.
4718c2ecf20Sopenharmony_ci
4728c2ecf20Sopenharmony_ci#define YELLOW_LED    DEBUG_BIT_0
4738c2ecf20Sopenharmony_ci#define GREEN_LED     DEBUG_BIT_1
4748c2ecf20Sopenharmony_ci#define YELLOW_LED_OE DEBUG_BIT_0_OE
4758c2ecf20Sopenharmony_ci#define GREEN_LED_OE  DEBUG_BIT_1_OE
4768c2ecf20Sopenharmony_ci
4778c2ecf20Sopenharmony_ci#define GREEN_LED_OFF(dev)                      \
4788c2ecf20Sopenharmony_ci  wr_regl (dev, CONTROL_0_REG, rd_regl (dev, CONTROL_0_REG) | GREEN_LED)
4798c2ecf20Sopenharmony_ci#define GREEN_LED_ON(dev)                       \
4808c2ecf20Sopenharmony_ci  wr_regl (dev, CONTROL_0_REG, rd_regl (dev, CONTROL_0_REG) &~ GREEN_LED)
4818c2ecf20Sopenharmony_ci#define YELLOW_LED_OFF(dev)                     \
4828c2ecf20Sopenharmony_ci  wr_regl (dev, CONTROL_0_REG, rd_regl (dev, CONTROL_0_REG) | YELLOW_LED)
4838c2ecf20Sopenharmony_ci#define YELLOW_LED_ON(dev)                      \
4848c2ecf20Sopenharmony_ci  wr_regl (dev, CONTROL_0_REG, rd_regl (dev, CONTROL_0_REG) &~ YELLOW_LED)
4858c2ecf20Sopenharmony_ci
4868c2ecf20Sopenharmony_citypedef enum {
4878c2ecf20Sopenharmony_ci  round_up,
4888c2ecf20Sopenharmony_ci  round_down,
4898c2ecf20Sopenharmony_ci  round_nearest
4908c2ecf20Sopenharmony_ci} rounding;
4918c2ecf20Sopenharmony_ci
4928c2ecf20Sopenharmony_ci#endif /* DRIVER_ATM_HORIZON_H */
493