Lines Matching refs:hp_sdc
112 static hp_i8042_sdc hp_sdc; /* All driver state is kept in here. */ variable
120 write_lock_irqsave(&hp_sdc.ibf_lock, flags); in hp_sdc_status_in8()
121 status = sdc_readb(hp_sdc.status_io); in hp_sdc_status_in8()
123 hp_sdc.ibf = 0; in hp_sdc_status_in8()
124 write_unlock_irqrestore(&hp_sdc.ibf_lock, flags); in hp_sdc_status_in8()
131 return sdc_readb(hp_sdc.data_io); in hp_sdc_data_in8()
138 write_lock_irqsave(&hp_sdc.ibf_lock, flags); in hp_sdc_status_out8()
139 hp_sdc.ibf = 1; in hp_sdc_status_out8()
141 hp_sdc.wi = 0xff; in hp_sdc_status_out8()
142 sdc_writeb(val, hp_sdc.status_io); in hp_sdc_status_out8()
143 write_unlock_irqrestore(&hp_sdc.ibf_lock, flags); in hp_sdc_status_out8()
150 write_lock_irqsave(&hp_sdc.ibf_lock, flags); in hp_sdc_data_out8()
151 hp_sdc.ibf = 1; in hp_sdc_data_out8()
152 sdc_writeb(val, hp_sdc.data_io); in hp_sdc_data_out8()
153 write_unlock_irqrestore(&hp_sdc.ibf_lock, flags); in hp_sdc_data_out8()
165 lock = &hp_sdc.ibf_lock; in hp_sdc_spin_ibf()
168 if (!hp_sdc.ibf) { in hp_sdc_spin_ibf()
174 while (sdc_readb(hp_sdc.status_io) & HP_SDC_STATUS_IBF) in hp_sdc_spin_ibf()
176 hp_sdc.ibf = 0; in hp_sdc_spin_ibf()
186 read_lock(&hp_sdc.rtq_lock); in hp_sdc_take()
187 if (hp_sdc.rcurr < 0) { in hp_sdc_take()
188 read_unlock(&hp_sdc.rtq_lock); in hp_sdc_take()
191 curr = hp_sdc.tq[hp_sdc.rcurr]; in hp_sdc_take()
192 read_unlock(&hp_sdc.rtq_lock); in hp_sdc_take()
196 hp_sdc.rqty -= 2; in hp_sdc_take()
197 do_gettimeofday(&hp_sdc.rtv); in hp_sdc_take()
199 if (hp_sdc.rqty <= 0) { in hp_sdc_take()
212 write_lock(&hp_sdc.rtq_lock); in hp_sdc_take()
213 hp_sdc.rcurr = -1; in hp_sdc_take()
214 hp_sdc.rqty = 0; in hp_sdc_take()
215 write_unlock(&hp_sdc.rtq_lock); in hp_sdc_take()
216 tasklet_schedule(&hp_sdc.task); in hp_sdc_take()
239 read_lock(&hp_sdc.hook_lock); in hp_sdc_isr()
240 if (hp_sdc.timer != NULL) in hp_sdc_isr()
241 hp_sdc.timer(irq, dev_id, status, data); in hp_sdc_isr()
242 read_unlock(&hp_sdc.hook_lock); in hp_sdc_isr()
251 read_lock(&hp_sdc.hook_lock); in hp_sdc_isr()
252 if (hp_sdc.hil != NULL) in hp_sdc_isr()
253 hp_sdc.hil(irq, dev_id, status, data); in hp_sdc_isr()
254 read_unlock(&hp_sdc.hook_lock); in hp_sdc_isr()
258 read_lock(&hp_sdc.hook_lock); in hp_sdc_isr()
259 if (hp_sdc.pup != NULL) in hp_sdc_isr()
260 hp_sdc.pup(irq, dev_id, status, data); in hp_sdc_isr()
263 read_unlock(&hp_sdc.hook_lock); in hp_sdc_isr()
267 read_lock(&hp_sdc.hook_lock); in hp_sdc_isr()
268 if (hp_sdc.cooked != NULL) in hp_sdc_isr()
269 hp_sdc.cooked(irq, dev_id, status, data); in hp_sdc_isr()
270 read_unlock(&hp_sdc.hook_lock); in hp_sdc_isr()
287 read_lock(&hp_sdc.hook_lock); in hp_sdc_nmisr()
288 if (hp_sdc.timer != NULL) in hp_sdc_nmisr()
289 hp_sdc.timer(irq, dev_id, status, 0); in hp_sdc_nmisr()
290 read_unlock(&hp_sdc.hook_lock); in hp_sdc_nmisr()
307 write_lock_irq(&hp_sdc.rtq_lock); in hp_sdc_tasklet()
309 if (hp_sdc.rcurr >= 0) { in hp_sdc_tasklet()
313 if (tv.tv_sec > hp_sdc.rtv.tv_sec) in hp_sdc_tasklet()
316 if (tv.tv_usec - hp_sdc.rtv.tv_usec > HP_SDC_MAX_REG_DELAY) { in hp_sdc_tasklet()
320 curr = hp_sdc.tq[hp_sdc.rcurr]; in hp_sdc_tasklet()
326 (int)(tv.tv_usec - hp_sdc.rtv.tv_usec)); in hp_sdc_tasklet()
327 curr->idx += hp_sdc.rqty; in hp_sdc_tasklet()
328 hp_sdc.rqty = 0; in hp_sdc_tasklet()
345 hp_sdc.rcurr = -1; in hp_sdc_tasklet()
348 write_unlock_irq(&hp_sdc.rtq_lock); in hp_sdc_tasklet()
360 write_lock(&hp_sdc.lock); in hp_sdc_put()
364 if (hp_sdc.ibf) { in hp_sdc_put()
366 if (hp_sdc.ibf) in hp_sdc_put()
372 if (hp_sdc.wcurr < 0) in hp_sdc_put()
373 hp_sdc.wcurr = 0; in hp_sdc_put()
374 read_lock_irq(&hp_sdc.rtq_lock); in hp_sdc_put()
375 if (hp_sdc.rcurr == hp_sdc.wcurr) in hp_sdc_put()
376 hp_sdc.wcurr++; in hp_sdc_put()
377 read_unlock_irq(&hp_sdc.rtq_lock); in hp_sdc_put()
378 if (hp_sdc.wcurr >= HP_SDC_QUEUE_LEN) in hp_sdc_put()
379 hp_sdc.wcurr = 0; in hp_sdc_put()
380 curridx = hp_sdc.wcurr; in hp_sdc_put()
382 if (hp_sdc.tq[curridx] != NULL) in hp_sdc_put()
385 while (++curridx != hp_sdc.wcurr) { in hp_sdc_put()
390 read_lock_irq(&hp_sdc.rtq_lock); in hp_sdc_put()
391 if (hp_sdc.rcurr == curridx) { in hp_sdc_put()
392 read_unlock_irq(&hp_sdc.rtq_lock); in hp_sdc_put()
395 read_unlock_irq(&hp_sdc.rtq_lock); in hp_sdc_put()
396 if (hp_sdc.tq[curridx] != NULL) in hp_sdc_put()
399 if (curridx == hp_sdc.wcurr) { /* There's nothing queued to do. */ in hp_sdc_put()
402 hp_sdc.wcurr = curridx; in hp_sdc_put()
407 if (hp_sdc.set_im) { in hp_sdc_put()
408 hp_sdc_status_out8(hp_sdc.im | HP_SDC_CMD_SET_IM); in hp_sdc_put()
409 hp_sdc.set_im = 0; in hp_sdc_put()
413 if (hp_sdc.wcurr == -1) in hp_sdc_put()
416 curr = hp_sdc.tq[curridx]; in hp_sdc_put()
420 hp_sdc.tq[curridx] = NULL; in hp_sdc_put()
422 hp_sdc.wcurr++; in hp_sdc_put()
423 if (hp_sdc.wcurr >= HP_SDC_QUEUE_LEN) in hp_sdc_put()
424 hp_sdc.wcurr = 0; in hp_sdc_put()
434 hp_sdc.tq[curridx] = NULL; in hp_sdc_put()
436 hp_sdc.wcurr++; in hp_sdc_put()
437 if (hp_sdc.wcurr >= HP_SDC_QUEUE_LEN) in hp_sdc_put()
438 hp_sdc.wcurr = 0; in hp_sdc_put()
490 w7[0] = (mask & 1) ? curr->seq[++idx] : hp_sdc.r7[0]; in hp_sdc_put()
491 w7[1] = (mask & 2) ? curr->seq[++idx] : hp_sdc.r7[1]; in hp_sdc_put()
492 w7[2] = (mask & 4) ? curr->seq[++idx] : hp_sdc.r7[2]; in hp_sdc_put()
493 w7[3] = (mask & 8) ? curr->seq[++idx] : hp_sdc.r7[3]; in hp_sdc_put()
495 if (hp_sdc.wi > 0x73 || hp_sdc.wi < 0x70 || in hp_sdc_put()
496 w7[hp_sdc.wi - 0x70] == hp_sdc.r7[hp_sdc.wi - 0x70]) { in hp_sdc_put()
500 while (i < 4 && w7[i] == hp_sdc.r7[i]) in hp_sdc_put()
505 hp_sdc.wi = 0x70 + i; in hp_sdc_put()
518 hp_sdc_data_out8(w7[hp_sdc.wi - 0x70]); in hp_sdc_put()
519 hp_sdc.r7[hp_sdc.wi - 0x70] = w7[hp_sdc.wi - 0x70]; in hp_sdc_put()
520 hp_sdc.wi++; /* write index register autoincrements */ in hp_sdc_put()
524 while ((i < 4) && w7[i] == hp_sdc.r7[i]) in hp_sdc_put()
537 read_lock_irq(&hp_sdc.rtq_lock); in hp_sdc_put()
538 if (hp_sdc.rcurr >= 0) { in hp_sdc_put()
539 read_unlock_irq(&hp_sdc.rtq_lock); in hp_sdc_put()
542 read_unlock_irq(&hp_sdc.rtq_lock); in hp_sdc_put()
554 hp_sdc.rqty = curr->seq[curr->idx]; in hp_sdc_put()
555 do_gettimeofday(&hp_sdc.rtv); in hp_sdc_put()
558 write_lock_irq(&hp_sdc.rtq_lock); in hp_sdc_put()
559 hp_sdc.rcurr = curridx; in hp_sdc_put()
560 write_unlock_irq(&hp_sdc.rtq_lock); in hp_sdc_put()
577 hp_sdc.tq[curridx] = NULL; in hp_sdc_put()
583 hp_sdc.wcurr++; in hp_sdc_put()
584 if (hp_sdc.wcurr >= HP_SDC_QUEUE_LEN) in hp_sdc_put()
585 hp_sdc.wcurr = 0; in hp_sdc_put()
590 if (!hp_sdc.ibf && limit++ < 20) in hp_sdc_put()
594 if (hp_sdc.wcurr >= 0) in hp_sdc_put()
595 tasklet_schedule(&hp_sdc.task); in hp_sdc_put()
596 write_unlock(&hp_sdc.lock); in hp_sdc_put()
613 if (hp_sdc.tq[i] == this) in __hp_sdc_enqueue_transaction()
621 if (hp_sdc.tq[i] == NULL) { in __hp_sdc_enqueue_transaction()
622 hp_sdc.tq[i] = this; in __hp_sdc_enqueue_transaction()
623 tasklet_schedule(&hp_sdc.task); in __hp_sdc_enqueue_transaction()
639 write_lock_irqsave(&hp_sdc.lock, flags); in hp_sdc_enqueue_transaction()
641 write_unlock_irqrestore(&hp_sdc.lock,flags); in hp_sdc_enqueue_transaction()
651 write_lock_irqsave(&hp_sdc.lock, flags); in hp_sdc_dequeue_transaction()
656 if (hp_sdc.tq[i] == this) in hp_sdc_dequeue_transaction()
657 hp_sdc.tq[i] = NULL; in hp_sdc_dequeue_transaction()
659 write_unlock_irqrestore(&hp_sdc.lock, flags); in hp_sdc_dequeue_transaction()
668 if (callback == NULL || hp_sdc.dev == NULL) in hp_sdc_request_timer_irq()
671 write_lock_irq(&hp_sdc.hook_lock); in hp_sdc_request_timer_irq()
672 if (hp_sdc.timer != NULL) { in hp_sdc_request_timer_irq()
673 write_unlock_irq(&hp_sdc.hook_lock); in hp_sdc_request_timer_irq()
677 hp_sdc.timer = callback; in hp_sdc_request_timer_irq()
679 hp_sdc.im &= ~HP_SDC_IM_FH; in hp_sdc_request_timer_irq()
680 hp_sdc.im &= ~HP_SDC_IM_PT; in hp_sdc_request_timer_irq()
681 hp_sdc.im &= ~HP_SDC_IM_TIMERS; in hp_sdc_request_timer_irq()
682 hp_sdc.set_im = 1; in hp_sdc_request_timer_irq()
683 write_unlock_irq(&hp_sdc.hook_lock); in hp_sdc_request_timer_irq()
685 tasklet_schedule(&hp_sdc.task); in hp_sdc_request_timer_irq()
692 if (callback == NULL || hp_sdc.dev == NULL) in hp_sdc_request_hil_irq()
695 write_lock_irq(&hp_sdc.hook_lock); in hp_sdc_request_hil_irq()
696 if (hp_sdc.hil != NULL) { in hp_sdc_request_hil_irq()
697 write_unlock_irq(&hp_sdc.hook_lock); in hp_sdc_request_hil_irq()
701 hp_sdc.hil = callback; in hp_sdc_request_hil_irq()
702 hp_sdc.im &= ~(HP_SDC_IM_HIL | HP_SDC_IM_RESET); in hp_sdc_request_hil_irq()
703 hp_sdc.set_im = 1; in hp_sdc_request_hil_irq()
704 write_unlock_irq(&hp_sdc.hook_lock); in hp_sdc_request_hil_irq()
706 tasklet_schedule(&hp_sdc.task); in hp_sdc_request_hil_irq()
713 if (callback == NULL || hp_sdc.dev == NULL) in hp_sdc_request_cooked_irq()
716 write_lock_irq(&hp_sdc.hook_lock); in hp_sdc_request_cooked_irq()
717 if (hp_sdc.cooked != NULL) { in hp_sdc_request_cooked_irq()
718 write_unlock_irq(&hp_sdc.hook_lock); in hp_sdc_request_cooked_irq()
723 hp_sdc.cooked = callback; in hp_sdc_request_cooked_irq()
724 hp_sdc.im &= ~(HP_SDC_IM_HIL | HP_SDC_IM_RESET); in hp_sdc_request_cooked_irq()
725 hp_sdc.set_im = 1; in hp_sdc_request_cooked_irq()
726 write_unlock_irq(&hp_sdc.hook_lock); in hp_sdc_request_cooked_irq()
728 tasklet_schedule(&hp_sdc.task); in hp_sdc_request_cooked_irq()
735 write_lock_irq(&hp_sdc.hook_lock); in hp_sdc_release_timer_irq()
736 if ((callback != hp_sdc.timer) || in hp_sdc_release_timer_irq()
737 (hp_sdc.timer == NULL)) { in hp_sdc_release_timer_irq()
738 write_unlock_irq(&hp_sdc.hook_lock); in hp_sdc_release_timer_irq()
743 hp_sdc.timer = NULL; in hp_sdc_release_timer_irq()
744 hp_sdc.im |= HP_SDC_IM_TIMERS; in hp_sdc_release_timer_irq()
745 hp_sdc.im |= HP_SDC_IM_FH; in hp_sdc_release_timer_irq()
746 hp_sdc.im |= HP_SDC_IM_PT; in hp_sdc_release_timer_irq()
747 hp_sdc.set_im = 1; in hp_sdc_release_timer_irq()
748 write_unlock_irq(&hp_sdc.hook_lock); in hp_sdc_release_timer_irq()
749 tasklet_schedule(&hp_sdc.task); in hp_sdc_release_timer_irq()
756 write_lock_irq(&hp_sdc.hook_lock); in hp_sdc_release_hil_irq()
757 if ((callback != hp_sdc.hil) || in hp_sdc_release_hil_irq()
758 (hp_sdc.hil == NULL)) { in hp_sdc_release_hil_irq()
759 write_unlock_irq(&hp_sdc.hook_lock); in hp_sdc_release_hil_irq()
763 hp_sdc.hil = NULL; in hp_sdc_release_hil_irq()
765 if(hp_sdc.cooked == NULL) { in hp_sdc_release_hil_irq()
766 hp_sdc.im |= (HP_SDC_IM_HIL | HP_SDC_IM_RESET); in hp_sdc_release_hil_irq()
767 hp_sdc.set_im = 1; in hp_sdc_release_hil_irq()
769 write_unlock_irq(&hp_sdc.hook_lock); in hp_sdc_release_hil_irq()
770 tasklet_schedule(&hp_sdc.task); in hp_sdc_release_hil_irq()
777 write_lock_irq(&hp_sdc.hook_lock); in hp_sdc_release_cooked_irq()
778 if ((callback != hp_sdc.cooked) || in hp_sdc_release_cooked_irq()
779 (hp_sdc.cooked == NULL)) { in hp_sdc_release_cooked_irq()
780 write_unlock_irq(&hp_sdc.hook_lock); in hp_sdc_release_cooked_irq()
784 hp_sdc.cooked = NULL; in hp_sdc_release_cooked_irq()
786 if(hp_sdc.hil == NULL) { in hp_sdc_release_cooked_irq()
787 hp_sdc.im |= (HP_SDC_IM_HIL | HP_SDC_IM_RESET); in hp_sdc_release_cooked_irq()
788 hp_sdc.set_im = 1; in hp_sdc_release_cooked_irq()
790 write_unlock_irq(&hp_sdc.hook_lock); in hp_sdc_release_cooked_irq()
791 tasklet_schedule(&hp_sdc.task); in hp_sdc_release_cooked_irq()
800 tasklet_schedule(&hp_sdc.task); in hp_sdc_kicker()
802 mod_timer(&hp_sdc.kicker, jiffies + HZ); in hp_sdc_kicker()
839 rwlock_init(&hp_sdc.lock); in hp_sdc_init()
840 rwlock_init(&hp_sdc.ibf_lock); in hp_sdc_init()
841 rwlock_init(&hp_sdc.rtq_lock); in hp_sdc_init()
842 rwlock_init(&hp_sdc.hook_lock); in hp_sdc_init()
844 hp_sdc.timer = NULL; in hp_sdc_init()
845 hp_sdc.hil = NULL; in hp_sdc_init()
846 hp_sdc.pup = NULL; in hp_sdc_init()
847 hp_sdc.cooked = NULL; in hp_sdc_init()
848 hp_sdc.im = HP_SDC_IM_MASK; /* Mask maskable irqs */ in hp_sdc_init()
849 hp_sdc.set_im = 1; in hp_sdc_init()
850 hp_sdc.wi = 0xff; in hp_sdc_init()
851 hp_sdc.r7[0] = 0xff; in hp_sdc_init()
852 hp_sdc.r7[1] = 0xff; in hp_sdc_init()
853 hp_sdc.r7[2] = 0xff; in hp_sdc_init()
854 hp_sdc.r7[3] = 0xff; in hp_sdc_init()
855 hp_sdc.ibf = 1; in hp_sdc_init()
857 memset(&hp_sdc.tq, 0, sizeof(hp_sdc.tq)); in hp_sdc_init()
859 hp_sdc.wcurr = -1; in hp_sdc_init()
860 hp_sdc.rcurr = -1; in hp_sdc_init()
861 hp_sdc.rqty = 0; in hp_sdc_init()
863 hp_sdc.dev_err = -ENODEV; in hp_sdc_init()
866 if (!hp_sdc.base_io) in hp_sdc_init()
870 if (!hp_sdc.irq) in hp_sdc_init()
873 hp_sdc.dev_err = -EBUSY; in hp_sdc_init()
877 if (request_region(hp_sdc.data_io, 2, hp_sdc_driver.name)) in hp_sdc_init()
882 if (request_irq(hp_sdc.irq, &hp_sdc_isr, IRQF_SHARED|IRQF_SAMPLE_RANDOM, in hp_sdc_init()
883 "HP SDC", &hp_sdc)) in hp_sdc_init()
887 if (request_irq(hp_sdc.nmi, &hp_sdc_nmisr, IRQF_SHARED, in hp_sdc_init()
888 "HP SDC NMI", &hp_sdc)) in hp_sdc_init()
892 (void *)hp_sdc.base_io, hp_sdc.irq, hp_sdc.nmi); in hp_sdc_init()
897 tasklet_init(&hp_sdc.task, hp_sdc_tasklet, 0); in hp_sdc_init()
913 init_timer(&hp_sdc.kicker); in hp_sdc_init()
914 hp_sdc.kicker.expires = jiffies + HZ; in hp_sdc_init()
915 hp_sdc.kicker.function = &hp_sdc_kicker; in hp_sdc_init()
916 add_timer(&hp_sdc.kicker); in hp_sdc_init()
918 hp_sdc.dev_err = 0; in hp_sdc_init()
921 free_irq(hp_sdc.irq, &hp_sdc); in hp_sdc_init()
923 release_region(hp_sdc.data_io, 2); in hp_sdc_init()
926 errstr, (void *)hp_sdc.base_io, hp_sdc.irq, hp_sdc.nmi); in hp_sdc_init()
927 hp_sdc.dev = NULL; in hp_sdc_init()
929 return hp_sdc.dev_err; in hp_sdc_init()
945 if (hp_sdc.dev != NULL) in hp_sdc_init_hppa()
948 hp_sdc.dev = d; in hp_sdc_init_hppa()
949 hp_sdc.irq = d->irq; in hp_sdc_init_hppa()
950 hp_sdc.nmi = d->aux_irq; in hp_sdc_init_hppa()
951 hp_sdc.base_io = d->hpa.start; in hp_sdc_init_hppa()
952 hp_sdc.data_io = d->hpa.start + 0x800; in hp_sdc_init_hppa()
953 hp_sdc.status_io = d->hpa.start + 0x801; in hp_sdc_init_hppa()
972 if (!hp_sdc.dev) in hp_sdc_exit()
975 write_lock_irq(&hp_sdc.lock); in hp_sdc_exit()
979 sdc_writeb(HP_SDC_CMD_SET_IM | HP_SDC_IM_MASK, hp_sdc.status_io); in hp_sdc_exit()
984 free_irq(hp_sdc.nmi, &hp_sdc); in hp_sdc_exit()
985 free_irq(hp_sdc.irq, &hp_sdc); in hp_sdc_exit()
986 write_unlock_irq(&hp_sdc.lock); in hp_sdc_exit()
988 del_timer(&hp_sdc.kicker); in hp_sdc_exit()
990 tasklet_kill(&hp_sdc.task); in hp_sdc_exit()
1014 hp_sdc.dev = NULL; in hp_sdc_register()
1015 hp_sdc.dev_err = 0; in hp_sdc_register()
1025 hp_sdc.irq = 1; in hp_sdc_register()
1026 hp_sdc.nmi = 7; in hp_sdc_register()
1027 hp_sdc.base_io = (unsigned long) 0xf0428000; in hp_sdc_register()
1028 hp_sdc.data_io = (unsigned long) hp_sdc.base_io + 1; in hp_sdc_register()
1029 hp_sdc.status_io = (unsigned long) hp_sdc.base_io + 3; in hp_sdc_register()
1032 if (!get_user(i, (unsigned char *)hp_sdc.data_io)) in hp_sdc_register()
1033 hp_sdc.dev = (void *)1; in hp_sdc_register()
1035 hp_sdc.dev_err = hp_sdc_init(); in hp_sdc_register()
1037 if (hp_sdc.dev == NULL) { in hp_sdc_register()
1039 return hp_sdc.dev_err; in hp_sdc_register()
1067 hp_sdc.r11 = tq_init_seq[4]; in hp_sdc_register()
1068 if (hp_sdc.r11 & HP_SDC_CFG_NEW) { in hp_sdc_register()
1082 hp_sdc.r7e = tq_init_seq[4]; in hp_sdc_register()
1083 HP_SDC_XTD_REV_STRINGS(hp_sdc.r7e & HP_SDC_XTD_REV, str) in hp_sdc_register()
1085 if (hp_sdc.r7e & HP_SDC_XTD_BEEPER) in hp_sdc_register()
1087 if (hp_sdc.r7e & HP_SDC_XTD_BBRTC) in hp_sdc_register()
1105 (hp_sdc.r11 & HP_SDC_CFG_REV) ? "3300" : "2564/3087"); in hp_sdc_register()