aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Nilsson <mattias.i.nilsson@stericsson.com>2012-03-08 08:02:05 -0500
committerSamuel Ortiz <sameo@linux.intel.com>2012-03-16 14:45:08 -0400
commit3c3e489831b601e566f6bc47e711f5847fb93dff (patch)
treeed40708984de7a3d5a88f973dbacb646b1122316
parenta982362c1723464fec0414f6460684844f2638f3 (diff)
mfd: Add a prcmu_abb_write_masked routine to db8500-prcmu
This patch adds driver support for the I2C read-modify-write service in the U8500 PRCMU firmware. Signed-off-by: Mattias Nilsson <mattias.i.nilsson@stericsson.com> Reviewed-by: Jonas ABERG <jonas.aberg@stericsson.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
-rw-r--r--drivers/mfd/db8500-prcmu.c28
-rw-r--r--include/linux/mfd/dbx500-prcmu.h7
2 files changed, 32 insertions, 3 deletions
diff --git a/drivers/mfd/db8500-prcmu.c b/drivers/mfd/db8500-prcmu.c
index a1b3464cdba..6e5a0a09c41 100644
--- a/drivers/mfd/db8500-prcmu.c
+++ b/drivers/mfd/db8500-prcmu.c
@@ -2332,6 +2332,7 @@ int prcmu_abb_read(u8 slave, u8 reg, u8 *value, u8 size)
2332 while (readl(PRCM_MBOX_CPU_VAL) & MBOX_BIT(5)) 2332 while (readl(PRCM_MBOX_CPU_VAL) & MBOX_BIT(5))
2333 cpu_relax(); 2333 cpu_relax();
2334 2334
2335 writeb(0, (tcdm_base + PRCM_MBOX_HEADER_REQ_MB5));
2335 writeb(PRCMU_I2C_READ(slave), (tcdm_base + PRCM_REQ_MB5_I2C_SLAVE_OP)); 2336 writeb(PRCMU_I2C_READ(slave), (tcdm_base + PRCM_REQ_MB5_I2C_SLAVE_OP));
2336 writeb(PRCMU_I2C_STOP_EN, (tcdm_base + PRCM_REQ_MB5_I2C_HW_BITS)); 2337 writeb(PRCMU_I2C_STOP_EN, (tcdm_base + PRCM_REQ_MB5_I2C_HW_BITS));
2337 writeb(reg, (tcdm_base + PRCM_REQ_MB5_I2C_REG)); 2338 writeb(reg, (tcdm_base + PRCM_REQ_MB5_I2C_REG));
@@ -2357,16 +2358,19 @@ int prcmu_abb_read(u8 slave, u8 reg, u8 *value, u8 size)
2357} 2358}
2358 2359
2359/** 2360/**
2360 * prcmu_abb_write() - Write register value(s) to the ABB. 2361 * prcmu_abb_write_masked() - Write masked register value(s) to the ABB.
2361 * @slave: The I2C slave address. 2362 * @slave: The I2C slave address.
2362 * @reg: The (start) register address. 2363 * @reg: The (start) register address.
2363 * @value: The value(s) to write. 2364 * @value: The value(s) to write.
2365 * @mask: The mask(s) to use.
2364 * @size: The number of registers to write. 2366 * @size: The number of registers to write.
2365 * 2367 *
2366 * Reads register value(s) from the ABB. 2368 * Writes masked register value(s) to the ABB.
2369 * For each @value, only the bits set to 1 in the corresponding @mask
2370 * will be written. The other bits are not changed.
2367 * @size has to be 1 for the current firmware version. 2371 * @size has to be 1 for the current firmware version.
2368 */ 2372 */
2369int prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size) 2373int prcmu_abb_write_masked(u8 slave, u8 reg, u8 *value, u8 *mask, u8 size)
2370{ 2374{
2371 int r; 2375 int r;
2372 2376
@@ -2378,6 +2382,7 @@ int prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size)
2378 while (readl(PRCM_MBOX_CPU_VAL) & MBOX_BIT(5)) 2382 while (readl(PRCM_MBOX_CPU_VAL) & MBOX_BIT(5))
2379 cpu_relax(); 2383 cpu_relax();
2380 2384
2385 writeb(~*mask, (tcdm_base + PRCM_MBOX_HEADER_REQ_MB5));
2381 writeb(PRCMU_I2C_WRITE(slave), (tcdm_base + PRCM_REQ_MB5_I2C_SLAVE_OP)); 2386 writeb(PRCMU_I2C_WRITE(slave), (tcdm_base + PRCM_REQ_MB5_I2C_SLAVE_OP));
2382 writeb(PRCMU_I2C_STOP_EN, (tcdm_base + PRCM_REQ_MB5_I2C_HW_BITS)); 2387 writeb(PRCMU_I2C_STOP_EN, (tcdm_base + PRCM_REQ_MB5_I2C_HW_BITS));
2383 writeb(reg, (tcdm_base + PRCM_REQ_MB5_I2C_REG)); 2388 writeb(reg, (tcdm_base + PRCM_REQ_MB5_I2C_REG));
@@ -2400,6 +2405,23 @@ int prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size)
2400} 2405}
2401 2406
2402/** 2407/**
2408 * prcmu_abb_write() - Write register value(s) to the ABB.
2409 * @slave: The I2C slave address.
2410 * @reg: The (start) register address.
2411 * @value: The value(s) to write.
2412 * @size: The number of registers to write.
2413 *
2414 * Writes register value(s) to the ABB.
2415 * @size has to be 1 for the current firmware version.
2416 */
2417int prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size)
2418{
2419 u8 mask = ~0;
2420
2421 return prcmu_abb_write_masked(slave, reg, value, &mask, size);
2422}
2423
2424/**
2403 * prcmu_ac_wake_req - should be called whenever ARM wants to wakeup Modem 2425 * prcmu_ac_wake_req - should be called whenever ARM wants to wakeup Modem
2404 */ 2426 */
2405void prcmu_ac_wake_req(void) 2427void prcmu_ac_wake_req(void)
diff --git a/include/linux/mfd/dbx500-prcmu.h b/include/linux/mfd/dbx500-prcmu.h
index eaa99a02178..d7674eb7305 100644
--- a/include/linux/mfd/dbx500-prcmu.h
+++ b/include/linux/mfd/dbx500-prcmu.h
@@ -368,6 +368,7 @@ static inline void prcmu_get_abb_event_buffer(void __iomem **buf)
368 368
369int prcmu_abb_read(u8 slave, u8 reg, u8 *value, u8 size); 369int prcmu_abb_read(u8 slave, u8 reg, u8 *value, u8 size);
370int prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size); 370int prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size);
371int prcmu_abb_write_masked(u8 slave, u8 reg, u8 *value, u8 *mask, u8 size);
371 372
372int prcmu_config_clkout(u8 clkout, u8 source, u8 div); 373int prcmu_config_clkout(u8 clkout, u8 source, u8 div);
373 374
@@ -620,6 +621,12 @@ static inline int prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size)
620 return -ENOSYS; 621 return -ENOSYS;
621} 622}
622 623
624static inline int prcmu_abb_write_masked(u8 slave, u8 reg, u8 *value, u8 *mask,
625 u8 size)
626{
627 return -ENOSYS;
628}
629
623static inline int prcmu_config_clkout(u8 clkout, u8 source, u8 div) 630static inline int prcmu_config_clkout(u8 clkout, u8 source, u8 div)
624{ 631{
625 return 0; 632 return 0;