From patchwork Thu Oct 18 18:45:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 986144 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="B/IK1joJ"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42bdKj05rQz9s9G for ; Fri, 19 Oct 2018 05:46:00 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 95EA9C21D74; Thu, 18 Oct 2018 18:45:53 +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=FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2, 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 290EBC21C27; Thu, 18 Oct 2018 18:45:51 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 04869C21C27; Thu, 18 Oct 2018 18:45:48 +0000 (UTC) Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by lists.denx.de (Postfix) with ESMTPS id 882AFC21BE5 for ; Thu, 18 Oct 2018 18:45:48 +0000 (UTC) Received: by mail-wm1-f66.google.com with SMTP id 206-v6so1282075wmb.5 for ; Thu, 18 Oct 2018 11:45:48 -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; bh=QnkDr7uEJmGj2lV0AizVE5gNKhzDXCWDVn5fM3qPJfM=; b=B/IK1joJOESQriFRYmpgqlYUHfavFYIEdYteAUFGGbUKE3ZpJ22EckXKphkk9EDHhi 4dIOErDgst3RaPwcB5fsXKwttJlboVDtaBH5eMWH7z/HYTnnUzvPTP5tISeFCBw8WO96 cfto1LYuR1A8+95EUiufg3cRBFDEgJQfWQ2WhQIxnEZwTg2iWlJ3QqLNZBJ1/+uobMXS NDMiVljXarEv4/aeuGLkzne/23M0qxNxV33iI5CwcoIfEp1FbROgilTEN3IWD9Glx0fO z+u/qYcBI3RZoSdXTxijb0XWMymiEPEAEkCi+vNjNaBthcR/NePc41FQsK/zugnoSx1r 4zBw== 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; bh=QnkDr7uEJmGj2lV0AizVE5gNKhzDXCWDVn5fM3qPJfM=; b=H1EoistFQbfRpZiQuVK7vLLfmJwF/QHANgmnzqUtgOxu8HiSRqLwAyrbcVwwBKWWel 4FSb0qAWfrPKD75ip7FoXycSZlugkf0lMce0fiLQcZE3Yj1A1cSEKAThZ6XAhuO7j0Nb Ba5KbhWw5yDazIQf82tbUqibbhUwAdc0fsTZGXhNikTYf9TQryQGeHfyCfL11UAbwm2X mdmk2dO7/RwHnWKaOLuULvq9EM3/E95wWcAGLZXOs2Rch4VZgZZ+oSUKHa78pObDZEXB a2twHaeRJGli0yacfxJBpCtSt1yzlbptXA/ab830Qxz4n6TthzJSctLps4Qyj6zJtJKH SdBw== X-Gm-Message-State: ABuFfogDiAqDAsEqmYcP/gDWqqkUA8J99PII05P3OTd6yiw+0Oda3jkL 1Vc/XJDLYWFEuNmGVLt/P9kFw/lx X-Google-Smtp-Source: ACcGV61MTcD9n83vj00SNocvLeqPBqtf8WtozacDkw/xOUl9zWPmq3GIN/M2KYc5NPKVz5YQcrC4qg== X-Received: by 2002:a1c:5702:: with SMTP id l2-v6mr1443831wmb.83.1539888347775; Thu, 18 Oct 2018 11:45:47 -0700 (PDT) Received: from kurokawa.lan (ip-86-49-110-70.net.upcbroadband.cz. [86.49.110.70]) by smtp.gmail.com with ESMTPSA id l38-v6sm18937733wre.38.2018.10.18.11.45.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Oct 2018 11:45:46 -0700 (PDT) From: Marek Vasut X-Google-Original-From: Marek Vasut To: u-boot@lists.denx.de Date: Thu, 18 Oct 2018 20:45:43 +0200 Message-Id: <20181018184543.22307-1-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.18.0 Cc: Marek Vasut Subject: [U-Boot] [PATCH] usb: ohci: Add OHCI PCI driver 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" Add small OHCI PCI driver for USB 1.1 OHCI controllers on PCI bus. This driver matches only on PCI class (serial-ohci) and requires DM-USB ; any sort of deprecated legacy usage is not supported. Signed-off-by: Marek Vasut --- drivers/usb/host/Kconfig | 6 ++++ drivers/usb/host/Makefile | 1 + drivers/usb/host/ohci-pci.c | 55 +++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 drivers/usb/host/ohci-pci.c diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index a213c918bc..045aa0a3f6 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -224,6 +224,12 @@ config USB_OHCI_GENERIC ---help--- Enables support for generic OHCI controller. +config USB_OHCI_PCI + bool "Support for PCI-based OHCI USB controller" + depends on DM_USB + help + Enables support for the PCI-based OHCI controller. + endif # USB_OHCI_HCD config USB_UHCI_HCD diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index cb8c315a15..b7c94cadcb 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile @@ -18,6 +18,7 @@ obj-$(CONFIG_USB_OHCI_EP93XX) += ohci-ep93xx.o obj-$(CONFIG_USB_OHCI_SUNXI) += ohci-sunxi.o obj-$(CONFIG_USB_OHCI_LPC32XX) += ohci-lpc32xx.o obj-$(CONFIG_USB_OHCI_GENERIC) += ohci-generic.o +obj-$(CONFIG_USB_OHCI_PCI) += ohci-pci.o # echi obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c new file mode 100644 index 0000000000..dd078f008e --- /dev/null +++ b/drivers/usb/host/ohci-pci.c @@ -0,0 +1,55 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2018 Marek Vasut + */ + +#include +#include +#include +#include +#include +#include + +#include "ohci.h" + +/* Information about the USB port */ +struct ohci_pci_priv { + ohci_t ohci; +}; + +static int ohci_pci_probe(struct udevice *dev) +{ + struct ohci_regs *regs; + u32 cmd; + + regs = dm_pci_map_bar(dev, PCI_BASE_ADDRESS_0, PCI_REGION_MEM); + if (!regs) + return -ENOMEM; + + /* Enable busmaster */ + dm_pci_read_config32(dev, PCI_COMMAND, &cmd); + cmd |= PCI_COMMAND_MASTER; + dm_pci_write_config32(dev, PCI_COMMAND, cmd); + + debug("OHCI-PCI init regs %p\n", regs); + + return ohci_register(dev, regs); +} + +U_BOOT_DRIVER(ohci_pci) = { + .name = "ohci_pci", + .id = UCLASS_USB, + .probe = ohci_pci_probe, + .remove = ohci_deregister, + .ops = &ohci_usb_ops, + .platdata_auto_alloc_size = sizeof(struct usb_platdata), + .priv_auto_alloc_size = sizeof(struct ohci_pci_priv), + .flags = DM_FLAG_ALLOC_PRIV_DMA, +}; + +static struct pci_device_id ohci_pci_supported[] = { + { PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_OHCI, ~0) }, + {}, +}; + +U_BOOT_PCI_DEVICE(ohci_pci, ohci_pci_supported);