summaryrefslogtreecommitdiff
path: root/drivers/e24/starfive_e24_hw.h
blob: 2beea192761eb1d5afca6e4bd593e85087f56fcd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __STARFIVE_E24_HW_H__
#define __STARFIVE_E24_HW_H__
/*
 * Hardware-specific operation entry points.
 */
struct e24_hw_ops {
	/*
	 * Gets the clock for E24.
	 */
	int (*init)(void *hw_arg);
	/*
	 * Enable power/clock, but keep the core stalled.
	 */
	int (*enable)(void *hw_arg);
	/*
	 * Diable power/clock.
	 */
	void (*disable)(void *hw_arg);
	/*
	 * Reset the core.
	 */
	void (*reset)(void *hw_arg);
	/*
	 * Unstall the core.
	 */
	void (*release)(void *hw_arg);
	/*
	 * Stall the core.
	 */
	void (*halt)(void *hw_arg);

	/* Get HW-specific data to pass to the DSP on synchronization
	 *
	 *  param hw_arg: opaque parameter passed to DSP at initialization
	 *  param sz: return size of sync data here
	 *  return a buffer allocated with kmalloc that the caller will free
	 */
	void *(*get_hw_sync_data)(void *hw_arg, size_t *sz);

	/*
	 * Send IRQ to the core.
	 */
	void (*send_irq)(void *hw_arg);

	/*
	 * Check whether region of physical memory may be handled by
	 * dma_sync_* operations
	 *
	 * \param hw_arg: opaque parameter passed to DSP at initialization
	 *                time
	 */
	bool (*cacheable)(void *hw_arg, unsigned long pfn, unsigned long n_pages);
	/*
	 * Synchronize region of memory for DSP access.
	 *
	 * \param hw_arg: opaque parameter passed to DSP at initialization
	 *                time
	 */
	void (*dma_sync_for_device)(void *hw_arg,
				    void *vaddr, phys_addr_t paddr,
				    unsigned long sz, unsigned int flags);
	/*
	 * Synchronize region of memory for host access.
	 *
	 * \param hw_arg: opaque parameter passed to DSP at initialization
	 *                time
	 */
	void (*dma_sync_for_cpu)(void *hw_arg,
				 void *vaddr, phys_addr_t paddr,
				 unsigned long sz, unsigned int flags);

	/*
	 * memcpy data/code to device-specific memory.
	 */
	void (*memcpy_tohw)(void __iomem *dst, const void *src, size_t sz);
	/*
	 * memset device-specific memory.
	 */
	void (*memset_hw)(void __iomem *dst, int c, size_t sz);

	/*
	 * Check DSP status.
	 *
	 * \param hw_arg: opaque parameter passed to DSP at initialization
	 *                time
	 * \return whether the core has crashed and needs to be restarted
	 */
	bool (*panic_check)(void *hw_arg);
};

long e24_init_hw(struct platform_device *pdev, void *hw_arg);
struct e24_hw_ops *e24_get_hw_ops(void);
#endif