Commit Graph

84 Commits

Author SHA1 Message Date
Justin Hibbits
6e1c39e9b2 Use the newly added mpc85xx_get_system_clock()
Simplify the platform clock acquisition by using the new helper function.
2017-04-01 22:35:03 +00:00
Marius Strobl
0f34084f95 o Add support for eMMC DDR bus speed mode at 52 MHz to sdhci(4) and
mmc(4). For the most part, this consists of support for:
  - Switching the signal voltage (VCCQ) to 1.8 V or (if supported
    by the host controller) to 1.2 V,
  - setting the UHS mode as appropriate in the SDHCI_HOST_CONTROL2
    register,
  - setting the power class in the eMMC device according to the
    core supply voltage (VCC),
  - using different bits for enabling a bus width of 4 and 8 bits
    in the the eMMC device at DDR or higher timings respectively,
  - arbitrating timings faster than high speed if there actually
    are additional devices on the same MMC bus.

  Given that support for DDR52 is not denoted by SDHCI capability
  registers, availability of that timing is indicated by a new
  quirk SDHCI_QUIRK_MMC_DDR52 and only enabled for Intel SDHCI
  controllers so far. Generally, what it takes for a sdhci(4)
  front-end to enable support for DDR52 is to hook up the bridge
  method mmcbr_switch_vccq (which especially for 1.2 V signaling
  support is chip/board specific) and the sdhci_set_uhs_timing
  sdhci(4) method.

  As a side-effect, this change also fixes communication with
  some eMMC devices at SDR high speed mode with 52 MHz due to
  the signaling voltage and UHS bits in the SDHCI controller no
  longer being left in an inappropriate state.

  Compared to 52 MHz at SDR high speed which typically yields
  ~45 MB/s with the eMMC chips tested, throughput goes up to
  ~80 MB/s at DDR52.

  Additionally, this change already adds infrastructure and quite
  some code for modes up to HS400ES and SDR104 respectively (I did
  not want to add to much stuff at a time, though). Essentially,
  what is still missing in order to be able to activate support
  for these latter is is support for and handling of (re-)tuning.

o In sdhci(4), add two tunables hw.sdhci.quirk_clear as well as
  hw.sdhci.quirk_set, which (when hooked up in the front-end)
  allow to set/clear sdhci(4) quirks for debugging and testing
  purposes. However, especially for SDHCI controllers on the
  PCI bus which have no specific support code so far and, thus,
  are picked up as generic SDHCI controllers, hw.sdhci.quirk_set
  allows for setting the necessary quirks (if required).

o In mmc(4), check and handle the return values of some more
  function calls instead of assuming that everything went right.
  In case failures actually are not problematic, indicate that
  by casting the return value to void.

Reviewed by:	jmcneill
2017-03-19 23:27:17 +00:00
Marius Strobl
c11bbc7dab Again, fixes regarding style(4), to comments, includes and unused
parameters.
2017-03-17 22:57:37 +00:00
Marius Strobl
9dbf8c467e - Adds macros for the content of SDHCI_ADMA_ERR and SDHCI_HOST_CONTROL2
registers.
- Add slot type capability bits. These bits should allow recognizing
  removable card slots, embedded cards and shared buses (shared bus
  supposedly is always comprised of non-removable cards).
- Dump CAPABILITIES2, ADMA_ERR, HOST_CONTROL2 and ADMA_ADDRESS_LO
  registers in sdhci_dumpregs().
- The drive type support flags in the CAPABILITIES2 register are for
  drive types A,C,D, drive type B is the default setting (value 0) of
  the drive strength field in the SDHCI_HOST_CONTROL2 register.

