The Tadpole SPARCle laptop has an SD card reader and I thought that it would be nice if we supported it. We already have a Winbond W83L518D driver, so making this work should be straightforward.

It turned out not to be as straightforward as that. The W83L518D supports v1.0 of the SD Physical Specification and fails if sent newer opcodes. This is handled in our driver by returning an error if any of the opcodes are sent, but our SDMMC layer sends the opcodes based on the capabilities of the card and fails if an error is returned. After discussion with Jared McNeill, I added a small change to skip these settings if the controller didn't support them. This means that the card will work, albeit at a lower speed. This is not a problem because the W83L518D doesn't support the higher speeds.

In the driver itself, configuration data was returned in little-endian format, so we need to do byte swapping when reading. I could not make cards work in 4-bit mode, so had to resort to 1-bit mode only. This might be because the physical slot is wired to only support 1-bit mode. With these changes and the sparc64 frontend the driver worked on SPARCle. The final piece was to commit the kernel configuration.

The result of this is (with a 32GB card):

[   1.8200095] ld0 at sdmmc0: <0x28:0x4245:     :0x10:0xbb060344:0x0c1>
[   1.8978086] ld0: 30535 MB, 7754 cyl, 128 head, 63 sec, 512 bytes/sect x 62535680 sectors
[   1.9945262] ld0: 1-bit width, 24.000 MHz
# mbrlabel -w ld0
Found MSDOS partition; size 62527488 (30531 MB), offset 8192
  adding MSDOS partition to slot a.

3 partitions:
#        size    offset     fstype [fsize bsize cpg/sgs]
 a:  62527488      8192      MSDOS                     # (Cyl.      1*-   7754*)
 c:  62535680         0     unused      0     0        # (Cyl.      0 -   7754*)

Updating in-core disk label.
# mount -t msdos /dev/ld0a /mnt
# df /mnt
Filesystem    1K-blocks       Used      Avail %Cap Mounted on
/dev/ld0a      31255552      25792   31229760   0% /mnt

The SPARCle also has a PMU (Power Management Unit) and Michael Lorenz had already committed a driver based on the OFW methods on the Tadpole Viper. It seemed useful to extend this to report on battery state and maybe warn when the battery was low.

There isn't any documentation for this device, so a combination of looking at the OFW methods and observation was required. After a few days, I was able to extend the driver to report better information to envstat:

              Current  CritMax  WarnMax  WarnMin  CritMin  Unit
[ac adapter]
  DC power:      TRUE
     Vbatt:    12.200                                         V
  capacity:    NORMAL
  charging:     FALSE
   systemp:    40.000                                      degC
    fan on:      TRUE

The driver also reacts to changes in battery capacity (there is an interrupt for this) so that it should be possible to know when the battery reaches warning and critical levels. However, the only information that we have about the battery capacity is the voltage and that doesn't always correlate to the charge level, so the driver currently has to guess at the remaining capacity. It would also be nice to be able to beep at these points, but I was unable to make the beeper sound via the driver (I was actually unable to write any values).

-^- More notes -^-