From patchwork Wed Apr 23 14:58:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 28900 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f71.google.com (mail-oa0-f71.google.com [209.85.219.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B1839203AC for ; Wed, 23 Apr 2014 15:02:17 +0000 (UTC) Received: by mail-oa0-f71.google.com with SMTP id j17sf6107185oag.10 for ; Wed, 23 Apr 2014 08:02:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=klurptUkdSQ8ckBHed3h4TDldi6AC8P94C/Azk2soKs=; b=XJ1MkUDzhFCPzA7CzVyFJhC/rb+fHcdvQ+I6wUtWGfemBOuz+b6xI0BEHjTLWXpOn7 IBYyJJDAMGX1994G2MurAa7qDHI/zPSNsUEYV/5p0r43MEIqSQN1TmixFnpKaKTi3ty7 qHptpWF7PsN31zS+jvxf2BjVgLV37gzaDoCVIJTrd72dt2AkbIoyhES1uMfHrwsaBWnQ bmu0yFGnB9ozYFTG05g7XxRxSNj8JJxD1d81janlyFlZVptcIn7IZX6DsAMXHxbEWG/7 cgHhk09G6oypjg26k9DA6JrxcFlXIt8C3i/HrcVGw+/VZhJEn7drgyAORS1OBWUMgd4K WU0Q== X-Gm-Message-State: ALoCoQnSU4+g5ppxb4q5u2Hsz562Y6OqP0vM2CR/6YEM2JnGY40uXb8IT1BAPSu8Tk7rz8hs2cKC X-Received: by 10.50.254.1 with SMTP id ae1mr1554747igd.6.1398265337248; Wed, 23 Apr 2014 08:02:17 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.96.201 with SMTP id k67ls649238qge.22.gmail; Wed, 23 Apr 2014 08:02:17 -0700 (PDT) X-Received: by 10.52.12.36 with SMTP id v4mr36349411vdb.20.1398265337114; Wed, 23 Apr 2014 08:02:17 -0700 (PDT) Received: from mail-ve0-f174.google.com (mail-ve0-f174.google.com [209.85.128.174]) by mx.google.com with ESMTPS id tm8si208962vdc.170.2014.04.23.08.02.17 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 23 Apr 2014 08:02:17 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.128.174; Received: by mail-ve0-f174.google.com with SMTP id oz11so1257654veb.33 for ; Wed, 23 Apr 2014 08:02:17 -0700 (PDT) X-Received: by 10.58.216.163 with SMTP id or3mr25107vec.80.1398265337008; Wed, 23 Apr 2014 08:02:17 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp110662vcb; Wed, 23 Apr 2014 08:02:15 -0700 (PDT) X-Received: by 10.68.186.33 with SMTP id fh1mr21110348pbc.140.1398265335081; Wed, 23 Apr 2014 08:02:15 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ef1si780069pbc.300.2014.04.23.08.02.11; Wed, 23 Apr 2014 08:02:11 -0700 (PDT) Received-SPF: none (google.com: devicetree-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756299AbaDWPCF (ORCPT + 9 others); Wed, 23 Apr 2014 11:02:05 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:32910 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755757AbaDWPBW (ORCPT ); Wed, 23 Apr 2014 11:01:22 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id s3NF1CmT005016; Wed, 23 Apr 2014 10:01:12 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s3NF1Ct5021607; Wed, 23 Apr 2014 10:01:12 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.174.1; Wed, 23 Apr 2014 10:01:11 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s3NF1Bnw017618; Wed, 23 Apr 2014 10:01:12 -0500 From: Felipe Balbi To: Greg KH CC: , , , , , Linux Kernel Mailing List , , , , Linux OMAP Mailing List , Tony Lindgren , Felipe Balbi Subject: [PATCH 13/13] serial: 8250: add OMAP glue Date: Wed, 23 Apr 2014 09:58:37 -0500 Message-ID: <1398265117-11793-13-git-send-email-balbi@ti.com> X-Mailer: git-send-email 1.9.2.459.g68773ac In-Reply-To: <1398265117-11793-1-git-send-email-balbi@ti.com> References: <1398265117-11793-1-git-send-email-balbi@ti.com> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: balbi@ti.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , NOT COMPLETE NYET-Signed-off-by: Felipe Balbi --- drivers/tty/serial/8250/8250_omap.c | 233 ++++++++++++++++++++++++++++++++++++ drivers/tty/serial/8250/Kconfig | 7 ++ drivers/tty/serial/8250/Makefile | 1 + 3 files changed, 241 insertions(+) create mode 100644 drivers/tty/serial/8250/8250_omap.c diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c new file mode 100644 index 0000000..e8ae479 --- /dev/null +++ b/drivers/tty/serial/8250/8250_omap.c @@ -0,0 +1,233 @@ +/* + * 8250-omap.c - OMAP adaptation for 8250 driver + * + * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com + * + * Author: Felipe Balbi + * + * Based on omap-serial.c: + * + * Copyright (C) 2010 Texas Instruments + * + * Authors: + * Govindraj R + * Thara Gopinath + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Note: This driver is made separate from 8250 driver as we cannot + * over load 8250 driver with omap platform specific configuration for + * features like DMA, it makes easier to implement features like DMA and + * hardware flow control and software flow control configuration with + * this driver as required for the omap-platform. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define OMAP_MAX_HSUART_PORTS 6 + +#define UART_BUILD_REVISION(x, y) (((x) << 8) | (y)) + +#define OMAP_UART_REV_42 0x0402 +#define OMAP_UART_REV_46 0x0406 +#define OMAP_UART_REV_52 0x0502 +#define OMAP_UART_REV_63 0x0603 + +#define OMAP_UART_TX_WAKEUP_EN BIT(7) + +/* Feature flags */ +#define OMAP_UART_WER_HAS_TX_WAKEUP BIT(0) + +#define UART_ERRATA_i202_MDR1_ACCESS BIT(0) +#define UART_ERRATA_i291_DMA_FORCEIDLE BIT(1) + +#define DEFAULT_CLK_SPEED 48000000 /* 48Mhz*/ + +/* SCR register bitmasks */ +#define OMAP_UART_SCR_RX_TRIG_GRANU1_MASK (1 << 7) +#define OMAP_UART_SCR_TX_TRIG_GRANU1_MASK (1 << 6) +#define OMAP_UART_SCR_TX_EMPTY (1 << 3) + +/* FCR register bitmasks */ +#define OMAP_UART_FCR_RX_FIFO_TRIG_MASK (0x3 << 6) +#define OMAP_UART_FCR_TX_FIFO_TRIG_MASK (0x3 << 4) + +/* MVR register bitmasks */ +#define OMAP_UART_MVR_SCHEME_SHIFT 30 + +#define OMAP_UART_LEGACY_MVR_MAJ_MASK 0xf0 +#define OMAP_UART_LEGACY_MVR_MAJ_SHIFT 4 +#define OMAP_UART_LEGACY_MVR_MIN_MASK 0x0f + +#define OMAP_UART_MVR_MAJ_MASK 0x700 +#define OMAP_UART_MVR_MAJ_SHIFT 8 +#define OMAP_UART_MVR_MIN_MASK 0x3f + +#define OMAP_UART_DMA_CH_FREE -1 + +#define MSR_SAVE_FLAGS UART_MSR_ANY_DELTA +#define OMAP_MODE13X_SPEED 230400 + +/* WER = 0x7F + * Enable module level wakeup in WER reg + */ +#define OMAP_UART_WER_MOD_WKUP 0X7F + +/* Enable XON/XOFF flow control on output */ +#define OMAP_UART_SW_TX 0x08 + +/* Enable XON/XOFF flow control on input */ +#define OMAP_UART_SW_RX 0x02 + +#define OMAP_UART_SW_CLR 0xF0 + +#define OMAP_UART_TCR_TRIG 0x0F + +struct uart_omap_port { + struct uart_8250_port uart; + struct device *dev; + int wakeirq; + + unsigned char ier; + unsigned char lcr; + unsigned char mcr; + unsigned char fcr; + unsigned char efr; + unsigned char dll; + unsigned char dlh; + unsigned char mdr1; + unsigned char scr; + unsigned char wer; + + int line; + + /* + * Some bits in registers are cleared on a read, so they must + * be saved whenever the register is read but the bits will not + * be immediately processed. + */ + unsigned int lsr_break_flag; + unsigned char msr_saved_flags; + char name[20]; + unsigned long port_activity; + int context_loss_cnt; + u32 errata; + u8 wakeups_enabled; + u32 features; +}; + +#define to_uart_omap_port(p) ((container_of((p), struct uart_omap_port, port))) + +static int serial_omap_probe(struct platform_device *pdev) +{ + struct uart_omap_port *up; + struct resource *mem; + void __iomem *base; + int uartirq = 0; + int ret; + + if (!pdev->dev.of_node) + return -ENODEV; + + uartirq = irq_of_parse_and_map(pdev->dev.of_node, 0); + if (!uartirq) + return -EPROBE_DEFER; + + up = devm_kzalloc(&pdev->dev, sizeof(*up), GFP_KERNEL); + if (!up) + return -ENOMEM; + + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); + base = devm_ioremap_resource(&pdev->dev, mem); + if (IS_ERR(base)) + return PTR_ERR(base); + + up->dev = &pdev->dev; + up->uart.port.mapbase = mem->start; + up->uart.port.membase = base; + up->uart.port.irq = uartirq; + up->uart.port.dev = &pdev->dev; + up->uart.port.type = PORT_16750; + up->uart.port.flags = UPF_SHARE_IRQ | UPF_FIXED_PORT; + up->uart.port.iotype = UPIO_MEM; + + if (of_property_read_u32(pdev->dev.of_node, "clock-frequency", + &up->uart.port.uartclk)) { + up->uart.port.uartclk = DEFAULT_CLK_SPEED; + dev_warn(&pdev->dev, + "No clock speed specified: using default: %d\n", + DEFAULT_CLK_SPEED); + } + + platform_set_drvdata(pdev, up); + + device_init_wakeup(up->dev, true); + pm_runtime_irq_safe(&pdev->dev); + pm_runtime_enable(&pdev->dev); + pm_runtime_get_sync(&pdev->dev); + + ret = serial8250_register_8250_port(&up->uart); + if (ret < 0) + goto err_add_port; + + up->line = ret; + + return 0; + +err_add_port: + pm_runtime_put(&pdev->dev); + pm_runtime_disable(&pdev->dev); + dev_err(&pdev->dev, "[UART%d]: failure [%s]: %d\n", + pdev->id, __func__, ret); + return ret; +} + +static int serial_omap_remove(struct platform_device *dev) +{ + struct uart_omap_port *up = platform_get_drvdata(dev); + + serial8250_unregister_port(up->line); + + pm_runtime_put_sync(up->dev); + pm_runtime_disable(up->dev); + + return 0; +} + +static const struct of_device_id omap_serial_of_match[] = { + { .compatible = "ti,am335x-uart" }, + {}, +}; +MODULE_DEVICE_TABLE(of, omap_serial_of_match); + +static struct platform_driver serial_omap_driver = { + .probe = serial_omap_probe, + .remove = serial_omap_remove, + .driver = { + .name = DRIVER_NAME, + .of_match_table = of_match_ptr(omap_serial_of_match), + }, +}; + +module_platform_driver(serial_omap_driver); + +MODULE_DESCRIPTION("OMAP High Speed UART driver"); +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("Texas Instruments Incorporated"); diff --git a/drivers/tty/serial/8250/Kconfig b/drivers/tty/serial/8250/Kconfig index 2332991..ad092d5 100644 --- a/drivers/tty/serial/8250/Kconfig +++ b/drivers/tty/serial/8250/Kconfig @@ -287,6 +287,13 @@ config SERIAL_8250_DW Selecting this option will enable handling of the extra features present in the Synopsys DesignWare APB UART. +config SERIAL_8250_OMAP + tristate "Support for OMAP 8250 quirks" + depends on SERIAL_8250 + help + Selecting this option will enable handling of the extra features + present in the TI OMAP UART. + config SERIAL_8250_EM tristate "Support for Emma Mobile integrated serial port" depends on SERIAL_8250 && ARM && HAVE_CLK diff --git a/drivers/tty/serial/8250/Makefile b/drivers/tty/serial/8250/Makefile index 36d68d0..0119a11 100644 --- a/drivers/tty/serial/8250/Makefile +++ b/drivers/tty/serial/8250/Makefile @@ -19,4 +19,5 @@ obj-$(CONFIG_SERIAL_8250_EXAR_ST16C554) += 8250_exar_st16c554.o obj-$(CONFIG_SERIAL_8250_HUB6) += 8250_hub6.o obj-$(CONFIG_SERIAL_8250_FSL) += 8250_fsl.o obj-$(CONFIG_SERIAL_8250_DW) += 8250_dw.o +obj-$(CONFIG_SERIAL_8250_OMAP) += 8250_omap.o obj-$(CONFIG_SERIAL_8250_EM) += 8250_em.o