/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * drivers/net/ethernet/ibm/emac/mal.h * * Memory Access Layer (MAL) support * * Copyright 2007 Benjamin Herrenschmidt, IBM Corp. * <benh@kernel.crashing.org> * * Based on the arch/ppc version of the driver: * * Copyright (c) 2004, 2005 Zultys Technologies. * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> * * Based on original work by * Armin Kuster <akuster@mvista.com> * Copyright 2002 MontaVista Softare Inc.
*/ #ifndef __IBM_NEWEMAC_MAL_H #define __IBM_NEWEMAC_MAL_H
/* * There are some variations on the MAL, we express them in this driver as * MAL Version 1 and 2 though that doesn't match any IBM terminology. * * We call MAL 1 the version in 405GP, 405GPR, 405EP, 440EP, 440GR and * NP405H. * * We call MAL 2 the version in 440GP, 440GX, 440SP, 440SPE and Axon * * The driver expects a "version" property in the emac node containing * a number 1 or 2. New device-trees for EMAC capable platforms are thus * required to include that when porting to arch/powerpc.
*/
/* In reality MAL can handle TX buffers up to 4095 bytes long, * but this isn't a good round number :) --ebs
*/ #define MAL_MAX_TX_SIZE 4080 #define MAL_MAX_RX_SIZE 4080
staticinlineint mal_rx_size(int len)
{
len = (len + 0xf) & ~0xf; return len > MAL_MAX_RX_SIZE ? MAL_MAX_RX_SIZE : len;
}
/* MAL Buffer Descriptor structure */ struct mal_descriptor {
u16 ctrl; /* MAL / Commac status control bits */
u16 data_len; /* Max length is 4K-1 (12 bits) */
u32 data_ptr; /* pointer to actual data buffer */
};
/* the following defines are for the MadMAL status and control registers. */ /* MADMAL transmit and receive status/control bits */ #define MAL_RX_CTRL_EMPTY 0x8000 #define MAL_RX_CTRL_WRAP 0x4000 #define MAL_RX_CTRL_CM 0x2000 #define MAL_RX_CTRL_LAST 0x1000 #define MAL_RX_CTRL_FIRST 0x0800 #define MAL_RX_CTRL_INTR 0x0400 #define MAL_RX_CTRL_SINGLE (MAL_RX_CTRL_LAST | MAL_RX_CTRL_FIRST) #define MAL_IS_SINGLE_RX(ctrl) (((ctrl) & MAL_RX_CTRL_SINGLE) == MAL_RX_CTRL_SINGLE)
struct mal_instance { int version;
dcr_host_t dcr_host;
int num_tx_chans; /* Number of TX channels */ int num_rx_chans; /* Number of RX channels */ int txeob_irq; /* TX End Of Buffer IRQ */ int rxeob_irq; /* RX End Of Buffer IRQ */ int txde_irq; /* TX Descriptor Error IRQ */ int rxde_irq; /* RX Descriptor Error IRQ */ int serr_irq; /* MAL System Error IRQ */
/* Set if you have interrupt coalescing and you have to clear the SDR * register for TXEOB and RXEOB interrupts to work
*/ #define MAL_FTR_CLEAR_ICINTSTAT 0x00000001
/* Set if your MAL has SERR, TXDE, and RXDE OR'd into a single UIC * interrupt
*/ #define MAL_FTR_COMMON_ERR_INT 0x00000002
/* Register MAL devices */ int mal_init(void); void mal_exit(void);
int mal_register_commac(struct mal_instance *mal, struct mal_commac *commac); void mal_unregister_commac(struct mal_instance *mal, struct mal_commac *commac); int mal_set_rcbs(struct mal_instance *mal, int channel, unsignedlong size);
/* Returns BD ring offset for a particular channel (in 'struct mal_descriptor' elements)
*/ int mal_tx_bd_offset(struct mal_instance *mal, int channel); int mal_rx_bd_offset(struct mal_instance *mal, int channel);
void mal_enable_tx_channel(struct mal_instance *mal, int channel); void mal_disable_tx_channel(struct mal_instance *mal, int channel); void mal_enable_rx_channel(struct mal_instance *mal, int channel); void mal_disable_rx_channel(struct mal_instance *mal, int channel);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.