diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-06 19:13:58 -0800 | 
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-06 19:13:58 -0800 | 
| commit | 01539ba2a706ab7d35fc0667dff919ade7f87d63 (patch) | |
| tree | 5a4bd0cf78007d06690fe4ac06bbd49a5a70bc47 /drivers/i2c | |
| parent | 9e9bc9736756f25d6c47b4eba0ebf25b20a6f153 (diff) | |
| parent | dc69d1af9e8d9cbbabff88bb35a6782187a22229 (diff) | |
| download | olio-linux-3.10-01539ba2a706ab7d35fc0667dff919ade7f87d63.tar.xz olio-linux-3.10-01539ba2a706ab7d35fc0667dff919ade7f87d63.zip  | |
Merge branch 'omap-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap-2.6
* 'omap-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap-2.6: (243 commits)
  omap2: Make OMAP2PLUS select OMAP_DM_TIMER
  OMAP4: hwmod data: Fix alignment and end of line in structurefields
  OMAP4: hwmod data: Move the DMA structures
  OMAP4: hwmod data: Move the smartreflex structures
  OMAP4: hwmod data: Fix missing SIDLE_SMART_WKUP in smartreflexsysc
  arm: omap: tusb6010: add name for MUSB IRQ
  arm: omap: craneboard: Add USB EHCI support
  omap2+: Initialize serial port for dynamic remuxing for n8x0
  omap2+: Add struct omap_board_data and use it for platform level serial init
  omap2+: Allow hwmod state changes to mux pads based on the state changes
  omap2+: Add support for hwmod specific muxing of devices
  omap2+: Add omap_mux_get_by_name
  OMAP2: PM: fix compile error when !CONFIG_SUSPEND
  MAINTAINERS: OMAP: hwmod: update hwmod code, data maintainership
  OMAP4: Smartreflex framework extensions
  OMAP4: hwmod: Add inital data for smartreflex modules.
  OMAP4: PM: Program correct init voltages for scalable VDDs
  OMAP4: Adding voltage driver support
  OMAP4: Register voltage PMIC parameters with the voltage layer
  OMAP3: PM: Program correct init voltages for VDD1 and VDD2
  ...