Obtained from:	DragonFlyBSD (9e3c8f63, 455bd1b1)
2017-03-16 22:42:17 +00:00
Marius Strobl
72dec0792a - Add support for eMMC "partitions". Besides the user data area, i. e.
the default partition, eMMC v4.41 and later devices can additionally
  provide up to:
  1 enhanced user data area partition
  2 boot partitions
  1 RPMB (Replay Protected Memory Block) partition
  4 general purpose partitions (optionally with a enhanced or extended
    attribute)

  Of these "partitions", only the enhanced user data area one actually
  slices the user data area partition and, thus, gets handled with the
  help of geom_flashmap(4). The other types of partitions have address
  space independent from the default partition and need to be switched
  to via CMD6 (SWITCH), i. e. constitute a set of additional "disks".

  The second kind of these "partitions" doesn't fit that well into the
  design of mmc(4) and mmcsd(4). I've decided to let mmcsd(4) hook all
  of these "partitions" up as disk(9)'s (except for the RPMB partition
  as it didn't seem to make much sense to be able to put a file-system
  there and may require authentication; therefore, RPMB partitions are
  solely accessible via the newly added IOCTL interface currently; see
  also below). This approach for one resulted in cleaner code. Second,
  it retains the notion of mmcsd(4) children corresponding to a single
  physical device each. With the addition of some layering violations,
  it also would have been possible for mmc(4) to add separate mmcsd(4)
  instances with one disk each for all of these "partitions", however.
  Still, both mmc(4) and mmcsd(4) share some common code now e. g. for
  issuing CMD6, which has been factored out into mmc_subr.c.

  Besides simply subdividing eMMC devices, some Intel NUCs having UEFI
  code in the boot partitions etc., another use case for the partition
  support is the activation of pseudo-SLC mode, which manufacturers of
  eMMC chips typically associate with the enhanced user data area and/
  or the enhanced attribute of general purpose partitions.

  CAVEAT EMPTOR: Partitioning eMMC devices is a one-time operation.

- Now that properly issuing CMD6 is crucial (so data isn't written to
  the wrong partition for example), make a step into the direction of
  correctly handling the timeout for these commands in the MMC layer.
  Also, do a SEND_STATUS when CMD6 is invoked with an R1B response as
  recommended by relevant specifications. However, quite some work is
  left to be done in this regard; all other R1B-type commands done by
  the MMC layer also should be followed by a SEND_STATUS (CMD13), the
  erase timeout calculations/handling as documented in specifications
  are entirely ignored so far, the MMC layer doesn't provide timeouts
  applicable up to the bridge drivers and at least sdhci(4) currently
  is hardcoding 1 s as timeout for all command types unconditionally.
  Let alone already available return codes often not being checked in
  the MMC layer ...

- Add an IOCTL interface to mmcsd(4); this is sufficiently compatible
  with Linux so that the GNU mmc-utils can be ported to and used with
  FreeBSD (note that due to the remaining deficiencies outlined above
  SANITIZE operations issued by/with `mmc` currently most likely will
  fail). These latter will be added to ports as sysutils/mmc-utils in
  a bit. Among others, the `mmc` tool of the GNU mmc-utils allows for
  partitioning eMMC devices (tested working).

- For devices following the eMMC specification v4.41 or later, year 0
  is 2013 rather than 1997; so correct this for assembling the device
  ID string properly.

- Let mmcsd.ko depend on mmc.ko. Additionally, bump MMC_VERSION as at
  least for some of the above a matching pair is required.

- In the ACPI front-end of sdhci(4) describe the Intel eMMC and SDXC
  controllers as such in order to match the PCI one.
  Additionally, in the entry for the 80860F14 SDXC controller remove
  the eMMC-only SDHCI_QUIRK_INTEL_POWER_UP_RESET.

OKed by:	imp
Submitted by:	ian (mmc_switch_status() implementation)
2017-03-16 22:23:04 +00:00
Michal Meloun
112d8ca98c Release all previously allocated resources. 2017-03-08 14:52:03 +00:00
Marius Strobl
55dae242e6 Add and use a MMC_DECLARE_BRIDGE macro for declaring mmc(4) bridges
as kernel drivers and their dependency onto mmc(4); this allows for
incrementing the mmc(4) module version but also for entire omission
of these bridge declarations for mmccam(4) in a single place, i. e.
in dev/mmc/bridge.h.
2017-03-07 22:42:44 +00:00
Marius Strobl
b440e965da o Another round fixes for mmc(4), mmcsd(4) and sdhci(4) regarding
comments, marking unused parameters as such, style(9), whitespace,
  etc.
o In the mmc(4) bridges and sdhci(4) (bus) front-ends:
  - Remove redundant assignments of the default bus_generic_print_child
    device method (I've whipped these out of the tree as part of r227843
    once, but they keep coming back ...),
  - use DEVMETHOD_END,
  - use NULL instead of 0 for pointers.
