xref: /linux/drivers/net/ethernet/altera/altera_utils.c (revision 75bf465f0bc33e9b776a46d6a1b9b990f5fb7c37)
1*9952f691SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
26c3324a9SVince Bridgers /* Altera TSE SGDMA and MSGDMA Linux driver
36c3324a9SVince Bridgers  * Copyright (C) 2014 Altera Corporation. All rights reserved
46c3324a9SVince Bridgers  */
56c3324a9SVince Bridgers 
66c3324a9SVince Bridgers #include "altera_tse.h"
76c3324a9SVince Bridgers #include "altera_utils.h"
86c3324a9SVince Bridgers 
tse_set_bit(void __iomem * ioaddr,size_t offs,u32 bit_mask)989830580SVince Bridgers void tse_set_bit(void __iomem *ioaddr, size_t offs, u32 bit_mask)
106c3324a9SVince Bridgers {
1189830580SVince Bridgers 	u32 value = csrrd32(ioaddr, offs);
126c3324a9SVince Bridgers 	value |= bit_mask;
1389830580SVince Bridgers 	csrwr32(value, ioaddr, offs);
146c3324a9SVince Bridgers }
156c3324a9SVince Bridgers 
tse_clear_bit(void __iomem * ioaddr,size_t offs,u32 bit_mask)1689830580SVince Bridgers void tse_clear_bit(void __iomem *ioaddr, size_t offs, u32 bit_mask)
176c3324a9SVince Bridgers {
1889830580SVince Bridgers 	u32 value = csrrd32(ioaddr, offs);
196c3324a9SVince Bridgers 	value &= ~bit_mask;
2089830580SVince Bridgers 	csrwr32(value, ioaddr, offs);
216c3324a9SVince Bridgers }
226c3324a9SVince Bridgers 
tse_bit_is_set(void __iomem * ioaddr,size_t offs,u32 bit_mask)2389830580SVince Bridgers int tse_bit_is_set(void __iomem *ioaddr, size_t offs, u32 bit_mask)
246c3324a9SVince Bridgers {
2589830580SVince Bridgers 	u32 value = csrrd32(ioaddr, offs);
266c3324a9SVince Bridgers 	return (value & bit_mask) ? 1 : 0;
276c3324a9SVince Bridgers }
286c3324a9SVince Bridgers 
tse_bit_is_clear(void __iomem * ioaddr,size_t offs,u32 bit_mask)2989830580SVince Bridgers int tse_bit_is_clear(void __iomem *ioaddr, size_t offs, u32 bit_mask)
306c3324a9SVince Bridgers {
3189830580SVince Bridgers 	u32 value = csrrd32(ioaddr, offs);
326c3324a9SVince Bridgers 	return (value & bit_mask) ? 0 : 1;
336c3324a9SVince Bridgers }
34