From owner-freebsd-embedded@FreeBSD.ORG Mon Oct 6 14:51:33 2014 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 354F8BE3; Mon, 6 Oct 2014 14:51:33 +0000 (UTC) Received: from mail-ob0-x230.google.com (mail-ob0-x230.google.com [IPv6:2607:f8b0:4003:c01::230]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DBF977EA; Mon, 6 Oct 2014 14:51:32 +0000 (UTC) Received: by mail-ob0-f176.google.com with SMTP id m8so3954478obr.35 for ; Mon, 06 Oct 2014 07:51:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=4Pvbf1YJxwya+gXEQNQ/DT4tGPC6OFotweQIyWwQpVU=; b=kQUEj3zdTDKGOSaBEgOnbrQG7R18oUYwSvMq/JdwHXFujmx8RgJFqGW4N4Kwf0KKbA ONFVuTQHxUrUMupCCk9zfUzrkoY4Gph8u8Kf5ymESMeAnsgYunD9Z0IhHBEX4tPZ+GSo UV7hvC6R5v/BZ1yNJuoi2KDuIqMlJn8v6TdWV+D/GtAYJZ1eRxfPrf6HPsm6wd0EaBEC 6FJasYQrbJy5sueFS8FcGJyW9m9WN0pl3qKfezHZ8fUCyW+d1Xn7j1Aj2HcGVo282P1c 5Xr8k9guccmQAN/4bbHhO3xjVvKQuPN9mKP/0hEDsmwP2nEHjCBJ0JktrPvP+6cbQKMj eh+A== MIME-Version: 1.0 X-Received: by 10.60.102.100 with SMTP id fn4mr28063611oeb.30.1412607092084; Mon, 06 Oct 2014 07:51:32 -0700 (PDT) Received: by 10.60.118.196 with HTTP; Mon, 6 Oct 2014 07:51:32 -0700 (PDT) In-Reply-To: <1412606675.12052.112.camel@revolution.hippie.lan> References: <1412606675.12052.112.camel@revolution.hippie.lan> Date: Mon, 6 Oct 2014 11:51:32 -0300 Message-ID: Subject: Re: A few questions about SD/MMC drivers From: Martin Galvan To: Ian Lepore Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: freebsd-drivers@freebsd.org, freebsd-embedded@freebsd.org X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Oct 2014 14:51:33 -0000 2014-10-06 11:44 GMT-03:00 Ian Lepore : > On Sun, 2014-10-05 at 21:32 -0300, Martin Galvan wrote: >> Hi Warner! Thanks for your answer. >> >> 2014-10-05 20:06 GMT-03:00 Warner Losh : >> > On Oct 5, 2014, at 4:05 PM, Martin Galvan wrot= e: >> > >> >> 2) The code I'm working on is based off the Linux driver for the same >> >> host, which as of today stands as the only "documentation", so to >> >> speak, on that particular host. According to the Linux driver, we nee= d >> >> to do a phase shift adjustment while setting the clock in the set_ios >> >> function. That involves several steps, one of which is calling >> >> clk_set_rate, which seems to be a function many other Linux drivers >> >> use. As I'm not familiar with Linux kernel internals, so far I haven'= t >> >> been able to find the equivalent for that function on BSD, so how >> >> should I go about this? >> > >> > Most likely you=E2=80=99ll need to write the clock infrastructure for = allwinner to >> > make this work. I don=E2=80=99t believe that it is actually there toda= y. Note: I=E2=80=99ve >> > not looked at the allwinner core code in a long time, so maybe this >> > has already been rectified. >> >> Well, there's a a10_clk.c file in the current tree that (sort of) >> takes care of the clocking for Allwinner. >> >> > clk_set_rate in Linux adjusts the produced clock frequency for a clock >> > that=E2=80=99s programmable in the SoC. >> > > The phase shift adjustment thing sounds like support for the Ultra rates > (clocks faster than 50mhz and clocking data on both clock edges). I > think people would be plenty happy to have 25 and 50mhz support without > any of the ultra rates, for starters. That may let you ignore the phase > tuning stuff. Maybe look at the driver in u-boot if it has one, often > the u-boot drivers are simplified compared to the full linux driver. I'm not sure if that's exactly the case. Quoting the author of the Linux dr= iver: "you have to clock up mmc0 mod clock and adapt the phase shift in order to compensate the delays caused by line distance on the PCB. This is done in here: https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/drive= rs/mmc/host/sunxi-mmc.c?id=3D3cbcb16095f916f50a5a55066fcc4be06946ce1e#n617 " > Also, it may be that if you do an "mmc init" in u-boot the driver will > work without doing any more clock stuff at all, because u-boot will do > all the hardware setup. It's best if our drivers can set up what they > need for themselves, but letting u-boot do it is a good starting point. That's a great idea, I never thought of looking at the u-boot driver. I'll try out DMA and multiblock first anyways, and if it works fast enough to at least be able to boot directly from the SD card I'll send you guys the patches.