[PATCH v5] usb: musb: Enable DMA mode1 RX for BULK endpoints

2011-08-26 Thread Moiz Sonasath
From: Anand Gadiyar gadi...@ti.com

This patch enables the DMA mode1 RX support for endpoints
that use BULK transactions. This will result in a throughput
increase of around 30-40% for BULK transfers
(mass-storage/mtp/ptp usecases)

Tested: Mass-storage, MTP, PTP, ADB, RNDIS gadgets

Signed-off-by: Anand Gadiyar gadi...@ti.com
Signed-off-by: Moiz Sonasath m-sonas...@ti.com
Signed-off-by: Vikram Pandita vikram.pand...@ti.com
---
 drivers/usb/musb/musb_gadget.c |   38 ++
 1 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index 8c41a2e..6841f91 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -624,6 +624,7 @@ void musb_g_tx(struct musb *musb, u8 epnum)
 /*
  * Context: controller locked, IRQs blocked, endpoint selected
  */
+
 static void rxstate(struct musb *musb, struct musb_request *req)
 {
const u8epnum = req-epnum;
@@ -634,6 +635,7 @@ static void rxstate(struct musb *musb, struct musb_request 
*req)
u16 len;
u16 csr = musb_readw(epio, MUSB_RXCSR);
struct musb_hw_ep   *hw_ep = musb-endpoints[epnum];
+   u8  use_mode_1;
 
if (hw_ep-is_shared_fifo)
musb_ep = hw_ep-ep_in;
@@ -683,6 +685,16 @@ static void rxstate(struct musb *musb, struct musb_request 
*req)
 
if (csr  MUSB_RXCSR_RXPKTRDY) {
len = musb_readw(epio, MUSB_RXCOUNT);
+
+   /*
+* Enable DMA Mode 1 RX transfers only for endpoints using BULK 
transactions
+*/
+
+   if (musb_ep-type == USB_ENDPOINT_XFER_BULK  len == 
musb_ep-packet_sz)
+   use_mode_1 = 1;
+   else
+   use_mode_1 = 0;
+
if (request-actual  request-length) {
 #ifdef CONFIG_USB_INVENTRA_DMA
if (is_buffer_mapped(req)) {
@@ -714,10 +726,11 @@ static void rxstate(struct musb *musb, struct 
musb_request *req)
 * then becomes usable as a runtime use mode 1 hint...
 */
 
-   csr |= MUSB_RXCSR_DMAENAB;
-#ifdef USE_MODE1
+   if (use_mode_1) {
csr |= MUSB_RXCSR_AUTOCLEAR;
-   /* csr |= MUSB_RXCSR_DMAMODE; */
+   musb_writew(epio, MUSB_RXCSR, csr);
+   csr |= MUSB_RXCSR_DMAENAB;
+   musb_writew(epio, MUSB_RXCSR, csr);
 
/* this special sequence (enabling and then
 * disabling MUSB_RXCSR_DMAMODE) is required
@@ -725,26 +738,27 @@ static void rxstate(struct musb *musb, struct 
musb_request *req)
 */
musb_writew(epio, MUSB_RXCSR,
csr | MUSB_RXCSR_DMAMODE);
-#else
+   musb_writew(epio, MUSB_RXCSR, csr);
+
+   } else {
if (!musb_ep-hb_mult 
musb_ep-hw_ep-rx_double_buffered)
csr |= MUSB_RXCSR_AUTOCLEAR;
-#endif
+   csr |= MUSB_RXCSR_DMAENAB;
musb_writew(epio, MUSB_RXCSR, csr);
+   }
 
if (request-actual  request-length) {
int transfer_size = 0;
-#ifdef USE_MODE1
+   if (use_mode_1) {
transfer_size = min(request-length - 
request-actual,
channel-max_len);
-#else
+   musb_ep-dma-desired_mode = 1;
+   } else {
transfer_size = min(request-length - 
request-actual,
(unsigned)len);
-#endif
-   if (transfer_size = musb_ep-packet_sz)
-   musb_ep-dma-desired_mode = 0;
-   else
-   musb_ep-dma-desired_mode = 1;
+   musb_ep-dma-desired_mode = 0;
+   }
 
use_dma = c-channel_program(
channel,
-- 
1.6.0.4

--
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


[PATCH] usb: musb: use put_sync_suspend instead of put_sync

2011-08-04 Thread Moiz Sonasath
From: Axel Haslam axelhas...@ti.com

As Documented in runtime documentation, drivers can call put_sync
in contexts where sleep is allowed, in contexts where sleep is not
possible, the drivers need to mark these as to be made interrupt
safe and also use put_sync_suspend instead of put_sync as the idle
callbacks will be called with interrupt enabled - which is not
a good thing to happen in isr context.

BUG: sleeping function called from invalid context at 
drivers/base/power/runtime.c:798
in_atomic(): 0, irqs_disabled(): 0, pid: 44, name: irq/164-fsa9480
Backtrace:
[c00520f0] (dump_backtrace+0x0/0x110) from [c059c1bc] (dump_stack+0x18/0x1c)
r6:de41bcd8 r5:72b6 r4:6f03 r3:6113
[c059c1a4] (dump_stack+0x0/0x1c) from [c007e370] (__might_sleep+0x130/0x134)
[c007e240] (__might_sleep+0x0/0x134) from [c02b2cc0] 
(__pm_runtime_resume+0x94/0x98)
r5:0004 r4:de58a408
[c02b2c2c] (__pm_runtime_resume+0x0/0x98) from [c0367b30] 
(musb_otg_notifications+0x90/0x140)
r7:c07c8220 r6:de41bcd8 r5:c0760494 r4:de41b000
[c0367aa0] (musb_otg_notifications+0x0/0x140) from [c00b2bc8] 
(notifier_call_chain+0x4c/0x8c)
r5: r4:
[c00b2b7c] (notifier_call_chain+0x0/0x8c) from [c00b3280] 
(__atomic_notifier_call_chain+0x40/0x54)
r8:0004 r7:0001 r6:de41bcd8 r5: r4:c078ca38

A call to pm_runtime_irq_safe, will indefently prevent the parent
from sleeping by doing a call to get-sync on the parent.
this is to prevent a irq-safe child to wait for a non-irq safe parent.
For this reason, the parent runtime-pm suspend is blocked, and we dont let L3 
and
CORE enter into low power.

As a workaround, we call the parent runtime functions on the child
runtime hooks, for this to work, the parent has to be set to
ignere children, otherwise, even with a timmed  autosuspend call,
will return BUSY, as the child is not yet suspended.

This patch is based off:
https://lkml.org/lkml/2011/7/20/357

Signed-off-by: Axel Haslam axelhas...@ti.com
Reported-by: Colin Cross ccr...@google.com
Signed-off-by: Moiz Sonasath m-sonas...@ti.com
---
 drivers/usb/musb/musb_core.c   |9 +
 drivers/usb/musb/musb_gadget.c |2 +-
 drivers/usb/musb/omap2430.c|4 +++-
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index c71b037..d22bc73 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1941,7 +1941,11 @@ musb_init_controller(struct device *dev, int nIrq, void 
__iomem *ctrl)
 
pm_runtime_use_autosuspend(musb-controller);
pm_runtime_set_autosuspend_delay(musb-controller, 200);
+   pm_runtime_use_autosuspend(musb-controller-parent);
+   pm_runtime_set_autosuspend_delay(musb-controller-parent, 500);
+   pm_suspend_ignore_children(musb-controller-parent,true);
pm_runtime_enable(musb-controller);
+   pm_runtime_irq_safe(musb-controller);
 
spin_lock_init(musb-lock);
musb-board_mode = plat-mode;
@@ -2375,6 +2379,9 @@ static int musb_runtime_suspend(struct device *dev)
 
musb_save_context(musb);
 
+   pm_runtime_mark_last_busy(musb-controller-parent);
+   pm_runtime_put_autosuspend(musb-controller-parent);
+
return 0;
 }
 
@@ -2392,6 +2399,8 @@ static int musb_runtime_resume(struct device *dev)
 * Also context restore without save does not make
 * any sense
 */
+   if (pm_runtime_suspended(dev-parent))
+   pm_runtime_get_sync(dev-parent);
if (!first)
musb_restore_context(musb);
first = 0;
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index 548338c..d5d8f3a 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -1710,7 +1710,7 @@ static int musb_gadget_pullup(struct usb_gadget *gadget, 
int is_on)
}
spin_unlock_irqrestore(musb-lock, flags);
 
-   pm_runtime_put(musb-controller);
+   pm_runtime_put_sync_suspend(musb-controller);
 
return 0;
 }
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index c5d4c44..8b6888d 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -471,6 +471,7 @@ static int __init omap2430_probe(struct platform_device 
*pdev)
}
 
pm_runtime_enable(pdev-dev);
+   pm_runtime_irq_safe(pdev-dev);
 
return 0;
 
@@ -516,7 +517,8 @@ static int omap2430_runtime_resume(struct device *dev)
struct musb *musb = glue_to_musb(glue);
 
omap2430_low_level_init(musb);
-   otg_set_suspend(musb-xceiv, 0);
+   if (musb-xceiv)
+   otg_set_suspend(musb-xceiv, 0);
 
return 0;
 }
-- 
1.6.0.4

--
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


[PATCHv2] USB: OTG: Use work_queue in set_vbus for TWL6030 transciever

2011-06-27 Thread Moiz Sonasath
From: Moiz Sonasath m-sonas...@ti.com

With this commit: cccad6d4b103e53fb3d1fc1467f654ecb572d047
usb: otg: notifier: switch to atomic notifier

Following dumps are observed on attach/detach for MUSB HOST
mode and on a detach for MUSB Device mode.

BUG: sleeping function called from invalid context at kernel/mutex.c:85
where, the source is:
twl6030_usb_irq
-atomic_notifier_call_chain
 -musb_otg_notifications
  -twl6030_set_vbus
   -twl_i2c_write_u8
-mutex_lock

This patch moves the i2c writes in set_vbus function to a
work-queue thereby avoiding I2C writes in atomic context.

Tested HOST and Device mode functionality on OMAP4460

Signed-off-by: Moiz Sonasath m-sonas...@ti.com
---
 drivers/usb/otg/twl6030-usb.c |   30 --
 1 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/otg/twl6030-usb.c b/drivers/usb/otg/twl6030-usb.c
index cfb5aa7..b4d2c09 100644
--- a/drivers/usb/otg/twl6030-usb.c
+++ b/drivers/usb/otg/twl6030-usb.c
@@ -95,11 +95,15 @@ struct twl6030_usb {
 
struct regulator*usb3v3;
 
+   /* used to set vbus, in atomic path */
+   struct work_struct  set_vbus_work;
+
int irq1;
int irq2;
u8  linkstat;
u8  asleep;
boolirq_enabled;
+   boolvbus_enable;
unsigned long   features;
 };
 
@@ -370,20 +374,31 @@ static int twl6030_enable_irq(struct otg_transceiver *x)
return 0;
 }
 
