All of lore.kernel.org
 help / color / mirror / Atom feed
From: Todd Poynor <toddpoynor@google.com>
To: jean.pihet@newoldbits.com
Cc: Linux OMAP Mailing List <linux-omap@vger.kernel.org>,
	paul@pwsan.com, khilman@ti.com, balbi@ti.com, rjw@sisk.pl,
	Jean Pihet <j-pihet@ti.com>,
	nm@ti.com
Subject: Re: [PATCH 25/26] OMAP: PM: convert the SmartReflex code into the AVS driver framework
Date: Wed, 23 Nov 2011 15:34:37 -0800	[thread overview]
Message-ID: <20111123233437.GA17638@google.com> (raw)
In-Reply-To: <1321974370-25800-26-git-send-email-j-pihet@ti.com>

...
> +int sr_configure_errgen(struct smartreflex *sr)
> +{
> +	struct smartreflex_platform_data *pdata = sr->pdev->dev.platform_data;
> +	u32 sr_config, sr_errconfig;
> +
> +	if (IS_ERR_OR_NULL(sr))
> +		return -EINVAL;
> +
> +	if (!sr_calculate_clk_length(sr))
> +		return -EINVAL;
> +
> +	sr_config = sr->proto_sr_config;
> +	sr_config |=  SRCONFIG_ERRGEN_EN;
> +	sr_write_reg(sr, SRCONFIG, sr_config);
> +
> +	sr_errconfig = (pdata->err_weight << ERRCONFIG_ERRWEIGHT_SHIFT) |
> +		(pdata->err_maxlimit << ERRCONFIG_ERRMAXLIMIT_SHIFT) |
> +		(sr->err_minlimit <<  ERRCONFIG_ERRMINLIMIT_SHIFT);
> +	sr_modify_reg(sr, sr->errconfig_offs, (SR_ERRWEIGHT_MASK |
> +		SR_ERRMAXLIMIT_MASK | SR_ERRMINLIMIT_MASK),
> +		sr_errconfig);
> +
> +	/* Enabling the interrupts if the ERROR module is used */
> +	sr_modify_reg(sr, sr->errconfig_offs,
> +		sr->vpboundint_en, (sr->vpboundint_en | sr->vpboundint_st));

Nishanth Menon has a patch for the reversed order of parameters for
mask and bits to set in the above.

> +
> +	return 0;
> +}

