linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rob Herring <robherring2@gmail.com>
To: Rajendra Nayak <rnayak@ti.com>
Cc: linux-serial@vger.kernel.org, linux-omap@vger.kernel.org,
	devicetree-discuss@lists.ozlabs.org, tony@atomide.com,
	khilman@ti.com, govindraj.raja@ti.com, b-cousson@ti.com,
	linux-arm-kernel@lists.infradead.org,
	linaro-dev@lists.linaro.org, patches@linaro.org
Subject: Re: [PATCH v2 3/4] omap-serial: Add minimal device tree support
Date: Mon, 28 Nov 2011 07:39:40 -0600	[thread overview]
Message-ID: <4ED38F1C.5080604@gmail.com> (raw)
In-Reply-To: <1321969456-24266-4-git-send-email-rnayak@ti.com>

On 11/22/2011 07:44 AM, Rajendra Nayak wrote:
> Adapt the driver to device tree and pass minimal platform
> data from device tree needed for console boot.
> No power management features will be suppported for now
> since it requires more tweaks around OCP settings
> to toggle forceidle/noidle/smaridle bits and handling

typo: smartidle

> remote wakeup and dynamic muxing.
> 
> Signed-off-by: Rajendra Nayak <rnayak@ti.com>

Acked-by: Rob Herring <rob.herring@calxeda.com>

Rob

