Re: [PATCH v2 10/20] omap: zoom: add fixed regulator device for wlan

2010-07-25 Thread Ohad Ben-Cohen
On Fri, Jul 23, 2010 at 12:15 PM, Mark Brown
broo...@opensource.wolfsonmicro.com wrote:
 On Fri, Jul 23, 2010 at 02:13:38AM +0300, Ohad Ben-Cohen wrote:
 On Thu, Jul 22, 2010 at 2:16 PM, Roger Quadros roger.quad...@nokia.com 
 wrote:
  .dev_name       = mmci-omap-hs.2

 I already set the .dev member of the consumer in a similar manner to
 how all other regulators are configured in this board - please check
 out patch 13:

 https://patchwork.kernel.org/patch/113418/

 Does this look reasonable to you ?

 You should really be using dev_name in preference to dev these days
 unless there's a *very* good reason.

Changed, thank you.

I'll submit the updated patch now as a standalone patch as it has no
dependencies on the whole series, and it could only help to start
trimming that series down.


--
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] omap: zoom: add fixed regulator device for wl1271

2010-07-25 Thread Ohad Ben-Cohen
Add a fixed regulator vmmc device to enable power control
of the wl1271 wlan device.

Signed-off-by: Ohad Ben-Cohen o...@wizery.com
---
This patch is a follow-up to a previous wl1271 discussion,
thus all original recipients are CC'ed.

 arch/arm/mach-omap2/board-zoom-peripherals.c |   35 ++
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/board-zoom-peripherals.c 
b/arch/arm/mach-omap2/board-zoom-peripherals.c
index 6b39849..de88635 100644
--- a/arch/arm/mach-omap2/board-zoom-peripherals.c
+++ b/arch/arm/mach-omap2/board-zoom-peripherals.c
@@ -16,6 +16,7 @@
 #include linux/gpio.h
 #include linux/i2c/twl.h
 #include linux/regulator/machine.h
+#include linux/regulator/fixed.h
 
 #include asm/mach-types.h
 #include asm/mach/arch.h
@@ -27,6 +28,8 @@
 #include mux.h
 #include hsmmc.h
 
