linux/include/linux/soc/ixp4xx/qmgr.h

/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (C) 2007 Krzysztof Halasa <[email protected]>
 */

#ifndef IXP4XX_QMGR_H
#define IXP4XX_QMGR_H

#include <linux/io.h>
#include <linux/kernel.h>

#define DEBUG_QMGR

#define HALF_QUEUES
#define QUEUES
#define MAX_QUEUE_LENGTH

#define QUEUE_STAT1_EMPTY
#define QUEUE_STAT1_NEARLY_EMPTY
#define QUEUE_STAT1_NEARLY_FULL
#define QUEUE_STAT1_FULL
#define QUEUE_STAT2_UNDERFLOW
#define QUEUE_STAT2_OVERFLOW

#define QUEUE_WATERMARK_0_ENTRIES
#define QUEUE_WATERMARK_1_ENTRY
#define QUEUE_WATERMARK_2_ENTRIES
#define QUEUE_WATERMARK_4_ENTRIES
#define QUEUE_WATERMARK_8_ENTRIES
#define QUEUE_WATERMARK_16_ENTRIES
#define QUEUE_WATERMARK_32_ENTRIES
#define QUEUE_WATERMARK_64_ENTRIES

/* queue interrupt request conditions */
#define QUEUE_IRQ_SRC_EMPTY
#define QUEUE_IRQ_SRC_NEARLY_EMPTY
#define QUEUE_IRQ_SRC_NEARLY_FULL
#define QUEUE_IRQ_SRC_FULL
#define QUEUE_IRQ_SRC_NOT_EMPTY
#define QUEUE_IRQ_SRC_NOT_NEARLY_EMPTY
#define QUEUE_IRQ_SRC_NOT_NEARLY_FULL
#define QUEUE_IRQ_SRC_NOT_FULL

struct qmgr_regs {};

void qmgr_put_entry(unsigned int queue, u32 val);
u32 qmgr_get_entry(unsigned int queue);
int qmgr_stat_empty(unsigned int queue);
int qmgr_stat_below_low_watermark(unsigned int queue);
int qmgr_stat_full(unsigned int queue);
int qmgr_stat_overflow(unsigned int queue);
void qmgr_release_queue(unsigned int queue);
void qmgr_set_irq(unsigned int queue, int src,
		  void (*handler)(void *pdev), void *pdev);
void qmgr_enable_irq(unsigned int queue);
void qmgr_disable_irq(unsigned int queue);

/* request_ and release_queue() must be called from non-IRQ context */

#if DEBUG_QMGR
extern char qmgr_queue_descs[QUEUES][32];

int qmgr_request_queue(unsigned int queue, unsigned int len /* dwords */,
		       unsigned int nearly_empty_watermark,
		       unsigned int nearly_full_watermark,
		       const char *desc_format, const char* name);
#else
int __qmgr_request_queue(unsigned int queue, unsigned int len /* dwords */,
			 unsigned int nearly_empty_watermark,
			 unsigned int nearly_full_watermark);
#define qmgr_request_queue(queue, len, nearly_empty_watermark,		\
			   nearly_full_watermark, desc_format, name)
#endif

#endif