-static int twl6030_set_vbus(struct otg_transceiver *x, bool enabled)
+static void otg_set_vbus_work(struct work_struct *data)
 {
-   struct twl6030_usb *twl = xceiv_to_twl(x);
+   struct twl6030_usb *twl = container_of(data, struct twl6030_usb,
+   set_vbus_work);
 
/*
 * Start driving VBUS. Set OPA_MODE bit in CHARGERUSB_CTRL1
 * register. This enables boost mode.
 */
-   if (enabled)
+
+   if (twl-vbus_enable)
twl6030_writeb(twl, TWL_MODULE_MAIN_CHARGE , 0x40,
-   CHARGERUSB_CTRL1);
-else
+   CHARGERUSB_CTRL1);
+   else
twl6030_writeb(twl, TWL_MODULE_MAIN_CHARGE , 0x00,
-   CHARGERUSB_CTRL1);
+   CHARGERUSB_CTRL1);
+}
+
+static int twl6030_set_vbus(struct otg_transceiver *x, bool enabled)
+{
+   struct twl6030_usb *twl = xceiv_to_twl(x);
+
+   twl-vbus_enable = enabled;
+   schedule_work(twl-set_vbus_work);
+
return 0;
 }
 
@@ -444,6 +459,8 @@ static int __devinit twl6030_usb_probe(struct 
platform_device *pdev)
 
