History log of /netbsd-current/sys/dev/ic/dwc_mmc.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.31 09-Feb-2024 skrll

Restrict dwcmmc to 32bit DMA (<4GB) regardless of attachment


# 1.30 09-Feb-2024 skrll

Fix a typo in a comment


Revision tags: netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 thorpej-ifq-base thorpej-altq-separation-base netbsd-10-0-RC1 netbsd-10-base bouyer-sunxi-drm-base
# 1.29 09-Jan-2022 jmcneill

dwcmmc: Add support for card detect using SDMMC_CDETECT register


Revision tags: thorpej-i2c-spi-conf2-base
# 1.28 07-Aug-2021 thorpej

Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base
# 1.27 24-Apr-2021 thorpej

branches: 1.27.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).


Revision tags: thorpej-cfargs-base thorpej-futex-base bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.26 20-Mar-2020 skrll

branches: 1.26.6;
Disable thrctrl or now and note why


# 1.25 20-Mar-2020 skrll

Remember / use sc_verid


# 1.24 20-Mar-2020 skrll

Trailing whitespace


# 1.23 19-Mar-2020 skrll

Release the sc_intr_lock on error


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2
# 1.22 23-Jan-2020 jmcneill

More SDIO stability and performance fixes


# 1.21 22-Jan-2020 jmcneill

dwc_mmc fixes:
- Rockchip uses a different SDIO int bit, so take this into consideration
- Avoid unnecessary resets and always wait for resets to complete
- kpause instead of delay while holding spinlock
- Do not attempt autostop for SD_IO_RW_EXTENDED commands
- Allow for sub-blklen byte counts for single block transfers


Revision tags: ad-namecache-base1 ad-namecache-base
# 1.20 01-Jan-2020 jmcneill

branches: 1.20.2;
Fix performance regression with previous


# 1.19 01-Jan-2020 jmcneill

dwcmmc improvements:
- Use mmcpwrseq resources if available
- Only set 4- or 8-bit mode if specified in the dt properties
- Add quirk for implementations with inverted power enable logic
- Support switching signal voltage between 1.8V and 3.3V
- Fix a clock divider issue on Rockchip SoCs


Revision tags: phil-wifi-20191119
# 1.18 05-Oct-2019 jmcneill

Add support for SDIO interrupts.


Revision tags: netbsd-9-0-RC1 netbsd-9-base
# 1.17 28-Jul-2019 jmcneill

branches: 1.17.2;
Fix infinite loop in dwc_mmc_exec_command error path


Revision tags: phil-wifi-20190609
# 1.16 30-Apr-2019 jmcneill

Simplify card detect


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.15 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728
# 1.14 02-Jul-2018 jmcneill

Reduce 10 second timeouts to 2 seconds.


Revision tags: phil-wifi-base pgoyette-compat-0625
# 1.13 19-Jun-2018 jmcneill

branches: 1.13.2;
dwcmmc: set ciu clock rate rather than assuming fixed input rate


# 1.12 10-Jun-2018 jmcneill

If the bus glue does not provide values for fifo reg offset and
fifo depth, try to auto detect based on the chip version and
value already programmed into FIFOTH.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.11 19-Jun-2017 jmcneill

branches: 1.11.4; 1.11.6;
More or less a rewrite of dwc_mmc, based on awin_mmc, adding DMA support.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.10 27-Dec-2015 jmcneill

branches: 1.10.10;
remove DWC_MMC_DEBUG


# 1.9 27-Dec-2015 jmcneill

reduce timeouts, fix clk div calculation


# 1.8 26-Dec-2015 jmcneill

Dump registers on timeout and allow bus glue to override card detect func


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.7 09-Aug-2015 jmcneill

wait for command done status before doing pio transfer


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.6 22-Jan-2015 jmcneill

branches: 1.6.2;
when resetting controller, dont preserve DWC_MMC_CTRL_REG state. makes this work on my radxa lite


# 1.5 17-Jan-2015 jmcneill

improve intr reg debugging


# 1.4 30-Dec-2014 jmcneill

Fix inverted logic of card_detect_n bit, from FUKAUMI Naoki <fun@naobsd.org>.


# 1.3 29-Dec-2014 jmcneill

- Simplify clock setup
- Add DWC_MMC_F_FORCE_CLK flag, which forces updating clock for each
command (apparently required by Rockchip)
- Let bus glue limit the max clk speed used


# 1.2 27-Dec-2014 jmcneill

- Explicitly initialize CLKSRC register.
- Reset FIFO and DMA along with controller.
- Support chips with inverted PWREN logic.
- Enable RXDR and TXDR irqs.
- Set max clk based on supplied clock freq.
- Use external clk control as well as internal divisor to set clock rates.
Requires bus glue to implement sc_set_clkdiv callback.


# 1.1 27-Dec-2014 jmcneill

add DesignWare SD/MMC controller driver


# 1.29 09-Jan-2022 jmcneill

dwcmmc: Add support for card detect using SDMMC_CDETECT register


Revision tags: thorpej-i2c-spi-conf2-base
# 1.28 07-Aug-2021 thorpej

Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base
# 1.27 24-Apr-2021 thorpej

branches: 1.27.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).


Revision tags: thorpej-cfargs-base thorpej-futex-base bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.26 20-Mar-2020 skrll

branches: 1.26.6;
Disable thrctrl or now and note why


# 1.25 20-Mar-2020 skrll

Remember / use sc_verid


# 1.24 20-Mar-2020 skrll

Trailing whitespace


# 1.23 19-Mar-2020 skrll

Release the sc_intr_lock on error


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2
# 1.22 23-Jan-2020 jmcneill

More SDIO stability and performance fixes


# 1.21 22-Jan-2020 jmcneill

dwc_mmc fixes:
- Rockchip uses a different SDIO int bit, so take this into consideration
- Avoid unnecessary resets and always wait for resets to complete
- kpause instead of delay while holding spinlock
- Do not attempt autostop for SD_IO_RW_EXTENDED commands
- Allow for sub-blklen byte counts for single block transfers


