pccard.c (150097) | pccard.c (150098) |
---|---|
1/* $NetBSD: pcmcia.c,v 1.23 2000/07/28 19:17:02 drochner Exp $ */ 2 3/*- 4 * Copyright (c) 1997 Marc Horowitz. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 16 unchanged lines hidden (view full) --- 25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32#include <sys/cdefs.h> | 1/* $NetBSD: pcmcia.c,v 1.23 2000/07/28 19:17:02 drochner Exp $ */ 2 3/*- 4 * Copyright (c) 1997 Marc Horowitz. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 16 unchanged lines hidden (view full) --- 25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32#include <sys/cdefs.h> |
33__FBSDID("$FreeBSD: head/sys/dev/pccard/pccard.c 150097 2005-09-13 17:49:47Z imp $"); | 33__FBSDID("$FreeBSD: head/sys/dev/pccard/pccard.c 150098 2005-09-13 17:56:36Z imp $"); |
34 35#include <sys/param.h> 36#include <sys/systm.h> 37#include <sys/malloc.h> 38#include <sys/module.h> 39#include <sys/kernel.h> 40#include <sys/queue.h> 41#include <sys/sysctl.h> --- 1267 unchanged lines hidden (view full) --- 1309static int 1310pccard_deactivate_resource(device_t brdev, device_t child, int type, 1311 int rid, struct resource *r) 1312{ 1313 /* XXX undo pccard_activate_resource? XXX */ 1314 return (bus_generic_deactivate_resource(brdev, child, type, rid, r)); 1315} 1316 | 34 35#include <sys/param.h> 36#include <sys/systm.h> 37#include <sys/malloc.h> 38#include <sys/module.h> 39#include <sys/kernel.h> 40#include <sys/queue.h> 41#include <sys/sysctl.h> --- 1267 unchanged lines hidden (view full) --- 1309static int 1310pccard_deactivate_resource(device_t brdev, device_t child, int type, 1311 int rid, struct resource *r) 1312{ 1313 /* XXX undo pccard_activate_resource? XXX */ 1314 return (bus_generic_deactivate_resource(brdev, child, type, rid, r)); 1315} 1316 |
1317static int 1318pccard_attr_read_impl(device_t brdev, device_t child, uint32_t offset, 1319 uint8_t *val) 1320{ 1321 struct pccard_ivar *devi = PCCARD_IVAR(child); 1322 struct pccard_function *pf = devi->pf; 1323 1324 /* 1325 * Optimization. Most of the time, devices want to access 1326 * the same page of the attribute memory that the CCR is in. 1327 * We take advantage of this fact here. 1328 */ 1329 if (offset / PCCARD_MEM_PAGE_SIZE == 1330 pf->ccr_base / PCCARD_MEM_PAGE_SIZE) 1331 *val = bus_space_read_1(pf->pf_ccrt, pf->pf_ccrh, 1332 offset % PCCARD_MEM_PAGE_SIZE); 1333 else { 1334 CARD_SET_MEMORY_OFFSET(brdev, child, pf->ccr_rid, offset, 1335 &offset); 1336 *val = bus_space_read_1(pf->pf_ccrt, pf->pf_ccrh, offset); 1337 CARD_SET_MEMORY_OFFSET(brdev, child, pf->ccr_rid, pf->ccr_base, 1338 &offset); 1339 } 1340 return 0; 1341} 1342 1343static int 1344pccard_attr_write_impl(device_t brdev, device_t child, uint32_t offset, 1345 uint8_t val) 1346{ 1347 struct pccard_ivar *devi = PCCARD_IVAR(child); 1348 struct pccard_function *pf = devi->pf; 1349 1350 /* 1351 * Optimization. Most of the time, devices want to access 1352 * the same page of the attribute memory that the CCR is in. 1353 * We take advantage of this fact here. 1354 */ 1355 if (offset / PCCARD_MEM_PAGE_SIZE == 1356 pf->ccr_base / PCCARD_MEM_PAGE_SIZE) 1357 bus_space_write_1(pf->pf_ccrt, pf->pf_ccrh, 1358 offset % PCCARD_MEM_PAGE_SIZE, val); 1359 else { 1360 CARD_SET_MEMORY_OFFSET(brdev, child, pf->ccr_rid, offset, 1361 &offset); 1362 bus_space_write_1(pf->pf_ccrt, pf->pf_ccrh, offset, val); 1363 CARD_SET_MEMORY_OFFSET(brdev, child, pf->ccr_rid, pf->ccr_base, 1364 &offset); 1365 } 1366 1367 return 0; 1368} 1369 1370static int 1371pccard_ccr_read_impl(device_t brdev, device_t child, uint32_t offset, 1372 uint8_t *val) 1373{ 1374 struct pccard_ivar *devi = PCCARD_IVAR(child); 1375 1376 *val = pccard_ccr_read(devi->pf, offset); 1377 device_printf(child, "ccr_read of %#x (%#x) is %#x\n", offset, 1378 devi->pf->pf_ccr_offset, *val); 1379 return 0; 1380} 1381 1382static int 1383pccard_ccr_write_impl(device_t brdev, device_t child, uint32_t offset, 1384 uint8_t val) 1385{ 1386 struct pccard_ivar *devi = PCCARD_IVAR(child); 1387 struct pccard_function *pf = devi->pf; 1388 1389 /* 1390 * Can't use pccard_ccr_write since client drivers may access 1391 * registers not contained in the 'mask' if they are non-standard. 1392 */ 1393 device_printf(child, "ccr_write of %#x to %#x (%#x)\n", val, offset, 1394 devi->pf->pf_ccr_offset); 1395 bus_space_write_1(pf->pf_ccrt, pf->pf_ccrh, pf->pf_ccr_offset + offset, 1396 val); 1397 return 0; 1398} 1399 1400 |
|
1317static device_method_t pccard_methods[] = { 1318 /* Device interface */ 1319 DEVMETHOD(device_probe, pccard_probe), 1320 DEVMETHOD(device_attach, pccard_attach), 1321 DEVMETHOD(device_detach, pccard_detach), 1322 DEVMETHOD(device_shutdown, bus_generic_shutdown), 1323 DEVMETHOD(device_suspend, pccard_suspend), 1324 DEVMETHOD(device_resume, pccard_resume), --- 16 unchanged lines hidden (view full) --- 1341 DEVMETHOD(bus_child_pnpinfo_str, pccard_child_pnpinfo_str), 1342 DEVMETHOD(bus_child_location_str, pccard_child_location_str), 1343 1344 /* Card Interface */ 1345 DEVMETHOD(card_set_res_flags, pccard_set_res_flags), 1346 DEVMETHOD(card_set_memory_offset, pccard_set_memory_offset), 1347 DEVMETHOD(card_attach_card, pccard_attach_card), 1348 DEVMETHOD(card_detach_card, pccard_detach_card), | 1401static device_method_t pccard_methods[] = { 1402 /* Device interface */ 1403 DEVMETHOD(device_probe, pccard_probe), 1404 DEVMETHOD(device_attach, pccard_attach), 1405 DEVMETHOD(device_detach, pccard_detach), 1406 DEVMETHOD(device_shutdown, bus_generic_shutdown), 1407 DEVMETHOD(device_suspend, pccard_suspend), 1408 DEVMETHOD(device_resume, pccard_resume), --- 16 unchanged lines hidden (view full) --- 1425 DEVMETHOD(bus_child_pnpinfo_str, pccard_child_pnpinfo_str), 1426 DEVMETHOD(bus_child_location_str, pccard_child_location_str), 1427 1428 /* Card Interface */ 1429 DEVMETHOD(card_set_res_flags, pccard_set_res_flags), 1430 DEVMETHOD(card_set_memory_offset, pccard_set_memory_offset), 1431 DEVMETHOD(card_attach_card, pccard_attach_card), 1432 DEVMETHOD(card_detach_card, pccard_detach_card), |
1433 DEVMETHOD(card_do_product_lookup, pccard_do_product_lookup), |
|
1349 DEVMETHOD(card_compat_do_probe, pccard_compat_do_probe), 1350 DEVMETHOD(card_compat_do_attach, pccard_compat_do_attach), | 1434 DEVMETHOD(card_compat_do_probe, pccard_compat_do_probe), 1435 DEVMETHOD(card_compat_do_attach, pccard_compat_do_attach), |
1351 DEVMETHOD(card_do_product_lookup, pccard_do_product_lookup), | |
1352 DEVMETHOD(card_cis_scan, pccard_scan_cis), | 1436 DEVMETHOD(card_cis_scan, pccard_scan_cis), |
1437 DEVMETHOD(card_attr_read, pccard_attr_read_impl), 1438 DEVMETHOD(card_attr_write, pccard_attr_write_impl), 1439 DEVMETHOD(card_ccr_read, pccard_ccr_read_impl), 1440 DEVMETHOD(card_ccr_write, pccard_ccr_write_impl), |
|
1353 1354 { 0, 0 } 1355}; 1356 1357static driver_t pccard_driver = { 1358 "pccard", 1359 pccard_methods, 1360 sizeof(struct pccard_softc) 1361}; 1362 1363devclass_t pccard_devclass; 1364 1365/* Maybe we need to have a slot device? */ 1366DRIVER_MODULE(pccard, pcic, pccard_driver, pccard_devclass, 0, 0); 1367DRIVER_MODULE(pccard, cbb, pccard_driver, pccard_devclass, 0, 0); 1368MODULE_VERSION(pccard, 1); | 1441 1442 { 0, 0 } 1443}; 1444 1445static driver_t pccard_driver = { 1446 "pccard", 1447 pccard_methods, 1448 sizeof(struct pccard_softc) 1449}; 1450 1451devclass_t pccard_devclass; 1452 1453/* Maybe we need to have a slot device? */ 1454DRIVER_MODULE(pccard, pcic, pccard_driver, pccard_devclass, 0, 0); 1455DRIVER_MODULE(pccard, cbb, pccard_driver, pccard_devclass, 0, 0); 1456MODULE_VERSION(pccard, 1); |