Re: [PATCH v3 5/5] OMAP: I2C: Convert i2c driver to use PM runtime api's
Ben Dooks ben-...@fluff.org writes: On Thu, Oct 07, 2010 at 10:37:03AM -0700, Kevin Hilman wrote: Ben Dooks ben-...@fluff.org writes: [...] As such, I should really go and read up all about this new runtime-pm and hwmod stuff before further commentign on the changes. ping From the drivers perspective, you don't neet to know anything about omap_hwmod. You can think of this change as simply using the runtime PM API instead of the clock API for enabling and idling the device. With your ack (on this patch only) we'd like to merge this along with the rest of the series for 2.6.37. Acked-by: Ben Dooks ben-li...@fluff.org please post via your tree. Thanks Ben, Will queue up for 2.6.38. Kevin -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 5/5] OMAP: I2C: Convert i2c driver to use PM runtime api's
On Thu, Oct 07, 2010 at 10:37:03AM -0700, Kevin Hilman wrote: Ben Dooks ben-...@fluff.org writes: [...] As such, I should really go and read up all about this new runtime-pm and hwmod stuff before further commentign on the changes. ping From the drivers perspective, you don't neet to know anything about omap_hwmod. You can think of this change as simply using the runtime PM API instead of the clock API for enabling and idling the device. With your ack (on this patch only) we'd like to merge this along with the rest of the series for 2.6.37. Acked-by: Ben Dooks ben-li...@fluff.org please post via your tree. -- Ben Q: What's a light-year? A: One-third less calories than a regular year. -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 5/5] OMAP: I2C: Convert i2c driver to use PM runtime api's
Ben Dooks ben-...@fluff.org writes: [...] As such, I should really go and read up all about this new runtime-pm and hwmod stuff before further commentign on the changes. ping From the drivers perspective, you don't neet to know anything about omap_hwmod. You can think of this change as simply using the runtime PM API instead of the clock API for enabling and idling the device. With your ack (on this patch only) we'd like to merge this along with the rest of the series for 2.6.37. Kevin -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH v3 5/5] OMAP: I2C: Convert i2c driver to use PM runtime api's
snip... 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 = 1200; 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,8 @@ 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); /* TRM for 5912 says the I2C clock must be prescaled to be * between 7 - 12 MHz. The XOR input clock is typically @@ -443,7 +422,8 @@ 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; You don't put the clk after getting it and using it once? clk_get needs an equivalent clk_put and not clk_get_rate. clk_get_rate is used to merely know the existing rate of the clock. Sorry, I guess you did mean the clk_get above the clk_get_rate does not have an equivalent clk_put. I could put a clk_put for readability, but a clk_put on OMAP actually does map to an empty function. See arch/arm/plat-omap/include/plat/clkdev.h clk_get merely returns a pointer to the clk struct and does not do any usecounting, hence a clk_put does not do anything. /* Compute prescaler divisor */ psc = fclk_rate / internal_clk; @@ -1046,14 +1026,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; @@ -1125,8 +1103,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); @@ -1148,7 +1124,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); -- 1.5.4.7 -- To unsubscribe from this list: send the line unsubscribe linux-i2c in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html -- -- Ben Q: What's a light-year? A: One-third less calories than a regular year. -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 5/5] OMAP: I2C: Convert i2c driver to use PM runtime api's
On Tue, Sep 28, 2010 at 12:29:01PM +0530, Nayak, Rajendra wrote: snip... 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 = 1200; 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,8 @@ 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); /* TRM for 5912 says the I2C clock must be prescaled to be * between 7 - 12 MHz. The XOR input clock is typically @@ -443,7 +422,8 @@ 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; You don't put the clk after getting it and using it once? clk_get needs an equivalent clk_put and not clk_get_rate. clk_get_rate is used to merely know the existing rate of the clock. Sorry, I guess you did mean the clk_get above the clk_get_rate does not have an equivalent clk_put. I could put a clk_put for readability, but a clk_put on OMAP actually does map to an empty function. See arch/arm/plat-omap/include/plat/clkdev.h clk_get merely returns a pointer to the clk struct and does not do any usecounting, hence a clk_put does not do anything. That's no reason to avoid using it. -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH v3 5/5] OMAP: I2C: Convert i2c driver to use PM runtime api's
-Original Message- From: Russell King - ARM Linux [mailto:li...@arm.linux.org.uk] Sent: Tuesday, September 28, 2010 1:19 PM To: Nayak, Rajendra Cc: Ben Dooks; Paul Walmsley; Kevin Hilman; linux-...@vger.kernel.org; ben-li...@fluff.org; kh...@linux-fr.org; linux- o...@vger.kernel.org; linux-arm-ker...@lists.infradead.org Subject: Re: [PATCH v3 5/5] OMAP: I2C: Convert i2c driver to use PM runtime api's On Tue, Sep 28, 2010 at 12:29:01PM +0530, Nayak, Rajendra wrote: snip... 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 = 1200; 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,8 @@ 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); /* TRM for 5912 says the I2C clock must be prescaled to be * between 7 - 12 MHz. The XOR input clock is typically @@ -443,7 +422,8 @@ 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; You don't put the clk after getting it and using it once? clk_get needs an equivalent clk_put and not clk_get_rate. clk_get_rate is used to merely know the existing rate of the clock. Sorry, I guess you did mean the clk_get above the clk_get_rate does not have an equivalent clk_put. I could put a clk_put for readability, but a clk_put on OMAP actually does map to an empty function. See arch/arm/plat-omap/include/plat/clkdev.h clk_get merely returns a pointer to the clk struct and does not do any usecounting, hence a clk_put does not do anything. That's no reason to avoid using it. Ok, I'll post an updated patch with the matching clk_put's in place. -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 5/5] OMAP: I2C: Convert i2c driver to use PM runtime api's
On Tue, Sep 28, 2010 at 12:29:01PM +0530, Nayak, Rajendra wrote: snip... 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 = 1200; 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,8 @@ 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); /* TRM for 5912 says the I2C clock must be prescaled to be * between 7 - 12 MHz. The XOR input clock is typically @@ -443,7 +422,8 @@ 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; You don't put the clk after getting it and using it once? clk_get needs an equivalent clk_put and not clk_get_rate. clk_get_rate is used to merely know the existing rate of the clock. Sorry, I guess you did mean the clk_get above the clk_get_rate does not have an equivalent clk_put. I could put a clk_put for readability, but a clk_put on OMAP actually does map to an empty function. See arch/arm/plat-omap/include/plat/clkdev.h clk_get merely returns a pointer to the clk struct and does not do any usecounting, hence a clk_put does not do anything. clk_get() should have a reference counter, and on many systems does. This is why we ask people to put clk_put() when they don't need the clock any more. It may not do anything on your system, but it will set a good example to anyone copying your driver code. As such, I should really go and read up all about this new runtime-pm and hwmod stuff before further commentign on the changes. /* Compute prescaler divisor */ psc = fclk_rate / internal_clk; @@ -1046,14 +1026,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; @@ -1125,8 +1103,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); @@ -1148,7 +1124,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); -- 1.5.4.7 -- To unsubscribe from this list: send the line unsubscribe linux-i2c in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html -- -- Ben Q: What's a light-year? A: One-third less calories than a regular year. -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ___ linux-arm-kernel mailing list linux-arm-ker...@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel -- -- Ben Q: What's a light-year? A: One-third less calories than a regular year. -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH v3 5/5] OMAP: I2C: Convert i2c driver to use PM runtime api's
-Original Message- From: Ben Dooks [mailto:ben-...@fluff.org] Sent: Wednesday, September 29, 2010 5:04 AM To: Nayak, Rajendra Cc: Ben Dooks; Paul Walmsley; Kevin Hilman; linux-...@vger.kernel.org; ben-li...@fluff.org; kh...@linux-fr.org; linux- o...@vger.kernel.org; linux-arm-ker...@lists.infradead.org Subject: Re: [PATCH v3 5/5] OMAP: I2C: Convert i2c driver to use PM runtime api's On Tue, Sep 28, 2010 at 12:29:01PM +0530, Nayak, Rajendra wrote: snip... 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 = 1200; 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,8 @@ 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); /* TRM for 5912 says the I2C clock must be prescaled to be * between 7 - 12 MHz. The XOR input clock is typically @@ -443,7 +422,8 @@ 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; You don't put the clk after getting it and using it once? clk_get needs an equivalent clk_put and not clk_get_rate. clk_get_rate is used to merely know the existing rate of the clock. Sorry, I guess you did mean the clk_get above the clk_get_rate does not have an equivalent clk_put. I could put a clk_put for readability, but a clk_put on OMAP actually does map to an empty function. See arch/arm/plat-omap/include/plat/clkdev.h clk_get merely returns a pointer to the clk struct and does not do any usecounting, hence a clk_put does not do anything. clk_get() should have a reference counter, and on many systems does. This is why we ask people to put clk_put() when they don't need the clock any more. It may not do anything on your system, but it will set a good example to anyone copying your driver code. I agree. There is an updated patch now posted with the clk_put's in place. As such, I should really go and read up all about this new runtime-pm and hwmod stuff before further commentign on the changes. Ok. Thanks. /* Compute prescaler divisor */ psc = fclk_rate / internal_clk; @@ -1046,14 +1026,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; @@ -1125,8 +1103,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); @@ -1148,7 +1124,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); -- 1.5.4.7 -- To unsubscribe from this list: send the line unsubscribe linux-i2c in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html -- -- Ben Q: What's a light-year? A: One-third less calories than a regular year. -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ___ linux-arm-kernel mailing list linux-arm-ker...@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel -- -- Ben Q: What's a light-year
Re: [PATCH v3 5/5] OMAP: I2C: Convert i2c driver to use PM runtime api's
On Tue, Sep 21, 2010 at 07:37:16PM +0530, Rajendra Nayak wrote: This patch converts the i2c driver to use PM runtime apis Signed-off-by: Rajendra Nayak rna...@ti.com Cc: Kevin Hilman khil...@deeprootsystems.com Cc: Paul Walmsley p...@pwsan.com --- drivers/i2c/busses/i2c-omap.c | 67 + 1 files changed, 21 insertions(+), 46 deletions(-) diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index 7674efb..126bde9 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 = 1200; 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,8 @@ 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); /* TRM for 5912 says the I2C clock must be prescaled to be * between 7 - 12 MHz. The XOR input clock is typically @@ -443,7 +422,8 @@ 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; You don't put the clk after getting it and using it once? /* Compute prescaler divisor */
RE: [PATCH v3 5/5] OMAP: I2C: Convert i2c driver to use PM runtime api's
-Original Message- From: Ben Dooks [mailto:ben-...@fluff.org] Sent: Tuesday, September 28, 2010 4:07 AM To: Nayak, Rajendra Cc: linux-omap@vger.kernel.org; linux-arm-ker...@lists.infradead.org; linux-...@vger.kernel.org; ben-li...@fluff.org; kh...@linux-fr.org; Kevin Hilman; Paul Walmsley Subject: Re: [PATCH v3 5/5] OMAP: I2C: Convert i2c driver to use PM runtime api's On Tue, Sep 21, 2010 at 07:37:16PM +0530, Rajendra Nayak wrote: This patch converts the i2c driver to use PM runtime apis Signed-off-by: Rajendra Nayak rna...@ti.com Cc: Kevin Hilman khil...@deeprootsystems.com Cc: Paul Walmsley p...@pwsan.com --- drivers/i2c/busses/i2c-omap.c | 67 + 1 files changed, 21 insertions(+), 46 deletions(-) diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index 7674efb..126bde9 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 = 1200; 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,8 @@ 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); /* TRM for 5912 says the I2C clock must be prescaled to be * between 7 - 12 MHz. The XOR input clock is typically @@ -443,7 +422,8 @@ static int omap_i2c_init(struct omap_i2c_dev *dev
[PATCH v3 5/5] OMAP: I2C: Convert i2c driver to use PM runtime api's
This patch converts the i2c driver to use PM runtime apis Signed-off-by: Rajendra Nayak rna...@ti.com Cc: Kevin Hilman khil...@deeprootsystems.com Cc: Paul Walmsley p...@pwsan.com --- drivers/i2c/busses/i2c-omap.c | 67 + 1 files changed, 21 insertions(+), 46 deletions(-) diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index 7674efb..126bde9 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 = 1200; 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,8 @@ 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); /* TRM for 5912 says the I2C clock must be prescaled to be * between 7 - 12 MHz. The XOR input clock is typically @@ -443,7 +422,8 @@ 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; /* Compute prescaler divisor */ psc = fclk_rate / internal_clk; @@ -1046,14 +1026,12 @@ omap_i2c_probe(struct platform_device