Revision tags: ad-namecache-base1 ad-namecache-base
# 1.20 01-Jan-2020 jmcneill

branches: 1.20.2;
Fix performance regression with previous


# 1.19 01-Jan-2020 jmcneill

dwcmmc improvements:
- Use mmcpwrseq resources if available
- Only set 4- or 8-bit mode if specified in the dt properties
- Add quirk for implementations with inverted power enable logic
- Support switching signal voltage between 1.8V and 3.3V
- Fix a clock divider issue on Rockchip SoCs


Revision tags: phil-wifi-20191119
# 1.18 05-Oct-2019 jmcneill

Add support for SDIO interrupts.


Revision tags: netbsd-9-0-RC1 netbsd-9-base
# 1.17 28-Jul-2019 jmcneill

branches: 1.17.2;
Fix infinite loop in dwc_mmc_exec_command error path


Revision tags: phil-wifi-20190609
# 1.16 30-Apr-2019 jmcneill

Simplify card detect


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.15 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728
# 1.14 02-Jul-2018 jmcneill

Reduce 10 second timeouts to 2 seconds.


Revision tags: phil-wifi-base pgoyette-compat-0625
# 1.13 19-Jun-2018 jmcneill

branches: 1.13.2;
dwcmmc: set ciu clock rate rather than assuming fixed input rate


# 1.12 10-Jun-2018 jmcneill

If the bus glue does not provide values for fifo reg offset and
fifo depth, try to auto detect based on the chip version and
value already programmed into FIFOTH.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.11 19-Jun-2017 jmcneill

branches: 1.11.4; 1.11.6;
More or less a rewrite of dwc_mmc, based on awin_mmc, adding DMA support.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.10 27-Dec-2015 jmcneill

branches: 1.10.10;
remove DWC_MMC_DEBUG


# 1.9 27-Dec-2015 jmcneill

reduce timeouts, fix clk div calculation


# 1.8 26-Dec-2015 jmcneill

Dump registers on timeout and allow bus glue to override card detect func


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.7 09-Aug-2015 jmcneill

wait for command done status before doing pio transfer


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.6 22-Jan-2015 jmcneill

branches: 1.6.2;
when resetting controller, dont preserve DWC_MMC_CTRL_REG state. makes this work on my radxa lite


# 1.5 17-Jan-2015 jmcneill

improve intr reg debugging


# 1.4 30-Dec-2014 jmcneill

Fix inverted logic of card_detect_n bit, from FUKAUMI Naoki <fun@naobsd.org>.


# 1.3 29-Dec-2014 jmcneill

- Simplify clock setup
- Add DWC_MMC_F_FORCE_CLK flag, which forces updating clock for each
command (apparently required by Rockchip)
- Let bus glue limit the max clk speed used


# 1.2 27-Dec-2014 jmcneill

- Explicitly initialize CLKSRC register.
- Reset FIFO and DMA along with controller.
- Support chips with inverted PWREN logic.
- Enable RXDR and TXDR irqs.
- Set max clk based on supplied clock freq.
- Use external clk control as well as internal divisor to set clock rates.
Requires bus glue to implement sc_set_clkdiv callback.


# 1.1 27-Dec-2014 jmcneill

add DesignWare SD/MMC controller driver


# 1.28 07-Aug-2021 thorpej

Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base
# 1.27 24-Apr-2021 thorpej

branches: 1.27.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).


Revision tags: thorpej-cfargs-base thorpej-futex-base bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.26 20-Mar-2020 skrll

branches: 1.26.6;
Disable thrctrl or now and note why


# 1.25 20-Mar-2020 skrll

Remember / use sc_verid


# 1.24 20-Mar-2020 skrll

Trailing whitespace


# 1.23 19-Mar-2020 skrll

Release the sc_intr_lock on error


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2
# 1.22 23-Jan-2020 jmcneill

More SDIO stability and performance fixes


# 1.21 22-Jan-2020 jmcneill

dwc_mmc fixes:
- Rockchip uses a different SDIO int bit, so take this into consideration
- Avoid unnecessary resets and always wait for resets to complete
- kpause instead of delay while holding spinlock
- Do not attempt autostop for SD_IO_RW_EXTENDED commands
- Allow for sub-blklen byte counts for single block transfers


Revision tags: ad-namecache-base1 ad-namecache-base
# 1.20 01-Jan-2020 jmcneill

branches: 1.20.2;
Fix performance regression with previous


# 1.19 01-Jan-2020 jmcneill

dwcmmc improvements:
- Use mmcpwrseq resources if available
- Only set 4- or 8-bit mode if specified in the dt properties
- Add quirk for implementations with inverted power enable logic
- Support switching signal voltage between 1.8V and 3.3V
- Fix a clock divider issue on Rockchip SoCs


Revision tags: phil-wifi-20191119
# 1.18 05-Oct-2019 jmcneill

Add support for SDIO interrupts.


Revision tags: netbsd-9-0-RC1 netbsd-9-base
# 1.17 28-Jul-2019 jmcneill

branches: 1.17.2;
Fix infinite loop in dwc_mmc_exec_command error path


Revision tags: phil-wifi-20190609
# 1.16 30-Apr-2019 jmcneill

Simplify card detect


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.15 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728
# 1.14 02-Jul-2018 jmcneill

Reduce 10 second timeouts to 2 seconds.


Revision tags: phil-wifi-base pgoyette-compat-0625
# 1.13 19-Jun-2018 jmcneill

branches: 1.13.2;
dwcmmc: set ciu clock rate rather than assuming fixed input rate


# 1.12 10-Jun-2018 jmcneill

If the bus glue does not provide values for fifo reg offset and
fifo depth, try to auto detect based on the chip version and
value already programmed into FIFOTH.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.11 19-Jun-2017 jmcneill

branches: 1.11.4; 1.11.6;
More or less a rewrite of dwc_mmc, based on awin_mmc, adding DMA support.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.10 27-Dec-2015 jmcneill

branches: 1.10.10;
remove DWC_MMC_DEBUG


# 1.9 27-Dec-2015 jmcneill

reduce timeouts, fix clk div calculation


