Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) #ifndef _SPARC64_LDC_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #define _SPARC64_LDC_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #include <asm/hypervisor.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) extern int ldom_domaining_enabled;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) void ldom_set_var(const char *var, const char *value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) void ldom_reboot(const char *boot_command);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) void ldom_power_off(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) /* The event handler will be evoked when link state changes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  * or data becomes available on the receive side.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  * For non-RAW links, if the LDC_EVENT_RESET event arrives the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  * driver should reset all of it's internal state and reinvoke
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  * ldc_connect() to try and bring the link up again.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  * For RAW links, ldc_connect() is not used.  Instead the driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * just waits for the LDC_EVENT_UP event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) struct ldc_channel_config {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	void (*event)(void *arg, int event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	u32			mtu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	unsigned int		rx_irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	unsigned int		tx_irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	u8			mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #define LDC_MODE_RAW		0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #define LDC_MODE_UNRELIABLE	0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #define LDC_MODE_RESERVED	0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #define LDC_MODE_STREAM		0x03
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	u8			debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #define LDC_DEBUG_HS		0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #define LDC_DEBUG_STATE		0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #define LDC_DEBUG_RX		0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #define LDC_DEBUG_TX		0x08
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #define LDC_DEBUG_DATA		0x10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #define LDC_EVENT_RESET		0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #define LDC_EVENT_UP		0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #define LDC_EVENT_DATA_READY	0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #define LDC_STATE_INVALID	0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) #define LDC_STATE_INIT		0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #define LDC_STATE_BOUND		0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) #define LDC_STATE_READY		0x03
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #define LDC_STATE_CONNECTED	0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) #define	LDC_PACKET_SIZE		64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) struct ldc_channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) /* Allocate state for a channel.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) struct ldc_channel *ldc_alloc(unsigned long id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 			      const struct ldc_channel_config *cfgp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 			      void *event_arg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 			      const char *name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) /* Shut down and free state for a channel.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) void ldc_free(struct ldc_channel *lp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) /* Register TX and RX queues of the link with the hypervisor.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) int ldc_bind(struct ldc_channel *lp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) void ldc_unbind(struct ldc_channel *lp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) /* For non-RAW protocols we need to complete a handshake before
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  * communication can proceed.  ldc_connect() does that, if the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  * handshake completes successfully, an LDC_EVENT_UP event will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  * be sent up to the driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) int ldc_connect(struct ldc_channel *lp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) int ldc_disconnect(struct ldc_channel *lp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) int ldc_state(struct ldc_channel *lp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) void ldc_set_state(struct ldc_channel *lp, u8 state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) int ldc_mode(struct ldc_channel *lp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) void __ldc_print(struct ldc_channel *lp, const char *caller);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) int ldc_rx_reset(struct ldc_channel *lp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) #define	ldc_print(chan)	__ldc_print(chan, __func__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) /* Read and write operations.  Only valid when the link is up.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) int ldc_write(struct ldc_channel *lp, const void *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	      unsigned int size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) int ldc_read(struct ldc_channel *lp, void *buf, unsigned int size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) #define LDC_MAP_SHADOW	0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) #define LDC_MAP_DIRECT	0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) #define LDC_MAP_IO	0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) #define LDC_MAP_R	0x08
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) #define LDC_MAP_W	0x10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) #define LDC_MAP_X	0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) #define LDC_MAP_RW	(LDC_MAP_R | LDC_MAP_W)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) #define LDC_MAP_RWX	(LDC_MAP_R | LDC_MAP_W | LDC_MAP_X)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) #define LDC_MAP_ALL	0x03f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) struct ldc_trans_cookie {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	u64			cookie_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	u64			cookie_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) struct scatterlist;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) int ldc_map_sg(struct ldc_channel *lp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	       struct scatterlist *sg, int num_sg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	       struct ldc_trans_cookie *cookies, int ncookies,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	       unsigned int map_perm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) int ldc_map_single(struct ldc_channel *lp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		   void *buf, unsigned int len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 		   struct ldc_trans_cookie *cookies, int ncookies,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		   unsigned int map_perm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) void ldc_unmap(struct ldc_channel *lp, struct ldc_trans_cookie *cookies,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	       int ncookies);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) int ldc_copy(struct ldc_channel *lp, int copy_dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	     void *buf, unsigned int len, unsigned long offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	     struct ldc_trans_cookie *cookies, int ncookies);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) static inline int ldc_get_dring_entry(struct ldc_channel *lp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 				      void *buf, unsigned int len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 				      unsigned long offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 				      struct ldc_trans_cookie *cookies,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 				      int ncookies)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	return ldc_copy(lp, LDC_COPY_IN, buf, len, offset, cookies, ncookies);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) static inline int ldc_put_dring_entry(struct ldc_channel *lp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 				      void *buf, unsigned int len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 				      unsigned long offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 				      struct ldc_trans_cookie *cookies,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 				      int ncookies)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	return ldc_copy(lp, LDC_COPY_OUT, buf, len, offset, cookies, ncookies);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) void *ldc_alloc_exp_dring(struct ldc_channel *lp, unsigned int len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 			  struct ldc_trans_cookie *cookies,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 			  int *ncookies, unsigned int map_perm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) void ldc_free_exp_dring(struct ldc_channel *lp, void *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		        unsigned int len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 		        struct ldc_trans_cookie *cookies, int ncookies);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) #endif /* _SPARC64_LDC_H */