...
> +int __init sr_common_probe(struct platform_device *pdev,
> +			   struct smartreflex *sr)
> +{
> +	struct smartreflex_platform_data *pdata = pdev->dev.platform_data;
> +	struct resource *mem, *irq;
> +	int ret = 0;
> +
> +	sr->name = kasprintf(GFP_KERNEL, "sr_%s", pdata->name);
> +	if (!sr->name) {
> +		dev_err(&pdev->dev, "%s: Unable to alloc debugfs name\n",
> +			__func__);
> +		return -ENOMEM;
> +	}
> +
> +	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	if (!mem) {
> +		dev_err(&pdev->dev, "%s: no mem resource\n", __func__);
> +		return -ENODEV;

Need free(sr->name) ?

> +	}
> +
> +	mem = request_mem_region(mem->start, resource_size(mem),
> +					dev_name(&pdev->dev));
> +	if (!mem) {
> +		dev_err(&pdev->dev, "%s: no mem region\n", __func__);
> +		return -EBUSY;
> +	}
> +
> +	sr->base = ioremap(mem->start, resource_size(mem));
> +	if (!sr->base) {
> +		dev_err(&pdev->dev, "%s: ioremap fail\n", __func__);
> +		ret = -ENOMEM;
> +		goto err_release_region;
> +	}
> +
> +	irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
> +	if (!irq) {
> +		dev_err(&pdev->dev, "%s: no IRQ resource defined\n", __func__);
> +		ret = -ENODEV;
> +		goto err_iounmap;
> +	}
> +	sr->irq = irq->start;
> +
> +	ret = request_irq(sr->irq, sr->isr, 0, sr->name, (void *)sr);
> +	if (ret) {
> +		dev_err(&pdev->dev, "%s: could not register interrupt "
> +				    "handler\n", __func__);
> +		goto err_iounmap;
> +	}
> +
> +	pdata->sr = sr;
> +
> +	sr->pdev = pdev;
> +	sr->voltdm = pdata->voltdm;
> +
> +	sr->autocomp_active = false;
> +
> +	pm_runtime_enable(&pdev->dev);
> +	pm_runtime_irq_safe(&pdev->dev);
> +
> +#ifdef CONFIG_POWER_AVS_DEBUG
> +	ret = sr_debugfs_setup(pdev, sr);
> +	if (ret)
> +		goto err_free_irq;
> +#endif
> +
> +	dev_info(&pdev->dev, "%s: SmartReflex driver initialized\n", __func__);
> +
> +	return ret;
> +
> +err_free_irq:
> +	free_irq(sr->irq, (void *)sr);
> +err_iounmap:
> +	iounmap(sr->base);
> +err_release_region:
> +	release_mem_region(mem->start, resource_size(mem));
> +
> +	return ret;
> +}
> +
> +int __devexit sr_remove(struct platform_device *pdev)
> +{
> +	struct smartreflex_platform_data *pdata = pdev->dev.platform_data;
> +	struct smartreflex *sr;
> +	struct resource *mem;
> +
> +	if (!pdata) {
> +		dev_err(&pdev->dev, "%s: platform data missing\n", __func__);
> +		return -EINVAL;
> +	}
> +
> +	sr = pdata->sr;
> +	if (IS_ERR(sr)) {

Sometimes set to NULL, use IS_ERR_OR_NULL ?

> +		dev_warn(&pdev->dev, "%s: smartreflex struct not found\n",
> +			__func__);
> +		return -EINVAL;
> +	}
> +
> +	if (sr->autocomp_active)
> +		sr_stop_vddautocomp(sr);
> +#ifdef CONFIG_POWER_AVS_DEBUG
> +	if (sr->dbg_dir)
> +		debugfs_remove_recursive(sr->dbg_dir);
> +#endif
> +	free_irq(sr->irq, (void *)sr);
> +	iounmap(sr->base);

Need free(sr->name) ?

> +	kfree(sr);
> +	pdata->sr = NULL;
> +	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	release_mem_region(mem->start, resource_size(mem));
> +
> +	return 0;
> +}

