From patchwork Sun Jun 26 07:28:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 70857 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp554646qgy; Sun, 26 Jun 2016 00:29:08 -0700 (PDT) X-Received: by 10.66.156.9 with SMTP id wa9mr22554476pab.64.1466926144067; Sun, 26 Jun 2016 00:29:04 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x13si18088022pal.215.2016.06.26.00.29.03; Sun, 26 Jun 2016 00:29:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752095AbcFZH2v (ORCPT + 8 others); Sun, 26 Jun 2016 03:28:51 -0400 Received: from mail-pf0-f181.google.com ([209.85.192.181]:34147 "EHLO mail-pf0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752069AbcFZH2q (ORCPT ); Sun, 26 Jun 2016 03:28:46 -0400 Received: by mail-pf0-f181.google.com with SMTP id h14so51895656pfe.1 for ; Sun, 26 Jun 2016 00:28:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mt/6ateycLV2JH1btLhTp1EC6bn+JhTIADFFnCCLB9Y=; b=A/7ONPFpADnk4QiprDCzJgdDMSkbWaIrY2FZMvT44JPHdFQxYdzmkc3wibAw3RazWr dTRQ02EgQ52tY2DyZ4Ev5h0z7KZNn98aVJIXLi94amvgz/94rorVaeAXFlB4HMXLifa2 /aUuiW0hDoQMS63vJkTd/n9XCQh29wmwaPJeI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mt/6ateycLV2JH1btLhTp1EC6bn+JhTIADFFnCCLB9Y=; b=b/84KlglR1wtYEMF4WuTltSj6FPkGxjd0JjvTLXdc3sqJZBzBgUtVhzJ0pvVwBJPsT EMkWm4KINWArmIyNs+l9reKwKDafYgdTKYCVPuPaBth8TQgV+Ww+tCdzy0ry8d9bQVta +V9xZsUAFqLIxsK+IT/fzRzTwzY+W2HpJTuPWyEQRj9XcSpcp52w1tiWHro8F/vvFfAM gQvQmypjiKP8O1tKYPib+n8rg9jSBma6kGWz2ceynWb3yBu+Paljk2iXxHkZoabif+P1 +wOXXWoQPA169EVGWw1rZ7EzS1N0Zah/+69uBQL8feVsvTMZuPUO8gIdeU3jzJXSYLZF kJYw== X-Gm-Message-State: ALyK8tLC9vFI65g5tFBR9zD+PBXILJeGIZ6GtSNCI8xZ9CcX7LMPupUzkVTQYpkF4XpkYZaz X-Received: by 10.98.9.141 with SMTP id 13mr22541780pfj.130.1466926125535; Sun, 26 Jun 2016 00:28:45 -0700 (PDT) Received: from localhost.localdomain (ip68-101-172-78.sd.sd.cox.net. [68.101.172.78]) by smtp.gmail.com with ESMTPSA id f138sm3790495pfa.17.2016.06.26.00.28.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 26 Jun 2016 00:28:45 -0700 (PDT) From: Stephen Boyd To: linux-usb@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Andy Gross , Bjorn Andersson , Neil Armstrong , Arnd Bergmann , Felipe Balbi , Greg Kroah-Hartman , Heikki Krogerus Subject: [PATCH 03/21] usb: ulpi: Avoid reading/writing in device creation with OF devices Date: Sun, 26 Jun 2016 00:28:20 -0700 Message-Id: <20160626072838.28082-4-stephen.boyd@linaro.org> X-Mailer: git-send-email 2.9.0.rc2.8.ga28705d In-Reply-To: <20160626072838.28082-1-stephen.boyd@linaro.org> References: <20160626072838.28082-1-stephen.boyd@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org ULPI devices are matched up against ULPI drivers by reading the vendor id and product id registers in the ULPI address space. Before we try to read those registers we'll do a scratch write to test the interface. Unfortunately, this doesn't work well if the ULPI device is not powered at the time of device creation. In that case, the scratch register writes fail and product and vendor ids can't be read. If the ULPI spec had some way to describe generic power requirements for the scratch, product, and vendor registers we could but power sequencing into the ULPI bus layer and power up the device before touching the hardware. Unfortunately this doesn't exist. Furthermore, the power information is device specific, so it varies from device to device and is not standard. Let's punt on doing the reads/writes here when we're using DT backed ULPI devices. This avoids any problems where we need to power on the device but haven't figured out which device it is yet to know what sort of regulators, clks, etc. that need to be turned on for it to work. Cc: Greg Kroah-Hartman Cc: Heikki Krogerus Signed-off-by: Stephen Boyd --- drivers/usb/common/ulpi.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) -- 2.9.0.rc2.8.ga28705d -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c index 980af672bfe3..a6b2a150b176 100644 --- a/drivers/usb/common/ulpi.c +++ b/drivers/usb/common/ulpi.c @@ -197,25 +197,7 @@ static int ulpi_of_register(struct ulpi *ulpi) static int ulpi_register(struct device *dev, struct ulpi *ulpi) { - int ret; - - /* Test the interface */ - ret = ulpi_write(ulpi, ULPI_SCRATCH, 0xaa); - if (ret < 0) - return ret; - - ret = ulpi_read(ulpi, ULPI_SCRATCH); - if (ret < 0) - return ret; - - if (ret != 0xaa) - return -ENODEV; - - ulpi->id.vendor = ulpi_read(ulpi, ULPI_VENDOR_ID_LOW); - ulpi->id.vendor |= ulpi_read(ulpi, ULPI_VENDOR_ID_HIGH) << 8; - - ulpi->id.product = ulpi_read(ulpi, ULPI_PRODUCT_ID_LOW); - ulpi->id.product |= ulpi_read(ulpi, ULPI_PRODUCT_ID_HIGH) << 8; + int ret = -ENODEV; ulpi->dev.parent = dev; ulpi->dev.bus = &ulpi_bus; @@ -230,6 +212,26 @@ static int ulpi_register(struct device *dev, struct ulpi *ulpi) return ret; } + if (ret) { + /* Test the interface */ + ret = ulpi_write(ulpi, ULPI_SCRATCH, 0xaa); + if (ret < 0) + return ret; + + ret = ulpi_read(ulpi, ULPI_SCRATCH); + if (ret < 0) + return ret; + + if (ret != 0xaa) + return -ENODEV; + + ulpi->id.vendor = ulpi_read(ulpi, ULPI_VENDOR_ID_LOW); + ulpi->id.vendor |= ulpi_read(ulpi, ULPI_VENDOR_ID_HIGH) << 8; + + ulpi->id.product = ulpi_read(ulpi, ULPI_PRODUCT_ID_LOW); + ulpi->id.product |= ulpi_read(ulpi, ULPI_PRODUCT_ID_HIGH) << 8; + } + if (of_device_request_module(&ulpi->dev)) request_module("ulpi:v%04xp%04x", ulpi->id.vendor, ulpi->id.product);