ATOMIC_INIT_NOTIFIER_HEAD(twl-otg.notifier);
 
+   INIT_WORK(twl-set_vbus_work, otg_set_vbus_work);
+
twl-irq_enabled = true;
status = request_threaded_irq(twl-irq1, NULL, twl6030_usbotg_irq,
IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
@@ -494,6 +511,7 @@ static int __exit twl6030_usb_remove(struct platform_device 
*pdev)
regulator_put(twl-usb3v3);
pdata-phy_exit(twl-dev);
device_remove_file(twl-dev, dev_attr_vbus);
+   cancel_work_sync(twl-set_vbus_work);
kfree(twl);
 
return 0;
-- 
1.6.0.4

--
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


[PATCH] USB: OTG: Use work_queue in set_vbus for TWL6030 transciever

2011-06-24 Thread Moiz Sonasath
From: Moiz Sonasath m-sonas...@ti.com

With this commit: cccad6d4b103e53fb3d1fc1467f654ecb572d047
usb: otg: notifier: switch to atomic notifier

Following dumps are observed on attach/detach for MUSB HOST
mode and on a detach for MUSB Device mode.

BUG: sleeping function called from invalid context at kernel/mutex.c:85
where, the source is:
twl6030_usb_irq
-atomic_notifier_call_chain
 -musb_otg_notifications
  -twl6030_set_vbus
   -twl_i2c_write_u8
-mutex_lock

This patch moves the i2c writes in set_vbus function to a
work-queue thereby avoiding I2C writes in atomic context.

Tested HOST and Device mode functionality on OMAP4460

Signed-off-by: Moiz Sonasath m-sonas...@ti.com
---
 drivers/usb/otg/twl6030-usb.c |   33 +++--
 1 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/otg/twl6030-usb.c b/drivers/usb/otg/twl6030-usb.c
index cfb5aa7..857de79 100644
--- a/drivers/usb/otg/twl6030-usb.c
+++ b/drivers/usb/otg/twl6030-usb.c
@@ -95,11 +95,15 @@ struct twl6030_usb {
 
struct regulator*usb3v3;
 
+   /* used to set vbus, in atomic path */
+   struct work_struct  set_vbus_work;
+
int irq1;
int irq2;
u8  linkstat;
u8  asleep;
boolirq_enabled;
+   boolvbus_enable;
unsigned long   features;
 };
 
@@ -370,20 +374,35 @@ static int twl6030_enable_irq(struct otg_transceiver *x)
return 0;
 }
 
