Lines Matching +full:rc +full:- +full:map +full:- +full:name

13  * 2. The name of the author may not be used to endorse or promote products
30 * HP-HIL Technical Reference Manual. Hewlett Packard Product No. 45918A
35 * Some access methods and an ISR is defined by the sub-driver
39 * sub-driver and invoked directly, must check for record
48 * at some point with a sub-driver-specific mechanism.)
92 mlc->di_map[j] = -1; in hil_mlc_clear_di_map()
97 memset(&mlc->di_scratch, 0, sizeof(mlc->di_scratch)); in hil_mlc_clear_di_scratch()
102 memcpy(&mlc->di[idx], &mlc->di_scratch, sizeof(mlc->di_scratch)); in hil_mlc_copy_di_scratch()
112 /* In-use slots are not eligible. */ in hil_mlc_match_di_scratch()
114 if (mlc->di_map[j] == idx) in hil_mlc_match_di_scratch()
120 if (!memcmp(mlc->di + idx, &mlc->di_scratch, in hil_mlc_match_di_scratch()
121 sizeof(mlc->di_scratch))) in hil_mlc_match_di_scratch()
124 return idx >= HIL_MLC_DEVMEM ? -1 : idx; in hil_mlc_match_di_scratch()
131 /* TODO: Pick all-zero slots first, failing that, in hil_mlc_find_free_di()
138 if (mlc->di_map[j] == idx) in hil_mlc_find_free_di()
156 if (mlc->di_map[j] == idx) in hil_mlc_clean_serio_map()
160 mlc->serio_map[idx].di_revmap = -1; in hil_mlc_clean_serio_map()
171 did = (mlc->ipacket[0] & HIL_PKT_ADDR_MASK) >> 8; in hil_mlc_send_polls()
172 serio = did ? mlc->serio[mlc->di_map[did - 1]] : NULL; in hil_mlc_send_polls()
173 drv = (serio != NULL) ? serio->drv : NULL; in hil_mlc_send_polls()
175 while (mlc->icount < 15 - i) { in hil_mlc_send_polls()
178 p = mlc->ipacket[i]; in hil_mlc_send_polls()
180 if (drv && drv->interrupt) { in hil_mlc_send_polls()
181 drv->interrupt(serio, 0, 0); in hil_mlc_send_polls()
182 drv->interrupt(serio, HIL_ERR_INT >> 16, 0); in hil_mlc_send_polls()
183 drv->interrupt(serio, HIL_PKT_CMD >> 8, 0); in hil_mlc_send_polls()
184 drv->interrupt(serio, HIL_CMD_POL + cnt, 0); in hil_mlc_send_polls()
188 serio = did ? mlc->serio[mlc->di_map[did-1]] : NULL; in hil_mlc_send_polls()
189 drv = (serio != NULL) ? serio->drv : NULL; in hil_mlc_send_polls()
196 if (drv && drv->interrupt) { in hil_mlc_send_polls()
197 drv->interrupt(serio, (p >> 24), 0); in hil_mlc_send_polls()
198 drv->interrupt(serio, (p >> 16) & 0xff, 0); in hil_mlc_send_polls()
199 drv->interrupt(serio, (p >> 8) & ~HIL_PKT_ADDR_MASK, 0); in hil_mlc_send_polls()
200 drv->interrupt(serio, p & 0xff, 0); in hil_mlc_send_polls()
242 int rc; in hilse_match() local
244 rc = hil_mlc_match_di_scratch(mlc); in hilse_match()
245 if (rc == -1) { in hilse_match()
246 rc = hil_mlc_find_free_di(mlc); in hilse_match()
247 if (rc == -1) in hilse_match()
251 printk(KERN_DEBUG PREFIX "new in slot %i\n", rc); in hilse_match()
253 hil_mlc_copy_di_scratch(mlc, rc); in hilse_match()
254 mlc->di_map[mlc->ddi] = rc; in hilse_match()
255 mlc->serio_map[rc].di_revmap = mlc->ddi; in hilse_match()
257 serio_rescan(mlc->serio[rc]); in hilse_match()
258 return -1; in hilse_match()
261 mlc->di_map[mlc->ddi] = rc; in hilse_match()
263 printk(KERN_DEBUG PREFIX "same in slot %i\n", rc); in hilse_match()
265 mlc->serio_map[rc].di_revmap = mlc->ddi; in hilse_match()
279 if (mlc->lcv && (now - mlc->lcv_time) < 5) in hilse_init_lcv()
280 return -1; in hilse_init_lcv()
282 mlc->lcv_time = now; in hilse_init_lcv()
283 mlc->lcv = 0; in hilse_init_lcv()
290 return mlc->lcv++ >= lim ? -1 : 0; in hilse_inc_lcv()
296 mlc->lcv = val;
302 /* Management of the discovered device index (zero based, -1 means no devs) */
305 mlc->ddi = val; in hilse_set_ddi()
313 mlc->ddi--; in hilse_dec_ddi()
314 if (mlc->ddi <= -1) { in hilse_dec_ddi()
315 mlc->ddi = -1; in hilse_dec_ddi()
317 return -1; in hilse_dec_ddi()
319 hil_mlc_clear_di_map(mlc, mlc->ddi + 1); in hilse_dec_ddi()
326 BUG_ON(mlc->ddi >= 6); in hilse_inc_ddi()
327 mlc->ddi++; in hilse_inc_ddi()
341 if (mlc->ipacket[0] & HIL_PKT_CMD) in hilse_take_idd()
346 if (((mlc->ipacket[i] & HIL_PKT_ADDR_MASK) == in hilse_take_idd()
347 (mlc->ipacket[0] & HIL_PKT_ADDR_MASK)) && in hilse_take_idd()
348 (mlc->ipacket[i] & HIL_PKT_CMD) && in hilse_take_idd()
349 ((mlc->ipacket[i] & HIL_PKT_DATA_MASK) == HIL_CMD_IDD)) in hilse_take_idd()
357 if (mlc->ipacket[i]) in hilse_take_idd()
364 mlc->di_scratch.idd[i] = in hilse_take_idd()
365 mlc->ipacket[i] & HIL_PKT_DATA_MASK; in hilse_take_idd()
368 if (mlc->di_scratch.idd[1] & HIL_IDD_HEADER_RSC) in hilse_take_idd()
371 if (mlc->di_scratch.idd[1] & HIL_IDD_HEADER_EXD) in hilse_take_idd()
377 mlc->ddi--; in hilse_take_idd()
379 return -1; /* This should send us off to ACF */ in hilse_take_idd()
387 mlc->di_scratch.rsc[i] = in hilse_take_rsc()
388 mlc->ipacket[i] & HIL_PKT_DATA_MASK; in hilse_take_rsc()
391 if (mlc->di_scratch.idd[1] & HIL_IDD_HEADER_EXD) in hilse_take_rsc()
402 mlc->di_scratch.exd[i] = in hilse_take_exd()
403 mlc->ipacket[i] & HIL_PKT_DATA_MASK; in hilse_take_exd()
406 if (mlc->di_scratch.exd[0] & HIL_EXD_HEADER_RNM) in hilse_take_exd()
417 mlc->di_scratch.rnm[i] = in hilse_take_rnm()
418 mlc->ipacket[i] & HIL_PKT_DATA_MASK; in hilse_take_rnm()
420 printk(KERN_INFO PREFIX "Device name gotten: %16s\n", in hilse_take_rnm()
421 mlc->di_scratch.rnm); in hilse_take_rnm()
429 if (mlc->opercnt == 0) in hilse_operate()
431 mlc->opercnt = 1; in hilse_operate()
438 mlc->opercnt = 0; in hilse_operate()
487 FUNC(hilse_set_ddi, -1, HILSEN_NEXT, 0, 0)
565 FUNC(hilse_set_ddi, -1, HILSEN_NEXT, 0, 0)
586 switch (node->act) { in hilse_setup_input()
588 mlc->imatch = node->object.packet; in hilse_setup_input()
589 mlc->imatch |= ((mlc->ddi + 2) << HIL_PKT_ADDR_SHIFT); in hilse_setup_input()
592 mlc->imatch = node->object.packet; in hilse_setup_input()
593 mlc->imatch |= ((mlc->ddi + 1) << HIL_PKT_ADDR_SHIFT); in hilse_setup_input()
596 mlc->imatch = node->object.packet; in hilse_setup_input()
599 mlc->imatch = 0; in hilse_setup_input()
604 mlc->istarted = 1; in hilse_setup_input()
605 mlc->intimeout = usecs_to_jiffies(node->arg); in hilse_setup_input()
606 mlc->instart = jiffies; in hilse_setup_input()
607 mlc->icount = 15; in hilse_setup_input()
608 memset(mlc->ipacket, 0, 16 * sizeof(hil_packet)); in hilse_setup_input()
609 BUG_ON(down_trylock(&mlc->isem)); in hilse_setup_input()
625 if (mlc->seidx && mlc->seidx != seidx && in hilse_donode()
626 mlc->seidx != 41 && mlc->seidx != 42 && mlc->seidx != 43) { in hilse_donode()
627 printk(KERN_DEBUG PREFIX "z%i \n {%i}", doze, mlc->seidx); in hilse_donode()
631 seidx = mlc->seidx; in hilse_donode()
633 node = hil_mlc_se + mlc->seidx; in hilse_donode()
635 switch (node->act) { in hilse_donode()
636 int rc; in hilse_donode() local
640 BUG_ON(node->object.func == NULL); in hilse_donode()
641 rc = node->object.func(mlc, node->arg); in hilse_donode()
642 nextidx = (rc > 0) ? node->ugly : in hilse_donode()
643 ((rc < 0) ? node->bad : node->good); in hilse_donode()
645 nextidx = rc; in hilse_donode()
653 write_lock_irqsave(&mlc->lock, flags); in hilse_donode()
654 rc = mlc->in(mlc, node->arg); in hilse_donode()
655 if (rc == 2) { in hilse_donode()
658 write_unlock_irqrestore(&mlc->lock, flags); in hilse_donode()
661 if (rc == 1) in hilse_donode()
662 nextidx = node->ugly; in hilse_donode()
663 else if (rc == 0) in hilse_donode()
664 nextidx = node->good; in hilse_donode()
666 nextidx = node->bad; in hilse_donode()
667 mlc->istarted = 0; in hilse_donode()
668 write_unlock_irqrestore(&mlc->lock, flags); in hilse_donode()
672 write_lock_irqsave(&mlc->lock, flags); in hilse_donode()
673 pack = node->object.packet; in hilse_donode()
674 pack |= ((mlc->ddi + 1) << HIL_PKT_ADDR_SHIFT); in hilse_donode()
678 write_lock_irqsave(&mlc->lock, flags); in hilse_donode()
679 pack = node->object.packet; in hilse_donode()
680 pack |= ((mlc->ddi + 2) << HIL_PKT_ADDR_SHIFT); in hilse_donode()
684 write_lock_irqsave(&mlc->lock, flags); in hilse_donode()
685 pack = node->object.packet; in hilse_donode()
687 if (!mlc->istarted) { in hilse_donode()
689 if ((node + 1)->act & HILSE_IN) in hilse_donode()
693 write_unlock_irqrestore(&mlc->lock, flags); in hilse_donode()
695 if (down_trylock(&mlc->osem)) { in hilse_donode()
699 up(&mlc->osem); in hilse_donode()
701 write_lock_irqsave(&mlc->lock, flags); in hilse_donode()
702 if (!mlc->ostarted) { in hilse_donode()
703 mlc->ostarted = 1; in hilse_donode()
704 mlc->opacket = pack; in hilse_donode()
705 rc = mlc->out(mlc); in hilse_donode()
707 write_unlock_irqrestore(&mlc->lock, flags); in hilse_donode()
708 if (rc) { in hilse_donode()
714 mlc->ostarted = 0; in hilse_donode()
715 mlc->instart = jiffies; in hilse_donode()
716 write_unlock_irqrestore(&mlc->lock, flags); in hilse_donode()
721 write_lock_irqsave(&mlc->lock, flags); in hilse_donode()
722 rc = mlc->cts(mlc); in hilse_donode()
723 nextidx = rc ? node->bad : node->good; in hilse_donode()
724 write_unlock_irqrestore(&mlc->lock, flags); in hilse_donode()
725 if (rc) { in hilse_donode()
746 if (time_after(now, mlc->instart + mlc->intimeout)) in hilse_donode()
748 mod_timer(&hil_mlcs_kicker, mlc->instart + mlc->intimeout); in hilse_donode()
756 mlc->seidx += nextidx & HILSEN_MASK; in hilse_donode()
758 mlc->seidx -= nextidx & HILSEN_MASK; in hilse_donode()
760 mlc->seidx = nextidx & HILSEN_MASK; in hilse_donode()
778 if (mlc->seidx != 41 && in hil_mlcs_process()
779 mlc->seidx != 42 && in hil_mlcs_process()
780 mlc->seidx != 43) in hil_mlcs_process()
793 /* could not send packet - stop immediately. */ in hil_mlcs_timer()
794 pr_warn(PREFIX "HIL seems stuck - Disabling HIL MLC.\n"); in hil_mlcs_timer()
800 /* Re-insert the periodic task. */ in hil_mlcs_timer()
809 struct hil_mlc_serio_map *map; in hil_mlc_serio_write() local
814 map = serio->port_data; in hil_mlc_serio_write()
815 BUG_ON(map == NULL); in hil_mlc_serio_write()
817 mlc = map->mlc; in hil_mlc_serio_write()
820 mlc->serio_opacket[map->didx] |= in hil_mlc_serio_write()
821 ((hil_packet)c) << (8 * (3 - mlc->serio_oidx[map->didx])); in hil_mlc_serio_write()
823 if (mlc->serio_oidx[map->didx] >= 3) { in hil_mlc_serio_write()
825 if (!(mlc->serio_opacket[map->didx] & HIL_PKT_CMD)) in hil_mlc_serio_write()
826 return -EIO; in hil_mlc_serio_write()
827 switch (mlc->serio_opacket[map->didx] & HIL_PKT_DATA_MASK) { in hil_mlc_serio_write()
829 idx = mlc->di[map->didx].idd; in hil_mlc_serio_write()
832 idx = mlc->di[map->didx].rsc; in hil_mlc_serio_write()
835 idx = mlc->di[map->didx].exd; in hil_mlc_serio_write()
838 idx = mlc->di[map->didx].rnm; in hil_mlc_serio_write()
843 mlc->serio_oidx[map->didx] = 0; in hil_mlc_serio_write()
844 mlc->serio_opacket[map->didx] = 0; in hil_mlc_serio_write()
847 mlc->serio_oidx[map->didx]++; in hil_mlc_serio_write()
848 return -EIO; in hil_mlc_serio_write()
850 drv = serio->drv; in hil_mlc_serio_write()
855 last--; in hil_mlc_serio_write()
858 drv->interrupt(serio, 0, 0); in hil_mlc_serio_write()
859 drv->interrupt(serio, HIL_ERR_INT >> 16, 0); in hil_mlc_serio_write()
860 drv->interrupt(serio, 0, 0); in hil_mlc_serio_write()
861 drv->interrupt(serio, *idx, 0); in hil_mlc_serio_write()
864 drv->interrupt(serio, 0, 0); in hil_mlc_serio_write()
865 drv->interrupt(serio, HIL_ERR_INT >> 16, 0); in hil_mlc_serio_write()
866 drv->interrupt(serio, HIL_PKT_CMD >> 8, 0); in hil_mlc_serio_write()
867 drv->interrupt(serio, *idx, 0); in hil_mlc_serio_write()
869 mlc->serio_oidx[map->didx] = 0; in hil_mlc_serio_write()
870 mlc->serio_opacket[map->didx] = 0; in hil_mlc_serio_write()
877 struct hil_mlc_serio_map *map; in hil_mlc_serio_open() local
881 return -EBUSY; in hil_mlc_serio_open()
883 map = serio->port_data; in hil_mlc_serio_open()
884 BUG_ON(map == NULL); in hil_mlc_serio_open()
886 mlc = map->mlc; in hil_mlc_serio_open()
894 struct hil_mlc_serio_map *map; in hil_mlc_serio_close() local
897 map = serio->port_data; in hil_mlc_serio_close()
898 BUG_ON(map == NULL); in hil_mlc_serio_close()
900 mlc = map->mlc; in hil_mlc_serio_close()
904 serio->drv = NULL; in hil_mlc_serio_close()
922 mlc->istarted = 0; in hil_mlc_register()
923 mlc->ostarted = 0; in hil_mlc_register()
925 rwlock_init(&mlc->lock); in hil_mlc_register()
926 sema_init(&mlc->osem, 1); in hil_mlc_register()
928 sema_init(&mlc->isem, 1); in hil_mlc_register()
929 mlc->icount = -1; in hil_mlc_register()
930 mlc->imatch = 0; in hil_mlc_register()
932 mlc->opercnt = 0; in hil_mlc_register()
934 sema_init(&(mlc->csem), 0); in hil_mlc_register()
942 mlc->serio[i] = mlc_serio; in hil_mlc_register()
943 if (!mlc->serio[i]) { in hil_mlc_register()
944 for (; i >= 0; i--) in hil_mlc_register()
945 kfree(mlc->serio[i]); in hil_mlc_register()
946 return -ENOMEM; in hil_mlc_register()
948 snprintf(mlc_serio->name, sizeof(mlc_serio->name)-1, "HIL_SERIO%d", i); in hil_mlc_register()
949 snprintf(mlc_serio->phys, sizeof(mlc_serio->phys)-1, "HIL%d", i); in hil_mlc_register()
950 mlc_serio->id = hil_mlc_serio_id; in hil_mlc_register()
951 mlc_serio->id.id = i; /* HIL port no. */ in hil_mlc_register()
952 mlc_serio->write = hil_mlc_serio_write; in hil_mlc_register()
953 mlc_serio->open = hil_mlc_serio_open; in hil_mlc_register()
954 mlc_serio->close = hil_mlc_serio_close; in hil_mlc_register()
955 mlc_serio->port_data = &(mlc->serio_map[i]); in hil_mlc_register()
956 mlc->serio_map[i].mlc = mlc; in hil_mlc_register()
957 mlc->serio_map[i].didx = i; in hil_mlc_register()
958 mlc->serio_map[i].di_revmap = -1; in hil_mlc_register()
959 mlc->serio_opacket[i] = 0; in hil_mlc_register()
960 mlc->serio_oidx[i] = 0; in hil_mlc_register()
964 mlc->tasklet = &hil_mlcs_tasklet; in hil_mlc_register()
967 list_add_tail(&mlc->list, &hil_mlcs); in hil_mlc_register()
968 mlc->seidx = HILSEN_START; in hil_mlc_register()
991 return -ENODEV; in hil_mlc_unregister()
998 serio_unregister_port(mlc->serio[i]); in hil_mlc_unregister()
999 mlc->serio[i] = NULL; in hil_mlc_unregister()