1ff9112dfSStefan Roese /* 2ff9112dfSStefan Roese * Copyright (C) Marvell International Ltd. and its affiliates 3ff9112dfSStefan Roese * 4ff9112dfSStefan Roese * SPDX-License-Identifier: GPL-2.0 5ff9112dfSStefan Roese */ 6ff9112dfSStefan Roese 7ff9112dfSStefan Roese #ifndef __XOR_H 8ff9112dfSStefan Roese #define __XOR_H 9ff9112dfSStefan Roese 10ff9112dfSStefan Roese #include "ddr3_hw_training.h" 11ff9112dfSStefan Roese 12ff9112dfSStefan Roese #define MV_XOR_MAX_CHAN 4 /* total channels for all units together */ 13ff9112dfSStefan Roese 14ff9112dfSStefan Roese /* 15ff9112dfSStefan Roese * This enumerator describes the type of functionality the XOR channel 16ff9112dfSStefan Roese * can have while using the same data structures. 17ff9112dfSStefan Roese */ 18ff9112dfSStefan Roese enum xor_type { 19ff9112dfSStefan Roese MV_XOR, /* XOR channel functions as XOR accelerator */ 20ff9112dfSStefan Roese MV_DMA, /* XOR channel functions as IDMA channel */ 21ff9112dfSStefan Roese MV_CRC32 /* XOR channel functions as CRC 32 calculator */ 22ff9112dfSStefan Roese }; 23ff9112dfSStefan Roese 24ff9112dfSStefan Roese /* 25ff9112dfSStefan Roese * This enumerator describes the set of commands that can be applied on 26ff9112dfSStefan Roese * an engine (e.g. IDMA, XOR). Appling a comman depends on the current 27ff9112dfSStefan Roese * status (see MV_STATE enumerator) 28ff9112dfSStefan Roese * Start can be applied only when status is IDLE 29ff9112dfSStefan Roese * Stop can be applied only when status is IDLE, ACTIVE or PAUSED 30ff9112dfSStefan Roese * Pause can be applied only when status is ACTIVE 31ff9112dfSStefan Roese * Restart can be applied only when status is PAUSED 32ff9112dfSStefan Roese */ 33ff9112dfSStefan Roese enum mv_command { 34ff9112dfSStefan Roese MV_START, /* Start */ 35ff9112dfSStefan Roese MV_STOP, /* Stop */ 36ff9112dfSStefan Roese MV_PAUSE, /* Pause */ 37ff9112dfSStefan Roese MV_RESTART /* Restart */ 38ff9112dfSStefan Roese }; 39ff9112dfSStefan Roese 40ff9112dfSStefan Roese /* 41ff9112dfSStefan Roese * This enumerator describes the set of state conditions. 42ff9112dfSStefan Roese * Moving from one state to other is stricted. 43ff9112dfSStefan Roese */ 44ff9112dfSStefan Roese enum mv_state { 45ff9112dfSStefan Roese MV_IDLE, 46ff9112dfSStefan Roese MV_ACTIVE, 47ff9112dfSStefan Roese MV_PAUSED, 48ff9112dfSStefan Roese MV_UNDEFINED_STATE 49ff9112dfSStefan Roese }; 50ff9112dfSStefan Roese 51ff9112dfSStefan Roese /* XOR descriptor structure for CRC and DMA descriptor */ 52ff9112dfSStefan Roese struct crc_dma_desc { 53ff9112dfSStefan Roese u32 status; /* Successful descriptor execution indication */ 54ff9112dfSStefan Roese u32 crc32_result; /* Result of CRC-32 calculation */ 55ff9112dfSStefan Roese u32 desc_cmd; /* type of operation to be carried out on the data */ 56ff9112dfSStefan Roese u32 next_desc_ptr; /* Next descriptor address pointer */ 57ff9112dfSStefan Roese u32 byte_cnt; /* Size of source block part represented by the descriptor */ 58ff9112dfSStefan Roese u32 dst_addr; /* Destination Block address pointer (not used in CRC32 */ 59ff9112dfSStefan Roese u32 src_addr0; /* Mode: Source Block address pointer */ 60ff9112dfSStefan Roese u32 src_addr1; /* Mode: Source Block address pointer */ 61ff9112dfSStefan Roese } __packed; 62ff9112dfSStefan Roese 63*0ceb2daeSStefan Roese void mv_xor_hal_init(u32 chan_num); 64ff9112dfSStefan Roese int mv_xor_state_get(u32 chan); 65ff9112dfSStefan Roese void mv_sys_xor_init(MV_DRAM_INFO *dram_info); 66ff9112dfSStefan Roese void mv_sys_xor_finish(void); 67ff9112dfSStefan Roese int mv_xor_transfer(u32 chan, int xor_type, u32 xor_chain_ptr); 68ff9112dfSStefan Roese int mv_xor_mem_init(u32 chan, u32 start_ptr, u32 block_size, u32 init_val_high, 69ff9112dfSStefan Roese u32 init_val_low); 70ff9112dfSStefan Roese 71ff9112dfSStefan Roese #endif /* __XOR_H */ 72