From patchwork Fri Apr 27 10:36:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 134570 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp550345lji; Fri, 27 Apr 2018 03:37:28 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrxMKGdyVDALbh+lNcuLIeED+nIOaqh6wfwLcYTJKMM7UlNIoy4Bo0D4rn488paQOYlqhPU X-Received: by 10.98.61.201 with SMTP id x70mr1694305pfj.85.1524825448472; Fri, 27 Apr 2018 03:37:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524825448; cv=none; d=google.com; s=arc-20160816; b=p5aCBwoBmwRvFIkeFKKc7Q0ZKZISx7B0wqAYdWf8Jyv/zFE1DXOQb8oGqa/4Vy2uDH lEG+nsKjg/ImbTJnpWTlHK/MaXlp/19MaeRpMlvepIG/F9kVnvPx5LcNlYvXaUTz3m8Y gnZCvYBvtQcHvtJPQfVel0POq0yJA99c9UeH9qwl9UEpHWC9kBdTPCMA462K6rUYErpZ JY3jVE0upeK1Sb90bqZN7omOd3ExI48EwgxnDMnrSsUs2sV9W4pHCi/VMb8q7xQM3JUE BZyuC+5eZiv8CMwHGxoGB+88WR4EsJQLPh62LiGih3nLnS1eR2YWTbB3RZhD53jLGlc4 b2Xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=JgqOE+nxXLymnROk8qWJzAO9jBF/WcTP8pbE3MIAkfs=; b=tgm6TDA+0KFiMcPBvO4RYP1/ia65x007wCBYp/3r3XwWmsr0hIQdJ7cD1CEqQQjlb2 UJWXCD5m/YvjL+mGts85erC1Qwj/krg/bTk77G+g2NNg83Woriaz/WNPbVVswLQFXhgU g3JiZ+1pwPiEMnAAsShP38BSB12raS1jPksO4MQGcAwLcPEfUipr3LoBPPlmmJGxfixP cBch0oKEy4a1wMdp65IUFvUN0AGuhIzD8gaZOKBsY/ZYjPzD+bO8Y1qPmpSgeIcvuOiK l3dsz0QkhTo/gDo/punJrryDz5lIK3PjRz8TXDXZQHNAZDlohZbavTYiQ9oxzlltvcp7 HjpQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k19-v6si1014721pgf.550.2018.04.27.03.37.28; Fri, 27 Apr 2018 03:37:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932589AbeD0Kh1 (ORCPT + 2 others); Fri, 27 Apr 2018 06:37:27 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:7216 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932415AbeD0Kh0 (ORCPT ); Fri, 27 Apr 2018 06:37:26 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 0A058237088E3; Fri, 27 Apr 2018 18:37:12 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.361.1; Fri, 27 Apr 2018 18:37:05 +0800 From: John Garry To: , , , , , , , , CC: , , , , John Garry Subject: [PATCH v2] serial: 8250_of: Add IO space support Date: Fri, 27 Apr 2018 18:36:06 +0800 Message-ID: <1524825366-155559-1-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Currently the 8250_of driver only supports MEM IO type accesses. Some development boards (Huawei D03, specifically) require IO space access for 8250-compatible OF driver support, so add it. The modification is quite simple: just set the port iotype and associated flags depending on the device address resource type. Signed-off-by: John Garry --- Changes v1->v2: - rebase to Greg's tty-testing branch - use resource_type() helper -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-serial" 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/tty/serial/8250/8250_of.c b/drivers/tty/serial/8250/8250_of.c index 3de8d6a..bfb37f0 100644 --- a/drivers/tty/serial/8250/8250_of.c +++ b/drivers/tty/serial/8250/8250_of.c @@ -92,13 +92,43 @@ static int of_platform_serial_setup(struct platform_device *ofdev, goto err_unprepare; } + port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_FIXED_PORT | + UPF_FIXED_TYPE; spin_lock_init(&port->lock); - port->mapbase = resource.start; - port->mapsize = resource_size(&resource); - /* Check for shifted address mapping */ - if (of_property_read_u32(np, "reg-offset", &prop) == 0) - port->mapbase += prop; + if (resource_type(&resource) == IORESOURCE_IO) { + port->iotype = UPIO_PORT; + port->iobase = resource.start; + } else { + port->mapbase = resource.start; + port->mapsize = resource_size(&resource); + + /* Check for shifted address mapping */ + if (of_property_read_u32(np, "reg-offset", &prop) == 0) + port->mapbase += prop; + + port->iotype = UPIO_MEM; + if (of_property_read_u32(np, "reg-io-width", &prop) == 0) { + switch (prop) { + case 1: + port->iotype = UPIO_MEM; + break; + case 2: + port->iotype = UPIO_MEM16; + break; + case 4: + port->iotype = of_device_is_big_endian(np) ? + UPIO_MEM32BE : UPIO_MEM32; + break; + default: + dev_warn(&ofdev->dev, "unsupported reg-io-width (%d)\n", + prop); + ret = -EINVAL; + goto err_dispose; + } + } + port->flags |= UPF_IOREMAP; + } /* Check for registers offset within the devices address range */ if (of_property_read_u32(np, "reg-shift", &prop) == 0) @@ -114,26 +144,6 @@ static int of_platform_serial_setup(struct platform_device *ofdev, port->line = ret; port->irq = irq_of_parse_and_map(np, 0); - port->iotype = UPIO_MEM; - if (of_property_read_u32(np, "reg-io-width", &prop) == 0) { - switch (prop) { - case 1: - port->iotype = UPIO_MEM; - break; - case 2: - port->iotype = UPIO_MEM16; - break; - case 4: - port->iotype = of_device_is_big_endian(np) ? - UPIO_MEM32BE : UPIO_MEM32; - break; - default: - dev_warn(&ofdev->dev, "unsupported reg-io-width (%d)\n", - prop); - ret = -EINVAL; - goto err_dispose; - } - } info->rst = devm_reset_control_get_optional_shared(&ofdev->dev, NULL); if (IS_ERR(info->rst)) { @@ -147,8 +157,6 @@ static int of_platform_serial_setup(struct platform_device *ofdev, port->type = type; port->uartclk = clk; - port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP - | UPF_FIXED_PORT | UPF_FIXED_TYPE; port->irqflags |= IRQF_SHARED; if (of_property_read_bool(np, "no-loopback-test"))