Skip to contentSkip to conversation

West Bridge Astoria Driver 2.6.35, Kconfig fixes

PATCH In review David Cross 2 participants 12 messages Sep 2, 2010 – Sep 9, 2010 1 message not in the archive

Subsystems (7)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 West Bridge Astoria Driver 2.6.35, Kconfig fixes

Quoted 26 lines

From: Greg KH [mailto:[email protected]]
Sent: Tuesday, August 31, 2010 9:32 AM
To: David Cross
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] West Bridge Astoria Driver 2.6.35

Quoted 12 lines · David Cross
Quoted 3 lines

I get a build error when I try to build this driver:

drivers/staging/westbridge/astoria/block/../include/linux/westbridge/c> yasmisc.h:521:2: error: expected declaration specifiers or '...' before > 'cy_as_hal_device_tag'

Quoted 4 lines

It looks like the #include mess isn't working quite properly.

Also note that this driver is building on an x86-64 platform, which is something that you probably don't want :)

Quoted 6 lines
Quoted 3 lines

So, for now, I'll just mark the driver as CONFIG_BROKEN and can you send me some Kconfig patches against the next linux-next release which should have this driver in it, so that it will build properly?

Sure, I can do that. I have since changed the Kconfig structure a bit. It actually will build properly with the correct .config as it is though. I

Quoted 8 lines

can

Quoted 1 line

send you the .config if you would like.

It's up to the Kconfig rules to ensure that there can never be a "non-correct" .config file, so that needs to be fixed so that the build will never be broken no matter what type of options are selected.

Care to send a patch for that?

This patch actually contains quite a few fixes, but it addresses the Kconfig issue as well. The linux-next tree does not seem to have a config for the zoom2, and trying to build it for that board seems to make the compilation break. As such, the only thing that I tested was compilation using the two different HALs (one of which is added in this patch). Please let me know if there are problems or questions with this. Thanks,
David

arch/arm/mach-omap2/gpmc.c +3 -0
diff -uprN -X linux-next-vanilla/Documentation/dontdiff linux-next-vanilla/arch/arm/mach-omap2/gpmc.c linux-next-incl-sdk/arch/arm/mach-omap2/gpmc.c
@@ -133,6 +133,7 @@ void gpmc_cs_write_reg(int cs, int idx, 
 	reg_addr = gpmc_base + GPMC_CS0_OFFSET + (cs * GPMC_CS_SIZE) + idx;
 	__raw_writel(val, reg_addr);
 }
+EXPORT_SYMBOL(gpmc_cs_write_reg);
 
 u32 gpmc_cs_read_reg(int cs, int idx)
 {
@@ -141,6 +142,7 @@ u32 gpmc_cs_read_reg(int cs, int idx)
 	reg_addr = gpmc_base + GPMC_CS0_OFFSET + (cs * GPMC_CS_SIZE) + idx;
 	return __raw_readl(reg_addr);
 }
+EXPORT_SYMBOL(gpmc_cs_read_reg);
 
 /* TODO: Add support for gpmc_fck to clock framework and use it */
 unsigned long gpmc_get_fclk_period(void)
@@ -294,6 +296,7 @@ int gpmc_cs_set_timings(int cs, const st
 
 	return 0;
 }
+EXPORT_SYMBOL(gpmc_cs_set_timings);
 
 static void gpmc_cs_enable_mem(int cs, u32 base, u32 size)
 {
drivers/staging/westbridge/astoria/arch/arm/mach-omap2/cyashalomap_cram.c +1851 -0

1,851 lines not on this page · raw message

drivers/staging/westbridge/astoria/arch/arm/mach-omap2/cyashalomap_kernel.c +0 -2450

1,128 lines not on this page · raw message

drivers/staging/westbridge/astoria/arch/arm/mach-omap2/cyashalomap_pnand.c +2462 -0

2,462 lines not on this page · raw message

drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-cram-hal/cyashalomap_cram.h +319 -0

319 lines not on this page · raw message

drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-cram-hal/cyasmemmap.h +565 -0

565 lines not on this page · raw message

drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-cram-hal/cyasomapdev_cram.h +73 -0

73 lines not on this page · raw message

drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyashalomap_kernel.h +0 -319

319 lines not on this page · raw message

drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyashalomap_pnand.h +319 -0

319 lines not on this page · raw message

drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyasmemmap.h +6 -3
diff -uprN -X linux-next-vanilla/Documentation/dontdiff linux-next-vanilla/drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyasmemmap.h linux-next-incl-sdk/drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyasmemmap.h

Lines of this file are not shown. View the raw message.

drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyasomapdev_kernel.h +0 -72

72 lines not on this page · raw message

drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyasomapdev_pnand.h +72 -0

72 lines not on this page · raw message

drivers/staging/westbridge/astoria/block/cyasblkdev_block.c +45 -39

84 lines not on this page · raw message

drivers/staging/westbridge/astoria/block/cyasblkdev_queue.c +6 -6
diff -uprN -X linux-next-vanilla/Documentation/dontdiff linux-next-vanilla/drivers/staging/westbridge/astoria/block/cyasblkdev_queue.c linux-next-incl-sdk/drivers/staging/westbridge/astoria/block/cyasblkdev_queue.c

Lines of this file are not shown. View the raw message.

drivers/staging/westbridge/astoria/block/cyasblkdev_queue.h +2 -0
diff -uprN -X linux-next-vanilla/Documentation/dontdiff linux-next-vanilla/drivers/staging/westbridge/astoria/block/cyasblkdev_queue.h linux-next-incl-sdk/drivers/staging/westbridge/astoria/block/cyasblkdev_queue.h

Lines of this file are not shown. View the raw message.

drivers/staging/westbridge/astoria/device/cyasdevice.c +53 -5

58 lines not on this page · raw message

drivers/staging/westbridge/astoria/device/Makefile +9 -1
diff -uprN -X linux-next-vanilla/Documentation/dontdiff linux-next-vanilla/drivers/staging/westbridge/astoria/device/Makefile linux-next-incl-sdk/drivers/staging/westbridge/astoria/device/Makefile

Lines of this file are not shown. View the raw message.

drivers/staging/westbridge/astoria/gadget/cyasgadget.c +33 -68

101 lines not on this page · raw message

drivers/staging/westbridge/astoria/gadget/cyasgadget.h +3 -1
diff -uprN -X linux-next-vanilla/Documentation/dontdiff linux-next-vanilla/drivers/staging/westbridge/astoria/gadget/cyasgadget.h linux-next-incl-sdk/drivers/staging/westbridge/astoria/gadget/cyasgadget.h

Lines of this file are not shown. View the raw message.

drivers/staging/westbridge/astoria/include/linux/westbridge/cyashal.h +19 -2
diff -uprN -X linux-next-vanilla/Documentation/dontdiff linux-next-vanilla/drivers/staging/westbridge/astoria/include/linux/westbridge/cyashal.h linux-next-incl-sdk/drivers/staging/westbridge/astoria/include/linux/westbridge/cyashal.h

Lines of this file are not shown. View the raw message.

drivers/staging/westbridge/Kconfig +37 -5

42 lines not on this page · raw message

fs/mpage.c +46 -0

46 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

---------------------------------------------------------------
This message and any attachments may contain Cypress (or its subsidiaries) confidential information. If it has been received in error, please advise the sender and immediately delete this message.
---------------------------------------------------------------

Part of the diff is not shown here. View the raw message.

#2 lore raw
Quoted 35 lines · David Cross
Quoted 26 lines

From: Greg KH [mailto:[email protected]]
Sent: Tuesday, August 31, 2010 9:32 AM
To: David Cross
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] West Bridge Astoria Driver 2.6.35

Quoted 12 lines · David Cross
Quoted 3 lines

I get a build error when I try to build this driver:

drivers/staging/westbridge/astoria/block/../include/linux/westbridge/c> yasmisc.h:521:2: error: expected declaration specifiers or '...' before > 'cy_as_hal_device_tag'

Quoted 4 lines

It looks like the #include mess isn't working quite properly.

Also note that this driver is building on an x86-64 platform, which is something that you probably don't want :)

Quoted 6 lines
Quoted 3 lines

So, for now, I'll just mark the driver as CONFIG_BROKEN and can you send me some Kconfig patches against the next linux-next release which should have this driver in it, so that it will build properly?

Sure, I can do that. I have since changed the Kconfig structure a bit. It actually will build properly with the correct .config as it is though. I

Quoted 8 lines

can

Quoted 1 line

send you the .config if you would like.

It's up to the Kconfig rules to ensure that there can never be a "non-correct" .config file, so that needs to be fixed so that the build will never be broken no matter what type of options are selected.

Care to send a patch for that?

Quoted 8 lines

This patch actually contains quite a few fixes, but it addresses the Kconfig issue as well. The linux-next tree does not seem to have a config for the zoom2, and trying to build it for that board seems to make the compilation break. As such, the only thing that I tested was compilation using the two different HALs (one of which is added in this patch). Please let me know if there are problems or questions with this. Thanks,
David

Hm, I need a single-patch-per-change, as described in the Documentation/SubmittingPatches file. So, could you break this up into the logical changes, so that I can apply them all? That makes it easier for everyone involved (reviewing, bisecting, etc.) and it's what is needed for the rest of the kernel as well.

thanks,

greg k-h

#3 lore raw

Re: [PATCH] West Bridge Astoria Driver 2.6.35, Kconfig and HAL fixes

In reply to David Cross

On Wed, 2010-09-01 at 17:08 -0700, David Cross wrote:
From: Greg KH [mailto:[email protected]]

Quoted 24 lines

Sent: Tuesday, August 31, 2010 9:32 AM
To: David Cross
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] West Bridge Astoria Driver 2.6.35

Quoted 12 lines · David Cross
Quoted 3 lines

I get a build error when I try to build this driver:

drivers/staging/westbridge/astoria/block/../include/linux/westbridge/c> yasmisc.h:521:2: error: expected declaration specifiers or '...' before > 'cy_as_hal_device_tag'

Quoted 4 lines

It looks like the #include mess isn't working quite properly.

Also note that this driver is building on an x86-64 platform, which is something that you probably don't want :)

Quoted 6 lines
Quoted 3 lines

So, for now, I'll just mark the driver as CONFIG_BROKEN and can you send me some Kconfig patches against the next linux-next release which should have this driver in it, so that it will build properly?

Sure, I can do that. I have since changed the Kconfig structure a bit. It actually will build properly with the correct .config as it is though. I

Quoted 8 lines

can

Quoted 1 line

send you the .config if you would like.

It's up to the Kconfig rules to ensure that there can never be a "non-correct" .config file, so that needs to be fixed so that the build will never be broken no matter what type of options are selected.

Care to send a patch for that?

This patch actually contains the KConfig changes necessary an additional HAL layer. The Kconfig changes are pretty closely related to this HAL layer, as such this patch is difficult to logically separate. The HAL layers also rely on the export of some gpmc functions, which are added to this patch. Although I don't own this driver, it is difficult for me to understand why there would be issues with exporting these symbols. The linux-next tree does not seem to have a config for the zoom2, and trying to build it for that board seems to make the compilation break. As such, the only thing that I tested was compilation using the two different HALs (one of which is added in this patch). Please let me know if there are problems or questions with this.
Thanks,
David

arch/arm/mach-omap2/gpmc.c +3 -0
diff -uprN -X linux-next-vanilla/Documentation/dontdiff linux-next-vanilla/arch/arm/mach-omap2/gpmc.c linux-next-incl-sdk/arch/arm/mach-omap2/gpmc.c
@@ -133,6 +133,7 @@ void gpmc_cs_write_reg(int cs, int idx, 
 	reg_addr = gpmc_base + GPMC_CS0_OFFSET + (cs * GPMC_CS_SIZE) + idx;
 	__raw_writel(val, reg_addr);
 }
+EXPORT_SYMBOL(gpmc_cs_write_reg);
 
 u32 gpmc_cs_read_reg(int cs, int idx)
 {
@@ -141,6 +142,7 @@ u32 gpmc_cs_read_reg(int cs, int idx)
 	reg_addr = gpmc_base + GPMC_CS0_OFFSET + (cs * GPMC_CS_SIZE) + idx;
 	return __raw_readl(reg_addr);
 }
+EXPORT_SYMBOL(gpmc_cs_read_reg);
 
 /* TODO: Add support for gpmc_fck to clock framework and use it */
 unsigned long gpmc_get_fclk_period(void)
@@ -294,6 +296,7 @@ int gpmc_cs_set_timings(int cs, const st
 
 	return 0;
 }
+EXPORT_SYMBOL(gpmc_cs_set_timings);
 
 static void gpmc_cs_enable_mem(int cs, u32 base, u32 size)
 {
drivers/staging/westbridge/astoria/arch/arm/mach-omap2/cyashalomap_cram.c +1851 -0

1,851 lines not on this page · raw message

drivers/staging/westbridge/astoria/arch/arm/mach-omap2/cyashalomap_kernel.c +0 -2450

1,128 lines not on this page · raw message

drivers/staging/westbridge/astoria/arch/arm/mach-omap2/cyashalomap_pnand.c +2462 -0

2,462 lines not on this page · raw message

drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-cram-hal/cyashalomap_cram.h +319 -0

319 lines not on this page · raw message

drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-cram-hal/cyasmemmap.h +565 -0

565 lines not on this page · raw message

drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-cram-hal/cyasomapdev_cram.h +73 -0

73 lines not on this page · raw message

drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyashalomap_kernel.h +0 -319

319 lines not on this page · raw message

drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyashalomap_pnand.h +319 -0

319 lines not on this page · raw message

drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyasmemmap.h +6 -3
diff -uprN -X linux-next-vanilla/Documentation/dontdiff linux-next-vanilla/drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyasmemmap.h linux-next-incl-sdk/drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyasmemmap.h

Lines of this file are not shown. View the raw message.

drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyasomapdev_kernel.h +0 -72

72 lines not on this page · raw message

drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyasomapdev_pnand.h +72 -0

72 lines not on this page · raw message

drivers/staging/westbridge/astoria/device/Makefile +9 -1
diff -uprN -X linux-next-vanilla/Documentation/dontdiff linux-next-vanilla/drivers/staging/westbridge/astoria/device/Makefile linux-next-incl-sdk/drivers/staging/westbridge/astoria/device/Makefile

Lines of this file are not shown. View the raw message.

drivers/staging/westbridge/astoria/include/linux/westbridge/cyashal.h +19 -2
diff -uprN -X linux-next-vanilla/Documentation/dontdiff linux-next-vanilla/drivers/staging/westbridge/astoria/include/linux/westbridge/cyashal.h linux-next-incl-sdk/drivers/staging/westbridge/astoria/include/linux/westbridge/cyashal.h

Lines of this file are not shown. View the raw message.

drivers/staging/westbridge/Kconfig +37 -5

42 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

---------------------------------------------------------------
This message and any attachments may contain Cypress (or its subsidiaries) confidential information. If it has been received in error, please advise the sender and immediately delete this message.
---------------------------------------------------------------

Part of the diff is not shown here. View the raw message.

#4 lore raw

Re: [PATCH] West Bridge Astoria Driver 2.6.35, Kconfig and HAL fixes

Quoted 29 lines · David Cross

On Wed, 2010-09-01 at 17:08 -0700, David Cross wrote:
From: Greg KH [mailto:[email protected]]

Quoted 27 lines

Sent: Tuesday, August 31, 2010 9:32 AM
To: David Cross
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] West Bridge Astoria Driver 2.6.35

Quoted 12 lines · David Cross
Quoted 3 lines

I get a build error when I try to build this driver:

drivers/staging/westbridge/astoria/block/../include/linux/westbridge/c> yasmisc.h:521:2: error: expected declaration specifiers or '...' before > 'cy_as_hal_device_tag'

Quoted 4 lines

It looks like the #include mess isn't working quite properly.

Also note that this driver is building on an x86-64 platform, which is something that you probably don't want :)

Quoted 6 lines
Quoted 3 lines

So, for now, I'll just mark the driver as CONFIG_BROKEN and can you send me some Kconfig patches against the next linux-next release which should have this driver in it, so that it will build properly?

Sure, I can do that. I have since changed the Kconfig structure a bit. It actually will build properly with the correct .config as it is though. I

can

Quoted 1 line

send you the .config if you would like.

Quoted 8 lines
Quoted 5 lines

It's up to the Kconfig rules to ensure that there can never be a "non-correct" .config file, so that needs to be fixed so that the build will never be broken no matter what type of options are selected.

Care to send a patch for that?

This patch actually contains the KConfig changes necessary an additional HAL layer.

Note, when sending a patch, don't include all of the stuff above, that makes no sense.

Also, your Subject: should be a bit cleaner. For example, I would edit this subject from:

Subject: Re: [PATCH] West Bridge Astoria Driver 2.6.35, Kconfig and HAL fixes

to

Subject: [PATCH] Staging: westbridge: Kconfig and HAL fixes

