| 256 | } |
| 257 | |
| 258 | static int |
| 259 | ti_adc_clockdiv_proc(SYSCTL_HANDLER_ARGS) |
| 260 | { |
| 261 | int error, reg; |
| 262 | struct ti_adc_softc *sc; |
| 263 | |
| 264 | sc = (struct ti_adc_softc *)arg1; |
| 265 | |
| 266 | TI_ADC_LOCK(sc); |
| 267 | reg = (int)ADC_READ4(sc, ADC_CLKDIV) + 1; |
| 268 | TI_ADC_UNLOCK(sc); |
| 269 | |
| 270 | error = sysctl_handle_int(oidp, ®, sizeof(reg), req); |
| 271 | if (error != 0 || req->newptr == NULL) |
| 272 | return (error); |
| 273 | |
| 274 | /* |
| 275 | * The actual written value is the prescaler setting - 1. |
| 276 | * Enforce a minimum value of 10 (i.e. 9) which limits the maximum |
| 277 | * ADC clock to ~2.4Mhz (CLK_M_OSC / 10). |
| 278 | */ |
| 279 | reg--; |
| 280 | if (reg < 9) |
| 281 | reg = 9; |
| 282 | if (reg > USHRT_MAX) |
| 283 | reg = USHRT_MAX; |
| 284 | |
| 285 | TI_ADC_LOCK(sc); |
| 286 | /* Disable the ADC. */ |
| 287 | ti_adc_disable(sc); |
| 288 | /* Update the ADC prescaler setting. */ |
| 289 | ADC_WRITE4(sc, ADC_CLKDIV, reg); |
| 290 | /* Enable the ADC again. */ |
| 291 | ti_adc_setup(sc); |
| 292 | TI_ADC_UNLOCK(sc); |
| 293 | |
| 294 | return (0); |
| 295 | } |
| 296 | |
| 297 | static int |
| 298 | ti_adc_enable_proc(SYSCTL_HANDLER_ARGS) |
nothing calls this directly
no test coverage detected