1 // SPDX-License-Identifier: GPL-2.0
2 /* ICSSG Buffer queue helpers
4 * Copyright (C) 2021 Texas Instruments Incorporated - https://www.ti.com
7 #include <linux/regmap.h>
8 #include "icssg_prueth.h"
10 #define ICSSG_QUEUES_MAX 64
11 #define ICSSG_QUEUE_OFFSET 0xd00
12 #define ICSSG_QUEUE_PEEK_OFFSET 0xe00
13 #define ICSSG_QUEUE_CNT_OFFSET 0xe40
14 #define ICSSG_QUEUE_RESET_OFFSET 0xf40
16 int icssg_queue_pop(struct prueth
*prueth
, u8 queue
)
20 if (queue
>= ICSSG_QUEUES_MAX
)
23 regmap_read(prueth
->miig_rt
, ICSSG_QUEUE_CNT_OFFSET
+ 4 * queue
, &cnt
);
27 regmap_read(prueth
->miig_rt
, ICSSG_QUEUE_OFFSET
+ 4 * queue
, &val
);
31 EXPORT_SYMBOL_GPL(icssg_queue_pop
);
33 void icssg_queue_push(struct prueth
*prueth
, int queue
, u16 addr
)
35 if (queue
>= ICSSG_QUEUES_MAX
)
38 regmap_write(prueth
->miig_rt
, ICSSG_QUEUE_OFFSET
+ 4 * queue
, addr
);
40 EXPORT_SYMBOL_GPL(icssg_queue_push
);
42 u32
icssg_queue_level(struct prueth
*prueth
, int queue
)
46 if (queue
>= ICSSG_QUEUES_MAX
)
49 regmap_read(prueth
->miig_rt
, ICSSG_QUEUE_CNT_OFFSET
+ 4 * queue
, ®
);