Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59719C636CB for ; Thu, 15 Jul 2021 18:54:48 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 894E7613D7 for ; Thu, 15 Jul 2021 18:54:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 894E7613D7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4523D82BFA; Thu, 15 Jul 2021 20:54:41 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Cs1zNJEo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2C01882C93; Thu, 15 Jul 2021 20:54:22 +0200 (CEST) Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8452582BDD for ; Thu, 15 Jul 2021 20:54:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=daniel.schwierzeck@gmail.com Received: by mail-ed1-x52b.google.com with SMTP id h8so9603838eds.4 for ; Thu, 15 Jul 2021 11:54:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Z570aCPL64buG3vV9lG76EsWYYKiLAflDq3xsi/7tSQ=; b=Cs1zNJEoBjtInxc64ZjGmUjlDpvco4nTt4UvnoWZzU9N4mxYzyfG6WTrrnbKiAOiRi U0CVvDzhv9zVM+olPmYL9jmRo3pkEyMy1pe2MWi2Lrrx1QQk3xdye4ztXR3c+VwIEErM LerTSV4FE7u9pMI5MYlrAUv8pXo/EaM+/7Y0SAuPzh+VkexgbB5oAabRve6JlYncgGPm bnCoBoxuM2ZOMf4B8OuLh9y/4lTFlFrriNoiHUDqZ7nSTb6PfXMv5ouy3ItKmxTdHku/ wS1+htr7Pk9T1WAJj4swMigCsigr0MB0IzPrbbFnOVA8wdEI2/onDfsK26kJMwHn7D8D zZgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Z570aCPL64buG3vV9lG76EsWYYKiLAflDq3xsi/7tSQ=; b=Wiv84g7ZUFLKcV+NCPS0ZkGIsVqQI7LkPj3OHHKpDL4S3Xm/n9uiYr6/pMo90naonu 54W7+WQdhtQdzsfMtyHrMJfFgBHbq5MiKVs9Mtz8D51hvuqrwxI/8hyPipU9bLpnQm1w WZCw4i2lSh39uy/0vSQyUjstUiZxdu9Yw7IYD541+m9vVZ+5AUCOmund+cyPCwEIpJZz OY2+NJB84lENSbETmuLZmnI/JStPShS55YmvPdxcTIDGadY+7wbI1+ilwpPV2DN44RDQ 8PfmKw70K+12sBRWj23y3rJQNOAYinkpO7p1s2G7pwkc/iBCRkwPN/Aiw7/6mmTQI3mk /P/Q== X-Gm-Message-State: AOAM531V2jHGWNdFt9zHOpO1yv5BcMR06C6oI1QbRoYMl95uwXzM0rxv 2cYLlCM3iBC4D9nefo48lhULFZTLBz8= X-Google-Smtp-Source: ABdhPJwvlj/5mQTUsxXQNV2lDSitDmLh85fuguzuI/Gk9GVd+KaNDJhVQsj3eXNTwywATE2IkApeow== X-Received: by 2002:aa7:d514:: with SMTP id y20mr9049460edq.371.1626375254202; Thu, 15 Jul 2021 11:54:14 -0700 (PDT) Received: from workstation.lan.schwierd.dedyn.io (i5E860616.versanet.de. [94.134.6.22]) by smtp.gmail.com with ESMTPSA id t17sm2803486edv.75.2021.07.15.11.54.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jul 2021 11:54:13 -0700 (PDT) From: Daniel Schwierzeck To: u-boot@lists.denx.de Cc: Simon Glass , Tom Rini , Stefan Roese , Daniel Schwierzeck Subject: [PATCH v2 2/6] pci: gt64120: convert to driver model Date: Thu, 15 Jul 2021 20:53:57 +0200 Message-Id: <20210715185401.301211-3-daniel.schwierzeck@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715185401.301211-1-daniel.schwierzeck@gmail.com> References: <20210706142222.497569-1-daniel.schwierzeck@gmail.com> <20210715185401.301211-1-daniel.schwierzeck@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean This driver is currently only used on MIPS Malta boards. Signed-off-by: Daniel Schwierzeck Reviewed-by: Simon Glass --- Changes in v2: - add empty line before return statements drivers/pci/pci_gt64120.c | 74 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pci_gt64120.c b/drivers/pci/pci_gt64120.c index 80f11fedd1..e57fedf036 100644 --- a/drivers/pci/pci_gt64120.c +++ b/drivers/pci/pci_gt64120.c @@ -8,7 +8,7 @@ * Maciej W. Rozycki */ -#include +#include #include #include #include @@ -114,6 +114,7 @@ static int gt_config_access(struct gt64120_pci_controller *gt, return 0; } +#if !IS_ENABLED(CONFIG_DM_PCI) static int gt_read_config_dword(struct pci_controller *hose, pci_dev_t dev, int where, u32 *value) { @@ -175,3 +176,74 @@ void gt64120_pci_init(void *regs, unsigned long sys_bus, unsigned long sys_phys, pci_register_hose(hose); hose->last_busno = pci_hose_scan(hose); } +#else +static int gt64120_pci_read_config(const struct udevice *dev, pci_dev_t bdf, + uint where, ulong *val, + enum pci_size_t size) +{ + struct gt64120_pci_controller *gt = dev_get_priv(dev); + u32 data = 0; + + if (gt_config_access(gt, PCI_ACCESS_READ, bdf, where, &data)) { + *val = pci_get_ff(size); + return 0; + } + + *val = pci_conv_32_to_size(data, where, size); + + return 0; +} + +static int gt64120_pci_write_config(struct udevice *dev, pci_dev_t bdf, + uint where, ulong val, + enum pci_size_t size) +{ + struct gt64120_pci_controller *gt = dev_get_priv(dev); + u32 data = 0; + + if (size == PCI_SIZE_32) { + data = val; + } else { + u32 old; + + if (gt_config_access(gt, PCI_ACCESS_READ, bdf, where, &old)) + return 0; + + data = pci_conv_size_to_32(old, val, where, size); + } + + gt_config_access(gt, PCI_ACCESS_WRITE, bdf, where, &data); + + return 0; +} + +static int gt64120_pci_probe(struct udevice *dev) +{ + struct gt64120_pci_controller *gt = dev_get_priv(dev); + + gt->regs = dev_remap_addr(dev); + if (!gt->regs) + return -EINVAL; + + return 0; +} + +static const struct dm_pci_ops gt64120_pci_ops = { + .read_config = gt64120_pci_read_config, + .write_config = gt64120_pci_write_config, +}; + +static const struct udevice_id gt64120_pci_ids[] = { + { .compatible = "marvell,pci-gt64120" }, + { } +}; + +U_BOOT_DRIVER(gt64120_pci) = { + .name = "gt64120_pci", + .id = UCLASS_PCI, + .of_match = gt64120_pci_ids, + .ops = >64120_pci_ops, + .probe = gt64120_pci_probe, + .priv_auto = sizeof(struct gt64120_pci_controller), +}; +#endif -- 2.32.0