From patchwork Fri Mar 29 09:33:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10876697 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 05208922 for ; Fri, 29 Mar 2019 09:33:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4D0E290C6 for ; Fri, 29 Mar 2019 09:33:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D91D8290CF; Fri, 29 Mar 2019 09:33:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 77D4A290C6 for ; Fri, 29 Mar 2019 09:33:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728831AbfC2Jdt (ORCPT ); Fri, 29 Mar 2019 05:33:49 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:38900 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728804AbfC2Jds (ORCPT ); Fri, 29 Mar 2019 05:33:48 -0400 Received: by mail-wm1-f67.google.com with SMTP id w15so1957031wmc.3 for ; Fri, 29 Mar 2019 02:33:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JM1IFJaq9Fzy9jb7gkxjcG7uHNdo0C9cZXORwZYID2s=; b=D0JHjConPyyO0cRxQv1PUTZqVI3WTeq57J3FAP2XyHi2rJUUNI5ZC5L7oc/E6tlcJN pKNHgYGDM1aPFyKvAHOx5g33iVr1PTs45fCR7PCDPkoMwaK3YfH7RUk2J3PBNkEA4rBx sYENWcWooDcJodHMYVS5WMlwCz84djynJF+xtLKkE856uw5WapRrfx8t5I/axUlT05el Z28geVAWnsVKjM6IiysviN72ZTQI5oAQAAgMrm8iM9YB/HhM7CiR+4s/ZaZHhKAFbuf/ Gajlg7u54ny33L+HlpaZvMnZhVpGiBVJahmZS8Qsum5UFEK40GnEuuS3GpBfj74Ty3x+ hdng== 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=JM1IFJaq9Fzy9jb7gkxjcG7uHNdo0C9cZXORwZYID2s=; b=hMPMXgWYtE3q79HbROLuYrklmsHECoHkYkqHrrMVBfIFuMhVaWx3JNC8YgiHHYJUZ9 pMViVFoLn9+W82hn7naw+GDrry/VmFnosHoGnNl5IOORE3JoWL69s25UWtsBKlT4tZJ2 Jjno9ZkYfqs/c+gJNUWKYpdCd7+wLA0O8XeHrdNWHjJExmICxHs3N9vTLlTwPHxGapmd TKqPG1gqOwBRQ9E/NeQdzF70qyhH9SvUbUoCLPvJstqB7mJWSCplQDIf1hNJEPvrjLsN ligA2T+KRee9nb6sm2May45PbKZN+t1AEtusxN+SdtzZv+OJtmpipJ4fevOsfO0zJX5K cTvw== X-Gm-Message-State: APjAAAV7HtAIzELr7gGQRa9eTPsQUMouODHZi+Du/ESzBfOI8xN0QImu DxZRxLCv8S2t14zGzqJ79fEY1g== X-Google-Smtp-Source: APXvYqxBhAX2VClwpi4aYDKKs3DFdRs9olKE3HhUScClXiKL60lGO7CW7XC2L6AlxrsLRV/60+rvBw== X-Received: by 2002:a1c:f115:: with SMTP id p21mr3028614wmh.93.1553852026829; Fri, 29 Mar 2019 02:33:46 -0700 (PDT) Received: from localhost.localdomain (aputeaux-684-1-29-77.w90-86.abo.wanadoo.fr. [90.86.254.77]) by smtp.gmail.com with ESMTPSA id s12sm1957125wmj.42.2019.03.29.02.33.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Mar 2019 02:33:46 -0700 (PDT) From: Bartosz Golaszewski To: Sekhar Nori , Kevin Hilman , Alan Stern , Greg Kroah-Hartman Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 4/6] ARM: davinci: omapl138-hawk: add a fixed regulator for ohci-da8xx Date: Fri, 29 Mar 2019 10:33:32 +0100 Message-Id: <20190329093334.3885-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190329093334.3885-1-brgl@bgdev.pl> References: <20190329093334.3885-1-brgl@bgdev.pl> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bartosz Golaszewski Instead of directly using the vbus GPIO we should model it as a fixed regulator. Add all necessary fix-ups for the regulator to be registered and configure the vbus GPIO as its enable pin. Signed-off-by: Bartosz Golaszewski --- arch/arm/mach-davinci/board-omapl138-hawk.c | 49 +++++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-davinci/board-omapl138-hawk.c b/arch/arm/mach-davinci/board-omapl138-hawk.c index e244c8648594..0039b4d4c935 100644 --- a/arch/arm/mach-davinci/board-omapl138-hawk.c +++ b/arch/arm/mach-davinci/board-omapl138-hawk.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -298,15 +299,50 @@ static const short da850_hawk_usb11_pins[] = { -1 }; -static struct gpiod_lookup_table hawk_usb_gpio_lookup = { +static struct regulator_consumer_supply hawk_usb_supplies[] = { + REGULATOR_SUPPLY("vbus", NULL), +}; + +static struct regulator_init_data hawk_usb_vbus_data = { + .consumer_supplies = hawk_usb_supplies, + .num_consumer_supplies = ARRAY_SIZE(hawk_usb_supplies), +}; + +static struct fixed_voltage_config hawk_usb_vbus = { + .supply_name = "vbus", + .microvolts = 3300000, + .init_data = &hawk_usb_vbus_data, +}; + +static struct platform_device hawk_usb_vbus_device = { + .name = "reg-fixed-voltage", + .id = 1, + .dev = { + .platform_data = &hawk_usb_vbus, + }, +}; + +static struct gpiod_lookup_table hawk_usb_oc_gpio_lookup = { .dev_id = "ohci-da8xx", .table = { - GPIO_LOOKUP("davinci_gpio", DA850_USB1_VBUS_PIN, "vbus", 0), GPIO_LOOKUP("davinci_gpio", DA850_USB1_OC_PIN, "oc", 0), { } }, }; +static struct gpiod_lookup_table hawk_usb_vbus_gpio_lookup = { + .dev_id = "reg-fixed-voltage.1", + .table = { + GPIO_LOOKUP("davinci_gpio", DA850_USB1_VBUS_PIN, NULL, 0), + { } + }, +}; + +static struct gpiod_lookup_table *hawk_usb_gpio_lookups[] = { + &hawk_usb_oc_gpio_lookup, + &hawk_usb_vbus_gpio_lookup, +}; + static struct da8xx_ohci_root_hub omapl138_hawk_usb11_pdata = { /* TPS2087 switch @ 5V */ .potpgt = (3 + 1) / 2, /* 3 ms max */ @@ -327,12 +363,19 @@ static __init void omapl138_hawk_usb_init(void) pr_warn("%s: USB PHY CLK registration failed: %d\n", __func__, ret); + gpiod_add_lookup_tables(hawk_usb_gpio_lookups, + ARRAY_SIZE(hawk_usb_gpio_lookups)); + ret = da8xx_register_usb_phy(); if (ret) pr_warn("%s: USB PHY registration failed: %d\n", __func__, ret); - gpiod_add_lookup_table(&hawk_usb_gpio_lookup); + ret = platform_device_register(&hawk_usb_vbus_device); + if (ret) { + pr_warn("%s: Unable to register the vbus supply\n", __func__); + return; + } ret = da8xx_register_usb11(&omapl138_hawk_usb11_pdata); if (ret)