From patchwork Mon Jun 19 17:11:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 777888 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3wryNn3tMCz9s7m for ; Tue, 20 Jun 2017 03:18:17 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="BrFRsbQs"; dkim-atps=neutral Received: by lists.denx.de (Postfix, from userid 105) id 48110C21CC6; Mon, 19 Jun 2017 17:16:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id B03DBC21CCF; Mon, 19 Jun 2017 17:12:48 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 15061C21CD5; Mon, 19 Jun 2017 17:12:10 +0000 (UTC) Received: from mail-oi0-f46.google.com (mail-oi0-f46.google.com [209.85.218.46]) by lists.denx.de (Postfix) with ESMTPS id B84DEC21CA3 for ; Mon, 19 Jun 2017 17:12:02 +0000 (UTC) Received: by mail-oi0-f46.google.com with SMTP id p66so25370910oia.0 for ; Mon, 19 Jun 2017 10:12:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=9y+D4HT+k64L6rcx0K0JXFPq9eRHvYZKH1gskHYCmXg=; b=BrFRsbQsZpk3y+xS3IsO9MrZKKKqB1PuR+1untdu/i8efJqMbGZ3Ii4neIenR5zvE5 Z0jPTO1s+O6J6Uu8Tj9pDclOAYYKQZHjrKU5va/Tl5jyKxpy8iFTQuzXWBawss0ENIQr JPHYUg8ye45djY+gHs4ixORxzbWxucUuN8etBt2jP3Rp3vJVbDQzR9SGzpeDzdcm7lVj H33cWPCjmKKzSM+8jPQwnsLW4SbhAG2rwyI71AIlg44Ap196oIYWjUkVaqbD/pz/98i/ pouxSa3d0GIPUs9z8RwMn+2hprH5ZPFmho7lLRVru4doCLMj/FxUKIYspvR2Etdptx+m +64w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=9y+D4HT+k64L6rcx0K0JXFPq9eRHvYZKH1gskHYCmXg=; b=EhgkUPz51xK0C8kfECEArPiei9FMKdIA47o6n1fVc47ICiQRYC3zJ/r8Yuri1DgiSY vTyL7RXVs/mU+2os4k4fsMleQIwZisVRJRldm9kHtsy4DCTQods7sObYRfPim7xBXA9x ad17HYEKvRVdQYuFaIE3CDbT4v+kCKkff5XIvKeryTqwmDpSjPn5LYKpeZ3AY1lP8ery MpZVuY69MH8mjm/ahzzJg8mOmrPK/ND66N7k6TAEuGiNAq6JZiDatmKp/aUjKiTvVTRg Ryi0DfXSpMXYqvmi4+6oxsGvmGWWK201zEHJN6FFMRSG/93ZcfLzCRbTl6+r4OSo2//v 2tpw== X-Gm-Message-State: AKS2vOydBWNoxhPMlRbOctEQDspSRzSD+jGPregeWqAYa6stIzqnTZUu 3WE9Aow/iBi0ZL3U X-Received: by 10.202.179.2 with SMTP id c2mr12621680oif.226.1497892321273; Mon, 19 Jun 2017 10:12:01 -0700 (PDT) Received: from kiwi.bld.corp.google.com ([2620:0:10f2:0:b403:80a1:2924:4bbd]) by smtp.gmail.com with ESMTPSA id a77sm5179247oic.4.2017.06.19.10.12.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 10:12:00 -0700 (PDT) Received: by kiwi.bld.corp.google.com (Postfix, from userid 121222) id 137B514210A; Mon, 19 Jun 2017 11:12:00 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Mon, 19 Jun 2017 11:11:30 -0600 Message-Id: <20170619171131.185337-14-sjg@chromium.org> X-Mailer: git-send-email 2.13.1.518.g3df882009-goog In-Reply-To: <20170619171131.185337-1-sjg@chromium.org> References: <20170619171131.185337-1-sjg@chromium.org> Cc: Hans de Goede , Maxime Ripard , Jagan Teki Subject: [U-Boot] [PATCH 13/14] dm: sata: sunxi: Add support for driver model X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Adjust SATA setup to support driver model. Signed-off-by: Simon Glass --- board/sunxi/ahci.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 58 insertions(+), 3 deletions(-) diff --git a/board/sunxi/ahci.c b/board/sunxi/ahci.c index 522e54ab16..a79b80ca1e 100644 --- a/board/sunxi/ahci.c +++ b/board/sunxi/ahci.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -13,9 +14,8 @@ /* This magic PHY initialisation was taken from the Allwinner releases * and Linux driver, but is completely undocumented. */ -static int sunxi_ahci_phy_init(u32 base) +static int sunxi_ahci_phy_init(u8 *reg_base) { - u8 *reg_base = (u8 *)base; u32 reg_val; int timeout; @@ -70,10 +70,65 @@ static int sunxi_ahci_phy_init(u32 base) return 0; } +#ifndef CONFIG_DM_SCSI void scsi_init(void) { - if (sunxi_ahci_phy_init(SUNXI_SATA_BASE) < 0) + if (sunxi_ahci_phy_init((u8 *)SUNXI_SATA_BASE) < 0) return; ahci_init((void __iomem *)SUNXI_SATA_BASE); } +#else +static int sunxi_sata_probe(struct udevice *dev) +{ + ulong base; + u8 *reg; + int ret; + + base = dev_read_addr(dev); + if (base == FDT_ADDR_T_NONE) { + debug("%s: Failed to find address (err=%d\n)", __func__, ret); + return -EINVAL; + } + reg = (u8 *)base; + ret = sunxi_ahci_phy_init(reg); + if (ret) { + debug("%s: Failed to init phy (err=%d\n)", __func__, ret); + return ret; + } + ret = ahci_probe_scsi(dev, base); + if (ret) { + debug("%s: Failed to probe (err=%d\n)", __func__, ret); + return ret; + } + + return 0; +} + +static int sunxi_sata_bind(struct udevice *dev) +{ + struct udevice *scsi_dev; + int ret; + + ret = ahci_bind_scsi(dev, &scsi_dev); + if (ret) { + debug("%s: Failed to bind (err=%d\n)", __func__, ret); + return ret; + } + + return 0; +} + +static const struct udevice_id sunxi_ahci_ids[] = { + { .compatible = "allwinner,sun4i-a10-ahci" }, + { } +}; + +U_BOOT_DRIVER(ahci_sunxi_drv) = { + .name = "ahci_sunxi", + .id = UCLASS_AHCI, + .of_match = sunxi_ahci_ids, + .bind = sunxi_sata_bind, + .probe = sunxi_sata_probe, +}; +#endif