+#define OMAP_ZOOM_WLAN_PMENA_GPIO  (101)
+
 /* Zoom2 has Qwerty keyboard*/
 static int board_keymap[] = {
KEY(0, 0, KEY_E),
@@ -106,6 +109,11 @@ static struct regulator_consumer_supply zoom_vmmc2_supply 
= {
.supply = vmmc,
 };
 
+static struct regulator_consumer_supply zoom_vmmc3_supply = {
+   .supply = vmmc,
+   .dev_name   = mmci-omap-hs.2,
+};
+
 /* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
 static struct regulator_init_data zoom_vmmc1 = {
.constraints = {
@@ -151,6 +159,32 @@ static struct regulator_init_data zoom_vsim = {
.consumer_supplies  = zoom_vsim_supply,
 };
 
+static struct regulator_init_data zoom_vmmc3 = {
+   .constraints = {
+   .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+   },
+   .num_consumer_supplies = 1,
+   .consumer_supplies = zoom_vmmc3_supply,
+};
+
+static struct fixed_voltage_config zoom_vwlan = {
+   .supply_name = vwl1271,
+   .microvolts = 180, /* 1.8V */
+   .gpio = OMAP_ZOOM_WLAN_PMENA_GPIO,
+   .startup_delay = 7, /* 70msec */
+   .enable_high = 1,
+   .enabled_at_boot = 0,
+   .init_data = zoom_vmmc3,
+};
+
+static struct platform_device omap_vwlan_device = {
+   .name   = reg-fixed-voltage,
+   .id = 1,
+   .dev = {
+   .platform_data = zoom_vwlan,
+   },
+};
+
 static struct omap2_hsmmc_info mmc[] __initdata = {
{
.name   = external,
@@ -280,6 +314,7 @@ static void enable_board_wakeup_source(void)
 void __init zoom_peripherals_init(void)
 {
omap_i2c_init();
+   platform_device_register(omap_vwlan_device);
usb_musb_init(musb_board_data);
enable_board_wakeup_source();
 }
-- 
1.7.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


Re: [PATCH v2 18/20] mmc: sdio: enable a default power off mode of the card

2010-07-25 Thread Ohad Ben-Cohen
On Thu, Jul 22, 2010 at 2:35 PM, Roger Quadros roger.quad...@nokia.com wrote:
 On 07/21/2010 08:33 PM, ext Ohad Ben-Cohen wrote:

 Add support for an SDIO device to stay powered off even without
 the presence of an SDIO function driver. A host should explicitly
 ask for it by means of MMC_CAP_DONT_POWER_CARD, and the SDIO
 function driver should know it needs to call sdio_claim_power
 before accessing the device.

 Signed-off-by: Ohad Ben-Coheno...@wizery.com

 Shouldn't this be the default behaviour? If there is no function driver for
 any of the functions of the card, then sdio core shold power off the card.

 I don't see a need for a special capability flag for this.

 in fact MMC_CAP_DONT_POWER_CARD does not seem like an mmc host's capability

Totally agree.

I didn't want to change the current behavior of the cards/funcs so I
looked for a way to explicitly power down only specific cards.

Alternatively we could power down all cards at the end
mmc_attach_sdio, and then power them up selectively in sdio_bus_probe,
just before calling probe. If the probe succeeds, the function driver
takes over. If the probe fails, we can power them down again.

Is that what you meant ?

This would work both if the sdio function driver is already loaded, or
will only be loaded at a later time. But I'm not too fond of the extra
power on/off cycles that it will introduce for each card..

Thanks,
Ohad.

 flag, it seems more like a request from the board to keep the card powered
 off.

 regards,
 -roger

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


[RFC] ARM: DMA coherent allocator: align remapped addresses

2010-07-25 Thread Russell King - ARM Linux
The DMA coherent remap area is used to provide an uncached mapping
of memory for coherency with DMA engines.  Currently, we look for
any free hole which our allocation will fit in with page alignment.

However, this can lead to fragmentation of the area, and allows small
allocations to cross L1 entry boundaries.  This is undesirable as we
want to move towards allocating sections of memory.

Align allocations according to the size, limiting the alignment between
the page and section sizes.

Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
The reduction in probability of fragmentation is not the main reason
for this patch - it's more to check what the effect of aligning the
allocations will have on the system.  The point of aligning the
allocations is to prevent requests below the section size from crossing
a section size boundary, which may be discontiguous (see below.)

The long term idea is to solve the problem of the DMA coherent region
aliasing with the main memory region with different attributes by
allocating DMA memory in 1MB or larger contiguous chunks.  However,
there are a few issues with this which will need to be solved:

1. being able to allocate 1MB of naturally aligned DMA-able memory
   will be problematical for some platforms.  Possible solutions are
   pre-allocating a specified amount of coherent memory (maybe specified
   via a command line option, or maybe based on a certain %age of
   available DMA memory.)

2. allocations will always have to be done using GFP_DMA as allocations
   smaller than 1MB will share existing sections - so we need to ensure
   that all allocated memory will be DMA-able to all devices.  This isn't
   a new restriction as we already assume that GFP_DMA memory can satisfy
   any DMA mask presented to the system.

3. mapping and unmapping sections is fraught at the best of times, as
   these actions need to be manually propagated to all other tasks page
   tables in the system.  (we currently get around this by pre-allocating
   the L2 tables at boot time for the DMA coherent region.)

 arch/arm/mm/dma-mapping.c |   15 ++-
 arch/arm/mm/vmregion.c|5 +++--
 arch/arm/mm/vmregion.h|2 +-
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 9e7742f..c704eed 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -183,6 +183,8 @@ static void *
 __dma_alloc_remap(struct page *page, size_t size, gfp_t gfp, pgprot_t prot)
 {
struct arm_vmregion *c;
+   size_t align;
+   int bit;
 
if (!consistent_pte[0]) {
printk(KERN_ERR %s: not initialised\n, __func__);
@@ -191,9 +193,20 @@ __dma_alloc_remap(struct page *page, size_t size, gfp_t 
gfp, pgprot_t prot)
}
 
/*
+* Align the virtual region allocation - maximum alignment is
+* a section size, minimum is a page size.  This helps reduce
+* fragmentation of the DMA space, and also prevents allocations
+* smaller than a section from crossing a section boundary.
+*/
+   bit = fls(size - 1) + 1;
+   if (bit  SECTION_SHIFT)
+   bit = SECTION_SHIFT;
+   align = 1  bit;
+
+   /*
 * Allocate a virtual address in the consistent mapping region.
 */
-   c = arm_vmregion_alloc(consistent_head, size,
+   c = arm_vmregion_alloc(consistent_head, align, size,
gfp  ~(__GFP_DMA | __GFP_HIGHMEM));
if (c) {
pte_t *pte;
diff --git a/arch/arm/mm/vmregion.c b/arch/arm/mm/vmregion.c
index 19e09bd..935993e 100644
--- a/arch/arm/mm/vmregion.c
+++ b/arch/arm/mm/vmregion.c
@@ -35,7 +35,8 @@
  */
 
 struct arm_vmregion *
-arm_vmregion_alloc(struct arm_vmregion_head *head, size_t size, gfp_t gfp)
+arm_vmregion_alloc(struct arm_vmregion_head *head, size_t align,
+  size_t size, gfp_t gfp)
 {
unsigned long addr = head-vm_start, end = head-vm_end - size;
unsigned long flags;
@@ -58,7 +59,7 @@ arm_vmregion_alloc(struct arm_vmregion_head *head, size_t 
size, gfp_t gfp)
goto nospc;
if ((addr + size) = c-vm_start)
goto found;
-   addr = c-vm_end;
+   addr = ALIGN(c-vm_end, align);
if (addr  end)
goto nospc;
}
diff --git a/arch/arm/mm/vmregion.h b/arch/arm/mm/vmregion.h
index 6b2cdbd..15e9f04 100644
--- a/arch/arm/mm/vmregion.h
+++ b/arch/arm/mm/vmregion.h
@@ -21,7 +21,7 @@ struct arm_vmregion {
int vm_active;
 };
 
-struct arm_vmregion *arm_vmregion_alloc(struct arm_vmregion_head *, size_t, 
gfp_t);
+struct arm_vmregion *arm_vmregion_alloc(struct arm_vmregion_head *, size_t, 
size_t, gfp_t);
 struct arm_vmregion *arm_vmregion_find(struct arm_vmregion_head *, unsigned 
long);
 struct arm_vmregion *arm_vmregion_find_remove(struct arm_vmregion_head *, 

Re: [PATCH v2 18/20] mmc: sdio: enable a default power off mode of the card

2010-07-25 Thread Nicolas Pitre
On Sun, 25 Jul 2010, Ohad Ben-Cohen wrote:

 On Thu, Jul 22, 2010 at 2:35 PM, Roger Quadros roger.quad...@nokia.com 
 wrote:
  On 07/21/2010 08:33 PM, ext Ohad Ben-Cohen wrote:
 
  Add support for an SDIO device to stay powered off even without
  the presence of an SDIO function driver. A host should explicitly
  ask for it by means of MMC_CAP_DONT_POWER_CARD, and the SDIO
  function driver should know it needs to call sdio_claim_power
  before accessing the device.
 
  Signed-off-by: Ohad Ben-Coheno...@wizery.com
 
  Shouldn't this be the default behaviour? If there is no function driver for
  any of the functions of the card, then sdio core shold power off the card.
 
  I don't see a need for a special capability flag for this.
 
  in fact MMC_CAP_DONT_POWER_CARD does not seem like an mmc host's capability
 
 Totally agree.
 
 I didn't want to change the current behavior of the cards/funcs so I
 looked for a way to explicitly power down only specific cards.
 
 Alternatively we could power down all cards at the end
 mmc_attach_sdio, and then power them up selectively in sdio_bus_probe,
 just before calling probe. If the probe succeeds, the function driver
 takes over. If the probe fails, we can power them down again.

Exactly!

 Is that what you meant ?
 
 This would work both if the sdio function driver is already loaded, or
 will only be loaded at a later time. But I'm not too fond of the extra
 power on/off cycles that it will introduce for each card..

This is still way better than introducing knowledge about specific cards 
in the host drivers.


Nicolas
--
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 v2 18/20] mmc: sdio: enable a default power off mode of the card

2010-07-25 Thread Ohad Ben-Cohen
On Sun, Jul 25, 2010 at 4:56 PM, Nicolas Pitre n...@fluxnic.net wrote:
 On Sun, 25 Jul 2010, Ohad Ben-Cohen wrote:

 On Thu, Jul 22, 2010 at 2:35 PM, Roger Quadros roger.quad...@nokia.com 
 wrote:
  On 07/21/2010 08:33 PM, ext Ohad Ben-Cohen wrote:
 
  Add support for an SDIO device to stay powered off even without
  the presence of an SDIO function driver. A host should explicitly
  ask for it by means of MMC_CAP_DONT_POWER_CARD, and the SDIO
  function driver should know it needs to call sdio_claim_power
  before accessing the device.
 
  Signed-off-by: Ohad Ben-Coheno...@wizery.com
 
  Shouldn't this be the default behaviour? If there is no function driver for
  any of the functions of the card, then sdio core shold power off the card.
 
  I don't see a need for a special capability flag for this.
 
  in fact MMC_CAP_DONT_POWER_CARD does not seem like an mmc host's capability

 Totally agree.

 I didn't want to change the current behavior of the cards/funcs so I
 looked for a way to explicitly power down only specific cards.

 Alternatively we could power down all cards at the end
 mmc_attach_sdio, and then power them up selectively in sdio_bus_probe,
 just before calling probe. If the probe succeeds, the function driver
 takes over. If the probe fails, we can power them down again.

 Exactly!

Ok, v3 is on the way :)

(featuring no special host CAP, fix locking issues, and power down
unclaimed cards also on resume)
--
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: [RFC 3/8] TILER-DMM: Sample TCM implementation: Simple TILER Allocator

2010-07-25 Thread Molnar, Lajos


 -Original Message-
 From: Shilimkar, Santosh
 Sent: Saturday, July 24, 2010 2:13 AM
  +   kfree(tcm);
  +   kfree(pvt);
 If only one of the allocation was successful, then you
 are freeing a NULL pointer.
 May be have something like this
 
   tcm = kzalloc(sizeof(*tcm), GFP_KERNEL);
   if (!tcm)
   goto error1;
   pvt = kzalloc(sizeof(*pvt), GFP_KERNEL);
   if (!pvt)
   goto error2;
   .
   .
   .
 error1:
   kfree(tcm);
 error2:
   kfree(pvt);

Freeing a NULL pointer is always valid, and simply returns.  This is a C 
specification.

--
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 6/7] save and restore etm state across core OFF modes

2010-07-25 Thread Alexander Shishkin
This prevents ETM stalls whenever core enters OFF mode. Original patch
author is Richard Woodruff r-woodru...@ti.com.

This version of the patch makes use of the ETM OS save/restore mechanism,
which takes about 55 words in omap3_arm_context[] instead of 128. Also,
saving ETM context can be switched on/off at runtime.

Signed-off-by: Alexander Shishkin virtu...@slind.org
Cc: Richard Woodruff r-woodru...@ti.com
Cc: Tony Lindgren t...@atomide.com
Cc: Russell King li...@arm.linux.org.uk
Cc: Paul Walmsley p...@pwsan.com
Cc: Kevin Hilman khil...@deeprootsystems.com
Cc: linux-omap@vger.kernel.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-ker...@vger.kernel.org
---
 arch/arm/mach-omap2/Kconfig   |9 ++
 arch/arm/mach-omap2/control.c |2 +-
 arch/arm/mach-omap2/sleep34xx.S   |  135 +
 arch/arm/plat-omap/include/plat/control.h |2 +-
 4 files changed, 146 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig
index b48bacf..0413d88 100644
--- a/arch/arm/mach-omap2/Kconfig
+++ b/arch/arm/mach-omap2/Kconfig
@@ -243,6 +243,15 @@ config MACH_OMAP4_PANDA
default y
depends on ARCH_OMAP4
 
+config ENABLE_OFF_MODE_JTAG_ETM_DEBUG
+   bool Enable hardware emulation context save and restore
+   depends on ARCH_OMAP3
+   default y
+   help
+ This option enables JTAG  ETM debugging across power states.
+ With out this option emulation features are reset across OFF
+ mode state changes.
+
 config OMAP3_EMU
bool OMAP3 debugging peripherals
depends on ARCH_OMAP3
diff --git a/arch/arm/mach-omap2/control.c b/arch/arm/mach-omap2/control.c
index a8d20ee..22dd240 100644
--- a/arch/arm/mach-omap2/control.c
+++ b/arch/arm/mach-omap2/control.c
@@ -93,7 +93,7 @@ void *omap3_secure_ram_storage;
  * The address is stored in scratchpad, so that it can be used
  * during the restore path.
  */
-u32 omap3_arm_context[128];
+u32 omap3_arm_context[256];
 
 struct omap3_control_regs {
u32 sysconfig;
diff --git a/arch/arm/mach-omap2/sleep34xx.S b/arch/arm/mach-omap2/sleep34xx.S
index d522cd7..cd6a1d4 100644
--- a/arch/arm/mach-omap2/sleep34xx.S
+++ b/arch/arm/mach-omap2/sleep34xx.S
@@ -28,6 +28,7 @@
 #include asm/assembler.h
 #include mach/io.h
 #include plat/control.h
+#include asm/hardware/coresight.h
 
 #include cm.h
 #include prm.h
@@ -226,6 +227,18 @@ loop:
nop
bl wait_sdrc_ok
 
+#ifdef CONFIG_ENABLE_OFF_MODE_JTAG_ETM_DEBUG
+   /*
+* Restore Coresight debug registers
+*/
+   ldr r6, debug_vbase /* base Vaddr of CortexA8-Debug */
+   ldr r4, debug_xlar_key  /* get lock key for OSLAR */
+   bl  unlock_debug/* remove global lock if set */
+   ldr r6, etm_vbase   /* base Vaddr of ETM */
+   bl  unlock_debug/* remove global lock if set */
+   str r6, [r6, #ETMMR_OSLAR]  /* clear OSLAR lock using non-key */
+#endif
+
ldmfd   sp!, {r0-r12, pc}   @ restore regs and return
 restore_es3:
/*b restore_es3*/   @ Enable to debug restore code
@@ -385,6 +398,44 @@ logic_l1_restore:
/*normal memory remap register */
MCR p15, 0, r5, c10, c2, 1
 
+#ifdef CONFIG_ENABLE_OFF_MODE_JTAG_ETM_DEBUG
+   /*
+* Restore Coresight debug registers
+*/
+   ldr r6, debug_pbase /* base paddr of CortexA8-Debug */
+   ldr r4, debug_xlar_key  /* get lock key for OSLAR */
+   bl  unlock_debug/* remove global lock if set */
+   str r4, [r6, #ETMMR_OSLAR]  /* reset-pointer (already locked) */
+   ldr r4, [r6, #ETMMR_OSSRR]  /* dummy read */
+   ldr r4, [r3], #4/* load save size */
+   cmp r4, #0  /* check for zero */
+debug_restore:
+   itttne  /* t2/compat if-then block */
+   ldrne   r5, [r3], #4/* get saved value */
+   strne   r5, [r6,#ETMMR_OSSRR]   /* restore saved value */
+   subnes  r4, r4, #1  /* decrement loop */
+   bne debug_restore   /* loop till done */
+   str r5, [r6, #ETMMR_OSSRR]  /* clear lock */
+   /*
+* Restore CoreSight ETM registers
+*/
+   ldr r6, etm_pbase   /* base paddr of ETM */
+   ldr r4, debug_xlar_key  /* get lock key for OSLAR */
+   bl  unlock_debug/* remove global lock if set */
+   str r4, [r6, #ETMMR_OSLAR]  /* reset-pointer (already locked) */
+   ldr r4, [r6, #ETMMR_OSSRR]  /* dummy read */
+   ldr r4, [r3], #4/* load save size */
+   cmp r4, #0  /* check for zero */
+   beq etm_skip
+etm_restore:
+   ldrne   r5, [r3], #4/* get saved value */
+   strne   r5, [r6, #ETMMR_OSSRR]  /* restore saved 

[PATCH 5/7] omap3: move EMU peripheral addresses to a platform header

2010-07-25 Thread Alexander Shishkin
These addresses are also needed for the OFF code to save/restore the
contexts of the EMU peripherals correctly.

Signed-off-by: Alexander Shishkin virtu...@slind.org
Cc: Tony Lindgren t...@atomide.com
Cc: Russell King li...@arm.linux.org.uk
Cc: Paul Walmsley p...@pwsan.com
Cc: Santosh Shilimkar santosh.shilim...@ti.com
Cc: Kevin Hilman khil...@deeprootsystems.com
Cc: linux-omap@vger.kernel.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-ker...@vger.kernel.org
---
 arch/arm/mach-omap2/emu.c|   14 --
 arch/arm/plat-omap/include/plat/io.h |   20 
 2 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-omap2/emu.c b/arch/arm/mach-omap2/emu.c
index 9c442e2..6b41745 100644
--- a/arch/arm/mach-omap2/emu.c
+++ b/arch/arm/mach-omap2/emu.c
@@ -24,19 +24,13 @@
 MODULE_LICENSE(GPL);
 MODULE_AUTHOR(Alexander Shishkin);
 
-/* Cortex CoreSight components within omap3xxx EMU */
-#define ETM_BASE   (L4_EMU_34XX_PHYS + 0x1)
-#define DBG_BASE   (L4_EMU_34XX_PHYS + 0x11000)
-#define ETB_BASE   (L4_EMU_34XX_PHYS + 0x1b000)
-#define DAPCTL (L4_EMU_34XX_PHYS + 0x1d000)
-
 static struct amba_device omap3_etb_device = {
.dev= {
.init_name = etb,
},
.res= {
-   .start  = ETB_BASE,
-   .end= ETB_BASE + SZ_4K - 1,
+   .start  = OMAP34XX_ETB_PHYS,
+   .end= OMAP34XX_ETB_PHYS + OMAP34XX_ETB_SIZE - 1,
.flags  = IORESOURCE_MEM,
},
.periphid   = 0x000bb907,
@@ -47,8 +41,8 @@ static struct amba_device omap3_etm_device = {
.init_name = etm,
},
.res= {
-   .start  = ETM_BASE,
-   .end= ETM_BASE + SZ_4K - 1,
+   .start  = OMAP34XX_ETM_PHYS,
+   .end= OMAP34XX_ETM_PHYS + OMAP34XX_ETM_SIZE - 1,
.flags  = IORESOURCE_MEM,
},
.periphid   = 0x102bb921,
diff --git a/arch/arm/plat-omap/include/plat/io.h 
b/arch/arm/plat-omap/include/plat/io.h
index 128b549..81f736a 100644
--- a/arch/arm/plat-omap/include/plat/io.h
+++ b/arch/arm/plat-omap/include/plat/io.h
@@ -185,6 +185,26 @@
 
 /* 3430 IVA - currently unmapped */
 
+#define OMAP34XX_DBG_OFFSET(0x00011000)
+#define OMAP34XX_DBG_VIRT  (L4_EMU_34XX_VIRT + OMAP34XX_DBG_OFFSET)
+#define OMAP34XX_DBG_PHYS  (L4_EMU_34XX_PHYS + OMAP34XX_DBG_OFFSET)
+#define OMAP34XX_DBG_SIZE  SZ_4K
+
+#define OMAP34XX_ETM_OFFSET(0x0001)
+#define OMAP34XX_ETM_VIRT  (L4_EMU_34XX_VIRT + OMAP34XX_ETM_OFFSET)
+#define OMAP34XX_ETM_PHYS  (L4_EMU_34XX_PHYS + OMAP34XX_ETM_OFFSET)
+#define OMAP34XX_ETM_SIZE  SZ_4K
+
+#define OMAP34XX_ETB_OFFSET(0x0001b000)
+#define OMAP34XX_ETB_VIRT  (L4_EMU_34XX_VIRT + OMAP34XX_ETB_OFFSET)
+#define OMAP34XX_ETB_PHYS  (L4_EMU_34XX_PHYS + OMAP34XX_ETB_OFFSET)
+#define OMAP34XX_ETB_SIZE  SZ_4K
+
+#define OMAP34XX_DAP_OFFSET(0x0001d000)
+#define OMAP34XX_DAP_VIRT  (L4_EMU_34XX_VIRT + OMAP34XX_DAP_OFFSET)
+#define OMAP34XX_DAP_PHYS  (L4_EMU_34XX_PHYS + OMAP34XX_DAP_OFFSET)
+#define OMAP34XX_DAP_SIZE  SZ_4K
+
 /*
  * 
  * Omap4 specific IO mapping
-- 
1.7.1

--
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 6/7] save and restore etm state across core OFF modes

2010-07-25 Thread Hari Kanigeri
 +config ENABLE_OFF_MODE_JTAG_ETM_DEBUG
 +       bool Enable hardware emulation context save and restore
 +       depends on ARCH_OMAP3

-- Shouldn't this be depends on OMAP3_EMU instead ?

 +       default y

-- As this is debug option, can you keep this n by default ?

 +       help
 +         This option enables JTAG  ETM debugging across power states.
 +         With out this option emulation features are reset across OFF
 +         mode state changes.
 +

Hari
--
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 6/7] save and restore etm state across core OFF modes

2010-07-25 Thread Alexander Shishkin
On Sun, Jul 25, 2010 at 12:34:22 -0600, Hari Kanigeri wrote:
  +config ENABLE_OFF_MODE_JTAG_ETM_DEBUG
  +       bool Enable hardware emulation context save and restore
  +       depends on ARCH_OMAP3
 
 -- Shouldn't this be depends on OMAP3_EMU instead ?

Not really. OMAP3_EMU will enable ETM/ETB drivers within omap, but this
particular patch is also needed if you're using an external hardware
debugger to debug code across OFF modes.

  +       default y
 
 -- As this is debug option, can you keep this n by default ?

This option allows for enabling certain debugging functionality in runtime
(via a sysfs file), which is turned off by default. It is debatable whether
this option should default to 'y' or 'n', seeing as it doesn't add much
overhead to the normal usecase.

  +       help
  +         This option enables JTAG  ETM debugging across power states.
  +         With out this option emulation features are reset across OFF
  +         mode state changes.

But I see that the wording is misleading and unclear, so I'll try to come
up with something more descriptive.

Regards,
--
Alex
--
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 1/1] DSPBRIDGE: cache operation against kernel address instead of user's

2010-07-25 Thread Felipe Contreras
Hi,

While investigating a bug in maemo[1] I found that this patch triggers
it, I think I found the reason.

It probably doesn't matter for upstream anymore.

On Fri, Nov 6, 2009 at 3:34 PM, Hiroshi DOYU hiroshi.d...@nokia.com wrote:
 @@ -690,14 +732,19 @@ static int memory_check_vma(unsigned long start, u32 
 len)
        if (end = start)
                return -EINVAL;

 -       down_read(current-mm-mmap_sem);
 -
        while ((vma = find_vma(current-mm, start)) != NULL) {
 +               ssize_t size;

 -               if (vma-vm_start  start) {
 -                       err = -EINVAL;
 +               if (vma-vm_flags  (VM_IO | VM_PFNMAP))
 +                       return -EINVAL;
 +
 +               if (vma-vm_start  start)
 +                       return -EINVAL;
 +
 +               size = min_t(ssize_t, vma-vm_end - start, len);

This 'len' is the total length, which is not what we want; in each
iteration the length should be decreased so that it's always the
remaining length. Right?

len -= size;

 +               err = memory_sync_page(vma, start, size, ftype);
 +               if (err)
                        break;
 -               }

                if (end = vma-vm_end)
                        break;

[1] https://bugs.maemo.org/show_bug.cgi?id=10813

-- 
Felipe Contreras


Re: [PATCH v3 3/7] DSPBRIDGE: do not call follow_page

2010-07-25 Thread Felipe Contreras
Hi,

Just for the record, I found a problem in this patch. The next patch
in the series overrides it, so it's not that important, unless
somebody picks only this patch.

On Thu, May 27, 2010 at 7:02 PM, Ohad Ben-Cohen o...@wizery.com wrote:
 @@ -537,23 +606,30 @@ dsp_status proc_enum_nodes(void *hprocessor, void 
 **node_tab,
  }

  /* Cache operation against kernel address instead of users */
 -static int memory_sync_page(struct vm_area_struct *vma, unsigned long start,
 -                           ssize_t len, enum dsp_flushtype ftype)
 +static int memory_sync_page(struct dmm_map_object *map_obj,
 +               unsigned long start, ssize_t len, enum dsp_flushtype ftype)
  {
        struct page *page;
        void *kaddr;

[...]

 -       if (memory_sync_vma((u32) pmpu_addr, ul_size, FlushMemType)) {
 +       /* find requested memory are in cached mapping information */
 +       map_obj = find_containing_mapping(pr_ctxt, (u32) pmpu_addr, ul_size);
 +       if (!map_obj) {
 +               pr_err(%s: find_containing_mapping failed\n, __func__);
 +               status = -EFAULT;
 +               goto err_out;
 +       }
 +       if (memory_sync_page(map_obj, (u32) pmpu_addr, ul_size, ul_flags)) {

It should be FlushMemType, not ul_flags.

                pr_err(%s: InValid address parameters %p %x\n,
 -                      __func__, pmpu_addr, ul_size);
 +                              __func__, pmpu_addr, ul_size);
                status = -EFAULT;
        }

-- 
Felipe Contreras
--
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] omap3: make coresight register save across OFF modes a sysfs option

2010-07-25 Thread Alexander Shishkin
This adds a sysfs file at /sys/power/coresight_save which is used to
control if the ETM and debug components' states should be saved and
restored across OFF modes.

Signed-off-by: Alexander Shishkin virtu...@slind.org
Cc: Tony Lindgren t...@atomide.com
Cc: Russell King li...@arm.linux.org.uk
Cc: Paul Walmsley p...@pwsan.com
Cc: Kevin Hilman khil...@deeprootsystems.com
Cc: linux-omap@vger.kernel.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-ker...@vger.kernel.org
---
 arch/arm/mach-omap2/Makefile|1 +
 arch/arm/mach-omap2/debug34xx.c |   66 +++
 arch/arm/mach-omap2/pm.h|6 +++
 arch/arm/mach-omap2/pm34xx.c|3 ++
 4 files changed, 76 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-omap2/debug34xx.c

diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index f5b4ff4..3a64ce4 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -49,6 +49,7 @@ ifeq ($(CONFIG_PM),y)
 obj-$(CONFIG_ARCH_OMAP2)   += pm24xx.o
 obj-$(CONFIG_ARCH_OMAP2)   += sleep24xx.o
 obj-$(CONFIG_ARCH_OMAP3)   += pm34xx.o sleep34xx.o cpuidle34xx.o
+obj-$(CONFIG_ENABLE_OFF_MODE_JTAG_ETM_DEBUG) += debug34xx.o
 obj-$(CONFIG_PM_DEBUG) += pm-debug.o
 
 AFLAGS_sleep24xx.o :=-Wa,-march=armv6
diff --git a/arch/arm/mach-omap2/debug34xx.c b/arch/arm/mach-omap2/debug34xx.c
new file mode 100644
index 000..698e83a
--- /dev/null
+++ b/arch/arm/mach-omap2/debug34xx.c
@@ -0,0 +1,66 @@
+/*
+ * Control saving and restoring of coresight components' state during
+ * OFF mode.
+ *
+ * Copyright (C) 2010 Nokia Corporation
+ * Alexander Shishkin
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/kernel.h
+#include linux/sysfs.h
+#include linux/kobject.h
+
+#include pm.h
+
+/*
+ * Pointer to a place in sram where the ETM/debug state save
+ * flag is. It can be calculated after the omap_sram_idle is
+ * pushed to sram.
+ */
+static unsigned int *_etm_save;
+
+/*
+ * sysfs file /sys/power/coresight_save controls whether the
+ * state of coresight components should be saved and restored
+ * across OFF modes.
+ */
+static ssize_t coresight_save_show(struct kobject *kobj,
+ struct kobj_attribute *attr,
+ char *buf)
+{
+   return sprintf(buf, %u\n, *_etm_save);
+}
+
+static ssize_t coresight_save_store(struct kobject *kobj,
+  struct kobj_attribute *attr,
+  const char *buf, size_t n)
+{
+   unsigned int value;
+
+   if (sscanf(buf, %u, value) != 1)
+   return -EINVAL;
+
+   *_etm_save = !!value;
+
+   return n;
+}
+
+static struct kobj_attribute coresight_save_attr =
+   __ATTR(coresight_save, 0644, coresight_save_show, coresight_save_store);
+
+int omap3_coresight_pm_init(void *sram_addr)
+{
+   int ret;
+
+   /* the last word from the top of omap_sram_idle */
+   _etm_save = (unsigned *)((u8 *)sram_addr + omap34xx_cpu_suspend_sz - 4);
+
+   ret = sysfs_create_file(power_kobj, coresight_save_attr.attr);
+
+   return ret;
+}
+
diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
index 3de6ece..0321834 100644
--- a/arch/arm/mach-omap2/pm.h
+++ b/arch/arm/mach-omap2/pm.h
@@ -76,6 +76,12 @@ extern void omap34xx_cpu_suspend(u32 *addr, int save_state);
 extern void save_secure_ram_context(u32 *addr);
 extern void omap3_save_scratchpad_contents(void);
 
+#ifdef CONFIG_ENABLE_OFF_MODE_JTAG_ETM_DEBUG
+int omap3_coresight_pm_init(void *sram_addr);
+#else
+#define omap3_coresight_pm_init(x) do {} while (0)
+#endif
+
 extern unsigned int omap24xx_idle_loop_suspend_sz;
 extern unsigned int omap34xx_suspend_sz;
 extern unsigned int save_secure_ram_context_sz;
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index fb4994a..c389e65 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -1096,6 +1096,9 @@ static int __init omap3_pm_init(void)
core_clkdm = clkdm_lookup(core_clkdm);
 
omap_push_sram_idle();
+
+   omap3_coresight_pm_init(_omap_sram_idle);
+
 #ifdef CONFIG_SUSPEND
suspend_set_ops(omap_pm_ops);
 #endif /* CONFIG_SUSPEND */
-- 
1.7.1

--
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] omap3: make coresight register save across OFF modes a sysfs option

2010-07-25 Thread Alexander Shishkin
On Mon, Jul 26, 2010 at 12:04:23 +0300, Alexander Shishkin wrote:
 This adds a sysfs file at /sys/power/coresight_save which is used to
 control if the ETM and debug components' states should be saved and
 restored across OFF modes.

Oops, I wanted to resend the previous patch, but it's getting late here.
Sorry for the spam.

Regards,
--
Alex
--
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] save and restore etm state across core OFF modes

2010-07-25 Thread Alexander Shishkin
This prevents ETM stalls whenever core enters OFF mode. Original patch
author is Richard Woodruff r-woodru...@ti.com.

This version of the patch makes use of the ETM OS save/restore mechanism,
which takes about 55 words in omap3_arm_context[] instead of 128. Also,
saving ETM context can be switched on/off at runtime.

Signed-off-by: Alexander Shishkin virtu...@slind.org
Cc: Richard Woodruff r-woodru...@ti.com
Cc: Tony Lindgren t...@atomide.com
Cc: Russell King li...@arm.linux.org.uk
Cc: Paul Walmsley p...@pwsan.com
Cc: Kevin Hilman khil...@deeprootsystems.com
Cc: linux-omap@vger.kernel.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-ker...@vger.kernel.org
---
 arch/arm/mach-omap2/Kconfig   |   12 +++
 arch/arm/mach-omap2/control.c |2 +-
 arch/arm/mach-omap2/sleep34xx.S   |  135 +
 arch/arm/plat-omap/include/plat/control.h |2 +-
 4 files changed, 149 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig
index b48bacf..b00d719 100644
--- a/arch/arm/mach-omap2/Kconfig
+++ b/arch/arm/mach-omap2/Kconfig
@@ -243,6 +243,18 @@ config MACH_OMAP4_PANDA
default y
depends on ARCH_OMAP4
 
+config ENABLE_OFF_MODE_JTAG_ETM_DEBUG
+   bool Enable hardware emulation context save and restore
+   depends on ARCH_OMAP3
+   default y
+   help
+ This option enables the code that controls the capability to
+ save and restore JTAG  ETM debugging across power states. It
+ may be required when using the ETM/ETB tracing driver or an
+ external debugging hardware.
+ Without this option emulation features' states are reset across
+ OFF mode state changes.
+
 config OMAP3_EMU
bool OMAP3 debugging peripherals
depends on ARCH_OMAP3
diff --git a/arch/arm/mach-omap2/control.c b/arch/arm/mach-omap2/control.c
index a8d20ee..22dd240 100644
--- a/arch/arm/mach-omap2/control.c
+++ b/arch/arm/mach-omap2/control.c
@@ -93,7 +93,7 @@ void *omap3_secure_ram_storage;
  * The address is stored in scratchpad, so that it can be used
  * during the restore path.
  */
-u32 omap3_arm_context[128];
+u32 omap3_arm_context[256];
 
 struct omap3_control_regs {
u32 sysconfig;
diff --git a/arch/arm/mach-omap2/sleep34xx.S b/arch/arm/mach-omap2/sleep34xx.S
index d522cd7..cd6a1d4 100644
--- a/arch/arm/mach-omap2/sleep34xx.S
+++ b/arch/arm/mach-omap2/sleep34xx.S
@@ -28,6 +28,7 @@
 #include asm/assembler.h
 #include mach/io.h
 #include plat/control.h
+#include asm/hardware/coresight.h
 
 #include cm.h
 #include prm.h
@@ -226,6 +227,18 @@ loop:
nop
bl wait_sdrc_ok
 
+#ifdef CONFIG_ENABLE_OFF_MODE_JTAG_ETM_DEBUG
+   /*
+* Restore Coresight debug registers
+*/
+   ldr r6, debug_vbase /* base Vaddr of CortexA8-Debug */
+   ldr r4, debug_xlar_key  /* get lock key for OSLAR */
+   bl  unlock_debug/* remove global lock if set */
+   ldr r6, etm_vbase   /* base Vaddr of ETM */
+   bl  unlock_debug/* remove global lock if set */
+   str r6, [r6, #ETMMR_OSLAR]  /* clear OSLAR lock using non-key */
+#endif
+
ldmfd   sp!, {r0-r12, pc}   @ restore regs and return
 restore_es3:
/*b restore_es3*/   @ Enable to debug restore code
@@ -385,6 +398,44 @@ logic_l1_restore:
/*normal memory remap register */
MCR p15, 0, r5, c10, c2, 1
 
+#ifdef CONFIG_ENABLE_OFF_MODE_JTAG_ETM_DEBUG
+   /*
+* Restore Coresight debug registers
+*/
+   ldr r6, debug_pbase /* base paddr of CortexA8-Debug */
+   ldr r4, debug_xlar_key  /* get lock key for OSLAR */
+   bl  unlock_debug/* remove global lock if set */
+   str r4, [r6, #ETMMR_OSLAR]  /* reset-pointer (already locked) */
+   ldr r4, [r6, #ETMMR_OSSRR]  /* dummy read */
+   ldr r4, [r3], #4/* load save size */
+   cmp r4, #0  /* check for zero */
+debug_restore:
+   itttne  /* t2/compat if-then block */
+   ldrne   r5, [r3], #4/* get saved value */
+   strne   r5, [r6,#ETMMR_OSSRR]   /* restore saved value */
+   subnes  r4, r4, #1  /* decrement loop */
+   bne debug_restore   /* loop till done */
+   str r5, [r6, #ETMMR_OSSRR]  /* clear lock */
+   /*
+* Restore CoreSight ETM registers
+*/
+   ldr r6, etm_pbase   /* base paddr of ETM */
+   ldr r4, debug_xlar_key  /* get lock key for OSLAR */
+   bl  unlock_debug/* remove global lock if set */
+   str r4, [r6, #ETMMR_OSLAR]  /* reset-pointer (already locked) */
+   ldr r4, [r6, #ETMMR_OSSRR]  /* dummy read */
+   ldr r4, [r3], #4/* load save size */
+   cmp r4, #0