...
> +static irqreturn_t _interrupt(int irq, void *data)
> +{
> +	struct smartreflex *sr = (struct smartreflex *)data;
> +	u32 status = 0;
> +
> +	/* Read the status bits */
> +	sr_read_reg(sr, IRQSTATUS);
> +
> +	/* Clear them by writing back */
> +	sr_write_reg(sr, IRQSTATUS, status);

Felipe Balbi sent a patch to the list fixing the write of zero,
failing to clear the interrupts, to the list recently.


Todd

  parent reply	other threads:[~2011-11-23 23:34 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-22 15:05 [RFC/PATCH 00/26] PM: Create the AVS class of drivers jean.pihet
2011-11-22 15:05 ` [PATCH 01/26] OMAP2+: smartreflex: use sane default values jean.pihet
2011-11-22 15:05 ` [PATCH 02/26] OMAP3/4: SmartReflex: class drivers should use struct omap_sr * jean.pihet
2011-11-22 15:05 ` [PATCH 03/26] OMAP3/4: SmartReflex: API should use struct omap_sr *, not struct voltagedomain * jean.pihet
2011-11-22 15:05 ` [PATCH 04/26] OMAP: SmartReflex: drop _sr_lookup() jean.pihet
2011-11-22 15:05 ` [PATCH 05/26] OMAP: hwmod/SmartReflex: remove IP block instance-specific data from the driver code jean.pihet
2011-11-22 15:05 ` [PATCH 06/26] OMAP3+: Pass SmartReflex instance-specific data via hwmod dev_attr jean.pihet
2011-11-22 15:05 ` [PATCH 07/26] OMAP3+: hwmod: get rid of vdd_name field jean.pihet
2011-11-22 15:05 ` [PATCH 08/26] OMAP: SmartReflex: make pdata distinct from other data jean.pihet
2011-11-22 15:05 ` [PATCH 09/26] OMAP: SmartReflex: Use 'sr' for struct smartreflex jean.pihet
2011-11-22 15:05 ` [PATCH 10/26] OMAP2+: rename struct omap_sr_class_data to smartreflex_class_data jean.pihet
2011-11-22 15:05 ` [PATCH 11/26] OMAP3+: SmartReflex: remove unused PMIC code jean.pihet
2011-11-22 15:05 ` [PATCH 12/26] OMAP: SmartReflex: remove some SoC-specific implementation details from driver jean.pihet
2011-11-22 15:05 ` [PATCH 13/26] OMAP: SmartReflex driver interface: allow core to override eFuse data jean.pihet
2011-11-22 15:05 ` [PATCH 14/26] OMAP2+: Use the names from the SmartReflex data instead of voltage domains jean.pihet
2011-11-22 15:05 ` [PATCH 15/26] OMAP2+: SmartReflex: rename nvalue table jean.pihet
2011-11-22 15:06 ` [PATCH 16/26] OMAP2+: SmartReflex: cosmetic changes jean.pihet
2011-11-22 15:06 ` [PATCH 17/26] OMAP3+: Add SmartReflex clocks jean.pihet
2011-11-22 15:06 ` [PATCH 18/26] OMAP2+: Use the TRM formula to calculate the SmartReflex clock rate jean.pihet
2011-11-22 15:06 ` [PATCH 19/26] OMAP2+: SmartReflex: Remove the notifier handler jean.pihet
2011-11-22 15:06 ` [PATCH 20/26] OMAP2+: SmartReflex: make driver generic jean.pihet
2011-11-22 15:06 ` [PATCH 21/26] OMAP2+: SmartReflex: get rid of superfluous data that is duplicated between platform_data and the struct omap_sr jean.pihet
2011-11-22 15:06 ` [PATCH 22/26] OMAP2+: SmartReflex: remove OMAP specific code jean.pihet
2011-11-22 15:06 ` [PATCH 23/26] OMAP2+: SmartReflex: conversion into generic driver jean.pihet
2011-11-22 15:06 ` [PATCH 24/26] OMAP3+: voltage: export functions to plat/voltage.h jean.pihet
2011-11-22 15:06 ` [PATCH 25/26] OMAP: PM: convert the SmartReflex code into the AVS driver framework jean.pihet
2011-11-23  9:51   ` Felipe Balbi
2011-11-23 10:22     ` Jean Pihet
2011-11-23 11:04       ` Felipe Balbi
2011-11-23 11:30         ` Jean Pihet
2011-11-23 11:38           ` Felipe Balbi
2012-01-12  0:52           ` Kevin Hilman
2012-01-12 11:13             ` Jean Pihet
2011-11-23 23:34   ` Todd Poynor [this message]
2012-01-12  0:55     ` Kevin Hilman
2012-01-12 11:12       ` Jean Pihet
2011-11-22 15:06 ` [PATCH 26/26] PM: Create the AVS class of drivers jean.pihet
2011-11-22 16:43 ` [RFC/PATCH 00/26] " Mark Brown
2011-11-22 17:40   ` Cousson, Benoit
2011-11-22 17:47     ` Mark Brown
2011-11-22 20:01       ` Jean Pihet
     [not found] ` <87mx9tu3x5.fsf@ti.com>
2012-01-12  1:06   ` Kevin Hilman
2012-01-12 11:17   ` Jean Pihet

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=20111123233437.GA17638@google.com \
    --to=toddpoynor@google.com \
    --cc=balbi@ti.com \
    --cc=j-pihet@ti.com \
    --cc=jean.pihet@newoldbits.com \
    --cc=khilman@ti.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=nm@ti.com \
    --cc=paul@pwsan.com \
    --cc=rjw@sisk.pl \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.