[1] | 1 | /* |
---|
[3] | 2 | * dev_iob.h - IOB (bridge to external I/O) generic device API. |
---|
[1] | 3 | * |
---|
| 4 | * Authors Alain Greiner (2016) |
---|
| 5 | * |
---|
| 6 | * Copyright (c) UPMC Sorbonne Universites |
---|
| 7 | * |
---|
| 8 | * This file is part of ALMOS-MKH. |
---|
| 9 | * |
---|
| 10 | * ALMOS-MKH is free software; you can redistribute it and/or modify it |
---|
| 11 | * under the terms of the GNU General Public License as published by |
---|
| 12 | * the Free Software Foundation; version 2.0 of the License. |
---|
| 13 | * |
---|
| 14 | * ALMOS-MKH is distributed in the hope that it will be useful, but |
---|
| 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
[3] | 16 | * MERCHANTABILITY or FITNESS FOR A PARTIOBLAR PURPOSE. See the GNU |
---|
[1] | 17 | * General Public License for more details. |
---|
| 18 | * |
---|
| 19 | * You should have received a copy of the GNU General Public License |
---|
| 20 | * along with ALMOS-MKH; if not, write to the Free Software Foundation, |
---|
| 21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
| 22 | */ |
---|
| 23 | |
---|
[3] | 24 | #ifndef _DEV_IOB_H_ |
---|
| 25 | #define _DEV_IOB_H_ |
---|
[1] | 26 | |
---|
[14] | 27 | #include <kernel_config.h> |
---|
[1] | 28 | #include <hal_types.h> |
---|
| 29 | #include <spinlock.h> |
---|
| 30 | |
---|
| 31 | /***************************************************************************************** |
---|
[3] | 32 | * Generic IOB (bridge to external IO peripherals) definition. |
---|
[1] | 33 | * |
---|
[3] | 34 | * The IOB device is used to access external peripherals. It implements an IO-MMU service |
---|
[1] | 35 | * for DMA transactions launched by DMA capable external peripherals. |
---|
[279] | 36 | * |
---|
[3] | 37 | * This IOB peripheral is acting as a dynamically configurable bridge, used for others |
---|
| 38 | * I/O operations. Therefore, ALMOS-MKH does not use the IOB device waiting queue, |
---|
| 39 | * and calls directly the IOB driver blocking functions, using the device lock to |
---|
| 40 | * get exclusive access to the IOB bridge internal state. |
---|
[1] | 41 | ****************************************************************************************/ |
---|
| 42 | |
---|
[3] | 43 | /**** Forward declarations ****/ |
---|
[1] | 44 | |
---|
[3] | 45 | struct chdev_s; |
---|
| 46 | |
---|
[1] | 47 | /***************************************************************************************** |
---|
[346] | 48 | * This defines the specific extension for the IOB chdev descriptor. |
---|
| 49 | ****************************************************************************************/ |
---|
| 50 | |
---|
| 51 | typedef void (iob_set_active_t) ( xptr_t iob_xp, uint32_t value ); |
---|
| 52 | typedef void (iob_set_ptpr_t) ( xptr_t iob_xp, uint32_t value ); |
---|
| 53 | typedef void (iob_inval_page_t) ( xptr_t iob_xp, vpn_t vpn ); |
---|
| 54 | typedef uint32_t (iob_get_bvar_t) ( xptr_t iob_xp ); |
---|
| 55 | typedef uint32_t (iob_get_srcid_t) ( xptr_t iob_xp ); |
---|
| 56 | typedef uint32_t (iob_get_error_t) ( xptr_t iob_xp ); |
---|
| 57 | |
---|
| 58 | typedef struct iob_extend_s |
---|
| 59 | { |
---|
| 60 | iob_set_active_t * set_active; |
---|
| 61 | iob_set_ptpr_t * set_ptpr; |
---|
| 62 | iob_inval_page_t * inval_page; |
---|
| 63 | iob_get_bvar_t * get_bvar; |
---|
| 64 | iob_get_srcid_t * get_srcid; |
---|
| 65 | iob_get_error_t * get_error; |
---|
| 66 | } |
---|
| 67 | iob_extend_t; |
---|
| 68 | |
---|
| 69 | /***************************************************************************************** |
---|
[3] | 70 | * This enum defines the various implementations of the IOB generic device. |
---|
[1] | 71 | * This array must be kept consistent with the define in arch_info.h file |
---|
| 72 | ****************************************************************************************/ |
---|
| 73 | |
---|
[3] | 74 | enum iob_impl_e |
---|
[1] | 75 | { |
---|
[3] | 76 | IMPL_IOB_TSR = 0, /* vci_iob component used in TSAR */ |
---|
| 77 | IMPL_IOB_I86 = 1, /* TBD */ |
---|
[1] | 78 | } |
---|
[3] | 79 | iob_impl_t; |
---|
[1] | 80 | |
---|
| 81 | /***************************************************************************************** |
---|
[3] | 82 | * This function initializes the IOB device descriptor with IOMMU disabled. |
---|
[1] | 83 | ***************************************************************************************** |
---|
[3] | 84 | * @ chdev : pointer on IOB chdev descriptor. |
---|
[1] | 85 | ****************************************************************************************/ |
---|
[3] | 86 | void dev_iob_init( struct chdev_s * chdev ); |
---|
[1] | 87 | |
---|
| 88 | /***************************************************************************************** |
---|
[3] | 89 | * This function activates the IOMMU for the IOB device identified by its |
---|
[1] | 90 | * extended pointer. |
---|
| 91 | ***************************************************************************************** |
---|
[3] | 92 | * @ dev_xp : extended pointer on IOB device descriptor. |
---|
[1] | 93 | ****************************************************************************************/ |
---|
[3] | 94 | void dev_iob_iommu_enable( xptr_t dev_xp ); |
---|
[1] | 95 | |
---|
| 96 | /***************************************************************************************** |
---|
[3] | 97 | * This function desactivates the IO-MMU for the IOB device identified by its |
---|
[1] | 98 | * extended pointer. |
---|
| 99 | ***************************************************************************************** |
---|
[3] | 100 | * @ dev_xp : extended pointer on IOB device descriptor. |
---|
[1] | 101 | ****************************************************************************************/ |
---|
[3] | 102 | void dev_iob_iommu_disable( xptr_t dev_xp ); |
---|
[1] | 103 | |
---|
| 104 | /***************************************************************************************** |
---|
| 105 | * This function set a new value in the IO-MMU PTPR register. |
---|
| 106 | ***************************************************************************************** |
---|
[3] | 107 | * @ dev_xp : extended pointer on IOB device descriptor. |
---|
[1] | 108 | * @ wdata : value to be written in PTPR register. |
---|
| 109 | ****************************************************************************************/ |
---|
[3] | 110 | void dev_iob_set_ptpr( xptr_t dev_xp, |
---|
[1] | 111 | uint32_t wdata ); |
---|
| 112 | |
---|
| 113 | /***************************************************************************************** |
---|
| 114 | * This function invalidates an IOMMU TLB entry identified by its vpn. |
---|
| 115 | ***************************************************************************************** |
---|
[3] | 116 | * @ dev_xp : extended pointer on IOB device descriptor. |
---|
[1] | 117 | * @ vpn : virtual page number in IO virtual space. |
---|
| 118 | ****************************************************************************************/ |
---|
[3] | 119 | void dev_iob_inval_page( xptr_t dev_xp, |
---|
[1] | 120 | vpn_t vpn ); |
---|
| 121 | |
---|
| 122 | /***************************************************************************************** |
---|
| 123 | * This function return informations relative to an error reported by the IOMMU. |
---|
| 124 | ***************************************************************************************** |
---|
[3] | 125 | * @ dev_xp : extended pointer on IOB device descriptor. |
---|
[1] | 126 | * @ error : [out] pointer on buffer for erro type. |
---|
| 127 | * @ bvar : [out] pointer on buffer for bad virtual address. |
---|
| 128 | * @ srcid : [out] pointer on buffer for faulty peripheral index. |
---|
| 129 | ****************************************************************************************/ |
---|
[3] | 130 | void dev_iob_get_status( xptr_t dev_xp, |
---|
[1] | 131 | uint32_t * error, |
---|
| 132 | uint32_t * bvar, |
---|
| 133 | uint32_t * srcid ); |
---|
| 134 | |
---|
[3] | 135 | #endif /* _DEV_IOB_H_ */ |
---|