The kernel version doesn't matter as I can't patch an old kernel, right? :)

Quoted 13 lines

The Kconfig changes are pretty closely related to this HAL layer, as such this patch is difficult to logically separate. The HAL layers also rely on the export of some gpmc functions, which are added to this patch. Although I don't own this driver, it is difficult for me to understand why there would be issues with exporting these symbols. The linux-next tree does not seem to have a config for the zoom2, and trying to build it for that board seems to make the compilation break. As such, the only thing that I tested was compilation using the two different HALs (one of which is added in this patch). Please let me know if there are problems or questions with this.
Thanks,
David

Quoted 1 line

You really need all of this at once to fix the Kconfig issues? It's a huge patch, what happened that made it needed?

Quoted 20 lines

diff -uprN -X linux-next-vanilla/Documentation/dontdiff linux-next-vanilla/arch/arm/mach-omap2/gpmc.c linux-next-incl-sdk/arch/arm/mach-omap2/gpmc.c

arch/arm/mach-omap2/gpmc.c +2 -0
@@ -133,6 +133,7 @@ void gpmc_cs_write_reg(int cs, int idx, 
 	reg_addr = gpmc_base + GPMC_CS0_OFFSET + (cs * GPMC_CS_SIZE) + idx;
 	__raw_writel(val, reg_addr);
 }
+EXPORT_SYMBOL(gpmc_cs_write_reg);
 
 u32 gpmc_cs_read_reg(int cs, int idx)
 {
@@ -141,6 +142,7 @@ u32 gpmc_cs_read_reg(int cs, int idx)
 	reg_addr = gpmc_base + GPMC_CS0_OFFSET + (cs * GPMC_CS_SIZE) + idx;
 	return __raw_readl(reg_addr);
 }
+EXPORT_SYMBOL(gpmc_cs_read_reg);
 
 /* TODO: Add support for gpmc_fck to clock framework and use it */
 unsigned long gpmc_get_fclk_period(void)