Fix up trivial conflict in arch/arm/plat-omap/Kconfig
Diffstat (limited to 'drivers/i2c')
| -rw-r--r-- | drivers/i2c/busses/i2c-omap.c | 73 | 
1 files changed, 25 insertions, 48 deletions
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index b33c78586bf..9d090833e24 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c @@ -39,6 +39,7 @@  #include <linux/io.h>  #include <linux/slab.h>  #include <linux/i2c-omap.h> +#include <linux/pm_runtime.h>  /* I2C controller revisions */  #define OMAP_I2C_REV_2			0x20 @@ -175,8 +176,6 @@ struct omap_i2c_dev {  	void __iomem		*base;		/* virtual */  	int			irq;  	int			reg_shift;      /* bit shift for I2C register addresses */ -	struct clk		*iclk;		/* Interface clock */ -	struct clk		*fclk;		/* Functional clock */  	struct completion	cmd_complete;  	struct resource		*ioarea;  	u32			latency;	/* maximum mpu wkup latency */ @@ -265,45 +264,18 @@ static inline u16 omap_i2c_read_reg(struct omap_i2c_dev *i2c_dev, int reg)  				(i2c_dev->regs[reg] << i2c_dev->reg_shift));  } -static int __init omap_i2c_get_clocks(struct omap_i2c_dev *dev) +static void omap_i2c_unidle(struct omap_i2c_dev *dev)  { -	int ret; +	struct platform_device *pdev; +	struct omap_i2c_bus_platform_data *pdata; -	dev->iclk = clk_get(dev->dev, "ick"); -	if (IS_ERR(dev->iclk)) { -		ret = PTR_ERR(dev->iclk); -		dev->iclk = NULL; -		return ret; -	} +	WARN_ON(!dev->idle); -	dev->fclk = clk_get(dev->dev, "fck"); -	if (IS_ERR(dev->fclk)) { -		ret = PTR_ERR(dev->fclk); -		if (dev->iclk != NULL) { -			clk_put(dev->iclk); -			dev->iclk = NULL; -		} -		dev->fclk = NULL; -		return ret; -	} +	pdev = to_platform_device(dev->dev); +	pdata = pdev->dev.platform_data; -	return 0; -} +	pm_runtime_get_sync(&pdev->dev); -static void omap_i2c_put_clocks(struct omap_i2c_dev *dev) -{ -	clk_put(dev->fclk); -	dev->fclk = NULL; -	clk_put(dev->iclk); -	dev->iclk = NULL; -} - -static void omap_i2c_unidle(struct omap_i2c_dev *dev) -{ -	WARN_ON(!dev->idle); - -	clk_enable(dev->iclk); -	clk_enable(dev->fclk);  	if (cpu_is_omap34xx()) {  		omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);  		omap_i2c_write_reg(dev, OMAP_I2C_PSC_REG, dev->pscstate); @@ -326,10 +298,15 @@ static void omap_i2c_unidle(struct omap_i2c_dev *dev)  static void omap_i2c_idle(struct omap_i2c_dev *dev)  { +	struct platform_device *pdev; +	struct omap_i2c_bus_platform_data *pdata;  	u16 iv;  	WARN_ON(dev->idle); +	pdev = to_platform_device(dev->dev); +	pdata = pdev->dev.platform_data; +  	dev->iestate = omap_i2c_read_reg(dev, OMAP_I2C_IE_REG);  	if (dev->rev >= OMAP_I2C_REV_ON_4430)  		omap_i2c_write_reg(dev, OMAP_I2C_IRQENABLE_CLR, 1); @@ -345,8 +322,8 @@ static void omap_i2c_idle(struct omap_i2c_dev *dev)  		omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG);  	}  	dev->idle = 1; -	clk_disable(dev->fclk); -	clk_disable(dev->iclk); + +	pm_runtime_put_sync(&pdev->dev);  }  static int omap_i2c_init(struct omap_i2c_dev *dev) @@ -356,6 +333,7 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)  	unsigned long fclk_rate = 12000000;  	unsigned long timeout;  	unsigned long internal_clk = 0; +	struct clk *fclk;  	if (dev->rev >= OMAP_I2C_REV_2) {  		/* Disable I2C controller before soft reset */ @@ -414,7 +392,9 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)  		 * always returns 12MHz for the functional clock, we can  		 * do this bit unconditionally.  		 */ -		fclk_rate = clk_get_rate(dev->fclk); +		fclk = clk_get(dev->dev, "fck"); +		fclk_rate = clk_get_rate(fclk); +		clk_put(fclk);  		/* TRM for 5912 says the I2C clock must be prescaled to be  		 * between 7 - 12 MHz. The XOR input clock is typically @@ -443,7 +423,9 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)  			internal_clk = 9600;  		else  			internal_clk = 4000; -		fclk_rate = clk_get_rate(dev->fclk) / 1000; +		fclk = clk_get(dev->dev, "fck"); +		fclk_rate = clk_get_rate(fclk) / 1000; +		clk_put(fclk);  		/* Compute prescaler divisor */  		psc = fclk_rate / internal_clk; @@ -1048,14 +1030,12 @@ omap_i2c_probe(struct platform_device *pdev)  	else  		dev->reg_shift = 2; -	if ((r = omap_i2c_get_clocks(dev)) != 0) -		goto err_iounmap; -  	if (cpu_is_omap44xx())  		dev->regs = (u8 *) omap4_reg_map;  	else  		dev->regs = (u8 *) reg_map; +	pm_runtime_enable(&pdev->dev);  	omap_i2c_unidle(dev);  	dev->rev = omap_i2c_read_reg(dev, OMAP_I2C_REV_REG) & 0xff; @@ -1127,8 +1107,6 @@ err_free_irq:  err_unuse_clocks:  	omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);  	omap_i2c_idle(dev); -	omap_i2c_put_clocks(dev); -err_iounmap:  	iounmap(dev->base);  err_free_mem:  	platform_set_drvdata(pdev, NULL); @@ -1150,7 +1128,6 @@ omap_i2c_remove(struct platform_device *pdev)  	free_irq(dev->irq, dev);  	i2c_del_adapter(&dev->adapter);  	omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0); -	omap_i2c_put_clocks(dev);  	iounmap(dev->base);  	kfree(dev);  	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -1162,7 +1139,7 @@ static struct platform_driver omap_i2c_driver = {  	.probe		= omap_i2c_probe,  	.remove		= omap_i2c_remove,  	.driver		= { -		.name	= "i2c_omap", +		.name	= "omap_i2c",  		.owner	= THIS_MODULE,  	},  }; @@ -1184,4 +1161,4 @@ module_exit(omap_i2c_exit_driver);  MODULE_AUTHOR("MontaVista Software, Inc. (and others)");  MODULE_DESCRIPTION("TI OMAP I2C bus adapter");  MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:i2c_omap"); +MODULE_ALIAS("platform:omap_i2c");  |