From owner-svn-src-all@freebsd.org Mon Feb 26 21:29:02 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3BBAAF23F81; Mon, 26 Feb 2018 21:29:02 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E26296A754; Mon, 26 Feb 2018 21:29:01 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DC23120E40; Mon, 26 Feb 2018 21:29:01 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1QLT1J2090037; Mon, 26 Feb 2018 21:29:01 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1QLT1A1090035; Mon, 26 Feb 2018 21:29:01 GMT (envelope-from manu@FreeBSD.org) Message-Id: <201802262129.w1QLT1A1090035@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Mon, 26 Feb 2018 21:29:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r330038 - in head/sys: conf dev/mmc/host X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: in head/sys: conf dev/mmc/host X-SVN-Commit-Revision: 330038 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Feb 2018 21:29:02 -0000 Author: manu Date: Mon Feb 26 21:29:01 2018 New Revision: 330038 URL: https://svnweb.freebsd.org/changeset/base/330038 Log: dwmmc_rockchip: Add support for rk3328-dw-mshc * Do not use pio mode like rk2928 * Change clocks frequency in update_ios Tested-On: Pine64 Rock64 (RK3328) Modified: head/sys/conf/files.arm64 head/sys/dev/mmc/host/dwmmc_rockchip.c Modified: head/sys/conf/files.arm64 ============================================================================== --- head/sys/conf/files.arm64 Mon Feb 26 21:27:42 2018 (r330037) +++ head/sys/conf/files.arm64 Mon Feb 26 21:29:01 2018 (r330038) @@ -185,6 +185,7 @@ dev/hwpmc/hwpmc_arm64_md.c optional hwpmc dev/mbox/mbox_if.m optional soc_brcm_bcm2837 dev/mmc/host/dwmmc.c optional dwmmc fdt dev/mmc/host/dwmmc_hisi.c optional dwmmc fdt soc_hisi_hi6220 +dev/mmc/host/dwmmc_rockchip.c optional dwmmc fdt soc_rockchip_rk3328 dev/neta/if_mvneta_fdt.c optional neta fdt dev/neta/if_mvneta.c optional neta mdio mii dev/ofw/ofw_cpu.c optional fdt Modified: head/sys/dev/mmc/host/dwmmc_rockchip.c ============================================================================== --- head/sys/dev/mmc/host/dwmmc_rockchip.c Mon Feb 26 21:27:42 2018 (r330037) +++ head/sys/dev/mmc/host/dwmmc_rockchip.c Mon Feb 26 21:29:01 2018 (r330038) @@ -41,11 +41,19 @@ __FBSDID("$FreeBSD$"); #include +enum RKTYPE { + RK2928 = 1, + RK3328, +}; + static struct ofw_compat_data compat_data[] = { - {"rockchip,rk2928-dw-mshc", 1}, + {"rockchip,rk2928-dw-mshc", RK2928}, + {"rockchip,rk3328-dw-mshc", RK3328}, {NULL, 0}, }; +static int dwmmc_rockchip_update_ios(struct dwmmc_softc *sc, struct mmc_ios *ios); + static int rockchip_dwmmc_probe(device_t dev) { @@ -66,14 +74,50 @@ static int rockchip_dwmmc_attach(device_t dev) { struct dwmmc_softc *sc; + int type; sc = device_get_softc(dev); sc->hwtype = HWTYPE_ROCKCHIP; + type = ofw_bus_search_compatible(dev, compat_data)->ocd_data; - sc->use_pio = 1; + switch (type) { + case RK2928: + sc->use_pio = 1; + break; + } + sc->pwren_inverted = 1; + sc->update_ios = &dwmmc_rockchip_update_ios; + return (dwmmc_attach(dev)); +} + +static int +dwmmc_rockchip_update_ios(struct dwmmc_softc *sc, struct mmc_ios *ios) +{ + unsigned int clock; + int error; + + if (ios->clock && ios->clock != sc->bus_hz) { + sc->bus_hz = clock = ios->clock; + /* Set the MMC clock. */ + if (sc->ciu) { + /* + * Apparently you need to set the ciu clock to + * the double of bus_hz + */ + error = clk_set_freq(sc->ciu, clock * 2, + CLK_SET_ROUND_DOWN); + if (error != 0) { + device_printf(sc->dev, + "failed to set frequency to %u Hz: %d\n", + clock, error); + return (error); + } + } + } + return (0); } static device_method_t rockchip_dwmmc_methods[] = {