arch/arm/mach-omap2/gpmc.c int gpmc_cs_set_timings(int cs, const st · line 302

Quoted 7 lines
arch/arm/mach-omap2/gpmc.c +1 -0
@@ -294,6 +296,7 @@ int gpmc_cs_set_timings(int cs, const st
 
 	return 0;
 }
+EXPORT_SYMBOL(gpmc_cs_set_timings);
 
 static void gpmc_cs_enable_mem(int cs, u32 base, u32 size)
 {

Sorry, I can't change things outside of the drivers/staging/ directory unless you get the maintainer/owner of this file to agree to export these symbols.

Can you do that as a separate patch and get their ack? Then I can apply it.

Also, how about "EXPORT_SYMBOL_GPL()" instead?

So, care to redo this patch?

thanks,

greg k-h

#5 lore raw

Re: [PATCH] west bridge, kconfig and hal fixes

In reply to David Cross

This patch contains the kconfig changes necessary to fix build errors that could come up in the linux-next version. It also includes an additional HAL layer for the west bridge CRAM interface. The inclusion of this interface support did require the reorganization of some of the existing code, which is part of the reason for the size of the patch. Moving files and directories makes this patch seem larger than it really is. The Kconfig changes are closely related to the inclusion of the CRAM HAL layer, and as such this patch is difficult to logically separate. The linux-next tree does not seem to have a config for the zoom2, and trying to build it for that board seems to make the compilation break. As such, the only thing that I tested was compilation using the two different HALs (one of which is added in this patch). Please let me know if there are problems or questions with this.
Thanks,
David

drivers/staging/westbridge/astoria/arch/arm/mach-omap2/cyashalomap_cram.c +1845 -0
diff -uprN -X linux-next-vanilla/Documentation/dontdiff linux-next-vanilla/drivers/staging/westbridge/astoria/arch/arm/mach-omap2/cyashalomap_cram.c linux-next-incl-sdk/drivers/staging/westbridge/astoria/arch/arm/mach-omap2/cyashalomap_cram.c
@@ -0,0 +1,1845 @@
+/* Cypress WestBridge OMAP3430 Kernel Hal source file (cyashalomap_kernel.c)
+## ===========================
+## Copyright (C) 2010  Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street, Fifth Floor,
+## Boston, MA  02110-1301, USA.
+## ===========================
+*/
+
+#ifdef CONFIG_MACH_OMAP3_WESTBRIDGE_AST_CRAM_HAL
+
+#include <linux/fs.h>
+#include <linux/ioport.h>
+#include <linux/timer.h>
+#include <linux/gpio.h>
+#include <linux/interrupt.h>
+#include <linux/delay.h>
+#include <linux/scatterlist.h>
+#include <linux/mm.h>
+#include <linux/irq.h>
+#include <linux/slab.h>
+#include <linux/sched.h>
+/* include seems broken moving for patch submission
+ * #include <mach/mux.h>
+ * #include <mach/gpmc.h>
+ * #include <mach/westbridge/westbridge-omap3-pnand-hal/cyashalomap_cram.h>
+ * #include <mach/westbridge/westbridge-omap3-pnand-hal/cyasomapdev_cram.h>
+ * #include <mach/westbridge/westbridge-omap3-pnand-hal/cyasmemmap.h>
+ * #include <linux/westbridge/cyaserr.h>
+ * #include <linux/westbridge/cyasregs.h>
+ * #include <linux/westbridge/cyasdma.h>
+ * #include <linux/westbridge/cyasintr.h>
+ */
+#include <linux/../../arch/arm/plat-omap/include/plat/mux.h>
+#include <linux/../../arch/arm/plat-omap/include/plat/gpmc.h>
+#include "../plat-omap/include/mach/westbridge/westbridge-omap3-cram-hal/cyashalomap_cram.h"
+#include "../plat-omap/include/mach/westbridge/westbridge-omap3-cram-hal/cyasomapdev_cram.h"
+#include "../plat-omap/include/mach/westbridge/westbridge-omap3-cram-hal/cyasmemmap.h"
+#include "../../../include/linux/westbridge/cyaserr.h"
+#include "../../../include/linux/westbridge/cyasregs.h"
+#include "../../../include/linux/westbridge/cyasdma.h"
+#include "../../../include/linux/westbridge/cyasintr.h"
+
+#define HAL_REV "1.1.0"
+
+
+
+/*
+ * westbrige astoria ISR options to limit number of
+ * back to back DMA transfers per ISR interrupt
+ */
+#define MAX_DRQ_LOOPS_IN_ISR 4
+
+/*
+ * debug prints enabling
+ *#define DBGPRN_ENABLED
+ *#define DBGPRN_DMA_SETUP_RD
+ *#define DBGPRN_DMA_SETUP_WR
+ */
+
+
+/*
+ * For performance reasons, we handle storage endpoint transfers upto 4 KB
+ * within the HAL itself.
+ */
+#define CYASSTORAGE_WRITE_EP_NUM	(4)
+#define CYASSTORAGE_READ_EP_NUM	(8)
+
+/*
+ *  size of DMA packet HAL can accept from Storage API
+ *  HAL will fragment it into smaller chunks that the P port can accept
+ */
+#define CYASSTORAGE_MAX_XFER_SIZE	(2*32768)
+
+/*
+ *  P port MAX DMA packet size according to interface/ep configurartion
+ */
+#define HAL_DMA_PKT_SZ 512
+
+#define is_storage_e_p(ep) (((ep) == 2) || ((ep) == 4) || \
+				((ep) == 6) || ((ep) == 8))
+
+
+/*
+ * keep processing new WB DRQ in ISR untill all handled (performance feature)
+ */
+#define PROCESS_MULTIPLE_DRQ_IN_ISR (1)
+
+
+/*
+ * The type of DMA operation, per endpoint
+ */
+typedef enum cy_as_hal_dma_type {
+	cy_as_hal_read,
+	cy_as_hal_write,
+	cy_as_hal_none
+} cy_as_hal_dma_type ;
+
+
+/*
+ * SG list halpers defined in scaterlist.h
+#define sg_is_chain(sg)		((sg)->page_link & 0x01)
+#define sg_is_last(sg)		((sg)->page_link & 0x02)
+#define sg_chain_ptr(sg)	\
+	((struct scatterlist *) ((sg)->page_link & ~0x03))
+*/
+typedef struct cy_as_hal_endpoint_dma {
+	cy_bool buffer_valid ;
+	uint8_t *data_p ;
+	uint32_t size ;
+	/*
+	 * sg_list_enabled - if true use, r/w DMA transfers use sg list,
+	 *		FALSE use pointer to a buffer
+	 * sg_p - pointer to the owner's sg list, of there is such
+	 *		(like blockdriver)
+	 * dma_xfer_sz - size of the next dma xfer on P port
+	 * seg_xfer_cnt -  counts xfered bytes for in current sg_list
+	 *		memory segment
+	 * req_xfer_cnt - total number of bytes transfered so far in
+	 *		current request
+	 * req_length - total request length
+	 */
+	bool sg_list_enabled;
+	struct scatterlist *sg_p ;
+	uint16_t dma_xfer_sz;
+	uint32_t seg_xfer_cnt;
+	uint16_t req_xfer_cnt;
+	uint16_t req_length;
+	cy_as_hal_dma_type type ;
+	cy_bool pending ;
+} cy_as_hal_endpoint_dma ;
+
+/*
+ * The list of OMAP devices (should be one)
+ */
+static cy_as_omap_dev_kernel *m_omap_list_p;
+
+/*
+ * The callback to call after DMA operations are complete
+ */
+static cy_as_hal_dma_complete_callback callback;
+
+/*
+ * Pending data size for the endpoints
+ */
+static cy_as_hal_endpoint_dma end_points[16] ;
+
+/*
+ * Forward declaration
+ */
+static void cy_handle_d_r_q_interrupt(cy_as_omap_dev_kernel *dev_p);
+
+static uint16_t intr_sequence_num;
+static uint8_t intr__enable;
+spinlock_t int_lock ;
+
+static u32 iomux_vma;
+
+/*
+ * gpmc I/O registers VMA
+ */
+static u32 gpmc_base ;
+
+/*
+ * prints given number of omap registers
+ */
+static void cy_as_hal_print_omap_regs(char *name_prefix,
+				u8 name_base, u32 virt_base, u16 count)
+{
+	u32 reg_val, reg_addr;
+	u16 i;
+	printk(KERN_INFO "\n");
+	for (i = 0; i < count; i++) {
+
+		reg_addr = virt_base + (i*4);
+		/* use virtual addresses here*/
+		reg_val = __raw_readl(reg_addr);
+		printk(KERN_INFO "%s_%d[%8.8x]=%8.8x\n",
+						name_prefix, name_base+i,
+						reg_addr, reg_val);
+	}
+}
+
+/*
+ * setMUX function for a pad + additional pad flags
+ */
+static u16 omap_cfg_reg_L(u32 pad_func_index)
+{
+	static u8 sanity_check = 1;
+
+	u32 reg_vma;
+	u16 cur_val, wr_val, rdback_val;
+
+	/*
+	 * do sanity check on the omap_mux_pin_cfg[] table
+	 */
+	printk(KERN_INFO " OMAP pins user_pad cfg with address");
+	if (sanity_check) {
+		if ((omap_mux_pin_cfg[END_OF_TABLE].name[0] == 'E') &&
+			(omap_mux_pin_cfg[END_OF_TABLE].name[1] == 'N') &&
+			(omap_mux_pin_cfg[END_OF_TABLE].name[2] == 'D')) {
+
+			printk(KERN_INFO
+					"table is good.\n");
+		} else {
+			cy_as_hal_print_message(KERN_WARNING
+					"table is bad, fix it");
+		}
+		/*
+		 * do it only once
+		 */
+		sanity_check = 0;
+	}
+
+	/*
+	 * get virtual address to the PADCNF_REG
+	 */
+	reg_vma = (u32)iomux_vma + omap_mux_pin_cfg[pad_func_index].offset;
+
+	/*
+	 * add additional USER PU/PD/EN flags
+	 */
+	wr_val = omap_mux_pin_cfg[pad_func_index].mux_val;
+	cur_val = IORD16(reg_vma);
+
+	/*
+	 * PADCFG regs 16 bit long, packed into 32 bit regs,
+	 * can also be accessed as u16
+	 */
+	IOWR16(reg_vma, wr_val);
+	rdback_val = IORD16(reg_vma);
+
+	/*
+	 * in case if the caller wants to save the old value
+	 */
+	return wr_val;
+}
+
+uint32_t cy_as_hal_gpmc_init(cy_as_omap_dev_kernel *dev_p)
+{
+	u32 tmp32;
+	int err;
+	struct gpmc_timings	timings;
+	unsigned int cs_mem_base;
+	unsigned int cs_vma_base;
+
+	/*
+	 * get GPMC i/o registers base(already been i/o mapped
+	 * in kernel, no need for separate i/o remap)
+	 */
+	printk(KERN_INFO "%s: mapping phys_to_virt\n", __func__);
+
+	gpmc_base = (u32)ioremap_nocache(OMAP34XX_GPMC_BASE, SZ_16K);
+	printk(KERN_INFO "kernel has gpmc_base=%x , val@ the base=%x",
+		gpmc_base, __raw_readl(gpmc_base)
+	);
+
+	printk(KERN_INFO "%s: calling gpmc_cs_request\n", __func__);
+	/*
+	 * request GPMC CS for ASTORIA request
+	 */
+	if (gpmc_cs_request(AST_GPMC_CS, SZ_16M, (void *)&cs_mem_base) < 0) {
+		cy_as_hal_print_message(KERN_ERR "error failed to request"
+					"ncs4 for ASTORIA\n");
+			return -1;
+	} else {
+		printk(KERN_INFO "got phy_addr:%x for "
+				"GPMC CS%d GPMC_CFGREG7[CS4]\n",
+				 cs_mem_base, AST_GPMC_CS);
+	}
+
+	printk(KERN_INFO "%s: calling request_mem_region\n", __func__);
+	/*
+	 * request VM region for 4K addr space for chip select 4 phy address
+	 * technically we don't need it for NAND devices, but do it anyway
+	 * so that data read/write bus cycle can be triggered by reading
+	 * or writing this mem region
+	 */
+	if (!request_mem_region(cs_mem_base, SZ_16K, "AST_OMAP_HAL")) {
+		err = -EBUSY;
+		cy_as_hal_print_message(KERN_ERR "error MEM region "
+					"request for phy_addr:%x failed\n",
+					cs_mem_base);
+			goto out_free_cs;
+	}
+
+	printk(KERN_INFO "%s: calling ioremap_nocache\n", __func__);
+
+	/* REMAP mem region associated with our CS */
+	cs_vma_base = (u32)ioremap_nocache(cs_mem_base, SZ_16K);
+	if (!cs_vma_base) {
+		err = -ENOMEM;
+		cy_as_hal_print_message(KERN_ERR "error- ioremap()"
+					"for phy_addr:%x failed", cs_mem_base);
+
+		goto out_release_mem_region;
+	}
+	printk(KERN_INFO "ioremap(%x) returned vma=%x\n",
+			cs_mem_base, cs_vma_base);
+
+	dev_p->m_phy_addr_base = (void *) cs_mem_base;
+	dev_p->m_vma_addr_base = (void *) cs_vma_base;
+
+	memset(&timings, 0, sizeof(timings));
+
+	/* cs timing */
+	timings.cs_on = WB_GPMC_CS_t_on;
+	timings.cs_wr_off = WB_GPMC_BUSCYC_t;
+	timings.cs_rd_off = WB_GPMC_BUSCYC_t;
+
+	/* adv timing */
+	timings.adv_on = WB_GPMC_ADV_t_on;
+	timings.adv_rd_off = WB_GPMC_ADV_t_off;
+	timings.adv_wr_off = WB_GPMC_ADV_t_off;
+
+	/* oe timing */
+	timings.oe_on = WB_GPMC_OE_t_on;
+	timings.oe_off = WB_GPMC_OE_t_off;
+	timings.access = WB_GPMC_RD_t_a_c_c;
+	timings.rd_cycle = WB_GPMC_BUSCYC_t;
+
+	/* we timing */
+	timings.we_on = WB_GPMC_WE_t_on;
+	timings.we_off = WB_GPMC_WE_t_off;
+	timings.wr_access = WB_GPMC_WR_t_a_c_c;
+	timings.wr_cycle = WB_GPMC_BUSCYC_t;
+
+	timings.page_burst_access = WB_GPMC_BUSCYC_t;
+	timings.wr_data_mux_bus = WB_GPMC_BUSCYC_t;
+	gpmc_cs_set_timings(AST_GPMC_CS, &timings);
+
+	/*
+	 * by default configure GPMC into 8 bit mode
+	 * (to match astoria default mode)
+	 */
+	gpmc_cs_write_reg(AST_GPMC_CS, GPMC_CS_CONFIG1,
+					(GPMC_CONFIG1_DEVICETYPE(0) |
+					 GPMC_CONFIG1_DEVICESIZE_16
+					));
+
+	/*
+	 * No method currently exists to write this register through GPMC APIs
+	 * need to change WAIT2 polarity
+	 */
+	tmp32 = IORD32(GPMC_VMA(GPMC_CONFIG_REG));
+	tmp32 = tmp32 | NAND_FORCE_POSTED_WRITE_B | 0x40;
+	IOWR32(GPMC_VMA(GPMC_CONFIG_REG), tmp32);
+
+	tmp32 = IORD32(GPMC_VMA(GPMC_CONFIG_REG));
+	cy_as_hal_print_message("GPMC_CONFIG_REG=0x%x\n", tmp32);
+
+	cy_as_hal_print_omap_regs("GPMC_CONFIG", 1,
+			GPMC_VMA(GPMC_CFG_REG(1, AST_GPMC_CS)), 7);
+
+	return 0;
+
+out_release_mem_region:
+	release_mem_region(cs_mem_base, SZ_16K);
+
+out_free_cs:
+	gpmc_cs_free(AST_GPMC_CS);
+
+	return err;
+}
+
+/*
+ * west bridge astoria ISR (Interrupt handler)
+ */
+static irqreturn_t cy_astoria_int_handler(int irq,
+				void *dev_id, struct pt_regs *regs)
+{
+	cy_as_omap_dev_kernel *dev_p;
+	uint16_t		  read_val = 0 ;
+	uint16_t		  mask_val = 0 ;
+
+	/*
+	* debug stuff, counts number of loops per one intr trigger
+	*/
+	uint16_t		  drq_loop_cnt = 0;
+	uint8_t		   irq_pin;
+	/*
+	 * flags to watch
+	 */
+	const uint16_t	sentinel = (CY_AS_MEM_P0_INTR_REG_MCUINT |
+				CY_AS_MEM_P0_INTR_REG_MBINT |
+				CY_AS_MEM_P0_INTR_REG_PMINT |
+				CY_AS_MEM_P0_INTR_REG_PLLLOCKINT);
+
+	/*
+	 * sample IRQ pin level (just for statistics)
+	 */
+	irq_pin = __gpio_get_value(AST_INT);
+
+	/*
+	 * this one just for debugging
+	 */
+	intr_sequence_num++ ;
+
+	/*
+	 * astoria device handle
+	 */
+	dev_p = dev_id;
+
+	/*
+	 * read Astoria intr register
+	 */
+	read_val = cy_as_hal_read_register((cy_as_hal_device_tag)dev_p,
+						CY_AS_MEM_P0_INTR_REG) ;
+
+	/*
+	 * save current mask value
+	 */
+	mask_val = cy_as_hal_read_register((cy_as_hal_device_tag)dev_p,
+						CY_AS_MEM_P0_INT_MASK_REG) ;
+
+	DBGPRN("<1>HAL__intr__enter:_seq:%d, P0_INTR_REG:%x\n",
+			intr_sequence_num, read_val);
+
+	/*
+	 * Disable WB interrupt signal generation while we are in ISR
+	 */
+	cy_as_hal_write_register((cy_as_hal_device_tag)dev_p,
+					CY_AS_MEM_P0_INT_MASK_REG, 0x0000) ;
+
+	/*
+	* this is a DRQ Interrupt
+	*/
+	if (read_val & CY_AS_MEM_P0_INTR_REG_DRQINT) {
+
+		do {
+			/*
+			 * handle DRQ interrupt
+			 */
+			drq_loop_cnt++;
+
+			cy_handle_d_r_q_interrupt(dev_p) ;
+
+			/*
+			 * spending to much time in ISR may impact
+			 * average system performance
+			 */
+			if (drq_loop_cnt >= MAX_DRQ_LOOPS_IN_ISR)
+				break;
+
+		/*
+		 * Keep processing if there is another DRQ int flag
+		 */
+		} while (cy_as_hal_read_register((cy_as_hal_device_tag)dev_p,
+					CY_AS_MEM_P0_INTR_REG) &
+					CY_AS_MEM_P0_INTR_REG_DRQINT);
+	}
+
+	if (read_val & sentinel)
+		cy_as_intr_service_interrupt((cy_as_hal_device_tag)dev_p) ;
+
+	DBGPRN("<1>_hal:_intr__exit seq:%d, mask=%4.4x,"
+			"int_pin:%d DRQ_jobs:%d\n",
+			intr_sequence_num,
+			mask_val,
+			irq_pin,
+			drq_loop_cnt);
+
+	/*
+	 * re-enable WB hw interrupts
+	 */
+	cy_as_hal_write_register((cy_as_hal_device_tag)dev_p,
+					CY_AS_MEM_P0_INT_MASK_REG, mask_val) ;
+
+	return IRQ_HANDLED ;
+}
+
+static int cy_as_hal_configure_interrupts(void *dev_p)
+{
+	int result;
+	int irq_pin  = AST_INT;
+
+	set_irq_type(OMAP_GPIO_IRQ(irq_pin), IRQ_TYPE_LEVEL_LOW);
+
+	/*
+	 * for shared IRQS must provide non NULL device ptr
+	 * othervise the int won't register
+	 * */
+	result = request_irq(OMAP_GPIO_IRQ(irq_pin),
+					(irq_handler_t)cy_astoria_int_handler,
+					IRQF_SHARED, "AST_INT#", dev_p);
+
+	if (result == 0) {
+		/*
+		 * OMAP_GPIO_IRQ(irq_pin) - omap logical IRQ number
+		 *		assigned to this interrupt
+		 * OMAP_GPIO_BIT(AST_INT, GPIO_IRQENABLE1) - print status
+		 *		of AST_INT GPIO IRQ_ENABLE FLAG
+		 */
+		printk(KERN_INFO "AST_INT omap_pin:"
+				"%d assigned IRQ #%d IRQEN1=%d\n",
+				irq_pin,
+				OMAP_GPIO_IRQ(irq_pin),
+				OMAP_GPIO_BIT(AST_INT, GPIO_IRQENABLE1)
+				);
+	} else {
+		cy_as_hal_print_message("cyasomaphal: interrupt "
+				"failed to register\n");
+		gpio_free(irq_pin);
+		cy_as_hal_print_message(KERN_WARNING
+				"ASTORIA: can't get assigned IRQ"
+				"%i for INT#\n", OMAP_GPIO_IRQ(irq_pin));
+	}
+
+	return result;
+}
+
+/*
+ * initialize OMAP pads/pins to user defined functions
+ */
+static void cy_as_hal_init_user_pads(user_pad_cfg_t *pad_cfg_tab)
+{
+	/*
+	 * browse through the table an dinitiaze the pins
+	 */
+	u32 in_level = 0;
+	u16 tmp16, mux_val;
+
+	while (pad_cfg_tab->name != NULL) {
+
+		if (gpio_request(pad_cfg_tab->pin_num, NULL) == 0) {
+
+			pad_cfg_tab->valid = 1;
+			mux_val = omap_cfg_reg_L(pad_cfg_tab->mux_func);
+
+			/*
+			 * always set drv level before changing out direction
+			 */
+			__gpio_set_value(pad_cfg_tab->pin_num,
+							pad_cfg_tab->drv);
+
+			/*
+			 * "0" - OUT, "1", input omap_set_gpio_direction
+			 * (pad_cfg_tab->pin_num, pad_cfg_tab->dir);
+			 */
+			if (pad_cfg_tab->dir)
+				gpio_direction_input(pad_cfg_tab->pin_num);
+			else
+				gpio_direction_output(pad_cfg_tab->pin_num,
+							pad_cfg_tab->drv);
+
+			/*  sample the pin  */
+			in_level = __gpio_get_value(pad_cfg_tab->pin_num);
+
+			printk(KERN_INFO "configured %s to "
+					"OMAP pad_%d, DIR=%d "
+					"DOUT=%d, DIN=%d\n",
+					pad_cfg_tab->name,
+					pad_cfg_tab->pin_num,
+					pad_cfg_tab->dir,
+					pad_cfg_tab->drv,
+					in_level
+			);
+		} else {
+			/*
+			 * get the pad_mux value to check on the pin_function
+			 */
+			printk(KERN_INFO "couldn't cfg pin %d"
+					"for signal %s, its already taken\n",
+					pad_cfg_tab->pin_num,
+					pad_cfg_tab->name);
+		}
+
+		tmp16 = *(u16 *)PADCFG_VMA
+			(omap_mux_pin_cfg[pad_cfg_tab->mux_func].offset);
+
+		printk(KERN_INFO "GPIO_%d(PAD_CFG=%x,OE=%d"
+			"DOUT=%d, DIN=%d IRQEN=%d)\n\n",
+			pad_cfg_tab->pin_num, tmp16,
+			OMAP_GPIO_BIT(pad_cfg_tab->pin_num, GPIO_OE),
+			OMAP_GPIO_BIT(pad_cfg_tab->pin_num, GPIO_DATA_OUT),
+			OMAP_GPIO_BIT(pad_cfg_tab->pin_num, GPIO_DATA_IN),
+			OMAP_GPIO_BIT(pad_cfg_tab->pin_num, GPIO_IRQENABLE1)
+			);
+
+		/*
+		 * next pad_cfg deriptor
+		 */
+		pad_cfg_tab++;
+	}
+
+	printk(KERN_INFO "pads configured\n");
+}
+
+
+/*
+ * release gpios taken by the module
+ */
+static void cy_as_hal_release_user_pads(user_pad_cfg_t *pad_cfg_tab)
+{
+	while (pad_cfg_tab->name != NULL) {
+
+		if (pad_cfg_tab->valid) {
+			gpio_free(pad_cfg_tab->pin_num);
+			pad_cfg_tab->valid = 0;
+			printk(KERN_INFO "GPIO_%d "
+					"released from %s\n",
+					pad_cfg_tab->pin_num,
+					pad_cfg_tab->name);
+		} else {
+			printk(KERN_INFO "no release "
+					"for %s, GPIO_%d, wasn't acquired\n",
+					pad_cfg_tab->name,
+					pad_cfg_tab->pin_num);
+		}
+		pad_cfg_tab++;
+	}
+}
+
+void cy_as_hal_config_c_s_mux(void)
+{
+	/*
+	 * FORCE the GPMC CS4 pin (it is in use by the  zoom system)
+	 */
+	omap_cfg_reg_L(T8_OMAP3430_GPMC_n_c_s4);
+}
+EXPORT_SYMBOL(cy_as_hal_config_c_s_mux);
+
+/*
+ * inits all omap h/w
+ */
+uint32_t cy_as_hal_processor_hw_init(cy_as_omap_dev_kernel *dev_p)
+{
+	int i, err;
+
+	printk(KERN_INFO "init OMAP3430 hw...\n");
+
+	iomux_vma = (u32)ioremap_nocache(
+				(u32)CTLPADCONF_BASE_ADDR, CTLPADCONF_SIZE);
+	printk(KERN_INFO "PADCONF_VMA=%x val=%x\n",
+				iomux_vma, IORD32(iomux_vma));
+
+	/*
+	 * remap gpio banks
+	 */
+	for (i = 0; i < 6; i++) {
+		gpio_vma_tab[i].virt_addr = (u32)ioremap_nocache(
+					gpio_vma_tab[i].phy_addr,
+					gpio_vma_tab[i].size);
+
+		printk(KERN_INFO "%s virt_addr=%x\n",
+					gpio_vma_tab[i].name,
+					(u32)gpio_vma_tab[i].virt_addr);
+	};
+
+	/*
+	 * force OMAP_GPIO_126  to rleased state,
+	 * will be configured to drive reset
+	 */
+	gpio_free(AST_RESET);
+
+	/*
+	 *same thing with AStoria CS pin
+	 */
+	gpio_free(AST_CS);
+
+	/*
+	 * initialize all the OMAP pads connected to astoria
+	 */
+	cy_as_hal_init_user_pads(user_pad_cfg);
+
+	err = cy_as_hal_gpmc_init(dev_p);
+
+	cy_as_hal_config_c_s_mux();
+
+	return err;
+}
+EXPORT_SYMBOL(cy_as_hal_processor_hw_init);
+
+void cy_as_hal_omap_hardware_deinit(cy_as_omap_dev_kernel *dev_p)
+{
+	/*
+	 * free omap hw resources
+	 */
+	if (dev_p->m_vma_addr_base != 0)
+		iounmap((void *)dev_p->m_vma_addr_base);
+
+	if (dev_p->m_phy_addr_base != 0)
+		release_mem_region((void *)dev_p->m_phy_addr_base, SZ_16K);
+
+	gpmc_cs_free(AST_GPMC_CS);
+
+	free_irq(OMAP_GPIO_IRQ(AST_INT), dev_p);
+
+	cy_as_hal_release_user_pads(user_pad_cfg);
+}
+
+/*
+ * These are the functions that are not part of the
+ * HAL layer, but are required to be called for this HAL
+ */
+
+/*
+ * Called On AstDevice LKM exit
+ */
+int cy_as_hal_omap_cram_stop(const char *pgm, cy_as_hal_device_tag tag)
+{
+	cy_as_omap_dev_kernel *dev_p = (cy_as_omap_dev_kernel *)tag ;
+
+	/*
+	 * TODO: Need to disable WB interrupt handlere 1st
+	 */
+	if (0 == dev_p)
+		return 1 ;
+
+	cy_as_hal_print_message("<1>_stopping OMAP34xx HAL layer object\n");
+	if (dev_p->m_sig != CY_AS_OMAP_CRAM_HAL_SIG) {
+		cy_as_hal_print_message("<1>%s: %s: bad HAL tag\n",
+								pgm, __func__) ;
+		return 1 ;
+	}
+
+	/*
+	 * disable interrupt
+	 */
+	cy_as_hal_write_register((cy_as_hal_device_tag)dev_p,
+			CY_AS_MEM_P0_INT_MASK_REG, 0x0000) ;
+
+#if 0
+	if (dev_p->thread_flag == 0) {
+		dev_p->thread_flag = 1 ;
+		wait_for_completion(&dev_p->thread_complete) ;
+		cy_as_hal_print_message("cyasomaphal:"
+			"done cleaning thread\n");
+		cy_as_hal_destroy_sleep_channel(&dev_p->thread_sc) ;
+	}
+#endif
+
+	cy_as_hal_omap_hardware_deinit(dev_p);
+
+	/*
+	 * Rearrange the list
+	 */
+	if (m_omap_list_p == dev_p)
+		m_omap_list_p = dev_p->m_next_p ;
+
+	cy_as_hal_free(dev_p) ;
+
+	printk(KERN_INFO "OMAP_kernel_hal stopped\n");
+	return 0;
+}
+
+int omap_start_intr(cy_as_hal_device_tag tag)
+{
+	cy_as_omap_dev_kernel *dev_p = (cy_as_omap_dev_kernel *)tag ;
+	int ret = 0 ;
+	const uint16_t mask = CY_AS_MEM_P0_INTR_REG_DRQINT |
+				CY_AS_MEM_P0_INTR_REG_MBINT ;
+
+	/*
+	 * register for interrupts
+	 */
+	ret = cy_as_hal_configure_interrupts(dev_p) ;
+
+	/*
+	 * enable only MBox & DRQ interrupts for now
+	 */
+	cy_as_hal_write_register((cy_as_hal_device_tag)dev_p,
+				CY_AS_MEM_P0_INT_MASK_REG, mask) ;
+
+	return 1 ;
+}
+
+/*
+ * Below are the functions that communicate with the WestBridge device.
+ * These are system dependent and must be defined by the HAL layer
+ * for a given system.
+ */
+
+
+
+/*
+ * This function must be defined to write a register within the WestBridge
+ * device.  The addr value is the address of the register to write with
+ * respect to the base address of the WestBridge device.
+ */
+void cy_as_hal_write_register(
+					cy_as_hal_device_tag tag,
+					uint16_t addr, uint16_t data)
+{
+	uint16_t write_addr;
+	cy_as_omap_dev_kernel *dev_p = (cy_as_omap_dev_kernel *)tag ;
+
+	#ifndef WESTBRIDGE_NDEBUG
+	if (dev_p->m_sig != CY_AS_OMAP_CRAM_HAL_SIG) {
+		printk(KERN_INFO "%s: bad TAG parameter passed\n",
+			__func__) ;
+		return ;
+	}
+	#endif
+
+	write_addr = (void *)(dev_p->m_vma_addr_base +
+		CYAS_DEV_CALC_ADDR(addr));
+	writew((unsigned short)data, write_addr) ;
+}
+
+/*
+ * This function must be defined to read a register from the WestBridge
+ * device.  The addr value is the address of the register to read with
+ * respect to the base address of the WestBridge device.
+ */
+uint16_t cy_as_hal_read_register(cy_as_hal_device_tag tag, uint16_t addr)
+{
+	uint16_t data  = 0 ;
+	uint32_t read_addr = 0;
+	cy_as_omap_dev_kernel *dev_p = (cy_as_omap_dev_kernel *)tag ;
+
+	#ifndef WESTBRIDGE_NDEBUG
+	if (dev_p->m_sig != CY_AS_OMAP_CRAM_HAL_SIG) {
+		printk(KERN_INFO "%s: bad TAG parameter passed\n",
+			__func__) ;
+		return dev_p->m_sig;
+	}
+	#endif
+
+	read_addr = (void *) (dev_p->m_vma_addr_base +
+		CYAS_DEV_CALC_ADDR(addr));
+	data = (unsigned short) readw(read_addr) ;
+
+	return data ;
+}
+
+/*
+ * preps Ep pointers & data counters for next packet
+ * (fragment of the request) xfer returns true if
+ * there is a next transfer, and false if all bytes in
+ * current request have been xfered
+ */
+static inline bool prep_for_next_xfer(cy_as_hal_device_tag tag, uint8_t ep)
+{
+
+	if (!end_points[ep].sg_list_enabled) {
+		/*
+		 * no further transfers for non storage EPs
+		 * (like EP2 during firmware download, done
+		 * in 64 byte chunks)
+		 */
+		if (end_points[ep].req_xfer_cnt >= end_points[ep].req_length) {
+			DBGPRN("<1> %s():RQ sz:%d non-_sg EP:%d completed\n",
+				__func__, end_points[ep].req_length, ep);
+
+			/*
+			 * no more transfers, we are done with the request
+			 */
+			return false;
+		}
+
+		/*
+		 * calculate size of the next DMA xfer, corner
+		 * case for non-storage EPs where transfer size
+		 * is not egual N * HAL_DMA_PKT_SZ xfers
+		 */
+		if ((end_points[ep].req_length - end_points[ep].req_xfer_cnt)
+		>= HAL_DMA_PKT_SZ) {
+				end_points[ep].dma_xfer_sz = HAL_DMA_PKT_SZ;
+		} else {
+			/*
+			 * that would be the last chunk less
+			 * than P-port max size
+			 */
+			end_points[ep].dma_xfer_sz = end_points[ep].req_length -
+					end_points[ep].req_xfer_cnt;
+		}
+
+		return true;
+	}
+
+	/*
+	 * for SG_list assisted dma xfers
+	 * are we done with current SG ?
+	 */
+	if (end_points[ep].seg_xfer_cnt ==  end_points[ep].sg_p->length) {
+		/*
+		 *  was it the Last SG segment on the list ?
+		 */
+		if (sg_is_last(end_points[ep].sg_p)) {
+			DBGPRN("<1> %s: EP:%d completed,"
+					"%d bytes xfered\n",
+					__func__,
+					ep,
+					end_points[ep].req_xfer_cnt
+			);
+
+			return false;
+		} else {
+			/*
+			 * There are more SG segments in current
+			 * request's sg list setup new segment
+			 */
+
+			end_points[ep].seg_xfer_cnt = 0;
+			end_points[ep].sg_p = sg_next(end_points[ep].sg_p);
+			/* set data pointer for next DMA sg transfer*/
+			end_points[ep].data_p = sg_virt(end_points[ep].sg_p);
+			DBGPRN("<1> %s new SG:_va:%p\n\n",
+					__func__, end_points[ep].data_p);
+		}
+
+	}
+
+	/*
+	 * for sg list xfers it will always be 512 or 1024
+	 */
+	end_points[ep].dma_xfer_sz = HAL_DMA_PKT_SZ;
+
+	/*
+	 * next transfer is required
+	 */
+
+	return true;
+}
+
+/*
+ * Astoria DMA read request, APP_CPU reads from WB ep buffer
+ */
+static void cy_service_e_p_dma_read_request(
+			cy_as_omap_dev_kernel *dev_p, uint8_t ep)
+{
+	cy_as_hal_device_tag tag = (cy_as_hal_device_tag)dev_p ;
+	uint16_t  v, i, size;
+	uint16_t	*dptr;
+	uint16_t ep_dma_reg = CY_AS_MEM_P0_EP2_DMA_REG + ep - 2;
+	register void     *read_addr ;
+	register uint16_t a, b, c, d, e, f, g, h ;
+	/*
+	 * get the XFER size frtom WB eP DMA REGISTER
+	 */
+	v = cy_as_hal_read_register(tag, ep_dma_reg);
+
+	/*
+	 * amount of data in EP buff in  bytes
+	 */
+	size =  v & CY_AS_MEM_P0_E_pn_DMA_REG_COUNT_MASK;
+
+	/*
+	 * memory pointer for this DMA packet xfer (sub_segment)
+	 */
+	dptr = (uint16_t *) end_points[ep].data_p;
+
+	read_addr = dev_p->m_vma_addr_base + CYAS_DEV_CALC_EP_ADDR(ep) ;
+
+	cy_as_hal_assert(size != 0);
+
+	if (size) {
+		/*
+		 * Now, read the data from the device
+		 */
+		for (i = size/16 ; i > 0 ; i--) {
+			a = (unsigned short) readw(read_addr) ;
+			b = (unsigned short) readw(read_addr) ;
+			c = (unsigned short) readw(read_addr) ;
+			d = (unsigned short) readw(read_addr) ;
+			e = (unsigned short) readw(read_addr) ;
+			f = (unsigned short) readw(read_addr) ;
+			g = (unsigned short) readw(read_addr) ;
+			h = (unsigned short) readw(read_addr) ;
+			*dptr++ = a ;
+			*dptr++ = b ;
+			*dptr++ = c ;
+			*dptr++ = d ;
+			*dptr++ = e ;
+			*dptr++ = f ;
+			*dptr++ = g ;
+			*dptr++ = h ;
+		}
+
+		switch ((size & 0xF)/2) {
+		case 7:
+		    *dptr = (unsigned short) readw(read_addr) ;
+		    dptr++ ;
+		case 6:
+		    *dptr = (unsigned short) readw(read_addr) ;
+		    dptr++ ;
+		case 5:
+		    *dptr = (unsigned short) readw(read_addr) ;
+		    dptr++ ;
+		case 4:
+		    *dptr = (unsigned short) readw(read_addr) ;
+		    dptr++ ;
+		case 3:
+		    *dptr = (unsigned short) readw(read_addr) ;
+		    dptr++ ;
+		case 2:
+		    *dptr = (unsigned short) readw(read_addr) ;
+		    dptr++ ;
+		case 1:
+		    *dptr = (unsigned short) readw(read_addr) ;
+		    dptr++ ;
+			break ;
+		}
+
+		if (size & 1) {
+			/* Odd sized packet */
+			uint16_t d = (unsigned short) readw(read_addr) ;
+			*((uint8_t *)dptr) = (d & 0xff) ;
+		}
+	}
+
+	/*
+	 * clear DMAVALID bit indicating that the data has been read
+	 */
+	cy_as_hal_write_register(tag, ep_dma_reg, 0) ;
+
+	end_points[ep].seg_xfer_cnt += size;
+	end_points[ep].req_xfer_cnt += size;
+
+	/*
+	 *  pre-advance data pointer (if it's outside sg
+	 * list it will be reset anyway
+	 */
+	end_points[ep].data_p += size;
+
+	if (prep_for_next_xfer(tag, ep)) {
+		/*
+		 * we have more data to read in this request,
+		 * setup next dma packet due tell WB how much
+		 * data we are going to xfer next
+		 */
+		v = end_points[ep].dma_xfer_sz/*HAL_DMA_PKT_SZ*/ |
+				CY_AS_MEM_P0_E_pn_DMA_REG_DMAVAL ;
+		cy_as_hal_write_register(tag, ep_dma_reg, v);
+	} else {
+		end_points[ep].pending	  = cy_false ;
+		end_points[ep].type		 = cy_as_hal_none ;
+		end_points[ep].buffer_valid = cy_false ;
+
+		/*
+		 * notify the API that we are done with rq on this EP
+		 */
+		if (callback) {
+			DBGPRN("<1>trigg rd_dma completion cb: xfer_sz:%d\n",
+				end_points[ep].req_xfer_cnt);
+				callback(tag, ep,
+					end_points[ep].req_xfer_cnt,
+					CY_AS_ERROR_SUCCESS);
+		}
+	}
+}
+
+/*
+ * omap_cpu needs to transfer data to ASTORIA EP buffer
+ */
+static void cy_service_e_p_dma_write_request(
+			cy_as_omap_dev_kernel *dev_p, uint8_t ep)
+{
+	uint16_t  addr;
+	uint16_t v  = 0, i = 0;
+	uint32_t  size;
+	uint16_t	*dptr;
+	register void     *write_addr ;
+	register uint16_t a, b, c, d ;
+
+	cy_as_hal_device_tag tag = (cy_as_hal_device_tag)dev_p ;
+	/*
+	 * note: size here its the size of the dma transfer could be
+	 * anything > 0 && < P_PORT packet size
+	 */
+	size = end_points[ep].dma_xfer_sz ;
+	dptr = end_points[ep].data_p ;
+
+	write_addr = (void *) (dev_p->m_vma_addr_base +
+		CYAS_DEV_CALC_EP_ADDR(ep)) ;
+
+	/*
+	 * perform the soft DMA transfer, soft in this case
+	 */
+	if (size) {
+		/*
+		 * Now, write the data to the device
+		 */
+		for (i = size/8 ; i > 0 ; i--) {
+			a = *dptr++ ;
+			b = *dptr++ ;
+			c = *dptr++ ;
+			d = *dptr++ ;
+		    writew(a, write_addr) ;
+		    writew(b, write_addr) ;
+		    writew(c, write_addr) ;
+		    writew(d, write_addr) ;
+		}
+
+		switch ((size & 7)/2) {
+		case 3:
+		    writew(*dptr, write_addr) ;
+		    dptr++ ;
+		case 2:
+		    writew(*dptr, write_addr) ;
+		    dptr++ ;
+		case 1:
+		    writew(*dptr, write_addr) ;
+		    dptr++ ;
+			break ;
+		}
+
+		if (size & 1) {
+			uint16_t v = *((uint8_t *)dptr) ;
+			writew(v, write_addr);
+		}
+	}
+
+	end_points[ep].seg_xfer_cnt += size;
+	end_points[ep].req_xfer_cnt += size;
+	/*
+	 * pre-advance data pointer
+	 * (if it's outside sg list it will be reset anyway)
+	 */
+	end_points[ep].data_p += size;
+
+	/*
+	 * now clear DMAVAL bit to indicate we are done
+	 * transferring data and that the data can now be
+	 * sent via USB to the USB host, sent to storage,
+	 * or used internally.
+	 */
+
+	addr = CY_AS_MEM_P0_EP2_DMA_REG + ep - 2 ;
+	cy_as_hal_write_register(tag, addr, size) ;
+
+	/*
+	 * finally, tell the USB subsystem that the
+	 * data is gone and we can accept the
+	 * next request if one exists.
+	 */
+	if (prep_for_next_xfer(tag, ep)) {
+		/*
+		 * There is more data to go. Re-init the WestBridge DMA side
+		 */
+		v = end_points[ep].dma_xfer_sz |
+			CY_AS_MEM_P0_E_pn_DMA_REG_DMAVAL ;
+		cy_as_hal_write_register(tag, addr, v) ;
+	} else {
+
+	   end_points[ep].pending	  = cy_false ;
+	   end_points[ep].type		 = cy_as_hal_none ;
+	   end_points[ep].buffer_valid = cy_false ;
+
+		/*
+		 * notify the API that we are done with rq on this EP
+		 */
+		if (callback) {
+			/*
+			 * this callback will wake up the process that might be
+			 * sleeping on the EP which data is being transferred
+			 */
+			callback(tag, ep,
+					end_points[ep].req_xfer_cnt,
+					CY_AS_ERROR_SUCCESS);
+		}
+	}
+}
+
+/*
+ * HANDLE DRQINT from Astoria (called in AS_Intr context
+ */
+static void cy_handle_d_r_q_interrupt(cy_as_omap_dev_kernel *dev_p)
+{
+	uint16_t v ;
+	static uint8_t service_ep = 2 ;
+
+	/*
+	 * We've got DRQ INT, read DRQ STATUS Register */
+	v = cy_as_hal_read_register((cy_as_hal_device_tag)dev_p,
+			CY_AS_MEM_P0_DRQ) ;
+
+	if (v == 0) {
+#ifndef WESTBRIDGE_NDEBUG
+		cy_as_hal_print_message("stray DRQ interrupt detected\n") ;
+#endif
+		return;
+	}
+
+	/*
+	 * Now, pick a given DMA request to handle, for now, we just
+	 * go round robin.  Each bit position in the service_mask
+	 * represents an endpoint from EP2 to EP15.  We rotate through
+	 * each of the endpoints to find one that needs to be serviced.
+	 */
+	while ((v & (1 << service_ep)) == 0) {
+
+		if (service_ep == 15)
+			service_ep = 2 ;
+		else
+			service_ep++ ;
+	}
+
+	if (end_points[service_ep].type == cy_as_hal_write) {
+		/*
+		 * handle DMA WRITE REQUEST: app_cpu will
+		 * write data into astoria EP buffer
+		 */
+		cy_service_e_p_dma_write_request(dev_p, service_ep) ;
+	} else if (end_points[service_ep].type == cy_as_hal_read) {
+		/*
+		 * handle DMA READ REQUEST: cpu will
+		 * read EP buffer from Astoria
+		 */
+		cy_service_e_p_dma_read_request(dev_p, service_ep) ;
+	}
+#ifndef WESTBRIDGE_NDEBUG
+	else
+		cy_as_hal_print_message("cyashalomap:interrupt,"
+					" w/o pending DMA job,"
+					"-check DRQ_MASK logic\n") ;
+#endif
+
+	/*
+	 * Now bump the EP ahead, so other endpoints get
+	 * a shot before the one we just serviced
+	 */
+	if (end_points[service_ep].type == cy_as_hal_none) {
+		if (service_ep == 15)
+			service_ep = 2 ;
+		else
+			service_ep++ ;
+	}
+
+}
+
+void cy_as_hal_dma_cancel_request(cy_as_hal_device_tag tag, uint8_t ep)
+{
+	DBGPRN("cy_as_hal_dma_cancel_request on ep:%d", ep);
+	if (end_points[ep].pending)
+		cy_as_hal_write_register(tag,
+				CY_AS_MEM_P0_EP2_DMA_REG + ep - 2, 0);
+
+	end_points[ep].buffer_valid = cy_false ;
+	end_points[ep].type = cy_as_hal_none;
+}
+
+/*
+ * enables/disables SG list assisted DMA xfers for the given EP
+ * sg_list assisted XFERS can use physical addresses of mem pages in case if the
+ * xfer is performed by a h/w DMA controller rather then the CPU on P port
+ */
+void cy_as_hal_set_ep_dma_mode(uint8_t ep, bool sg_xfer_enabled)
+{
+	end_points[ep].sg_list_enabled = sg_xfer_enabled;
+	DBGPRN("<1> EP:%d sg_list assisted DMA mode set to = %d\n",
+			ep, end_points[ep].sg_list_enabled);
+}
+EXPORT_SYMBOL(cy_as_hal_set_ep_dma_mode);
+
+/*
+ * This function must be defined to transfer a block of data to
+ * the WestBridge device.  This function can use the burst write
+ * (DMA) capabilities of WestBridge to do this, or it can just copy
+ * the data using writes.
+ */
+void cy_as_hal_dma_setup_write(cy_as_hal_device_tag tag,
+						uint8_t ep, void *buf,
+						uint32_t size, uint16_t maxsize)
+{
+	uint32_t addr = 0 ;
+	uint16_t v  = 0;
+
+	/*
+	 * Note: "size" is the actual request size
+	 * "maxsize" - is the P port fragment size
+	 * No EP0 or EP1 traffic should get here
+	 */
+	cy_as_hal_assert(ep != 0 && ep != 1) ;
+
+	/*
+	 * If this asserts, we have an ordering problem.  Another DMA request
+	 * is coming down before the previous one has completed.
+	 */
+	cy_as_hal_assert(end_points[ep].buffer_valid == cy_false) ;
+	end_points[ep].buffer_valid = cy_true ;
+	end_points[ep].type = cy_as_hal_write ;
+	end_points[ep].pending = cy_true;
+
+	/*
+	 * total length of the request
+	 */
+	end_points[ep].req_length = size;
+
+	if (size >= maxsize) {
+		/*
+		 * set xfer size for very 1st DMA xfer operation
+		 * port max packet size ( typically 512 or 1024)
+		 */
+		end_points[ep].dma_xfer_sz = maxsize;
+	} else {
+		/*
+		 * smaller xfers for non-storage EPs
+		 */
+		end_points[ep].dma_xfer_sz = size;
+	}
+
+	/*
+	 * check the EP transfer mode uses sg_list rather then a memory buffer
+	 * block devices pass it to the HAL, so the hAL could get to the real
+	 * physical address for each segment and set up a DMA controller
+	 * hardware ( if there is one)
+	 */
+	if (end_points[ep].sg_list_enabled) {
+		/*
+		 * buf -  pointer to the SG list
+		 * data_p - data pointer to the 1st DMA segment
+		 * seg_xfer_cnt - keeps track of N of bytes sent in current
+		 *		sg_list segment
+		 * req_xfer_cnt - keeps track of the total N of bytes
+		 *		transferred for the request
+		 */
+		end_points[ep].sg_p = buf;
+		end_points[ep].data_p = sg_virt(end_points[ep].sg_p);
+		end_points[ep].seg_xfer_cnt = 0 ;
+		end_points[ep].req_xfer_cnt = 0;
+
+#ifdef DBGPRN_DMA_SETUP_WR
+		DBGPRN("cyasomaphal:%s: EP:%d, buf:%p, buf_va:%p,"
+				"req_sz:%d, maxsz:%d\n",
+				__func__,
+				ep,
+				buf,
+				end_points[ep].data_p,
+				size,
+				maxsize);
+#endif
+
+	} else {
+		/*
+		 * setup XFER for non sg_list assisted EPs
+		 */
+
+		#ifdef DBGPRN_DMA_SETUP_WR
+			DBGPRN("<1>%s non storage or sz < 512:"
+					"EP:%d, sz:%d\n", __func__, ep, size);
+		#endif
+
+		end_points[ep].sg_p = NULL;
+
+		/*
+		 * must be a VMA of a membuf in kernel space
+		 */
+		end_points[ep].data_p = buf;
+
+		/*
+		 * will keep track No of bytes xferred for the request
+		 */
+		end_points[ep].req_xfer_cnt = 0;
+	}
+
+	/*
+	 * Tell WB we are ready to send data on the given endpoint
+	 */
+	v = (end_points[ep].dma_xfer_sz & CY_AS_MEM_P0_E_pn_DMA_REG_COUNT_MASK)
+			| CY_AS_MEM_P0_E_pn_DMA_REG_DMAVAL ;
+
+	addr = CY_AS_MEM_P0_EP2_DMA_REG + ep - 2 ;
+
+	cy_as_hal_write_register(tag, addr, v) ;
+}
+
+/*
+ * This function must be defined to transfer a block of data from
+ * the WestBridge device.  This function can use the burst read
+ * (DMA) capabilities of WestBridge to do this, or it can just
+ * copy the data using reads.
+ */
+void cy_as_hal_dma_setup_read(cy_as_hal_device_tag tag,
+					uint8_t ep, void *buf,
+					uint32_t size, uint16_t maxsize)
+{
+	uint32_t addr ;
+	uint16_t v ;
+
+	/*
+	 * Note: "size" is the actual request size
+	 * "maxsize" - is the P port fragment size
+	 * No EP0 or EP1 traffic should get here
+	 */
+	cy_as_hal_assert(ep != 0 && ep != 1) ;
+
+	/*
+	 * If this asserts, we have an ordering problem.
+	 * Another DMA request is coming down before the
+	 * previous one has completed. we should not get
+	 * new requests if current is still in process
+	 */
+
+	cy_as_hal_assert(end_points[ep].buffer_valid == cy_false);
+
+	end_points[ep].buffer_valid = cy_true ;
+	end_points[ep].type = cy_as_hal_read ;
+	end_points[ep].pending = cy_true;
+	end_points[ep].req_xfer_cnt = 0;
+	end_points[ep].req_length = size;
+
+	if (size >= maxsize) {
+		/*
+		 * set xfer size for very 1st DMA xfer operation
+		 * port max packet size ( typically 512 or 1024)
+		 */
+		end_points[ep].dma_xfer_sz = maxsize;
+	} else {
+		/*
+		 * so that we could handle small xfers on in case
+		 * of non-storage EPs
+		 */
+		end_points[ep].dma_xfer_sz = size;
+	}
+
+	addr = CY_AS_MEM_P0_EP2_DMA_REG + ep - 2 ;
+
+	if (end_points[ep].sg_list_enabled) {
+		/*
+		 * Handle sg-list assisted EPs
+		 * seg_xfer_cnt - keeps track of N of sent packets
+		 * buf - pointer to the SG list
+		 * data_p - data pointer for the 1st DMA segment
+		 */
+		end_points[ep].seg_xfer_cnt = 0 ;
+		end_points[ep].sg_p = buf;
+		end_points[ep].data_p = sg_virt(end_points[ep].sg_p);
+
+		#ifdef DBGPRN_DMA_SETUP_RD
+		DBGPRN("cyasomaphal:DMA_setup_read sg_list EP:%d, "
+			   "buf:%p, buf_va:%p, req_sz:%d, maxsz:%d\n",
+				ep,
+				buf,
+				end_points[ep].data_p,
+				size,
+				maxsize);
+		#endif
+		v = (end_points[ep].dma_xfer_sz &
+				CY_AS_MEM_P0_E_pn_DMA_REG_COUNT_MASK) |
+				CY_AS_MEM_P0_E_pn_DMA_REG_DMAVAL ;
+		cy_as_hal_write_register(tag, addr, v);
+	} else {
+		/*
+		 * Non sg list EP passed  void *buf rather then scatterlist *sg
+		 */
+		#ifdef DBGPRN_DMA_SETUP_RD
+			DBGPRN("%s:non-sg_list EP:%d,"
+					"RQ_sz:%d, maxsz:%d\n",
+					__func__, ep, size,  maxsize);
+		#endif
+
+		end_points[ep].sg_p = NULL;
+
+		/*
+		 * must be a VMA of a membuf in kernel space
+		 */
+		end_points[ep].data_p = buf;
+
+		/*
+		 * Program the EP DMA register for Storage endpoints only.
+		 */
+		if (is_storage_e_p(ep)) {
+			v = (end_points[ep].dma_xfer_sz &
+					CY_AS_MEM_P0_E_pn_DMA_REG_COUNT_MASK) |
+					CY_AS_MEM_P0_E_pn_DMA_REG_DMAVAL ;
+			cy_as_hal_write_register(tag, addr, v);
+		}
+	}
+}
+
+/*
+ * This function must be defined to allow the WB API to
+ * register a callback function that is called when a
+ * DMA transfer is complete.
+ */
+void cy_as_hal_dma_register_callback(cy_as_hal_device_tag tag,
+					cy_as_hal_dma_complete_callback cb)
+{
+	DBGPRN("<1>\n%s: WB API has registered a dma_complete callback:%x\n",
+			__func__, (uint32_t)cb);
+	callback = cb ;
+}
+
+/*
+ * This function must be defined to return the maximum size of
+ * DMA request that can be handled on the given endpoint.  The
+ * return value should be the maximum size in bytes that the DMA
+ * module can handle.
+ */
+uint32_t cy_as_hal_dma_max_request_size(cy_as_hal_device_tag tag,
+					cy_as_end_point_number_t ep)
+{
+	/*
+	 * Storage reads and writes are always done in 512 byte blocks.
+	 * So, we do the count handling within the HAL, and save on
+	 * some of the data transfer delay.
+	 */
+	if ((ep == CYASSTORAGE_READ_EP_NUM) ||
+	(ep == CYASSTORAGE_WRITE_EP_NUM)) {
+		/* max DMA request size HAL can handle by itself */
+		return CYASSTORAGE_MAX_XFER_SIZE;
+	} else {
+	/*
+	 * For the USB - Processor endpoints, the maximum transfer
+	 * size depends on the speed of USB operation. So, we use
+	 * the following constant to indicate to the API that
+	 * splitting of the data into chunks less that or equal to
+	 * the max transfer size should be handled internally.
+	 */
+
+		/* DEFINED AS 0xffffffff in cyasdma.h */
+		return CY_AS_DMA_MAX_SIZE_HW_SIZE;
+	}
+}
+
+/*
+ * This function must be defined to set the state of the WAKEUP pin
+ * on the WestBridge device.  Generally this is done via a GPIO of
+ * some type.
+ */
+cy_bool cy_as_hal_set_wakeup_pin(cy_as_hal_device_tag tag, cy_bool state)
+{
+	if (state)
+		__gpio_set_value(AST_WAKEUP, 1);
+	else
+		__gpio_set_value(AST_WAKEUP, 0);
+
+	return cy_true;
+}
+
+void cy_as_hal_pll_lock_loss_handler(cy_as_hal_device_tag tag)
+{
+	cy_as_hal_print_message("error: astoria PLL lock is lost\n") ;
+	cy_as_hal_print_message("please check the input voltage levels");
+	cy_as_hal_print_message("and clock, and restart the system\n") ;
+}
+
+/*
+ * Below are the functions that must be defined to provide the basic
+ * operating system services required by the API.
+ */
+
+/*
+ * This function is required by the API to allocate memory.
+ * This function is expected to work exactly like malloc().
+ */
+void *cy_as_hal_alloc(uint32_t cnt)
+{
+	void *ret_p ;
+
+	ret_p = kmalloc(cnt, GFP_ATOMIC) ;
+	return ret_p ;
+}
+
+/*
+ * This function is required by the API to free memory allocated
+ * with CyAsHalAlloc().  This function is'expected to work exacly
+ * like free().
+ */
+void cy_as_hal_free(void *mem_p)
+{
+	kfree(mem_p) ;
+}
+
+/*
+ * Allocator that can be used in interrupt context.
+ * We have to ensure that the kmalloc call does not
+ * sleep in this case.
+ */
+void *cy_as_hal_c_b_alloc(uint32_t cnt)
+{
+	void *ret_p ;
+
+	ret_p = kmalloc(cnt, GFP_ATOMIC) ;
+	return ret_p ;
+}
+
+/*
+ * This function is required to set a block of memory to a
+ * specific value.  This function is expected to work exactly
+ * like memset()
+ */
+void cy_as_hal_mem_set(void *ptr, uint8_t value, uint32_t cnt)
+{
+	memset(ptr, value, cnt) ;
+}
+
+/*
+ * This function is expected to create a sleep channel.
+ * The data structure that represents the sleep channel object
+ * sleep channel (which is Linux "wait_queue_head_t wq" for this paticular HAL)
+ * passed as a pointer, and allpocated by the caller
+ * (typically as a local var on the stack) "Create" word should read as
+ * "SleepOn", this func doesn't actually create anything
+ */
+cy_bool cy_as_hal_create_sleep_channel(cy_as_hal_sleep_channel *channel)
+{
+	init_waitqueue_head(&channel->wq) ;
+	return cy_true ;
+}
+
+/*
+ * for this particular HAL it doesn't actually destroy anything
+ * since no actual sleep object is created in CreateSleepChannel()
+ * sleep channel is given by the pointer in the argument.
+ */
+cy_bool cy_as_hal_destroy_sleep_channel(cy_as_hal_sleep_channel *channel)
+{
+	return cy_true ;
+}
+
+/*
+ * platform specific wakeable Sleep implementation
+ */
+cy_bool cy_as_hal_sleep_on(cy_as_hal_sleep_channel *channel, uint32_t ms)
+{
+	wait_event_interruptible_timeout(channel->wq, 0, ((ms * HZ)/1000)) ;
+	return cy_true ;
+}
+
+/*
+ * wakes up the process waiting on the CHANNEL
+ */
+cy_bool cy_as_hal_wake(cy_as_hal_sleep_channel *channel)
+{
+	wake_up_interruptible_all(&channel->wq);
+	return cy_true ;
+}
+
+uint32_t cy_as_hal_disable_interrupts()
+{
+	if (0 == intr__enable)
+		;
+
+	intr__enable++ ;
+	return 0 ;
+}
+
+void cy_as_hal_enable_interrupts(uint32_t val)
+{
+	intr__enable-- ;
+	if (0 == intr__enable)
+		;
+}
+
+/*
+ * Sleep atleast 150ns, cpu dependent
+ */
+void cy_as_hal_sleep150(void)
+{
+	uint32_t i, j;
+
+	j = 0;
+	for (i = 0; i < 1000; i++)
+		j += (~i);
+}
+
+void cy_as_hal_sleep(uint32_t ms)
+{
+	cy_as_hal_sleep_channel channel;
+
+	cy_as_hal_create_sleep_channel(&channel) ;
+	cy_as_hal_sleep_on(&channel, ms) ;
+	cy_as_hal_destroy_sleep_channel(&channel) ;
+}
+
+cy_bool cy_as_hal_is_polling()
+{
+	return cy_false;
+}
+
+void cy_as_hal_c_b_free(void *ptr)
+{
+	cy_as_hal_free(ptr);
+}
+
+/*
+ * suppose to reinstate the astoria registers
+ * that may be clobbered in sleep mode
+ */
+void cy_as_hal_init_dev_registers(cy_as_hal_device_tag tag,
+					cy_bool is_standby_wakeup)
+{
+	/* specific to SPI, no implementation required */
+	(void) tag;
+	(void) is_standby_wakeup;
+}
+
+void cy_as_hal_read_regs_before_standby(cy_as_hal_device_tag tag)
+{
+	/* specific to SPI, no implementation required */
+	(void) tag;
+}
+
+cy_bool cy_as_hal_sync_device_clocks(cy_as_hal_device_tag tag)
+{
+	/*
+	 * we are in asynchronous mode. so no need to handle this
+	 */
+	return true;
+}
+
+/*
+ * init OMAP h/w resources
+ */
+int cy_as_hal_omap_cram_start(const char *pgm,
+				cy_as_hal_device_tag *tag, cy_bool debug)
+{
+	cy_as_omap_dev_kernel *dev_p ;
+	int i;
+	u16 data16[4];
+	uint32_t err = 0;
+	/* No debug mode support through argument as of now */
+	(void)debug;
+
+
+	/*
+	 * Initialize the HAL level endpoint DMA data.
+	 */
+	for (i = 0 ; i < sizeof(end_points)/sizeof(end_points[0]) ; i++) {
+		end_points[i].data_p = 0 ;
+		end_points[i].pending = cy_false ;
+		end_points[i].size = 0 ;
+		/* No debug mode support through argument as of now */
+		(void)debug;
+
+		end_points[i].type = cy_as_hal_none ;
+		end_points[i].sg_list_enabled = cy_false;
+
+		/*
+		 * by default the DMA transfers to/from the E_ps don't
+		 * use sg_list that implies that the upper devices like
+		 * blockdevice have to enable it for the E_ps in their
+		 * initialization code
+		 */
+	}
+
+	/* allocate memory for OMAP HAL*/
+	dev_p = (cy_as_omap_dev_kernel *)cy_as_hal_alloc(
+						sizeof(cy_as_omap_dev_kernel)) ;
+	if (dev_p == 0) {
+		cy_as_hal_print_message("out of memory allocating OMAP"
+					"device structure\n") ;
+		return 0 ;
+	}
+
+	dev_p->m_sig = CY_AS_OMAP_CRAM_HAL_SIG;
+
+	/* initialize OMAP hardware and StartOMAPKernelall gpio pins */
+	err = cy_as_hal_processor_hw_init(dev_p);
+	if (err)
+		goto bus_acc_error;
+
+	/*
+	 * Now perform a hard reset of the device to have
+	 * the new settings take effect
+	 */
+	__gpio_set_value(AST_WAKEUP, 1);
+
+	/*
+	 * do Astoria  h/w reset
+	 */
+	DBGPRN(KERN_INFO"-_-_pulse -> westbridge RST pin\n");
+
+	/*
+	 * NEGATIVE PULSE on RST pin
+	 */
+	__gpio_set_value(AST_RESET, 0);
+	mdelay(1);
+	__gpio_set_value(AST_RESET, 1);
+	mdelay(50);
+
+
+	/*
+	 *  NOTE: if you want to capture bus activity on the LA,
+	 *  don't use printks in between the activities you want to capture.
+	 *  prinks may take milliseconds, and the data of interest
+	 *  will fall outside the LA capture window/buffer
+	 */
+	data16[0] = cy_as_hal_read_register(
+		(cy_as_hal_device_tag)dev_p, CY_AS_MEM_CM_WB_CFG_ID);
+
+	if (data16[0] != 0xA200) {
+		/*
+		 * astoria device is not found
+		 */
+		printk(KERN_ERR "ERROR: astoria device is not found, "
+			"CY_AS_MEM_CM_WB_CFG_ID %4.4x", data16[0]);
+		goto bus_acc_error;
+	}
+
+	printk(KERN_INFO " register access CASDO test:"
+				"\n CY_AS_MEM_CM_WB_CFG_ID:%4.4x\n"
+				"after cfg_wr:%4.4x\n\n",
+				data16[0], data16[1]);
+
+	dev_p->thread_flag = 1 ;
+	spin_lock_init(&int_lock) ;
+	dev_p->m_next_p = m_omap_list_p ;
+
+	m_omap_list_p = dev_p ;
+	*tag = dev_p;
+
+	cy_as_hal_configure_interrupts((void *)dev_p);
+
+	printk(KERN_INFO "OMAP3430__hal started tag:%p"
+				", kernel HZ:%d\n", dev_p, HZ);
+
+	/*
+	 *make processor to storage endpoints SG assisted by default
+	 */
+	cy_as_hal_set_ep_dma_mode(4, true);
+	cy_as_hal_set_ep_dma_mode(8, true);
+
+	return 1 ;
+
+	/*
+	 * there's been a NAND bus access error or
+	 * astoria device is not connected
+	 */
+bus_acc_error:
+	/*
+	 * at this point hal tag hasn't been set yet
+	 * so the device will not call omap_stop
+	 */
+	cy_as_hal_omap_hardware_deinit(dev_p);
+	cy_as_hal_free(dev_p) ;
+	return 0;
+}
+
+#else
+/*
+ * Some compilers do not like empty C files, so if the OMAP hal is not being
+ * compiled, we compile this single function.  We do this so that for a
+ * given target HAL there are not multiple sources for the HAL functions.
+ */
+void my_o_m_a_p_kernel_hal_dummy_function(void)
+{
+}
+
+#endif
drivers/staging/westbridge/astoria/arch/arm/mach-omap2/cyashalomap_kernel.c +0 -2450

1,155 lines not on this page · raw message

drivers/staging/westbridge/astoria/arch/arm/mach-omap2/cyashalomap_pnand.c +2462 -0

2,462 lines not on this page · raw message

drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-cram-hal/cyashalomap_cram.h +319 -0

319 lines not on this page · raw message

drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-cram-hal/cyasmemmap.h +564 -0

564 lines not on this page · raw message

drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-cram-hal/cyasomapdev_cram.h +73 -0

73 lines not on this page · raw message

drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyashalomap_kernel.h +0 -319

319 lines not on this page · raw message

drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyashalomap_pnand.h +319 -0

319 lines not on this page · raw message

drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyasmemmap.h +6 -3
diff -uprN -X linux-next-vanilla/Documentation/dontdiff linux-next-vanilla/drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyasmemmap.h linux-next-incl-sdk/drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyasmemmap.h

Lines of this file are not shown. View the raw message.

drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyasomapdev_kernel.h +0 -72

72 lines not on this page · raw message

drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyasomapdev_pnand.h +72 -0

72 lines not on this page · raw message

drivers/staging/westbridge/astoria/device/Makefile +9 -1
diff -uprN -X linux-next-vanilla/Documentation/dontdiff linux-next-vanilla/drivers/staging/westbridge/astoria/device/Makefile linux-next-incl-sdk/drivers/staging/westbridge/astoria/device/Makefile

Lines of this file are not shown. View the raw message.

drivers/staging/westbridge/astoria/include/linux/westbridge/cyashal.h +28 -11
diff -uprN -X linux-next-vanilla/Documentation/dontdiff linux-next-vanilla/drivers/staging/westbridge/astoria/include/linux/westbridge/cyashal.h linux-next-incl-sdk/drivers/staging/westbridge/astoria/include/linux/westbridge/cyashal.h

Lines of this file are not shown. View the raw message.

drivers/staging/westbridge/Kconfig +37 -5

42 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

---------------------------------------------------------------
This message and any attachments may contain Cypress (or its subsidiaries) confidential information. If it has been received in error, please advise the sender and immediately delete this message.
---------------------------------------------------------------

Part of the diff is not shown here. View the raw message.

#6 lore raw

Re: [PATCH] west bridge, kconfig and hal fixes

On Tue, Sep 07, 2010 at 12:22:10PM -0700, David Cross wrote:

First off, what's with the "Re:" of the Subject? What are you responding to here?

Quoted 3 lines

This patch contains the kconfig changes necessary to fix build errors that could come up in the linux-next version. It also includes an additional HAL layer for the west bridge CRAM interface.

Again, one patch per change, please break this up.

Quoted 5 lines

The inclusion
of this interface support did require the reorganization of some of the existing code, which is part of the reason for the size of the patch. Moving files and directories makes this patch seem larger than it really is.

If you use git you can send a patch that properly shows only what changes even if the file is moved. Care to do that?

Quoted 2 lines

The Kconfig changes are closely related to the inclusion of the CRAM HAL layer, and as such this patch is difficult to logically separate.

Why is it necessary?

Quoted 2 lines

The linux-next tree does not seem to have a config for the zoom2, and trying to build it for that board seems to make the compilation break.

Why should the driver care about which arch it is built for? It should build on _all_ arches, right?

Quoted 3 lines

As such, the only thing that I tested was compilation using the two different HALs (one of which is added in this patch). Please let me know if there are problems or questions with this.

Why do you need a "HAL" at all here?

confused,

greg k-h

#7 lore raw

RE: [PATCH] west bridge, kconfig and hal fixes

From: Greg KH [mailto:[email protected]]

Quoted 2 lines · David Cross

First off, what's with the "Re:" of the Subject? What are you responding to here?

I will removed that going forward when submitting patches, it does seem appropriate on this response, so am leaving it in.

Quoted 5 lines
Quoted 3 lines

This patch contains the kconfig changes necessary to fix build errors that could come up in the linux-next version. It also includes an additional HAL layer for the west bridge CRAM interface.

Again, one patch per change, please break this up.

Can I break it up as 1) moving PNAND HAL layer + Kconfig changes and 2) CRAM HAL layer inclusion or is this still too tightly coupled? The issue that I am having is that I was working on these drivers while waiting on inclusion in the staging area in order to incorporate all of the feedback I have gotten so far. As such, I now either have to artificially break up the patches or start with a clean kernel and start sequentially hand coding them again. I think this latter might be what you want, but this is really time-consuming to do at this point.
While I definitely understand the need for this type of review of patches for changes to the kernel itself, it is hard for me to understand why the same rigor needs to apply to this driver in the staging area. As you mentioned, it needs a lot of work to meet the standards for acceptance. I have done a fair amount of work to move it closer. Do I really need to undo and repeat all of that in order to clean up "BROKEN" code in the staging area of the linux-next tree?

