brintos

brintos / linux-shallow public Read only

0
0
Text · 1.1 KiB · e5052d9 Raw
53 lines · c
1// SPDX-License-Identifier: GPL-2.02/* ICSSG Buffer queue helpers3 *4 * Copyright (C) 2021 Texas Instruments Incorporated - https://www.ti.com5 */6 7#include <linux/regmap.h>8#include "icssg_prueth.h"9 10#define ICSSG_QUEUES_MAX		6411#define ICSSG_QUEUE_OFFSET		0xd0012#define ICSSG_QUEUE_PEEK_OFFSET		0xe0013#define ICSSG_QUEUE_CNT_OFFSET		0xe4014#define	ICSSG_QUEUE_RESET_OFFSET	0xf4015 16int icssg_queue_pop(struct prueth *prueth, u8 queue)17{18	u32 val, cnt;19 20	if (queue >= ICSSG_QUEUES_MAX)21		return -EINVAL;22 23	regmap_read(prueth->miig_rt, ICSSG_QUEUE_CNT_OFFSET + 4 * queue, &cnt);24	if (!cnt)25		return -EINVAL;26 27	regmap_read(prueth->miig_rt, ICSSG_QUEUE_OFFSET + 4 * queue, &val);28 29	return val;30}31EXPORT_SYMBOL_GPL(icssg_queue_pop);32 33void icssg_queue_push(struct prueth *prueth, int queue, u16 addr)34{35	if (queue >= ICSSG_QUEUES_MAX)36		return;37 38	regmap_write(prueth->miig_rt, ICSSG_QUEUE_OFFSET + 4 * queue, addr);39}40EXPORT_SYMBOL_GPL(icssg_queue_push);41 42u32 icssg_queue_level(struct prueth *prueth, int queue)43{44	u32 reg;45 46	if (queue >= ICSSG_QUEUES_MAX)47		return 0;48 49	regmap_read(prueth->miig_rt, ICSSG_QUEUE_CNT_OFFSET + 4 * queue, &reg);50 51	return reg;52}53