+static void otg_set_vbus_work(struct work_struct *data)
+{
+   struct twl6030_usb *twl = container_of(data, struct twl6030_usb,
+   set_vbus_work);
+
+   if (twl-vbus_enable)
+   twl6030_writeb(twl, TWL_MODULE_MAIN_CHARGE , 0x40,
+   CHARGERUSB_CTRL1);
+   else
+   twl6030_writeb(twl, TWL_MODULE_MAIN_CHARGE , 0x00,
+   CHARGERUSB_CTRL1);
+}
+
 static int twl6030_set_vbus(struct otg_transceiver *x, bool enabled)
 {
struct twl6030_usb *twl = xceiv_to_twl(x);
 
+   if (enabled)
+   twl-vbus_enable = 1;
+   else
+   twl-vbus_enable = 0;
+
/*
 * Start driving VBUS. Set OPA_MODE bit in CHARGERUSB_CTRL1
 * register. This enables boost mode.
 */
-   if (enabled)
-   twl6030_writeb(twl, TWL_MODULE_MAIN_CHARGE , 0x40,
-   CHARGERUSB_CTRL1);
-else
-   twl6030_writeb(twl, TWL_MODULE_MAIN_CHARGE , 0x00,
-   CHARGERUSB_CTRL1);
+
+   schedule_work(twl-set_vbus_work);
+
return 0;
 }
 
@@ -444,6 +463,8 @@ static int __devinit twl6030_usb_probe(struct 
platform_device *pdev)
 
ATOMIC_INIT_NOTIFIER_HEAD(twl-otg.notifier);
 
