H A D | comedi_8254.c | 133 static unsigned int __i8254_read(struct comedi_8254 *i8254, unsigned int reg) __i8254_read() argument 135 unsigned int reg_offset = (reg * i8254->iosize) << i8254->regshift; __i8254_read() 138 switch (i8254->iosize) { __i8254_read() 141 if (i8254->mmio) __i8254_read() 142 val = readb(i8254->mmio + reg_offset); __i8254_read() 144 val = inb(i8254->iobase + reg_offset); __i8254_read() 147 if (i8254->mmio) __i8254_read() 148 val = readw(i8254->mmio + reg_offset); __i8254_read() 150 val = inw(i8254->iobase + reg_offset); __i8254_read() 153 if (i8254->mmio) __i8254_read() 154 val = readl(i8254->mmio + reg_offset); __i8254_read() 156 val = inl(i8254->iobase + reg_offset); __i8254_read() 162 static void __i8254_write(struct comedi_8254 *i8254, __i8254_write() argument 165 unsigned int reg_offset = (reg * i8254->iosize) << i8254->regshift; __i8254_write() 167 switch (i8254->iosize) { __i8254_write() 170 if (i8254->mmio) __i8254_write() 171 writeb(val, i8254->mmio + reg_offset); __i8254_write() 173 outb(val, i8254->iobase + reg_offset); __i8254_write() 176 if (i8254->mmio) __i8254_write() 177 writew(val, i8254->mmio + reg_offset); __i8254_write() 179 outw(val, i8254->iobase + reg_offset); __i8254_write() 182 if (i8254->mmio) __i8254_write() 183 writel(val, i8254->mmio + reg_offset); __i8254_write() 185 outl(val, i8254->iobase + reg_offset); __i8254_write() 192 * @i8254: comedi_8254 struct for the timer 195 unsigned int comedi_8254_status(struct comedi_8254 *i8254, unsigned int counter) comedi_8254_status() argument 203 __i8254_write(i8254, cmd, I8254_CTRL_REG); comedi_8254_status() 205 return __i8254_read(i8254, counter); comedi_8254_status() 211 * @i8254: comedi_8254 struct for the timer 214 unsigned int comedi_8254_read(struct comedi_8254 *i8254, unsigned int counter) comedi_8254_read() argument 222 __i8254_write(i8254, I8254_CTRL_SEL_CTR(counter) | I8254_CTRL_LATCH, comedi_8254_read() 226 val = __i8254_read(i8254, counter); comedi_8254_read() 227 val |= (__i8254_read(i8254, counter) << 8); comedi_8254_read() 235 * @i8254: comedi_8254 struct for the timer 239 void comedi_8254_write(struct comedi_8254 *i8254, comedi_8254_write() argument 251 __i8254_write(i8254, byte, counter); comedi_8254_write() 253 __i8254_write(i8254, byte, counter); comedi_8254_write() 259 * @i8254: comedi_8254 struct for the timer 263 int comedi_8254_set_mode(struct comedi_8254 *i8254, unsigned int counter, comedi_8254_set_mode() argument 276 __i8254_write(i8254, byte, I8254_CTRL_REG); comedi_8254_set_mode() 284 * @i8254: comedi_8254 struct for the timer 289 int comedi_8254_load(struct comedi_8254 *i8254, unsigned int counter, comedi_8254_load() argument 299 comedi_8254_set_mode(i8254, counter, mode); comedi_8254_load() 300 comedi_8254_write(i8254, counter, val); comedi_8254_load() 308 * @i8254: comedi_8254 struct for the timer 313 void comedi_8254_pacer_enable(struct comedi_8254 *i8254, comedi_8254_pacer_enable() argument 328 comedi_8254_set_mode(i8254, counter1, mode); comedi_8254_pacer_enable() 329 comedi_8254_set_mode(i8254, counter2, mode); comedi_8254_pacer_enable() 337 comedi_8254_write(i8254, counter2, i8254->divisor2); comedi_8254_pacer_enable() 338 comedi_8254_write(i8254, counter1, i8254->divisor1); comedi_8254_pacer_enable() 345 * @i8254: comedi_8254 struct for the timer 347 void comedi_8254_update_divisors(struct comedi_8254 *i8254) comedi_8254_update_divisors() argument 350 i8254->divisor = i8254->next_div & 0xffff; comedi_8254_update_divisors() 351 i8254->divisor1 = i8254->next_div1 & 0xffff; comedi_8254_update_divisors() 352 i8254->divisor2 = i8254->next_div2 & 0xffff; comedi_8254_update_divisors() 358 * @i8254: comedi_8254 struct for the timer 362 void comedi_8254_cascade_ns_to_timer(struct comedi_8254 *i8254, comedi_8254_cascade_ns_to_timer() argument 366 unsigned int d1 = i8254->next_div1 ? i8254->next_div1 : I8254_MAX_COUNT; comedi_8254_cascade_ns_to_timer() 367 unsigned int d2 = i8254->next_div2 ? i8254->next_div2 : I8254_MAX_COUNT; comedi_8254_cascade_ns_to_timer() 381 if (div * i8254->osc_base == *nanosec && comedi_8254_cascade_ns_to_timer() 386 div * i8254->osc_base > div && comedi_8254_cascade_ns_to_timer() 387 div * i8254->osc_base > i8254->osc_base) comedi_8254_cascade_ns_to_timer() 390 div = *nanosec / i8254->osc_base; comedi_8254_cascade_ns_to_timer() 398 ns = i8254->osc_base * d1 * d2; comedi_8254_cascade_ns_to_timer() 415 ns_high = d1_lub * d2_lub * i8254->osc_base; comedi_8254_cascade_ns_to_timer() 416 ns_low = d1_glb * d2_glb * i8254->osc_base; comedi_8254_cascade_ns_to_timer() 435 *nanosec = d1 * d2 * i8254->osc_base; comedi_8254_cascade_ns_to_timer() 436 i8254->next_div1 = d1; comedi_8254_cascade_ns_to_timer() 437 i8254->next_div2 = d2; comedi_8254_cascade_ns_to_timer() 443 * @i8254: comedi_8254 struct for the timer 447 void comedi_8254_ns_to_timer(struct comedi_8254 *i8254, comedi_8254_ns_to_timer() argument 455 divisor = DIV_ROUND_CLOSEST(*nanosec, i8254->osc_base); comedi_8254_ns_to_timer() 458 divisor = DIV_ROUND_UP(*nanosec, i8254->osc_base); comedi_8254_ns_to_timer() 461 divisor = *nanosec / i8254->osc_base; comedi_8254_ns_to_timer() 469 *nanosec = divisor * i8254->osc_base; comedi_8254_ns_to_timer() 470 i8254->next_div = divisor; comedi_8254_ns_to_timer() 476 * @i8254: comedi_8254 struct for the timer 480 void comedi_8254_set_busy(struct comedi_8254 *i8254, comedi_8254_set_busy() argument 484 i8254->busy[counter] = busy; comedi_8254_set_busy() 493 struct comedi_8254 *i8254 = s->private; comedi_8254_insn_read() local 497 if (i8254->busy[chan]) comedi_8254_insn_read() 501 data[i] = comedi_8254_read(i8254, chan); comedi_8254_insn_read() 511 struct comedi_8254 *i8254 = s->private; comedi_8254_insn_write() local 514 if (i8254->busy[chan]) comedi_8254_insn_write() 518 comedi_8254_write(i8254, chan, data[insn->n - 1]); comedi_8254_insn_write() 528 struct comedi_8254 *i8254 = s->private; comedi_8254_insn_config() local 532 if (i8254->busy[chan]) comedi_8254_insn_config() 537 ret = comedi_8254_set_mode(i8254, chan, comedi_8254_insn_config() 543 ret = comedi_8254_set_mode(i8254, chan, data[1]); comedi_8254_insn_config() 548 data[1] = comedi_8254_status(i8254, chan); comedi_8254_insn_config() 555 if (i8254->insn_config) comedi_8254_insn_config() 556 return i8254->insn_config(dev, s, insn, data); comedi_8254_insn_config() 569 struct comedi_8254 *i8254) comedi_8254_subdevice_init() 580 s->private = i8254; comedi_8254_subdevice_init() 590 struct comedi_8254 *i8254; __i8254_init() local 598 i8254 = kzalloc(sizeof(*i8254), GFP_KERNEL); __i8254_init() 599 if (!i8254) __i8254_init() 602 i8254->iobase = iobase; __i8254_init() 603 i8254->mmio = mmio; __i8254_init() 604 i8254->iosize = iosize; __i8254_init() 605 i8254->regshift = regshift; __i8254_init() 608 i8254->osc_base = osc_base ? osc_base : I8254_OSC_BASE_10MHZ; __i8254_init() 612 comedi_8254_set_mode(i8254, i, I8254_MODE0 | I8254_BINARY); __i8254_init() 614 return i8254; __i8254_init() 568 comedi_8254_subdevice_init(struct comedi_subdevice *s, struct comedi_8254 *i8254) comedi_8254_subdevice_init() argument
|