From patchwork Thu Apr 19 15:37:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 133828 Delivered-To: patch@linaro.org Received: by 10.46.66.142 with SMTP id h14csp781968ljf; Thu, 19 Apr 2018 08:43:03 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/H9cXkQF9W16SbyWgbU5ORHpmfJUlK3ltldCEevBuHuxWljOINOoqPEu8P5g/aWfuxgdV6 X-Received: by 10.101.100.203 with SMTP id t11mr5650036pgv.417.1524152582942; Thu, 19 Apr 2018 08:43:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524152582; cv=none; d=google.com; s=arc-20160816; b=BykBK6XmFrMWCXpfpjg32f6gGP0VNpV8exUDD/ysoV6MHRNq4STxCZJmiQVbnu8lYp 2xAmsZfM3HJO9nQtM4BUlU22f208FSlDhzxx/QkQArXuItMynOD9zqg0W4SNxZL7eAzE uuqmL3/NwFyPIdAp0ukfv1NYqROAAeBdEazC0kd7fTQ751zui3sC1KpLYdJzXwlka4bK +A9PDEzeOxnRsd+FVrgjMriEK0uJftg5SNOeSX7X35jhYN9YafhFIh2i2AEmvqaBswii R+83IGS6POWe0f2w/ThbI8F4HkXyvRN25n6CaOwcmcCTNdS5CHuGkyryTaDjLRCKkJ8y b+3A== 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=y1ZgkHFKv0COLWh8RDJNe+FHm9B7uDpiY87mFPkC7cg=; b=uYpWdKp3NuHfjJHsHQHZUKa5/6AKXY4C0KI/4Bm6QkeKdIcWXtgWAOU1HFRXb3yyvg G138GK5yz1RDT6LFZ9nTW3EO+sTWf9PudqBxa3dR6FxaKKT9zqx3IPuWGgRlHzBKDOxW qkiu4Hb/Jwsvd0E87CxCRS3kdauiWx8tfisjKZe9r/CsfptNXmFX2q6sVJHJaublEmpb CeTn9SpdeiyQyRQ4Yyw5jAPTrWv9r/PnAWKjYL72drK5L6HysUWaYSQpg4aNgRV8xv5s fUmGRZ/cBzrhZmtdCkNKwa/XoWWfpjKvKhMSvV7lNIr/+7fLkzoE8cwaR+5gmYLi/OtD 4IXA== 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 w69si3599485pfd.332.2018.04.19.08.43.02; Thu, 19 Apr 2018 08:43:02 -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 S1753107AbeDSPnC (ORCPT + 2 others); Thu, 19 Apr 2018 11:43:02 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:6750 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752385AbeDSPnB (ORCPT ); Thu, 19 Apr 2018 11:43:01 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id C444BEBF1B500; Thu, 19 Apr 2018 23:42:46 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.361.1; Thu, 19 Apr 2018 23:42:38 +0800 From: John Garry To: , , , , , , , , CC: , , , , John Garry Subject: [PATCH] serial: 8250_of: Add IO space support Date: Thu, 19 Apr 2018 23:37:48 +0800 Message-ID: <1524152268-228631-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 -- 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 9835b1c..a7ffaf6 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.flags & IORESOURCE_TYPE_BITS) == 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; if (of_property_read_bool(np, "no-loopback-test")) port->flags |= UPF_SKIP_TEST;