+   INIT_WORK(twl-set_vbus_work, otg_set_vbus_work);
+
twl-irq_enabled = true;
status = request_threaded_irq(twl-irq1, NULL, twl6030_usbotg_irq,
IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
-- 
1.6.0.4

--
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


[PATCH 1/2] omap: Disable TWL4030/5030 I2C1/I2C4 internal pull-ups

2010-02-16 Thread Moiz Sonasath
This patch disables TWL4030/5030 I2C1 adn I2C4(SR) internal pull-up, to
use only the external HW resistor =470 Ohm for the assured
functionality in HS mode.

While testing the I2C in High Speed mode, it was discovered that
without a proper pull-up resistor, there is data corruption during
multi-byte transfer. RTC(time_set) test case was used for testing.

From the analysis done, it was concluded that ideally we need a
pull-up of 1.6k Ohm(recomended) or atleast 470 Ohm or greater for
assured performance in HS mode.

Signed-off-by: Moiz Sonasath m-sonas...@ti.com
Signed-off-by: Allen Pais allen.p...@ti.com
---
 drivers/mfd/twl-core.c  |   13 +
 include/linux/i2c/twl.h |   15 +++
 2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index 2a76065..35ae2ee 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -965,6 +965,7 @@ twl_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
int status;
unsignedi;
struct twl4030_platform_data*pdata = client-dev.platform_data;
+   u8 temp;
 
if (!pdata) {
dev_dbg(client-dev, no platform data?\n);
@@ -1032,6 +1033,18 @@ twl_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
goto fail;
}
 
+   /* Disable TWL4030/TWL5030 I2C Pull-up on I2C1 and I2C4(SR) interface.
+* Program I2C_SCL_CTRL_PU(bit 0)=0, I2C_SDA_CTRL_PU (bit 2)=0,
+* SR_I2C_SCL_CTRL_PU(bit 4)=0 and SR_I2C_SDA_CTRL_PU(bit 6)=0.
+*/
+
+   if (twl_class_is_4030()) {
+   twl_i2c_read_u8(TWL4030_MODULE_INTBR, temp, REG_GPPUPDCTR1);
+   temp = ~(SR_I2C_SDA_CTRL_PU | SR_I2C_SCL_CTRL_PU | \
+   I2C_SDA_CTRL_PU | I2C_SCL_CTRL_PU);
+   twl_i2c_write_u8(TWL4030_MODULE_INTBR, temp, REG_GPPUPDCTR1);
+   }
+
status = add_children(pdata, id-driver_data);
 fail:
if (status  0)
diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h
index bf1c5be..fd95eca 100644
--- a/include/linux/i2c/twl.h
+++ b/include/linux/i2c/twl.h
@@ -239,6 +239,21 @@ int twl6030_interrupt_mask(u8 bit_mask, u8 offset);
 
 /*--*/
 
+/*Interface Bit Register (INTBR) offsets
+ *(Use TWL_4030_MODULE_INTBR)
+ */
+
+#define REG_GPPUPDCTR1 0x0F
+
+/*I2C1 and I2C4(SR) SDA/SCL pull-up control bits */
+
+#define I2C_SCL_CTRL_PUBIT(0)
+#define I2C_SDA_CTRL_PUBIT(2)
+#define SR_I2C_SCL_CTRL_PU BIT(4)
+#define SR_I2C_SDA_CTRL_PU BIT(6)
+
+/*--*/
+
 /*
  * Keypad register offsets (use TWL4030_MODULE_KEYPAD)
  * ... SIH/interrupt only
-- 
1.5.6.3

--
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


[no subject]

2010-02-16 Thread Moiz Sonasath
This patch disables the newly introduced internal pull-up feature in
OMAP3630, to use only the external HW resitor = 470 Ohm for the
assured functionality in HS mode.

While testing the I2C in High Speed mode, it was discovered that
without a proper pull-up resitor, there is data corruption during
multi-byte transfers. RTC(time_set) test case was used for testing.

From the analysis done, it was concluded that ideally we need a pull-up
of 1.6 K Ohm (recomended) or atleast 470 Ohm or greater for assured
performance in HS mode.

Signed-off-by: Moiz Sonasath m-sonas...@ti.com
Signed-off-by: Allen Pais allen.p...@ti.com
Signed-off-by: Vikram Pandita vikram.pand...@ti.com
---
 arch/arm/mach-omap2/i2c.c |   24 
 arch/arm/plat-omap/include/plat/control.h |   14 ++
 2 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/i2c.c b/arch/arm/mach-omap2/i2c.c
index 789ca8c..2e6eb28 100644
--- a/arch/arm/mach-omap2/i2c.c
+++ b/arch/arm/mach-omap2/i2c.c
@@ -22,6 +22,7 @@
 #include plat/cpu.h
 #include plat/i2c.h
 #include plat/mux.h
+#include plat/control.h
 
 #include mux.h
 
@@ -52,5 +53,28 @@ int __init omap_register_i2c_bus(int bus_id, u32 clkrate,
omap_mux_init_signal(mux_name, OMAP_PIN_INPUT);
}
 
+   /* Disable OMAP 3630 internal pull-ups for all I2Ci */
+   if (cpu_is_omap3630()  !(omap_ctrl_readl(OMAP343X_CONTROL_PROG_IO1)  
OMAP3630_PRG_I2C1_PULLUPRESX)) {
+
+   u32 prog_io;
+
+   prog_io = omap_ctrl_readl(OMAP343X_CONTROL_PROG_IO1);
+   /* Program (bit 19)=1 to disable internal pull-up on I2C1 */
+   prog_io |= OMAP3630_PRG_I2C1_PULLUPRESX;
+   /* Program (bit 0)=1 to disable internal pull-up on I2C2 */
+   prog_io |= OMAP3630_PRG_I2C2_PULLUPRESX;
+   omap_ctrl_writel(prog_io, OMAP343X_CONTROL_PROG_IO1);
+
+   prog_io = omap_ctrl_readl(OMAP36XX_CONTROL_PROG_IO2);
+   /* Program (bit 7)=1 to disable internal pull-up on I2C3 */
+   prog_io |= OMAP3630_PRG_I2C3_PULLUPRESX;
+   omap_ctrl_writel(prog_io, OMAP36XX_CONTROL_PROG_IO2);
+
+   prog_io = omap_ctrl_readl(OMAP36XX_CONTROL_PROG_IO_WKUP1);
+   /* Program (bit 5)=1 to disable internall pull-up on I2C4(SR) */
+   prog_io |= OMAP3630_PRG_SR_PULLUPRESX;
+   omap_ctrl_writel(prog_io, OMAP36XX_CONTROL_PROG_IO_WKUP1);
+   }
+
return omap_plat_register_i2c_bus(bus_id, clkrate, info, len);
 }
