devices/ccat/print.c
author Patrick Bruenn <p.bruenn@beckhoff.com>
Wed, 23 Apr 2014 15:20:33 +0200
branchstable-1.5
changeset 2553 b0c2762a1a83
parent 2550 devices/ccat/print-3.4-ethercat.c@7e25950ea941
permissions -rw-r--r--
ccat: use the same file for different driver version
2550
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
     1
/**
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
     2
    Network Driver for Beckhoff CCAT communication controller
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
     3
    Copyright (C) 2014  Beckhoff Automation GmbH
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
     4
    Author: Patrick Bruenn <p.bruenn@beckhoff.com>
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
     5
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
     6
    This program is free software; you can redistribute it and/or modify
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
     7
    it under the terms of the GNU General Public License as published by
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
     8
    the Free Software Foundation; either version 2 of the License, or
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
     9
    (at your option) any later version.
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    10
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    11
    This program is distributed in the hope that it will be useful,
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    14
    GNU General Public License for more details.
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    15
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    16
    You should have received a copy of the GNU General Public License along
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    17
    with this program; if not, write to the Free Software Foundation, Inc.,
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    18
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    19
*/
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    20
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    21
#include <linux/kernel.h>
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    22
#include "CCatDefinitions.h"
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    23
#include "module.h"
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    24
#include "print.h"
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    25
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    26
#define TESTING_ENABLED 1
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    27
void print_mem(const unsigned char *p, size_t lines)
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    28
{
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    29
#if TESTING_ENABLED
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    30
	pr_info("mem at: %p\n", p);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    31
	pr_info(" 0  1  2  3  4  5  6  7   8  9  A  B  C  D  E  F\n");
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    32
	while (lines > 0) {
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    33
		pr_info
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    34
		    ("%02x %02x %02x %02x %02x %02x %02x %02x  %02x %02x %02x %02x %02x %02x %02x %02x\n",
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    35
		     p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9],
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    36
		     p[10], p[11], p[12], p[13], p[14], p[15]);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    37
		p += 16;
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    38
		--lines;
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    39
	}
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    40
#endif /* #if TESTING_ENABLED */
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    41
}
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    42
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    43
static const char *CCatFunctionTypes[CCATINFO_MAX + 1] = {
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    44
	"not used",
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    45
	"Informationblock",
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    46
	"EtherCAT Slave",
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    47
	"EtherCAT Master without DMA",
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    48
	"Ethernet MAC without DMA",
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    49
	"Ethernet Switch",
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    50
	"Sercos III",
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    51
	"Profibus",
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    52
	"CAN Controller",
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    53
	"KBUS Master",
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    54
	"IP-Link Master (planned)",
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    55
	"SPI Master",
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    56
	"I²C",
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    57
	"GPIO",
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    58
	"Drive",
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    59
	"CCAT Update",
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    60
	"Systemtime",
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    61
	"Interrupt Controller",
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    62
	"EEPROM Controller",
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    63
	"DMA Controller",
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    64
	"EtherCAT Master with DMA",
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    65
	"Ethernet MAC with DMA",
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    66
	"SRAM Interface",
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    67
	"Internal Copy block",
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    68
	"unknown"
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    69
};
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    70
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    71
static void print_CCatDmaRxActBuf(const struct ccat_eth_priv *const priv)
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    72
{
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    73
	CCatDmaRxActBuf rx_fifo;
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    74
	memcpy_fromio(&rx_fifo, priv->reg.rx_fifo, sizeof(rx_fifo));
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    75
	pr_debug("Rx FIFO base address: %p\n", priv->reg.rx_fifo);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    76
	pr_debug("     Rx Frame Header start:   0x%08x\n", rx_fifo.startAddr);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    77
	pr_debug("     reserved:                0x%08x\n", rx_fifo.reserved1);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    78
	pr_debug("     Rx start address valid:    %8u\n", rx_fifo.nextValid);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    79
	pr_debug("     reserved:                0x%08x\n", rx_fifo.reserved2);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    80
	pr_debug("     FIFO level:              0x%08x\n", rx_fifo.FifoLevel);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    81
	pr_debug("     Buffer level:            0x%08x\n", rx_fifo.bufferLevel);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    82
	pr_debug("     next address:            0x%08x\n", rx_fifo.nextAddr);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    83
}
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    84
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    85
static void print_CCatDmaTxFifo(const struct ccat_eth_priv *const priv)
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    86
{
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    87
	CCatDmaTxFifo tx_fifo;
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    88
	memcpy_fromio(&tx_fifo, priv->reg.tx_fifo, sizeof(tx_fifo));
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    89
	pr_debug("Tx FIFO base address: %p\n", priv->reg.tx_fifo);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    90
	pr_debug("     Tx Frame Header start:   0x%08x\n", tx_fifo.startAddr);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    91
	pr_debug("     # 64 bit words:          %10d\n", tx_fifo.numQuadWords);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    92
	pr_debug("     reserved:                0x%08x\n", tx_fifo.reserved1);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    93
	pr_debug("     FIFO reset:              0x%08x\n", tx_fifo.fifoReset);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    94
}
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    95
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    96
static void print_CCatInfoBlock(const CCatInfoBlock * info,
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    97
				const void __iomem * const base_addr)
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    98
{
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
    99
	const size_t index = min((int)info->eCCatInfoType, CCATINFO_MAX);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   100
	pr_debug("%s\n", CCatFunctionTypes[index]);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   101
	pr_debug("     revision:     0x%x\n", info->nRevision);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   102
	pr_debug("     RX channel:   %d\n", info->rxDmaChn);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   103
	pr_debug("     TX channel:   %d\n", info->txDmaChn);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   104
	pr_debug("     baseaddr:     0x%x\n", info->nAddr);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   105
	pr_debug("     size:         0x%x\n", info->nSize);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   106
	pr_debug("     subfunction:  %p\n", base_addr);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   107
}
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   108
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   109
static void print_CCatMacRegs(const struct ccat_eth_priv *const priv)
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   110
{
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   111
	CCatMacRegs mac;
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   112
	memcpy_fromio(&mac, priv->reg.mac, sizeof(mac));
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   113
	pr_debug("MAC base address: %p\n", priv->reg.mac);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   114
	pr_debug("     frame length error count:   %10d\n", mac.frameLenErrCnt);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   115
	pr_debug("     RX error count:             %10d\n", mac.rxErrCnt);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   116
	pr_debug("     CRC error count:            %10d\n", mac.crcErrCnt);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   117
	pr_debug("     Link lost error count:      %10d\n", mac.linkLostErrCnt);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   118
	pr_debug("     reserved:                   0x%08x\n", mac.reserved1);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   119
	pr_debug("     RX overflow count:          %10d\n",
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   120
		 mac.dropFrameErrCnt);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   121
	pr_debug("     DMA overflow count:         %10d\n", mac.reserved2[0]);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   122
	//pr_debug("     reserverd:         %10d\n", DRV_NAME, mac.reserved2[1]);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   123
	pr_debug("     TX frame counter:           %10d\n", mac.txFrameCnt);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   124
	pr_debug("     RX frame counter:           %10d\n", mac.rxFrameCnt);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   125
	pr_debug("     TX-FIFO level:              0x%08x\n", mac.txFifoLevel);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   126
	pr_debug("     MII connection:             0x%08x\n", mac.miiConnected);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   127
}
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   128
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   129
static void print_CCatMii(const struct ccat_eth_priv *const priv)
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   130
{
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   131
	CCatMii mii;
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   132
	memcpy_fromio(&mii, priv->reg.mii, sizeof(mii));
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   133
	pr_debug("MII base address: %p\n", priv->reg.mii);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   134
	pr_debug("     MII cycle:    %s\n",
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   135
		 mii.startMiCycle ? "running" : "no cycle");
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   136
	pr_debug("     reserved:     0x%x\n", mii.reserved1);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   137
	pr_debug("     cmd valid:    %s\n", mii.cmdErr ? "no" : "yes");
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   138
	pr_debug("     cmd:          0x%x\n", mii.cmd);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   139
	pr_debug("     reserved:     0x%x\n", mii.reserved2);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   140
	pr_debug("     PHY addr:     0x%x\n", mii.phyAddr);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   141
	pr_debug("     reserved:     0x%x\n", mii.reserved3);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   142
	pr_debug("     PHY reg:      0x%x\n", mii.phyReg);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   143
	pr_debug("     reserved:     0x%x\n", mii.reserved4);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   144
	pr_debug("     PHY write:    0x%x\n", mii.phyWriteData);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   145
	pr_debug("     PHY read:     0x%x\n", mii.phyReadData);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   146
	pr_debug("     MAC addr:     %02x:%02x:%02x:%02x:%02x:%02x\n",
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   147
		 mii.macAddr.b[0], mii.macAddr.b[1], mii.macAddr.b[2],
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   148
		 mii.macAddr.b[3], mii.macAddr.b[4], mii.macAddr.b[5]);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   149
	pr_debug("     MAC filter enable:   %s\n",
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   150
		 mii.macFilterEnabled ? "enabled" : "disabled");
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   151
	pr_debug("     reserved:     0x%x\n", mii.reserved6);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   152
	pr_debug("     Link State:   %s\n",
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   153
		 mii.linkStatus ? "link" : "no link");
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   154
	pr_debug("     reserved:     0x%x\n", mii.reserved7);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   155
	//pr_debug("     reserved:     0x%x\n", DRV_NAME, mii.reserved8);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   156
	//TODO add leds, systemtime insertion and interrupts
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   157
}
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   158
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   159
void ccat_print_function_info(struct ccat_eth_priv *priv)
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   160
{
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   161
	print_CCatInfoBlock(&priv->info, priv->ccatdev->bar[0].ioaddr);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   162
	print_CCatMii(priv);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   163
	print_CCatDmaTxFifo(priv);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   164
	print_CCatDmaRxActBuf(priv);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   165
	print_CCatMacRegs(priv);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   166
	pr_debug("  RX window:    %p\n", priv->reg.rx_mem);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   167
	pr_debug("  TX memory:    %p\n", priv->reg.tx_mem);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   168
	pr_debug("  misc:         %p\n", priv->reg.misc);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   169
}
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   170
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   171
void print_update_info(const CCatInfoBlock * const info,
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   172
		       void __iomem * const ioaddr)
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   173
{
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   174
	const size_t index = min((int)info->eCCatInfoType, CCATINFO_MAX);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   175
	pr_debug("%s\n", CCatFunctionTypes[index]);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   176
	pr_debug("     revision:     0x%x\n", info->nRevision);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   177
	pr_debug("     baseaddr:     0x%x\n", info->nAddr);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   178
	pr_debug("     size:         0x%x\n", info->nSize);
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   179
	pr_debug("     PROM ID is:   0x%x\n", ccat_get_prom_id(ioaddr));
7e25950ea941 replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents: 2549
diff changeset
   180
}