# 1.8 26-Dec-2015 jmcneill

Dump registers on timeout and allow bus glue to override card detect func


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.7 09-Aug-2015 jmcneill

wait for command done status before doing pio transfer


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.6 22-Jan-2015 jmcneill

branches: 1.6.2;
when resetting controller, dont preserve DWC_MMC_CTRL_REG state. makes this work on my radxa lite


# 1.5 17-Jan-2015 jmcneill

improve intr reg debugging


# 1.4 30-Dec-2014 jmcneill

Fix inverted logic of card_detect_n bit, from FUKAUMI Naoki <fun@naobsd.org>.


# 1.3 29-Dec-2014 jmcneill

- Simplify clock setup
- Add DWC_MMC_F_FORCE_CLK flag, which forces updating clock for each
command (apparently required by Rockchip)
- Let bus glue limit the max clk speed used


# 1.2 27-Dec-2014 jmcneill

- Explicitly initialize CLKSRC register.
- Reset FIFO and DMA along with controller.
- Support chips with inverted PWREN logic.
- Enable RXDR and TXDR irqs.
- Set max clk based on supplied clock freq.
- Use external clk control as well as internal divisor to set clock rates.
Requires bus glue to implement sc_set_clkdiv callback.


# 1.1 27-Dec-2014 jmcneill

add DesignWare SD/MMC controller driver


# 1.27 24-Apr-2021 thorpej

Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).


Revision tags: thorpej-cfargs-base thorpej-futex-base bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.26 20-Mar-2020 skrll

branches: 1.26.6;
Disable thrctrl or now and note why


# 1.25 20-Mar-2020 skrll

Remember / use sc_verid


# 1.24 20-Mar-2020 skrll

Trailing whitespace


# 1.23 19-Mar-2020 skrll

Release the sc_intr_lock on error


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2
# 1.22 23-Jan-2020 jmcneill

More SDIO stability and performance fixes


# 1.21 22-Jan-2020 jmcneill

dwc_mmc fixes:
- Rockchip uses a different SDIO int bit, so take this into consideration
- Avoid unnecessary resets and always wait for resets to complete
- kpause instead of delay while holding spinlock
- Do not attempt autostop for SD_IO_RW_EXTENDED commands
- Allow for sub-blklen byte counts for single block transfers


Revision tags: ad-namecache-base1 ad-namecache-base
# 1.20 01-Jan-2020 jmcneill

branches: 1.20.2;
Fix performance regression with previous


# 1.19 01-Jan-2020 jmcneill

dwcmmc improvements:
- Use mmcpwrseq resources if available
- Only set 4- or 8-bit mode if specified in the dt properties
- Add quirk for implementations with inverted power enable logic
- Support switching signal voltage between 1.8V and 3.3V
- Fix a clock divider issue on Rockchip SoCs


Revision tags: phil-wifi-20191119
# 1.18 05-Oct-2019 jmcneill

Add support for SDIO interrupts.


Revision tags: netbsd-9-0-RC1 netbsd-9-base
# 1.17 28-Jul-2019 jmcneill

branches: 1.17.2;
Fix infinite loop in dwc_mmc_exec_command error path


Revision tags: phil-wifi-20190609
# 1.16 30-Apr-2019 jmcneill

Simplify card detect


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.15 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728
# 1.14 02-Jul-2018 jmcneill

Reduce 10 second timeouts to 2 seconds.


Revision tags: phil-wifi-base pgoyette-compat-0625
# 1.13 19-Jun-2018 jmcneill

branches: 1.13.2;
dwcmmc: set ciu clock rate rather than assuming fixed input rate


# 1.12 10-Jun-2018 jmcneill

If the bus glue does not provide values for fifo reg offset and
fifo depth, try to auto detect based on the chip version and
value already programmed into FIFOTH.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.11 19-Jun-2017 jmcneill

branches: 1.11.4; 1.11.6;
More or less a rewrite of dwc_mmc, based on awin_mmc, adding DMA support.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.10 27-Dec-2015 jmcneill

branches: 1.10.10;
remove DWC_MMC_DEBUG


# 1.9 27-Dec-2015 jmcneill

reduce timeouts, fix clk div calculation


# 1.8 26-Dec-2015 jmcneill

Dump registers on timeout and allow bus glue to override card detect func


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.7 09-Aug-2015 jmcneill

wait for command done status before doing pio transfer


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.6 22-Jan-2015 jmcneill

branches: 1.6.2;
when resetting controller, dont preserve DWC_MMC_CTRL_REG state. makes this work on my radxa lite


# 1.5 17-Jan-2015 jmcneill

improve intr reg debugging


# 1.4 30-Dec-2014 jmcneill

Fix inverted logic of card_detect_n bit, from FUKAUMI Naoki <fun@naobsd.org>.


# 1.3 29-Dec-2014 jmcneill

- Simplify clock setup
- Add DWC_MMC_F_FORCE_CLK flag, which forces updating clock for each
command (apparently required by Rockchip)
- Let bus glue limit the max clk speed used


# 1.2 27-Dec-2014 jmcneill

- Explicitly initialize CLKSRC register.
- Reset FIFO and DMA along with controller.
- Support chips with inverted PWREN logic.
- Enable RXDR and TXDR irqs.
- Set max clk based on supplied clock freq.
- Use external clk control as well as internal divisor to set clock rates.
Requires bus glue to implement sc_set_clkdiv callback.


# 1.1 27-Dec-2014 jmcneill

add DesignWare SD/MMC controller driver


# 1.26 20-Mar-2020 skrll

Disable thrctrl or now and note why


# 1.25 20-Mar-2020 skrll

Remember / use sc_verid


# 1.24 20-Mar-2020 skrll

Trailing whitespace


# 1.23 19-Mar-2020 skrll

Release the sc_intr_lock on error


Revision tags: ad-namecache-base3 ad-namecache-base2
# 1.22 23-Jan-2020 jmcneill

More SDIO stability and performance fixes


# 1.21 22-Jan-2020 jmcneill

