Re: Writing a driver for a card reader controller - how?

From: M. Warner Losh (imp_at_bsdimp.com)
Date: 11/24/05

  • Next message: Thiemo Nordenholz: "Re: Writing a driver for a card reader controller - how?"
    Date: Thu, 24 Nov 2005 02:17:47 -0700 (MST)
    To: listmember@thiemo.net
    
    

    In message: <20051123092045.GA48216@mygiea.ham01.thiemo.net>
                Thiemo Nordenholz <listmember@thiemo.net> writes:
    : I am writing a device driver for a card reader controller which is installed
    : in my notebook, using the Winbond W83L518D chip. It's FreeBSD 6.0-STABLE
    : running there now, though I started programming under 5.4-R, and the
    : symptoms have not changed since then.
    :
    : However, when I attach it, it seems to allocate the resources
    :
    : port 0-0x7 irq 0 drq 4 on acpi0
    :
    : which seems strange to me -- accessing registers in the respective
    : SYS_RES_IOPORT seems to work, though.

    This looks like a problem. It shouldn't be at port 0 or irq 0.
    There's a resource issue with the ACPI.

    However, this may be a classic problem instead. If your driver does
    not filter out pnpid that it gets, then you can wind up with this
    situation.

    : Now, as far as I understand the data*** for the controller, I have to use
    : another I/O port to access the SD card itself, to check if one is there, and
    : finally to access it. How I do this, though, I have no idea. The data***
    : lists two configuration registers that "select SD Card interface base
    : address on 8-byte boundary" - but will my driver have to program an address
    : into those registers? Does the bus framework somehow handle this? Does even
    : BIOS do this? Or will I have to write one driver for the controller, have
    : that act as a bus driver, and attach some SD card driver to that one?

    Chances are several drivers will be needed to support SD cards. There
    are a number of layers involved. You have the slot/controller
    interface which is resposible for sending commands to the card. You
    have a higher level interface, which different slot controllers can
    plug into that deals with sending commands to the cards. Finally,
    you'd likely have a disk layer layered on top of that to prsent bits
    to the user.

    : Maybe someone is willing to spend some time having a look at the data***
    : and what I have done so far, and give me a little (or larger) clue-up... In
    : return, I promise to write some documentation about how I have done it once
    : it is ready, just in case someone else faces similar problems. A pointer to
    : some driver programming documentation I have missed so far would be just as
    : nice, of course.

    I'd be happy to take a look at the data***.

    : So far, I have tried using fdc and ppc as a guideline (after having found
    : the spkr driver to be a bit too simple), and I _think_ I am doing just as
    : those drivers do probing and resource allocation, but somehow they work, and
    : mine does not.

    : Link to the data*** and some more description of what I have done so far
    : (including my current state of source code) are at
    : http://projects.thiemo.net/WbcrDriver

    The probe routine shouldn't allocate resources. Old ISA drivers
    needed to do this to cope with the vagaries of probing the hardware
    that may or may not be there. It looks like you have a specific
    instance in the ACPI space that you can attach to, so there's no
    need. This should be deferred until attach time.

    There's no equivalent in FreeBSD to the mmc code that Linux has.
    There really should be (this is the layering I was describing above).

    I'm not sure how to best advise moving the device's I/O port address.
    Not having one to mess with, I'm unsure how you should proceed. I
    think that the location of '0' might be a default, and that it needs
    to be set. Can you send me a pointer to the winbond data*** you are
    using? IIRC, this chip has an odd API since it appears to be derived
    from Winbond's superI/O chips with all the 'super' removed except the
    SD interface.

    Warner
    _______________________________________________
    freebsd-hackers@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
    To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"


  • Next message: Thiemo Nordenholz: "Re: Writing a driver for a card reader controller - how?"