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.7 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,URIBL_BLOCKED,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 C0DCDC07E96 for ; Tue, 6 Jul 2021 14:23:07 +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 2E68C61AC0 for ; Tue, 6 Jul 2021 14:23:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2E68C61AC0 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 E907382CDD; Tue, 6 Jul 2021 16:22:38 +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="M89RKd2m"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9F6DF82CDA; Tue, 6 Jul 2021 16:22:35 +0200 (CEST) Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) (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 CBD3D82BE0 for ; Tue, 6 Jul 2021 16:22:29 +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-wm1-x32b.google.com with SMTP id r9-20020a7bc0890000b02901f347b31d55so1881498wmh.2 for ; Tue, 06 Jul 2021 07:22:29 -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=ZU4mwYbvJvr/8hG+rrzig9nPJ/7NXQaFekdU6nST+UI=; b=M89RKd2m2fPDuPOWsZ7ashL3rXazrenJ1EpuTxIP30V2CvuW0YTSXlR9MnGiqBy0W1 bb3rSQmE7pP2AW1OOvRbrelpAfnQhsnhZI9ZEBmYVYm1gb2zdYp7FUUot5hPFwOtUDqB Z0hry6nTg1FKc0DKLxfAX5Bbku4CA4QCeHFA3iltfC+c+q5wRuN669bpEbbf5PTdxmQF 8w6+nzo/S2hNwcuEA3/yLCEhfAkTZJF8W98CdvqbuTfCVt/U5ktWImtPDxaaU4CUin4e WF/nXZgJOGCugynQt5/GgD+5KalVwvFXIruhdDUm2tACtQ/FhXp1LI3wpfATRMf5TbLS Vb7w== 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=ZU4mwYbvJvr/8hG+rrzig9nPJ/7NXQaFekdU6nST+UI=; b=sQHErDp4Zoi/44lUjunV5rPVHZkD57+epEtOvuzaC3RHndmbS1gNUkKioMdRzYY7/j Y6fYvqrBRjarvnW/vvWnNcNSlQWoobGN3PV87/ihNMCfe+NzSt1Bk1IOeRmRDF8aemUo unmXxMA06yIjMNSE3cQClejfe24gStSlHnuMKqKIaLFXXJHXLmCRPHJ0v3chcFrgNemM phdCMk/gGrUnx7t2UzAKtZZIn++0kd/ozZlii8mi+1t4/Nl5ovd6I6NmH2z+5LILZChA phuG1IqRu865EEIUwya0a9zUNTqkPH40Te9YB7hoTpjQUPFRo+Cr6HDNWj6WbiNB5OBc s1Sw== X-Gm-Message-State: AOAM530bIHN73QrhbPcVyt0ZwhIM29T7pbJh/4J8uKOXG/AafUFpTC4D l9HzYfkwzVy2HUv33NfnejI+2sa22+A= X-Google-Smtp-Source: ABdhPJyPPuEjdHqF2d0Hk9ep2zQHMFq9kFcO6vluD4wsb8EDoMMLUy/gR6qVuzyUfGi+n96kSTIIvw== X-Received: by 2002:a1c:7515:: with SMTP id o21mr1085116wmc.65.1625581349500; Tue, 06 Jul 2021 07:22:29 -0700 (PDT) Received: from workstation.lan.schwierd.dedyn.io (i5E860781.versanet.de. [94.134.7.129]) by smtp.gmail.com with ESMTPSA id t9sm16880571wrq.92.2021.07.06.07.22.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jul 2021 07:22:28 -0700 (PDT) From: Daniel Schwierzeck To: u-boot@lists.denx.de Cc: Simon Glass , Stefan Roese , Tom Rini , Daniel Schwierzeck Subject: [PATCH 3/6] pci: msc01: convert to driver model Date: Tue, 6 Jul 2021 16:22:19 +0200 Message-Id: <20210706142222.497569-4-daniel.schwierzeck@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210706142222.497569-1-daniel.schwierzeck@gmail.com> References: <20210706142222.497569-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 --- drivers/pci/pci_msc01.c | 70 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pci_msc01.c b/drivers/pci/pci_msc01.c index 04838200a8..ad203c86d0 100644 --- a/drivers/pci/pci_msc01.c +++ b/drivers/pci/pci_msc01.c @@ -4,7 +4,7 @@ * Author: Paul Burton */ -#include +#include #include #include #include @@ -62,6 +62,7 @@ static int msc01_config_access(struct msc01_pci_controller *msc01, return 0; } +#if !IS_ENABLED(CONFIG_DM_PCI) static int msc01_read_config_dword(struct pci_controller *hose, pci_dev_t dev, int where, u32 *value) { @@ -123,3 +124,70 @@ void msc01_pci_init(void *base, unsigned long sys_bus, unsigned long sys_phys, pci_register_hose(hose); hose->last_busno = pci_hose_scan(hose); } +#else +static int msc01_pci_read_config(const struct udevice *dev, pci_dev_t bdf, + uint where, ulong *val, enum pci_size_t size) +{ + struct msc01_pci_controller *msc01 = dev_get_priv(dev); + u32 data = 0; + + if (msc01_config_access(msc01, 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 msc01_pci_write_config(struct udevice *dev, pci_dev_t bdf, + uint where, ulong val, enum pci_size_t size) +{ + struct msc01_pci_controller *msc01 = dev_get_priv(dev); + u32 data = 0; + + if (size == PCI_SIZE_32) { + data = val; + } else { + u32 old; + + if (msc01_config_access(msc01, PCI_ACCESS_READ, bdf, where, &old)) + return 0; + + data = pci_conv_size_to_32(old, val, where, size); + } + + msc01_config_access(msc01, PCI_ACCESS_WRITE, bdf, where, &data); + return 0; +} + +static int msc01_pci_probe(struct udevice *dev) +{ + struct msc01_pci_controller *msc01 = dev_get_priv(dev); + + msc01->base = dev_remap_addr(dev); + if (!msc01->base) + return -EINVAL; + + return 0; +} + +static const struct dm_pci_ops msc01_pci_ops = { + .read_config = msc01_pci_read_config, + .write_config = msc01_pci_write_config, +}; + +static const struct udevice_id msc01_pci_ids[] = { + { .compatible = "mips,pci-msc01" }, + { } +}; + +U_BOOT_DRIVER(msc01_pci) = { + .name = "msc01_pci", + .id = UCLASS_PCI, + .of_match = msc01_pci_ids, + .ops = &msc01_pci_ops, + .probe = msc01_pci_probe, + .priv_auto = sizeof(struct msc01_pci_controller), +}; +#endif -- 2.32.0