dwc_mmc fixes:
- Rockchip uses a different SDIO int bit, so take this into consideration
- Avoid unnecessary resets and always wait for resets to complete
- kpause instead of delay while holding spinlock
- Do not attempt autostop for SD_IO_RW_EXTENDED commands
- Allow for sub-blklen byte counts for single block transfers


Revision tags: ad-namecache-base1 ad-namecache-base
# 1.20 01-Jan-2020 jmcneill

branches: 1.20.2;
Fix performance regression with previous


# 1.19 01-Jan-2020 jmcneill

dwcmmc improvements:
- Use mmcpwrseq resources if available
- Only set 4- or 8-bit mode if specified in the dt properties
- Add quirk for implementations with inverted power enable logic
- Support switching signal voltage between 1.8V and 3.3V
- Fix a clock divider issue on Rockchip SoCs


Revision tags: phil-wifi-20191119
# 1.18 05-Oct-2019 jmcneill

Add support for SDIO interrupts.


Revision tags: netbsd-9-0-RC1 netbsd-9-base
# 1.17 28-Jul-2019 jmcneill

branches: 1.17.2;
Fix infinite loop in dwc_mmc_exec_command error path


Revision tags: phil-wifi-20190609
# 1.16 30-Apr-2019 jmcneill

Simplify card detect


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.15 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728
# 1.14 02-Jul-2018 jmcneill

Reduce 10 second timeouts to 2 seconds.


Revision tags: phil-wifi-base pgoyette-compat-0625
# 1.13 19-Jun-2018 jmcneill

branches: 1.13.2;
dwcmmc: set ciu clock rate rather than assuming fixed input rate


# 1.12 10-Jun-2018 jmcneill

If the bus glue does not provide values for fifo reg offset and
fifo depth, try to auto detect based on the chip version and
value already programmed into FIFOTH.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.11 19-Jun-2017 jmcneill

branches: 1.11.4; 1.11.6;
More or less a rewrite of dwc_mmc, based on awin_mmc, adding DMA support.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.10 27-Dec-2015 jmcneill

branches: 1.10.10;
remove DWC_MMC_DEBUG


# 1.9 27-Dec-2015 jmcneill

reduce timeouts, fix clk div calculation


# 1.8 26-Dec-2015 jmcneill

Dump registers on timeout and allow bus glue to override card detect func


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.7 09-Aug-2015 jmcneill

wait for command done status before doing pio transfer


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.6 22-Jan-2015 jmcneill

branches: 1.6.2;
when resetting controller, dont preserve DWC_MMC_CTRL_REG state. makes this work on my radxa lite


# 1.5 17-Jan-2015 jmcneill

improve intr reg debugging


# 1.4 30-Dec-2014 jmcneill

Fix inverted logic of card_detect_n bit, from FUKAUMI Naoki <fun@naobsd.org>.


# 1.3 29-Dec-2014 jmcneill

- Simplify clock setup
- Add DWC_MMC_F_FORCE_CLK flag, which forces updating clock for each
command (apparently required by Rockchip)
- Let bus glue limit the max clk speed used


# 1.2 27-Dec-2014 jmcneill

- Explicitly initialize CLKSRC register.
- Reset FIFO and DMA along with controller.
- Support chips with inverted PWREN logic.
- Enable RXDR and TXDR irqs.
- Set max clk based on supplied clock freq.
- Use external clk control as well as internal divisor to set clock rates.
Requires bus glue to implement sc_set_clkdiv callback.


# 1.1 27-Dec-2014 jmcneill

add DesignWare SD/MMC controller driver


# 1.24 20-Mar-2020 skrll

Trailing whitespace


# 1.23 19-Mar-2020 skrll

Release the sc_intr_lock on error


Revision tags: ad-namecache-base3 ad-namecache-base2
# 1.22 23-Jan-2020 jmcneill

More SDIO stability and performance fixes


# 1.21 22-Jan-2020 jmcneill

dwc_mmc fixes:
- Rockchip uses a different SDIO int bit, so take this into consideration
- Avoid unnecessary resets and always wait for resets to complete
- kpause instead of delay while holding spinlock
- Do not attempt autostop for SD_IO_RW_EXTENDED commands
- Allow for sub-blklen byte counts for single block transfers


Revision tags: ad-namecache-base1 ad-namecache-base
# 1.20 01-Jan-2020 jmcneill

branches: 1.20.2;
Fix performance regression with previous


# 1.19 01-Jan-2020 jmcneill

dwcmmc improvements:
- Use mmcpwrseq resources if available
- Only set 4- or 8-bit mode if specified in the dt properties
- Add quirk for implementations with inverted power enable logic
- Support switching signal voltage between 1.8V and 3.3V
- Fix a clock divider issue on Rockchip SoCs


Revision tags: phil-wifi-20191119
# 1.18 05-Oct-2019 jmcneill

Add support for SDIO interrupts.


Revision tags: netbsd-9-0-RC1 netbsd-9-base
# 1.17 28-Jul-2019 jmcneill

branches: 1.17.2;
Fix infinite loop in dwc_mmc_exec_command error path


Revision tags: phil-wifi-20190609
# 1.16 30-Apr-2019 jmcneill

Simplify card detect


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.15 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728
# 1.14 02-Jul-2018 jmcneill

Reduce 10 second timeouts to 2 seconds.


Revision tags: phil-wifi-base pgoyette-compat-0625
# 1.13 19-Jun-2018 jmcneill

branches: 1.13.2;
dwcmmc: set ciu clock rate rather than assuming fixed input rate


# 1.12 10-Jun-2018 jmcneill

If the bus glue does not provide values for fifo reg offset and
fifo depth, try to auto detect based on the chip version and
value already programmed into FIFOTH.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.11 19-Jun-2017 jmcneill

branches: 1.11.4; 1.11.6;
More or less a rewrite of dwc_mmc, based on awin_mmc, adding DMA support.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.10 27-Dec-2015 jmcneill

branches: 1.10.10;
remove DWC_MMC_DEBUG


# 1.9 27-Dec-2015 jmcneill

reduce timeouts, fix clk div calculation


# 1.8 26-Dec-2015 jmcneill

