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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  * Inline routines shareable across OS platforms.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Copyright (c) 1994-2001 Justin T. Gibbs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (c) 2000-2003 Adaptec Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * Redistribution and use in source and binary forms, with or without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * modification, are permitted provided that the following conditions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * are met:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * 1. Redistributions of source code must retain the above copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *    notice, this list of conditions, and the following disclaimer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *    without modification.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  *    substantially similar to the "NO WARRANTY" disclaimer below
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  *    ("Disclaimer") and any redistribution must be conditioned upon
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  *    including a substantially similar Disclaimer requirement for further
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  *    binary redistribution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  * 3. Neither the names of the above-listed copyright holders nor the names
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  *    of any contributors may be used to endorse or promote products derived
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  *    from this software without specific prior written permission.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  * Alternatively, this software may be distributed under the terms of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  * GNU General Public License ("GPL") version 2 as published by the Free
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  * Software Foundation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  * NO WARRANTY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  * POSSIBILITY OF SUCH DAMAGES.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  * $Id: //depot/aic7xxx/aic7xxx/aic79xx_inline.h#59 $
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  * $FreeBSD$
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #ifndef _AIC79XX_INLINE_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #define _AIC79XX_INLINE_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) /******************************** Debugging ***********************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) static inline char *ahd_name(struct ahd_softc *ahd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) static inline char *ahd_name(struct ahd_softc *ahd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	return (ahd->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) /************************ Sequencer Execution Control *************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) static inline void ahd_known_modes(struct ahd_softc *ahd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 				     ahd_mode src, ahd_mode dst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) static inline ahd_mode_state ahd_build_mode_state(struct ahd_softc *ahd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 						    ahd_mode src,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 						    ahd_mode dst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) static inline void ahd_extract_mode_state(struct ahd_softc *ahd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 					    ahd_mode_state state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 					    ahd_mode *src, ahd_mode *dst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) void ahd_set_modes(struct ahd_softc *ahd, ahd_mode src,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		   ahd_mode dst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) ahd_mode_state ahd_save_modes(struct ahd_softc *ahd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) void ahd_restore_modes(struct ahd_softc *ahd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 		       ahd_mode_state state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) int  ahd_is_paused(struct ahd_softc *ahd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) void ahd_pause(struct ahd_softc *ahd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) void ahd_unpause(struct ahd_softc *ahd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) ahd_known_modes(struct ahd_softc *ahd, ahd_mode src, ahd_mode dst)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	ahd->src_mode = src;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	ahd->dst_mode = dst;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	ahd->saved_src_mode = src;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	ahd->saved_dst_mode = dst;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) static inline ahd_mode_state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) ahd_build_mode_state(struct ahd_softc *ahd, ahd_mode src, ahd_mode dst)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	return ((src << SRC_MODE_SHIFT) | (dst << DST_MODE_SHIFT));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) ahd_extract_mode_state(struct ahd_softc *ahd, ahd_mode_state state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		       ahd_mode *src, ahd_mode *dst)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	*src = (state & SRC_MODE) >> SRC_MODE_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	*dst = (state & DST_MODE) >> DST_MODE_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) /*********************** Scatter Gather List Handling *************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) void	*ahd_sg_setup(struct ahd_softc *ahd, struct scb *scb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 		      void *sgptr, dma_addr_t addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		      bus_size_t len, int last);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) /************************** Memory mapping routines ***************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) static inline size_t	ahd_sg_size(struct ahd_softc *ahd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) void	ahd_sync_sglist(struct ahd_softc *ahd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 			struct scb *scb, int op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) static inline size_t ahd_sg_size(struct ahd_softc *ahd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		return (sizeof(struct ahd_dma64_seg));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	return (sizeof(struct ahd_dma_seg));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) /*********************** Miscellaneous Support Functions ***********************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) struct ahd_initiator_tinfo *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	ahd_fetch_transinfo(struct ahd_softc *ahd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 			    char channel, u_int our_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 			    u_int remote_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 			    struct ahd_tmode_tstate **tstate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) uint16_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	ahd_inw(struct ahd_softc *ahd, u_int port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) void	ahd_outw(struct ahd_softc *ahd, u_int port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		 u_int value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) uint32_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	ahd_inl(struct ahd_softc *ahd, u_int port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) void	ahd_outl(struct ahd_softc *ahd, u_int port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		 uint32_t value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) uint64_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	ahd_inq(struct ahd_softc *ahd, u_int port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) void	ahd_outq(struct ahd_softc *ahd, u_int port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		 uint64_t value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) u_int	ahd_get_scbptr(struct ahd_softc *ahd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) void	ahd_set_scbptr(struct ahd_softc *ahd, u_int scbptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) u_int	ahd_inb_scbram(struct ahd_softc *ahd, u_int offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) u_int	ahd_inw_scbram(struct ahd_softc *ahd, u_int offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) struct scb *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	ahd_lookup_scb(struct ahd_softc *ahd, u_int tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) void	ahd_queue_scb(struct ahd_softc *ahd, struct scb *scb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) static inline uint8_t *ahd_get_sense_buf(struct ahd_softc *ahd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 					  struct scb *scb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) static inline uint32_t ahd_get_sense_bufaddr(struct ahd_softc *ahd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 					      struct scb *scb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) #if 0 /* unused */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) #define AHD_COPY_COL_IDX(dst, src)				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) do {								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	dst->hscb->scsiid = src->hscb->scsiid;			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	dst->hscb->lun = src->hscb->lun;			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) static inline uint8_t *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) ahd_get_sense_buf(struct ahd_softc *ahd, struct scb *scb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	return (scb->sense_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) static inline uint32_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) ahd_get_sense_bufaddr(struct ahd_softc *ahd, struct scb *scb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	return (scb->sense_busaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) /************************** Interrupt Processing ******************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) int	ahd_intr(struct ahd_softc *ahd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) #endif  /* _AIC79XX_INLINE_H_ */