Quoted 8 lines
Quoted 5 lines

The inclusion
of this interface support did require the reorganization of some of the existing code, which is part of the reason for the size of the patch. Moving files and directories makes this patch seem larger than it really is.

If you use git you can send a patch that properly shows only what changes even if the file is moved. Care to do that?

I have not used git so far, other than to pull from repositories. I probably could, but it will take me some time to learn. Is this "nice to have" or do I need to do it to get this patch applied?

Quoted 4 lines
Quoted 2 lines

The Kconfig changes are closely related to the inclusion of the CRAM HAL layer, and as such this patch is difficult to logically separate.

Why is it necessary?

The HAL layer in general or this specific HAL layer? One of the reasons for needing memory interface options is the allocation of pins on a given platform. For example, if CLE was used as a GPIO for some other purpose, it is nice to have the option to move to an SRAM like interface. Also, I needed to develop this for unrelated reasons. As such, making minor structural changes such that new HALs could be easily incorporated in an intuitive manner seemed to be a plus. I also hoped that it would make the structure and rationale behind the initial driver structure more intuitive to the kernel maintainers.

Quoted 5 lines
Quoted 2 lines

The linux-next tree does not seem to have a config for the zoom2, and trying to build it for that board seems to make the compilation break.

Why should the driver care about which arch it is built for? It should build on _all_ arches, right?

