Changes in uspace/drv/platform/icp/icp.c [75fe97b:a416d070] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/platform/icp/icp.c
r75fe97b ra416d070 39 39 #include <stdio.h> 40 40 #include <errno.h> 41 #include <irc.h> 41 42 #include <stdbool.h> 42 43 #include <stdlib.h> … … 53 54 icp_kbd_irq = 3, 54 55 icp_mouse_base = 0x19000000, 55 icp_mouse_irq = 4 56 icp_mouse_irq = 4, 57 icp_ic_base = 0x14000000 56 58 }; 57 59 … … 107 109 }; 108 110 111 static hw_resource_t icp_ic_res[] = { 112 { 113 .type = MEM_RANGE, 114 .res.mem_range = { 115 .address = icp_ic_base, 116 .size = 40, 117 .relative = false, 118 .endianness = LITTLE_ENDIAN 119 } 120 } 121 }; 122 109 123 static pio_window_t icp_pio_window = { 110 124 .mem = { … … 128 142 }; 129 143 144 static icp_fun_t icp_ic_fun_proto = { 145 .hw_resources = { 146 sizeof(icp_ic_res) / sizeof(icp_ic_res[0]), 147 icp_ic_res 148 }, 149 }; 150 130 151 /** Obtain function soft-state from DDF function node */ 131 152 static icp_fun_t *icp_fun(ddf_fun_t *fnode) … … 142 163 } 143 164 144 static bool icp_enable_interrupt(ddf_fun_t *fun) 145 { 146 /* TODO */ 165 static bool icp_fun_owns_interrupt(icp_fun_t *fun, int irq) 166 { 167 const hw_resource_list_t *res = &fun->hw_resources; 168 169 /* Check that specified irq really belongs to the function */ 170 for (size_t i = 0; i < res->count; ++i) { 171 if (res->resources[i].type == INTERRUPT && 172 res->resources[i].res.interrupt.irq == irq) { 173 return true; 174 } 175 } 176 147 177 return false; 178 } 179 180 static int icp_fun_enable_interrupt(ddf_fun_t *fnode, int irq) 181 { 182 icp_fun_t *fun = icp_fun(fnode); 183 184 if (!icp_fun_owns_interrupt(fun, irq)) 185 return EINVAL; 186 187 return irc_enable_interrupt(irq); 188 } 189 190 static int icp_fun_disable_interrupt(ddf_fun_t *fnode, int irq) 191 { 192 icp_fun_t *fun = icp_fun(fnode); 193 194 if (!icp_fun_owns_interrupt(fun, irq)) 195 return EINVAL; 196 197 return irc_disable_interrupt(irq); 198 } 199 200 static int icp_fun_clear_interrupt(ddf_fun_t *fnode, int irq) 201 { 202 icp_fun_t *fun = icp_fun(fnode); 203 204 if (!icp_fun_owns_interrupt(fun, irq)) 205 return EINVAL; 206 207 return irc_clear_interrupt(irq); 148 208 } 149 209 … … 155 215 static hw_res_ops_t icp_hw_res_ops = { 156 216 .get_resource_list = &icp_get_resources, 157 .enable_interrupt = &icp_enable_interrupt, 217 .enable_interrupt = &icp_fun_enable_interrupt, 218 .disable_interrupt = &icp_fun_disable_interrupt, 219 .clear_interrupt = &icp_fun_clear_interrupt 158 220 }; 159 221 … … 225 287 return rc; 226 288 289 rc = icp_add_fun(dev, "intctl", "integratorcp/intctl", 290 &icp_ic_fun_proto); 291 if (rc != EOK) 292 return rc; 293 227 294 return EOK; 228 295 }
Note:
See TracChangeset
for help on using the changeset viewer.