Dump registers on timeout and allow bus glue to override card detect func


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.7 09-Aug-2015 jmcneill

wait for command done status before doing pio transfer


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.6 22-Jan-2015 jmcneill

branches: 1.6.2;
when resetting controller, dont preserve DWC_MMC_CTRL_REG state. makes this work on my radxa lite


# 1.5 17-Jan-2015 jmcneill

improve intr reg debugging


# 1.4 30-Dec-2014 jmcneill

Fix inverted logic of card_detect_n bit, from FUKAUMI Naoki <fun@naobsd.org>.


# 1.3 29-Dec-2014 jmcneill

- Simplify clock setup
- Add DWC_MMC_F_FORCE_CLK flag, which forces updating clock for each
command (apparently required by Rockchip)
- Let bus glue limit the max clk speed used


# 1.2 27-Dec-2014 jmcneill

- Explicitly initialize CLKSRC register.
- Reset FIFO and DMA along with controller.
- Support chips with inverted PWREN logic.
- Enable RXDR and TXDR irqs.
- Set max clk based on supplied clock freq.
- Use external clk control as well as internal divisor to set clock rates.
Requires bus glue to implement sc_set_clkdiv callback.


# 1.1 27-Dec-2014 jmcneill

add DesignWare SD/MMC controller driver


# 1.22 23-Jan-2020 jmcneill

More SDIO stability and performance fixes


# 1.21 22-Jan-2020 jmcneill

dwc_mmc fixes:
- Rockchip uses a different SDIO int bit, so take this into consideration
- Avoid unnecessary resets and always wait for resets to complete
- kpause instead of delay while holding spinlock
- Do not attempt autostop for SD_IO_RW_EXTENDED commands
- Allow for sub-blklen byte counts for single block transfers


Revision tags: ad-namecache-base1 ad-namecache-base
# 1.20 01-Jan-2020 jmcneill

Fix performance regression with previous


# 1.19 01-Jan-2020 jmcneill

dwcmmc improvements:
- Use mmcpwrseq resources if available
- Only set 4- or 8-bit mode if specified in the dt properties
- Add quirk for implementations with inverted power enable logic
- Support switching signal voltage between 1.8V and 3.3V
- Fix a clock divider issue on Rockchip SoCs


Revision tags: phil-wifi-20191119
# 1.18 05-Oct-2019 jmcneill

Add support for SDIO interrupts.


Revision tags: netbsd-9-0-RC1 netbsd-9-base
# 1.17 28-Jul-2019 jmcneill

branches: 1.17.2;
Fix infinite loop in dwc_mmc_exec_command error path


Revision tags: phil-wifi-20190609
# 1.16 30-Apr-2019 jmcneill

Simplify card detect


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.15 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728
# 1.14 02-Jul-2018 jmcneill

Reduce 10 second timeouts to 2 seconds.


Revision tags: phil-wifi-base pgoyette-compat-0625
# 1.13 19-Jun-2018 jmcneill

branches: 1.13.2;
dwcmmc: set ciu clock rate rather than assuming fixed input rate


# 1.12 10-Jun-2018 jmcneill

If the bus glue does not provide values for fifo reg offset and
fifo depth, try to auto detect based on the chip version and
value already programmed into FIFOTH.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.11 19-Jun-2017 jmcneill

branches: 1.11.4; 1.11.6;
More or less a rewrite of dwc_mmc, based on awin_mmc, adding DMA support.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.10 27-Dec-2015 jmcneill

branches: 1.10.10;
remove DWC_MMC_DEBUG


# 1.9 27-Dec-2015 jmcneill

reduce timeouts, fix clk div calculation


# 1.8 26-Dec-2015 jmcneill

Dump registers on timeout and allow bus glue to override card detect func


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.7 09-Aug-2015 jmcneill

wait for command done status before doing pio transfer


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.6 22-Jan-2015 jmcneill

branches: 1.6.2;
when resetting controller, dont preserve DWC_MMC_CTRL_REG state. makes this work on my radxa lite


# 1.5 17-Jan-2015 jmcneill

improve intr reg debugging


# 1.4 30-Dec-2014 jmcneill

Fix inverted logic of card_detect_n bit, from FUKAUMI Naoki <fun@naobsd.org>.


# 1.3 29-Dec-2014 jmcneill

- Simplify clock setup
- Add DWC_MMC_F_FORCE_CLK flag, which forces updating clock for each
command (apparently required by Rockchip)
- Let bus glue limit the max clk speed used


# 1.2 27-Dec-2014 jmcneill

- Explicitly initialize CLKSRC register.
- Reset FIFO and DMA along with controller.
- Support chips with inverted PWREN logic.
- Enable RXDR and TXDR irqs.
- Set max clk based on supplied clock freq.
- Use external clk control as well as internal divisor to set clock rates.
Requires bus glue to implement sc_set_clkdiv callback.


# 1.1 27-Dec-2014 jmcneill

add DesignWare SD/MMC controller driver


# 1.21 22-Jan-2020 jmcneill

dwc_mmc fixes:
- Rockchip uses a different SDIO int bit, so take this into consideration
- Avoid unnecessary resets and always wait for resets to complete
- kpause instead of delay while holding spinlock
- Do not attempt autostop for SD_IO_RW_EXTENDED commands
- Allow for sub-blklen byte counts for single block transfers


Revision tags: ad-namecache-base1 ad-namecache-base
# 1.20 01-Jan-2020 jmcneill

Fix performance regression with previous


# 1.19 01-Jan-2020 jmcneill

dwcmmc improvements:
- Use mmcpwrseq resources if available
- Only set 4- or 8-bit mode if specified in the dt properties
- Add quirk for implementations with inverted power enable logic
- Support switching signal voltage between 1.8V and 3.3V
- Fix a clock divider issue on Rockchip SoCs


Revision tags: phil-wifi-20191119
# 1.18 05-Oct-2019 jmcneill

Add support for SDIO interrupts.


Revision tags: netbsd-9-0-RC1 netbsd-9-base
# 1.17 28-Jul-2019 jmcneill

branches: 1.17.2;
Fix infinite loop in dwc_mmc_exec_command error path