It should build on all architectures that have an appropriate HAL implemented. Otherwise, if you don't have a method for low level communication with west bridge, why would you want to build the driver?

Quoted 5 lines
Quoted 3 lines

As such, the only thing that I tested was compilation using the two different HALs (one of which is added in this patch). Please let me know if there are problems or questions with this.

Why do you need a "HAL" at all here?

For low level communication. The interface to the processor is a memory interface across which mailbox messages are passed. These mailbox messages makeup a sort of data link layer on top of which higher levels of abstraction can be built.
Additionally, the HAL defines how you pump data to the device's endpoints, since this is also done across the memory interface from the processor's perspective. Other power management items are also included, and the complete list of functions can be seen in the header files.

Thanks,
david

---------------------------------------------------------------
This message and any attachments may contain Cypress (or its subsidiaries) confidential information. If it has been received in error, please advise the sender and immediately delete this message.
---------------------------------------------------------------

#8 lore raw

Re: [PATCH] west bridge, kconfig and hal fixes

Quoted 9 lines · David Cross

From: Greg KH [mailto:[email protected]]

Quoted 2 lines · David Cross

First off, what's with the "Re:" of the Subject? What are you responding to here?

I will removed that going forward when submitting patches, it does seem appropriate on this response, so am leaving it in.

