Change the interface to pccard_function_init. The interface is such
that it looks for an acceptible one. Once it finds it, it should set the resources for the device. I say "should" because I've not written that. Also set an ivar for the child of pccard. Minor fix to the attach message printed, we lose the slot number, which I'll have to restore later. Adjust the pccard ivar so that we can save the function that corresponds to this driver so we can enable and disable it more easily. Save a pointer to the function so we know what we're dealing with. There should be some way for the driver to specify which cfg it wants to activate. For now the pccard_function_init function just picks one, but we'll have to revisit this going forward. I'm not doing it now because I'd need some way to activate the card many times and I'm not sure that is desirable or even safe with some cards.
This commit is contained in:
parent
3700a99cae
commit
45713b37cd
@ -95,6 +95,7 @@ pccard_attach_card(device_t dev)
|
||||
{
|
||||
struct pccard_softc *sc = PCCARD_SOFTC(dev);
|
||||
struct pccard_function *pf;
|
||||
struct pccard_ivar *ivar;
|
||||
device_t child;
|
||||
int attached;
|
||||
|
||||
@ -147,7 +148,6 @@ pccard_attach_card(device_t dev)
|
||||
STAILQ_FOREACH(pf, &sc->card.pf_head, pf_list) {
|
||||
if (STAILQ_EMPTY(&pf->cfe_head))
|
||||
continue;
|
||||
/* XXX */
|
||||
/*
|
||||
* In NetBSD, the drivers are responsible for activating
|
||||
* each function of a card. I think that in FreeBSD we
|
||||
@ -160,8 +160,11 @@ pccard_attach_card(device_t dev)
|
||||
*
|
||||
*/
|
||||
device_printf(dev, "Starting to attach....\n");
|
||||
/* XXX Need ivars XXXimpXXX */
|
||||
ivar = malloc(sizeof(struct pccard_ivar), M_DEVBUF, M_WAITOK);
|
||||
child = device_add_child(dev, NULL, -1);
|
||||
pccard_function_init(pf, STAILQ_FIRST(&pf->cfe_head));
|
||||
device_set_ivars(child, ivar);
|
||||
pccard_function_init(pf);
|
||||
pccard_function_enable(pf);
|
||||
device_printf(dev, "pf %p pf->sc %p\n", pf, pf->sc);
|
||||
if (device_probe_and_attach(child) == 0) {
|
||||
@ -228,14 +231,21 @@ pccard_card_gettype(device_t dev, int *type)
|
||||
* disabled.
|
||||
*/
|
||||
void
|
||||
pccard_function_init(struct pccard_function *pf,
|
||||
struct pccard_config_entry *cfe)
|
||||
pccard_function_init(struct pccard_function *pf)
|
||||
{
|
||||
struct pccard_config_entry *cfe;
|
||||
|
||||
if (pf->pf_flags & PFF_ENABLED)
|
||||
panic("pccard_function_init: function is enabled");
|
||||
|
||||
/* Remember which configuration entry we are using. */
|
||||
/* XXX
|
||||
* need to look for one we can allocate the resources
|
||||
* and then set them so the alloc_resources work later.
|
||||
*/
|
||||
cfe = STAILQ_FIRST(&pf->cfe_head);
|
||||
pf->cfe = cfe;
|
||||
|
||||
}
|
||||
|
||||
/* Enable a PCCARD function */
|
||||
@ -573,7 +583,7 @@ pccard_print_child(device_t dev, device_t child)
|
||||
"%ld");
|
||||
pccard_print_resources(rl, "drq", SYS_RES_DRQ, PCCARD_NDRQ,
|
||||
"%ld");
|
||||
retval += printf(" slot %d", devi->slotnum);
|
||||
retval += printf(" slot ?"); /* XXX imp */
|
||||
}
|
||||
|
||||
retval += bus_print_child_footer(dev, child);
|
||||
|
@ -168,7 +168,7 @@ struct pccard_card {
|
||||
/* More later? */
|
||||
struct pccard_ivar {
|
||||
struct resource_list resources;
|
||||
int slotnum;
|
||||
struct pccard_function *fcn;
|
||||
};
|
||||
|
||||
struct pccard_softc {
|
||||
@ -244,8 +244,7 @@ void pccard_ccr_write(struct pccard_function *, int, int);
|
||||
|
||||
/* The following is the vestages of the NetBSD driver api */
|
||||
|
||||
void pccard_function_init(struct pccard_function *,
|
||||
struct pccard_config_entry *);
|
||||
void pccard_function_init(struct pccard_function *);
|
||||
int pccard_function_enable(struct pccard_function *);
|
||||
void pccard_function_disable(struct pccard_function *);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user