diff --git a/arch/arm/plat-omap/include/plat/control.h 
b/arch/arm/plat-omap/include/plat/control.h
index 2074473..9e58d8e 100644
--- a/arch/arm/plat-omap/include/plat/control.h
+++ b/arch/arm/plat-omap/include/plat/control.h
@@ -169,6 +169,9 @@
 #define AM35XX_CONTROL_IP_SW_RESET  (OMAP2_CONTROL_GENERAL + 0x0328)
 #define AM35XX_CONTROL_IPSS_CLK_CTRL(OMAP2_CONTROL_GENERAL + 0x032C)
 
+/* 36xx-only CONTROL_GENERAL register offsets */
+#define OMAP36XX_CONTROL_PROG_IO2   (OMAP2_CONTROL_GENERAL + 0x0198)
+
 /* 34xx PADCONF register offsets */
 #define OMAP343X_PADCONF_ETK(i)(OMAP2_CONTROL_PADCONFS + 0x5a8 
+ \
(i)*2)
@@ -200,6 +203,9 @@
 #define OMAP343X_CONTROL_WKUP_DEBOBS3 (OMAP343X_CONTROL_GENERAL_WKUP + 0x014)
 #define OMAP343X_CONTROL_WKUP_DEBOBS4 (OMAP343X_CONTROL_GENERAL_WKUP + 0x018)
 
+/* 36xx-only GENERAL_WKUP register offsets */
+#define OMAP36XX_CONTROL_PROG_IO_WKUP1 (OMAP343X_CONTROL_GENERAL_WKUP + 0x020)
+
 /* 34xx D2D idle-related pins, handled by PM core */
 #define OMAP3_PADCONF_SAD2D_MSTANDBY   0x250
 #define OMAP3_PADCONF_SAD2D_IDLEACK0x254
@@ -250,6 +256,8 @@
 #define OMAP2_PBIASLITEVMODE0  (1  0)
 
 /* CONTROL_PROG_IO1 bits */
+#define OMAP3630_PRG_I2C2_PULLUPRESX(1  0)
+#define OMAP3630_PRG_I2C1_PULLUPRESX   (1  19)
 #define OMAP3630_PRG_SDMMC1_SPEEDCTRL  (1  20)
 
 /* CONTROL_IVA2_BOOTMOD bits */
@@ -257,6 +265,12 @@
 #define OMAP3_IVA2_BOOTMOD_MASK(0xf  0)
 #define OMAP3_IVA2_BOOTMOD_IDLE(0x1  0)
 
+/* CONTROL_PROG_IO2 bits on omap3630 */
+#define OMAP3630_PRG_I2C3_PULLUPRESX(1  7)
+
+/* CONTROL_PROG_IO_WKUP1 bits on omap3630 */
+#define OMAP3630_PRG_SR_PULLUPRESX(1  5)
+
 /* CONTROL_PADCONF_X bits */
 #define OMAP3_PADCONF_WAKEUPEVENT0 (1  15)
 #define OMAP3_PADCONF_WAKEUPENABLE0(1  14)