o Trim/adjust includes.
2017-03-06 23:47:59 +00:00
Ian Lepore
5c65c9998a Fix typos in bootverbose printfs... display the write-protect pin info,
not the card-detect pin info.
2017-02-21 21:21:58 +00:00
Oleksandr Tymoshenko
3bd0d6b434 [sdhci_acpi] Add support for Bay Trail SDHC SD card slot
Add ACPI device 80860F14 with _UID 3 to the list of known devices. It
make SD card available on NUCs and Minnowboard. Previously added _UID 1
covered only eMMC devices.

Reported by:	kib@
MFC after:	1 week
2017-02-14 00:04:36 +00:00
Marius Strobl
7e6ccea3b1 Fix some more overly long lines, whitespace and other bugs according to
style(9) as well as spelling in comments.
2017-02-04 19:35:38 +00:00
Marius Strobl
1bacf3be8c Fix overly long lines, whitespace and other bugs according to style(9). 2017-01-29 00:05:49 +00:00
Luiz Otavio O Souza
96d2f2694a Set the the wp_disabled flag when asked to.
While here, add the missing new line.

MFC after:	3 days
Sponsored by:	Rubicon Communications, LLC (Netgate)
2017-01-17 17:41:14 +00:00
Ian Lepore
8a2ec16a9d Include sys/systm.h for use of bootverbose. Fixes powerpc MPC85XXSPE build. 2017-01-12 00:09:31 +00:00
Oleksandr Tymoshenko
e5d519fdbc [sdhci] Add ACPI platform support for SDHCI driver
- Create ACPI version of SDHCI attach/detach/accessors logic. Some
    platforms (e.g. BayTrail-based Minnowboard) expose SDHCI devices
    via ACPI, not PCI
- Add sdchi_acpi kernel module

Reviewed by:	ian, imp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D9112
2017-01-11 01:53:54 +00:00
Ian Lepore
b8bf08b1fa Add sdhci_handle_card_present_locked() that can be called from the interrupt
handler which already holds the mutex, and have sdhci_handle_card_present()
be just a tiny wrapper that does the locking for external callers.

This should fix the recursive locking panics seen on rpi3.

Reported by:	Shawn Webb
2017-01-09 17:10:50 +00:00
Marius Strobl
a2832f9fce - Add support for Intel Apollo Lake and Bay Trail eMMC controllers.
Besides slots always having non-removable media, these HCIs require
  a custom hardware reset sequence after power-up.
- Flesh out the support for Intel Braswell eMMC controllers further.
  Apart from also requiring said reset code, the timeout clock needs to
  be hardcoded to 1 MHz for these.
  Both the special reset and timeout clock handlings are implemented as
  global sdhci(4) quirks as the same treatment will be necessary for
  Intel eMMC controllers attached via ACPI (once sdhci(4) grows such a
  front-end).
- In sdhci_init_slot(), use the right capability field for determining
  the announced bus width based on MMC_CAP_*_BIT_DATA.
- Correct inverted sdhci_pci_softc member comments added in r276469. [1]

Submitted by:	Anton Yuzhaninov [1]
MFC after:	5 days
2017-01-09 17:07:13 +00:00
Ian Lepore
8adb836cda Use the new sdhci_fdt_gpio helper functions to add full support for FDT
gpio pins for detecting card insert/remove and write protect.
2017-01-09 02:04:54 +00:00
Ian Lepore
78906a722f Add new helper routines for sdhci bridge drivers that use gpio pins for
card presence and write protect switch detection.

A bridge driver just needs to call the setup routine in its attach(), the
teardown in its detach(), and write a couple tiny glue functions to connect
the sdhci interface functions to the new helper functions.  This is not
extensively documented, but multiple examples will exist real soon.
2017-01-09 01:54:36 +00:00
Ian Lepore
639f59f02a Add support for non-removable media, and a quirk to use polling to detect
card insert/remove events on controllers that don't implement the insert
and remove interrupts.

Bridge drivers can set a new slot option, SDHCI_NON_REMOVABLE, to indicate
non-removable media (such as eMMC).  The sdhci driver will not enable
insert/remove interrupts, and sdhci_generic_get_card_present() will always
return true.

Bridge drivers can set a new quirk, SDHCI_QUIRK_POLL_CARD_PRESENT, and the
sdhci driver will not enable insert/remove interrupts, and instead will use
a callout to poll the card-present status at 5 Hz.