Yes, of course it is correct here :)

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

This patch contains the kconfig changes necessary to fix build errors that could come up in the linux-next version. It also includes an additional HAL layer for the west bridge CRAM interface.

Again, one patch per change, please break this up.

Can I break it up as 1) moving PNAND HAL layer + Kconfig changes and

Wait, look, you had a "and" in there. Why?

Why not just do:
- move PNAND HAL layer
- Kconfig changes
as individual patches.

Each one does only one thing. Again, please try to remember that.

Quoted 8 lines

2) CRAM HAL layer inclusion or is this still too tightly coupled? The issue that I am having is that I was working on these drivers while waiting on inclusion in the staging area in order to incorporate all of the feedback I have gotten so far. As such, I now either have to artificially break up the patches or start with a clean kernel and start sequentially hand coding them again. I think this latter might be what you want, but this is really time-consuming to do at this point.

Well, it shouldn't take all that long of time, as you know what you want to accomplish. It's also how kernel development works, you usually go off and do a bunch of work, then step back and figure out how to break it up into logical chunks to submit it. Everyone does it. After time you will get used to doing things in logical steps so you don't have to redo things, but that takes a bit of time.

Quoted 3 lines

While I definitely understand the need for this type of review of patches for changes to the kernel itself, it is hard for me to understand why the same rigor needs to apply to this driver in the staging area.

There is no difference here for what type of patches I can accept in the staging area. Staging is for code that doesn't meet the "normal" acceptance guidelines, but that does not mean that the proper development process does not also apply here at all. It's a matter of both cleaning up the code, and cleaning up the developers who are working on the code at the same time :)

Quoted 4 lines

As you gmentioned, it needs a lot of work to meet the standards for acceptance. I have done a fair amount of work to move it closer. Do I really need to undo and repeat all of that in order to clean up "BROKEN" code in the staging area of the linux-next tree?

It's marked "BROKEN" because it breaks the build. Once that is fixed we can remove that marking, that's the only thing keeping it that way.

Quoted 6 lines
Quoted 5 lines
Quoted 5 lines

The inclusion
of this interface support did require the reorganization of some of the existing code, which is part of the reason for the size of the patch. Moving files and directories makes this patch seem larger than it really is.

Quoted 6 lines
Quoted 2 lines

If you use git you can send a patch that properly shows only what changes even if the file is moved. Care to do that?

I have not used git so far, other than to pull from repositories. I probably could, but it will take me some time to learn. Is this "nice to have" or do I need to do it to get this patch applied?

What are you using to develop your patches? If you don't use git, you can use quilt, or some other type of patch management system. But it might be worth spending a few hours to get up and running on one of them as this is going to be something you use a lot in the future, and it will help you get work done much faster and be able to work with the rest of the community better as well.

Trust me, taking the time to learn git is worth it in the end.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

The Kconfig changes are closely related to the inclusion of the CRAM HAL layer, and as such this patch is difficult to logically separate.

Why is it necessary?

The HAL layer in general or this specific HAL layer?

Any HAL layer.

Quoted 9 lines

One of the reasons for needing memory interface options is the allocation of pins on a given platform. For example, if CLE was used as a GPIO for some other purpose, it is nice to have the option to move to an SRAM like interface. Also, I needed to develop this for unrelated reasons. As such, making minor structural changes such that new HALs could be easily incorporated in an intuitive manner seemed to be a plus. I also hoped that it would make the structure and rationale behind the initial driver structure more intuitive to the kernel maintainers.

Note that almost no other driver in the kernel needs such a layer. What you do is have a "backend" that talks to either GPIO or SRAM or something else. Then, at runtime, you can pick the one you need/want depending on the hardware the code is running on, and everything "just works".

Remember, the goal is to be able to build your driver once for any platform it might run on. Don't rely on Kconfig options to select the hardware types, that's not the correct way to do things in the end at all.

Quoted 9 lines
Quoted 5 lines
Quoted 2 lines

The linux-next tree does not seem to have a config for the zoom2, and trying to build it for that board seems to make the compilation break.

Why should the driver care about which arch it is built for? It should build on _all_ arches, right?

It should build on all architectures that have an appropriate HAL implemented. Otherwise, if you don't have a method for low level communication with west bridge, why would you want to build the driver?

Testing that the build isn't broken? Building one image to run on lots of different platforms? Distros really need this and there is a large unification effort for ARM to get this to work for that platform right now. PPC has done this a lot already as well.

Hope this helps,

greg k-h

#9 lore raw

Re: [PATCH] West Bridge Astoria Driver 2.6.35, cyasgadget fixes and mpage_cleardirty

In reply to David Cross

This patch contains update to the gadget driver, some of which are based on feedback from the Linux community concerning the usage of fat_get_block. It also contains the addition of mpage_clear_dirty, a function used to clear dirty pages from the page cache. These two patches are also interdependent and difficult to separate. As such, they are included as one patch.
Thanks,
David

drivers/staging/westbridge/astoria/gadget/cyasgadget.c +33 -68
diff -uprN -X linux-next-vanilla/Documentation/dontdiff linux-next-vanilla/drivers/staging/westbridge/astoria/gadget/cyasgadget.c linux-next-incl-sdk/drivers/staging/westbridge/astoria/gadget/cyasgadget.c
@@ -224,6 +224,8 @@ static void cy_as_gadget_mtp_event_callb
 			cy_as_mtp_send_object_complete_data *send_obj_data =
 				(cy_as_mtp_send_object_complete_data *) evdata ;
 
+			cy_as_release_common_lock();
+
 			#ifndef WESTBRIDGE_NDEBUG
 			cy_as_hal_print_message(
 				"<6>MTP EVENT: send_object_complete\n");
