5 void mps_fifo_init(struct mps_fifo
*fifo
, void __iomem
*base
,
6 void __iomem
*head_addr
, void __iomem
*tail_addr
, uint32_t size
)
9 fifo
->head_addr
= head_addr
;
10 fifo
->tail_addr
= tail_addr
;
15 void mps_fifo_in(struct mps_fifo
*fifo
, const uint32_t *from
, size_t len
)
17 uint32_t head
= __raw_readl(fifo
->head_addr
);
18 void __iomem
*base
= fifo
->base
+ head
;
20 size_t byte_len
= len
* 4;
22 if (head
< byte_len
) {
23 for(; i
<= head
/ 4; ++i
) {
24 __raw_writel(from
[i
], base
);
33 __raw_writel(from
[i
], base
);
38 __raw_writel(head
, fifo
->head_addr
);
41 EXPORT_SYMBOL_GPL(mps_fifo_in
);
43 void mps_fifo_out(struct mps_fifo
*fifo
, uint32_t *to
, size_t len
)
45 uint32_t tail
= __raw_readl(fifo
->tail_addr
);
46 void __iomem
*base
= fifo
->base
+ tail
;
48 size_t byte_len
= len
* 4;
50 if (tail
< byte_len
) {
51 for(; i
<= tail
/ 4; ++i
) {
52 to
[i
] = __raw_readl(base
);
61 to
[i
] = __raw_readl(base
);
66 __raw_writel(tail
, fifo
->tail_addr
);
68 EXPORT_SYMBOL_GPL(mps_fifo_out
);
70 uint32_t mps_fifo_peek(struct mps_fifo
*fifo
)
72 uint32_t tail
= __raw_readl(fifo
->tail_addr
);
73 void __iomem
*base
= fifo
->base
+ tail
;
74 return __raw_readl(base
);
77 void mps_fifo_reset(struct mps_fifo
*fifo
)
79 void __iomem
*base
= fifo
->base
+ fifo
->size
- 4;
82 __raw_writel(fifo
->size
- 4, fifo
->head_addr
);
83 __raw_writel(fifo
->size
- 4, fifo
->tail_addr
);
85 for(i
= 0; i
< 16; ++i
) {
86 __raw_writel(0x0, base
);
91 size_t mps_fifo_len(struct mps_fifo
*fifo
)
93 uint32_t head
= __raw_readl(fifo
->head_addr
);
94 uint32_t tail
= __raw_readl(fifo
->tail_addr
);
99 return fifo
->size
- (tail
- head
);
101 EXPORT_SYMBOL_GPL(mps_fifo_len
);
This page took 0.046966 seconds and 5 git commands to generate.