On Sun, May 02, 2021 at 05:28:24PM +0200, Mark Kettenis wrote:
> > Date: Sun, 2 May 2021 14:21:29 +0000
> > From: Visa Hankala <v...@hankala.org>
> > 
> > Zynq-7000 has a variant of Arasan SD controller that is not recognized
> > by the fdt glue. The diff below fixes this.
> > 
> > The controller's capabilities register lacks the base clock frequency.
> > The attachment glue has to provide this parameter.
> > 
> > OK?
> > 
> > Index: dev/fdt/sdhc_fdt.c
> > ===================================================================
> > RCS file: src/sys/dev/fdt/sdhc_fdt.c,v
> > retrieving revision 1.15
> > diff -u -p -r1.15 sdhc_fdt.c
> > --- dev/fdt/sdhc_fdt.c      5 Apr 2021 09:31:45 -0000       1.15
> > +++ dev/fdt/sdhc_fdt.c      2 May 2021 14:07:45 -0000
> > @@ -126,6 +126,7 @@ sdhc_fdt_match(struct device *parent, vo
> >     struct fdt_attach_args *faa = aux;
> >  
> >     return (OF_is_compatible(faa->fa_node, "arasan,sdhci-5.1") ||
> > +       OF_is_compatible(faa->fa_node, "arasan,sdhci-8.9a") ||
> >         OF_is_compatible(faa->fa_node, "brcm,bcm2711-emmc2") ||
> >         OF_is_compatible(faa->fa_node, "brcm,bcm2835-sdhci") ||
> >         OF_is_compatible(faa->fa_node, "marvell,armada-3700-sdhci") ||
> > @@ -232,6 +233,11 @@ sdhc_fdt_attach(struct device *parent, s
> >             sc->sc.sc_flags |= SDHC_F_NODDR50;
> >     }
> >  
> > +   if (OF_is_compatible(faa->fa_node, "arasan,sdhci-8.9a")) {
> > +           freq = clock_get_frequency(faa->fa_node, "clk_xin");
> > +           sc->sc.sc_clkbase = (freq + 500) / 1000;
> 
> Is there a particular reason why you are trying to round to the
> nearest kHz here?  We don't do that for any of the other cases where
> we set sc_clkbase, and I'd prefer not to have any special cases that
> aren't necessary.

In my case, the rounding makes a displayed value look more sensible.

sdhc0 at simplebus0
sdhc0: SDHC 2.0, 100 MHz base clock
sdmmc0 at sdhc0: 4-bit, sd high-speed, mmc high-speed, dma

The clock computations use frequency 33333333 Hz as input. This value
is multiplied and divided, giving 99999990 Hz (which already has some
truncation). If this was truncated to MHz, the result would be 99 MHz.

However, if the rounding is not wanted, I can leave it out.

> > +   }
> > +
> >     if (OF_is_compatible(faa->fa_node, "brcm,bcm2711-emmc2"))
> >             sc->sc.sc_flags |= SDHC_F_NOPWR0;
> > 

Reply via email to