From patchwork Fri May 18 11:15:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 916211 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=none (p=none dis=none) header.from=xilinx.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.b="O7FK/Sw3"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40nQhM3PS3z9rxs for ; Fri, 18 May 2018 21:20:35 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 36905C21EBE; Fri, 18 May 2018 11:20:13 +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_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 3A0E8C21FB6; Fri, 18 May 2018 11:15:28 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 6F4BAC21F99; Fri, 18 May 2018 11:15:18 +0000 (UTC) Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) by lists.denx.de (Postfix) with ESMTPS id EA194C21F38 for ; Fri, 18 May 2018 11:15:13 +0000 (UTC) Received: by mail-wr0-f196.google.com with SMTP id y15-v6so8790699wrg.11 for ; Fri, 18 May 2018 04:15:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=oyxQwGrXqI6ktc+GUW25/jBGRF0+r/5Yf45rfmAIaEA=; b=O7FK/Sw3Ko8uL6ilVQYX1QHUzZexUPJFIctS1eDbVXFC4NchVqsr5fcbpoG8p15YAc fUUe/f8nxfsSCj9SKBQcvNGq/JYCPM/XrWOoWxEaZPJ45GXTKa1Db1H3TVKfaUjYMxLj 1iT27yZsCz9RjUoy29tu/0FMdDNkOHJ/IP5QuPkT/mUV1n5bfuRbErK8Qw9xQ35Qmy7b x3JlcwDre+ZGY1dAelyGrnbo5p80rLy3OdtLX2NHqgQleNzQTksqpbf+QeyVskFHIuL4 n4lvtdE19bQcRqyNgkSW6zK/5yd1e4O5tZPulr29ap7GtpK4734sc0pDx3olex4r3+EP 6V0A== 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:in-reply-to:references; bh=oyxQwGrXqI6ktc+GUW25/jBGRF0+r/5Yf45rfmAIaEA=; b=M9NZZKWOAcG0PFaKiLV0VvyHcrSvBoBHUYO7lFMkGSIk7obe6PgYtJivtYH9P9KQHx E1Nv2MKxUHZSPci71SGjX12idYtFJMf40Y5JkyJAfKs3xUvHy5+hrMjLDgHBFzirzxJy 1c0uUhdn+dzBqZd8CIKREx4MR57E3vU/f2r1ufw5ComDJtpdg0NHXgJW1CMGnef0l56I o3fa07kv7XEXzyE0GejH6TpmJz4snyPuCKHcBC0ysBcHXF9l2XUaHW3LojCH2eCEMQmG gdyLS41+fuQdrZfJWiY08xIbqIlaOqswhgRJJd6vLGrD3imZFZ7LmiOKbboglf7guMR6 dQkA== X-Gm-Message-State: ALKqPwdkkanQVzQxIpWVfrK8CL+uBw+PdWR+AbXuuDzTr/0sUmoSZTXo A/IeKXYZ85KKarW5XCiEHX2xlg== X-Google-Smtp-Source: AB8JxZor1IdhBh1gmjb3PUjN6cyq6t3eordDVt9m/0k70DdY6Vmi9KkHthurHEgME5NMUxnNMglomw== X-Received: by 2002:adf:c3d0:: with SMTP id d16-v6mr1586739wrg.68.1526642113654; Fri, 18 May 2018 04:15:13 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id m64-v6sm11651178wmb.12.2018.05.18.04.15.12 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 18 May 2018 04:15:13 -0700 (PDT) From: Michal Simek To: Marek Vasut , u-boot@lists.denx.de Date: Fri, 18 May 2018 13:15:05 +0200 Message-Id: X-Mailer: git-send-email 2.17.0 In-Reply-To: References: In-Reply-To: References: Cc: Mugunthan V N Subject: [U-Boot] [PATCH v2 2/6] usb: common: add support to get maximum speed from dt 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" From: Mugunthan V N Add support to get maximum speed from dt so that usb drivers makes use of it for DT parsing. Signed-off-by: Mugunthan V N Signed-off-by: Michal Simek (rebase and fix errors) Reviewed-by: Simon Glass --- Changes in v2: None drivers/usb/common/common.c | 29 +++++++++++++++++++++++++++++ include/linux/usb/otg.h | 9 +++++++++ 2 files changed, 38 insertions(+) diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c index 17a0ab23ff53..a55def5aba67 100644 --- a/drivers/usb/common/common.c +++ b/drivers/usb/common/common.c @@ -9,6 +9,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -37,3 +38,31 @@ enum usb_dr_mode usb_get_dr_mode(int node) return USB_DR_MODE_UNKNOWN; } + +static const char *const speed_names[] = { + [USB_SPEED_UNKNOWN] = "UNKNOWN", + [USB_SPEED_LOW] = "low-speed", + [USB_SPEED_FULL] = "full-speed", + [USB_SPEED_HIGH] = "high-speed", + [USB_SPEED_WIRELESS] = "wireless", + [USB_SPEED_SUPER] = "super-speed", +}; + +enum usb_device_speed usb_get_maximum_speed(int node) +{ + const void *fdt = gd->fdt_blob; + const char *max_speed; + int i; + + max_speed = fdt_getprop(fdt, node, "maximum-speed", NULL); + if (!max_speed) { + pr_err("usb maximum-speed not found\n"); + return USB_SPEED_UNKNOWN; + } + + for (i = 0; i < ARRAY_SIZE(speed_names); i++) + if (!strcmp(max_speed, speed_names[i])) + return i; + + return USB_SPEED_UNKNOWN; +} diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h index 0b273d8e2e8a..d2604c5cafba 100644 --- a/include/linux/usb/otg.h +++ b/include/linux/usb/otg.h @@ -25,4 +25,13 @@ enum usb_dr_mode { */ enum usb_dr_mode usb_get_dr_mode(int node); +/** + * usb_get_maximum_speed() - Get maximum speed for given device + * @node: Node offset to the given device + * + * The function gets phy interface string from property 'maximum-speed', + * and returns the correspondig enum usb_device_speed + */ +enum usb_device_speed usb_get_maximum_speed(int node); + #endif /* __LINUX_USB_OTG_H */