-- 
1.5.6.3

--
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


[PATCH 3/3] i2c-omap: Enable workaround for Errata 1.153 based on

2009-08-20 Thread Moiz Sonasath
Silicon Errata 1.153 has been fixed on OMAP 3630|4430 with the use of a later
version of I2C IP block.

The errata impacts OMAP 2420|2430|3430, enable the workaround for these based 
on I2C IP block revision number instead of OMAP CPU type

Signed-off-by: Moiz Sonasath m-sonas...@ti.com
Signed-off-by: Vikram Pandita vikram.pand...@ti.com
Reviewed-by: Paul Walmsley p...@pwsan.com
---
 drivers/i2c/busses/i2c-omap.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 16b39f4..827da08 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -784,7 +784,7 @@ complete:
 * memory to the I2C interface.
 */
 
-   if (cpu_is_omap34xx()) {
+   if (dev-rev = OMAP_I2C_REV_ON_3430) {
while (!(stat  
OMAP_I2C_STAT_XUDF)) {
if (stat  
(OMAP_I2C_STAT_NACK | OMAP_I2C_STAT_AL)) {

omap_i2c_ack_stat(dev, stat  (OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR));
-- 
1.5.6.3

--
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


[PATCH 0/3] i2c-omap: I2C clean-up patch

2009-08-20 Thread Moiz Sonasath
This patch includes the following fixes:
-Fix I2C status ACK
-ACK pending [R/X]DR and [R/X]RDY interrupts in the error/completeion path
-Enable workaround for Errata 1.153 based on I2C IP block

Signed-off-by: Moiz Sonasath m-sonas...@ti.com
Signed-off-by: Vikram Pandita vikram.pand...@ti.com

Moiz Sonasath (3):
  i2c-omap: Fix I2C status ACK
  i2c-omap: ACK pending [R/X]DR and [R/X]RDY interrupts in the
error/completeion path
  i2c-omap: Enable workaround for Errata 1.153 based on I2C IP block

 drivers/i2c/busses/i2c-omap.c |   14 --
 1 files changed, 12 insertions(+), 2 deletions(-)

--
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


[PATCH 1/3] i2c-omap: Fix I2C status ACK

2009-08-20 Thread Moiz Sonasath
From: Nishanth Menon n...@ti.com

I2C status ack for [RX]RDR and [RX]RDY could
cause race conditions of clearing the event
twice and a violation of the programing
sequence as defined in TRM This patch fixes
the same.

Signed-off-by: Nishanth Menon n...@ti.com
Signed-off-by: Moiz Sonasath m-sonas...@ti.com
---
 drivers/i2c/busses/i2c-omap.c |9 -
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index d258b02..94639d0 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -674,7 +674,14 @@ omap_i2c_isr(int this_irq, void *dev_id)
 
err = 0;
 complete:
-   omap_i2c_write_reg(dev, OMAP_I2C_STAT_REG, stat);
+   /*
+* Ack the stat in one go, but [R/X]DR and [R/X]RDY should be
+* acked after the data operation is complete.
+* Ref: TRM SWPU114Q Figure 18-31
+*/
+   omap_i2c_write_reg(dev, OMAP_I2C_STAT_REG, stat 
+   ~(OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR |
+   OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR));
 
if (stat  OMAP_I2C_STAT_NACK) {
err |= OMAP_I2C_STAT_NACK;
-- 
1.5.6.3

--
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


[PATCH 2/3] i2c-omap: ACK pending [R/X]DR and [R/X]RDY interrupts

2009-08-20 Thread Moiz Sonasath
ACK any pending read/write interrupts before exiting the ISR either after 
completing the operation [ARDY interrupt] or in case of an error 
[NACK|AL interrupt]

Signed-off-by: Moiz Sonasath m-sonas...@ti.com
Signed-off-by: Vikram Pandita vikram.pand...@ti.com
---
 drivers/i2c/busses/i2c-omap.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 94639d0..16b39f4 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -694,6 +694,9 @@ complete:
}
if (stat  (OMAP_I2C_STAT_ARDY | OMAP_I2C_STAT_NACK |
OMAP_I2C_STAT_AL)) {
+   omap_i2c_ack_stat(dev, stat 
+   (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR |
+   OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR));
omap_i2c_complete_cmd(dev, err);
return IRQ_HANDLED;
}
-- 
1.5.6.3

--
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


[PATCH 1/3] i2c-omap: Fix I2C status ACK

2009-08-17 Thread Moiz Sonasath
From: Nishanth Menon n...@ti.com

I2C status ack for [RX]RDR and [RX]RDY could
cause race conditions of clearing the event
twice and a violation of the programing
sequence as defined in TRM This patch fixes
the same.

Signed-off-by: Nishanth Menon n...@ti.com
Signed-off-by: Moiz Sonasath m-sonas...@ti.com
---
 drivers/i2c/busses/i2c-omap.c |9 -
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index d258b02..94639d0 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -674,7 +674,14 @@ omap_i2c_isr(int this_irq, void *dev_id)
 
err = 0;
 complete:
-   omap_i2c_write_reg(dev, OMAP_I2C_STAT_REG, stat);
+   /*
+* Ack the stat in one go, but [R/X]DR and [R/X]RDY should be
+* acked after the data operation is complete.
+* Ref: TRM SWPU114Q Figure 18-31
+*/
+   omap_i2c_write_reg(dev, OMAP_I2C_STAT_REG, stat 
+   ~(OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR |
+   OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR));
 
if (stat  OMAP_I2C_STAT_NACK) {
err |= OMAP_I2C_STAT_NACK;
-- 
1.5.6.3

--
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


[PATCH 3/3] i2c-omap: Enable workaround for Errata 1.153 based on

2009-08-17 Thread Moiz Sonasath
Silicon Errata 1.153 has been fixed on OMAP 3630|4430 with the use of a later
version of I2C IP block.

The errata impacts OMAP 2420|2430|3430, enable the workaround for these based 
on I2C IP block revision number instead of OMAP CPU type

Signed-off-by: Moiz Sonasath m-sonas...@ti.com
Signed-off-by: Vikram Pandita vikram.pand...@ti.com
---
 drivers/i2c/busses/i2c-omap.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 16b39f4..827da08 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -784,7 +784,7 @@ complete:
 * memory to the I2C interface.
 */
 
-   if (cpu_is_omap34xx()) {
+   if (dev-rev = OMAP_I2C_REV_ON_3430) {
while (!(stat  
OMAP_I2C_STAT_XUDF)) {
if (stat  
(OMAP_I2C_STAT_NACK | OMAP_I2C_STAT_AL)) {

omap_i2c_ack_stat(dev, stat  (OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR));
-- 
1.5.6.3

--
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


[PATCH 2/3] i2c-omap: ACK pending [R/X]DR and [R/X]RDY interrupts

2009-08-17 Thread Moiz Sonasath
ACK any pending read/write interrupts before exiting the ISR either after 
completing the operation [ARDY interrupt] or in case of an error 
[NACK|AL interrupt]

Signed-off-by: Moiz Sonasath m-sonas...@ti.com
Signed-off-by: Vikram Pandita vikram.pand...@ti.com
---
 drivers/i2c/busses/i2c-omap.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 94639d0..16b39f4 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -694,6 +694,9 @@ complete:
}
if (stat  (OMAP_I2C_STAT_ARDY | OMAP_I2C_STAT_NACK |
OMAP_I2C_STAT_AL)) {
+   omap_i2c_ack_stat(dev, stat 
+   (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR |
+   OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR));
omap_i2c_complete_cmd(dev, err);
return IRQ_HANDLED;
}
-- 
1.5.6.3

--
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


[PATCH 0/3] *** SUBJECT HERE ***

2009-08-17 Thread Moiz Sonasath
i2c-omap: I2C clean-up patch

This patch includes the following fixes:
-Fix I2C status ACK
-ACK pending [R/X]DR and [R/X]RDY interrupts in the error/completeion path
-Enable workaround for Errata 1.153 based on I2C IP block

Signed-off-by: Moiz Sonasath m-sonas...@ti.com
Signed-off-by: Vikram Pandita vikram.pand...@ti.com

Moiz Sonasath (3):
  i2c-omap: Fix I2C status ACK
  i2c-omap: ACK pending [R/X]DR and [R/X]RDY interrupts in the
error/completeion path
  i2c-omap: Enable workaround for Errata 1.153 based on I2C IP block

 drivers/i2c/busses/i2c-omap.c |   14 --
 1 files changed, 12 insertions(+), 2 deletions(-)

--
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