svn commit: r353493 - head/sys/dev/mmc/host

Emmanuel Vadot manu at bidouilliste.com
Mon Oct 14 16:11:01 UTC 2019


 Hi Ruslan,

On Mon, 14 Oct 2019 15:53:00 +0000 (UTC)
Ruslan Bukin <br at FreeBSD.org> wrote:

> Author: br
> Date: Mon Oct 14 15:52:59 2019
> New Revision: 353493
> URL: https://svnweb.freebsd.org/changeset/base/353493
> 
> Log:
>   Fix the driver attachment in cases when the external resource devices
>   (resets, regulators, clocks) are not available.
>   
>   Rely on a system initialization done by a bootloader in that cases.
>   
>   This fixes operation on Terasic DE10-Pro (an Intel Stratix 10
>   development kit).
>   
>   Sponsored by:	DARPA, AFRL
> 
> Modified:
>   head/sys/dev/mmc/host/dwmmc.c
> 
> Modified: head/sys/dev/mmc/host/dwmmc.c
> ==============================================================================
> --- head/sys/dev/mmc/host/dwmmc.c	Mon Oct 14 15:33:53 2019	(r353492)
> +++ head/sys/dev/mmc/host/dwmmc.c	Mon Oct 14 15:52:59 2019	(r353493)
> @@ -1,5 +1,5 @@
>  /*-
> - * Copyright (c) 2014 Ruslan Bukin <br at bsdpad.com>
> + * Copyright (c) 2014-2019 Ruslan Bukin <br at bsdpad.com>
>   * All rights reserved.
>   *
>   * This software was developed by SRI International and the University of
> @@ -457,26 +457,20 @@ parse_fdt(struct dwmmc_softc *sc)
>  
>  	/* IP block reset is optional */
>  	error = hwreset_get_by_ofw_name(sc->dev, 0, "reset", &sc->hwreset);
> -	if (error != 0 && error != ENOENT) {
> +	if (error != 0 && error != ENOENT)
>  		device_printf(sc->dev, "Cannot get reset\n");
> -		goto fail;
> -	}

 This is not correct, on a system without reset/clock/regulator support
you will get ENODEV as the phandle is present but no device is
associated with it. This is the case that you want to test. Currently
this hide all errors. 
 But you should really consider implementing reset/clock/regulator the
correct way for your platform otherwise a lot of thing will not work
and relying on bootloader leftover is a bad habit. Even simple thing
like sd probing can fail is the sd module clock is really high and the
controller internal divider cannot be large enough to reach the 400khz
discovery frequency.

>  	/* vmmc regulator is optional */
>  	error = regulator_get_by_ofw_property(sc->dev, 0, "vmmc-supply",
>  	     &sc->vmmc);
> -	if (error != 0 && error != ENOENT) {
> +	if (error != 0 && error != ENOENT)
>  		device_printf(sc->dev, "Cannot get regulator 'vmmc-supply'\n");
> -		goto fail;
> -	}
>  
>  	/* vqmmc regulator is optional */
>  	error = regulator_get_by_ofw_property(sc->dev, 0, "vqmmc-supply",
>  	     &sc->vqmmc);
> -	if (error != 0 && error != ENOENT) {
> +	if (error != 0 && error != ENOENT)
>  		device_printf(sc->dev, "Cannot get regulator 'vqmmc-supply'\n");
> -		goto fail;
> -	}
>  
>  	/* Assert reset first */
>  	if (sc->hwreset != NULL) {
> @@ -489,10 +483,9 @@ parse_fdt(struct dwmmc_softc *sc)
>  
>  	/* BIU (Bus Interface Unit clock) is optional */
>  	error = clk_get_by_ofw_name(sc->dev, 0, "biu", &sc->biu);
> -	if (error != 0 && error != ENOENT) {
> +	if (error != 0 && error != ENOENT)
>  		device_printf(sc->dev, "Cannot get 'biu' clock\n");
> -		goto fail;
> -	}
> +
>  	if (sc->biu) {
>  		error = clk_enable(sc->biu);
>  		if (error != 0) {
> @@ -506,10 +499,9 @@ parse_fdt(struct dwmmc_softc *sc)
>  	 * if no clock-frequency property is given
>  	 */
>  	error = clk_get_by_ofw_name(sc->dev, 0, "ciu", &sc->ciu);
> -	if (error != 0 && error != ENOENT) {
> -		device_printf(sc->dev, "Cannot get 'ciu'clock\n");
> -		goto fail;
> -	}
> +	if (error != 0 && error != ENOENT)
> +		device_printf(sc->dev, "Cannot get 'ciu' clock\n");
> +
>  	if (sc->ciu) {
>  		if (bus_hz != 0) {
>  			error = clk_set_freq(sc->ciu, bus_hz, 0);


-- 
Emmanuel Vadot <manu at bidouilliste.com> <manu at freebsd.org>


More information about the svn-src-head mailing list