> ---
>  .../devicetree/bindings/serial/omap_serial.txt     |   10 ++++
>  drivers/tty/serial/omap-serial.c                   |   45 ++++++++++++++++++-
>  2 files changed, 52 insertions(+), 3 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/serial/omap_serial.txt
> 
> diff --git a/Documentation/devicetree/bindings/serial/omap_serial.txt b/Documentation/devicetree/bindings/serial/omap_serial.txt
> new file mode 100644
> index 0000000..342eedd
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/serial/omap_serial.txt
> @@ -0,0 +1,10 @@
> +OMAP UART controller
> +
> +Required properties:
> +- compatible : should be "ti,omap2-uart" for OMAP2 controllers
> +- compatible : should be "ti,omap3-uart" for OMAP3 controllers
> +- compatible : should be "ti,omap4-uart" for OMAP4 controllers
> +- ti,hwmods : Must be "uart<n>", n being the instance number (1-based)
> +
> +Optional properties:
> +- clock-frequency : frequency of the clock input to the UART
> diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
> index f14b9c5..5aa524e 100644
> --- a/drivers/tty/serial/omap-serial.c
> +++ b/drivers/tty/serial/omap-serial.c
> @@ -38,6 +38,7 @@
>  #include <linux/serial_core.h>
>  #include <linux/irq.h>
>  #include <linux/pm_runtime.h>
> +#include <linux/of.h>
>  
>  #include <plat/dma.h>
>  #include <plat/dmtimer.h>
> @@ -1324,6 +1325,19 @@ static void uart_tx_dma_callback(int lch, u16 ch_status, void *data)
>  	return;
>  }
>  
> +static struct omap_uart_port_info *of_get_uart_port_info(struct device *dev)
> +{
> +	struct omap_uart_port_info *omap_up_info;
> +
> +	omap_up_info = devm_kzalloc(dev, sizeof(*omap_up_info), GFP_KERNEL);
> +	if (!omap_up_info)
> +		return NULL; /* out of memory */
> +
> +	of_property_read_u32(dev->of_node, "clock-frequency",
> +					 &omap_up_info->uartclk);
> +	return omap_up_info;
> +}
> +
>  static int serial_omap_probe(struct platform_device *pdev)
>  {
>  	struct uart_omap_port	*up;
> @@ -1331,6 +1345,9 @@ static int serial_omap_probe(struct platform_device *pdev)
>  	struct omap_uart_port_info *omap_up_info = pdev->dev.platform_data;
>  	int ret = -ENOSPC;
>  
> +	if (pdev->dev.of_node)
> +		omap_up_info = of_get_uart_port_info(&pdev->dev);
> +
>  	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	if (!mem) {
>  		dev_err(&pdev->dev, "no mem resource?\n");
> @@ -1375,9 +1392,20 @@ static int serial_omap_probe(struct platform_device *pdev)
>  	up->port.regshift = 2;
>  	up->port.fifosize = 64;
>  	up->port.ops = &serial_omap_pops;
> -	up->port.line = pdev->id;
> -	sprintf(up->name, "OMAP UART%d", up->port.line);
>  
> +	if (pdev->dev.of_node)
> +		up->port.line = of_alias_get_id(pdev->dev.of_node, "serial");
> +	else
> +		up->port.line = pdev->id;
> +
> +	if (up->port.line < 0) {
> +		dev_err(&pdev->dev, "failed to get alias/pdev id, errno %d\n",
> +								up->port.line);
> +		ret = -ENODEV;
> +		goto err;
> +	}
> +
> +	sprintf(up->name, "OMAP UART%d", up->port.line);
>  	up->port.mapbase = mem->start;
>  	up->port.membase = ioremap(mem->start, resource_size(mem));
>  	if (!up->port.membase) {
> @@ -1530,7 +1558,7 @@ static int serial_omap_runtime_suspend(struct device *dev)
>  	if (!up)
>  		return -EINVAL;
>  
> -	if (!pdata->enable_wakeup)
> +	if (!pdata || !pdata->enable_wakeup)
>  		return 0;
>  
>  	if (pdata->get_context_loss_count)
> @@ -1591,12 +1619,23 @@ static const struct dev_pm_ops serial_omap_dev_pm_ops = {
>  				serial_omap_runtime_resume, NULL)
>  };
>  
> +#if defined(CONFIG_OF)
> +static const struct of_device_id omap_serial_of_match[] = {
> +	{ .compatible = "ti,omap2-uart" },
> +	{ .compatible = "ti,omap3-uart" },
> +	{ .compatible = "ti,omap4-uart" },
> +	{},
> +};
> +MODULE_DEVICE_TABLE(of, omap_serial_of_match);
> +#endif
> +
>  static struct platform_driver serial_omap_driver = {
>  	.probe          = serial_omap_probe,
>  	.remove         = serial_omap_remove,
>  	.driver		= {
>  		.name	= DRIVER_NAME,
>  		.pm	= &serial_omap_dev_pm_ops,
> +		.of_match_table = of_match_ptr(omap_serial_of_match),
>  	},
>  };
>  


  reply	other threads:[~2011-11-28 13:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-22 13:44 [PATCH v2 0/4] OMAP serial device tree support Rajendra Nayak
2011-11-22 13:44 ` [PATCH v2 2/4] omap-serial: Use default clock speed (48Mhz) if not specified Rajendra Nayak
     [not found] ` <1321969456-24266-1-git-send-email-rnayak-l0cyMroinI0@public.gmane.org>
2011-11-22 13:44   ` [PATCH v2 1/4] omap-serial: Get rid of all pdev->id usage Rajendra Nayak
2011-11-22 13:44   ` [PATCH v2 3/4] omap-serial: Add minimal device tree support Rajendra Nayak
2011-11-28 13:39     ` Rob Herring [this message]
2011-11-29  7:04       ` Rajendra Nayak
2011-11-22 13:44   ` [PATCH v2 4/4] ARM: omap: pass minimal SoC/board data for UART from dt Rajendra Nayak
2011-11-28 13:40     ` Rob Herring
2011-11-27  3:36 ` [PATCH v2 0/4] OMAP serial device tree support Greg KH
2011-11-28  6:06   ` Rajendra Nayak
2011-11-28  6:31     ` Greg KH
2011-11-28 13:44       ` Rob Herring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4ED38F1C.5080604@gmail.com \
    --to=robherring2@gmail.com \
    --cc=b-cousson@ti.com \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=govindraj.raja@ti.com \
    --cc=khilman@ti.com \
    --cc=linaro-dev@lists.linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=patches@linaro.org \
    --cc=rnayak@ti.com \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).