Revision tags: phil-wifi-20190609
# 1.16 30-Apr-2019 jmcneill

Simplify card detect


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.15 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728
# 1.14 02-Jul-2018 jmcneill

Reduce 10 second timeouts to 2 seconds.


Revision tags: phil-wifi-base pgoyette-compat-0625
# 1.13 19-Jun-2018 jmcneill

branches: 1.13.2;
dwcmmc: set ciu clock rate rather than assuming fixed input rate


# 1.12 10-Jun-2018 jmcneill

If the bus glue does not provide values for fifo reg offset and
fifo depth, try to auto detect based on the chip version and
value already programmed into FIFOTH.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.11 19-Jun-2017 jmcneill

branches: 1.11.4; 1.11.6;
More or less a rewrite of dwc_mmc, based on awin_mmc, adding DMA support.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.10 27-Dec-2015 jmcneill

branches: 1.10.10;
remove DWC_MMC_DEBUG


# 1.9 27-Dec-2015 jmcneill

reduce timeouts, fix clk div calculation


# 1.8 26-Dec-2015 jmcneill

Dump registers on timeout and allow bus glue to override card detect func


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.7 09-Aug-2015 jmcneill

wait for command done status before doing pio transfer


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.6 22-Jan-2015 jmcneill

branches: 1.6.2;
when resetting controller, dont preserve DWC_MMC_CTRL_REG state. makes this work on my radxa lite


# 1.5 17-Jan-2015 jmcneill

improve intr reg debugging


# 1.4 30-Dec-2014 jmcneill

Fix inverted logic of card_detect_n bit, from FUKAUMI Naoki <fun@naobsd.org>.


# 1.3 29-Dec-2014 jmcneill

- Simplify clock setup
- Add DWC_MMC_F_FORCE_CLK flag, which forces updating clock for each
command (apparently required by Rockchip)
- Let bus glue limit the max clk speed used


# 1.2 27-Dec-2014 jmcneill

- Explicitly initialize CLKSRC register.
- Reset FIFO and DMA along with controller.
- Support chips with inverted PWREN logic.
- Enable RXDR and TXDR irqs.
- Set max clk based on supplied clock freq.
- Use external clk control as well as internal divisor to set clock rates.
Requires bus glue to implement sc_set_clkdiv callback.


# 1.1 27-Dec-2014 jmcneill

add DesignWare SD/MMC controller driver


# 1.20 01-Jan-2020 jmcneill

Fix performance regression with previous


# 1.19 01-Jan-2020 jmcneill

dwcmmc improvements:
- Use mmcpwrseq resources if available
- Only set 4- or 8-bit mode if specified in the dt properties
- Add quirk for implementations with inverted power enable logic
- Support switching signal voltage between 1.8V and 3.3V
- Fix a clock divider issue on Rockchip SoCs


Revision tags: phil-wifi-20191119
# 1.18 05-Oct-2019 jmcneill

Add support for SDIO interrupts.


Revision tags: netbsd-9-0-RC1 netbsd-9-base
# 1.17 28-Jul-2019 jmcneill

Fix infinite loop in dwc_mmc_exec_command error path


Revision tags: phil-wifi-20190609
# 1.16 30-Apr-2019 jmcneill

Simplify card detect


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.15 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728
# 1.14 02-Jul-2018 jmcneill

Reduce 10 second timeouts to 2 seconds.


Revision tags: phil-wifi-base pgoyette-compat-0625
# 1.13 19-Jun-2018 jmcneill

branches: 1.13.2;
dwcmmc: set ciu clock rate rather than assuming fixed input rate


# 1.12 10-Jun-2018 jmcneill

If the bus glue does not provide values for fifo reg offset and
fifo depth, try to auto detect based on the chip version and
value already programmed into FIFOTH.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.11 19-Jun-2017 jmcneill

branches: 1.11.4; 1.11.6;
More or less a rewrite of dwc_mmc, based on awin_mmc, adding DMA support.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.10 27-Dec-2015 jmcneill

branches: 1.10.10;
remove DWC_MMC_DEBUG


# 1.9 27-Dec-2015 jmcneill

reduce timeouts, fix clk div calculation


# 1.8 26-Dec-2015 jmcneill

Dump registers on timeout and allow bus glue to override card detect func


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.7 09-Aug-2015 jmcneill

wait for command done status before doing pio transfer


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.6 22-Jan-2015 jmcneill

branches: 1.6.2;
when resetting controller, dont preserve DWC_MMC_CTRL_REG state. makes this work on my radxa lite


# 1.5 17-Jan-2015 jmcneill

improve intr reg debugging


# 1.4 30-Dec-2014 jmcneill

Fix inverted logic of card_detect_n bit, from FUKAUMI Naoki <fun@naobsd.org>.


# 1.3 29-Dec-2014 jmcneill

- Simplify clock setup
- Add DWC_MMC_F_FORCE_CLK flag, which forces updating clock for each
command (apparently required by Rockchip)
- Let bus glue limit the max clk speed used


# 1.2 27-Dec-2014 jmcneill

- Explicitly initialize CLKSRC register.
- Reset FIFO and DMA along with controller.
- Support chips with inverted PWREN logic.
- Enable RXDR and TXDR irqs.
- Set max clk based on supplied clock freq.
- Use external clk control as well as internal divisor to set clock rates.
Requires bus glue to implement sc_set_clkdiv callback.


# 1.1 27-Dec-2014 jmcneill

add DesignWare SD/MMC controller driver


# 1.18 05-Oct-2019 jmcneill

Add support for SDIO interrupts.


Revision tags: netbsd-9-base
# 1.17 28-Jul-2019 jmcneill

Fix infinite loop in dwc_mmc_exec_command error path


Revision tags: phil-wifi-20190609
# 1.16 30-Apr-2019 jmcneill

Simplify card detect


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.15 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728
# 1.14 02-Jul-2018 jmcneill

Reduce 10 second timeouts to 2 seconds.


Revision tags: phil-wifi-base pgoyette-compat-0625
# 1.13 19-Jun-2018 jmcneill