@@ -246,6 +248,8 @@ static void cy_as_gadget_mtp_event_callb
 		{
 			cy_as_mtp_get_object_complete_data *get_obj_data =
 				(cy_as_mtp_get_object_complete_data *) evdata ;
+;
+			cy_as_release_common_lock();
 
 			#ifndef WESTBRIDGE_NDEBUG
 			cy_as_hal_print_message(
@@ -752,6 +756,9 @@ static int cyasgadget_queue(
 	_req->status = -EINPROGRESS;
 	_req->actual = 0;
 
+	if (as_req)
+		list_add_tail(&as_req->queue, &as_ep->queue);
+
 	spin_unlock_irqrestore(&cy_as_dev->lock, flags);
 
 	/* Call Async functions */
@@ -772,16 +779,6 @@ static int cyasgadget_queue(
 		else
 			_req->status = -EALREADY ;
 	} else if (as_ep->num == 0) {
-		/*
-		ret = cy_as_usb_write_data_async(cy_as_dev->dev_handle,
-			as_ep->num, _req->length, _req->buf, cy_false,
-			cyasgadget_setupwritecallback) ;
-
-		if (ret != CY_AS_ERROR_SUCCESS)
-			cy_as_hal_print_message("<1>_cy_as_gadget: "
-				"cy_as_usb_write_data_async failed with error "
-				"code %d\n", ret) ;
-		*/
 		if ((cy_as_dev->outsetupreq) && (_req->length)) {
 			#ifndef WESTBRIDGE_NDEBUG
 				cy_as_hal_print_message("<1>_cy_as_gadget: "
@@ -817,8 +814,7 @@ static int cyasgadget_queue(
 				"cy_as_usb_write_data_async failed with "
 				"error code %d\n", ret) ;
 		}
-
-	} else if (list_empty(&as_ep->queue)) {
+	} else { /* read function not to EP 0*/
 		#ifndef WESTBRIDGE_NDEBUG
 			cy_as_hal_print_message("<1>_cy_as_gadget: "
 				"cy_as_usb_read_data_async being called since "
@@ -836,13 +832,6 @@ static int cyasgadget_queue(
 			_req->status = -EALREADY ;
 	}
 
-	spin_lock_irqsave(&cy_as_dev->lock, flags);
-
-	if (as_req)
-		list_add_tail(&as_req->queue, &as_ep->queue);
-
-	spin_unlock_irqrestore(&cy_as_dev->lock, flags);
-
 	return 0;
 }
 
@@ -1146,11 +1135,9 @@ static int cyasgadget_ioctl(
 			struct inode *inode = mapping->host;
 			struct inode *alloc_inode =
 				file_to_allocate->f_path.dentry->d_inode;
-			int cluster = 0;
 			uint32_t num_clusters = 0;
 			struct buffer_head bh;
 			struct kstat stat;
-			struct iattr alloc_iattr;
 			int nr_pages = 0;
 			int ret_stat = 0;
 
@@ -1158,10 +1145,10 @@ static int cyasgadget_ioctl(
 			cy_as_hal_print_message("%s: fhandle is OK, "
 				"calling vfs_getattr\n", __func__);
 			#endif
-
+			
 			ret_stat = vfs_getattr(file_to_allocate->f_path.mnt,
 				file_to_allocate->f_path.dentry, &stat);
-
+			
 			#ifndef WESTBRIDGE_NDEBUG
 			cy_as_hal_print_message("%s: returned from "
 				"vfs_getattr() stat->blksize=0x%lx\n",
@@ -1171,15 +1158,11 @@ static int cyasgadget_ioctl(
 			/* TODO:  get this from disk properties
 			 * (from blockdevice)*/
 			#define SECTOR_SIZE 512
-			if (stat.blksize != 0) {
 				num_clusters = (k_d.num_bytes) / SECTOR_SIZE;
 
-				if (((k_d.num_bytes) % SECTOR_SIZE) != 0)
+			if (((k_d.num_bytes) % SECTOR_SIZE) != 0)
 						num_clusters++;
-			} else {
-				goto initsoj_safe_exit;
-			}
-
+			
 			bh.b_state = 0;
 			bh.b_blocknr = 0;
 			/* block size is arbitrary , we'll use sector size*/
@@ -1190,42 +1173,6 @@ static int cyasgadget_ioctl(
 				"size of  %d\n", __func__,
 				num_clusters, bh.b_size);
 			#endif
-			for (cluster = 0; cluster < num_clusters; cluster++)  {
-				ret_stat = fat_get_block(inode,
-					cluster, &bh, 1);
-				if (ret_stat) {
-					cy_as_hal_print_message(
-						"%s: unable to get fat block, "
-						"ret_stat=0x%d\n",
-						__func__, ret_stat);
-					goto initsoj_safe_exit;
-				}
-			}
-
-			#ifndef WESTBRIDGE_NDEBUG
-			cy_as_hal_print_message("%s: allocated clusters "
-				"successfully (fat_get_block), check bmap..."
-				"\n", __func__);
-			#endif
-
-			alloc_iattr.ia_valid = ATTR_SIZE;
-			alloc_iattr.ia_size = k_d.num_bytes;
-
-			#ifndef WESTBRIDGE_NDEBUG
-			cy_as_hal_print_message("%s: calling fat_notify_change "
-				"(ia_valid:%d, ia_size:%d)\n", __func__,
-				alloc_iattr.ia_valid,
-				(int)alloc_iattr.ia_size);
-			#endif
-
-			/* adjust the filesize */
-			ret_stat = alloc_inode->i_op->setattr(
-				file_to_allocate->f_path.dentry, &alloc_iattr);
-			#ifndef WESTBRIDGE_NDEBUG
-			cy_as_hal_print_message("%s: fat_setattr() "
-				"returned 0x%x\n",
-				__func__, ret_stat);
-			#endif
 
 			/* clear dirty pages in page cache
 			 * (if were any allocated) */
@@ -1246,7 +1193,7 @@ static int cyasgadget_ioctl(
 					"mpage_cleardirty() "
 					"for %d pages\n", __func__, nr_pages);
 			#endif
-
+			
 			ret_stat = mpage_cleardirty(mapping, nr_pages);
 
 			/*fill up the the block table from the addr mapping  */
@@ -1363,6 +1310,9 @@ static int cyasgadget_ioctl(
 				__func__);
 			#endif
 			sg_init_one(&sg, &blk_table, sizeof(blk_table));
+
+			cy_as_acquire_common_lock();
+
 			ret_stat = cy_as_mtp_init_send_object(dev->dev_handle,
 				(cy_as_mtp_block_table *)&sg,
 				k_d.num_bytes, 0, 0);
@@ -1379,7 +1329,6 @@ static int cyasgadget_ioctl(
 				__func__, alloc_filename);
 		} /* end if (file_to_allocate)*/
 		#endif
-initsoj_safe_exit:
 			ret_stat = 0;
 			retval = __put_user(ret_stat,
 				(uint32_t __user *)(&(usr_d->ret_val)));
@@ -1541,6 +1490,8 @@ initsoj_safe_exit:
 				k_d.num_bytes);
 			#endif
 
+			cy_as_acquire_common_lock();
+
 			ret_stat = cy_as_mtp_init_get_object(
 				dev->dev_handle,
 				(cy_as_mtp_block_table *)&sg,
@@ -2151,7 +2102,21 @@ static int cyasgadget_initialize(void)
 	/*strcpy(cy_as_dev->gadget.dev.bus_id, "cyasgadget");*/
 	cy_as_dev->gadget.dev.release = cyas_gadget_release;
 	cy_as_dev->gadget.name = cy_as_driver_name;
-
+	
+	/* this "gadget" abstracts/virtualizes the controller */
+	dev_set_name(&cy_as_dev->gadget.dev, "cyas" );
+	cy_as_dev->gadget.dev.parent = cy_as_dev->cy_controller;
+
+	retval = device_register(&cy_as_dev->gadget.dev);
+	if (retval != 0) {
+		cy_as_hal_print_message( "%s: can not register device\n", __func__) ;
+		return retval;
+	}
+	#ifndef WESTBRIDGE_NDEBUG
+	else
+		cy_as_hal_print_message( "%s: successfully registered device\n", __func__) ;
+	#endif
+	
 	/* Get the device handle */
 	cy_as_dev->dev_handle = cyasdevice_getdevhandle() ;
 	if (0 == cy_as_dev->dev_handle) {
drivers/staging/westbridge/astoria/gadget/cyasgadget.h +3 -1
diff -uprN -X linux-next-vanilla/Documentation/dontdiff linux-next-vanilla/drivers/staging/westbridge/astoria/gadget/cyasgadget.h linux-next-incl-sdk/drivers/staging/westbridge/astoria/gadget/cyasgadget.h
@@ -83,8 +83,9 @@
 #include <linux/uaccess.h>	/* copy_*_user */
 
 extern int mpage_cleardirty(struct address_space *mapping, int num_pages);
-extern int fat_get_block(struct inode *, sector_t , struct buffer_head *, int);
 extern cy_as_device_handle *cyasdevice_getdevhandle(void) ;
+extern void cy_as_acquire_common_lock(void);
+extern void cy_as_release_common_lock(void);
 
 /* Driver data structures and utilities */
 typedef struct cyasgadget_ep {
@@ -119,6 +120,7 @@ typedef struct cyasgadget {
 	struct usb_gadget			gadget;
 	spinlock_t					lock;
 	struct cyasgadget_ep		an_gadget_ep[16];
+	struct device			*cy_controller;
 	struct usb_gadget_driver	 *driver;
 	/* Handle to the West Bridge device */
 	cy_as_device_handle			dev_handle;
fs/mpage.c +46 -0

49 lines not on this page · raw message

---------------------------------------------------------------
This message and any attachments may contain Cypress (or its subsidiaries) confidential information. If it has been received in error, please advise the sender and immediately delete this message.
---------------------------------------------------------------

#10 lore raw

Re: [PATCH] West Bridge Astoria Driver 2.6.35, cyasgadget fixes and mpage_cleardirty

Quoted 3 lines · David Cross

This patch contains update to the gadget driver, some of which are based on feedback from the Linux community concerning the usage of fat_get_block. It also contains the addition of mpage_clear_dirty, a function used to clear dirty pages from the page cache. These two patches are also interdependent and difficult to separate. As such, they are included as one patch.

Please wrap your lines at 72 columns.

And is this really hard to separate? I can't take a patch that touches anything outside of drivers/staging/ at the moment.

How about a patch here to fix up the locking issues, and the rest as a separate patch?

Oh, you also added lines with trailing spaces and that's it, like the following:

drivers/staging/westbridge/astoria/gadget/cyasgadget.c static int cyasgadget_ioctl( · line 1154

Quoted 13 lines
drivers/staging/westbridge/astoria/gadget/cyasgadget.c +2 -2
@@ -1158,10 +1145,10 @@ static int cyasgadget_ioctl(
 			cy_as_hal_print_message("%s: fhandle is OK, "
 				"calling vfs_getattr\n", __func__);
 			#endif
-
+			
 			ret_stat = vfs_getattr(file_to_allocate->f_path.mnt,
 				file_to_allocate->f_path.dentry, &stat);
-
+			
 			#ifndef WESTBRIDGE_NDEBUG
 			cy_as_hal_print_message("%s: returned from "
 				"vfs_getattr() stat->blksize=0x%lx\n",

Why? I think you might want to make sure your editor doesn't do this in the future.

Also, if you ran your patch through the scripts/checkpatch.pl script, it would have caught this error.

Care to redo it?

thanks,

greg k-h

#11 lore raw

Re: [PATCH] West Bridge Astoria Driver 2.6.35, minor block and device driver updates

In reply to David Cross

This patch contains minor updates to the west bridge block and device drivers, including the addition of a common lock and a minor update to remove the blk_fs_request call based on a kernel update. These changes could possibly be separated, but are very minor in scope and as such have been submitted together.
Thanks,
David

drivers/staging/westbridge/astoria/block/cyasblkdev_block.c +45 -39
diff -uprN -X linux-next-vanilla/Documentation/dontdiff linux-next-vanilla/drivers/staging/westbridge/astoria/block/cyasblkdev_block.c linux-next-incl-sdk/drivers/staging/westbridge/astoria/block/cyasblkdev_block.c
@@ -389,7 +389,7 @@ int cyasblkdev_media_changed(struct gend
 	struct cyasblkdev_blk_data *bd;
 
 	#ifndef WESTBRIDGE_NDEBUG
-	cy_as_hal_print_message("cyasblkdev_media_changed() is called\n");
+	cy_as_hal_print_message(KERN_INFO"cyasblkdev_media_changed() is called\n");
 	#endif
 
 	if (gd)
@@ -466,7 +466,7 @@ static int cyasblkdev_blk_prep_rq(
 
 	/* Check for excessive requests.*/
 	if (blk_rq_pos(req) + blk_rq_sectors(req) > get_capacity(req->rq_disk)) {
-		cy_as_hal_print_message("cyasblkdev: bad request address\n");
+		cy_as_hal_print_message(KERN_INFO"cyasblkdev: bad request address\n");
 		stat = BLKPREP_KILL;
 	}
 
@@ -493,7 +493,7 @@ static void cyasblkdev_issuecallback(
 {
 	int retry_cnt = 0;
 	DBGPRN_FUNC_NAME;
-
+	
 	if (status != CY_AS_ERROR_SUCCESS) {
 		#ifndef WESTBRIDGE_NDEBUG
 		cy_as_hal_print_message(
@@ -509,7 +509,10 @@ static void cyasblkdev_issuecallback(
 		__func__, (unsigned int) gl_bd->queue.req, status,
 		(unsigned int) blk_rq_sectors(gl_bd->queue.req)) ;
 	#endif
-
+	
+	if(rq_data_dir(gl_bd->queue.req) != READ) {
+		cy_as_release_common_lock();
+	}
 	/* note: blk_end_request w/o __ prefix should
 	 * not require spinlocks on the queue*/
 	while (blk_end_request(gl_bd->queue.req,
@@ -533,7 +536,7 @@ static void cyasblkdev_issuecallback(
 		/* queue is not plugged */
 		gl_bd->queue.req = blk_fetch_request(gl_bd->queue.queue);
 		#ifndef WESTBRIDGE_NDEBUG
-		cy_as_hal_print_message("%s blkdev_callback: "
+		cy_as_hal_print_message(KERN_INFO"%s blkdev_callback: "
 		"blk_fetch_request():%p\n",
 			__func__, gl_bd->queue.req);
 		#endif
@@ -543,7 +546,7 @@ static void cyasblkdev_issuecallback(
 		spin_unlock_irq(&gl_bd->lock);
 
 		#ifndef WESTBRIDGE_NDEBUG
-		cy_as_hal_print_message("%s blkdev_callback: about to "
+		cy_as_hal_print_message(KERN_INFO"%s blkdev_callback: about to "
 		"call issue_fn:%p\n", __func__, gl_bd->queue.req);
 		#endif
 
@@ -585,7 +588,7 @@ static int cyasblkdev_blk_issue_rq(
 		lcl_unit_no = gl_bd->user_disk_0_unit_no;
 
 		#ifndef WESTBRIDGE_NDEBUG
-		cy_as_hal_print_message("%s: request made to disk 0 "
+		cy_as_hal_print_message(KERN_INFO"%s: request made to disk 0 "
 			"for sector=%d, num_sectors=%d, unit_no=%d\n",
 			__func__, req_sector, (int) blk_rq_sectors(req),
 			lcl_unit_no);
@@ -598,7 +601,7 @@ static int cyasblkdev_blk_issue_rq(
 		lcl_unit_no = gl_bd->user_disk_1_unit_no;
 
 		#ifndef WESTBRIDGE_NDEBUG
-		cy_as_hal_print_message("%s: request made to disk 1 for "
+		cy_as_hal_print_message(KERN_INFO"%s: request made to disk 1 for "
 			"sector=%d, num_sectors=%d, unit_no=%d\n", __func__,
 			req_sector, (int) blk_rq_sectors(req), lcl_unit_no);
 		#endif
@@ -609,7 +612,7 @@ static int cyasblkdev_blk_issue_rq(
 		lcl_unit_no = gl_bd->system_disk_unit_no;
 
 		#ifndef WESTBRIDGE_NDEBUG
-		cy_as_hal_print_message("%s: request made to system disk "
+		cy_as_hal_print_message(KERN_INFO"%s: request made to system disk "
 			"for sector=%d, num_sectors=%d, unit_no=%d\n", __func__,
 			req_sector, (int) blk_rq_sectors(req), lcl_unit_no);
 		#endif
@@ -625,7 +628,7 @@ static int cyasblkdev_blk_issue_rq(
 
 	if (rq_data_dir(req) == READ) {
 		#ifndef WESTBRIDGE_NDEBUG
-		cy_as_hal_print_message("%s: calling readasync() "
+		cy_as_hal_print_message(KERN_INFO"%s: calling readasync() "
 			"req_sector=0x%x, req_nr_sectors=0x%x, bd->sg:%x\n\n",
 			__func__, req_sector, req_nr_sectors, (uint32_t)bd->sg);
 		#endif
@@ -636,10 +639,10 @@ static int cyasblkdev_blk_issue_rq(
 
 		if (ret != CY_AS_ERROR_SUCCESS) {
 			#ifndef WESTBRIDGE_NDEBUG
-			cy_as_hal_print_message("%s:readasync() error %d at "
+			cy_as_hal_print_message(KERN_INFO"%s:readasync() error %d at "
 				"address %ld, unit no %d\n", __func__, ret,
 				blk_rq_pos(req), lcl_unit_no);
-			cy_as_hal_print_message("%s:ending i/o request "
+			cy_as_hal_print_message(KERN_INFO"%s:ending i/o request "
 				"on reg:%x\n", __func__, (uint32_t)req);
 			#endif
 
@@ -651,13 +654,14 @@ static int cyasblkdev_blk_issue_rq(
 			bq->req = NULL ;
 		}
 	} else {
+		cy_as_acquire_common_lock();
 		ret = cy_as_storage_write_async(bd->dev_handle, bus_num, 0,
 			lcl_unit_no, req_sector, bd->sg, req_nr_sectors,
 			(cy_as_storage_callback)cyasblkdev_issuecallback);
 
 		if (ret != CY_AS_ERROR_SUCCESS) {
 			#ifndef WESTBRIDGE_NDEBUG
-			cy_as_hal_print_message("%s: write failed with "
+			cy_as_hal_print_message(KERN_INFO"%s: write failed with "
 			"error %d at address %ld, unit no %d\n",
 			__func__, ret, blk_rq_pos(req), lcl_unit_no);
 			#endif
@@ -690,7 +694,7 @@ static void cyasblkdev_storage_callback(
 					)
 {
 	#ifndef WESTBRIDGE_NDEBUG
-	cy_as_hal_print_message("%s: bus:%d, device:%d, evtype:%d, "
+	cy_as_hal_print_message(KERN_INFO"%s: bus:%d, device:%d, evtype:%d, "
 	"evdata:%p\n ", __func__, bus, device, evtype, evdata);
 	#endif
 
@@ -746,7 +750,7 @@ uint32_t cyasblkdev_get_vfat_offset(int 
 
 	for (sect_no = 0; sect_no < SECTORS_TO_SCAN; sect_no++) {
 		#ifndef WESTBRIDGE_NDEBUG
-		cy_as_hal_print_message("%s before cyasstorageread "
+		cy_as_hal_print_message(KERN_INFO"%s before cyasstorageread "
 			"gl_bd->sg addr=0x%x\n", __func__,
 			(unsigned int) gl_bd->sg);
 		#endif
@@ -787,8 +791,8 @@ uint32_t cyasblkdev_get_vfat_offset(int 
 
 		if (stat != 0) {
 			#ifndef WESTBRIDGE_NDEBUG
-			cy_as_hal_print_message("%s sector scan error\n",
-				__func__);
+			cy_as_hal_print_message(KERN_INFO"%s sector scan error: %d\n",
+				__func__, stat);
 			#endif
 			break;
 		}
@@ -821,7 +825,7 @@ static int cyasblkdev_add_disks(int bus_
 	cy_as_storage_query_unit_data unit_data = {0} ;
 
 	#ifndef WESTBRIDGE_NDEBUG
-		cy_as_hal_print_message("%s:query device: "
+		cy_as_hal_print_message(KERN_INFO"%s:query device: "
 		"type:%d, removable:%d, writable:%d, "
 		"blksize %d, units:%d, locked:%d, "
 		"erase_sz:%d\n",
@@ -846,7 +850,7 @@ static int cyasblkdev_add_disks(int bus_
 			bd->dev_handle, bus_num, 0, 0, 0) ;
 		if (ret != CY_AS_ERROR_SUCCESS) {
 			#ifndef WESTBRIDGE_NDEBUG
-			cy_as_hal_print_message("%s cannot release"
+			cy_as_hal_print_message(KERN_INFO"%s cannot release"
 				" storage\n", __func__) ;
 			#endif
 			goto out;
@@ -861,7 +865,7 @@ static int cyasblkdev_add_disks(int bus_
 		&unit_data, 0, 0) ;
 	if (ret != CY_AS_ERROR_SUCCESS) {
 		#ifndef WESTBRIDGE_NDEBUG
-		cy_as_hal_print_message("%s: cannot query "
+		cy_as_hal_print_message(KERN_INFO"%s: cannot query "
 			"%d device unit - reason code %d\n",
 			__func__, bus_num, ret) ;
 		#endif
@@ -876,7 +880,7 @@ static int cyasblkdev_add_disks(int bus_
 			if ((ret != CY_AS_ERROR_SUCCESS) &&
 			(ret != CY_AS_ERROR_ALREADY_PARTITIONED)) {
 			#ifndef WESTBRIDGE_NDEBUG
-				cy_as_hal_print_message("%s: cy_as_storage_"
+				cy_as_hal_print_message(KERN_INFO"%s: cy_as_storage_"
 				"create_p_partition after size > 0 check "
 				"failed with error code %d\n",
 				__func__, ret);
@@ -976,7 +980,7 @@ static int cyasblkdev_add_disks(int bus_
 					}
 				} else {
 					#ifndef WESTBRIDGE_NDEBUG
-					cy_as_hal_print_message("%s: partition "
+					cy_as_hal_print_message(KERN_INFO"%s: partition "
 						"exists and sizes equal\n",
 						__func__);
 					#endif
@@ -1054,13 +1058,13 @@ static int cyasblkdev_add_disks(int bus_
 		#endif
 
 		#ifndef WESTBRIDGE_NDEBUG
-		cy_as_hal_print_message("%s: setting gendisk disk "
+		cy_as_hal_print_message(KERN_INFO"%s: setting gendisk disk "
 			"capacity to %d\n", __func__, (int) disk_cap);
 		#endif
 
 		/* initializing bd->queue */
 		#ifndef WESTBRIDGE_NDEBUG
-		cy_as_hal_print_message("%s: init bd->queue\n",
+		cy_as_hal_print_message(KERN_INFO"%s: init bd->queue\n",
 			__func__);
 		#endif
 
@@ -1111,7 +1115,8 @@ static int cyasblkdev_add_disks(int bus_
 		 * public partition beginning */
 		if (vfat_search) {
 			bd->user_disk_0_first_sector =
-				cyasblkdev_get_vfat_offset(0,
+				cyasblkdev_get_vfat_offset(
+					bd->user_disk_0_bus_num,
 					bd->user_disk_0_unit_no);
 		} else {
 			bd->user_disk_0_first_sector = 0;
@@ -1244,7 +1249,8 @@ static int cyasblkdev_add_disks(int bus_
 		if (vfat_search) {
 			bd->user_disk_1_first_sector =
 				cyasblkdev_get_vfat_offset(
-					1, bd->user_disk_1_unit_no);
+					bd->user_disk_1_bus_num,
+					bd->user_disk_1_unit_no);
 		} else {
 			bd->user_disk_1_first_sector
 				= 0;
@@ -1342,7 +1348,7 @@ static struct cyasblkdev_blk_data *cyasb
 		}
 
 		#ifndef WESTBRIDGE_NDEBUG
-		cy_as_hal_print_message("%s west bridge device handle:%x\n",
+		cy_as_hal_print_message(KERN_INFO"%s west bridge device handle:%x\n",
 			__func__, (uint32_t)bd->dev_handle);
 		#endif
 
@@ -1356,7 +1362,7 @@ static struct cyasblkdev_blk_data *cyasb
 		if ((stat != CY_AS_ERROR_SUCCESS) &&
 		(stat != CY_AS_ERROR_RESOURCE_NOT_OWNED)) {
 			#ifndef WESTBRIDGE_NDEBUG
-			cy_as_hal_print_message("%s: cannot release "
+			cy_as_hal_print_message(KERN_INFO"%s: cannot release "
 				"resource bus 0 - reason code %d\n",
 				__func__, stat) ;
 			#endif
@@ -1366,7 +1372,7 @@ static struct cyasblkdev_blk_data *cyasb
 		if ((stat != CY_AS_ERROR_SUCCESS) &&
 		(stat != CY_AS_ERROR_RESOURCE_NOT_OWNED)) {
 			#ifndef WESTBRIDGE_NDEBUG
-			cy_as_hal_print_message("%s: cannot release "
+			cy_as_hal_print_message(KERN_INFO"%s: cannot release "
 				"resource bus 0 - reason code %d\n",
 				__func__, stat) ;
 			#endif
@@ -1376,14 +1382,14 @@ static struct cyasblkdev_blk_data *cyasb
 		stat = cy_as_storage_start(bd->dev_handle, 0, 0x101) ;
 		if (stat != CY_AS_ERROR_SUCCESS) {
 			#ifndef WESTBRIDGE_NDEBUG
-			cy_as_hal_print_message("%s: cannot start storage "
+			cy_as_hal_print_message(KERN_INFO"%s: cannot start storage "
 				"stack - reason code %d\n", __func__, stat) ;
 			#endif
 			goto out;
 		}
 
 		#ifndef WESTBRIDGE_NDEBUG
-		cy_as_hal_print_message("%s: storage started:%d ok\n",
+		cy_as_hal_print_message(KERN_INFO"%s: storage started:%d ok\n",
 			__func__, stat);
 		#endif
 
@@ -1391,7 +1397,7 @@ static struct cyasblkdev_blk_data *cyasb
 			cyasblkdev_storage_callback);
 		if (stat != CY_AS_ERROR_SUCCESS) {
 			#ifndef WESTBRIDGE_NDEBUG
-			cy_as_hal_print_message("%s: cannot register callback "
+			cy_as_hal_print_message(KERN_INFO"%s: cannot register callback "
 				"- reason code %d\n", __func__, stat) ;
 			#endif
 			goto out;
@@ -1405,7 +1411,7 @@ static struct cyasblkdev_blk_data *cyasb
 					bd->media_count[bus_num];
 			} else {
 				#ifndef WESTBRIDGE_NDEBUG
-				cy_as_hal_print_message("%s: cannot query %d, "
+				cy_as_hal_print_message(KERN_INFO"%s: cannot query %d, "
 					"reason code: %d\n",
 					__func__, bus_num, stat) ;
 				#endif
@@ -1433,7 +1439,7 @@ static struct cyasblkdev_blk_data *cyasb
 			}
 			#ifndef WESTBRIDGE_NDEBUG
 			else {
-				cy_as_hal_print_message("%s: no available "
+				cy_as_hal_print_message(KERN_INFO"%s: no available "
 					"gen_disk for disk 0, "
 					"physically inconsistent\n", __func__);
 			}
@@ -1453,7 +1459,7 @@ static struct cyasblkdev_blk_data *cyasb
 			}
 			#ifndef WESTBRIDGE_NDEBUG
 			else {
-				cy_as_hal_print_message("%s: no available "
+				cy_as_hal_print_message(KERN_INFO"%s: no available "
 					"gen_disk for media, "
 					"physically inconsistent\n", __func__);
 			}
@@ -1461,13 +1467,13 @@ static struct cyasblkdev_blk_data *cyasb
 		}
 		#ifndef WESTBRIDGE_NDEBUG
 		else if (total_media_count > 2) {
-			cy_as_hal_print_message("%s: count corrupted = 0x%d\n",
+			cy_as_hal_print_message(KERN_INFO"%s: count corrupted = 0x%d\n",
 				__func__, total_media_count);
 		}
 		#endif
 
 		#ifndef WESTBRIDGE_NDEBUG
-		cy_as_hal_print_message("%s: %d device(s) found\n",
+		cy_as_hal_print_message(KERN_INFO"%s: %d device(s) found\n",
 			__func__, total_media_count) ;
 		#endif
 
@@ -1476,7 +1482,7 @@ static struct cyasblkdev_blk_data *cyasb
 			stat = cy_as_storage_claim(bd->dev_handle,
 				bus_num, 0, 0, 0) ;
 			if (stat != CY_AS_ERROR_SUCCESS) {
-				cy_as_hal_print_message("%s: cannot claim "
+				cy_as_hal_print_message(KERN_INFO"%s: cannot claim "
 					"%d bus - reason code %d\n",
 					__func__, bus_num, stat) ;
 				goto out;
@@ -1570,7 +1576,7 @@ static int __init cyasblkdev_blk_init(vo
 		return 0;
 
 	#ifndef WESTBRIDGE_NDEBUG
-	cy_as_hal_print_message("cyasblkdev init error:%d\n", res);
+	cy_as_hal_print_message(KERN_INFO"cyasblkdev init error:%d\n", res);
 	#endif
 	return res;
 }
drivers/staging/westbridge/astoria/block/cyasblkdev_queue.c +6 -6
diff -uprN -X linux-next-vanilla/Documentation/dontdiff linux-next-vanilla/drivers/staging/westbridge/astoria/block/cyasblkdev_queue.c linux-next-incl-sdk/drivers/staging/westbridge/astoria/block/cyasblkdev_queue.c
@@ -95,9 +95,9 @@ static int cyasblkdev_prep_request(
 	DBGPRN_FUNC_NAME;
 
 	/* we only like normal block requests.*/
-	if (!blk_fs_request(req)) {
+	if (req->cmd_type != REQ_TYPE_FS && !(req->cmd_flags & REQ_DISCARD)) {
 		#ifndef WESTBRIDGE_NDEBUG
-		cy_as_hal_print_message("%s:%x bad request received\n",
+		cy_as_hal_print_message(KERN_INFO"%s:%x bad request received\n",
 			__func__, current->pid) ;
 		#endif
 
@@ -192,7 +192,7 @@ static int cyasblkdev_queue_thread(void 
 				"thread_sem->count=%d\n",
 				__func__, bq->thread_sem.count);
 			if (spin_is_locked(q->queue_lock)) {
-				cy_as_hal_print_message("%s: queue_lock "
+				cy_as_hal_print_message(KERN_INFO"%s: queue_lock "
 				"is locked, need to release\n", __func__);
 				spin_unlock(q->queue_lock);
 
@@ -249,7 +249,7 @@ static int cyasblkdev_queue_thread(void 
 	complete_and_exit(&bq->thread_complete, 0);
 
 	#ifndef WESTBRIDGE_NDEBUG
-	cy_as_hal_print_message("%s: is finished\n", __func__) ;
+	cy_as_hal_print_message(KERN_INFO"%s: is finished\n", __func__) ;
 	#endif
 
 	return 0;
@@ -274,7 +274,7 @@ static void cyasblkdev_request(struct re
 
 	if (!bq->req) {
 		#ifndef WESTBRIDGE_NDEBUG
-		cy_as_hal_print_message("%s wake_up(&bq->thread_wq)\n",
+		cy_as_hal_print_message(KERN_INFO"%s wake_up(&bq->thread_wq)\n",
 			__func__);
 		#endif
 
@@ -282,7 +282,7 @@ static void cyasblkdev_request(struct re
 		wake_up(&bq->thread_wq);
 	} else {
 		#ifndef WESTBRIDGE_NDEBUG
-		cy_as_hal_print_message("%s: don't wake Q_thr, bq->req:%x\n",
+		cy_as_hal_print_message(KERN_INFO"%s: don't wake Q_thr, bq->req:%x\n",
 			__func__, (uint32_t)bq->req);
 		#endif
 	}
drivers/staging/westbridge/astoria/block/cyasblkdev_queue.h +2 -0
diff -uprN -X linux-next-vanilla/Documentation/dontdiff linux-next-vanilla/drivers/staging/westbridge/astoria/block/cyasblkdev_queue.h linux-next-incl-sdk/drivers/staging/westbridge/astoria/block/cyasblkdev_queue.h
@@ -54,6 +54,8 @@ extern int cyasblkdev_init_queue(struct 
 extern void cyasblkdev_cleanup_queue(struct cyasblkdev_queue *);
 extern void cyasblkdev_queue_suspend(struct cyasblkdev_queue *);
 extern void cyasblkdev_queue_resume(struct cyasblkdev_queue *);
+extern void cy_as_acquire_common_lock(void);
+extern void cy_as_release_common_lock(void);
 
 extern cy_as_device_handle cyasdevice_getdevhandle(void) ;
 #define MOD_LOGS 1
drivers/staging/westbridge/astoria/device/cyasdevice.c +53 -5

106 lines not on this page · raw message

---------------------------------------------------------------
This message and any attachments may contain Cypress (or its subsidiaries) confidential information. If it has been received in error, please advise the sender and immediately delete this message.
---------------------------------------------------------------

#12 lore raw

Re: [PATCH] West Bridge Astoria Driver 2.6.35, minor block and device driver updates

Quoted 5 lines · David Cross

This patch contains minor updates to the west bridge block and device drivers, including the addition of a common lock and a minor update to remove the blk_fs_request call based on a kernel update. These changes could possibly be separated, but are very minor in scope and as such have been submitted together.

Again, one patch per logical change please. That's the way patches for the kernel work. So can you please separate these and resend them?

drivers/staging/westbridge/astoria/block/cyasblkdev_block.c int cyasblkdev_media_changed(struct gend · line 392

Quoted 11 lines

diff -uprN -X linux-next-vanilla/Documentation/dontdiff linux-next-vanilla/drivers/staging/westbridge/astoria/block/cyasblkdev_block.c linux-next-incl-sdk/drivers/staging/westbridge/astoria/block/cyasblkdev_block.c

drivers/staging/westbridge/astoria/block/cyasblkdev_block.c +1 -1
@@ -389,7 +389,7 @@ int cyasblkdev_media_changed(struct gend
 	struct cyasblkdev_blk_data *bd;
 
 	#ifndef WESTBRIDGE_NDEBUG
-	cy_as_hal_print_message("cyasblkdev_media_changed() is called\n");
+	cy_as_hal_print_message(KERN_INFO"cyasblkdev_media_changed() is called\n");

Ick. How about a ' ' after KERN_INFO? And do you really always want to do this? You can enable tracing to get this type of info.

drivers/staging/westbridge/astoria/block/cyasblkdev_block.c int cyasblkdev_media_changed(struct gend · line 393

Quoted 1 line
drivers/staging/westbridge/astoria/block/cyasblkdev_block.c +0 -0
 	#endif

The whole NDEBUG stuff should be removed from the .c files and put in the .h file if it's really needed.

drivers/staging/westbridge/astoria/block/cyasblkdev_block.c static void cyasblkdev_issuecallback( · line 499

Quoted 9 lines
drivers/staging/westbridge/astoria/block/cyasblkdev_block.c +1 -1
@@ -493,7 +493,7 @@ static void cyasblkdev_issuecallback(
 {
 	int retry_cnt = 0;
 	DBGPRN_FUNC_NAME;
-
+	
 	if (status != CY_AS_ERROR_SUCCESS) {
 		#ifndef WESTBRIDGE_NDEBUG
 		cy_as_hal_print_message(

You added a line of trailing spaces for no good reason :(

drivers/staging/westbridge/astoria/block/cyasblkdev_block.c static void cyasblkdev_issuecallback( · line 515

Quoted 9 lines
drivers/staging/westbridge/astoria/block/cyasblkdev_block.c +4 -1
@@ -509,7 +509,10 @@ static void cyasblkdev_issuecallback(
 		__func__, (unsigned int) gl_bd->queue.req, status,
 		(unsigned int) blk_rq_sectors(gl_bd->queue.req)) ;
 	#endif
-
+	
+	if(rq_data_dir(gl_bd->queue.req) != READ) {
+		cy_as_release_common_lock();
+	}

No need for the extra {}, please take a look at Documentation/CodingStyle for how to do things for the kernel. Also a space is needed after the 'if'.

Please run your patches through the scripts/checkpatch.pl tool before sending them to me. Yes, there's lots of checkpatch issues in the driver already, but don't add new ones now please.

Care to redo this?

thanks,

greg k-h