Deleted Added
full compact
pccard.c (102896) pccard.c (102923)
1/* $NetBSD: pcmcia.c,v 1.23 2000/07/28 19:17:02 drochner Exp $ */
1/* $NetBSD: pcmcia.c,v 1.23 2000/07/28 19:17:02 drochner Exp $ */
2/* $FreeBSD: head/sys/dev/pccard/pccard.c 102896 2002-09-03 11:24:25Z phk $ */
2/* $FreeBSD: head/sys/dev/pccard/pccard.c 102923 2002-09-04 06:53:37Z imp $ */
3
4/*
5 * Copyright (c) 1997 Marc Horowitz. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright

--- 701 unchanged lines hidden (view full) ---

712
713 /*
714 * Decrement the reference count, and power down the socket, if
715 * necessary.
716 */
717 pf->sc->sc_enabled_count--;
718}
719
3
4/*
5 * Copyright (c) 1997 Marc Horowitz. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright

--- 701 unchanged lines hidden (view full) ---

712
713 /*
714 * Decrement the reference count, and power down the socket, if
715 * necessary.
716 */
717 pf->sc->sc_enabled_count--;
718}
719
720#if 0
721/* XXX These functions are needed, but not like this XXX */
722int
723pccard_io_map(struct pccard_function *pf, int width, bus_addr_t offset,
724 bus_size_t size, struct pccard_io_handle *pcihp, int *windowp)
725{
726 int reg;
727
728 if (pccard_chip_io_map(pf->sc->pct, pf->sc->pch, width, offset, size,
729 pcihp, windowp))
730 return (1);
731
732 /*
733 * XXX in the multifunction multi-iospace-per-function case, this
734 * needs to cooperate with io_alloc to make sure that the spaces
735 * don't overlap, and that the ccr's are set correctly
736 */
737
738 if (pccard_mfc(pf->sc)) {
739 long tmp, iosize;
740
741 if (pf->pf_mfc_iomax == 0) {
742 pf->pf_mfc_iobase = pcihp->addr + offset;
743 pf->pf_mfc_iomax = pf->pf_mfc_iobase + size;
744 } else {
745 /* this makes the assumption that nothing overlaps */
746 if (pf->pf_mfc_iobase > pcihp->addr + offset)
747 pf->pf_mfc_iobase = pcihp->addr + offset;
748 if (pf->pf_mfc_iomax < pcihp->addr + offset + size)
749 pf->pf_mfc_iomax = pcihp->addr + offset + size;
750 }
751
752 tmp = pf->pf_mfc_iomax - pf->pf_mfc_iobase;
753 /* round up to nearest (2^n)-1 */
754 for (iosize = 1; iosize >= tmp; iosize <<= 1)
755 ;
756 iosize--;
757
758 pccard_ccr_write(pf, PCCARD_CCR_IOBASE0,
759 pf->pf_mfc_iobase & 0xff);
760 pccard_ccr_write(pf, PCCARD_CCR_IOBASE1,
761 (pf->pf_mfc_iobase >> 8) & 0xff);
762 pccard_ccr_write(pf, PCCARD_CCR_IOBASE2, 0);
763 pccard_ccr_write(pf, PCCARD_CCR_IOBASE3, 0);
764
765 pccard_ccr_write(pf, PCCARD_CCR_IOSIZE, iosize);
766
767 reg = pccard_ccr_read(pf, PCCARD_CCR_OPTION);
768 reg |= PCCARD_CCR_OPTION_ADDR_DECODE;
769 pccard_ccr_write(pf, PCCARD_CCR_OPTION, reg);
770 }
771 return (0);
772}
773
774void
775pccard_io_unmap(struct pccard_function *pf, int window)
776{
777
778 pccard_chip_io_unmap(pf->sc->pct, pf->sc->pch, window);
779
780 /* XXX Anything for multi-function cards? */
781}
782#endif
783
784/*
785 * simulate the old "probe" routine. In the new world order, the driver
786 * needs to grab devices while in the old they were assigned to the device by
787 * the pccardd process. These symbols are exported to the upper layers.
788 */
789static int
790pccard_compat_do_probe(device_t bus, device_t dev)
791{

--- 377 unchanged lines hidden (view full) ---

1169
1170 pccard_function_disable(pf);
1171}
1172
1173static void
1174pccard_intr(void *arg)
1175{
1176 struct pccard_function *pf = (struct pccard_function*) arg;
720/*
721 * simulate the old "probe" routine. In the new world order, the driver
722 * needs to grab devices while in the old they were assigned to the device by
723 * the pccardd process. These symbols are exported to the upper layers.
724 */
725static int
726pccard_compat_do_probe(device_t bus, device_t dev)
727{

--- 377 unchanged lines hidden (view full) ---

1105
1106 pccard_function_disable(pf);
1107}
1108
1109static void
1110pccard_intr(void *arg)
1111{
1112 struct pccard_function *pf = (struct pccard_function*) arg;
1177#ifdef COOKIE_FOR_WARNER
1178 int reg;
1113 int reg;
1114 int doisr = 1;
1179
1115
1180 if (pf->intr_handler == NULL)
1181 return;
1182
1183 /*
1116 /*
1184 * XXX The CCR_STATUS register bits used here are
1185 * only valid for multi function cards.
1117 * MFC cards know if they interrupted, so we have to ack the
1118 * interrupt and call the ISR. Non-MFC cards don't have these
1119 * bits, so they always get called. Many non-MFC cards have
1120 * this bit set always upon read, but some do not.
1121 *
1122 * We always ack the interrupt, even if there's no ISR
1123 * for the card. This is done on the theory that acking
1124 * the interrupt will pacify the card enough to keep an
1125 * interrupt storm from happening. Of course this won't
1126 * help in the non-MFC case.
1186 */
1127 */
1187 reg = pccard_ccr_read(pf, PCCARD_CCR_STATUS);
1188 if (reg & PCCARD_CCR_STATUS_INTR) {
1189 pccard_ccr_write(pf, PCCARD_CCR_STATUS,
1190 reg & ~PCCARD_CCR_STATUS_INTR);
1191 pf->intr_handler(pf->intr_handler_arg);
1128 if (pccard_mfc(pf->sc)) {
1129 reg = pccard_ccr_read(pf, PCCARD_CCR_STATUS);
1130 if (reg & PCCARD_CCR_STATUS_INTR)
1131 pccard_ccr_write(pf, PCCARD_CCR_STATUS,
1132 reg & ~PCCARD_CCR_STATUS_INTR);
1133 else
1134 doisr = 0;
1192 }
1135 }
1193#else
1194 if (pf->intr_handler == NULL)
1195 return;
1196 pf->intr_handler(pf->intr_handler_arg);
1197#endif
1136 if (pf->intr_handler != NULL && doisr)
1137 pf->intr_handler(pf->intr_handler_arg);
1198}
1199
1200static int
1201pccard_setup_intr(device_t dev, device_t child, struct resource *irq,
1202 int flags, driver_intr_t *intr, void *arg, void **cookiep)
1203{
1204 struct pccard_softc *sc = PCCARD_SOFTC(dev);
1205 struct pccard_ivar *ivar = PCCARD_IVAR(child);

--- 96 unchanged lines hidden ---
1138}
1139
1140static int
1141pccard_setup_intr(device_t dev, device_t child, struct resource *irq,
1142 int flags, driver_intr_t *intr, void *arg, void **cookiep)
1143{
1144 struct pccard_softc *sc = PCCARD_SOFTC(dev);
1145 struct pccard_ivar *ivar = PCCARD_IVAR(child);

--- 96 unchanged lines hidden ---