branches: 1.13.2;
dwcmmc: set ciu clock rate rather than assuming fixed input rate


# 1.12 10-Jun-2018 jmcneill

If the bus glue does not provide values for fifo reg offset and
fifo depth, try to auto detect based on the chip version and
value already programmed into FIFOTH.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.11 19-Jun-2017 jmcneill

branches: 1.11.4; 1.11.6;
More or less a rewrite of dwc_mmc, based on awin_mmc, adding DMA support.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.10 27-Dec-2015 jmcneill

branches: 1.10.10;
remove DWC_MMC_DEBUG


# 1.9 27-Dec-2015 jmcneill

reduce timeouts, fix clk div calculation


# 1.8 26-Dec-2015 jmcneill

Dump registers on timeout and allow bus glue to override card detect func


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.7 09-Aug-2015 jmcneill

wait for command done status before doing pio transfer


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.6 22-Jan-2015 jmcneill

branches: 1.6.2;
when resetting controller, dont preserve DWC_MMC_CTRL_REG state. makes this work on my radxa lite


# 1.5 17-Jan-2015 jmcneill

improve intr reg debugging


# 1.4 30-Dec-2014 jmcneill

Fix inverted logic of card_detect_n bit, from FUKAUMI Naoki <fun@naobsd.org>.


# 1.3 29-Dec-2014 jmcneill

- Simplify clock setup
- Add DWC_MMC_F_FORCE_CLK flag, which forces updating clock for each
command (apparently required by Rockchip)
- Let bus glue limit the max clk speed used


# 1.2 27-Dec-2014 jmcneill

- Explicitly initialize CLKSRC register.
- Reset FIFO and DMA along with controller.
- Support chips with inverted PWREN logic.
- Enable RXDR and TXDR irqs.
- Set max clk based on supplied clock freq.
- Use external clk control as well as internal divisor to set clock rates.
Requires bus glue to implement sc_set_clkdiv callback.


# 1.1 27-Dec-2014 jmcneill

add DesignWare SD/MMC controller driver


# 1.17 28-Jul-2019 jmcneill

Fix infinite loop in dwc_mmc_exec_command error path


Revision tags: phil-wifi-20190609
# 1.16 30-Apr-2019 jmcneill

Simplify card detect


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.15 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728
# 1.14 02-Jul-2018 jmcneill

Reduce 10 second timeouts to 2 seconds.


Revision tags: phil-wifi-base pgoyette-compat-0625
# 1.13 19-Jun-2018 jmcneill

branches: 1.13.2;
dwcmmc: set ciu clock rate rather than assuming fixed input rate


# 1.12 10-Jun-2018 jmcneill

If the bus glue does not provide values for fifo reg offset and
fifo depth, try to auto detect based on the chip version and
value already programmed into FIFOTH.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.11 19-Jun-2017 jmcneill

branches: 1.11.4; 1.11.6;
More or less a rewrite of dwc_mmc, based on awin_mmc, adding DMA support.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.10 27-Dec-2015 jmcneill

branches: 1.10.10;
remove DWC_MMC_DEBUG


# 1.9 27-Dec-2015 jmcneill

reduce timeouts, fix clk div calculation


# 1.8 26-Dec-2015 jmcneill

Dump registers on timeout and allow bus glue to override card detect func


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.7 09-Aug-2015 jmcneill

wait for command done status before doing pio transfer


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.6 22-Jan-2015 jmcneill

branches: 1.6.2;
when resetting controller, dont preserve DWC_MMC_CTRL_REG state. makes this work on my radxa lite


# 1.5 17-Jan-2015 jmcneill

improve intr reg debugging


# 1.4 30-Dec-2014 jmcneill

Fix inverted logic of card_detect_n bit, from FUKAUMI Naoki <fun@naobsd.org>.


# 1.3 29-Dec-2014 jmcneill

- Simplify clock setup
- Add DWC_MMC_F_FORCE_CLK flag, which forces updating clock for each
command (apparently required by Rockchip)
- Let bus glue limit the max clk speed used


# 1.2 27-Dec-2014 jmcneill

- Explicitly initialize CLKSRC register.
- Reset FIFO and DMA along with controller.
- Support chips with inverted PWREN logic.
- Enable RXDR and TXDR irqs.
- Set max clk based on supplied clock freq.
- Use external clk control as well as internal divisor to set clock rates.
Requires bus glue to implement sc_set_clkdiv callback.


# 1.1 27-Dec-2014 jmcneill

add DesignWare SD/MMC controller driver


# 1.16 30-Apr-2019 jmcneill

Simplify card detect


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.15 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728
# 1.14 02-Jul-2018 jmcneill

Reduce 10 second timeouts to 2 seconds.


Revision tags: phil-wifi-base pgoyette-compat-0625
# 1.13 19-Jun-2018 jmcneill

dwcmmc: set ciu clock rate rather than assuming fixed input rate


# 1.12 10-Jun-2018 jmcneill

If the bus glue does not provide values for fifo reg offset and
fifo depth, try to auto detect based on the chip version and
value already programmed into FIFOTH.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.11 19-Jun-2017 jmcneill

branches: 1.11.4; 1.11.6;
More or less a rewrite of dwc_mmc, based on awin_mmc, adding DMA support.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.10 27-Dec-2015 jmcneill

branches: 1.10.10;
remove DWC_MMC_DEBUG


# 1.9 27-Dec-2015 jmcneill

reduce timeouts, fix clk div calculation


# 1.8 26-Dec-2015 jmcneill

Dump registers on timeout and allow bus glue to override card detect func


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.7 09-Aug-2015 jmcneill

wait for command done status before doing pio transfer


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.6 22-Jan-2015 jmcneill

branches: 1.6.2;
when resetting controller, dont preserve DWC_MMC_CTRL_REG state. makes this work on my radxa lite


# 1.5 17-Jan-2015 jmcneill

improve intr reg debugging


# 1.4 30-Dec-2014 jmcneill

Fix inverted logic of card_detect_n bit, from FUKAUMI Naoki <fun@naobsd.org>.


# 1.3 29-Dec-2014 jmcneill