For bridge drivers that get notified of card insert/remove via gpio
interrupts, there is a new sdhci_handle_card_present() function they can
call from the gpio interrupt handler to inform the sdhci code of the event.

In addition to adding these new features, the existing code to debounce card
insertions was updated to use taskqueue_enqueue_timeout() instead of
scheduling a callout to do the taskqueue_enqueue().  There is also now a
comment explaining that insertion-debounce is what's going on -- it took me
a long time to realize that's what the old sdhci_card_delay() routine was
really doing.  There is no functional difference between the old and new
debounce code (I hope!).
2017-01-09 01:15:18 +00:00
Ian Lepore
90993663f8 Now that the PRESENT_STATE register is only used for the inhibit bits loop
in this function, eliminate the state variable and restructure the loop to
read the register just once at the top of the loop.

Suggested by:	skra
2017-01-08 18:28:06 +00:00
Ian Lepore
6e37fb2b62 Add a new sdhci interface method, get_card_present().
Many embedded SoC controllers that are (more or less) sdhci-compatible don't
implement card detect, and the related values in the PRESENT_STATE register
aren't useful.  A bridge driver can now implement get_card_present() to read
a gpio pin or whatever else is necessary for that system.

The default implementation reads the CARD_PRESENT bit from the PRESENT_STATE
register, so existing drivers will keep working (or keep not-fully-working,
since many drivers right now can't detect card insert/remove).
2017-01-08 02:32:53 +00:00
Conrad Meyer
8aa3468624 Follow-up to r310340: Add missing "Intel" to description
Reported by:	rpokala@
2016-12-20 22:47:09 +00:00
Conrad Meyer
00eb880d20 Add Braswell PCI IDs for Intel Cherryview
Submitted by:	Johannes Lundberg <yohanesu75 at gmail.com>
Reviewed by:	jhb
Differential Revision:	https://reviews.freebsd.org/D8861
2016-12-20 22:08:36 +00:00
Conrad Meyer
db6f80fd1c sdhci/mmc: Minor whitespace cleanups
No functional change.

Submitted by:	Johannes Lundberg <yohanesu75 at gmail.com>
2016-12-20 03:38:14 +00:00
Justin Hibbits
47a4ca603b Since it's no longer accessing a powerpc-specific register, drop the #ifdef. 2016-11-02 23:44:30 +00:00
Justin Hibbits
e8f58f1fb8 Fix the build. protctl is only used on powerpc.
While here, remove the need to check the SVR SPR, as others may be compatible
with the p1022-esdhc type.
2016-11-02 23:43:18 +00:00
Justin Hibbits
eecaab5275 Merge i.MX and PowerPC SDHCI drivers
Summary:
i.MX5 and PowerPC use a very similar eSDHC controller, which is also
similar to the uSDHC controller used by i.MX6.  The imx_sdhci driver works
almost completely with PowerPC, with some minor tweaks.

There is one caveat with this: reset currently does not work on PowerPC, so has
been #ifdef'd out until this can be tracked down and fixed.  If resets are done
the controller will timeout all data transactions.  Without a reset, it appears
to work just fine.

This is part 3, following up r308186 and r308187.

Test Plan:
This has been tested on a PowerPC QorIQ P1022 board.  It has not been
tested on i.MX, but no regressions are expected.

Reviewed By: imp
Differential Revision: https://reviews.freebsd.org/D8407
2016-11-02 00:57:04 +00:00
Justin Hibbits
2b96b955e9 Toggle card insert/remove interrupt enable bits on events
Some controllers (namely Freescale's eSDHC, tested) will continue to assert
the card removed or card insert interrupts even after being handled.  To work
around this, disable watching the interrupt that just occurred until the
opposite interrupt is triggered.

Linux has a similar change in its driver to address the same problem.
2016-11-02 00:54:39 +00:00
Justin Hibbits
3d9df07abf Move imx_sdhci driver over to a dev/sdhci in preparation for QorIQ support.
Freescale uses eSDHC in both i.MX (ARM) and QorIQ (PowerPC), with slight
differences.  This is part one in unifying the drivers.

Reviewed by:	imp
2016-11-02 00:51:09 +00:00
Ian Lepore
93ff47244a Add a convenience macro that masks all the bits related to clock divisors
in all versions of the sdhci spec (the HI bits are just unused reserved
bits in earlier versions).
2016-05-26 02:55:41 +00:00
Edward Tomasz Napierala
220adb0416 Make sdhci(4) work after suspend/resume for chipsets that require
the frequency quirk. This makes it work on eg ThinkPad T420.

Without it, after resume one can see this:

mmc0: ACMD42 failed, RESULT: 4
mmcsd0: Error indicated: 1 Timeout
mmcsd0: Error indicated: 2 Bad CRC
mmcsd0: Error indicated: 2 Bad CRC
mmcsd0: Error indicated: 2 Bad CRC
mmcsd0: Error indicated: 2 Bad CRC
sdhci_pci0-slot0: Got data interrupt 0x00200000, but there is no active command.
sdhci_pci0-slot0: ============== REGISTER DUMP ==============
sdhci_pci0-slot0: Sys addr: 0x06317200 | Version: 0x00000502
sdhci_pci0-slot0: Blk size: 0x00000200 | Blk cnt: 0x00000010
sdhci_pci0-slot0: Argument: 0x00000200 | Trn mode: 0x00000037
sdhci_pci0-slot0: Present: 0x01ff0000 | Host ctl: 0x00000007
sdhci_pci0-slot0: Power: 0x0000000f | Blk gap: 0x00000000
sdhci_pci0-slot0: Wake-up: 0x00000000 | Clock: 0x00000007
sdhci_pci0-slot0: Timeout: 0x0000000d | Int stat: 0x00000000
sdhci_pci0-slot0: Int enab: 0x01ff00fb | Sig enab: 0x01ff00fb
sdhci_pci0-slot0: AC12 err: 0x00000000 | Slot int: 0x00000000
sdhci_pci0-slot0: Caps: 0x21e8c8b2 | Max curr: 0x00000040
sdhci_pci0-slot0: ===========================================
sdhci_pci0-slot0: Got data interrupt 0x00200000, but there is no active command.
sdhci_pci0-slot0: ============== REGISTER DUMP ==============
sdhci_pci0-slot0: Sys addr: 0x06317200 | Version: 0x00000502
sdhci_pci0-slot0: Blk size: 0x00000200 | Blk cnt: 0x00000001
sdhci_pci0-slot0: Argument: 0x00000040 | Trn mode: 0x00000013
sdhci_pci0-slot0: Present: 0x01ff0000 | Host ctl: 0x00000007
sdhci_pci0-slot0: Power: 0x0000000f | Blk gap: 0x00000000
sdhci_pci0-slot0: Wake-up: 0x00000000 | Clock: 0x00000007
sdhci_pci0-slot0: Timeout: 0x0000000d | Int stat: 0x00000000
autofs_flush: /net flushed
sdhci_pci0-slot0: Int enab: 0x01ff00fb | Sig enab: 0x01ff00fb
autofs_flush: /media flushed
sdhci_pci0-slot0: AC12 err: 0x00000000 | Slot int: 0x00000000
sdhci_pci0-slot0: Caps: 0x21e8c8b2 | Max curr: 0x00000040
sdhci_pci0-slot0: ===========================================

Afterwards all operations on /dev/mmcsd0 fail with EIO.

Reviewed by:	jhb@
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D6265
2016-05-11 07:50:35 +00:00
Ian Lepore
dec4873723 Fix fallout from r292180 (Dec 2015)... ensure that every driver which has
a DRIVER_MODULE() referencing mmc_driver has a MODULE_DEPEND() on mmc.  This
is because the kernel linker only searches for symbols in dependent modules,
so loading sdhci_pci (and other bus-flavors of sdhci) would fail when mmc
was not compiled into the kernel (even if you hand-loaded mmc first).

(Thanks to jilles@ for providing the vital clue about the kernel linker.)
2016-03-21 00:52:24 +00:00
Justin Hibbits
eff83876b6 Replace several bus_alloc_resource() calls with bus_alloc_resource_any()
Most of these are BARs, and we allocate them in their entirety.  The one outlier
in this is amdsbwd, which calls bus_set_resource() prior.

Reviewed by:	jhb
Differential Revision:	https://reviews.freebsd.org/D5370 (partial)
2016-02-27 03:34:01 +00:00
Ian Lepore
3f62727443 Move the DRIVER_MODULE() statements that declare mmc(4) to be a child of
the various bridge drivers out of dev/mmc.c and into the bridge drivers.

Requested by:	   jhb (almost two years ago; better late than never)
2015-12-14 01:09:25 +00:00
Adrian Chadd
93efdc635d Add support for the BCM57765 card reader.
This patch adds support for the BCM57765[2] card reader function included in
Broadcom's BCM57766 ethernet/sd3.0 controller. This controller is commonly
found in laptops and Apple hardware (MBP, iMac, etc).

The BCM57765 chipset is almost fully compatible with the SD3.0 spec, but
does not support deriving a frequency below 781KHz from its default base
clock via the standard SD3.0-configured 10-bit clock divisor.

If such a divisor is set, card identification (which requires a 400KHz
clock frequency) will time out[1].

As a work-around, I've made use of an undocumented device-specific clock
control register to switch the controller to a 63MHz clock source when
targeting clock speeds below 781KHz; the clock source is likewise switched
back to the 200MHz clock when targeting speeds greater than 781KHz.

Additionally, this patch fixes a small sdhci_pci bug; the
sdhci_pci_softc->quirks flag was not copied to the sdhci_slot, resulting in
`quirk` behavior not being applied by sdhci.c.

[1] A number of Linux/FreeBSD users have noted that bringing up the chipsets'
associated ethernet interface will allow SD cards to enumerate (slowly).
This is a controller implementation side-effect triggered by the ethernet
driver's reading of the hardware statistics registers.

[2] This may also fix card detection when using the BCM57785 chipset, but I
don't have access to the BCM57785 chipset and can't verify.

I actually snagged some BCM57785 hardware recently (2012 Retina MacBook Pro)
and can confirm that this also fixes card enumeration with the BCM57785
chipset; with the patch, I can boot off of the internal sdcard reader.

PR:		kern/203385
Submitted by:	Landon Fuller <landon@landonf.org>
2015-10-15 04:22:56 +00:00
Luiz Otavio O Souza
ba6fc1c73c Raise the SDHCI timeout to 10 seconds and add a sysctl to allow changing
this value at runtime.

The SD card specification says that a block write or a block erase can take
up to 250ms to complete and thus, under some circumstances, the existent 2
seconds timeout was triggering with normal usage.

This change fixes the sporadic controller timeout that happens on RPi and
RPi 2.

Discussed with:		ian (some time ago)
2015-05-21 20:09:36 +00:00
Ian Lepore
2d1731b857 Detect, report and use 8-bit bus if is available.
Differential Revision:	https://reviews.freebsd.org/D1921
Submitted by:	Michal Meloun
2015-02-27 15:47:30 +00:00
Ian Lepore
bba987dc50 Add a new SDHCI quirk, SDHCI_QUIRK_DONT_SET_HISPD_BIT. Apparently some
sdhci controllers, such as the one on a Raspberry Pi, mishandle the signal
timing in high speed signaling mode, but run just fine in standard mode
with the bus running at frequencies between 25-50MHz (which shouldn't work).

This is the solution adopted by U-Boot and other OSes (linux and *BSD)
for the timeouts on Raspberry Pi boards with certain SD cards.  Some
research shows that this quirk is also used on a few other boards, so the
fix is a generic quirk instead of being in the RPi-specific driver code.

This change is based on information discovered by Michal Meloun.
2015-01-17 19:57:03 +00:00
Ian Lepore
cf5bb7ca1c Add defines for SDHCI 3.0 controllers.
Submitted by:	Michal Meloun <meloun@miracle.cz>
2015-01-17 18:56:22 +00:00
Ian Lepore
a98788edff Handle the possibility that SDHCI_PLATFORM_START_TRANSFER() can fail, by
moving the handling of curcmd->error != 0 to the end of the interrupt
handler.  Also make sdhci_finish_data() idempotent by moving the setting
of slot->data_done = 1 down past the point where the busdma buffer is
unmapped.  This allows for the possibility that the finish routine can
get called from multiple places when handling errors.
2015-01-11 21:25:03 +00:00
Marius Strobl
c22626471e - Switching the mode of Ricoh R5CE823 to SD2.0 causes their PCI device ID
to change to 0xe822, which may be persistent across reboots and, thus,
  confuse other OSes. Therefore, restore the original mode and frequency
  setting on detach and shutdown.
- Report Ricoh R5CE822 as such.
- According to Linux, Ricoh R5CE822 also need SDHCI_QUIRK_LOWER_FREQUENCY.
- Nuke an unused softc member.

MFC after:	3 days
2014-12-31 16:06:26 +00:00
Ian Lepore
61bc42f782 Add a new sdhci quirk, SDHCI_QUIRK_WAITFOR_RESET_ASSERTED, to work around
TI OMAP controllers which will return the reset-in-progress bit as zero if
you read the status register too fast after setting the reset bit.

The zero is apparently from a stale snapshot of the internal state presented
in the interface register, and leads to a false indication that the reset
is complete when it either hasn't started yet or is in-progress.  The
workaround is to first loop until the bit is seen as asserted, then do the
normal loop waiting to see it de-asserted.

Submitted by:	Michal Meloun <meloun@miracle.cz>
2014-12-20 01:13:13 +00:00
Ian Lepore
7e5866432f When command and data interrupts have been aggregated together, don't do
the data-completed processing if a command-error interrupt is also asserted.

Reviewed by:	Michal Meloun <meloun@miracle.cz>
2014-12-20 00:37:56 +00:00
Warner Losh
5df0ffc762 class, subclass and progif were never used, so don't bother setting
them.
2014-10-13 16:23:51 +00:00
Marius Strobl
f0d2731dd8 - Nuke unused sdhci_softc.
- Static'ize sdhci_debug local to sdhci.c.
- Const'ify PCI device description strings.
- Nuke redundant resource ID members from sdhci_pci_softc.
- Nuke unused hw.sdhci_pci.debug tunable.
- Add support for using MSI instead of INTx, controllable via the tunable
  hw.sdhci.enable_msi (defaulting to on) and tested with a RICOH R5CE823 SD
  controller.
- Use NULL instead of 0 for pointers.

MFC after:	3 days
2014-08-31 17:56:54 +00:00
Hans Petter Selasky
af3b2549c4 Pull in r267961 and r267973 again. Fix for issues reported will follow. 2014-06-28 03:56:17 +00:00
Glen Barber
37a107a407 Revert r267961, r267973:
These changes prevent sysctl(8) from returning proper output,
such as:

 1) no output from sysctl(8)
 2) erroneously returning ENOMEM with tools like truss(1)
    or uname(1)
 truss: can not get etype: Cannot allocate memory
2014-06-27 22:05:21 +00:00
Hans Petter Selasky
3da1cf1e88 Extend the meaning of the CTLFLAG_TUN flag to automatically check if
there is an environment variable which shall initialize the SYSCTL
during early boot. This works for all SYSCTL types both statically and
dynamically created ones, except for the SYSCTL NODE type and SYSCTLs
which belong to VNETs. A new flag, CTLFLAG_NOFETCH, has been added to
be used in the case a tunable sysctl has a custom initialisation
function allowing the sysctl to still be marked as a tunable. The
kernel SYSCTL API is mostly the same, with a few exceptions for some
special operations like iterating childrens of a static/extern SYSCTL
node. This operation should probably be made into a factored out
common macro, hence some device drivers use this. The reason for
changing the SYSCTL API was the need for a SYSCTL parent OID pointer
and not only the SYSCTL parent OID list pointer in order to quickly
generate the sysctl path. The motivation behind this patch is to avoid
parameter loading cludges inside the OFED driver subsystem. Instead of
adding special code to the OFED driver subsystem to post-load tunables
into dynamically created sysctls, we generalize this in the kernel.

Other changes:
- Corrected a possibly incorrect sysctl name from "hw.cbb.intr_mask"
to "hw.pcic.intr_mask".
- Removed redundant TUNABLE statements throughout the kernel.
- Some minor code rewrites in connection to removing not needed
TUNABLE statements.
- Added a missing SYSCTL_DECL().
- Wrapped two very long lines.
- Avoid malloc()/free() inside sysctl string handling, in case it is
called to initialize a sysctl from a tunable, hence malloc()/free() is
not ready when sysctls from the sysctl dataset are registered.
- Bumped FreeBSD version to indicate SYSCTL API change.

MFC after:	2 weeks
Sponsored by:	Mellanox Technologies
2014-06-27 16:33:43 +00:00
Ian Lepore
e625c10b2f Honor the max-frequency property if it appears in the fdt data.
Adjust the exynos and zedboard dts files to use max-frequency (the
documented standard property) instead of clock-frequency.

Submitted by:	Thomas Skibo <ThomasSkibo@sbcglobal.net>
2014-05-02 01:28:19 +00:00