From patchwork Tue Jan 26 11:18:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Westerberg X-Patchwork-Id: 8120511 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9BA4CBEEE5 for ; Tue, 26 Jan 2016 11:18:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BEB0A201FE for ; Tue, 26 Jan 2016 11:18:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CF15520272 for ; Tue, 26 Jan 2016 11:18:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965246AbcAZLSi (ORCPT ); Tue, 26 Jan 2016 06:18:38 -0500 Received: from mga04.intel.com ([192.55.52.120]:63954 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934138AbcAZLSf (ORCPT ); Tue, 26 Jan 2016 06:18:35 -0500 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP; 26 Jan 2016 03:18:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,350,1449561600"; d="scan'208";a="898491276" Received: from black.fi.intel.com ([10.237.72.93]) by orsmga002.jf.intel.com with ESMTP; 26 Jan 2016 03:18:32 -0800 Received: by black.fi.intel.com (Postfix, from userid 1001) id 8D7CB14A; Tue, 26 Jan 2016 13:18:31 +0200 (EET) From: Mika Westerberg To: Mark Brown Cc: Daniel Mack , Haojian Zhuang , Robert Jarzmik , Jarkko Nikula , Mika Westerberg , Bastien Nocera , linux-spi@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] spi: pxa2xx: Translate ACPI DeviceSelection to Linux chip select on Baytrail Date: Tue, 26 Jan 2016 13:18:29 +0200 Message-Id: <1453807111-103111-3-git-send-email-mika.westerberg@linux.intel.com> X-Mailer: git-send-email 2.7.0.rc3 In-Reply-To: <1453807111-103111-1-git-send-email-mika.westerberg@linux.intel.com> References: <1453807111-103111-1-git-send-email-mika.westerberg@linux.intel.com> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The Windows Baytrail SPI host controller driver uses 1 as the first (and only) value for ACPI DeviceSelection like can be seen in DSDT taken from Lenovo Thinkpad 10: Device (FPNT) { ... Method (_CRS, 0, NotSerialized) // _CRS: Current Resource Settings { Name (UBUF, ResourceTemplate () { SpiSerialBus (0x0001, // DeviceSelection PolarityLow, FourWireMode, 0x08, ControllerInitiated, 0x007A1200, ClockPolarityLow, ClockPhaseFirst, "\\_SB.SPI1", 0x00, ResourceConsumer,,) This will fail to enumerate in Linux with following error: [ 0.241296] pxa2xx-spi 80860F0E:00: cs1 >= max 1 [ 0.241312] spi_master spi32766: failed to add SPI device VFSI6101:00 from ACPI To make the Linux SPI core successfully enumerate the device we provide a custom version of ->fw_translate_cs() that translates DeviceSelection correctly. Signed-off-by: Mika Westerberg --- drivers/spi/spi-pxa2xx.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index ab9914ad8365..baa98365a490 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -1328,11 +1328,30 @@ static int pxa2xx_spi_get_port_id(struct acpi_device *adev) port_id = devid; return port_id; } + +static int pxa2xx_spi_fw_translate_cs(struct spi_master *master, unsigned cs) +{ + struct driver_data *drv_data = spi_master_get_devdata(master); + + switch (drv_data->ssp_type) { + /* + * For Atoms the Windows driver starts enumerating chip selects + * from 1 instead of 0 so translate it here to match what Linux + * expects. + */ + case LPSS_BYT_SSP: + return cs - 1; + + default: + return cs; + } +} #else /* !CONFIG_ACPI */ static int pxa2xx_spi_get_port_id(struct acpi_device *adev) { return -1; } +#define pxa2xx_spi_fw_translate_cs NULL #endif /* @@ -1490,6 +1509,7 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) master->setup = setup; master->transfer_one_message = pxa2xx_spi_transfer_one_message; master->unprepare_transfer_hardware = pxa2xx_spi_unprepare_transfer; + master->fw_translate_cs = pxa2xx_spi_fw_translate_cs; master->auto_runtime_pm = true; drv_data->ssp_type = ssp->type;