devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shawn Guo <shawn.guo@linaro.org>
To: Frank.Li@freescale.com
Cc: lznuaa@gmail.com, dmitry.torokhov@gmail.com, robh+dt@kernel.org,
	alexandre.belloni@free-electrons.com, linux@arm.linux.org.uk,
	linux-arm-kernel@lists.infradead.org,
	linux-input@vger.kernel.org, rtc-linux@googlegroups.com,
	devicetree@vger.kernel.org
Subject: Re: [PATCH v4 1/6] rtc: arm: imx: snvs: change use syscon to access register
Date: Mon, 25 May 2015 14:44:28 +0800	[thread overview]
Message-ID: <20150525064427.GG3264@dragon> (raw)
In-Reply-To: <1432305399-30571-2-git-send-email-Frank.Li@freescale.com>

On Fri, May 22, 2015 at 10:36:34PM +0800, Frank.Li@freescale.com wrote:
>  static int snvs_rtc_probe(struct platform_device *pdev)
>  {
>  	struct snvs_rtc_data *data;
>  	struct resource *res;
>  	int ret;
> +	struct device_node *snvs_np;
> +	void __iomem *mmio;
>  
>  	data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
>  	if (!data)
>  		return -ENOMEM;
>  
> -	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	data->ioaddr = devm_ioremap_resource(&pdev->dev, res);
> -	if (IS_ERR(data->ioaddr))
> -		return PTR_ERR(data->ioaddr);
> +	snvs_np = of_get_parent(pdev->dev.of_node);
> +	if (!snvs_np)
> +		return -ENODEV;
> +
> +	if (of_device_is_compatible(snvs_np, "syscon")) {
> +		data->regmap = syscon_node_to_regmap(snvs_np);
> +		data->offset = 0x34;

As I commented on dts patch, we should probably follow syscon-poweroff
to have 'regmap' and 'offset' properties.

Shawn

> +	} else {
> +		pr_warn("snvs rtc: you use old dts file, please update it\n");
> +		res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +
> +		mmio = devm_ioremap_resource(&pdev->dev, res);
> +		if (IS_ERR(mmio))
> +			return PTR_ERR(mmio);
> +
> +		data->regmap = devm_regmap_init_mmio(&pdev->dev, mmio, &snvs_rtc_config);
> +	}
> +
> +	of_node_put(snvs_np);
> +
> +	if (!data->regmap) {
> +		pr_err("Can't snvs syscon\n");
> +		return -ENODEV;
> +	}
>  
>  	data->irq = platform_get_irq(pdev, 0);
>  	if (data->irq < 0)
> @@ -276,13 +282,11 @@ static int snvs_rtc_probe(struct platform_device *pdev)
>  
>  	platform_set_drvdata(pdev, data);
>  
> -	spin_lock_init(&data->lock);
> -
>  	/* Initialize glitch detect */
> -	writel(SNVS_LPPGDR_INIT, data->ioaddr + SNVS_LPPGDR);
> +	regmap_write(data->regmap, data->offset + SNVS_LPPGDR, SNVS_LPPGDR_INIT);
>  
>  	/* Clear interrupt status */
> -	writel(0xffffffff, data->ioaddr + SNVS_LPSR);
> +	regmap_write(data->regmap, data->offset + SNVS_LPSR, 0xffffffff);
>  
>  	/* Enable RTC */
>  	snvs_rtc_enable(data, true);
> -- 
> 1.9.1
> 

  parent reply	other threads:[~2015-05-25  6:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-22 14:36 [PATCH v4 0/6] Change snvs rtc and poweroff to use syscon add pwrkey driver Frank.Li
2015-05-22 14:36 ` [PATCH v4 1/6] rtc: arm: imx: snvs: change use syscon to access register Frank.Li
2015-05-25  6:18   ` Shawn Guo
2015-05-25  6:44   ` Shawn Guo [this message]
2015-05-22 14:36 ` [PATCH v4 2/6] Document: dt: fsl: snvs: change support syscon Frank.Li
2015-05-25  6:26   ` Shawn Guo
2015-05-22 14:36 ` [PATCH v4 3/6] arm: dts: imx: update snvs to use syscon access register Frank.Li
2015-05-25  6:39   ` Shawn Guo
2015-05-22 14:36 ` [PATCH v4 4/6] input: keyboard: imx: add snvs power key driver Frank.Li
2015-05-25  7:35   ` Shawn Guo
2015-05-22 14:36 ` [PATCH v4 5/6] document: devicetree: input: imx: i.mx snvs power device tree bindings Frank.Li
     [not found] ` <1432305399-30571-1-git-send-email-Frank.Li-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2015-05-22 14:36   ` [PATCH v4 6/6] arm: dts: imx6sx: enable snvs power key Frank.Li-KZfg59tc24xl57MIdRCFDg
2015-05-25  7:39     ` Shawn Guo
2015-05-25  6:47 ` [PATCH v4 0/6] Change snvs rtc and poweroff to use syscon add pwrkey driver Shawn Guo

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=20150525064427.GG3264@dragon \
    --to=shawn.guo@linaro.org \
    --cc=Frank.Li@freescale.com \
    --cc=alexandre.belloni@free-electrons.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=lznuaa@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=rtc-linux@googlegroups.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).