From patchwork Tue Nov 5 09:28:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 21327 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f197.google.com (mail-ie0-f197.google.com [209.85.223.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7014A25B39 for ; Tue, 5 Nov 2013 09:29:08 +0000 (UTC) Received: by mail-ie0-f197.google.com with SMTP id e14sf24924673iej.0 for ; Tue, 05 Nov 2013 01:29:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=wbtxNKuomySaFrasH9MnCatqGaD0tNNQxU6PksXQ2mw=; b=abNAaVO3SFBh02NT27mUc1gmOLDGqEHEMtFIbj1RkpBD+5yZtfyfQ+Ra4H/NwnH7wY XDYt7LBx6PHGEW5OVFzr70UkitXYptDThxgu5/BtKvJcOLCCxJtlxQtF7rOT8MrkMiS7 ty+0kVtMQ9EKbaadqGuI6TybTZA0YqQVHsA0p01L7uXZWQeRMTR04Dn0FLVNtIEtMlos uVeoFIZ8rHuHdlMYOf/GIxMT5X/2JwgwvD9BdhQQT7QAo4VkDeQ1HUTsD/YGWoXgPhKA YiSavIWEbQPJqN0Fjtf1iAaDAlqyZKDK0qtdedGanK7/UFt2AP3xR+B0dvvOaavYOmN8 zYjQ== X-Gm-Message-State: ALoCoQn4DHzeVs4XJEvfJ4XXFX8dacJiDfKmYkmUfWdEr8vfQ7JasClSKR0KPuW8ZyHjUzAy10Ks X-Received: by 10.182.109.164 with SMTP id ht4mr7132748obb.16.1383643747615; Tue, 05 Nov 2013 01:29:07 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.71.209 with SMTP id x17ls120323qeu.83.gmail; Tue, 05 Nov 2013 01:29:07 -0800 (PST) X-Received: by 10.220.144.18 with SMTP id x18mr14824843vcu.15.1383643747503; Tue, 05 Nov 2013 01:29:07 -0800 (PST) Received: from mail-ve0-f174.google.com (mail-ve0-f174.google.com [209.85.128.174]) by mx.google.com with ESMTPS id c8si6199769vcq.63.2013.11.05.01.29.07 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 05 Nov 2013 01:29:07 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.174; Received: by mail-ve0-f174.google.com with SMTP id pa12so2299460veb.33 for ; Tue, 05 Nov 2013 01:29:07 -0800 (PST) X-Received: by 10.52.165.131 with SMTP id yy3mr4276094vdb.25.1383643747190; Tue, 05 Nov 2013 01:29:07 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp193263vcz; Tue, 5 Nov 2013 01:29:06 -0800 (PST) X-Received: by 10.180.99.99 with SMTP id ep3mr15869504wib.11.1383643745877; Tue, 05 Nov 2013 01:29:05 -0800 (PST) Received: from mail-we0-f176.google.com (mail-we0-f176.google.com [74.125.82.176]) by mx.google.com with ESMTPS id gg7si2026193wic.5.2013.11.05.01.29.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 05 Nov 2013 01:29:05 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.176 is neither permitted nor denied by best guess record for domain of linus.walleij@linaro.org) client-ip=74.125.82.176; Received: by mail-we0-f176.google.com with SMTP id w62so3149163wes.21 for ; Tue, 05 Nov 2013 01:29:05 -0800 (PST) X-Received: by 10.180.160.240 with SMTP id xn16mr15864065wib.62.1383643745223; Tue, 05 Nov 2013 01:29:05 -0800 (PST) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id fr4sm12476303wib.0.2013.11.05.01.29.03 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Nov 2013 01:29:04 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Andrew Victor , Nicolas Ferre , Jean-Christophe Plagniol-Villard , linux-serial@vger.kernel.org, Greg Kroah-Hartman Cc: Alexandre Courbot , linux-arm-kernel@lists.infradead.org, Linus Walleij Subject: [PATCH 1/4] ARM/serial: at91: move machine quirk into machine Date: Tue, 5 Nov 2013 10:28:42 +0100 Message-Id: <1383643722-14189-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.8.3.1 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: linus.walleij@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This removes the dependency on from the AT91 serial driver by adding an mctrl callback quirk. Long term it is better if the driver calls the generic GPIO interface (gpio_set_value()), but this gets a hairy cross-depency into the machine-local headers out of the way for now. Cc: Greg Kroah-Hartman Signed-off-by: Linus Walleij --- Greg, if you're OK with this approach please give me an ACK so I can take this through the ARM SoC or GPIO tree in the end. --- arch/arm/mach-at91/at91rm9200_devices.c | 14 ++++++++++++++ drivers/tty/serial/atmel_serial.c | 19 ++++--------------- include/linux/platform_data/atmel.h | 1 + 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/arch/arm/mach-at91/at91rm9200_devices.c b/arch/arm/mach-at91/at91rm9200_devices.c index 3ebc9792560c..3ce6ba6341ed 100644 --- a/arch/arm/mach-at91/at91rm9200_devices.c +++ b/arch/arm/mach-at91/at91rm9200_devices.c @@ -12,6 +12,7 @@ */ #include #include +#include #include #include @@ -957,9 +958,22 @@ static struct resource uart0_resources[] = { }, }; +static void uart0_set_mctrl(unsigned int mctrl) +{ + /* + * AT91RM9200 Errata #39: RTS0 is not internally connected + * to PA21. We need to drive the pin manually. + */ + if (mctrl & TIOCM_RTS) + at91_set_gpio_value(AT91_PIN_PA21, 0); + else + at91_set_gpio_value(AT91_PIN_PA21, 1); +} + static struct atmel_uart_data uart0_data = { .use_dma_tx = 1, .use_dma_rx = 1, + .set_mctrl = uart0_set_mctrl, }; static u64 uart0_dmamask = DMA_BIT_MASK(32); diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c index d067285a2d20..5b29e3152d7e 100644 --- a/drivers/tty/serial/atmel_serial.c +++ b/drivers/tty/serial/atmel_serial.c @@ -47,7 +47,6 @@ #ifdef CONFIG_ARM #include -#include #endif #define PDC_BUFFER_SIZE 512 @@ -176,6 +175,7 @@ struct atmel_uart_port { void (*schedule_tx)(struct uart_port *port); void (*release_rx)(struct uart_port *port); void (*release_tx)(struct uart_port *port); + void (*set_mctrl)(unsigned int mctrl); }; static struct atmel_uart_port atmel_ports[ATMEL_MAX_UART]; @@ -300,20 +300,8 @@ static void atmel_set_mctrl(struct uart_port *port, u_int mctrl) unsigned int mode; struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); -#ifdef CONFIG_ARCH_AT91RM9200 - if (cpu_is_at91rm9200()) { - /* - * AT91RM9200 Errata #39: RTS0 is not internally connected - * to PA21. We need to drive the pin manually. - */ - if (port->mapbase == AT91RM9200_BASE_US0) { - if (mctrl & TIOCM_RTS) - at91_set_gpio_value(AT91_PIN_PA21, 0); - else - at91_set_gpio_value(AT91_PIN_PA21, 1); - } - } -#endif + if (atmel_port->set_mctrl) + atmel_port->set_mctrl(mctrl); if (mctrl & TIOCM_RTS) control |= ATMEL_US_RTSEN; @@ -2365,6 +2353,7 @@ static int atmel_serial_probe(struct platform_device *pdev) port = &atmel_ports[ret]; port->backup_imr = 0; port->uart.line = ret; + port->set_mctrl = pdata->set_mctrl; ret = atmel_init_port(port, pdev); if (ret) diff --git a/include/linux/platform_data/atmel.h b/include/linux/platform_data/atmel.h index cea9f70133c5..59991aae0217 100644 --- a/include/linux/platform_data/atmel.h +++ b/include/linux/platform_data/atmel.h @@ -84,6 +84,7 @@ struct atmel_uart_data { short use_dma_rx; /* use receive DMA? */ void __iomem *regs; /* virt. base address, if any */ struct serial_rs485 rs485; /* rs485 settings */ + void (*set_mctrl)(unsigned int mctrl); /* mctrl callback */ }; /* Touchscreen Controller */