- Simplify clock setup
- Add DWC_MMC_F_FORCE_CLK flag, which forces updating clock for each
command (apparently required by Rockchip)
- Let bus glue limit the max clk speed used


# 1.2 27-Dec-2014 jmcneill

- Explicitly initialize CLKSRC register.
- Reset FIFO and DMA along with controller.
- Support chips with inverted PWREN logic.
- Enable RXDR and TXDR irqs.
- Set max clk based on supplied clock freq.
- Use external clk control as well as internal divisor to set clock rates.
Requires bus glue to implement sc_set_clkdiv callback.


# 1.1 27-Dec-2014 jmcneill

add DesignWare SD/MMC controller driver


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.15 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728
# 1.14 02-Jul-2018 jmcneill

Reduce 10 second timeouts to 2 seconds.


Revision tags: phil-wifi-base pgoyette-compat-0625
# 1.13 19-Jun-2018 jmcneill

dwcmmc: set ciu clock rate rather than assuming fixed input rate


# 1.12 10-Jun-2018 jmcneill

If the bus glue does not provide values for fifo reg offset and
fifo depth, try to auto detect based on the chip version and
value already programmed into FIFOTH.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.11 19-Jun-2017 jmcneill

branches: 1.11.4; 1.11.6;
More or less a rewrite of dwc_mmc, based on awin_mmc, adding DMA support.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.10 27-Dec-2015 jmcneill

branches: 1.10.10;
remove DWC_MMC_DEBUG


# 1.9 27-Dec-2015 jmcneill

reduce timeouts, fix clk div calculation


# 1.8 26-Dec-2015 jmcneill

Dump registers on timeout and allow bus glue to override card detect func


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.7 09-Aug-2015 jmcneill

wait for command done status before doing pio transfer


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.6 22-Jan-2015 jmcneill

branches: 1.6.2;
when resetting controller, dont preserve DWC_MMC_CTRL_REG state. makes this work on my radxa lite


# 1.5 17-Jan-2015 jmcneill

improve intr reg debugging


# 1.4 30-Dec-2014 jmcneill

Fix inverted logic of card_detect_n bit, from FUKAUMI Naoki <fun@naobsd.org>.


# 1.3 29-Dec-2014 jmcneill

- Simplify clock setup
- Add DWC_MMC_F_FORCE_CLK flag, which forces updating clock for each
command (apparently required by Rockchip)
- Let bus glue limit the max clk speed used


# 1.2 27-Dec-2014 jmcneill

- Explicitly initialize CLKSRC register.
- Reset FIFO and DMA along with controller.
- Support chips with inverted PWREN logic.
- Enable RXDR and TXDR irqs.
- Set max clk based on supplied clock freq.
- Use external clk control as well as internal divisor to set clock rates.
Requires bus glue to implement sc_set_clkdiv callback.


# 1.1 27-Dec-2014 jmcneill

add DesignWare SD/MMC controller driver


# 1.11 19-Jun-2017 jmcneill

More or less a rewrite of dwc_mmc, based on awin_mmc, adding DMA support.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.10 27-Dec-2015 jmcneill

remove DWC_MMC_DEBUG


# 1.9 27-Dec-2015 jmcneill

reduce timeouts, fix clk div calculation


# 1.8 26-Dec-2015 jmcneill

Dump registers on timeout and allow bus glue to override card detect func


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.7 09-Aug-2015 jmcneill

wait for command done status before doing pio transfer


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.6 22-Jan-2015 jmcneill

branches: 1.6.2;
when resetting controller, dont preserve DWC_MMC_CTRL_REG state. makes this work on my radxa lite


# 1.5 17-Jan-2015 jmcneill

improve intr reg debugging


# 1.4 30-Dec-2014 jmcneill

Fix inverted logic of card_detect_n bit, from FUKAUMI Naoki <fun@naobsd.org>.


# 1.3 29-Dec-2014 jmcneill

- Simplify clock setup
- Add DWC_MMC_F_FORCE_CLK flag, which forces updating clock for each
command (apparently required by Rockchip)
- Let bus glue limit the max clk speed used


# 1.2 27-Dec-2014 jmcneill

- Explicitly initialize CLKSRC register.
- Reset FIFO and DMA along with controller.
- Support chips with inverted PWREN logic.
- Enable RXDR and TXDR irqs.
- Set max clk based on supplied clock freq.
- Use external clk control as well as internal divisor to set clock rates.
Requires bus glue to implement sc_set_clkdiv callback.


# 1.1 27-Dec-2014 jmcneill

add DesignWare SD/MMC controller driver


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.10 27-Dec-2015 jmcneill

remove DWC_MMC_DEBUG


# 1.9 27-Dec-2015 jmcneill

reduce timeouts, fix clk div calculation


# 1.8 26-Dec-2015 jmcneill

Dump registers on timeout and allow bus glue to override card detect func


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.7 09-Aug-2015 jmcneill

wait for command done status before doing pio transfer


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.6 22-Jan-2015 jmcneill

branches: 1.6.2;
when resetting controller, dont preserve DWC_MMC_CTRL_REG state. makes this work on my radxa lite


# 1.5 17-Jan-2015 jmcneill

improve intr reg debugging


# 1.4 30-Dec-2014 jmcneill

Fix inverted logic of card_detect_n bit, from FUKAUMI Naoki <fun@naobsd.org>.


# 1.3 29-Dec-2014 jmcneill

- Simplify clock setup
- Add DWC_MMC_F_FORCE_CLK flag, which forces updating clock for each
command (apparently required by Rockchip)
- Let bus glue limit the max clk speed used


# 1.2 27-Dec-2014 jmcneill

- Explicitly initialize CLKSRC register.
- Reset FIFO and DMA along with controller.
- Support chips with inverted PWREN logic.
- Enable RXDR and TXDR irqs.
- Set max clk based on supplied clock freq.
- Use external clk control as well as internal divisor to set clock rates.
Requires bus glue to implement sc_set_clkdiv callback.


# 1.1 27-Dec-2014 jmcneill

add DesignWare SD/MMC controller driver