Lines Matching refs:hp_sdc
49 * Busy polling for IBF clear wastes CPU cycles and bus cycles. hp_sdc.ibf
53 * hp_sdc state. Whenever a register is written hp_sdc.ibf is set to 1.
56 * starting at 0x70 are kept track of in hp_sdc.wi, and .r7[], respectively,
64 #include <linux/hp_sdc.h>
112 static hp_i8042_sdc hp_sdc; /* All driver state is kept in here. */
120 write_lock_irqsave(&hp_sdc.ibf_lock, flags);
121 status = sdc_readb(hp_sdc.status_io);
123 hp_sdc.ibf = 0;
124 write_unlock_irqrestore(&hp_sdc.ibf_lock, flags);
131 return sdc_readb(hp_sdc.data_io);
138 write_lock_irqsave(&hp_sdc.ibf_lock, flags);
139 hp_sdc.ibf = 1;
141 hp_sdc.wi = 0xff;
142 sdc_writeb(val, hp_sdc.status_io);
143 write_unlock_irqrestore(&hp_sdc.ibf_lock, flags);
150 write_lock_irqsave(&hp_sdc.ibf_lock, flags);
151 hp_sdc.ibf = 1;
152 sdc_writeb(val, hp_sdc.data_io);
153 write_unlock_irqrestore(&hp_sdc.ibf_lock, flags);
165 lock = &hp_sdc.ibf_lock;
168 if (!hp_sdc.ibf) {
174 while (sdc_readb(hp_sdc.status_io) & HP_SDC_STATUS_IBF)
176 hp_sdc.ibf = 0;
186 read_lock(&hp_sdc.rtq_lock);
187 if (hp_sdc.rcurr < 0) {
188 read_unlock(&hp_sdc.rtq_lock);
191 curr = hp_sdc.tq[hp_sdc.rcurr];
192 read_unlock(&hp_sdc.rtq_lock);
196 hp_sdc.rqty -= 2;
197 do_gettimeofday(&hp_sdc.rtv);
199 if (hp_sdc.rqty <= 0) {
212 write_lock(&hp_sdc.rtq_lock);
213 hp_sdc.rcurr = -1;
214 hp_sdc.rqty = 0;
215 write_unlock(&hp_sdc.rtq_lock);
216 tasklet_schedule(&hp_sdc.task);
239 read_lock(&hp_sdc.hook_lock);
240 if (hp_sdc.timer != NULL)
241 hp_sdc.timer(irq, dev_id, status, data);
242 read_unlock(&hp_sdc.hook_lock);
251 read_lock(&hp_sdc.hook_lock);
252 if (hp_sdc.hil != NULL)
253 hp_sdc.hil(irq, dev_id, status, data);
254 read_unlock(&hp_sdc.hook_lock);
258 read_lock(&hp_sdc.hook_lock);
259 if (hp_sdc.pup != NULL)
260 hp_sdc.pup(irq, dev_id, status, data);
263 read_unlock(&hp_sdc.hook_lock);
267 read_lock(&hp_sdc.hook_lock);
268 if (hp_sdc.cooked != NULL)
269 hp_sdc.cooked(irq, dev_id, status, data);
270 read_unlock(&hp_sdc.hook_lock);
296 write_lock_irq(&hp_sdc.rtq_lock);
298 if (hp_sdc.rcurr >= 0) {
302 if (tv.tv_sec > hp_sdc.rtv.tv_sec)
305 if (tv.tv_usec - hp_sdc.rtv.tv_usec > HP_SDC_MAX_REG_DELAY) {
309 curr = hp_sdc.tq[hp_sdc.rcurr];
315 (int)(tv.tv_usec - hp_sdc.rtv.tv_usec));
316 curr->idx += hp_sdc.rqty;
317 hp_sdc.rqty = 0;
334 hp_sdc.rcurr = -1;
337 write_unlock_irq(&hp_sdc.rtq_lock);
349 write_lock(&hp_sdc.lock);
353 if (hp_sdc.ibf) {
355 if (hp_sdc.ibf)
361 if (hp_sdc.wcurr < 0)
362 hp_sdc.wcurr = 0;
363 read_lock_irq(&hp_sdc.rtq_lock);
364 if (hp_sdc.rcurr == hp_sdc.wcurr)
365 hp_sdc.wcurr++;
366 read_unlock_irq(&hp_sdc.rtq_lock);
367 if (hp_sdc.wcurr >= HP_SDC_QUEUE_LEN)
368 hp_sdc.wcurr = 0;
369 curridx = hp_sdc.wcurr;
371 if (hp_sdc.tq[curridx] != NULL)
374 while (++curridx != hp_sdc.wcurr) {
379 read_lock_irq(&hp_sdc.rtq_lock);
380 if (hp_sdc.rcurr == curridx) {
381 read_unlock_irq(&hp_sdc.rtq_lock);
384 read_unlock_irq(&hp_sdc.rtq_lock);
385 if (hp_sdc.tq[curridx] != NULL)
388 if (curridx == hp_sdc.wcurr) { /* There's nothing queued to do. */
391 hp_sdc.wcurr = curridx;
396 if (hp_sdc.set_im) {
397 hp_sdc_status_out8(hp_sdc.im | HP_SDC_CMD_SET_IM);
398 hp_sdc.set_im = 0;
402 if (hp_sdc.wcurr == -1)
405 curr = hp_sdc.tq[curridx];
409 hp_sdc.tq[curridx] = NULL;
411 hp_sdc.wcurr++;
412 if (hp_sdc.wcurr >= HP_SDC_QUEUE_LEN)
413 hp_sdc.wcurr = 0;
423 hp_sdc.tq[curridx] = NULL;
425 hp_sdc.wcurr++;
426 if (hp_sdc.wcurr >= HP_SDC_QUEUE_LEN)
427 hp_sdc.wcurr = 0;
479 w7[0] = (mask & 1) ? curr->seq[++idx] : hp_sdc.r7[0];
480 w7[1] = (mask & 2) ? curr->seq[++idx] : hp_sdc.r7[1];
481 w7[2] = (mask & 4) ? curr->seq[++idx] : hp_sdc.r7[2];
482 w7[3] = (mask & 8) ? curr->seq[++idx] : hp_sdc.r7[3];
484 if (hp_sdc.wi > 0x73 || hp_sdc.wi < 0x70 ||
485 w7[hp_sdc.wi - 0x70] == hp_sdc.r7[hp_sdc.wi - 0x70]) {
489 while (i < 4 && w7[i] == hp_sdc.r7[i])
494 hp_sdc.wi = 0x70 + i;
507 hp_sdc_data_out8(w7[hp_sdc.wi - 0x70]);
508 hp_sdc.r7[hp_sdc.wi - 0x70] = w7[hp_sdc.wi - 0x70];
509 hp_sdc.wi++; /* write index register autoincrements */
513 while ((i < 4) && w7[i] == hp_sdc.r7[i])
526 read_lock_irq(&hp_sdc.rtq_lock);
527 if (hp_sdc.rcurr >= 0) {
528 read_unlock_irq(&hp_sdc.rtq_lock);
531 read_unlock_irq(&hp_sdc.rtq_lock);
543 hp_sdc.rqty = curr->seq[curr->idx];
544 do_gettimeofday(&hp_sdc.rtv);
547 write_lock_irq(&hp_sdc.rtq_lock);
548 hp_sdc.rcurr = curridx;
549 write_unlock_irq(&hp_sdc.rtq_lock);
566 hp_sdc.tq[curridx] = NULL;
572 hp_sdc.wcurr++;
573 if (hp_sdc.wcurr >= HP_SDC_QUEUE_LEN)
574 hp_sdc.wcurr = 0;
579 if (!hp_sdc.ibf && limit++ < 20)
583 if (hp_sdc.wcurr >= 0)
584 tasklet_schedule(&hp_sdc.task);
585 write_unlock(&hp_sdc.lock);
602 if (hp_sdc.tq[i] == this)
610 if (hp_sdc.tq[i] == NULL) {
611 hp_sdc.tq[i] = this;
612 tasklet_schedule(&hp_sdc.task);
628 write_lock_irqsave(&hp_sdc.lock, flags);
630 write_unlock_irqrestore(&hp_sdc.lock,flags);
640 write_lock_irqsave(&hp_sdc.lock, flags);
645 if (hp_sdc.tq[i] == this)
646 hp_sdc.tq[i] = NULL;
648 write_unlock_irqrestore(&hp_sdc.lock, flags);
657 if (callback == NULL || hp_sdc.dev == NULL)
660 write_lock_irq(&hp_sdc.hook_lock);
661 if (hp_sdc.timer != NULL) {
662 write_unlock_irq(&hp_sdc.hook_lock);
666 hp_sdc.timer = callback;
668 hp_sdc.im &= ~HP_SDC_IM_FH;
669 hp_sdc.im &= ~HP_SDC_IM_PT;
670 hp_sdc.im &= ~HP_SDC_IM_TIMERS;
671 hp_sdc.set_im = 1;
672 write_unlock_irq(&hp_sdc.hook_lock);
674 tasklet_schedule(&hp_sdc.task);
681 if (callback == NULL || hp_sdc.dev == NULL)
684 write_lock_irq(&hp_sdc.hook_lock);
685 if (hp_sdc.hil != NULL) {
686 write_unlock_irq(&hp_sdc.hook_lock);
690 hp_sdc.hil = callback;
691 hp_sdc.im &= ~(HP_SDC_IM_HIL | HP_SDC_IM_RESET);
692 hp_sdc.set_im = 1;
693 write_unlock_irq(&hp_sdc.hook_lock);
695 tasklet_schedule(&hp_sdc.task);
702 if (callback == NULL || hp_sdc.dev == NULL)
705 write_lock_irq(&hp_sdc.hook_lock);
706 if (hp_sdc.cooked != NULL) {
707 write_unlock_irq(&hp_sdc.hook_lock);
712 hp_sdc.cooked = callback;
713 hp_sdc.im &= ~(HP_SDC_IM_HIL | HP_SDC_IM_RESET);
714 hp_sdc.set_im = 1;
715 write_unlock_irq(&hp_sdc.hook_lock);
717 tasklet_schedule(&hp_sdc.task);
724 write_lock_irq(&hp_sdc.hook_lock);
725 if ((callback != hp_sdc.timer) ||
726 (hp_sdc.timer == NULL)) {
727 write_unlock_irq(&hp_sdc.hook_lock);
732 hp_sdc.timer = NULL;
733 hp_sdc.im |= HP_SDC_IM_TIMERS;
734 hp_sdc.im |= HP_SDC_IM_FH;
735 hp_sdc.im |= HP_SDC_IM_PT;
736 hp_sdc.set_im = 1;
737 write_unlock_irq(&hp_sdc.hook_lock);
738 tasklet_schedule(&hp_sdc.task);
745 write_lock_irq(&hp_sdc.hook_lock);
746 if ((callback != hp_sdc.hil) ||
747 (hp_sdc.hil == NULL)) {
748 write_unlock_irq(&hp_sdc.hook_lock);
752 hp_sdc.hil = NULL;
754 if(hp_sdc.cooked == NULL) {
755 hp_sdc.im |= (HP_SDC_IM_HIL | HP_SDC_IM_RESET);
756 hp_sdc.set_im = 1;
758 write_unlock_irq(&hp_sdc.hook_lock);
759 tasklet_schedule(&hp_sdc.task);
766 write_lock_irq(&hp_sdc.hook_lock);
767 if ((callback != hp_sdc.cooked) ||
768 (hp_sdc.cooked == NULL)) {
769 write_unlock_irq(&hp_sdc.hook_lock);
773 hp_sdc.cooked = NULL;
775 if(hp_sdc.hil == NULL) {
776 hp_sdc.im |= (HP_SDC_IM_HIL | HP_SDC_IM_RESET);
777 hp_sdc.set_im = 1;
779 write_unlock_irq(&hp_sdc.hook_lock);
780 tasklet_schedule(&hp_sdc.task);
789 tasklet_schedule(&hp_sdc.task);
791 mod_timer(&hp_sdc.kicker, jiffies + HZ);
814 .name = "hp_sdc",
828 rwlock_init(&hp_sdc.lock);
829 rwlock_init(&hp_sdc.ibf_lock);
830 rwlock_init(&hp_sdc.rtq_lock);
831 rwlock_init(&hp_sdc.hook_lock);
833 hp_sdc.timer = NULL;
834 hp_sdc.hil = NULL;
835 hp_sdc.pup = NULL;
836 hp_sdc.cooked = NULL;
837 hp_sdc.im = HP_SDC_IM_MASK; /* Mask maskable irqs */
838 hp_sdc.set_im = 1;
839 hp_sdc.wi = 0xff;
840 hp_sdc.r7[0] = 0xff;
841 hp_sdc.r7[1] = 0xff;
842 hp_sdc.r7[2] = 0xff;
843 hp_sdc.r7[3] = 0xff;
844 hp_sdc.ibf = 1;
846 memset(&hp_sdc.tq, 0, sizeof(hp_sdc.tq));
848 hp_sdc.wcurr = -1;
849 hp_sdc.rcurr = -1;
850 hp_sdc.rqty = 0;
852 hp_sdc.dev_err = -ENODEV;
855 if (!hp_sdc.base_io)
859 if (!hp_sdc.irq)
862 hp_sdc.dev_err = -EBUSY;
866 if (request_region(hp_sdc.data_io, 2, hp_sdc_driver.name))
871 if (request_irq(hp_sdc.irq, &hp_sdc_isr, IRQF_SHARED|IRQF_SAMPLE_RANDOM,
872 "HP SDC", &hp_sdc))
876 if (request_irq(hp_sdc.nmi, &hp_sdc_nmisr, IRQF_SHARED,
877 "HP SDC NMI", &hp_sdc))
881 (void *)hp_sdc.base_io, hp_sdc.irq, hp_sdc.nmi);
886 tasklet_init(&hp_sdc.task, hp_sdc_tasklet, 0);
902 init_timer(&hp_sdc.kicker);
903 hp_sdc.kicker.expires = jiffies + HZ;
904 hp_sdc.kicker.function = &hp_sdc_kicker;
905 add_timer(&hp_sdc.kicker);
907 hp_sdc.dev_err = 0;
910 free_irq(hp_sdc.irq, &hp_sdc);
912 release_region(hp_sdc.data_io, 2);
915 errstr, (void *)hp_sdc.base_io, hp_sdc.irq, hp_sdc.nmi);
916 hp_sdc.dev = NULL;
918 return hp_sdc.dev_err;
934 if (hp_sdc.dev != NULL)
937 hp_sdc.dev = d;
938 hp_sdc.irq = d->irq;
939 hp_sdc.nmi = d->aux_irq;
940 hp_sdc.base_io = d->hpa.start;
941 hp_sdc.data_io = d->hpa.start + 0x800;
942 hp_sdc.status_io = d->hpa.start + 0x801;
961 if (!hp_sdc.dev)
964 write_lock_irq(&hp_sdc.lock);
968 sdc_writeb(HP_SDC_CMD_SET_IM | HP_SDC_IM_MASK, hp_sdc.status_io);
973 free_irq(hp_sdc.nmi, &hp_sdc);
974 free_irq(hp_sdc.irq, &hp_sdc);
975 write_unlock_irq(&hp_sdc.lock);
977 del_timer(&hp_sdc.kicker);
979 tasklet_kill(&hp_sdc.task);
1003 hp_sdc.dev = NULL;
1004 hp_sdc.dev_err = 0;
1014 hp_sdc.irq = 1;
1015 hp_sdc.nmi = 7;
1016 hp_sdc.base_io = (unsigned long) 0xf0428000;
1017 hp_sdc.data_io = (unsigned long) hp_sdc.base_io + 1;
1018 hp_sdc.status_io = (unsigned long) hp_sdc.base_io + 3;
1021 if (!get_user(i, (unsigned char *)hp_sdc.data_io))
1022 hp_sdc.dev = (void *)1;
1024 hp_sdc.dev_err = hp_sdc_init();
1026 if (hp_sdc.dev == NULL) {
1028 return hp_sdc.dev_err;
1056 hp_sdc.r11 = tq_init_seq[4];
1057 if (hp_sdc.r11 & HP_SDC_CFG_NEW) {
1071 hp_sdc.r7e = tq_init_seq[4];
1072 HP_SDC_XTD_REV_STRINGS(hp_sdc.r7e & HP_SDC_XTD_REV, str)
1074 if (hp_sdc.r7e & HP_SDC_XTD_BEEPER)
1076 if (hp_sdc.r7e & HP_SDC_XTD_BBRTC)
1094 (hp_sdc.r11 & HP_SDC_CFG_REV) ? "3300" : "2564/3087");