[U-Boot] uboot for vexpress-a15x2

2012-07-04 Thread Xiao Jiang

Hello,

Since vexpress-a15x2 and vexpress-a9x4 share same motherboard, I guess 
the two boards

can be supported with same uboot, does someone can confirm it? thanks.

Regards,
Xiao

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] cm-t35: fix incorrect NAND_ECC layout selection

2012-07-04 Thread Nikita Kiryanov

On 07/02/2012 07:06 PM, Tom Rini wrote:

On Mon, Jul 02, 2012 at 03:27:59PM +0300, Nikita Kiryanov wrote:


The current configuration selects an incorrect NAND ECC layout,
which causes u-boot to write HW ECC data incorrectly.
This patch selects the right layout.

Signed-off-by: Nikita Kiryanov 


This change is correct on all boards and not due to a change in NAND
parts used in newer revisions or anything, correct?



Yes. All our boards have 8 bit NAND chips.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/7] dfu:usb: Support for g_dnl composite download gadget.

2012-07-04 Thread Lukasz Majewski
Hi Marek,

Thanks for review.

> Dear Lukasz Majewski,
> 
> > Composite USB download gadget support (g_dnl) for download
> > functions. This code works on top of composite gadget.
> > 
> > Signed-off-by: Lukasz Majewski 
> > Signed-off-by: Kyungmin Park 
> > Cc: Marek Vasut 
> > ---
> >  drivers/usb/gadget/Makefile |1 +
> >  drivers/usb/gadget/g_dnl.c  |  235
> > +++
> > include/g_dnl.h | 33 ++
> >  3 files changed, 269 insertions(+), 0 deletions(-)
> >  create mode 100644 drivers/usb/gadget/g_dnl.c
> >  create mode 100644 include/g_dnl.h
> > 
> > diff --git a/drivers/usb/gadget/Makefile
> > b/drivers/usb/gadget/Makefile index 87d1918..2c067c8 100644
> > --- a/drivers/usb/gadget/Makefile
> > +++ b/drivers/usb/gadget/Makefile
> > @@ -29,6 +29,7 @@ LIB   := $(obj)libusb_gadget.o
> >  ifdef CONFIG_USB_GADGET
> >  COBJS-y += epautoconf.o config.o usbstring.o
> >  COBJS-$(CONFIG_USB_GADGET_S3C_UDC_OTG) += s3c_udc_otg.o
> > +COBJS-$(CONFIG_USBDOWNLOAD_GADGET) += g_dnl.o
> >  endif
> >  ifdef CONFIG_USB_ETHER
> >  COBJS-y += ether.o epautoconf.o config.o usbstring.o
> > diff --git a/drivers/usb/gadget/g_dnl.c b/drivers/usb/gadget/g_dnl.c
> > new file mode 100644
> > index 000..7925d0e
> > --- /dev/null
> > +++ b/drivers/usb/gadget/g_dnl.c
> > @@ -0,0 +1,235 @@
> > +/*
> > + * g_dnl.c -- USB Downloader Gadget
> > + *
> > + * Copyright (C) 2012 Samsung Electronics
> > + * Lukasz Majewski  
> > + *
> > + * 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., 59 Temple Place, Suite 330, Boston, MA
> > 02111-1307 USA + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include 
> > +#include 
> > +
> > +#include 
> > +#include "f_dfu.h"
> > +
> > +#include "gadget_chips.h"
> > +#include "composite.c"
> > +
> > +/* Samsung's IDs */
> > +#define DRIVER_VENDOR_NUM 0x04E8
> > +#define DRIVER_PRODUCT_NUM 0x6601
> 
> Is it samsung specific? Or can we use some USB IDs that are not bound
> to samsung?

I think, that those IDs shall be defined at include/configs/.h
In that way one can use any ID.

> 
> > +#define STRING_MANUFACTURER 25
> > +#define STRING_PRODUCT 2
> > +#define STRING_USBDOWN 2
> > +#define CONFIG_USBDOWNLOADER 2
> > +
> > +#define DRIVER_VERSION "usb_dnl 2.0"
> > +
> > +static const char shortname[] = "usb_dnl_";
> > +static const char product[] = "SLP USB download gadget";
> > +static const char manufacturer[] = "Samsung";
> 
> DITTO?

Manufacturer field can be either omitted or changed to other name.

> 
> > +
> > +static struct usb_device_descriptor device_desc = {
> > +   .bLength =  sizeof device_desc,
> > +   .bDescriptorType =  USB_DT_DEVICE,
> > +
> > +   .bcdUSB =   __constant_cpu_to_le16(0x0200),
> > +   .bDeviceClass = USB_CLASS_COMM,
> > +   .bDeviceSubClass =  0x02,   /*0x02:CDC-modem ,
> > 0x00:CDC-serial*/ +
> > +   .idVendor =
> > __constant_cpu_to_le16(DRIVER_VENDOR_NUM),
> > +   .idProduct =
> > __constant_cpu_to_le16(DRIVER_PRODUCT_NUM),
> > +   .iProduct = STRING_PRODUCT,
> > +   .bNumConfigurations =   1,
> > +};
> > +
> > +static const struct usb_descriptor_header *otg_desc[] = {
> > +   (struct usb_descriptor_header *) &(struct
> > usb_otg_descriptor){
> > +   .bLength =  sizeof(struct
> > usb_otg_descriptor),
> > +   .bDescriptorType =  USB_DT_OTG,
> > +   .bmAttributes = USB_OTG_SRP,
> > +   },
> > +   NULL,
> > +};
> > +
> > +/* static strings, in UTF-8 */
> > +static struct usb_string odin_string_defs[] = {
> > +   { 0, manufacturer, },
> > +   { 1, product, },
> > +};
> > +
> > +static struct usb_gadget_strings odin_string_tab = {
> > +   .language   = 0x0409,   /* en-us */
> > +   .strings= odin_string_defs,
> > +};
> > +
> > +static struct usb_gadget_strings *g_dnl_composite_strings[] = {
> > +   &odin_string_tab,
> > +   NULL,
> > +};
> > +
> > +static int g_dnl_unbind(struct usb_composite_dev *cdev)
> > +{
> > +   debug("%s\n", __func__);
> > +   return 0;
> > +}
> > +
> > +static int g_dnl_do_config(struct usb_configuration *c)
> > +{
> > +   int ret = -1;
> > +   char *s = (char *) c->cdev->driver->name;
> > +
> > +   debug("%s: c: 0x%p cdev: 0x%p\n", __func__,

Re: [U-Boot] [PATCH] usb_storage: fix ehci driver max transfer size

2012-07-04 Thread Stefan Herbrechtsmeier

Am 04.07.2012 08:57, schrieb Schneider, Kolja:

Am 03.07.2012 20:10, schrieb Marek Vasut:

The commit 5dd95cf93dfffa1d19a1928990852aac9f55b9d9 'usb_storage:
Fix EHCI "out of buffer pointers" with CD-ROM' introduce a bug in
usb_storage as it wrongly assumes that every transfer can use 4k
per qt_buffer. This is wrong if the start address of the data
is not 4k aligned and leads to 'EHCI timed out on TD' messages
because of 'out of buffer pointers' in ehci_td_buffer function.

Cc: Marek Vasut 
Signed-off-by: Stefan Herbrechtsmeier 

Ok, first I have to admit I broke my promise to look into this ASAP, sorry

about

it :-(

No problem, as long as we get it into the next release. ;-)

Just curious, but shouldn't it be ((4096 * 5) / dev_desc->blk_sz) - 1 ?

No, because the first blk need to be aligned with the 4096. In worst
case the blk is at the end of the 4096 range. If we assume that the blk
is aligned to blk_sz we can change it to ((4096 * 4) / dev_desc->blk_sz)
+ 1. I skip the last blk (+ 1) because with 4096 aligned first blk we
unaligned the next transfer and add extra short packages to each ehci
transfer.

If we want to maximise the usage we need to calculate the max_xfer_blk
depending on the start address of the first blk.


I admit to not totally getting it. However, there are two things that come to 
my mind:
  - Doesn't the EHCI Specification mention exactly five buffers that 
can/should/must
be used?

Yes, you can use up to five 4096 byte buffers.

  - I think I once stumbled across some comment that said as much as the 
blocks
always having to be aligned anyway?
The buffers must be aligned to a 4096 byte page. This means that you 
have to use the first and last buffer to align your data to the next or 
previous 4096 byte page boundary.



___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 00/10 V6] EXYNOS5: Support for Exynos5250 Rev 1.0

2012-07-04 Thread Minkyu Kang
On 4 July 2012 15:02, Rajeshwari Shinde  wrote:
> This patch set adds support for Exynos5250 Rev 1.0.
> Exynos5250 Rev 1.0 supports DDR3 Memory configuration and
> support for LPDDR2 is removed.
> Exynos5250 Rev 1.0 supports DWMMC controller and does not support SDHCI
> controller.
> After DWMMC driver is added to Mainline support for generic S5P MMC driver
> will be removed.
>
> Due to Support of SDHCI controller currently still there for
> EXYNOS5 you can see the following error on boot.
>
> mmc_reset: timeout error
> mmc_change_clock: timeout error
> mmc_send_cmd: waiting for status update
> MMC init failed
>
> Changes in V2:
> - Included Paramateric structure with in #ifndef __ASSEMBLY__.
> Chnages in V3:
> - Incorporated the review comments.
> - Added support for BPLL.
> - Corrected the gpio pinmux settings.
> Changes in V4:
> - Fixed Warning message.
> Changes in V5:
> - Corrected indentation error.
> Changes in V6:
> - Fixed Compiler warning messages.
>
> Rajeshwari Shinde (10):
>   ARCH: SPL: Add parametric board initializer
>   SMDK5250: SPL: Define parametric board initializer
>   SMDK5250: Add smdk5250-uboot-spl.lds
>   EXYNOS5: CLOCK: define additional clock registers for Exynos5250 Rev
> 1.0
>   EXYNOS5: CLOCK: Add clock support for Exynos5250 Rev 1.0
>   Exynos5: DDR3: Add DDR3 memory setup for Exynos5250 Rev 1.0
>   EXYNOS5: CLOCK: Modify MPLL clock out for Exynos5250 Rev 1.0
>   EXYNOS5: CLOCK: Add BPLL support
>   EXYNOS5 : Modify pinnumx settings as per Exynos5250 Rev 1.0
>   SMDK5250: Enable UART and MMC for Exynos5250 Rev 1.0
>
>  arch/arm/cpu/armv7/exynos/clock.c |   28 +-
>  arch/arm/cpu/armv7/exynos/pinmux.c|   22 +-
>  arch/arm/include/asm/arch-exynos/clk.h|1 +
>  arch/arm/include/asm/arch-exynos/clock.h  |  237 +
>  arch/arm/include/asm/arch-exynos/dmc.h|   65 +++
>  arch/arm/include/asm/arch-exynos/gpio.h   |7 +-
>  arch/arm/include/asm/arch-exynos/spl.h|   97 
>  board/samsung/smdk5250/Makefile   |3 +-
>  board/samsung/smdk5250/clock_init.c   |  714 +++
>  board/samsung/smdk5250/clock_init.h   |  149 +
>  board/samsung/smdk5250/dmc_common.c   |  199 +++
>  board/samsung/smdk5250/dmc_init.c |  462 ---
>  board/samsung/smdk5250/dmc_init_ddr3.c|  228 
>  board/samsung/smdk5250/setup.h|  763 
> +++--
>  board/samsung/smdk5250/smdk5250-uboot-spl.lds |   66 +++
>  board/samsung/smdk5250/smdk5250.c |6 +-
>  board/samsung/smdk5250/smdk5250_spl.c |   68 +++
>  include/configs/smdk5250.h|7 +-
>  18 files changed, 2100 insertions(+), 1022 deletions(-)
>  create mode 100644 arch/arm/include/asm/arch-exynos/spl.h
>  create mode 100644 board/samsung/smdk5250/clock_init.h
>  create mode 100644 board/samsung/smdk5250/dmc_common.c
>  delete mode 100644 board/samsung/smdk5250/dmc_init.c
>  create mode 100644 board/samsung/smdk5250/dmc_init_ddr3.c
>  create mode 100644 board/samsung/smdk5250/smdk5250-uboot-spl.lds
>  create mode 100644 board/samsung/smdk5250/smdk5250_spl.c
>

applied to u-boot-samsung.

Thanks.
Minkyu Kang.
-- 
from. prom.
www.promsoft.net
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 12/20] arm/km: add support for external switchconfiguration

2012-07-04 Thread Detlev Zundel
Hi Valentin and Prafulla,

[...]

>> Dear Valentin
>> We must keep develop it as generic driver.
>> 
>> Regards...
>> Prafulla . . .
>> 
>
> Sure it would be great if we had the time and resources to contribute a 
> generic
> driver for these switches. Unfortunately it is not the case and we have only
> developed a simple driver with limited features that suits our current needs.
>
> Since we know it's very limited, we have intentionally chosen to put in in our
> board/keymile directory so that it's obvious that it is (currently) not 
> intended
> to be used nor was it tested on other boards or with other switches.

Personally I welcome such a driver submission to mainline as it can be a
starting point for someone else later.

> The question now is: does u-boot allow some boards (or family of boards) to
> integrate some board codes or drivers ? It was until now our understanding 
> that
> u-boot allows this. This code definitely fits into this category.

This is also my understanding and actually our source code has lots of
them and many people are thankful to find such code (if they are able to
find it ;)

> As for the generic driver, if someone contributes one (the current driver can 
> be
> used as a basis), we will be very happy to drop this code and use the generic
> driver.

Actually I would go even further and say that a generic driver can only
be started when there are at least two or more users of the code.
One should probably think about not making too many short-sighted
assumptions when working on a driver but to think that one could develop
a generic driver from one device only would be foolish.

So Prafulla, can you please reconsider to add the driver?

Thanks
  Detlev

-- 
Provide mechanism rather than policy. In particular, place user
interface policy in the clients' hands.
-- principles of X Window System
--
DENX Software Engineering GmbH,  MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: d...@denx.de
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 03/14] arm/km: convert mgcoge3un target to km_kirkwood

2012-07-04 Thread Holger Brunck
Hi Prafulla,

On 07/03/2012 04:39 PM, Prafulla Wadaskar wrote:
>> On 07/03/2012 03:07 PM, Prafulla Wadaskar wrote:
>

 But 01-08 are not only bugfixes there are also two new boards in
>> these
 patches.
 So will you pull these eight patches in if I post them again
>> without
 09-14?
>>>
>>> Pls post bug fixes and improvement patches first those will be
>> pulled faster.
>>>
>> This was already done from my side:
>> http://lists.denx.de/pipermail/u-boot/2012-May/125219.html
>>
>> Sorry Prafulla but I have admit that this whole discussion costs a lot
>> of time
>> which I do not have. We are moving in circles your last comment was
>> already
>> discussed several times e.g.:
>> http://lists.denx.de/pipermail/u-boot/2012-June/126081.html
> 
> 
> Do you think I should pull this patch series, I hope it applies cleanly on 
> the recent master branch.
> Please confirm.
> 

at time of submission it applied cleanly, now I see some merge conlicts due to
some underlying changes in boards.cfg in your current master. But if you are now
fine with the patch serie I can provide an update which applies cleanly again.

>>
>> So again you have no specific inputs of improvements for 01-08 right?
>> All you
>> rephrase are some general comments which are not very helpfull to
>> improve our
>> situation and to get our own board code into mainline.
> 
> Well.. we can keep discussing patches here until all the patches in the patch 
> series gets acked.
> This adds time/cost to the developer and reviewer too.
> My old experience tells me that shorter is simpler and easier to accept.
> 

yes I agree but if you add new boards and new features there is sometimes no
chance to make everything small and simple.

> I personally don't wish to hold any thing that sounds good to me.
> The idea is how the development can be shared across the community.
> 
> So I had certain questions in my mind about your development for which I 
> don't want any answers. You can treat them as feedback for your future 
> development.
> 
> 1. Why do you modify the board parameters so frequently? I see several 
> patches for these, cant you freeze all this well before posting board support 
> patch?
> 2. Why do you use your own keymile-common.h, can't you migrate to use 
> mv_common.h which mainly created for the same purpose?

The mentioned keymile-common.h has a completely different intention then
mv-common.h. Our header is mainly to collect all features for our boards which
are common for our ppc and arm based boards (environment variables, cmd features
etc.). And including mv-common.h into our environment for our arm based boards
was investigated. But many many features which are used in this header is not
valid for our boards, so it would end up in a big set of #ifdefs.

> 3. When you support any generic peripheral can't you think of generic use 
> case?
> 
>>
>> We try to stick to every rule which is valid for u-boot development.
>> But we
>> can't stick to rules which are not clearly stated.
> 
> You better can have your own world, and maintain the code the way you want, 
> not necessarily you need u-boot for this.
> 
> We both have different thinking hats :-D
> In your view, your code is important to get mainlined, may be you don't care 
> other things.
> In my view, how any support can be added in simpler, shorter, reusable, 
> cleaner way in-sync with development strategy. I am just trying to follow 
> this.
> I might have done mistakes, I express grand SORRY for that :-(
> 
> I am always there to help everybody with my limited resources and time.
> 

yes and I don't want to offend anybody here. At the end we should benefit from
each other. Our side that we have our boards in mainline and you and others in
the community which take advantage from the bugfixes and bug reports we provide
for common code, as already done at several places.

Regards
Holger


___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RFC][PATCH v3] net: nfs: make NFS_TIMEOUT configurable

2012-07-04 Thread Tetsuyuki Kobayashi
NFS_TIMEOUT is constant value defined in net/nfs.c. But sometimes it needs to 
adjust.
This patch enables to override NFS_TIMEOUT by defining CONFIG_NFS_TIMEOUT in a 
board specific config file.

Signed-off-by: Tetsuyuki Kobayashi 
---
Changes for v2:
   - remove a wrong #error line
Changes for v3:
   - add CONFIG_NFS_TIMEOUT after CONFIG_ARP_TIMEOUT in README file
   - align #ifndef - #else - #endif format as same as tftp.c

 README|7 +++
 net/nfs.c |6 +-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/README b/README
index 67dc444..9a18a5c 100644
--- a/README
+++ b/README
@@ -2140,6 +2140,13 @@ The following options need to be configured:
 
Timeout waiting for an ARP reply in milliseconds.
 
+   CONFIG_NFS_TIMEOUT
+
+   Timeout in milliseconds used in NFS protocol.
+   If you encounter "ERROR: Cannot umount" in nfs command,
+   try longer timeout such as
+   #define CONFIG_NFS_TIMEOUT 1UL
+
 - Command Interpreter:
CONFIG_AUTO_COMPLETE
 
diff --git a/net/nfs.c b/net/nfs.c
index 5b99763..7f2393f 100644
--- a/net/nfs.c
+++ b/net/nfs.c
@@ -31,7 +31,11 @@
 
 #define HASHES_PER_LINE 65 /* Number of "loading" hashes per line  */
 #define NFS_RETRY_COUNT 30
-#define NFS_TIMEOUT 2000UL
+#ifndef CONFIG_NFS_TIMEOUT
+# define NFS_TIMEOUT 2000UL
+#else
+# define NFS_TIMEOUT CONFIG_NFS_TIMEOUT
+#endif
 
 static int fs_mounted;
 static unsigned long rpc_id;
-- 
1.7.9.5 
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 2/7] dfu:usb: DFU USB function (f_dfu) support for g_dnl composite gadget

2012-07-04 Thread Lukasz Majewski
Hi Marek,

> Dear Lukasz Majewski,
> 
> > Support for f_dfu USB function.
> > 
> > Signed-off-by: Lukasz Majewski 
> > Signed-off-by: Kyungmin Park 
> > Cc: Marek Vasut 
> > ---
> [...]
> > +
> > +static const char dfu_name[] = "Device Firmware Upgrade";
> > +
> > +/* static strings, in UTF-8 */
> > +/*
> > + * dfu_genericiguration specific
> 
> 
> generiwhat?

Misspelled, fixed.
> 
> > + */
> > +static struct usb_string strings_dfu_generic[] = {
> > +   [0].s = dfu_name,
> > +   {  }/* end of list */
> > +};
> > +
> > +static struct usb_gadget_strings stringtab_dfu_generic = {
> > +   .language   = 0x0409,   /* en-us */
> > +   .strings= strings_dfu_generic,
> > +};
> > +
> > +static struct usb_gadget_strings *dfu_generic_strings[] = {
> > +   &stringtab_dfu_generic,
> > +   NULL,
> > +};
> > +
> > +/*
> > + * usb_function specific
> > + */
> > +static struct usb_gadget_strings stringtab_dfu = {
> > +   .language   = 0x0409,   /* en-us */
> > +   /*
> > +* .strings
> > +*
> > +* assigned during initialization,
> > +* depends on number of flash entities
> > +*
> > +*/
> > +};
> > +
> > +static struct usb_gadget_strings *dfu_strings[] = {
> > +   &stringtab_dfu,
> > +   NULL,
> > +};
> > +
> > +/*
> > -*/ +
> > +static void dnload_request_complete(struct usb_ep *ep, struct
> > usb_request *req) +{
> > +   struct f_dfu *f_dfu = req->context;
> > +
> > +   dfu_write(dfu_get_entity(f_dfu->altsetting), req->buf,
> > + req->length, f_dfu->blk_seq_num);
> > +
> > +   if (req->length == 0) {
> > +   puts("DOWNLOAD ... OK\n");
> > +   puts("Ctrl+C to exit ...\n");
> > +   }
> > +}
> > +
> > +static void handle_getstatus(struct usb_request *req)
> > +{
> > +   struct dfu_status *dstat = (struct dfu_status *)req->buf;
> > +   struct f_dfu *f_dfu = req->context;
> > +
> > +   switch (f_dfu->dfu_state) {
> > +   case DFU_STATE_dfuDNLOAD_SYNC:
> 
> What's this crazy cammel case in here ? :-)

I know, that camel case descriptions are not welcome :-),
but those are written in this way for purpose.

dfuDNLOAD_SYNC is the exact state name mentioned at DFU specification.
Other states - like dfuDNBUSY are exactly the same.

>From mine experience it is more readable. Please consider for
example the Fig. A1 - Interface state transition diagram from page 28
at DFU_1.1.pdf spec (link below).

http://www.usb.org/developers/devclass_docs/DFU_1.1.pdf

> 
> > +   case DFU_STATE_dfuDNBUSY:
> > +   f_dfu->dfu_state = DFU_STATE_dfuDNLOAD_IDLE;
> > +   break;
> > +   case DFU_STATE_dfuMANIFEST_SYNC:
> > +   break;
> > +   default:
> > +   break;
> > +   }
> > +
> > +   /* send status response */
> > +   dstat->bStatus = f_dfu->dfu_status;
> > +   /* FIXME: set dstat->bwPollTimeout */
> 
> FIXME ... so fix it ;-)
This is not u-boot related - will be removed 

> 
> > +   dstat->bState = f_dfu->dfu_state;
> > +   dstat->iString = 0;
> > +}
> > +
> > +static void handle_getstate(struct usb_request *req)
> > +{
> > +   struct f_dfu *f_dfu = req->context;
> > +
> > +   ((u8 *)req->buf)[0] = f_dfu->dfu_state & 0xff;
> 
> Now ... this is ubercrazy ... can't this be made without this
> typecasting voodoo?

The problem is that req->buf is a void pointer. And the goal is to
store dfu state at 8 bits.

> 
> > +   req->actual = sizeof(u8);
> > +}
> > +
> [...]
> > +static int handle_dnload(struct usb_gadget *gadget, u16 len)
> > +{
> > +   struct usb_composite_dev *cdev = get_gadget_data(gadget);
> > +   struct usb_request *req = cdev->req;
> > +   struct f_dfu *f_dfu = req->context;
> > +
> > +   if (len == 0)
> > +   f_dfu->dfu_state = DFU_STATE_dfuMANIFEST_SYNC;
> > +
> > +   req->complete = dnload_request_complete;
> > +
> > +   return len;
> > +}
> 
> One newline too much below.
Fixed.
> 
> > +
> > +
> > +static int
> > +dfu_handle(struct usb_function *f, const struct usb_ctrlrequest
> > *ctrl) +{
> > +   struct usb_gadget *gadget = f->config->cdev->gadget;
> > +   struct usb_request *req = f->config->cdev->req;
> > +   struct f_dfu *f_dfu = f->config->cdev->req->context;
> > +   u16 len = le16_to_cpu(ctrl->wLength);
> > +   u16 w_value = le16_to_cpu(ctrl->wValue);
> > +   int value = 0;
> > +   int standard;
> > +
> > +   standard = (ctrl->bRequestType & USB_TYPE_MASK)
> > +   ==
> > USB_TYPE_STANDARD; +
> > +   debug("w_value: 0x%x len: 0x%x\n", w_value, len);
> > +   debug("standard: 0x%x ctrl->bRequest: 0x%x
> > f_dfu->dfu_state: 0x%x\n",
> > +  standard, ctrl->bRequest, f_dfu->dfu_state);
> > +
> > +   if (!standard) {
> 
> This function doesn't fit on my screen ... that means it's wy too
> long and shall be split into more functions ;-)
> 
> That's also remove the need for your crazy conditional assignment of
> standard.

You are correct :-). I will split the if(!standard) clause 

Re: [U-Boot] [PATCH 3/7] dfu: DFU backend implementation

2012-07-04 Thread Lukasz Majewski
Hi Marek,

> Dear Lukasz Majewski,
> 
> > New, separate driver at ./drivers/dfu has been added. It allows
> > platform and storage independent operation of DFU.
> > 
> > Signed-off-by: Lukasz Majewski 
> > Signed-off-by: Kyungmin Park 
> > Cc: Marek Vasut 
> > ---
> 
> [...]
> 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +static LIST_HEAD(dfu_list);
> > +static int dfu_alt_num;
> > +
> > +static int dfu_find_alt_num(char *s)
> > +{
> > +   int i = 0;
> > +
> > +   for (; *s; s++)
> > +   if (*s == ';')
> > +   i++;
> > +
> > +   return ++i;
> > +}
> > +
> > +static char *dfu_extract_entity(char** env)
> > +{
> > +   char *s = *env;
> > +
> > +   strsep(env, ";");
> > +   return s;
> > +}
> 
> Shall we not make these all generic? They seem to be quite helpful
> components.

It is a good topic for a discussion if those functions shall be moved
to ./lib/string.c. 
I regarded them as a "little" helper functions for parsing DFU alt
setting env variable. Those are very short and build with methods
exported from string.c

> 
> > +
> > +char *dfu_extract_token(char** e, int *n)
> > +{
> > +   char *st = *e;
> > +
> > +   debug("%s: %s\n", __func__, st);
> > +
> > +   strsep(e, " ");
> > +   *n = *e - st;
> > +
> > +   return st;
> > +}
> > +
> > +static unsigned char __aligned(CONFIG_SYS_CACHELINE_SIZE)
> > +dfu_buf[DFU_DATA_BUF_SIZE];
> 
> Can we not stack-allocate it with ALLOC_CACHE_ALIGN_BUFFER()?

The dfu_buf is 4 MiB (this is the size of DFU_DATA_BUF_SIZE). I don't
think, that allocating it on the stack (for stack allocation the
ALLOC_CACHE_ALIGN_BUFFER() is designed) is a good idea.

> 
> [...]
> 
> > diff --git a/include/dfu.h b/include/dfu.h
> > new file mode 100644
> > index 000..f7d823b
> > --- /dev/null
> > +++ b/include/dfu.h
> 
> [...]
> 
> > +struct dfu_entity {
> > +   charname[DFU_NAME_SIZE];
> > +   int alt;
> > +   void*dev_private;
> > +   int dev_num;
> > +   enum dfu_device_typedev_type;
> > +   enum dfu_layout layout;
> > +
> > +   union {
> > +   struct mmc_internal_data mmc;
> 
> This union seems redundant ;-)

Good point :-), but I predict, that DFU will be used to program other
memory types (OneNAND, or NAND). To support those, one needs to extend
the union with e.g struct onenand_internal_data onenand.

Since we don't have so many memory types, I think that union usage is
acceptable. 

> 
> [...]



-- 
Best regards,

Lukasz Majewski

Samsung Poland R&D Center | Linux Platform Group
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 4/7] dfu: MMC specific routines for DFU operation

2012-07-04 Thread Lukasz Majewski
Hi Marek,

> Dear Tom Rini,
> 
> > On Tue, Jul 03, 2012 at 11:29:31PM +0200, Marek Vasut wrote:
> > > Dear Lukasz Majewski,
> > > 
> > > > Support for MMC storage devices to work with DFU framework.
> > > > 
> > > > Signed-off-by: Lukasz Majewski 
> > > > Signed-off-by: Kyungmin Park 
> > > > Cc: Marek Vasut 
> > > > ---
> > > 
> > > [...]
> > > 
> > > > +
> > > > +#include 
> > > > +#include 
> > > > +#include 
> > > > +
> > > > +int dfu_write_medium_mmc(struct dfu_entity *dfu, void *buf,
> > > > long *len) +{
> > > > +   ALLOC_CACHE_ALIGN_BUFFER(char, cmd_buf,
> > > > DFU_CMD_BUF_SIZE); +
> > > > +   memset(cmd_buf, '\0', sizeof(cmd_buf));
> > > > +
> > > > +   switch (dfu->layout) {
> > > > +   case RAW_ADDR:
> > > > +   sprintf(cmd_buf, "mmc write 0x%x %x %x",
> > > > (unsigned int) buf,
> > > > +   dfu->data.mmc.lba_start,
> > > > dfu->data.mmc.lba_size);
> > > > +   break;
> > > > +   case FAT:
> > > > +   sprintf(cmd_buf, "fatwrite mmc %d:%d 0x%x %s
> > > > %lx",
> > > > +   dfu->data.mmc.dev, dfu->data.mmc.part,
> > > > +   (unsigned int) buf, dfu->name, *len);
> > > > +   break;
> > > > +   default:
> > > > +   printf("%s: Wrong layout!\n", __func__);
> > > > +   }
> > > > +
> > > > +   debug("%s: %s 0x%p\n", __func__, cmd_buf, cmd_buf);
> > > > +   run_command(cmd_buf, 0);
> > > 
> > > Holy Moly ... can we not make this into simple calls to those
> > > subsystems ? Instead invoking command is crazy ;-)
> > 
> > Are they really simple?  There's a few other places we do this, and
> > so long as it's documented that DFU depends on CONFIG_FAT_WRITE for
> > writing to fat and so forth.
> 
> Well ain't it easier to call fat_write() or similar?
> 
I've decided to use run_command on a purpose.

This call provides clean and reliable API. It is very unlikely that the
mmc write command will change (or any
other). 
On the other hand the fields of struct mmc are changed from time to
time.

Moreover, mmc drivers are also a subject to change (like adding dw_mmc
recently).
Using run_command also takes the burden of mmc_init() related calls. 

Of course the run_command's downside is the speed of execution. But is
it so important when one considers, the firmware update? 

Side note: DFU uses only EP0 (for transfer and configuration), so this
is rather slow communication link. 

I'm open for discussion.


-- 
Best regards,

Lukasz Majewski

Samsung Poland R&D Center | Linux Platform Group
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 12/20] arm/km: add support for external switchconfiguration

2012-07-04 Thread Prafulla Wadaskar


> -Original Message-
> From: Detlev Zundel [mailto:d...@denx.de]
> Sent: 04 July 2012 13:38
> To: Valentin Longchamp
> Cc: Prafulla Wadaskar; u-boot@lists.denx.de; holger.bru...@keymile.com
> Subject: Re: [U-Boot] [PATCH 12/20] arm/km: add support for external
> switchconfiguration
> 
> Hi Valentin and Prafulla,
> 
> [...]
> 
> >> Dear Valentin
> >> We must keep develop it as generic driver.
> >>
> >> Regards...
> >> Prafulla . . .
> >>
> >
> > Sure it would be great if we had the time and resources to
> contribute a generic
> > driver for these switches. Unfortunately it is not the case and we
> have only
> > developed a simple driver with limited features that suits our
> current needs.
> >
> > Since we know it's very limited, we have intentionally chosen to put
> in in our
> > board/keymile directory so that it's obvious that it is (currently)
> not intended
> > to be used nor was it tested on other boards or with other switches.
> 
> Personally I welcome such a driver submission to mainline as it can be
> a
> starting point for someone else later.
> 
> > The question now is: does u-boot allow some boards (or family of
> boards) to
> > integrate some board codes or drivers ? It was until now our
> understanding that
> > u-boot allows this. This code definitely fits into this category.
> 
> This is also my understanding and actually our source code has lots of
> them and many people are thankful to find such code (if they are able
> to
> find it ;)
> 
> > As for the generic driver, if someone contributes one (the current
> driver can be
> > used as a basis), we will be very happy to drop this code and use
> the generic
> > driver.
> 
> Actually I would go even further and say that a generic driver can
> only
> be started when there are at least two or more users of the code.
> One should probably think about not making too many short-sighted
> assumptions when working on a driver but to think that one could
> develop
> a generic driver from one device only would be foolish.
> 
> So Prafulla, can you please reconsider to add the driver?

Hi Detlev
Clear NAK for this patch

Let's put it in drivers/net/phy/
FYI: there are several drivers used by just one board,
[prafulla@pe-dt061 u-boot-marvell.git (master)]$ vim drivers/net/phy/Makefile
[prafulla@pe-dt061 u-boot-marvell.git (master)]$ grep -Irn "CONFIG_PHY_ATHEROS" 
include/configs/*
include/configs/microblaze-generic.h:346:# define CONFIG_PHY_ATHEROS1
[prafulla@pe-dt061 u-boot-marvell.git (master)]$ vim drivers/net/phy/Makefile
[prafulla@pe-dt061 u-boot-marvell.git (master)]$ grep -Irn 
"CONFIG_PHY_BROADCOM" include/configs/*
include/configs/microblaze-generic.h:347:# define CONFIG_PHY_BROADCOM   1

Anyways peripheral driver should go in drivers/

Regards...
Prafulla . . .
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 03/14] arm/km: convert mgcoge3un target to km_kirkwood

2012-07-04 Thread Prafulla Wadaskar


> -Original Message-
> From: Wolfgang Denk [mailto:w...@denx.de]
> Sent: 03 July 2012 23:31
> To: Prafulla Wadaskar
> Cc: Holger Brunck; u-boot@lists.denx.de; Valentin Longchamp
> Subject: Re: [U-Boot] [PATCH v2 03/14] arm/km: convert mgcoge3un
> target to km_kirkwood
> 
> Dear Prafulla,
> 
> In message  VEXCH4.marvell.com> you wrote:
> >
> > Do you think I should pull this patch series, I hope it applies
> cleanly on the recent master branch.
> > Please confirm.
> 
> I have to admit that I neither reviewed the patches in question, nor
> did I follow the whole thread of communication in this patch series.
> But the general rule is that if there are no strong argumentents
> against a patch (like a clear NAK or a specific request for changes)
> we will apply it.

Hi Wolfgang,
This patch series was too old, I was trying to save my effors ;-D
Finally I pulled these patches and tried to apply, but as I doubted it failed 
:-(
 
Hi Hogler

I could not apply the said patch series to the latest u-boot-marvell.git master 
branch

Pls re-submit it.

git-am U-Boot-1-9-arm-km-add-board-type-to-boards.cfg.patch

Applying arm/km: add board type to boards.cfg

error: patch failed: boards.cfg:138
error: boards.cfg: patch does not apply
error: patch failed: include/configs/km_kirkwood.h:42
error: include/configs/km_kirkwood.h: patch does not apply
Patch failed at 0001.
When you have resolved this problem run "git-am --resolved".
If you would prefer to skip this patch, instead run "git-am --skip"

Regards..
Prafulla . . .
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 03/14] arm/km: convert mgcoge3un target to km_kirkwood

2012-07-04 Thread Prafulla Wadaskar


> -Original Message-
> From: Holger Brunck [mailto:holger.bru...@keymile.com]
> Sent: 04 July 2012 13:55
> To: Prafulla Wadaskar
> Cc: u-boot@lists.denx.de; Valentin Longchamp;
> albert.u.b...@aribaud.net; Detlev Zundel
> Subject: Re: [PATCH v2 03/14] arm/km: convert mgcoge3un target to
> km_kirkwood
> 
> Hi Prafulla,
> 
> On 07/03/2012 04:39 PM, Prafulla Wadaskar wrote:
> >> On 07/03/2012 03:07 PM, Prafulla Wadaskar wrote:
> >
> 
>  But 01-08 are not only bugfixes there are also two new boards in
> >> these
>  patches.
>  So will you pull these eight patches in if I post them again
> >> without
>  09-14?
> >>>
> >>> Pls post bug fixes and improvement patches first those will be
> >> pulled faster.
> >>>
> >> This was already done from my side:
> >> http://lists.denx.de/pipermail/u-boot/2012-May/125219.html
> >>
> >> Sorry Prafulla but I have admit that this whole discussion costs a
> lot
> >> of time
> >> which I do not have. We are moving in circles your last comment was
> >> already
> >> discussed several times e.g.:
> >> http://lists.denx.de/pipermail/u-boot/2012-June/126081.html
> >
> >
> > Do you think I should pull this patch series, I hope it applies
> cleanly on the recent master branch.
> > Please confirm.
> >
> 
> at time of submission it applied cleanly, now I see some merge
> conlicts due to
> some underlying changes in boards.cfg in your current master. But if
> you are now
> fine with the patch serie I can provide an update which applies
> cleanly again.

No I am not fine with this patch series.
Pls provide updates

Regards..
Prafulla . . .
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 5/7] dfu:cmd: Support for DFU u-boot command

2012-07-04 Thread Lukasz Majewski
Hi Marek,

> Dear Lukasz Majewski,
> 
> > Support for u-boot's command line command "dfu  
> > [list]".
> > 
> > Signed-off-by: Lukasz Majewski 
> > Signed-off-by: Kyungmin Park 
> > Cc: Marek Vasut 
> > ---
> 
> [...]
> 
> > +int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const
> > argv[]) +{
> > +   char *str_env = NULL, *env_bkp = NULL;
> > +   static char *s = "dfu";
> > +   int ret = 0;
> > +
> > +   if (argc < 3)
> > +   return CMD_RET_USAGE;
> > +
> > +   str_env = getenv("dfu_alt_info");
> > +   if (str_env == NULL) {
> > +   printf("%s: \"dfu_alt_info\" env variable not
> > defined!\n",
> > +  __func__);
> 
> I was always curious if it's not possible to do something like 
> 
> puts(__func__ "rest of string");
> 
> Maybe it'd help the overhead a bit? Certainly, it's beyond the scope
> of this patchset, I'm just curious :)

It is a good idea, since many error/info messages are supposed to
produce following output:

"dfu_write: Not enough space!"

Putting there the __func__ name would improve structure and speed up
finding right place.

> 
> > +   return CMD_RET_FAILURE;
> > +   }
> 
> [...]
> 
> Best regards,
> Marek Vasut



-- 
Best regards,

Lukasz Majewski

Samsung Poland R&D Center | Linux Platform Group
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 6/7] arm:trats: Support for USB UDC driver at TRATS board.

2012-07-04 Thread Lukasz Majewski
Hi Minkyu,

> Dear Lukasz,
> 
> On 3 July 2012 18:38, Lukasz Majewski  wrote:
> > Support for USB UDC driver at trats board.
> >
> > Signed-off-by: Lukasz Majewski 
> > Signed-off-by: Kyungmin Park 
> > Cc: Marek Vasut 
> > Cc: Minkyu Kang 
> > ---
> >  board/samsung/trats/trats.c |9 +
> >  1 files changed, 9 insertions(+), 0 deletions(-)
> >
> > diff --git a/board/samsung/trats/trats.c
> > b/board/samsung/trats/trats.c index a95a516..2f3a531 100644
> > --- a/board/samsung/trats/trats.c
> > +++ b/board/samsung/trats/trats.c
> > @@ -59,6 +59,8 @@ static int hwrevision(int rev)
> > return (board_rev & 0xf) == rev;
> >  }
> >
> > +struct s3c_plat_otg_data s5pc210_otg_data;
> > +
> >  int board_init(void)
> >  {
> > gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
> > @@ -259,6 +261,13 @@ struct s3c_plat_otg_data s5pc210_otg_data = {
> > .usb_phy_ctrl   = EXYNOS4_USBPHY_CONTROL,
> > .usb_flags  = PHY0_SLEEP,
> >  };
> > +
> > +void board_usb_init(void)
> > +{
> > +   puts("USB_udc_probe\n");
> 
> is it useful information? or debug message?

Good point. I will change it to debug.
> 
> > +   s3c_udc_probe(&s5pc210_otg_data);
> > +
> > +}
> >  #endif
> >
> 
> Thanks.
> Minkyu Kang.



-- 
Best regards,

Lukasz Majewski

Samsung Poland R&D Center | Linux Platform Group
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH V2 3/4] common lcd: simplify core functions

2012-07-04 Thread Nikita Kiryanov

On 06/25/2012 10:23 AM, Wolfgang Denk wrote:

Dear Nikita Kiryanov,

In message <1340607844-8718-4-git-send-email-nik...@compulab.co.il> you wrote:

Move highly platform dependant code into its own function to reduce the
number of #ifdefs in the bigger functions

Signed-off-by: Nikita Kiryanov 
Signed-off-by: Igor Grinberg 
---
  common/lcd.c |   58 --
  1 files changed, 28 insertions(+), 30 deletions(-)

diff --git a/common/lcd.c b/common/lcd.c
index 4a5c8d5..3c0f1b1 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -498,21 +498,35 @@ static int lcd_getbgcolor(void)
  //
  /* ** Chipset depending Bitmap / Logo stuff...  */
  //
+static inline ushort *configuration_get_cmap(void)
+{
+#if defined CONFIG_CPU_PXA
+   struct pxafb_info *fbi = &panel_info.pxa;
+   return (ushort *)fbi->palette;
+#elif defined(CONFIG_MPC823)
+   volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
+   volatile cpm8xx_t *cp = &(immr->im_cpm);
+   return (ushort *)&(cp->lcd_cmap[255 * sizeof(ushort)]);
+#elif defined(CONFIG_ATMEL_LCD)
+   return (ushort *)(panel_info.mmio + ATMEL_LCDC_LUT(0));
+#else
+   return (ushort *)panel_info.cmap;
+#endif
+}


Please fix and use I/O accessors instead of volatile pointers.

Best regards,

Wolfgang Denk



The goal of this patch set was to reduce #define complexity in common/lcd.
Do you mind if I address the volatile pointers with a follow up patch?

--
Nikita


___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] ehci-hcd.c, musb_core, usb.h: Add USB_DMA_MINALIGN define for cache alignment

2012-07-04 Thread Ilya Yanok
From: Tom Rini 

The USB spec says that 32 bytes is the minimum required alignment.
However on some platforms we have a larger minimum requirement for cache
coherency.  In those cases, use that value rather than the USB spec
minimum.  We add a cpp check to  to define USB_DMA_MINALIGN and
make use of it in ehci-hcd.c and musb_core.h.  We cannot use MAX() here
as we are not allowed to have tests inside of align(...).

Cc: Marek Vasut 
Signed-off-by: Tom Rini 
[ilya.yanok]: fix size alignment, drop (incorrect) rounding
when invalidating the buffer. If we got unaligned buffer from the
upper layer -- that's definetely a bug so it's good to buzz
about it. But we have to align the buffer length -- upper layers
should take care to reserve enough space.
Signed-off-by: Ilya Yanok 
---
Changes from Tom's V4:
 - Internal buffers should be not only address but also size aligned
 - Don't try to fix unalignment of external buffer
 - Fix also debug() checks in ehci_td_buffer() (though size check is
   meaningless: in the current API only size of transfer is passed
   which is not always the same as size of underlying buffer and
   can be unaligned.

 No bounce-buffering is implemented so unaligned buffers coming from
the upper layers will still result in invalidate_dcache_range() vows.
But I tested it with unaligned fatload and got strange result: no
errors from invalidate_dcache_range, I got "EHCI timed out on TD"
errors instead (the same situtation without this patch and cache
disabled). Looks like unaligned buffers are problem for EHCI even
without cache involved...
Aligned fatload works like a charm.

 drivers/usb/host/ehci-hcd.c  |   89 +-
 drivers/usb/musb/musb_core.h |2 +-
 include/usb.h|   10 +
 3 files changed, 65 insertions(+), 36 deletions(-)

diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 04300be..74a5c76 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -34,7 +34,9 @@ struct ehci_hccr *hccr;   /* R/O registers, not need for 
volatile */
 volatile struct ehci_hcor *hcor;
 
 static uint16_t portreset;
-static struct QH qh_list __attribute__((aligned(32)));
+static char __qh_list[ALIGN(sizeof(struct QH), USB_DMA_MINALIGN)]
+   __attribute__((aligned(USB_DMA_MINALIGN)));
+static struct QH *qh_list = (struct QH *)__qh_list;
 
 static struct descriptor {
struct usb_hub_descriptor hub;
@@ -172,13 +174,13 @@ static int ehci_td_buffer(struct qTD *td, void *buf, 
size_t sz)
 {
uint32_t delta, next;
uint32_t addr = (uint32_t)buf;
-   size_t rsz = roundup(sz, 32);
+   size_t rsz = roundup(sz, USB_DMA_MINALIGN);
int idx;
 
if (sz != rsz)
debug("EHCI-HCD: Misaligned buffer size (%08x)\n", sz);
 
-   if (addr & 31)
+   if (addr != ALIGN(addr, USB_DMA_MINALIGN))
debug("EHCI-HCD: Misaligned buffer address (%p)\n", buf);
 
idx = 0;
@@ -207,8 +209,12 @@ static int
 ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,
   int length, struct devrequest *req)
 {
-   static struct QH qh __attribute__((aligned(32)));
-   static struct qTD qtd[3] __attribute__((aligned (32)));
+   static char *__qh[ALIGN(sizeof(struct QH), USB_DMA_MINALIGN)]
+   __attribute__((aligned(USB_DMA_MINALIGN)));
+   struct QH *qh = (struct QH *)__qh;
+   static char *__qtd[ALIGN(3*sizeof(struct qTD), USB_DMA_MINALIGN)]
+   __attribute__((aligned(USB_DMA_MINALIGN)));
+   struct qTD *qtd = (struct qTD *)__qtd;
int qtd_counter = 0;
 
volatile struct qTD *vtd;
@@ -229,8 +235,8 @@ ehci_submit_async(struct usb_device *dev, unsigned long 
pipe, void *buffer,
  le16_to_cpu(req->value), le16_to_cpu(req->value),
  le16_to_cpu(req->index));
 
-   memset(&qh, 0, sizeof(struct QH));
-   memset(qtd, 0, sizeof(qtd));
+   memset(qh, 0, sizeof(struct QH));
+   memset(qtd, 0, 3 * sizeof(*qtd));
 
toggle = usb_gettoggle(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe));
 
@@ -244,7 +250,7 @@ ehci_submit_async(struct usb_device *dev, unsigned long 
pipe, void *buffer,
 *   qh_overlay.qt_next .. 13-10 H
 * - qh_overlay.qt_altnext
 */
-   qh.qh_link = cpu_to_hc32((uint32_t)&qh_list | QH_LINK_TYPE_QH);
+   qh->qh_link = cpu_to_hc32((uint32_t)qh_list | QH_LINK_TYPE_QH);
c = (usb_pipespeed(pipe) != USB_SPEED_HIGH &&
 usb_pipeendpoint(pipe) == 0) ? 1 : 0;
endpt = (8 << 28) |
@@ -255,14 +261,14 @@ ehci_submit_async(struct usb_device *dev, unsigned long 
pipe, void *buffer,
(usb_pipespeed(pipe) << 12) |
(usb_pipeendpoint(pipe) << 8) |
(0 << 7) | (usb_pipedevice(pipe) << 0);
-   qh.qh_endpt1 = cpu_to_hc32(endpt);
+   qh->qh_endpt1 = cpu_to_hc32(endpt

Re: [U-Boot] [PATCH v4 3/6] mcx: Disable DCACHE since USB EHCI is enabled

2012-07-04 Thread Ilya Yanok

Hi All,

04.07.2012 04:14, Marek Vasut wrote:

Ilya, thank you for saving my back ;-)

And thank you for investing your time into this.


You are welcome ;)

Just posted the patch. No dealing with unaligned buffers from upper 
layers for now but at least fatload with aligned address works fine.


Regards, Ilya.

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [STATUS] Final pull requests for -rc1?

2012-07-04 Thread Ilya Yanok

Hi Tom,

02.07.2012 23:06, Tom Rini wrote:

On Mon, Jul 02, 2012 at 08:41:56PM +0200, Wolfgang Denk wrote:


Hello all,

I would like to get out -rc1 ASAP.  If you have any patches queued
that should make it into the upcoming release, then plase send your
pull requezts as soon as possible.


Albert, what are your plans for an ARM pull req?

I've got another round of fixes, pending a resolution for now on the USB
issue that needs to come in, certainly for release and since USB isn't
usable on my platforms, it'd be nice to be in -rc1.  Ilya, Marek, have
you guys agreed to something for now?


Yes. I just posted the modified version of your 2/6 patch. Your 1/6 is 
also required but other I hope not anymore ;)


Regards, Ilya.



___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 2/7] dfu:usb: DFU USB function (f_dfu) support for g_dnl composite gadget

2012-07-04 Thread Marek Vasut
Dear Lukasz Majewski,

[...]

> > > +static void handle_getstatus(struct usb_request *req)
> > > +{
> > > + struct dfu_status *dstat = (struct dfu_status *)req->buf;
> > > + struct f_dfu *f_dfu = req->context;
> > > +
> > > + switch (f_dfu->dfu_state) {
> > 
> > > + case DFU_STATE_dfuDNLOAD_SYNC:
> > What's this crazy cammel case in here ? :-)
> 
> I know, that camel case descriptions are not welcome :-),
> but those are written in this way for purpose.
> 
> dfuDNLOAD_SYNC is the exact state name mentioned at DFU specification.
> Other states - like dfuDNBUSY are exactly the same.
> 
> From mine experience it is more readable. Please consider for
> example the Fig. A1 - Interface state transition diagram from page 28
> at DFU_1.1.pdf spec (link below).
> 
> http://www.usb.org/developers/devclass_docs/DFU_1.1.pdf

OK, good.

> > > + case DFU_STATE_dfuDNBUSY:
> > > + f_dfu->dfu_state = DFU_STATE_dfuDNLOAD_IDLE;
> > > + break;
> > > + case DFU_STATE_dfuMANIFEST_SYNC:
> > > + break;
> > > + default:
> > > + break;
> > > + }
> > > +
> > > + /* send status response */
> > > + dstat->bStatus = f_dfu->dfu_status;
> > > + /* FIXME: set dstat->bwPollTimeout */
> > 
> > FIXME ... so fix it ;-)
> 
> This is not u-boot related - will be removed
> 
> > > + dstat->bState = f_dfu->dfu_state;
> > > + dstat->iString = 0;
> > > +}
> > > +
> > > +static void handle_getstate(struct usb_request *req)
> > > +{
> > > + struct f_dfu *f_dfu = req->context;
> > > +
> > > + ((u8 *)req->buf)[0] = f_dfu->dfu_state & 0xff;
> > 
> > Now ... this is ubercrazy ... can't this be made without this
> > typecasting voodoo?
> 
> The problem is that req->buf is a void pointer. And the goal is to
> store dfu state at 8 bits.

Sure, but why not make the buffer u8 ?

> > > + req->actual = sizeof(u8);
> > > +}
> > > +

[...]

> > > +static int
> > > +dfu_prepare_strings(struct f_dfu *f_dfu, int n)
> > > +{
> > > + struct dfu_entity *de = NULL;
> > > + int i = 0;
> > > +
> > > + f_dfu->strings = calloc(((n + 1) * sizeof(struct
> > > usb_string)), 1);
> > 
> > calloc(n, 1) ... that's the same as malloc(), isn't it ?
> 
> I now wonder how mine mind produced this :-)
> 
> Correct version:
> 
> f_dfu->strings = calloc(sizeof(struct usb_string), n + 1);
> 
> I prefer calloc, since it delivers zeroed memory.

ok, that's better :)

[...]
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 3/7] dfu: DFU backend implementation

2012-07-04 Thread Marek Vasut
Dear Lukasz Majewski,

> Hi Marek,
> 
> > Dear Lukasz Majewski,
> > 
> > > New, separate driver at ./drivers/dfu has been added. It allows
> > > platform and storage independent operation of DFU.
> > > 
> > > Signed-off-by: Lukasz Majewski 
> > > Signed-off-by: Kyungmin Park 
> > > Cc: Marek Vasut 
> > > ---
> > 
> > [...]
> > 
> > > +#include 
> > > +#include 
> > > +#include 
> > > +#include 
> > > +#include 
> > > +#include 
> > > +#include 
> > > +
> > > +static LIST_HEAD(dfu_list);
> > > +static int dfu_alt_num;
> > > +
> > > +static int dfu_find_alt_num(char *s)
> > > +{
> > > + int i = 0;
> > > +
> > > + for (; *s; s++)
> > > + if (*s == ';')
> > > + i++;
> > > +
> > > + return ++i;
> > > +}
> > > +
> > > +static char *dfu_extract_entity(char** env)
> > > +{
> > > + char *s = *env;
> > > +
> > > + strsep(env, ";");
> > > + return s;
> > > +}
> > 
> > Shall we not make these all generic? They seem to be quite helpful
> > components.
> 
> It is a good topic for a discussion if those functions shall be moved
> to ./lib/string.c.
> I regarded them as a "little" helper functions for parsing DFU alt
> setting env variable. Those are very short and build with methods
> exported from string.c

Good point

> > > +
> > > +char *dfu_extract_token(char** e, int *n)
> > > +{
> > > + char *st = *e;
> > > +
> > > + debug("%s: %s\n", __func__, st);
> > > +
> > > + strsep(e, " ");
> > > + *n = *e - st;
> > > +
> > > + return st;
> > > +}
> > > +
> > > +static unsigned char __aligned(CONFIG_SYS_CACHELINE_SIZE)
> > > +  dfu_buf[DFU_DATA_BUF_SIZE];
> > 
> > Can we not stack-allocate it with ALLOC_CACHE_ALIGN_BUFFER()?
> 
> The dfu_buf is 4 MiB (this is the size of DFU_DATA_BUF_SIZE). I don't
> think, that allocating it on the stack (for stack allocation the
> ALLOC_CACHE_ALIGN_BUFFER() is designed) is a good idea.

Heh, agreed :-)

> > [...]
> > 
> > > diff --git a/include/dfu.h b/include/dfu.h
> > > new file mode 100644
> > > index 000..f7d823b
> > > --- /dev/null
> > > +++ b/include/dfu.h
> > 
> > [...]
> > 
> > > +struct dfu_entity {
> > > + charname[DFU_NAME_SIZE];
> > > + int alt;
> > > + void*dev_private;
> > > + int dev_num;
> > > + enum dfu_device_typedev_type;
> > > + enum dfu_layout layout;
> > > +
> > > + union {
> > > + struct mmc_internal_data mmc;
> > 
> > This union seems redundant ;-)
> 
> Good point :-), but I predict, that DFU will be used to program other
> memory types (OneNAND, or NAND). To support those, one needs to extend
> the union with e.g struct onenand_internal_data onenand.
> 
> Since we don't have so many memory types, I think that union usage is
> acceptable.

And will those pieces be implemented any soon ? :)

> > [...]

Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 4/7] dfu: MMC specific routines for DFU operation

2012-07-04 Thread Marek Vasut
Dear Lukasz Majewski,

[...]

> > > > Holy Moly ... can we not make this into simple calls to those
> > > > subsystems ? Instead invoking command is crazy ;-)
> > > 
> > > Are they really simple?  There's a few other places we do this, and
> > > so long as it's documented that DFU depends on CONFIG_FAT_WRITE for
> > > writing to fat and so forth.
> > 
> > Well ain't it easier to call fat_write() or similar?
> 
> I've decided to use run_command on a purpose.
> 
> This call provides clean and reliable API. It is very unlikely that the
> mmc write command will change (or any
> other).
> On the other hand the fields of struct mmc are changed from time to
> time.

I'm afraid it might change with the driver model soon.

> Moreover, mmc drivers are also a subject to change (like adding dw_mmc
> recently).
> Using run_command also takes the burden of mmc_init() related calls.
> 
> Of course the run_command's downside is the speed of execution. But is
> it so important when one considers, the firmware update?

But as Stephen pointed out, the type checking is much better when used as 
function.

> Side note: DFU uses only EP0 (for transfer and configuration), so this
> is rather slow communication link.

I see

> I'm open for discussion.

Yes please, I think I started some bad flamewar in here :/

Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 5/7] dfu:cmd: Support for DFU u-boot command

2012-07-04 Thread Marek Vasut
Dear Lukasz Majewski,

> Hi Marek,
> 
> > Dear Lukasz Majewski,
> > 
> > > Support for u-boot's command line command "dfu  
> > > [list]".
> > > 
> > > Signed-off-by: Lukasz Majewski 
> > > Signed-off-by: Kyungmin Park 
> > > Cc: Marek Vasut 
> > > ---
> > 
> > [...]
> > 
> > > +int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const
> > > argv[]) +{
> > > + char *str_env = NULL, *env_bkp = NULL;
> > > + static char *s = "dfu";
> > > + int ret = 0;
> > > +
> > > + if (argc < 3)
> > > + return CMD_RET_USAGE;
> > > +
> > > + str_env = getenv("dfu_alt_info");
> > > + if (str_env == NULL) {
> > > + printf("%s: \"dfu_alt_info\" env variable not
> > > defined!\n",
> > > +__func__);
> > 
> > I was always curious if it's not possible to do something like
> > 
> > puts(__func__ "rest of string");
> > 
> > Maybe it'd help the overhead a bit? Certainly, it's beyond the scope
> > of this patchset, I'm just curious :)
> 
> It is a good idea, since many error/info messages are supposed to
> produce following output:
> 
> "dfu_write: Not enough space!"
> 
> Putting there the __func__ name would improve structure and speed up
> finding right place.

And if you want to use even __LINE__, look up __stringify patch in the ML 
archives ;-)

> > > + return CMD_RET_FAILURE;
> > > + }
> > 
> > [...]
> > 
> > Best regards,
> > Marek Vasut

Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RESEND 00/11] Support for ST-Ericsson snowball board

2012-07-04 Thread mathieu . poirier
From: "Mathieu J. Poirier" 

This set adds support for the ST-Ericsson u8500 based
snowball board.  Doing so it moves u8500-href code around
to allow for code reuse between boards.

It was sent out more than three weeks ago, was modified after
comments were received but never got an official ACK.

Resending again in it's last revision.

John Rigby (1):
  u8500: Separating mmc config parameters from driver

Mathieu J. Poirier (10):
  snowball: Add support for ux500 based snowball board
  u8500: Moving prcmu to cpu directory
  snowball: Adding architecture dependent initialisation
  snowball: Adding CPU clock initialisation
  snowball: Moving to ux500.v2 addess scheme for PRCMU access
  snowball: applying power to LAN and GBF controllers
  u8500: Moving processor-specific functions to cpu area.
  u8500: Enabling power to MMC device on AB8500 V2
  armv7: Adding cpu specific cache managmenent
  snowball: Adding board specific cache cleanup routine

 arch/arm/cpu/armv7/cpu.c|8 +
 arch/arm/cpu/armv7/u8500/Makefile   |2 +-
 arch/arm/cpu/armv7/u8500/clock.c|   34 +
 arch/arm/cpu/armv7/u8500/cpu.c  |  182 ++
 arch/arm/cpu/armv7/u8500/prcmu.c|  229 +++
 arch/arm/include/asm/arch-u8500/clock.h |5 +-
 arch/arm/include/asm/arch-u8500/db8500_gpio.h   |   42 ++
 arch/arm/include/asm/arch-u8500/db8500_pincfg.h |  172 ++
 arch/arm/include/asm/arch-u8500/hardware.h  |   33 +-
 arch/arm/include/asm/arch-u8500/prcmu.h |   76 +++
 arch/arm/include/asm/arch-u8500/sys_proto.h |1 +
 board/armltd/vexpress/ca9x4_ct_vxp.c|   21 +-
 board/st-ericsson/snowball/Makefile |   51 ++
 board/st-ericsson/snowball/db8500_pins.h|  745 +++
 board/st-ericsson/snowball/snowball.c   |  367 +++
 board/st-ericsson/u8500/Makefile|2 +-
 board/st-ericsson/u8500/prcmu-fw.h  |   55 --
 board/st-ericsson/u8500/prcmu.c |  165 -
 board/st-ericsson/u8500/u8500_href.c|   99 +---
 boards.cfg  |1 +
 drivers/gpio/Makefile   |1 +
 drivers/gpio/db8500_gpio.c  |  225 +++
 drivers/mmc/arm_pl180_mmci.c|  132 ++---
 drivers/mmc/arm_pl180_mmci.h|   27 +-
 drivers/serial/serial_pl01x.c   |2 +
 include/configs/snowball.h  |  268 
 26 files changed, 2554 insertions(+), 391 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/u8500/cpu.c
 create mode 100644 arch/arm/cpu/armv7/u8500/prcmu.c
 create mode 100644 arch/arm/include/asm/arch-u8500/db8500_gpio.h
 create mode 100644 arch/arm/include/asm/arch-u8500/db8500_pincfg.h
 create mode 100644 arch/arm/include/asm/arch-u8500/prcmu.h
 create mode 100644 board/st-ericsson/snowball/Makefile
 create mode 100644 board/st-ericsson/snowball/db8500_pins.h
 create mode 100644 board/st-ericsson/snowball/snowball.c
 delete mode 100644 board/st-ericsson/u8500/prcmu-fw.h
 delete mode 100644 board/st-ericsson/u8500/prcmu.c
 create mode 100644 drivers/gpio/db8500_gpio.c
 create mode 100644 include/configs/snowball.h

-- 
1.7.5.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RESEND 02/11] u8500: Moving prcmu to cpu directory

2012-07-04 Thread mathieu . poirier
From: "Mathieu J. Poirier" 

This is to allow the prcmu functions to be used by multiple
u8500-based processors.

Signed-off-by: Mathieu Poirier 
Signed-off-by: John Rigby 
---
 arch/arm/cpu/armv7/u8500/Makefile   |2 +-
 arch/arm/cpu/armv7/u8500/prcmu.c|  164 ++
 arch/arm/include/asm/arch-u8500/prcmu.h |   55 ++
 board/st-ericsson/u8500/Makefile|2 +-
 board/st-ericsson/u8500/prcmu-fw.h  |   55 --
 board/st-ericsson/u8500/prcmu.c |  165 ---
 board/st-ericsson/u8500/u8500_href.c|2 +-
 7 files changed, 222 insertions(+), 223 deletions(-)

diff --git a/arch/arm/cpu/armv7/u8500/Makefile 
b/arch/arm/cpu/armv7/u8500/Makefile
index 270aa40..77accde 100644
--- a/arch/arm/cpu/armv7/u8500/Makefile
+++ b/arch/arm/cpu/armv7/u8500/Makefile
@@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk
 
 LIB= $(obj)lib$(SOC).o
 
-COBJS  = timer.o clock.o
+COBJS  = timer.o clock.o prcmu.o
 SOBJS  = lowlevel.o
 
 SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
diff --git a/arch/arm/cpu/armv7/u8500/prcmu.c b/arch/arm/cpu/armv7/u8500/prcmu.c
new file mode 100644
index 000..119ead3
--- /dev/null
+++ b/arch/arm/cpu/armv7/u8500/prcmu.c
@@ -0,0 +1,164 @@
+/*
+ * Copyright (C) 2009 ST-Ericsson SA
+ *
+ * Adapted from the Linux version:
+ * Author: Kumar Sanghvi 
+ *
+ * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ */
+
+/*
+ * NOTE: This currently does not support the I2C workaround access method.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* CPU mailbox registers */
+#define PRCM_MBOX_CPU_VAL (U8500_PRCMU_BASE + 0x0fc)
+#define PRCM_MBOX_CPU_SET (U8500_PRCMU_BASE + 0x100)
+#define PRCM_MBOX_CPU_CLR (U8500_PRCMU_BASE + 0x104)
+
+static int prcmu_is_ready(void)
+{
+   int ready = readb(PRCM_XP70_CUR_PWR_STATE) == AP_EXECUTE;
+   if (!ready)
+   printf("PRCMU firmware not ready\n");
+   return ready;
+}
+
+static int _wait_for_req_complete(int num)
+{
+   int timeout = 1000;
+
+   /* checking any already on-going transaction */
+   while ((readl(PRCM_MBOX_CPU_VAL) & (1 << num)) && timeout--)
+   ;
+
+   timeout = 1000;
+
+   /* Set an interrupt to XP70 */
+   writel(1 << num, PRCM_MBOX_CPU_SET);
+
+   while ((readl(PRCM_MBOX_CPU_VAL) & (1 << num)) && timeout--)
+   ;
+
+   if (!timeout) {
+   printf("PRCMU operation timed out\n");
+   return -1;
+   }
+
+   return 0;
+}
+
+/**
+ * prcmu_i2c_read - PRCMU - 4500 communication using PRCMU I2C
+ * @reg: - db8500 register bank to be accessed
+ * @slave:  - db8500 register to be accessed
+ * Returns: ACK_MB5  value containing the status
+ */
+int prcmu_i2c_read(u8 reg, u16 slave)
+{
+   uint8_t i2c_status;
+   uint8_t i2c_val;
+
+   if (!prcmu_is_ready())
+   return -1;
+
+   debug("\nprcmu_4500_i2c_read:bank=%x;reg=%x;\n",
+   reg, slave);
+
+   /* prepare the data for mailbox 5 */
+   writeb((reg << 1) | I2CREAD, PRCM_REQ_MB5_I2COPTYPE_REG);
+   writeb((1 << 3) | 0x0, PRCM_REQ_MB5_BIT_FIELDS);
+   writeb(slave, PRCM_REQ_MB5_I2CSLAVE);
+   writeb(0, PRCM_REQ_MB5_I2CVAL);
+
+   _wait_for_req_complete(REQ_MB5);
+
+   /* retrieve values */
+   debug("ack-mb5:transfer status = %x\n",
+   readb(PRCM_ACK_MB5_STATUS));
+   debug("ack-mb5:reg bank = %x\n", readb(PRCM_ACK_MB5) >> 1);
+   debug("ack-mb5:slave_add = %x\n",
+   readb(PRCM_ACK_MB5_SLAVE));
+   debug("ack-mb5:reg_val = %d\n", readb(PRCM_ACK_MB5_VAL));
+
+   i2c_status = readb(PRCM_ACK_MB5_STATUS);
+   i2c_val = readb(PRCM_ACK_MB5_VAL);
+
+   if (i2c_status == I2C_RD_OK)
+   return i2c_val;
+   else {
+
+   printf("prcmu_i2c_read:read return status= %d\n",
+   i2c_status);
+   return -1;
+   }
+
+}
+
+/**
+ * prcmu_i2c_write - PRCMU-db8500 communication using PRCMU I2C
+ * @reg: - db8500 register bank to be accessed
+ * 

[U-Boot] [RESEND 03/11] snowball: Adding architecture dependent initialisation

2012-07-04 Thread mathieu . poirier
From: "Mathieu J. Poirier" 

Enabling timers and clocks in PRCMU and cleaning up mailbox.

Signed-off-by: Mathieu Poirier 
Signed-off-by: John Rigby 
---
Changes for v2:
   - Cleaned #defines in snowball.h
---
 arch/arm/cpu/armv7/u8500/Makefile   |2 +-
 arch/arm/cpu/armv7/u8500/cpu.c  |   41 +++
 arch/arm/cpu/armv7/u8500/prcmu.c|   30 ++
 arch/arm/include/asm/arch-u8500/prcmu.h |   24 ++
 board/st-ericsson/u8500/u8500_href.c|2 +-
 include/configs/snowball.h  |1 +
 6 files changed, 93 insertions(+), 7 deletions(-)

diff --git a/arch/arm/cpu/armv7/u8500/Makefile 
b/arch/arm/cpu/armv7/u8500/Makefile
index 77accde..ce8af96 100644
--- a/arch/arm/cpu/armv7/u8500/Makefile
+++ b/arch/arm/cpu/armv7/u8500/Makefile
@@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk
 
 LIB= $(obj)lib$(SOC).o
 
-COBJS  = timer.o clock.o prcmu.o
+COBJS  = timer.o clock.o prcmu.o cpu.o
 SOBJS  = lowlevel.o
 
 SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
diff --git a/arch/arm/cpu/armv7/u8500/cpu.c b/arch/arm/cpu/armv7/u8500/cpu.c
new file mode 100644
index 000..04f4b19
--- /dev/null
+++ b/arch/arm/cpu/armv7/u8500/cpu.c
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2012 Linaro Limited
+ * Mathieu Poirier 
+ *
+ * Based on original code from Joakim Axelsson at ST-Ericsson
+ * (C) Copyright 2010 ST-Ericsson
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include 
+#include 
+#include 
+
+#ifdef CONFIG_ARCH_CPU_INIT
+/*
+ * SOC specific cpu init
+ */
+int arch_cpu_init(void)
+{
+   db8500_prcmu_init();
+
+   return 0;
+}
+#endif /* CONFIG_ARCH_CPU_INIT */
diff --git a/arch/arm/cpu/armv7/u8500/prcmu.c b/arch/arm/cpu/armv7/u8500/prcmu.c
index 119ead3..6187dcc 100644
--- a/arch/arm/cpu/armv7/u8500/prcmu.c
+++ b/arch/arm/cpu/armv7/u8500/prcmu.c
@@ -40,6 +40,8 @@
 #define PRCM_MBOX_CPU_SET (U8500_PRCMU_BASE + 0x100)
 #define PRCM_MBOX_CPU_CLR (U8500_PRCMU_BASE + 0x104)
 
+#define I2C_MBOX_BIT(1 << 5)
+
 static int prcmu_is_ready(void)
 {
int ready = readb(PRCM_XP70_CUR_PWR_STATE) == AP_EXECUTE;
@@ -162,3 +164,31 @@ int prcmu_i2c_write(u8 reg, u16 slave, u8 reg_data)
return -1;
}
 }
+
+void u8500_prcmu_enable(u32 *reg)
+{
+   writel(readl(reg) | (1 << 8), reg);
+}
+
+void db8500_prcmu_init(void)
+{
+   /* Enable timers */
+   writel(1 << 17, PRCM_TCR);
+
+   u8500_prcmu_enable((u32 *)PRCM_PER1CLK_MGT_REG);
+   u8500_prcmu_enable((u32 *)PRCM_PER2CLK_MGT_REG);
+   u8500_prcmu_enable((u32 *)PRCM_PER3CLK_MGT_REG);
+   /* PER4CLK does not exist */
+   u8500_prcmu_enable((u32 *)PRCM_PER5CLK_MGT_REG);
+   u8500_prcmu_enable((u32 *)PRCM_PER6CLK_MGT_REG);
+   /* Only exists in ED but is always ok to write to */
+   u8500_prcmu_enable((u32 *)PRCM_PER7CLK_MGT_REG);
+
+   u8500_prcmu_enable((u32 *)PRCM_UARTCLK_MGT_REG);
+   u8500_prcmu_enable((u32 *)PRCM_I2CCLK_MGT_REG);
+
+   u8500_prcmu_enable((u32 *)PRCM_SDMMCCLK_MGT_REG);
+
+   /* Clean up the mailbox interrupts after pre-u-boot code. */
+   writel(I2C_MBOX_BIT, PRCM_ARM_IT1_CLEAR);
+}
diff --git a/arch/arm/include/asm/arch-u8500/prcmu.h 
b/arch/arm/include/asm/arch-u8500/prcmu.h
index 0836983..1fd4d2a 100644
--- a/arch/arm/include/asm/arch-u8500/prcmu.h
+++ b/arch/arm/include/asm/arch-u8500/prcmu.h
@@ -27,12 +27,23 @@
 #define I2C_RD_OK  2
 #define I2CWRITE   0
 
-#define _PRCMU_TCDM_BASEU8500_PRCMU_TCDM_BASE
-#define PRCM_XP70_CUR_PWR_STATE (_PRCMU_TCDM_BASE + 0xFFC)  /* 4 BYTES */
-
-#define PRCM_REQ_MB5(_PRCMU_TCDM_BASE + 0xE44)/* 4 bytes  */
-#define PRCM_ACK_MB5(_PRCMU_TCDM_BASE + 0xDF4)/* 4 bytes */
+#define PRCMU_BASE U8500_PRCMU_BASE
+#define PRCM_UARTCLK_MGT_REG   (PRCMU_BASE + 0x018)
+#define PRCM_MSPCLK_MGT_REG(PRCMU_BASE + 0x01C)
+#define PRCM_I2CCLK_MGT_REG(PRCMU_BASE + 0x020)
+#define PRCM_SDMMCCLK_MGT_REG  (PRCMU_BASE + 0x024)
+#define PRCM_PER1CLK_MGT_REG   (PRCMU_BASE + 0x02C)
+#define PRCM_PER2CLK_MGT_REG   (PRCMU_BASE + 0x030)
+#define PRCM_PER3CLK_MGT_REG   (PRCMU_BASE + 0x034)
+#define PRCM_PER5CL

[U-Boot] [RESEND 07/11] u8500: Moving processor-specific functions to cpu area.

2012-07-04 Thread mathieu . poirier
From: "Mathieu J. Poirier" 

Functions such as providing power to the MMC device and reading
the processor version register should be in the cpu area for
access by multiple u8500-based boards.

Signed-off-by: Mathieu Poirier 
Signed-off-by: John Rigby 
---
 arch/arm/cpu/armv7/u8500/cpu.c  |   86 +++
 arch/arm/include/asm/arch-u8500/sys_proto.h |1 +
 board/st-ericsson/u8500/u8500_href.c|   75 +---
 3 files changed, 88 insertions(+), 74 deletions(-)

diff --git a/arch/arm/cpu/armv7/u8500/cpu.c b/arch/arm/cpu/armv7/u8500/cpu.c
index fece201..593199c 100644
--- a/arch/arm/cpu/armv7/u8500/cpu.c
+++ b/arch/arm/cpu/armv7/u8500/cpu.c
@@ -28,6 +28,30 @@
 #include 
 #include 
 #include 
+#include 
+
+#include 
+
+#define CPUID_DB8500V1 0x411fc091
+#define CPUID_DB8500V2 0x412fc091
+#define ASICID_DB8500V11   0x008500A1
+
+static unsigned int read_asicid(void)
+{
+   unsigned int *address = (void *)U8500_BOOTROM_BASE
+   + U8500_BOOTROM_ASIC_ID_OFFSET;
+   return readl(address);
+}
+
+static int cpu_is_u8500v11(void)
+{
+   return read_asicid() == ASICID_DB8500V11;
+}
+
+static int cpu_is_u8500v2(void)
+{
+   return read_cpuid() == CPUID_DB8500V2;
+}
 
 #ifdef CONFIG_ARCH_CPU_INIT
 /*
@@ -41,3 +65,65 @@ int arch_cpu_init(void)
return 0;
 }
 #endif /* CONFIG_ARCH_CPU_INIT */
+
+#ifdef CONFIG_MMC
+
+#define LDO_VAUX3_MASK 0x3
+#define LDO_VAUX3_ENABLE   0x1
+#define VAUX3_VOLTAGE_2_9V 0xd
+
+#define AB8500_REGU_CTRL2  0x4
+#define AB8500_REGU_VRF1VAUX3_REGU_REG 0x040A
+#define AB8500_REGU_VRF1VAUX3_SEL_REG  0x0421
+
+int u8500_mmc_power_init(void)
+{
+   int ret;
+   int val;
+
+   if (!cpu_is_u8500v11())
+   return 0;
+
+   /*
+* On v1.1 HREF boards (HREF+), Vaux3 needs to be enabled for the SD
+* card to work.  This is done by enabling the regulators in the AB8500
+* via PRCMU I2C transactions.
+*
+* This code is derived from the handling of AB8500_LDO_VAUX3 in
+* ab8500_ldo_enable() and ab8500_ldo_disable() in Linux.
+*
+* Turn off and delay is required to have it work across soft reboots.
+*/
+
+   ret = prcmu_i2c_read(AB8500_REGU_CTRL2, AB8500_REGU_VRF1VAUX3_REGU_REG);
+   if (ret < 0)
+   goto out;
+
+   val = ret;
+
+   /* Turn off */
+   ret = prcmu_i2c_write(AB8500_REGU_CTRL2, AB8500_REGU_VRF1VAUX3_REGU_REG,
+   val & ~LDO_VAUX3_MASK);
+   if (ret < 0)
+   goto out;
+
+   udelay(10 * 1000);
+
+   /* Set the voltage to 2.9V */
+   ret = prcmu_i2c_write(AB8500_REGU_CTRL2,
+   AB8500_REGU_VRF1VAUX3_SEL_REG,
+   VAUX3_VOLTAGE_2_9V);
+   if (ret < 0)
+   goto out;
+
+   val = val & ~LDO_VAUX3_MASK;
+   val = val | LDO_VAUX3_ENABLE;
+
+   /* Turn on the supply */
+   ret = prcmu_i2c_write(AB8500_REGU_CTRL2,
+   AB8500_REGU_VRF1VAUX3_REGU_REG, val);
+
+out:
+   return ret;
+}
+#endif /* CONFIG_MMC */
diff --git a/arch/arm/include/asm/arch-u8500/sys_proto.h 
b/arch/arm/include/asm/arch-u8500/sys_proto.h
index bac5e79..a8ef9e5 100644
--- a/arch/arm/include/asm/arch-u8500/sys_proto.h
+++ b/arch/arm/include/asm/arch-u8500/sys_proto.h
@@ -23,5 +23,6 @@
 #define _SYS_PROTO_H_
 
 void gpio_init(void);
+int u8500_mmc_power_init(void);
 
 #endif  /* _SYS_PROTO_H_ */
diff --git a/board/st-ericsson/u8500/u8500_href.c 
b/board/st-ericsson/u8500/u8500_href.c
index fe72684..e75f8b4 100644
--- a/board/st-ericsson/u8500/u8500_href.c
+++ b/board/st-ericsson/u8500/u8500_href.c
@@ -139,18 +139,6 @@ void show_boot_progress(int progress)
 }
 #endif
 
-static unsigned int read_asicid(void)
-{
-   unsigned int *address = (void *)U8500_BOOTROM_BASE
-   + U8500_BOOTROM_ASIC_ID_OFFSET;
-   return readl(address);
-}
-
-int cpu_is_u8500v11(void)
-{
-   return read_asicid() == 0x008500A1;
-}
-
 /*
  * Miscellaneous platform dependent initialisations
  */
@@ -227,67 +215,6 @@ unsigned int addr_vall_arr[] = {
 };
 
 #ifdef CONFIG_BOARD_LATE_INIT
-#ifdef CONFIG_MMC
-
-#define LDO_VAUX3_MASK 0x3
-#define LDO_VAUX3_ENABLE   0x1
-#define VAUX3_VOLTAGE_2_9V 0xd
-
-#define AB8500_REGU_CTRL2  0x4
-#define AB8500_REGU_VRF1VAUX3_REGU_REG 0x040A
-#define AB8500_REGU_VRF1VAUX3_SEL_REG  0x0421
-
-static int hrefplus_mmc_power_init(void)
-{
-   int ret;
-   int val;
-
-   if (!cpu_is_u8500v11())
-   return 0;
-
-   /*
-* On v1.1 HREF boards (HREF+), Vaux3 needs to be enabled for the SD
-* card to work.  This is done by enabling the regulators in the AB8500
-* via PRCMU I2C transactions.
-*
-* This code is derived from the handling of AB8500_LDO_VAUX3 i

[U-Boot] [RESEND 05/11] snowball: Moving to ux500.v2 addess scheme for PRCMU access

2012-07-04 Thread mathieu . poirier
From: "Mathieu J. Poirier" 

Addresses between ux500.v1 and ux500.v2 have changed slightly,
hence mandating a review of the PRCMU access methods.

Signed-off-by: Mathieu Poirier 
Signed-off-by: John Rigby 
---
 arch/arm/cpu/armv7/u8500/prcmu.c   |   91 +++-
 arch/arm/include/asm/arch-u8500/hardware.h |2 +-
 arch/arm/include/asm/arch-u8500/prcmu.h|   10 ++-
 3 files changed, 71 insertions(+), 32 deletions(-)

diff --git a/arch/arm/cpu/armv7/u8500/prcmu.c b/arch/arm/cpu/armv7/u8500/prcmu.c
index 6187dcc..5bac75a 100644
--- a/arch/arm/cpu/armv7/u8500/prcmu.c
+++ b/arch/arm/cpu/armv7/u8500/prcmu.c
@@ -35,10 +35,11 @@
 #include 
 #include 
 
-/* CPU mailbox registers */
-#define PRCM_MBOX_CPU_VAL (U8500_PRCMU_BASE + 0x0fc)
-#define PRCM_MBOX_CPU_SET (U8500_PRCMU_BASE + 0x100)
-#define PRCM_MBOX_CPU_CLR (U8500_PRCMU_BASE + 0x104)
+#define PRCMU_I2C_WRITE(slave)  \
+   (((slave) << 1) | I2CWRITE | (1 << 6))
+
+#define PRCMU_I2C_READ(slave) \
+   (((slave) << 1) | I2CREAD | (1 << 6))
 
 #define I2C_MBOX_BIT(1 << 5)
 
@@ -50,26 +51,39 @@ static int prcmu_is_ready(void)
return ready;
 }
 
-static int _wait_for_req_complete(int num)
+static int wait_for_i2c_mbx_rdy(void)
 {
-   int timeout = 1000;
+   int timeout = 1;
+
+   if (readl(PRCM_ARM_IT1_VAL) & I2C_MBOX_BIT) {
+   printf("prcmu: warning i2c mailbox was not acked\n");
+   /* clear mailbox 5 ack irq */
+writel(I2C_MBOX_BIT, PRCM_ARM_IT1_CLEAR);
+   }
 
-   /* checking any already on-going transaction */
-   while ((readl(PRCM_MBOX_CPU_VAL) & (1 << num)) && timeout--)
+   /* check any already on-going transaction */
+   while ((readl(PRCM_MBOX_CPU_VAL) & I2C_MBOX_BIT) && timeout--)
;
 
-   timeout = 1000;
+   if (timeout == 0)
+   return -1;
+
+   return 0;
+}
+
+static int wait_for_i2c_req_done(void)
+{
+   int timeout = 1;
 
/* Set an interrupt to XP70 */
-   writel(1 << num, PRCM_MBOX_CPU_SET);
+   writel(I2C_MBOX_BIT, PRCM_MBOX_CPU_SET);
 
-   while ((readl(PRCM_MBOX_CPU_VAL) & (1 << num)) && timeout--)
+   /* wait for mailbox 5 (i2c) ack */
+   while (!(readl(PRCM_ARM_IT1_VAL) & I2C_MBOX_BIT) && timeout--)
;
 
-   if (!timeout) {
-   printf("PRCMU operation timed out\n");
+   if (timeout == 0)
return -1;
-   }
 
return 0;
 }
@@ -84,6 +98,7 @@ int prcmu_i2c_read(u8 reg, u16 slave)
 {
uint8_t i2c_status;
uint8_t i2c_val;
+   int ret;
 
if (!prcmu_is_ready())
return -1;
@@ -91,13 +106,23 @@ int prcmu_i2c_read(u8 reg, u16 slave)
debug("\nprcmu_4500_i2c_read:bank=%x;reg=%x;\n",
reg, slave);
 
+   ret = wait_for_i2c_mbx_rdy();
+   if (ret) {
+   printf("prcmu_i2c_read: mailbox became not ready\n");
+   return ret;
+   }
+
/* prepare the data for mailbox 5 */
-   writeb((reg << 1) | I2CREAD, PRCM_REQ_MB5_I2COPTYPE_REG);
+   writeb(PRCMU_I2C_READ(reg), PRCM_REQ_MB5_I2COPTYPE_REG);
writeb((1 << 3) | 0x0, PRCM_REQ_MB5_BIT_FIELDS);
writeb(slave, PRCM_REQ_MB5_I2CSLAVE);
writeb(0, PRCM_REQ_MB5_I2CVAL);
 
-   _wait_for_req_complete(REQ_MB5);
+   ret = wait_for_i2c_req_done();
+   if (ret) {
+   printf("prcmu_i2c_read: mailbox request timed out\n");
+   return ret;
+   }
 
/* retrieve values */
debug("ack-mb5:transfer status = %x\n",
@@ -109,16 +134,14 @@ int prcmu_i2c_read(u8 reg, u16 slave)
 
i2c_status = readb(PRCM_ACK_MB5_STATUS);
i2c_val = readb(PRCM_ACK_MB5_VAL);
+   /* clear mailbox 5 ack irq */
+   writel(I2C_MBOX_BIT, PRCM_ARM_IT1_CLEAR);
 
if (i2c_status == I2C_RD_OK)
return i2c_val;
-   else {
 
-   printf("prcmu_i2c_read:read return status= %d\n",
-   i2c_status);
+   printf("%s:read return status= %d\n", __func__, i2c_status);
return -1;
-   }
-
 }
 
 /**
@@ -131,6 +154,7 @@ int prcmu_i2c_read(u8 reg, u16 slave)
 int prcmu_i2c_write(u8 reg, u16 slave, u8 reg_data)
 {
uint8_t i2c_status;
+   int ret;
 
if (!prcmu_is_ready())
return -1;
@@ -138,14 +162,23 @@ int prcmu_i2c_write(u8 reg, u16 slave, u8 reg_data)
debug("\nprcmu_4500_i2c_write:bank=%x;reg=%x;\n",
reg, slave);
 
+   ret = wait_for_i2c_mbx_rdy();
+   if (ret) {
+   printf("prcmu_i2c_write: mailbox became not ready\n");
+   return ret;
+   }
+
/* prepare the data for mailbox 5 */
-   writeb((reg << 1) | I2CWRITE, PRCM_REQ_MB5_I2COPTYPE_REG);
+   writeb(PRCMU_I2C_WRITE(reg), PRCM_REQ_MB5_I2COPTYPE_REG);
writeb((1 << 3) | 0x0, PRCM_REQ_MB5_BIT_FIELDS);
writeb(slave, PRCM_REQ_MB5_I2

[U-Boot] [RESEND 04/11] snowball: Adding CPU clock initialisation

2012-07-04 Thread mathieu . poirier
From: "Mathieu J. Poirier" 

Signed-off-by: Mathieu Poirier 
Signed-off-by: John Rigby 
---
 arch/arm/cpu/armv7/u8500/clock.c|   34 +++
 arch/arm/cpu/armv7/u8500/cpu.c  |2 +
 arch/arm/include/asm/arch-u8500/clock.h |5 +---
 3 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/arch/arm/cpu/armv7/u8500/clock.c b/arch/arm/cpu/armv7/u8500/clock.c
index 9e3b873..fcfd61a 100644
--- a/arch/arm/cpu/armv7/u8500/clock.c
+++ b/arch/arm/cpu/armv7/u8500/clock.c
@@ -54,3 +54,37 @@ void u8500_clock_enable(int periph, int cluster, int kern)
if (cluster != -1)
writel(1 << cluster, &clkrst->pcken);
 }
+
+void db8500_clocks_init(void)
+{
+   /*
+* Enable all clocks. This is u-boot, we can enable it all. There is no
+* powersave in u-boot.
+*/
+
+   u8500_clock_enable(1, 9, -1); /* GPIO0 */
+   u8500_clock_enable(2, 11, -1);/* GPIO1 */
+   u8500_clock_enable(3, 8, -1); /* GPIO2 */
+   u8500_clock_enable(5, 1, -1); /* GPIO3 */
+   u8500_clock_enable(3, 6, 6);  /* UART2 */
+   u8500_clock_enable(3, 3, 3);  /* I2C0 */
+   u8500_clock_enable(1, 5, 5);  /* SDI0 */
+   u8500_clock_enable(2, 4, 2);  /* SDI4 */
+   u8500_clock_enable(6, 6, -1); /* MTU0 */
+   u8500_clock_enable(3, 4, 4);  /* SDI2 */
+
+   /*
+* Enabling clocks for all devices which are AMBA devices in the
+* kernel.  Otherwise they will not get probe()'d because the
+* peripheral ID register will not be powered.
+*/
+
+   /* XXX: some of these differ between ED/V1 */
+
+   u8500_clock_enable(1, 1, 1);  /* UART1 */
+   u8500_clock_enable(1, 0, 0);  /* UART0 */
+   u8500_clock_enable(3, 2, 2);  /* SSP1 */
+   u8500_clock_enable(3, 1, 1);  /* SSP0 */
+   u8500_clock_enable(2, 8, -1); /* SPI0 */
+   u8500_clock_enable(2, 5, 3);  /* MSP2 */
+}
diff --git a/arch/arm/cpu/armv7/u8500/cpu.c b/arch/arm/cpu/armv7/u8500/cpu.c
index 04f4b19..fece201 100644
--- a/arch/arm/cpu/armv7/u8500/cpu.c
+++ b/arch/arm/cpu/armv7/u8500/cpu.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #ifdef CONFIG_ARCH_CPU_INIT
 /*
@@ -35,6 +36,7 @@
 int arch_cpu_init(void)
 {
db8500_prcmu_init();
+   db8500_clocks_init();
 
return 0;
 }
diff --git a/arch/arm/include/asm/arch-u8500/clock.h 
b/arch/arm/include/asm/arch-u8500/clock.h
index b00ab0d..2a14784 100644
--- a/arch/arm/include/asm/arch-u8500/clock.h
+++ b/arch/arm/include/asm/arch-u8500/clock.h
@@ -64,9 +64,6 @@ struct prcmu {
 
 extern void u8500_clock_enable(int periph, int kern, int cluster);
 
-static inline void u8500_prcmu_enable(unsigned int *reg)
-{
-   writel(readl(reg) | (1 << 8), reg);
-}
+void db8500_clocks_init(void);
 
 #endif /* __ASM_ARCH_CLOCK */
-- 
1.7.5.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RESEND 06/11] snowball: applying power to LAN and GBF controllers

2012-07-04 Thread mathieu . poirier
From: "Mathieu J. Poirier" 

LAN and GBF need to be powered explicitely, doing so with
interface to AB8500 companion chip.

Signed-off-by: Mathieu Poirier 
Signed-off-by: John Rigby 
---
Changes for v2:
   - Cleaned #defines in snowball.h
---
 arch/arm/include/asm/arch-u8500/hardware.h |   11 +++-
 arch/arm/include/asm/arch-u8500/prcmu.h|7 ++-
 board/st-ericsson/snowball/snowball.c  |   87 
 include/configs/snowball.h |1 +
 4 files changed, 103 insertions(+), 3 deletions(-)

diff --git a/arch/arm/include/asm/arch-u8500/hardware.h 
b/arch/arm/include/asm/arch-u8500/hardware.h
index 9208880..8044ac3 100644
--- a/arch/arm/include/asm/arch-u8500/hardware.h
+++ b/arch/arm/include/asm/arch-u8500/hardware.h
@@ -62,7 +62,7 @@
 
 /* Per4 */
 #define U8500_PRCMU_BASE   (U8500_PER4_BASE + 0x07000)
-#define U8500_PRCMU_TCDM_BASE   (U8500_PER4_BASE + 0x06800)
+#define U8500_PRCMU_TCDM_BASE   (U8500_PER4_BASE + 0x68000)
 
 /* Per3 */
 #define U8500_UART2_BASE   (U8500_PER3_BASE + 0x7000)
@@ -80,4 +80,13 @@
 #define U8500_BOOTROM_BASE  0x9001f000
 #define U8500_BOOTROM_ASIC_ID_OFFSET0x0ff4
 
+/* AB8500 specifics */
+#define AB8500_MISC0x0010
+#define AB8500_GPIO_SEL2_REG   0x1001
+#define AB8500_GPIO_DIR2_REG   0x1011
+#define AB8500_GPIO_DIR4_REG   0x1013
+#define AB8500_GPIO_SEL4_REG   0x1003
+#define AB8500_GPIO_OUT2_REG   0x1021
+#define AB8500_GPIO_OUT4_REG   0x1023
+
 #endif /* __ASM_ARCH_HARDWARE_H */
diff --git a/arch/arm/include/asm/arch-u8500/prcmu.h 
b/arch/arm/include/asm/arch-u8500/prcmu.h
index 9862eb3..e9dcc93 100644
--- a/arch/arm/include/asm/arch-u8500/prcmu.h
+++ b/arch/arm/include/asm/arch-u8500/prcmu.h
@@ -64,8 +64,11 @@
 
 #define REQ_MB55
 
-extern int prcmu_i2c_read(u8 reg, u16 slave);
-extern int prcmu_i2c_write(u8 reg, u16 slave, u8 reg_data);
+#define ab8500_readprcmu_i2c_read
+#define ab8500_write   prcmu_i2c_write
+
+int prcmu_i2c_read(u8 reg, u16 slave);
+int prcmu_i2c_write(u8 reg, u16 slave, u8 reg_data);
 
 void u8500_prcmu_enable(u32 *reg);
 void db8500_prcmu_init(void);
diff --git a/board/st-ericsson/snowball/snowball.c 
b/board/st-ericsson/snowball/snowball.c
index 79c86df..bc95c50 100644
--- a/board/st-ericsson/snowball/snowball.c
+++ b/board/st-ericsson/snowball/snowball.c
@@ -25,6 +25,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include "db8500_pins.h"
 
@@ -183,3 +185,88 @@ int dram_init(void)
 
return 0;
 }
+
+static int raise_ab8500_gpio16(void)
+{
+   int ret;
+
+   /* selection */
+   ret = ab8500_read(AB8500_MISC, AB8500_GPIO_SEL2_REG);
+   if (ret < 0)
+   goto out;
+
+   ret |= 0x80;
+   ret = ab8500_write(AB8500_MISC, AB8500_GPIO_SEL2_REG, ret);
+   if (ret < 0)
+   goto out;
+
+   /* direction */
+   ret = ab8500_read(AB8500_MISC, AB8500_GPIO_DIR2_REG);
+   if (ret < 0)
+   goto out;
+
+   ret |= 0x80;
+   ret = ab8500_write(AB8500_MISC, AB8500_GPIO_DIR2_REG, ret);
+   if (ret < 0)
+   goto out;
+
+   /* out */
+   ret = ab8500_read(AB8500_MISC, AB8500_GPIO_OUT2_REG);
+   if (ret < 0)
+   goto out;
+
+   ret |= 0x80;
+   ret = ab8500_write(AB8500_MISC, AB8500_GPIO_OUT2_REG, ret);
+
+out:
+   return ret;
+}
+
+static int raise_ab8500_gpio26(void)
+{
+   int ret;
+
+   /* selection */
+   ret = ab8500_read(AB8500_MISC, AB8500_GPIO_DIR4_REG);
+   if (ret < 0)
+   goto out;
+
+   ret |= 0x2;
+   ret = ab8500_write(AB8500_MISC, AB8500_GPIO_DIR4_REG, ret);
+   if (ret < 0)
+   goto out;
+
+   /* out */
+   ret = ab8500_read(AB8500_MISC, AB8500_GPIO_OUT4_REG);
+   if (ret < 0)
+   goto out;
+
+   ret |= 0x2;
+   ret = ab8500_write(AB8500_MISC, AB8500_GPIO_OUT4_REG, ret);
+
+out:
+   return ret;
+}
+
+int board_late_init(void)
+{
+   /* enable 3V3 for LAN controller */
+   if (raise_ab8500_gpio26() >= 0) {
+   /* Turn on FSMC device */
+   writel(0x1, 0x8000f000);
+   writel(0x1, 0x8000f008);
+
+   /* setup FSMC for LAN controler */
+   writel(0x305b, 0x8000);
+
+   /* run at the highest possible speed */
+   writel(0x01010210, 0x8004);
+   } else
+   printf("error: can't raise GPIO26\n");
+
+   /* enable 3v6 for GBF chip */
+   if ((raise_ab8500_gpio16() < 0))
+   printf("error: cant' raise GPIO16\n");
+
+   return 0;
+}
diff --git a/include/configs/snowball.h b/include/configs/snowball.h
index 15cb78b..a818b48 100644
--- a/include/configs/snowball.h
+++ b/include/configs/snowball.h
@@ -32,6 +32,7 @@
 #define CONFIG_SYS_ICACHE_OFF
 #define CONFIG_SYS_DCACHE_OFF
 #define CONFIG_ARCH_CPU_INIT
+#define CONFIG_BOARD_LATE_INIT
 
 /*
  * High Level Configuration Options
-- 
1.7.5.4

__

[U-Boot] [RESEND 10/11] armv7: Adding cpu specific cache managmenent

2012-07-04 Thread mathieu . poirier
From: "Mathieu J. Poirier" 

Some CPU (i.e u8500) need more cache management before launching
the Linux kernel.

Signed-off-by: Mathieu Poirier 
Signed-off-by: John Rigby 
---
Changes for v2:
   - Moved from __attribute__(...) to __weak.
changes for v3:
   - Choosing more explicit name for extra cache management routine.
---
 arch/arm/cpu/armv7/cpu.c |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/arch/arm/cpu/armv7/cpu.c b/arch/arm/cpu/armv7/cpu.c
index c6fa8ef..f01989f 100644
--- a/arch/arm/cpu/armv7/cpu.c
+++ b/arch/arm/cpu/armv7/cpu.c
@@ -36,6 +36,7 @@
 #include 
 #include 
 #include 
+#include 
 
 void save_boot_params_default(u32 r0, u32 r1, u32 r2, u32 r3)
 {
@@ -44,6 +45,8 @@ void save_boot_params_default(u32 r0, u32 r1, u32 r2, u32 r3)
 void save_boot_params(u32 r0, u32 r1, u32 r2, u32 r3)
__attribute__((weak, alias("save_boot_params_default")));
 
+void __weak cpu_cache_initialization(void){}
+
 int cleanup_before_linux(void)
 {
/*
@@ -81,5 +84,10 @@ int cleanup_before_linux(void)
 */
invalidate_dcache_all();
 
+   /*
+* Some CPU need more cache attention before starting the kernel.
+*/
+   cpu_cache_initialization();
+
return 0;
 }
-- 
1.7.5.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RESEND 09/11] u8500: Separating mmc config parameters from driver

2012-07-04 Thread mathieu . poirier
From: John Rigby 

Configuration in vexpress and u8500.v1 is different from what
is needed in u8500.v2.  As such, card configuration specifics need
to reside in the board file rather than the driver.

Signed-off-by: John Rigby 
Signed-off-by: Mathieu Poirier 
---
 board/armltd/vexpress/ca9x4_ct_vxp.c  |   21 +-
 board/st-ericsson/snowball/snowball.c |   92 ++-
 board/st-ericsson/u8500/u8500_href.c  |   22 +-
 drivers/mmc/arm_pl180_mmci.c  |  132 +
 drivers/mmc/arm_pl180_mmci.h  |   27 ++-
 include/configs/snowball.h|8 ++
 6 files changed, 214 insertions(+), 88 deletions(-)

diff --git a/board/armltd/vexpress/ca9x4_ct_vxp.c 
b/board/armltd/vexpress/ca9x4_ct_vxp.c
index 0b36d12..d5e109e 100644
--- a/board/armltd/vexpress/ca9x4_ct_vxp.c
+++ b/board/armltd/vexpress/ca9x4_ct_vxp.c
@@ -33,6 +33,8 @@
  * MA 02111-1307 USA
  */
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -90,8 +92,25 @@ int board_eth_init(bd_t *bis)
 int cpu_mmc_init(bd_t *bis)
 {
int rc = 0;
+   (void) bis;
 #ifdef CONFIG_ARM_PL180_MMCI
-   rc = arm_pl180_mmci_init();
+   struct pl180_mmc_host *host;
+
+   host = malloc(sizeof(struct pl180_mmc_host));
+   if (!host)
+   return -ENOMEM;
+   memset(host, 0, sizeof(*host));
+
+   strcpy(host->name, "MMC");
+   host->base = (struct sdi_registers *)CONFIG_ARM_PL180_MMCI_BASE;
+   host->pwr_init = INIT_PWR;
+   host->clkdiv_init = SDI_CLKCR_CLKDIV_INIT_V1 | SDI_CLKCR_CLKEN;
+   host->voltages = VOLTAGE_WINDOW_MMC;
+   host->caps = 0;
+   host->clock_in = ARM_MCLK;
+   host->clock_min = ARM_MCLK / (2 * (SDI_CLKCR_CLKDIV_INIT_V1 + 1));
+   host->clock_max = CONFIG_ARM_PL180_MMCI_CLOCK_FREQ;
+   rc = arm_pl180_mmci_init(host);
 #endif
return rc;
 }
diff --git a/board/st-ericsson/snowball/snowball.c 
b/board/st-ericsson/snowball/snowball.c
index 2c01bc1..a44847c 100644
--- a/board/st-ericsson/snowball/snowball.c
+++ b/board/st-ericsson/snowball/snowball.c
@@ -29,6 +29,9 @@
 #include 
 #include 
 
+#ifdef CONFIG_MMC
+#include "../../../drivers/mmc/arm_pl180_mmci.h"
+#endif
 #include "db8500_pins.h"
 
 /*
@@ -269,9 +272,96 @@ int board_late_init(void)
if ((raise_ab8500_gpio16() < 0))
printf("error: cant' raise GPIO16\n");
 
+   return 0;
+}
+
 #ifdef CONFIG_MMC
+/*
+ * emmc_host_init - initialize the emmc controller.
+ * Configure GPIO settings, set initial clock and power for emmc slot.
+ * Initialize mmc struct and register with mmc framework.
+ */
+static int emmc_host_init(void)
+{
+   struct pl180_mmc_host *host;
+
+   host = malloc(sizeof(struct pl180_mmc_host));
+   if (!host)
+   return -ENOMEM;
+   memset(host, 0, sizeof(*host));
+
+   host->base = (struct sdi_registers *)CFG_EMMC_BASE;
+   host->pwr_init = SDI_PWR_OPD | SDI_PWR_PWRCTRL_ON;
+   host->clkdiv_init = SDI_CLKCR_CLKDIV_INIT_V2 |
+SDI_CLKCR_CLKEN | SDI_CLKCR_HWFC_EN;
+   strcpy(host->name, "EMMC");
+   host->caps = MMC_MODE_8BIT | MMC_MODE_HS | MMC_MODE_HS_52MHz;
+   host->voltages = VOLTAGE_WINDOW_MMC;
+   host->clock_min = ARM_MCLK / (2 + SDI_CLKCR_CLKDIV_INIT_V2);
+   host->clock_max = ARM_MCLK / 2;
+   host->clock_in = ARM_MCLK;
+   host->version2 = 1;
+
+   return arm_pl180_mmci_init(host);
+}
+
+/*
+ * mmc_host_init - initialize the external mmc controller.
+ * Configure GPIO settings, set initial clock and power for mmc slot.
+ * Initialize mmc struct and register with mmc framework.
+ */
+static int mmc_host_init(void)
+{
+   struct pl180_mmc_host *host;
+   u32 sdi_u32;
+
+   host = malloc(sizeof(struct pl180_mmc_host));
+   if (!host)
+   return -ENOMEM;
+   memset(host, 0, sizeof(*host));
+
+   host->base = (struct sdi_registers *)CFG_MMC_BASE;
+   sdi_u32 = 0xBF;
+   writel(sdi_u32, &host->base->power);
+   host->pwr_init = 0xBF;
+   host->clkdiv_init = SDI_CLKCR_CLKDIV_INIT_V2 |
+SDI_CLKCR_CLKEN | SDI_CLKCR_HWFC_EN;
+   strcpy(host->name, "MMC");
+   host->caps = MMC_MODE_8BIT;
+   host->b_max = 0;
+   host->voltages = VOLTAGE_WINDOW_SD;
+   host->clock_min = ARM_MCLK / (2 + SDI_CLKCR_CLKDIV_INIT_V2);
+   host->clock_max = ARM_MCLK / 2;
+   host->clock_in = ARM_MCLK;
+   host->version2 = 1;
+
+   return arm_pl180_mmci_init(host);
+}
+
+/*
+ * board_mmc_init - initialize all the mmc/sd host controllers.
+ * Called by generic mmc framework.
+ */
+int board_mmc_init(bd_t *bis)
+{
+   int error;
+
+   (void) bis;
+
+   error = emmc_host_init();
+   if (error) {
+   printf("emmc_host_init() %d\n", error);
+   return -1;
+   }
+
u8500_mmc_power_init();
-#endif /* CONFIG_MMC */
+
+   error = mmc_host_init();
+   if (e

[U-Boot] [RESEND 08/11] u8500: Enabling power to MMC device on AB8500 V2

2012-07-04 Thread mathieu . poirier
From: "Mathieu J. Poirier" 

Register mapping has changed on power control chip between
the first and second revision.

Signed-off-by: Mathieu Poirier 
Signed-off-by: John Rigby 
---
 arch/arm/cpu/armv7/u8500/cpu.c |   89 
 arch/arm/include/asm/arch-u8500/hardware.h |   22 ++-
 board/st-ericsson/snowball/snowball.c  |5 ++
 3 files changed, 88 insertions(+), 28 deletions(-)

diff --git a/arch/arm/cpu/armv7/u8500/cpu.c b/arch/arm/cpu/armv7/u8500/cpu.c
index 593199c..02bb332 100644
--- a/arch/arm/cpu/armv7/u8500/cpu.c
+++ b/arch/arm/cpu/armv7/u8500/cpu.c
@@ -36,11 +36,19 @@
 #define CPUID_DB8500V2 0x412fc091
 #define ASICID_DB8500V11   0x008500A1
 
-static unsigned int read_asicid(void)
+static unsigned int read_asicid(void);
+
+static inline unsigned int read_cpuid(void)
 {
-   unsigned int *address = (void *)U8500_BOOTROM_BASE
-   + U8500_BOOTROM_ASIC_ID_OFFSET;
-   return readl(address);
+   unsigned int val;
+
+   /* Main ID register (MIDR) */
+   asm("mrcp15, 0, %0, c0, c0, 0"
+  : "=r" (val)
+  :
+  : "cc");
+
+   return val;
 }
 
 static int cpu_is_u8500v11(void)
@@ -53,6 +61,18 @@ static int cpu_is_u8500v2(void)
return read_cpuid() == CPUID_DB8500V2;
 }
 
+static unsigned int read_asicid(void)
+{
+   unsigned int *address;
+
+   if (cpu_is_u8500v2())
+   address = (void *) U8500_ASIC_ID_LOC_V2;
+   else
+   address = (void *) U8500_ASIC_ID_LOC_ED_V1;
+
+   return readl(address);
+}
+
 #ifdef CONFIG_ARCH_CPU_INIT
 /*
  * SOC specific cpu init
@@ -68,22 +88,22 @@ int arch_cpu_init(void)
 
 #ifdef CONFIG_MMC
 
-#define LDO_VAUX3_MASK 0x3
-#define LDO_VAUX3_ENABLE   0x1
-#define VAUX3_VOLTAGE_2_9V 0xd
-
-#define AB8500_REGU_CTRL2  0x4
-#define AB8500_REGU_VRF1VAUX3_REGU_REG 0x040A
-#define AB8500_REGU_VRF1VAUX3_SEL_REG  0x0421
-
 int u8500_mmc_power_init(void)
 {
int ret;
-   int val;
+   int enable, voltage;
+   int ab8500_revision;
 
-   if (!cpu_is_u8500v11())
+   if (!cpu_is_u8500v11() && !cpu_is_u8500v2())
return 0;
 
+   /* Get AB8500 revision */
+   ret = ab8500_read(AB8500_MISC, AB8500_REV_REG);
+   if (ret < 0)
+   goto out;
+
+   ab8500_revision = ret;
+
/*
 * On v1.1 HREF boards (HREF+), Vaux3 needs to be enabled for the SD
 * card to work.  This is done by enabling the regulators in the AB8500
@@ -95,33 +115,50 @@ int u8500_mmc_power_init(void)
 * Turn off and delay is required to have it work across soft reboots.
 */
 
-   ret = prcmu_i2c_read(AB8500_REGU_CTRL2, AB8500_REGU_VRF1VAUX3_REGU_REG);
+   /* Turn off (read-modify-write) */
+   ret = ab8500_read(AB8500_REGU_CTRL2,
+   AB8500_REGU_VRF1VAUX3_REGU_REG);
if (ret < 0)
goto out;
 
-   val = ret;
+   enable = ret;
 
/* Turn off */
-   ret = prcmu_i2c_write(AB8500_REGU_CTRL2, AB8500_REGU_VRF1VAUX3_REGU_REG,
-   val & ~LDO_VAUX3_MASK);
+   ret = ab8500_write(AB8500_REGU_CTRL2,
+   AB8500_REGU_VRF1VAUX3_REGU_REG,
+   enable & ~LDO_VAUX3_ENABLE_MASK);
if (ret < 0)
goto out;
 
udelay(10 * 1000);
 
-   /* Set the voltage to 2.9V */
-   ret = prcmu_i2c_write(AB8500_REGU_CTRL2,
-   AB8500_REGU_VRF1VAUX3_SEL_REG,
-   VAUX3_VOLTAGE_2_9V);
+   /* Set the voltage to 2.91 V or 2.9 V without overriding VRF1 value */
+   ret = ab8500_read(AB8500_REGU_CTRL2,
+   AB8500_REGU_VRF1VAUX3_SEL_REG);
if (ret < 0)
goto out;
 
-   val = val & ~LDO_VAUX3_MASK;
-   val = val | LDO_VAUX3_ENABLE;
+   voltage = ret;
+
+   if (ab8500_revision < 0x20) {
+   voltage &= ~LDO_VAUX3_SEL_MASK;
+   voltage |= LDO_VAUX3_SEL_2V9;
+   } else {
+   voltage &= ~LDO_VAUX3_V2_SEL_MASK;
+   voltage |= LDO_VAUX3_V2_SEL_2V91;
+   }
+
+   ret = ab8500_write(AB8500_REGU_CTRL2,
+   AB8500_REGU_VRF1VAUX3_SEL_REG, voltage);
+   if (ret < 0)
+   goto out;
 
/* Turn on the supply */
-   ret = prcmu_i2c_write(AB8500_REGU_CTRL2,
-   AB8500_REGU_VRF1VAUX3_REGU_REG, val);
+   enable &= ~LDO_VAUX3_ENABLE_MASK;
+   enable |= LDO_VAUX3_ENABLE_VAL;
+
+   ret = ab8500_write(AB8500_REGU_CTRL2,
+   AB8500_REGU_VRF1VAUX3_REGU_REG, enable);
 
 out:
return ret;
diff --git a/arch/arm/include/asm/arch-u8500/hardware.h 
b/arch/arm/include/asm/arch-u8500/hardware.h
index 8044ac3..ee03419 100644
--- a/arch/arm/include/asm/arch-u8500/hardware.h
+++ b/arch/arm/include/asm/arch-u8500/

[U-Boot] [RESEND 11/11] snowball: Adding board specific cache cleanup routine

2012-07-04 Thread mathieu . poirier
From: "Mathieu J. Poirier" 

Following ARM's reference manuel for initializing the cache - the
kernel won't boot otherwise.

Signed-off-by: Mathieu Poirier 
Signed-off-by: John Rigby 
---
Changes for v2:
   - Correcting cache maintenance register address.
   - Invalidating all 16 bits in cache maintenance register.
   - Polling cache maintenance register for cleared bits.
   - Added comments to the code.
   - Re-worked commit description.
---
 arch/arm/cpu/armv7/u8500/cpu.c |   16 
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/arch/arm/cpu/armv7/u8500/cpu.c b/arch/arm/cpu/armv7/u8500/cpu.c
index 02bb332..50d5a83 100644
--- a/arch/arm/cpu/armv7/u8500/cpu.c
+++ b/arch/arm/cpu/armv7/u8500/cpu.c
@@ -73,6 +73,22 @@ static unsigned int read_asicid(void)
return readl(address);
 }
 
+void cpu_cache_initialization(void)
+{
+   /* invalidate all cache entries */
+   *((volatile unsigned int *)(0xA041277C)) = 0x;
+
+   /* ways are set to '0' when they are totally
+* cleaned and invalidated
+*/
+   while (*((volatile unsigned int *)(0xA041277C)) & 0xFF)
+   ;
+
+   /* Invalidate register 9 D and I lockdown */
+   *((volatile unsigned int *)(0xA0412900)) = 0xFF;
+   *((volatile unsigned int *)(0xA0412904)) = 0xFF;
+}
+
 #ifdef CONFIG_ARCH_CPU_INIT
 /*
  * SOC specific cpu init
-- 
1.7.5.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v3 1/3] AM335x : Add USB support for AM335x in u-boot

2012-07-04 Thread Ilya Yanok
Hi,

On Sun, Jul 1, 2012 at 9:33 PM, Harman Sohanpal wrote:

>
> Thanks for your review.
> But I believe you are talking of version 3 of the patches.
> Kindly have a look at the version 4 I have sent.
>

Yes, my bad. I've seen your fourth version just after sending my comment.


> I have used the same approach which Tom has mentioned
> for control register offset also.
>

Yes, I've seen. I still think that it's a bit misguiding to conditionally
define USB_CTRL0 but the general approach is ok.
Other than that I think it's good to have boards.cfg entries for both
options.

And how much have you tested these patches? I tried them on my beaglebone
and have issues both with host and device modes.

In device mode I tried to use CDC ACM. My Linux host sees the device and
/dev/ttyACM0 node shows up. I can put stdout in U-Boot to usbtty and this
works nice too. But once I try to reassign stdin also I got my picocom
hanged (only killable with kill -9).

I host mode I tried with two flashdisks (512MB and 4GB) and card-reader
(32MB SD and 8GB microSD cards). Only 512MB stick works as expected. With
others I got:
 1. 4GB flashdisk -- 0 device found, second "usb start" command seems to
wedge the board
 2. 8GB card --  scanning bus for storage devices... Device NOT ready
   Request Sense returned 00 00 00. Second "usb start" is lethal too.
 3. 32MB card -- scanning bus for storage devices... READ_CAP ERROR

Regards, Ilya.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 2/7] dfu:usb: DFU USB function (f_dfu) support for g_dnl composite gadget

2012-07-04 Thread Lukasz Majewski
Hi Marek,

> Dear Lukasz Majewski,
> 
> [...]
> 
> > > > +static void handle_getstatus(struct usb_request *req)
> > > > +{
> > > > +   struct dfu_status *dstat = (struct dfu_status
> > > > *)req->buf;
> > > > +   struct f_dfu *f_dfu = req->context;
> > > > +
> > > > +   switch (f_dfu->dfu_state) {
> > > 
> > > > +   case DFU_STATE_dfuDNLOAD_SYNC:
> > > What's this crazy cammel case in here ? :-)
> > 
> > I know, that camel case descriptions are not welcome :-),
> > but those are written in this way for purpose.
> > 
> > dfuDNLOAD_SYNC is the exact state name mentioned at DFU
> > specification. Other states - like dfuDNBUSY are exactly the same.
> > 
> > From mine experience it is more readable. Please consider for
> > example the Fig. A1 - Interface state transition diagram from page
> > 28 at DFU_1.1.pdf spec (link below).
> > 
> > http://www.usb.org/developers/devclass_docs/DFU_1.1.pdf
> 
> OK, good.
> 
> > > > +   case DFU_STATE_dfuDNBUSY:
> > > > +   f_dfu->dfu_state = DFU_STATE_dfuDNLOAD_IDLE;
> > > > +   break;
> > > > +   case DFU_STATE_dfuMANIFEST_SYNC:
> > > > +   break;
> > > > +   default:
> > > > +   break;
> > > > +   }
> > > > +
> > > > +   /* send status response */
> > > > +   dstat->bStatus = f_dfu->dfu_status;
> > > > +   /* FIXME: set dstat->bwPollTimeout */
> > > 
> > > FIXME ... so fix it ;-)
> > 
> > This is not u-boot related - will be removed
> > 
> > > > +   dstat->bState = f_dfu->dfu_state;
> > > > +   dstat->iString = 0;
> > > > +}
> > > > +
> > > > +static void handle_getstate(struct usb_request *req)
> > > > +{
> > > > +   struct f_dfu *f_dfu = req->context;
> > > > +
> > > > +   ((u8 *)req->buf)[0] = f_dfu->dfu_state & 0xff;
> > > 
> > > Now ... this is ubercrazy ... can't this be made without this
> > > typecasting voodoo?
> > 
> > The problem is that req->buf is a void pointer. And the goal is to
> > store dfu state at 8 bits.
> 
> Sure, but why not make the buffer u8 ?

The req->buf is a member of usb_request defined at gadget.h.

It represents the request from USB. I cannot guarantee, that we will
always regard data pointed by buf as u8. For flexibility of gadget
usage it is safer to leave it as void pointer.

> 
> > > > +   req->actual = sizeof(u8);
> > > > +}
> > > > +
> 
> [...]
> 
> > > > +static int
> > > > +dfu_prepare_strings(struct f_dfu *f_dfu, int n)
> > > > +{
> > > > +   struct dfu_entity *de = NULL;
> > > > +   int i = 0;
> > > > +
> > > > +   f_dfu->strings = calloc(((n + 1) * sizeof(struct
> > > > usb_string)), 1);
> > > 
> > > calloc(n, 1) ... that's the same as malloc(), isn't it ?
> > 
> > I now wonder how mine mind produced this :-)
> > 
> > Correct version:
> > 
> > f_dfu->strings = calloc(sizeof(struct usb_string), n + 1);
> > 
> > I prefer calloc, since it delivers zeroed memory.
> 
> ok, that's better :)
> 
> [...]



-- 
Best regards,

Lukasz Majewski

Samsung Poland R&D Center | Linux Platform Group
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 3/7] dfu: DFU backend implementation

2012-07-04 Thread Lukasz Majewski
Hi Marek,

> Dear Lukasz Majewski,
> 
> > Hi Marek,
> > 
> > > Dear Lukasz Majewski,
> > > 
> > > > New, separate driver at ./drivers/dfu has been added. It allows
> > > > platform and storage independent operation of DFU.
> > > > 
> > > > Signed-off-by: Lukasz Majewski 
> > > > Signed-off-by: Kyungmin Park 
> > > > Cc: Marek Vasut 
> > > > ---
> > > 
> > > [...]
> > > 
> > > > +#include 
> > > > +#include 
> > > > +#include 
> > > > +#include 
> > > > +#include 
> > > > +#include 
> > > > +#include 
> > > > +
> > > > +static LIST_HEAD(dfu_list);
> > > > +static int dfu_alt_num;
> > > > +
> > > > +static int dfu_find_alt_num(char *s)
> > > > +{
> > > > +   int i = 0;
> > > > +
> > > > +   for (; *s; s++)
> > > > +   if (*s == ';')
> > > > +   i++;
> > > > +
> > > > +   return ++i;
> > > > +}
> > > > +
> > > > +static char *dfu_extract_entity(char** env)
> > > > +{
> > > > +   char *s = *env;
> > > > +
> > > > +   strsep(env, ";");
> > > > +   return s;
> > > > +}
> > > 
> > > Shall we not make these all generic? They seem to be quite helpful
> > > components.
> > 
> > It is a good topic for a discussion if those functions shall be
> > moved to ./lib/string.c.
> > I regarded them as a "little" helper functions for parsing DFU alt
> > setting env variable. Those are very short and build with methods
> > exported from string.c
> 
> Good point
> 
> > > > +
> > > > +char *dfu_extract_token(char** e, int *n)
> > > > +{
> > > > +   char *st = *e;
> > > > +
> > > > +   debug("%s: %s\n", __func__, st);
> > > > +
> > > > +   strsep(e, " ");
> > > > +   *n = *e - st;
> > > > +
> > > > +   return st;
> > > > +}
> > > > +
> > > > +static unsigned char __aligned(CONFIG_SYS_CACHELINE_SIZE)
> > > > +
> > > > dfu_buf[DFU_DATA_BUF_SIZE];
> > > 
> > > Can we not stack-allocate it with ALLOC_CACHE_ALIGN_BUFFER()?
> > 
> > The dfu_buf is 4 MiB (this is the size of DFU_DATA_BUF_SIZE). I
> > don't think, that allocating it on the stack (for stack allocation
> > the ALLOC_CACHE_ALIGN_BUFFER() is designed) is a good idea.
> 
> Heh, agreed :-)
> 
> > > [...]
> > > 
> > > > diff --git a/include/dfu.h b/include/dfu.h
> > > > new file mode 100644
> > > > index 000..f7d823b
> > > > --- /dev/null
> > > > +++ b/include/dfu.h
> > > 
> > > [...]
> > > 
> > > > +struct dfu_entity {
> > > > +   charname[DFU_NAME_SIZE];
> > > > +   int alt;
> > > > +   void*dev_private;
> > > > +   int dev_num;
> > > > +   enum dfu_device_typedev_type;
> > > > +   enum dfu_layout layout;
> > > > +
> > > > +   union {
> > > > +   struct mmc_internal_data mmc;
> > > 
> > > This union seems redundant ;-)
> > 
> > Good point :-), but I predict, that DFU will be used to program
> > other memory types (OneNAND, or NAND). To support those, one needs
> > to extend the union with e.g struct onenand_internal_data onenand.
> > 
> > Since we don't have so many memory types, I think that union usage
> > is acceptable.
> 
> And will those pieces be implemented any soon ? :)

:-). Since I'm the OneNAND custodian I shall keep in the back of my
head, that support for this memory is important :-)

> 
> > > [...]
> 
> Best regards,
> Marek Vasut



-- 
Best regards,

Lukasz Majewski

Samsung Poland R&D Center | Linux Platform Group
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 4/7] dfu: MMC specific routines for DFU operation

2012-07-04 Thread Lukasz Majewski
Hi Marek,

> Dear Lukasz Majewski,
> 
> [...]
> 
> > > > > Holy Moly ... can we not make this into simple calls to those
> > > > > subsystems ? Instead invoking command is crazy ;-)
> > > > 
> > > > Are they really simple?  There's a few other places we do this,
> > > > and so long as it's documented that DFU depends on
> > > > CONFIG_FAT_WRITE for writing to fat and so forth.
> > > 
> > > Well ain't it easier to call fat_write() or similar?
> > 
> > I've decided to use run_command on a purpose.
> > 
> > This call provides clean and reliable API. It is very unlikely that
> > the mmc write command will change (or
> > any other).
> > On the other hand the fields of struct mmc are changed from time to
> > time.
> 
> I'm afraid it might change with the driver model soon.
You have probably more information than I about the driver model :-)

Since I know u-boot this API was stable. If it changes, I will adjust
the sprintf :-)

> 
> > Moreover, mmc drivers are also a subject to change (like adding
> > dw_mmc recently).
> > Using run_command also takes the burden of mmc_init() related calls.
> > 
> > Of course the run_command's downside is the speed of execution. But
> > is it so important when one considers, the firmware update?
> 
> But as Stephen pointed out, the type checking is much better when
> used as function.
Yes, I agree about the type check. 

Contrary, the cmd_mmc.c code is not checking the correctness of passed
data. It performs strncmp, then simple_strtoul and with this parameter
calls 
mmc->block_dev.block_read(). For this command such behavior is
acceptable.


> 
> > Side note: DFU uses only EP0 (for transfer and configuration), so
> > this is rather slow communication link.
> 
> I see
> 
> > I'm open for discussion.
> 
> Yes please, I think I started some bad flamewar in here :/

Maybe we come up with a better solution thanks to that :-).


-- 
Best regards,

Lukasz Majewski

Samsung Poland R&D Center | Linux Platform Group
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [STATUS] Final pull requests for -rc1?

2012-07-04 Thread Tom Rini
On Wed, Jul 04, 2012 at 05:10:06PM +0400, Ilya Yanok wrote:
> Hi Tom,
> 
> 02.07.2012 23:06, Tom Rini wrote:
> >On Mon, Jul 02, 2012 at 08:41:56PM +0200, Wolfgang Denk wrote:
> >
> >>Hello all,
> >>
> >>I would like to get out -rc1 ASAP.  If you have any patches queued
> >>that should make it into the upcoming release, then plase send your
> >>pull requezts as soon as possible.
> >>
> >>
> >>Albert, what are your plans for an ARM pull req?
> >I've got another round of fixes, pending a resolution for now on the USB
> >issue that needs to come in, certainly for release and since USB isn't
> >usable on my platforms, it'd be nice to be in -rc1.  Ilya, Marek, have
> >you guys agreed to something for now?
> 
> Yes. I just posted the modified version of your 2/6 patch. Your 1/6
> is also required but other I hope not anymore ;)

OK, thanks.  I'll do some testing and wait for Marek to ack :)  Then I
think it should go via the USB tree since it's all under drivers/usb/
now.

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 0/7] dfu:usb: Composite USB download gadget with DFU function

2012-07-04 Thread Lukasz Majewski
Those patches add support for composite USB download gadget.
This gadget (at least for now) is equipped with DFU download function.

A separate DFU back-end and front-end have been added.
Back-end is placed at ./drivers/dfu directory. The front-end is implemented
as USB function.

The back-end is written in a generic manner with storage device specific
code separated (eMMC).

DFU specification can be found at:
http://wiki.openmoko.org/wiki/USB_DFU_-_The_USB_Device_Firmware_Upgrade_standard

Example usage:

u-boot side: dfu mmc 0
PC: dfu-util -U IMAGE.bin -a uImage (for upload)
dfu-util -D uImage -a uImage (download)

To list the alt settings:
dfu mmc 0 list

Test HW:
Exynos4210 Trats board


Lukasz Majewski (7):
  dfu:usb: Support for g_dnl composite download gadget.
  dfu:usb: DFU USB function (f_dfu) support for g_dnl composite gadget
  dfu: DFU backend implementation
  dfu: MMC specific routines for DFU operation
  dfu:cmd: Support for DFU u-boot command
  arm:trats: Support for USB UDC driver at TRATS board.
  arm:trats: Enable g_dnl composite USB gadget with embedded DFU
function on TRATS

 Makefile|1 +
 board/samsung/trats/trats.c |8 +
 common/Makefile |1 +
 common/cmd_dfu.c|   81 +
 drivers/dfu/Makefile|   44 +++
 drivers/dfu/dfu.c   |  259 +++
 drivers/dfu/dfu_mmc.c   |  126 +++
 drivers/usb/gadget/Makefile |2 +
 drivers/usb/gadget/f_dfu.c  |  753 +++
 drivers/usb/gadget/f_dfu.h  |  100 ++
 drivers/usb/gadget/g_dnl.c  |  223 +
 include/configs/trats.h |   24 ++-
 include/dfu.h   |   99 ++
 include/g_dnl.h |   33 ++
 14 files changed, 1753 insertions(+), 1 deletions(-)
 create mode 100644 common/cmd_dfu.c
 create mode 100644 drivers/dfu/Makefile
 create mode 100644 drivers/dfu/dfu.c
 create mode 100644 drivers/dfu/dfu_mmc.c
 create mode 100644 drivers/usb/gadget/f_dfu.c
 create mode 100644 drivers/usb/gadget/f_dfu.h
 create mode 100644 drivers/usb/gadget/g_dnl.c
 create mode 100644 include/dfu.h
 create mode 100644 include/g_dnl.h

-- 
1.7.2.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 1/7] dfu:usb: Support for g_dnl composite download gadget.

2012-07-04 Thread Lukasz Majewski
Composite USB download gadget support (g_dnl) for download functions.
This code works on top of composite gadget.

Signed-off-by: Lukasz Majewski 
Signed-off-by: Kyungmin Park 
Cc: Marek Vasut 

---
Changes for v2:

- G_DNL_{VENDOR_NUM, PRODUCT_NUM and MANUFACTURER} defined at
./include/configs/.h
- Suspend and resume stub methods removed
- '\0' repleaced with plain 0
---
 drivers/usb/gadget/Makefile |1 +
 drivers/usb/gadget/g_dnl.c  |  223 +++
 include/g_dnl.h |   33 +++
 3 files changed, 257 insertions(+), 0 deletions(-)
 create mode 100644 drivers/usb/gadget/g_dnl.c
 create mode 100644 include/g_dnl.h

diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 87d1918..2c067c8 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -29,6 +29,7 @@ LIB   := $(obj)libusb_gadget.o
 ifdef CONFIG_USB_GADGET
 COBJS-y += epautoconf.o config.o usbstring.o
 COBJS-$(CONFIG_USB_GADGET_S3C_UDC_OTG) += s3c_udc_otg.o
+COBJS-$(CONFIG_USBDOWNLOAD_GADGET) += g_dnl.o
 endif
 ifdef CONFIG_USB_ETHER
 COBJS-y += ether.o epautoconf.o config.o usbstring.o
diff --git a/drivers/usb/gadget/g_dnl.c b/drivers/usb/gadget/g_dnl.c
new file mode 100644
index 000..fe996b4
--- /dev/null
+++ b/drivers/usb/gadget/g_dnl.c
@@ -0,0 +1,223 @@
+/*
+ * g_dnl.c -- USB Downloader Gadget
+ *
+ * Copyright (C) 2012 Samsung Electronics
+ * Lukasz Majewski  
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include "f_dfu.h"
+
+#include "gadget_chips.h"
+#include "composite.c"
+
+/*
+ * One needs to define the following:
+ * G_DNL_VENDOR_NUM
+ * G_DNL_PRODUCT_NUM
+ * G_DNL_MANUFACTURER
+ * at e.g. ./include/configs/.h
+ */
+
+#define STRING_MANUFACTURER 25
+#define STRING_PRODUCT 2
+#define STRING_USBDOWN 2
+#define CONFIG_USBDOWNLOADER 2
+
+#define DRIVER_VERSION "usb_dnl 2.0"
+
+static const char shortname[] = "usb_dnl_";
+static const char product[] = "USB download gadget";
+static const char manufacturer[] = G_DNL_MANUFACTURER;
+
+static struct usb_device_descriptor device_desc = {
+   .bLength =  sizeof device_desc,
+   .bDescriptorType =  USB_DT_DEVICE,
+
+   .bcdUSB =   __constant_cpu_to_le16(0x0200),
+   .bDeviceClass = USB_CLASS_COMM,
+   .bDeviceSubClass =  0x02,   /*0x02:CDC-modem , 0x00:CDC-serial*/
+
+   .idVendor = __constant_cpu_to_le16(G_DNL_VENDOR_NUM),
+   .idProduct =__constant_cpu_to_le16(G_DNL_PRODUCT_NUM),
+   .iProduct = STRING_PRODUCT,
+   .bNumConfigurations =   1,
+};
+
+static const struct usb_descriptor_header *otg_desc[] = {
+   (struct usb_descriptor_header *) &(struct usb_otg_descriptor){
+   .bLength =  sizeof(struct usb_otg_descriptor),
+   .bDescriptorType =  USB_DT_OTG,
+   .bmAttributes = USB_OTG_SRP,
+   },
+   NULL,
+};
+
+/* static strings, in UTF-8 */
+static struct usb_string odin_string_defs[] = {
+   { 0, manufacturer, },
+   { 1, product, },
+};
+
+static struct usb_gadget_strings odin_string_tab = {
+   .language   = 0x0409,   /* en-us */
+   .strings= odin_string_defs,
+};
+
+static struct usb_gadget_strings *g_dnl_composite_strings[] = {
+   &odin_string_tab,
+   NULL,
+};
+
+static int g_dnl_unbind(struct usb_composite_dev *cdev)
+{
+   debug("%s\n", __func__);
+   return 0;
+}
+
+static int g_dnl_do_config(struct usb_configuration *c)
+{
+   int ret = -1;
+   char *s = (char *) c->cdev->driver->name;
+
+   debug("%s: configuration: 0x%p composite dev: 0x%p\n",
+ __func__, c, c->cdev);
+
+   if (gadget_is_otg(c->cdev->gadget)) {
+   c->descriptors = otg_desc;
+   c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
+   }
+
+   printf("GADGET DRIVER: %s\n", s);
+
+   if (!strcmp(s, "usb_dnl_dfu"))
+   ret = dfu_add(c);
+
+   return ret;
+}
+
+static int g_dnl_config_register(struct usb_composite_dev *cdev)
+{
+   debug("%s:\n", __func__);
+   static struct usb_configuration config = {
+   .label = "usb_d

[U-Boot] [PATCH v2 4/7] dfu: MMC specific routines for DFU operation

2012-07-04 Thread Lukasz Majewski
Support for MMC storage devices to work with DFU framework.

Signed-off-by: Lukasz Majewski 
Signed-off-by: Kyungmin Park 
Cc: Marek Vasut 

---
Changes for v2:
- None
---
 drivers/dfu/Makefile  |1 +
 drivers/dfu/dfu_mmc.c |  126 +
 2 files changed, 127 insertions(+), 0 deletions(-)
 create mode 100644 drivers/dfu/dfu_mmc.c

diff --git a/drivers/dfu/Makefile b/drivers/dfu/Makefile
index 7736485..7b717bc 100644
--- a/drivers/dfu/Makefile
+++ b/drivers/dfu/Makefile
@@ -26,6 +26,7 @@ include $(TOPDIR)/config.mk
 LIB= $(obj)libdfu.o
 
 COBJS-$(CONFIG_DFU_FUNCTION) += dfu.o
+COBJS-$(CONFIG_DFU_MMC) += dfu_mmc.o
 
 SRCS:= $(COBJS-y:.o=.c)
 OBJS   := $(addprefix $(obj),$(COBJS-y))
diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c
new file mode 100644
index 000..3151fbc
--- /dev/null
+++ b/drivers/dfu/dfu_mmc.c
@@ -0,0 +1,126 @@
+/*
+ * dfu.c -- DFU back-end routines
+ *
+ * Copyright (C) 2012 Samsung Electronics
+ * authors: Andrzej Pietrasiewicz 
+ * Lukasz Majewski 
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include 
+#include 
+#include 
+
+int dfu_write_medium_mmc(struct dfu_entity *dfu, void *buf, long *len)
+{
+   ALLOC_CACHE_ALIGN_BUFFER(char, cmd_buf, DFU_CMD_BUF_SIZE);
+
+   memset(cmd_buf, '\0', sizeof(cmd_buf));
+
+   switch (dfu->layout) {
+   case RAW_ADDR:
+   sprintf(cmd_buf, "mmc write 0x%x %x %x", (unsigned int) buf,
+   dfu->data.mmc.lba_start, dfu->data.mmc.lba_size);
+   break;
+   case FAT:
+   sprintf(cmd_buf, "fatwrite mmc %d:%d 0x%x %s %lx",
+   dfu->data.mmc.dev, dfu->data.mmc.part,
+   (unsigned int) buf, dfu->name, *len);
+   break;
+   default:
+   printf("%s: Wrong layout!\n", __func__);
+   }
+
+   debug("%s: %s 0x%p\n", __func__, cmd_buf, cmd_buf);
+   run_command(cmd_buf, 0);
+
+   return 0;
+}
+
+int dfu_read_medium_mmc(struct dfu_entity *dfu, void *buf, long *len)
+{
+   ALLOC_CACHE_ALIGN_BUFFER(char, cmd_buf, DFU_CMD_BUF_SIZE);
+   char *str_env = NULL;
+   int ret = 0;
+
+   memset(cmd_buf, '\0', sizeof(cmd_buf));
+
+   switch (dfu->layout) {
+   case RAW_ADDR:
+   sprintf(cmd_buf, "mmc read 0x%x %x %x", (unsigned int) buf,
+   dfu->data.mmc.lba_start, dfu->data.mmc.lba_size);
+
+   *len = dfu->data.mmc.lba_blk_size * dfu->data.mmc.lba_size;
+   break;
+   case FAT:
+   sprintf(cmd_buf, "fatload mmc %d:%d 0x%x %s",
+   dfu->data.mmc.dev, dfu->data.mmc.part,
+   (unsigned int) buf, dfu->name);
+   break;
+   default:
+   printf("%s: Wrong layout!\n", __func__);
+   }
+
+   debug("%s: %s 0x%p\n", __func__, cmd_buf, cmd_buf);
+
+   ret = run_command(cmd_buf, 0);
+   if (ret) {
+   puts("dfu: Read error!\n");
+   return ret;
+   }
+
+   if (dfu->layout != RAW_ADDR) {
+   str_env = getenv("filesize");
+   if (str_env == NULL) {
+   puts("dfu: Wrong file size!\n");
+   return -1;
+   }
+
+   *len = simple_strtoul(str_env, NULL, 16);
+   }
+   return ret;
+}
+
+int dfu_fill_entity_mmc(struct dfu_entity *dfu, char* s)
+{
+   char *st = NULL;
+   int n = 0;
+
+   dfu->dev_type = MMC;
+   st = dfu_extract_token(&s, &n);
+
+   if (!strncmp(st, "mmc", n)) {
+   dfu->layout = RAW_ADDR;
+
+   dfu->data.mmc.lba_start = simple_strtoul(s, &s, 16);
+   dfu->data.mmc.lba_size = simple_strtoul(++s, &s, 16);
+   dfu->data.mmc.lba_blk_size = get_mmc_blk_size(dfu->dev_num);
+
+   } else if (!strncmp(st, "fat", n)) {
+   dfu->layout = FAT;
+
+   dfu->data.mmc.dev = simple_strtoul(s, &s, 10);
+   dfu->data.mmc.part = simple_strtoul(++s, &s, 10);
+
+   } else {
+   printf("%s: Wrong memory layout!\n", __func__);
+   }
+
+   dfu->read_medium = dfu_read_medium_mmc;
+   dfu->write_medium = dfu_write_medium_mmc;
+
+   return 0;
+}
-- 
1.7.2.3

_

[U-Boot] [PATCH v2 2/7] dfu:usb: DFU USB function (f_dfu) support for g_dnl composite gadget

2012-07-04 Thread Lukasz Majewski
Support for f_dfu USB function.

Signed-off-by: Lukasz Majewski 
Signed-off-by: Kyungmin Park 
Cc: Marek Vasut 

---
Changes for v2:

- Replace kzalloc and kfree with free and calloc
- Reorganization of calloc calls
- Misspelling corrected
- Redesign of DFU state machine from "switch case" to function pointers
- Split the dfu_handle method to separate functions for each DFU state
---
 drivers/usb/gadget/Makefile |1 +
 drivers/usb/gadget/f_dfu.c  |  753 +++
 drivers/usb/gadget/f_dfu.h  |  100 ++
 3 files changed, 854 insertions(+), 0 deletions(-)
 create mode 100644 drivers/usb/gadget/f_dfu.c
 create mode 100644 drivers/usb/gadget/f_dfu.h

diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 2c067c8..5bbdd36 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -30,6 +30,7 @@ ifdef CONFIG_USB_GADGET
 COBJS-y += epautoconf.o config.o usbstring.o
 COBJS-$(CONFIG_USB_GADGET_S3C_UDC_OTG) += s3c_udc_otg.o
 COBJS-$(CONFIG_USBDOWNLOAD_GADGET) += g_dnl.o
+COBJS-$(CONFIG_DFU_FUNCTION) += f_dfu.o
 endif
 ifdef CONFIG_USB_ETHER
 COBJS-y += ether.o epautoconf.o config.o usbstring.o
diff --git a/drivers/usb/gadget/f_dfu.c b/drivers/usb/gadget/f_dfu.c
new file mode 100644
index 000..c1ef70c
--- /dev/null
+++ b/drivers/usb/gadget/f_dfu.c
@@ -0,0 +1,753 @@
+/*
+ * f_dfu.c -- Device Firmware Update USB function
+ *
+ * Copyright (C) 2012 Samsung Electronics
+ * authors: Andrzej Pietrasiewicz 
+ *  Lukasz Majewski 
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include "f_dfu.h"
+
+struct f_dfu {
+   struct usb_function usb_function;
+
+   struct usb_descriptor_header**function;
+   struct usb_string   *strings;
+
+   /* when configured, we have one config */
+   u8  config;
+   u8  altsetting;
+   enum dfu_state  dfu_state;
+   unsigned intdfu_status;
+
+   /* Send/received block number is handy for data integrity check */
+   int blk_seq_num;
+};
+
+typedef int (*dfu_state_fn) (struct f_dfu *,
+const struct usb_ctrlrequest *,
+struct usb_gadget *,
+struct usb_request *);
+
+static inline struct f_dfu *func_to_dfu(struct usb_function *f)
+{
+   return container_of(f, struct f_dfu, usb_function);
+}
+
+static const struct dfu_function_descriptor dfu_func = {
+   .bLength =  sizeof dfu_func,
+   .bDescriptorType =  DFU_DT_FUNC,
+   .bmAttributes = DFU_BIT_WILL_DETACH |
+   DFU_BIT_MANIFESTATION_TOLERANT |
+   DFU_BIT_CAN_UPLOAD |
+   DFU_BIT_CAN_DNLOAD,
+   .wDetachTimeOut =   0,
+   .wTransferSize =DFU_USB_BUFSIZ,
+   .bcdDFUVersion =__constant_cpu_to_le16(0x0110),
+};
+
+static struct usb_interface_descriptor dfu_intf_runtime = {
+   .bLength =  sizeof dfu_intf_runtime,
+   .bDescriptorType =  USB_DT_INTERFACE,
+   .bNumEndpoints =0,
+   .bInterfaceClass =  USB_CLASS_APP_SPEC,
+   .bInterfaceSubClass =   1,
+   .bInterfaceProtocol =   1,
+   /* .iInterface = DYNAMIC */
+};
+
+static struct usb_descriptor_header *dfu_runtime_descs[] = {
+   (struct usb_descriptor_header *) &dfu_intf_runtime,
+   NULL,
+};
+
+static struct usb_qualifier_descriptor dev_qualifier = {
+   .bLength =  sizeof dev_qualifier,
+   .bDescriptorType =  USB_DT_DEVICE_QUALIFIER,
+   .bcdUSB =   __constant_cpu_to_le16(0x0200),
+   .bDeviceClass = USB_CLASS_VENDOR_SPEC,
+   .bNumConfigurations =   1,
+};
+
+static const char dfu_name[] = "Device Firmware Upgrade";
+
+/*
+ * static strings, in UTF-8
+ *
+ * dfu_generic configuration
+ */
+static struct usb_string strings_dfu_generic[] = {
+   [0].s = dfu_name,
+   {  }/* end of list */
+};
+
+static struct usb_gadget_strings stringtab_dfu_generic = {
+   .language

[U-Boot] [PATCH v2 3/7] dfu: DFU backend implementation

2012-07-04 Thread Lukasz Majewski
New, separate driver at ./drivers/dfu has been added. It allows platform
and storage independent operation of DFU.

Signed-off-by: Lukasz Majewski 
Signed-off-by: Kyungmin Park 
Cc: Marek Vasut 

---
Changes for v2:
- None
---
 Makefile |1 +
 drivers/dfu/Makefile |   43 
 drivers/dfu/dfu.c|  259 ++
 include/dfu.h|   99 +++
 4 files changed, 402 insertions(+), 0 deletions(-)
 create mode 100644 drivers/dfu/Makefile
 create mode 100644 drivers/dfu/dfu.c
 create mode 100644 include/dfu.h

diff --git a/Makefile b/Makefile
index 0197239..c37dcf3 100644
--- a/Makefile
+++ b/Makefile
@@ -271,6 +271,7 @@ LIBS += drivers/pci/libpci.o
 LIBS += drivers/pcmcia/libpcmcia.o
 LIBS += drivers/power/libpower.o
 LIBS += drivers/spi/libspi.o
+LIBS += drivers/dfu/libdfu.o
 ifeq ($(CPU),mpc83xx)
 LIBS += drivers/qe/libqe.o
 LIBS += arch/powerpc/cpu/mpc8xxx/ddr/libddr.o
diff --git a/drivers/dfu/Makefile b/drivers/dfu/Makefile
new file mode 100644
index 000..7736485
--- /dev/null
+++ b/drivers/dfu/Makefile
@@ -0,0 +1,43 @@
+#
+# Copyright (C) 2012 Samsung Electronics
+# Lukasz Majewski 
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# 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., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB= $(obj)libdfu.o
+
+COBJS-$(CONFIG_DFU_FUNCTION) += dfu.o
+
+SRCS:= $(COBJS-y:.o=.c)
+OBJS   := $(addprefix $(obj),$(COBJS-y))
+
+$(LIB):$(obj).depend $(OBJS)
+   $(call cmd_link_o_target, $(OBJS))
+
+#
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#
diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
new file mode 100644
index 000..63733fb
--- /dev/null
+++ b/drivers/dfu/dfu.c
@@ -0,0 +1,259 @@
+/*
+ * dfu.c -- DFU back-end routines
+ *
+ * Copyright (C) 2012 Samsung Electronics
+ * authors: Andrzej Pietrasiewicz 
+ * Lukasz Majewski 
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static LIST_HEAD(dfu_list);
+static int dfu_alt_num;
+
+static int dfu_find_alt_num(char *s)
+{
+   int i = 0;
+
+   for (; *s; s++)
+   if (*s == ';')
+   i++;
+
+   return ++i;
+}
+
+static char *dfu_extract_entity(char** env)
+{
+   char *s = *env;
+
+   strsep(env, ";");
+   return s;
+}
+
+char *dfu_extract_token(char** e, int *n)
+{
+   char *st = *e;
+
+   debug("%s: %s\n", __func__, st);
+
+   strsep(e, " ");
+   *n = *e - st;
+
+   return st;
+}
+
+static unsigned char __aligned(CONFIG_SYS_CACHELINE_SIZE)
+dfu_buf[DFU_DATA_BUF_SIZE];
+
+int dfu_write(struct dfu_entity *dfu, void *buf, int size, int blk_seq_num)
+{
+   static unsigned char *i_buf;
+   static int i_blk_seq_num;
+   long w_size = 0;
+   int ret = 0;
+
+   debug("%s: name: %s buf: 0x%p size: 0x%x p_num: 0x%x i_buf: 0x%p\n",
+  __func__, dfu->name, buf, size, blk_seq_num, i_buf);
+
+   if (blk_seq_num == 0) {
+   memset(dfu_buf, '\0', sizeof(dfu_buf));
+   i_buf = dfu_buf;
+   i_blk_seq_num = 0;
+   }
+
+   if (i_blk_seq_num++ != blk_seq_num) {
+   printf("%s: Wrong sequence number! [%d] [%d]\n",
+  __func__, i_blk_seq_num, blk_seq_num);
+   return -1;
+   }
+
+   me

[U-Boot] [PATCH v2 5/7] dfu:cmd: Support for DFU u-boot command

2012-07-04 Thread Lukasz Majewski
Support for u-boot's command line command "dfu   [list]".

Signed-off-by: Lukasz Majewski 
Signed-off-by: Kyungmin Park 
Cc: Marek Vasut 

---
Changes for v2:
- None
---
 common/Makefile  |1 +
 common/cmd_dfu.c |   81 ++
 2 files changed, 82 insertions(+), 0 deletions(-)
 create mode 100644 common/cmd_dfu.c

diff --git a/common/Makefile b/common/Makefile
index 31175e3..9d60fe1 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -184,6 +184,7 @@ COBJS-$(CONFIG_MENU) += menu.o
 COBJS-$(CONFIG_MODEM_SUPPORT) += modem.o
 COBJS-$(CONFIG_UPDATE_TFTP) += update.o
 COBJS-$(CONFIG_USB_KEYBOARD) += usb_kbd.o
+COBJS-$(CONFIG_CMD_DFU) += cmd_dfu.o
 endif
 
 ifdef CONFIG_SPL_BUILD
diff --git a/common/cmd_dfu.c b/common/cmd_dfu.c
new file mode 100644
index 000..ceb0f54
--- /dev/null
+++ b/common/cmd_dfu.c
@@ -0,0 +1,81 @@
+/*
+ * cmd_dfu.c -- dfu command
+ *
+ * Copyright (C) 2012 Samsung Electronics
+ * authors: Andrzej Pietrasiewicz 
+ * Lukasz Majewski 
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+   char *str_env = NULL, *env_bkp = NULL;
+   static char *s = "dfu";
+   int ret = 0;
+
+   if (argc < 3)
+   return CMD_RET_USAGE;
+
+   str_env = getenv("dfu_alt_info");
+   if (str_env == NULL) {
+   printf("%s: \"dfu_alt_info\" env variable not defined!\n",
+  __func__);
+   return CMD_RET_FAILURE;
+   }
+
+   env_bkp = strdup(str_env);
+   ret = dfu_config_entities(env_bkp, argv[1],
+   (int)simple_strtoul(argv[2], NULL, 10));
+   if (ret)
+   return CMD_RET_FAILURE;
+
+   if (strcmp(argv[3], "list") == 0) {
+   dfu_show_entities();
+   dfu_free_entities();
+   free(env_bkp);
+   return CMD_RET_SUCCESS;
+   }
+
+   board_usb_init();
+   g_dnl_init(s);
+   while (1) {
+   if (ctrlc())
+   goto exit;
+
+   usb_gadget_handle_interrupts();
+   }
+exit:
+   g_dnl_cleanup();
+   dfu_free_entities();
+   free(env_bkp);
+
+   return CMD_RET_SUCCESS;
+}
+
+U_BOOT_CMD(dfu, CONFIG_SYS_MAXARGS, 1, do_dfu,
+   "Device Firmware Upgrade",
+   "  [list]\n"
+   "  - device firmware upgrade on a device \n"
+   "attached to interface \n"
+   "[list] - list available alt settings"
+);
-- 
1.7.2.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 6/7] arm:trats: Support for USB UDC driver at TRATS board.

2012-07-04 Thread Lukasz Majewski
Support for USB UDC driver at trats board.

Signed-off-by: Lukasz Majewski 
Signed-off-by: Kyungmin Park 
Cc: Marek Vasut 
Cc: Minkyu Kang 

---
Changes for v2:
- replace puts to debug
---
 board/samsung/trats/trats.c |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/board/samsung/trats/trats.c b/board/samsung/trats/trats.c
index a95a516..a557e5c 100644
--- a/board/samsung/trats/trats.c
+++ b/board/samsung/trats/trats.c
@@ -59,6 +59,8 @@ static int hwrevision(int rev)
return (board_rev & 0xf) == rev;
 }
 
+struct s3c_plat_otg_data s5pc210_otg_data;
+
 int board_init(void)
 {
gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
@@ -259,6 +261,12 @@ struct s3c_plat_otg_data s5pc210_otg_data = {
.usb_phy_ctrl   = EXYNOS4_USBPHY_CONTROL,
.usb_flags  = PHY0_SLEEP,
 };
+
+void board_usb_init(void)
+{
+   debug("USB_udc_probe\n");
+   s3c_udc_probe(&s5pc210_otg_data);
+}
 #endif
 
 static void pmic_reset(void)
-- 
1.7.2.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 7/7] arm:trats: Enable g_dnl composite USB gadget with embedded DFU function on TRATS

2012-07-04 Thread Lukasz Majewski
Enable the g_dnl composite USB gadget driver with embedded DFU function on it.
It now uses the composite gadget framework to support download specific
USB functions (like enabled DFU or USB Mass Storage).

Signed-off-by: Lukasz Majewski 
Signed-off-by: Kyungmin Park 
Cc: Marek Vasut 
Cc: Minkyu Kang 

---
Change for v2:
- Move the G_DNL_{VENDOR_NUM, PRODUCT_NUM and MANUFACTURER} definitions to
  ./include/configs/.h
---
 include/configs/trats.h |   24 +++-
 1 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/include/configs/trats.h b/include/configs/trats.h
index eb269b2..a24e73d 100644
--- a/include/configs/trats.h
+++ b/include/configs/trats.h
@@ -94,6 +94,21 @@
 #undef CONFIG_CMD_ONENAND
 #undef CONFIG_CMD_MTDPARTS
 #define CONFIG_CMD_MMC
+#define CONFIG_CMD_DFU
+
+/* FAT */
+#define CONFIG_CMD_FAT
+#define CONFIG_FAT_WRITE
+
+/* USB Composite download gadget - g_dnl */
+#define CONFIG_USBDOWNLOAD_GADGET
+#define CONFIG_DFU_FUNCTION
+#define CONFIG_DFU_MMC
+
+/* USB Samsung's IDs */
+#define G_DNL_VENDOR_NUM 0x04E8
+#define G_DNL_PRODUCT_NUM 0x6601
+#define G_DNL_MANUFACTURER "Samsung"
 
 #define CONFIG_BOOTDELAY   1
 #define CONFIG_ZERO_BOOTDELAY_CHECK
@@ -104,6 +119,11 @@
 #define CONFIG_BOOTBLOCK   "10"
 #define CONFIG_ENV_COMMON_BOOT "${console} ${meminfo}"
 
+#define CONFIG_DFU_ALT \
+   "dfu_alt_info=" \
+   "u-boot mmc 80 400;" \
+   "uImage fat 0 2\0" \
+
 #define CONFIG_ENV_OVERWRITE
 #define CONFIG_SYS_CONSOLE_INFO_QUIET
 #define CONFIG_SYS_CONSOLE_IS_IN_ENV
@@ -146,7 +166,8 @@
"mmcdev=0\0" \
"mmcbootpart=2\0" \
"mmcrootpart=3\0" \
-   "opts=always_resume=1"
+   "opts=always_resume=1\0" \
+   CONFIG_DFU_ALT
 
 /* Miscellaneous configurable options */
 #define CONFIG_SYS_LONGHELP/* undef to save memory */
@@ -209,6 +230,7 @@
 #define CONFIG_USB_GADGET
 #define CONFIG_USB_GADGET_S3C_UDC_OTG
 #define CONFIG_USB_GADGET_DUALSPEED
+#define CONFIG_USB_GADGET_VBUS_DRAW2
 
 /* LCD */
 #define CONFIG_EXYNOS_FB
-- 
1.7.2.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 2/7] dfu:usb: DFU USB function (f_dfu) support for g_dnl composite gadget

2012-07-04 Thread Marek Vasut
Dear Lukasz Majewski,

[...]

> > > > Now ... this is ubercrazy ... can't this be made without this
> > > > typecasting voodoo?
> > > 
> > > The problem is that req->buf is a void pointer. And the goal is to
> > > store dfu state at 8 bits.
> > 
> > Sure, but why not make the buffer u8 ?
> 
> The req->buf is a member of usb_request defined at gadget.h.
> 
> It represents the request from USB. I cannot guarantee, that we will
> always regard data pointed by buf as u8. For flexibility of gadget
> usage it is safer to leave it as void pointer.

OK, then it's good :)

[...]

Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 3/7] dfu: DFU backend implementation

2012-07-04 Thread Marek Vasut
Dear Lukasz Majewski,

[...]

> > 
> > And will those pieces be implemented any soon ? :)
> :
> :-). Since I'm the OneNAND custodian I shall keep in the back of my
> 
> head, that support for this memory is important :-)

Good, will look forward to it :)


Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] i.MX35PDK: Starting U-Boot from serial NOR-Flash

2012-07-04 Thread Hornung, Michael
Dear list,

I have an i.MX35PDK (mx35_3stack) with one U-Boot running within the NAND flash 
and one U-Boot running within the parallel NOR flash. 

I am now trying to get another one running in a serial NOR flash (S25FL064K) I 
soldered to the CSPI1 lines with CSPI1_SS1 as chip select line. 

Then I changed the bootstrap switches as follows:

BOOT_MODE[1:0]: 00  Internal boot
BT_MEM_CTL[1:0]:11  Expansion device (... , serial ROM)
BT_BUS_WIDTH:   1   3-byte address SPI device (serial Flash)
BT_MEM_TYPE[1:0]11  Serial ROM via SPI

According to my oscilloscope (SPI decoder included), the hardware setup behaves 
as it should do. The processor clocks, it activates the SS1 line, 
it sends read commands (0x03) following an address and the serial flash sends 
answers with bytes matching the u-boot.bin file.

I tried the following to build the u-boot binary:

1.  $ make mx35pdk
Then I burned u-boot.bin to the serial flash starting at address 0x00

2.  See 1. but burning the u-boot.bin file to the serial flash starting at 
address 0x400 (doc/README.imximage)

3.  $ make mx35pdk
$ cp board/freescale/mx51evk/imximage.cfg board/freescale/mx35pdk/
$ ./tools/mkimage -n ./board/freescale/mx35pdk/imximage.cfg -T 
imximage -e 0xA000 -d u-boot.bin u-boot.imx
Then I burned u-boot.imx to the serial flash starting at address 0x00

4.  See 3. but burning the u-boot.imx file to the serial flash starting at 
address 0x400 (doc/README.imximage)
 
As you might guess, none of the above attempts works. I get no serial output 
from U-Boot.

Has anyone a short description how to compile U-Boot in order to run from 
serial NOR flash?

Thank you very much in advance.

With best regards


Michael Hornung
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] i.MX35PDK: Starting U-Boot from serial NOR-Flash

2012-07-04 Thread Fabio Estevam
Hi Michael,

On Wed, Jul 4, 2012 at 10:29 AM, Hornung, Michael  wrote:

> 3.  $ make mx35pdk
> $ cp board/freescale/mx51evk/imximage.cfg board/freescale/mx35pdk/

This is not correct. You can not use the DDR settings from mx51evk
directly into mx35pdk.

You would need to create a imximage.cfg for mx35pdk.

Take a look at Freescale U-boot as a reference:
http://opensource.freescale.com/git?p=imx/uboot-imx.git;a=blob;f=board/freescale/mx35_3stack/flash_header.S;h=b662669f80061be18787eafea6eb3668786b6224;hb=329240314138de1fb8d3d08531e0c3408482972f

With these values you can create a correct imximage.cfg file for mx35pdk.

Currently mx35pdk does not support internal boot mode and that is the
reason you don't find a imximage currently.

So my suggestion for you is to try to boot from internal boot mode
first. Try booting from SD card first as this would be easier.

Once you managed to boot from SD card, you will be also able to boot
it from SPI NOR.

Regards,

Fabio Estevam
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] i.MX35PDK: Starting U-Boot from serial NOR-Flash

2012-07-04 Thread Fabio Estevam
On Wed, Jul 4, 2012 at 2:31 PM, Fabio Estevam  wrote:

> Take a look at Freescale U-boot as a reference:
> http://opensource.freescale.com/git?p=imx/uboot-imx.git;a=blob;f=board/freescale/mx35_3stack/flash_header.S;h=b662669f80061be18787eafea6eb3668786b6224;hb=329240314138de1fb8d3d08531e0c3408482972f

Just to clarify: this file has the RAM settings for two versions of
the board. Earlier mx35pdk came with mDDR and the more recent boards
have DDR2. Most likely your mx35pdk has DDR2 populated, do the values
you need to use are:

//DDR2 init
DCDGEN(2, 4, 0xB8001010, 0x0304)
DCDGEN(3, 4, 0xB8001010, 0x030C)
DCDGEN(4, 4, 0xB8001004, 0x007ffc3f)
DCDGEN(5, 4, 0xB8001000, 0x9222)
DCDGEN(6, 4, 0x8400, 0x12345678)
DCDGEN(7, 4, 0xB8001000, 0xA222)
DCDGEN(8, 4, 0x8000, 0x87654321)
DCDGEN(9, 4, 0x8000, 0x87654321)
DCDGEN(10, 4, 0xB8001000, 0xB222)
DCDGEN(11, 1, 0x8233, 0xda)
DCDGEN(12, 1, 0x82000780, 0xda)
DCDGEN(13, 1, 0x82000400, 0xda)
DCDGEN(14, 4, 0xB8001000, 0x82226080)
DCDGEN(15, 4, 0xB8001004, 0x007ffc3f)
DCDGEN(16, 4, 0xB800100C, 0x007ffc3f)
DCDGEN(17, 4, 0xB8001010, 0x0304)
DCDGEN(18, 4, 0xB8001008, 0x2000)

You just need to convert these values into the proper syntax for imximage.cfg.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RESEND 01/11] snowball: Add support for ux500 based snowball board

2012-07-04 Thread Wolfgang Denk
Dear mathieu.poir...@linaro.org,

In message <1341413915-7944-2-git-send-email-mathieu.poir...@linaro.org> you 
wrote:
> From: "Mathieu J. Poirier" 
> 
> Signed-off-by: Mathieu Poirier 
> Signed-off-by: John Rigby 
> ---
> Changes for v2:
>- White space cleanup.
>- Cleaned #defines.
>- Removal of unnecessary defines.
> ---
>  arch/arm/include/asm/arch-u8500/db8500_gpio.h   |   42 ++
>  arch/arm/include/asm/arch-u8500/db8500_pincfg.h |  172 ++
>  board/st-ericsson/snowball/Makefile |   51 ++
>  board/st-ericsson/snowball/db8500_pins.h|  745 
> +++
>  board/st-ericsson/snowball/snowball.c   |  185 ++
>  boards.cfg  |1 +
>  drivers/gpio/Makefile   |1 +
>  drivers/gpio/db8500_gpio.c  |  225 +++
>  drivers/serial/serial_pl01x.c   |2 +
>  include/configs/snowball.h  |  258 
>  10 files changed, 1682 insertions(+), 0 deletions(-)

Entry to MAINTAINERS missing.

Also, there are a large number of checkpatch warnings, mostly "line
over 80 characters".

Please fix.


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
No one wants war.
-- Kirk, "Errand of Mercy", stardate 3201.7
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RESEND 02/11] u8500: Moving prcmu to cpu directory

2012-07-04 Thread Wolfgang Denk
Dear mathieu.poir...@linaro.org,

In message <1341413915-7944-3-git-send-email-mathieu.poir...@linaro.org> you 
wrote:
> From: "Mathieu J. Poirier" 
> 
> This is to allow the prcmu functions to be used by multiple
> u8500-based processors.
> 
> Signed-off-by: Mathieu Poirier 
> Signed-off-by: John Rigby 
> ---
>  arch/arm/cpu/armv7/u8500/Makefile   |2 +-
>  arch/arm/cpu/armv7/u8500/prcmu.c|  164 ++
>  arch/arm/include/asm/arch-u8500/prcmu.h |   55 ++
>  board/st-ericsson/u8500/Makefile|2 +-
>  board/st-ericsson/u8500/prcmu-fw.h  |   55 --
>  board/st-ericsson/u8500/prcmu.c |  165 
> ---
>  board/st-ericsson/u8500/u8500_href.c|2 +-
>  7 files changed, 222 insertions(+), 223 deletions(-)

Again checkpatch warnings: "Whitespace before semicolon".

Please fix.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
In any group of employed individuals the only naturally  early  riser
is  _always_  the office manager, who will _always_ leave reproachful
little notes ... on the desks of their subordinates.
- Terry Pratchett, _Lords and Ladies_
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RESEND 11/11] snowball: Adding board specific cache cleanup routine

2012-07-04 Thread Wolfgang Denk
Dear mathieu.poir...@linaro.org,

In message <1341413915-7944-12-git-send-email-mathieu.poir...@linaro.org> you 
wrote:
> From: "Mathieu J. Poirier" 
> 
> Following ARM's reference manuel for initializing the cache - the
> kernel won't boot otherwise.
> 
> Signed-off-by: Mathieu Poirier 
> Signed-off-by: John Rigby 
> ---
> Changes for v2:
>- Correcting cache maintenance register address.
>- Invalidating all 16 bits in cache maintenance register.
>- Polling cache maintenance register for cleared bits.
>- Added comments to the code.
>- Re-worked commit description.
> ---
>  arch/arm/cpu/armv7/u8500/cpu.c |   16 
>  1 files changed, 16 insertions(+), 0 deletions(-)
...
> +void cpu_cache_initialization(void)
> +{
> + /* invalidate all cache entries */
> + *((volatile unsigned int *)(0xA041277C)) = 0x;
...
> + while (*((volatile unsigned int *)(0xA041277C)) & 0xFF)
...
> + *((volatile unsigned int *)(0xA0412900)) = 0xFF;
> + *((volatile unsigned int *)(0xA0412904)) = 0xFF;

NAK.  Please use proper I/O accessors, and declare a C struct to
access these registers.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
Was heißt Windows auf Indianisch? - "Weißer  Mann,  der  auf  Sanduhr
wartet!"
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [STATUS] Final pull requests for -rc1?

2012-07-04 Thread Marek Vasut
Dear Tom Rini,

> On Wed, Jul 04, 2012 at 05:10:06PM +0400, Ilya Yanok wrote:
> > Hi Tom,
> > 
> > 02.07.2012 23:06, Tom Rini wrote:
> > >On Mon, Jul 02, 2012 at 08:41:56PM +0200, Wolfgang Denk wrote:
> > >>Hello all,
> > >>
> > >>I would like to get out -rc1 ASAP.  If you have any patches queued
> > >>that should make it into the upcoming release, then plase send your
> > >>pull requezts as soon as possible.
> > >>
> > >>
> > >>Albert, what are your plans for an ARM pull req?
> > >
> > >I've got another round of fixes, pending a resolution for now on the USB
> > >issue that needs to come in, certainly for release and since USB isn't
> > >usable on my platforms, it'd be nice to be in -rc1.  Ilya, Marek, have
> > >you guys agreed to something for now?
> > 
> > Yes. I just posted the modified version of your 2/6 patch. Your 1/6
> > is also required but other I hope not anymore ;)
> 
> OK, thanks.  I'll do some testing and wait for Marek to ack :)  Then I
> think it should go via the USB tree since it's all under drivers/usb/
> now.

Was I CCed on those? I can't find them in my mailbox :-(

Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [STATUS] Final pull requests for -rc1?

2012-07-04 Thread Ilya Yanok

Dear Marek,

04.07.2012 21:57, Marek Vasut wrote:

OK, thanks.  I'll do some testing and wait for Marek to ack :)  Then I
think it should go via the USB tree since it's all under drivers/usb/
now.

Was I CCed on those? I can't find them in my mailbox :-(


There is actually only one updated patch. You were CCed ;) I posted the 
patch from my cogentembedded.com address.


Regards, Ilya.

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RESEND 11/11] snowball: Adding board specific cache cleanup routine

2012-07-04 Thread Mathieu Poirier
On 12-07-04 12:53 PM, Wolfgang Denk wrote:
> Dear mathieu.poir...@linaro.org,
> 
> In message <1341413915-7944-12-git-send-email-mathieu.poir...@linaro.org> you 
> wrote:
>> From: "Mathieu J. Poirier" 
>>
>> Following ARM's reference manuel for initializing the cache - the
>> kernel won't boot otherwise.
>>
>> Signed-off-by: Mathieu Poirier 
>> Signed-off-by: John Rigby 
>> ---
>> Changes for v2:
>>- Correcting cache maintenance register address.
>>- Invalidating all 16 bits in cache maintenance register.
>>- Polling cache maintenance register for cleared bits.
>>- Added comments to the code.
>>- Re-worked commit description.
>> ---
>>  arch/arm/cpu/armv7/u8500/cpu.c |   16 
>>  1 files changed, 16 insertions(+), 0 deletions(-)
> ...
>> +void cpu_cache_initialization(void)
>> +{
>> +/* invalidate all cache entries */
>> +*((volatile unsigned int *)(0xA041277C)) = 0x;
> ...
>> +while (*((volatile unsigned int *)(0xA041277C)) & 0xFF)
> ...
>> +*((volatile unsigned int *)(0xA0412900)) = 0xFF;
>> +*((volatile unsigned int *)(0xA0412904)) = 0xFF;
> 
> NAK.  Please use proper I/O accessors, and declare a C struct to
> access these registers.

Ok, to make sure I do this properly please point me to an example in the
code base where I can find I/O accessors.

Also, could you be more specific about the C struct you're like to see
implemented - again and example in the code would be welcomed.

Thanks,
Mathieu.

> 
> Best regards,
> 
> Wolfgang Denk
> 

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RESEND 11/11] snowball: Adding board specific cache cleanup routine

2012-07-04 Thread Fabio Estevam
On Wed, Jul 4, 2012 at 4:53 PM, Mathieu Poirier
 wrote:

>> NAK.  Please use proper I/O accessors, and declare a C struct to
>> access these registers.
>
> Ok, to make sure I do this properly please point me to an example in the
> code base where I can find I/O accessors.

Take at how the registers are read/written at  look at
arch/arm/cpu/armv7/mx6/soc.c , for example.

Regards,

Fabio Estevam
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RESEND 11/11] snowball: Adding board specific cache cleanup routine

2012-07-04 Thread Wolfgang Denk
Dear Mathieu,

In message <4ff49f2c.1030...@linaro.org> you wrote:
>
> >> +  *((volatile unsigned int *)(0xA0412900)) = 0xFF;
> >> +  *((volatile unsigned int *)(0xA0412904)) = 0xFF;
> > 
> > NAK.  Please use proper I/O accessors, and declare a C struct to
> > access these registers.
> 
> Ok, to make sure I do this properly please point me to an example in the
> code base where I can find I/O accessors.
> 
> Also, could you be more specific about the C struct you're like to see
> implemented - again and example in the code would be welcomed.

See arch/arm/include/asm/io.h for the respective I/O accessors.

As I have no idea which registers might be hidden by these magig
numbers 0xA0412900 or 0xA0412904 it's hard for me to find any good
example.  See for example accesses like the

writel(val, &ccm->cgr0);

in arch/arm/cpu/arm926ejs/mx25/generic.c, etc. etc.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
Remember, there's a big difference between kneeling down and  bending
over.   - Frank Zappa
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] ehci-hcd.c, musb_core, usb.h: Add USB_DMA_MINALIGN define for cache alignment

2012-07-04 Thread Marek Vasut
Dear Ilya Yanok,

> From: Tom Rini 
> 
> The USB spec says that 32 bytes is the minimum required alignment.
> However on some platforms we have a larger minimum requirement for cache
> coherency.  In those cases, use that value rather than the USB spec
> minimum.  We add a cpp check to  to define USB_DMA_MINALIGN and
> make use of it in ehci-hcd.c and musb_core.h.  We cannot use MAX() here
> as we are not allowed to have tests inside of align(...).
> 
> Cc: Marek Vasut 
> Signed-off-by: Tom Rini 
> [ilya.yanok]: fix size alignment, drop (incorrect) rounding
> when invalidating the buffer. If we got unaligned buffer from the
> upper layer -- that's definetely a bug so it's good to buzz
> about it. But we have to align the buffer length -- upper layers
> should take care to reserve enough space.
> Signed-off-by: Ilya Yanok 
> ---
> Changes from Tom's V4:
>  - Internal buffers should be not only address but also size aligned
>  - Don't try to fix unalignment of external buffer
>  - Fix also debug() checks in ehci_td_buffer() (though size check is
>meaningless: in the current API only size of transfer is passed
>which is not always the same as size of underlying buffer and
>can be unaligned.
> 
>  No bounce-buffering is implemented so unaligned buffers coming from
> the upper layers will still result in invalidate_dcache_range() vows.
> But I tested it with unaligned fatload and got strange result: no
> errors from invalidate_dcache_range, I got "EHCI timed out on TD"
> errors instead (the same situtation without this patch and cache
> disabled). Looks like unaligned buffers are problem for EHCI even
> without cache involved...
> Aligned fatload works like a charm.
> 
>  drivers/usb/host/ehci-hcd.c  |   89
> +- drivers/usb/musb/musb_core.h | 
>   2 +-
>  include/usb.h|   10 +
>  3 files changed, 65 insertions(+), 36 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
> index 04300be..74a5c76 100644
> --- a/drivers/usb/host/ehci-hcd.c
> +++ b/drivers/usb/host/ehci-hcd.c
> @@ -34,7 +34,9 @@ struct ehci_hccr *hccr; /* R/O registers, not need for
> volatile */ volatile struct ehci_hcor *hcor;
> 
>  static uint16_t portreset;
> -static struct QH qh_list __attribute__((aligned(32)));
> +static char __qh_list[ALIGN(sizeof(struct QH), USB_DMA_MINALIGN)]
> + __attribute__((aligned(USB_DMA_MINALIGN)));
> +static struct QH *qh_list = (struct QH *)__qh_list;

Maybe we should create DEFINE_ALIGNED_VARIABLE as a common.h macro?

>  static struct descriptor {
>   struct usb_hub_descriptor hub;
> @@ -172,13 +174,13 @@ static int ehci_td_buffer(struct qTD *td, void *buf,
> size_t sz) {
>   uint32_t delta, next;
>   uint32_t addr = (uint32_t)buf;
> - size_t rsz = roundup(sz, 32);
> + size_t rsz = roundup(sz, USB_DMA_MINALIGN);
>   int idx;
> 
>   if (sz != rsz)
>   debug("EHCI-HCD: Misaligned buffer size (%08x)\n", sz);
> 
> - if (addr & 31)
> + if (addr != ALIGN(addr, USB_DMA_MINALIGN))
>   debug("EHCI-HCD: Misaligned buffer address (%p)\n", buf);

Good :)

>   idx = 0;
> @@ -207,8 +209,12 @@ static int
>  ehci_submit_async(struct usb_device *dev, unsigned long pipe, void
> *buffer, int length, struct devrequest *req)
>  {
> - static struct QH qh __attribute__((aligned(32)));
> - static struct qTD qtd[3] __attribute__((aligned (32)));
> + static char *__qh[ALIGN(sizeof(struct QH), USB_DMA_MINALIGN)]
> + __attribute__((aligned(USB_DMA_MINALIGN)));
> + struct QH *qh = (struct QH *)__qh;
> + static char *__qtd[ALIGN(3*sizeof(struct qTD), USB_DMA_MINALIGN)]
> + __attribute__((aligned(USB_DMA_MINALIGN)));
> + struct qTD *qtd = (struct qTD *)__qtd;
>   int qtd_counter = 0;
> 
>   volatile struct qTD *vtd;
> @@ -229,8 +235,8 @@ ehci_submit_async(struct usb_device *dev, unsigned long
> pipe, void *buffer, le16_to_cpu(req->value), le16_to_cpu(req->value),
> le16_to_cpu(req->index));
> 
> - memset(&qh, 0, sizeof(struct QH));
> - memset(qtd, 0, sizeof(qtd));
> + memset(qh, 0, sizeof(struct QH));
> + memset(qtd, 0, 3 * sizeof(*qtd));
> 
>   toggle = usb_gettoggle(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe));
> 
> @@ -244,7 +250,7 @@ ehci_submit_async(struct usb_device *dev, unsigned long
> pipe, void *buffer, *   qh_overlay.qt_next .. 13-10 H
>* - qh_overlay.qt_altnext
>*/
> - qh.qh_link = cpu_to_hc32((uint32_t)&qh_list | QH_LINK_TYPE_QH);
> + qh->qh_link = cpu_to_hc32((uint32_t)qh_list | QH_LINK_TYPE_QH);
>   c = (usb_pipespeed(pipe) != USB_SPEED_HIGH &&
>usb_pipeendpoint(pipe) == 0) ? 1 : 0;
>   endpt = (8 << 28) |
> @@ -255,14 +261,14 @@ ehci_submit_async(struct usb_device *dev, unsigned
> long pipe, void *buffer, (usb_pipespeed(pipe) << 12) |
>   (usb_pipeen

[U-Boot] [PATCH 2/3] microblaze: Wire up dts configuration

2012-07-04 Thread Stephan Linz
- enable OF control and embedded OF
- set default device tree file name to 'microblaze'
- add CPP to dtc proxy: board/xilinx/dts/microblaze.dts
- add an empty but processable dts for microblaze-generic

Signed-off-by: Stephan Linz 
---
 board/xilinx/dts/microblaze.dts|1 +
 board/xilinx/microblaze-generic/dts/microblaze.dts |7 +++
 include/configs/microblaze-generic.h   |5 +
 3 files changed, 13 insertions(+), 0 deletions(-)
 create mode 100644 board/xilinx/dts/microblaze.dts
 create mode 100644 board/xilinx/microblaze-generic/dts/microblaze.dts

diff --git a/board/xilinx/dts/microblaze.dts b/board/xilinx/dts/microblaze.dts
new file mode 100644
index 000..bf984b0
--- /dev/null
+++ b/board/xilinx/dts/microblaze.dts
@@ -0,0 +1 @@
+/include/ BOARD_DTS
diff --git a/board/xilinx/microblaze-generic/dts/microblaze.dts 
b/board/xilinx/microblaze-generic/dts/microblaze.dts
new file mode 100644
index 000..2033309
--- /dev/null
+++ b/board/xilinx/microblaze-generic/dts/microblaze.dts
@@ -0,0 +1,7 @@
+/dts-v1/;
+/ {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   aliases {
+   } ;
+} ;
diff --git a/include/configs/microblaze-generic.h 
b/include/configs/microblaze-generic.h
index 2fd2279..386189f 100644
--- a/include/configs/microblaze-generic.h
+++ b/include/configs/microblaze-generic.h
@@ -31,6 +31,11 @@
 #defineCONFIG_MICROBLAZE   1
 #defineMICROBLAZE_V5   1
 
+/* Open Firmware DTS */
+#define CONFIG_OF_CONTROL  1
+#define CONFIG_OF_EMBED1
+#define CONFIG_DEFAULT_DEVICE_TREE microblaze
+
 /* linear flash memory */
 #ifdef XILINX_FLASH_START
 #defineFLASH
-- 
1.7.0.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 1/3] fdt: Add board specific dts inclusion

2012-07-04 Thread Stephan Linz
Some architectures, for example Microblaze, doesn't need a
splitted device tree because every Microblaze hw design is
different. The individuell Microblaze device tree will be
auto generated by FPGA design tools and could be used directly
with dtc.

The auto generated dts for Microblaze can not processed by CPP.
Unfortunately that is the default procedure in U-Boot to merge
a splitted device tree (substitution of ARCH_CPU_DTS).

Microblaze will never use the ARCH_CPU_DTS substitution and we
introduce the new board specific substitution variable BOARD_DTS
that points into vendor/board/dts subdir with the file name
of CONFIG_DEFAULT_DEVICE_TREE. The common dts file in vendor/dts
subdir (defined by CONFIG_DEFAULT_DEVICE_TREE) contain a single
include line that can processed by CPP:

/include/ BOARD_DTS

Signed-off-by: Stephan Linz 
---
 dts/Makefile |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/dts/Makefile b/dts/Makefile
index 914e479..b1f47a1 100644
--- a/dts/Makefile
+++ b/dts/Makefile
@@ -36,7 +36,8 @@ $(error Your architecture does not have device tree support 
enabled. \
 Please define CONFIG_ARCH_DEVICE_TREE))
 
 # We preprocess the device tree file provide a useful define
-DTS_CPPFLAGS := 
-DARCH_CPU_DTS=\"$(SRCTREE)/arch/$(ARCH)/dts/$(CONFIG_ARCH_DEVICE_TREE).dtsi\"
+DTS_CPPFLAGS := 
-DARCH_CPU_DTS=\"$(SRCTREE)/arch/$(ARCH)/dts/$(CONFIG_ARCH_DEVICE_TREE).dtsi\" \
+   
-DBOARD_DTS=\"$(SRCTREE)/board/$(VENDOR)/$(BOARD)/dts/$(DEVICE_TREE).dts\"
 
 all:   $(obj).depend $(LIB)
 
-- 
1.7.0.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 3/3] microblaze: Wire up OF support for emaclite

2012-07-04 Thread Stephan Linz
- expand the condition with CONFIG_OF_CONTROL

Signed-off-by: Stephan Linz 
---
 include/configs/microblaze-generic.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/configs/microblaze-generic.h 
b/include/configs/microblaze-generic.h
index 386189f..01e3421 100644
--- a/include/configs/microblaze-generic.h
+++ b/include/configs/microblaze-generic.h
@@ -79,7 +79,7 @@
 
 /* ethernet */
 #undef CONFIG_SYS_ENET
-#if defined(XILINX_EMACLITE_BASEADDR)
+#if defined(XILINX_EMACLITE_BASEADDR) || defined(CONFIG_OF_CONTROL)
 # define CONFIG_XILINX_EMACLITE1
 # define CONFIG_SYS_ENET
 #endif
-- 
1.7.0.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] ARM CONFIG_OF_CONTROL status

2012-07-04 Thread Stephan Linz
Am Mittwoch, den 04.07.2012, 08:24 +0200 schrieb Michal Simek: 
> On 07/03/2012 10:22 PM, Stephan Linz wrote:
> > Am Dienstag, den 03.07.2012, 12:21 -0700 schrieb Simon Glass:
> >> Hi,
> >>
> >> On Sun, Jul 1, 2012 at 10:43 PM, Michal Simek  wrote:
> >>
> >>> 2012/6/29 Stephan Linz:
>  Am Freitag, den 29.06.2012, 10:18 +0200 schrieb Michal Simek:
> > On 06/29/2012 04:32 AM, Simon Glass wrote:
> >> Hi,
> >>
> >> --snip--
> >
> > 
> >>>
> >>
> >> Well there is no inherent problem with having multiple include files,
> >> except that it is hard to support with the old dtc when there are in
> >> different subdirs.
> >>
> >> As a workaround, how about putting the include files in the
> >> board/vendor/dts subdir as well for now?
> >
> > Hi,
> >
> > good idea -- but they cannot be used directly. The substitution variable
> > ARCH_CPU_DTS is already reserved for dtsi in arch/cpu. The Microblaze
> > architecture needs a board specific dts onyl. That's why I think the new
> > substitution variable BOARD_DTS can be a option to solve the CPP problem
> > today and handle the dtc -i in the future.
> >
> > BOARD_DTS can point to anything below board/vendor and perhaps with a
> > new configuration option similar to CONFIG_DEFAULT_DEVICE_TREE the
> > substitution could be affected with freely selectable file name instead
> > of DEVICE_TREE only.
> 
> 
> ok.
> 
> Stephan: go ahead and create proper patch with empty dts/dtsi files.

Hi Michal,

see my patch set, that I've already submitted. The patches are based on
your patch set from last week. I've create a bundle on patchwork:

http://patchwork.ozlabs.org/bundle/rexut/microblaze-fdt/

Further you will need a QnD hack to avoid a compilation error due to
type conflicts (I've not explored here, not yet):

In file included from key_matrix.c:28:
include/malloc.h:364: error: conflicting types for 'memset'
include/linux/string.h:71: error: previous declaration of 'memset' was
here
include/malloc.h:365: error: conflicting types for 'memcpy'
include/linux/string.h:74: error: previous declaration of 'memcpy' was
here


Here is the QnD hack:


diff --git a/drivers/input/Makefile b/drivers/input/Makefile
index 5c831b2..5efeeb3 100644
--- a/drivers/input/Makefile
+++ b/drivers/input/Makefile
@@ -32,7 +32,7 @@ COBJS-y += keyboard.o pc_keyb.o
COBJS-$(CONFIG_PS2MULT) += ps2mult.o ps2ser.o
endif
COBJS-y += input.o
-COBJS-$(CONFIG_OF_CONTROL) += key_matrix.o
+#COBJS-$(CONFIG_OF_CONTROL) += key_matrix.o

COBJS  := $(COBJS-y)
SRCS   := $(COBJS:.o=.c)




br,
Stephan


___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v4 0/3] AM335x: Add USB support in u-boot.

2012-07-04 Thread Marek Vasut
Dear Tom Rini,

[...]

> >> This is as per my understanding. It could also cause confusions
> >> to some due to name. maybe :)
> > 
> > I'm no omap guru, Tom is. Tom?
> 
> I think what we need to do is take a shot at converting am35x.c and
> am335x.c into a 'ti_musb.[ch]' and per-family header files that give
> the register layout, etc, etc.  We need to see how maintainable or not
> such a setup will be.

Good, will you please poke into it, guys?

Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] arm:trats: loaduimage environment variable defied for TRATS target

2012-07-04 Thread Minkyu Kang
On 3 July 2012 18:41, Lukasz Majewski  wrote:
> Signed-off-by: Lukasz Majewski 
> Signed-off-by: Kyungmin Park 
> Cc: Minkyu Kang 
> ---
>  include/configs/trats.h |1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
>

applied to u-boot-samsung.

Thanks.
Minkyu Kang.
-- 
from. prom.
www.promsoft.net
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v4 1/1] zfs: Add ZFS filesystem support

2012-07-04 Thread Jorgen Lundman


Do I have to do anything special at this point, or can I assume everything 
is going according to plan?


Lund

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v4 1/1] zfs: Add ZFS filesystem support

2012-07-04 Thread Graeme Russ
Hi Lund,

On Thu, Jul 5, 2012 at 1:34 PM, Jorgen Lundman  wrote:
>
> Do I have to do anything special at this point, or can I assume everything
> is going according to plan?

I've had a quick look - the intrusion into common code is minimal
(additions to Makefiles) so the risk to U-Boot stability is extremely
low and there is now impact on code size of ZFS is not enabled. I see
no reason it can't be integrated.

I don't know where your original submission sat within the release
cycle. If is was before the closing of the merge window then maybe
Wolfgang will include it in the upcoming RC.

The only thing you need to do now is wait :)

Oh, and maybe prod the mailing list every now and again ;)

Regards,

Graeme
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 03/14] arm/km: convert mgcoge3un target to km_kirkwood

2012-07-04 Thread Holger Brunck
On 07/04/2012 11:21 AM, Prafulla Wadaskar wrote:
> 
> 
>> -Original Message-
>> From: Wolfgang Denk [mailto:w...@denx.de]
>> Sent: 03 July 2012 23:31
>> To: Prafulla Wadaskar
>> Cc: Holger Brunck; u-boot@lists.denx.de; Valentin Longchamp
>> Subject: Re: [U-Boot] [PATCH v2 03/14] arm/km: convert mgcoge3un
>> target to km_kirkwood
>>
>> Dear Prafulla,
>>
>> In message > VEXCH4.marvell.com> you wrote:
>>>
>>> Do you think I should pull this patch series, I hope it applies
>> cleanly on the recent master branch.
>>> Please confirm.
>>
>> I have to admit that I neither reviewed the patches in question, nor
>> did I follow the whole thread of communication in this patch series.
>> But the general rule is that if there are no strong argumentents
>> against a patch (like a clear NAK or a specific request for changes)
>> we will apply it.
> 
> Hi Wolfgang,
> This patch series was too old, I was trying to save my effors ;-D
> Finally I pulled these patches and tried to apply, but as I doubted it failed 
> :-(
>  
> Hi Hogler
> 
> I could not apply the said patch series to the latest u-boot-marvell.git 
> master branch
> 
> Pls re-submit it.
> 
> git-am U-Boot-1-9-arm-km-add-board-type-to-boards.cfg.patch
> 
> Applying arm/km: add board type to boards.cfg
> 
> error: patch failed: boards.cfg:138
> error: boards.cfg: patch does not apply
> error: patch failed: include/configs/km_kirkwood.h:42
> error: include/configs/km_kirkwood.h: patch does not apply
> Patch failed at 0001.
> When you have resolved this problem run "git-am --resolved".
> If you would prefer to skip this patch, instead run "git-am --skip"
> 

sorry but now I am completely confused. Here you say you want to apply 01-09
which includes
[PATCH v2 05/14] arm/km: correct init of 88e6352 switch in the reset_phy 
function
and
[PATCH v2 09/14] arm/km: add support for external switch configuration

this includes basic infrastructure for the managed switch.

In another thread you NAK the whole driver:
http://lists.denx.de/pipermail/u-boot/2012-July/127529.html

In a further different thread where I asked if I should provide updates which
apply cleanly you say no there are general updates needed:
http://lists.denx.de/pipermail/u-boot/2012-July/127531.html

For me these statements are conflicting.

So can you please state clearly which updates you request from myside for which
patch and which are from your point of view not acceptable and why? Thanks

Regards
Holger
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 03/14] arm/km: convert mgcoge3un target to km_kirkwood

2012-07-04 Thread Prafulla Wadaskar


> -Original Message-
> From: Holger Brunck [mailto:holger.bru...@keymile.com]
> Sent: 05 July 2012 11:24
> To: Prafulla Wadaskar
> Cc: Wolfgang Denk; u-boot@lists.denx.de; Valentin Longchamp
> Subject: Re: [U-Boot] [PATCH v2 03/14] arm/km: convert mgcoge3un
> target to km_kirkwood
> 
> On 07/04/2012 11:21 AM, Prafulla Wadaskar wrote:
> >
> >
> >> -Original Message-
> >> From: Wolfgang Denk [mailto:w...@denx.de]
> >> Sent: 03 July 2012 23:31
> >> To: Prafulla Wadaskar
> >> Cc: Holger Brunck; u-boot@lists.denx.de; Valentin Longchamp
> >> Subject: Re: [U-Boot] [PATCH v2 03/14] arm/km: convert mgcoge3un
> >> target to km_kirkwood
> >>
> >> Dear Prafulla,
> >>
> >> In message  >> VEXCH4.marvell.com> you wrote:
> >>>
> >>> Do you think I should pull this patch series, I hope it applies
> >> cleanly on the recent master branch.
> >>> Please confirm.
> >>
> >> I have to admit that I neither reviewed the patches in question,
> nor
> >> did I follow the whole thread of communication in this patch
> series.
> >> But the general rule is that if there are no strong argumentents
> >> against a patch (like a clear NAK or a specific request for
> changes)
> >> we will apply it.
> >
> > Hi Wolfgang,
> > This patch series was too old, I was trying to save my effors ;-D
> > Finally I pulled these patches and tried to apply, but as I doubted
> it failed :-(
> >
> > Hi Hogler
> >
> > I could not apply the said patch series to the latest u-boot-
> marvell.git master branch
> >
> > Pls re-submit it.
> >
> > git-am U-Boot-1-9-arm-km-add-board-type-to-boards.cfg.patch
> >
> > Applying arm/km: add board type to boards.cfg
> >
> > error: patch failed: boards.cfg:138
> > error: boards.cfg: patch does not apply
> > error: patch failed: include/configs/km_kirkwood.h:42
> > error: include/configs/km_kirkwood.h: patch does not apply
> > Patch failed at 0001.
> > When you have resolved this problem run "git-am --resolved".
> > If you would prefer to skip this patch, instead run "git-am --skip"
> >
> 
> sorry but now I am completely confused. Here you say you want to apply
> 01-09
> which includes
> [PATCH v2 05/14] arm/km: correct init of 88e6352 switch in the
> reset_phy function
> and
> [PATCH v2 09/14] arm/km: add support for external switch configuration
> 
> this includes basic infrastructure for the managed switch.
> 
> In another thread you NAK the whole driver:
> http://lists.denx.de/pipermail/u-boot/2012-July/127529.html
> 
> In a further different thread where I asked if I should provide
> updates which
> apply cleanly you say no there are general updates needed:
> http://lists.denx.de/pipermail/u-boot/2012-July/127531.html
> 
> For me these statements are conflicting.
> 
> So can you please state clearly which updates you request from myside
> for which
> patch and which are from your point of view not acceptable and why?
> Thanks

Dear Holger

To avoid any further confusion let's keep aside all the past.
1. Pls post the new patch series that is just targeted for bugfixes and updates 
(no addition of new boards or drivers)
2. You may post anther patch series for addition of new boards which does not 
have any dependencies (if you have such)
3. You may post a standalone patch for a switch driver, needed ack from Joe, 
that might go to u-boot-net.git
4. You may post a board support patch using this switch.

#1,#2 I hope will be pulled faster, rest may take some time.

Regards...
Prafulla . . . .
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v3] powerpc/p1022ds: Add sdcard and spi boot support to P1022DS

2012-07-04 Thread Eibach, Dirk
 

> Can you give me some instructions on how to test this?  I'm 
> working on adding NAND boot support to the P1022, so I need 
> to make sure I don't conflict with your patch.

Hi Timur,

What is the current status of this stuff?

Cheers
Dirk



___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] Issue with running commands

2012-07-04 Thread Sughosh Ganu
hi Graeme,
On Wed Jul 04, 2012 at 09:28:07AM +1000, Graeme Russ wrote:



> >> On Mon, Jul 2, 2012 at 9:24 PM, Sughosh Ganu 
> >> wrote:
> >> > hi,
> >> > While testing on hawkboard with the latest commit, i hit an issue of
> >> > commands not being accepted.
> >> >
> >> > hawkboard > rese
> >> > Unknown command '�' - try 'help'
> >> > hawkboard >
> >> >
> >> > Running git bisect showed that this is caused due to commit 054ea170f271:
> >> > cmd_mem: cmp: unify size code paths. Has anyone seen this issue -- i
> >> don't
> >> > think this is board/arch specific.
> >>
> >> I tried to reproduce this on the calimain board (AM1808 SoC), but
> >> without success. The reset command works fine with current mainline
> >> u-boot.
> >>
> >
> > Thanks for testing this. This looks to be some kind of an alignment issue
> > on my board, which is getting introduced due to the commit i mentioned. The
> > said commit is not directly responsible for the problem, but it introduces
> > some kind of misalignment. I am looking into this -- at such times i so
> > dearly wish i had a jtag debugger :)
> 
> I may be totally off track, but I saw a patch recently 'arm: armv7:
> add compile option -mno-unaligned-access if available' - I wonder if
> its related

  The SoC on my board uses a armv5 based core(arm926ejs), so this
  patch won't apply for my board.

-sughosh
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 1/5] arm: rmobile: Add basic support for Renesas R-Mobile

2012-07-04 Thread Nobuhiro Iwamatsu
This patch adds minimum support for R-Mobile. Only minimal support with timer.
This CPU can uses the peripheral of Renesas SuperH.

Signed-off-by: Nobuhiro Iwamatsu 
---
 arch/arm/cpu/armv7/rmobile/Makefile |   48 +
 arch/arm/cpu/armv7/rmobile/cpu_info.c   |   74 
 arch/arm/cpu/armv7/rmobile/timer.c  |   97 +++
 arch/arm/include/asm/arch-rmobile/rmobile.h |8 +++
 4 files changed, 227 insertions(+)
 create mode 100644 arch/arm/cpu/armv7/rmobile/Makefile
 create mode 100644 arch/arm/cpu/armv7/rmobile/cpu_info.c
 create mode 100644 arch/arm/cpu/armv7/rmobile/timer.c
 create mode 100644 arch/arm/include/asm/arch-rmobile/rmobile.h

diff --git a/arch/arm/cpu/armv7/rmobile/Makefile 
b/arch/arm/cpu/armv7/rmobile/Makefile
new file mode 100644
index 000..e7eb90f
--- /dev/null
+++ b/arch/arm/cpu/armv7/rmobile/Makefile
@@ -0,0 +1,48 @@
+#
+# (C) Copyright 2000-2006
+# Wolfgang Denk, DENX Software Engineering, w...@denx.de.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# 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., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB= $(obj)lib$(SOC).o
+
+COBJS += cpu_info.o
+COBJS += timer.o
+
+SRCS   := $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS   := $(addprefix $(obj),$(COBJS) $(COBJS-y))
+START  := $(addprefix $(obj),$(START))
+
+all:   $(obj).depend $(LIB)
+
+$(LIB):$(OBJS)
+   $(call cmd_link_o_target, $(OBJS))
+
+#
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#
+
diff --git a/arch/arm/cpu/armv7/rmobile/cpu_info.c 
b/arch/arm/cpu/armv7/rmobile/cpu_info.c
new file mode 100644
index 000..789c2c3
--- /dev/null
+++ b/arch/arm/cpu/armv7/rmobile/cpu_info.c
@@ -0,0 +1,74 @@
+/*
+ * (C) Copyright 2012 Nobuhiro Iwamatsu 
+ * (C) Copyright 2012 Renesas Solutions Corp.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+#include 
+#include 
+#include 
+
+#ifdef CONFIG_ARCH_CPU_INIT
+int arch_cpu_init(void)
+{
+   icache_enable();
+   return 0;
+}
+#endif
+
+#ifndef CONFIG_SYS_DCACHE_OFF
+void enable_caches(void)
+{
+   dcache_enable();
+}
+#endif
+
+#ifdef CONFIG_DISPLAY_CPUINFO
+static u32 get_cpu_type(void)
+{
+   u32 id;
+   u32 type;
+
+   id = readl(CCCR);
+   type = (id >> 8) & 0xFF;
+
+   return type;
+}
+
+static u32 get_cpu_rev(void)
+{
+   u32 id;
+   u32 rev;
+
+   id = readl(CCCR);
+   rev = (id >> 4) & 0xF;
+
+   return rev;
+}
+
+int print_cpuinfo(void)
+{
+   switch (get_cpu_type()) {
+   default:
+   printf("CPU: Renesas Electronics CPU rev %d\n", get_cpu_rev());
+   break;
+   }
+   return 0;
+}
+#endif
diff --git a/arch/arm/cpu/armv7/rmobile/timer.c 
b/arch/arm/cpu/armv7/rmobile/timer.c
new file mode 100644
index 000..1818739
--- /dev/null
+++ b/arch/arm/cpu/armv7/rmobile/timer.c
@@ -0,0 +1,97 @@
+/*
+ * (C) Copyright 2012 Nobuhiro Iwamatsu 
+ * (C) Copyright 2012 Renesas Solutions Corp.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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 distrib

[U-Boot] [PATCH v2 3/5] sh: Add support pin function control using GPIO

2012-07-04 Thread Nobuhiro Iwamatsu
Renesas SH and R-Mobile set up device using PFC.
This provide the framework. Most codes were brought from linux kernel.

Signed-off-by: Nobuhiro Iwamatsu 
---
 drivers/gpio/Makefile |1 +
 drivers/gpio/sh_pfc.c |  629 +
 include/sh_pfc.h  |  192 +++
 3 files changed, 822 insertions(+)
 create mode 100644 drivers/gpio/sh_pfc.c
 create mode 100644 include/sh_pfc.h

diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index fb3b09a..9192582 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -39,6 +39,7 @@ COBJS-$(CONFIG_TEGRA2_GPIO)   += tegra2_gpio.o
 COBJS-$(CONFIG_DA8XX_GPIO) += da8xx_gpio.o
 COBJS-$(CONFIG_ALTERA_PIO) += altera_pio.o
 COBJS-$(CONFIG_MPC83XX_GPIO)   += mpc83xx_gpio.o
+COBJS-$(CONFIG_SH_GPIO_PFC)+= sh_pfc.o
 
 COBJS  := $(COBJS-y)
 SRCS   := $(COBJS:.o=.c)
diff --git a/drivers/gpio/sh_pfc.c b/drivers/gpio/sh_pfc.c
new file mode 100644
index 000..7a5af20
--- /dev/null
+++ b/drivers/gpio/sh_pfc.c
@@ -0,0 +1,629 @@
+/*
+ * Pinmuxed GPIO support for SuperH.
+ * Copy from linux kernel driver/sh/pfc.c
+ *
+ * Copyright (C) 2008 Magnus Damm
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+static struct pinmux_info *gpioc;
+
+#define pfc_phys_to_virt(p, a) ((void *)a)
+
+static int enum_in_range(pinmux_enum_t enum_id, struct pinmux_range *r)
+{
+   if (enum_id < r->begin)
+   return 0;
+
+   if (enum_id > r->end)
+   return 0;
+
+   return 1;
+}
+
+static unsigned long gpio_read_raw_reg(void *mapped_reg,
+  unsigned long reg_width)
+{
+   switch (reg_width) {
+
+   case 8:
+   return readb(mapped_reg);
+   case 16:
+   return readw(mapped_reg);
+   case 32:
+   return readl(mapped_reg);
+   }
+
+   BUG();
+   return 0;
+}
+
+static void gpio_write_raw_reg(void *mapped_reg,
+  unsigned long reg_width,
+  unsigned long data)
+{
+   switch (reg_width) {
+   case 8:
+   writeb(data, mapped_reg);
+   return;
+   case 16:
+   writew(data, mapped_reg);
+   return;
+   case 32:
+   writel(data, mapped_reg);
+   return;
+   }
+
+   BUG();
+}
+
+static int gpio_read_bit(struct pinmux_data_reg *dr,
+unsigned long in_pos)
+{
+   unsigned long pos;
+
+   pos = dr->reg_width - (in_pos + 1);
+
+   debug("read_bit: addr = %lx, pos = %ld, "
+"r_width = %ld\n", dr->reg, pos, dr->reg_width);
+
+   return (gpio_read_raw_reg(dr->mapped_reg, dr->reg_width) >> pos) & 1;
+}
+
+static void gpio_write_bit(struct pinmux_data_reg *dr,
+  unsigned long in_pos, unsigned long value)
+{
+   unsigned long pos;
+
+   pos = dr->reg_width - (in_pos + 1);
+
+   debug("write_bit addr = %lx, value = %d, pos = %ld, "
+"r_width = %ld\n",
+dr->reg, !!value, pos, dr->reg_width);
+
+   if (value)
+   __set_bit(pos, &dr->reg_shadow);
+   else
+   __clear_bit(pos, &dr->reg_shadow);
+
+   gpio_write_raw_reg(dr->mapped_reg, dr->reg_width, dr->reg_shadow);
+}
+
+static void config_reg_helper(struct pinmux_info *gpioc,
+ struct pinmux_cfg_reg *crp,
+ unsigned long in_pos,
+#if 0
+ void __iomem **mapped_regp,
+#else
+ void **mapped_regp,
+#endif
+ unsigned long *maskp,
+ unsigned long *posp)
+{
+   int k;
+
+   *mapped_regp = pfc_phys_to_virt(gpioc, crp->reg);
+
+   if (crp->field_width) {
+   *maskp = (1 << crp->field_width) - 1;
+   *posp = crp->reg_width - ((in_pos + 1) * crp->field_width);
+   } else {
+   *maskp = (1 << crp->var_field_width[in_pos]) - 1;
+   *posp = crp->reg_width;
+   for (k = 0; k <= in_pos; k++)
+   *posp -= crp->var_field_width[k];
+   }
+}
+
+static int read_config_reg(struct pinmux_info *gpioc,
+  struct pinmux_cfg_reg *crp,
+  unsigned long field)
+{
+   void *mapped_reg;
+
+   unsigned long mask, pos;
+
+   config_reg_helper(gpioc, crp, field, &mapped_reg, &mask, &pos);
+
+   debug("read_reg: addr = %lx, field = %ld, "
+"r_width = %ld, f_width = %ld\n",
+crp->reg, field, crp->reg_width, crp->field_width);
+
+   return (gpio_read_raw_reg(mapped_reg, crp->reg_width) >> pos) & mask;
+}
+
+static void write_config_reg(struct pinmux_info *g

[U-Boot] [PATCH v2 4/5] serial: sh: Add support Renesas SH73A0

2012-07-04 Thread Nobuhiro Iwamatsu
The serial device of SH73A0 has the same structure as SH7372 of SH, etc.

Signed-off-by: Nobuhiro Iwamatsu 
---
 drivers/serial/serial_sh.h |   21 ++---
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/serial/serial_sh.h b/drivers/serial/serial_sh.h
index 601da43..96509e1 100644
--- a/drivers/serial/serial_sh.h
+++ b/drivers/serial/serial_sh.h
@@ -45,7 +45,8 @@ struct uart_port {
defined(CONFIG_CPU_SH7721) || \
defined(CONFIG_ARCH_SH7367) || \
defined(CONFIG_ARCH_SH7377) || \
-   defined(CONFIG_ARCH_SH7372)
+   defined(CONFIG_ARCH_SH7372) || \
+   defined(CONFIG_SH73A0)
 # define SCSCR_INIT(port)  0x0030 /* TIE=0,RIE=0,TE=1,RE=1 */
 # define PORT_PTCR0xA405011EUL
 # define PORT_PVCR0xA4050122UL
@@ -282,7 +283,8 @@ struct uart_port {
defined(CONFIG_CPU_SH7721) || \
defined(CONFIG_ARCH_SH7367) || \
defined(CONFIG_ARCH_SH7377) || \
-   defined(CONFIG_ARCH_SH7372)
+   defined(CONFIG_ARCH_SH7372) || \
+   defined(CONFIG_SH73A0)
 # define SCIF_ORER0x0200
 # define SCIF_ERRORS (SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK | SCIF_ORER)
 # define SCIF_RFDC_MASK 0x007f
@@ -326,7 +328,8 @@ struct uart_port {
defined(CONFIG_CPU_SH7721) || \
defined(CONFIG_ARCH_SH7367) || \
defined(CONFIG_ARCH_SH7377) || \
-   defined(CONFIG_ARCH_SH7372)
+   defined(CONFIG_ARCH_SH7372) || \
+   defined(CONFIG_SH73A0)
 # define SCxSR_RDxF_CLEAR(port) (sci_in(port, SCxSR) & 0xfffc)
 # define SCxSR_ERROR_CLEAR(port) (sci_in(port, SCxSR) & 0xfd73)
 # define SCxSR_TDxE_CLEAR(port) (sci_in(port, SCxSR) & 0xffdf)
@@ -420,7 +423,8 @@ static inline void sci_##name##_out(struct uart_port *port,\
 #if defined(CONFIG_SH3) || \
defined(CONFIG_ARCH_SH7367) || \
defined(CONFIG_ARCH_SH7377) || \
-   defined(CONFIG_ARCH_SH7372)
+   defined(CONFIG_ARCH_SH7372) || \
+   defined(CONFIG_SH73A0)
 #if defined(CONFIG_CPU_SH7710) || defined(CONFIG_CPU_SH7712)
 #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size,\
sh4_sci_offset, sh4_sci_size, \
@@ -436,7 +440,8 @@ static inline void sci_##name##_out(struct uart_port *port,\
defined(CONFIG_CPU_SH7720) || \
defined(CONFIG_CPU_SH7721) || \
defined(CONFIG_ARCH_SH7367) || \
-   defined(CONFIG_ARCH_SH7377)
+   defined(CONFIG_ARCH_SH7377) || \
+   defined(CONFIG_SH73A0)
 #define SCIF_FNS(name, scif_offset, scif_size) \
CPU_SCIF_FNS(name, scif_offset, scif_size)
 #elif defined(CONFIG_ARCH_SH7372)
@@ -492,7 +497,8 @@ static inline void sci_##name##_out(struct uart_port *port,\
defined(CONFIG_CPU_SH7720) || \
defined(CONFIG_CPU_SH7721) || \
defined(CONFIG_ARCH_SH7367) || \
-   defined(CONFIG_ARCH_SH7377)
+   defined(CONFIG_ARCH_SH7377) || \
+   defined(CONFIG_SH73A0)
 
 SCIF_FNS(SCSMR,  0x00, 16)
 SCIF_FNS(SCBRR,  0x04,  8)
@@ -692,7 +698,8 @@ static inline int sci_rxd_in(struct uart_port *port)
defined(CONFIG_CPU_SH7721) || \
defined(CONFIG_ARCH_SH7367) || \
defined(CONFIG_ARCH_SH7377) || \
-   defined(CONFIG_ARCH_SH7372)
+   defined(CONFIG_ARCH_SH7372) || \
+   defined(CONFIG_SH73A0)
 #define SCBRR_VALUE(bps, clk) (((clk*2)+16*bps)/(32*bps)-1)
 #elif defined(CONFIG_CPU_SH7723) ||\
defined(CONFIG_CPU_SH7724)
-- 
1.7.10

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 5/5] arm: rmobile: Add supoprt for KMC KZM-A9-GT board

2012-07-04 Thread Nobuhiro Iwamatsu
The KZM-A9-GT board has Renesas R-Mobile SH73A0, 512MB DDR2-SDRAM,
USB, Ethernet, and more.

This patch supports the following functions:
- 512MB DDR2-SDRAM
- 16MB NOR Flash memory
- Serial console (SCIF)
- Ethernet (SCIM)
- I2C

Signed-off-by: Nobuhiro Iwamatsu 
--
V2: Add maintainer infomation to MAINTAINERS.
Change coding style from asm to using table.
Change board name from kzm_a9_gt to kzm9g. Request from board vendor.
Remove "1" from board config file.

 MAINTAINERS   |4 +
 arch/arm/include/asm/mach-types.h |2 +
 board/kmc/kzm9g/Makefile  |   50 +
 board/kmc/kzm9g/kzm9g.c   |  372 +
 boards.cfg|1 +
 include/configs/kzm9g.h   |  168 +
 7 files changed, 693 insertions(+)
 create mode 100644 board/kmc/kzm9g/Makefile
 create mode 100644 board/kmc/kzm9g/kzm9g.c
 create mode 100644 board/kmc/kzm9g/lowlevel_init.S
 create mode 100644 include/configs/kzm9g.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 17befd0..cb51ecd 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -944,6 +944,10 @@ Vladimir Zapolskiy 
 
devkit3250  lpc32xx
 
+Nobuhiro Iwamatsu 
+
+   kzm9g   SH73A0 (RMOBILE SoC)
+
 -
 
 Unknown / orphaned boards:
diff --git a/arch/arm/include/asm/mach-types.h 
b/arch/arm/include/asm/mach-types.h
index 2d5c3bc..98c992c 100644
--- a/arch/arm/include/asm/mach-types.h
+++ b/arch/arm/include/asm/mach-types.h
@@ -1106,6 +1106,8 @@ extern unsigned int __machine_arch_type;
 #define MACH_TYPE_ATDGP318 3494
 #define MACH_TYPE_OMAP5_SEVM   3777
 
+#define MACH_TYPE_KZM9G4140
+
 #ifdef CONFIG_ARCH_EBSA110
 # ifdef machine_arch_type
 #  undef machine_arch_type
diff --git a/board/kmc/kzm9g/Makefile b/board/kmc/kzm9g/Makefile
new file mode 100644
index 000..bae79f5
--- /dev/null
+++ b/board/kmc/kzm9g/Makefile
@@ -0,0 +1,50 @@
+#
+# (C) Copyright 2012 Nobuhiro Iwamatsu 
+# (C) Copyright 2012 Renesas Solutions Corp.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# 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., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB= $(obj)lib$(BOARD).o
+
+COBJS  := kzm9g.o
+
+SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS   := $(addprefix $(obj),$(COBJS))
+SOBJS  := $(addprefix $(obj),$(SOBJS))
+
+$(LIB):$(obj).depend $(OBJS) $(SOBJS)
+   $(call cmd_link_o_target, $(OBJS) $(SOBJS))
+
+clean:
+   rm -f $(SOBJS) $(OBJS)
+
+distclean: clean
+   rm -f $(LIB) core *.bak $(obj) .depend
+
+#
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#
diff --git a/board/kmc/kzm9g/kzm9g.c b/board/kmc/kzm9g/kzm9g.c
new file mode 100644
index 000..3f38f69
--- /dev/null
+++ b/board/kmc/kzm9g/kzm9g.c
@@ -0,0 +1,372 @@
+/*
+ * (C) Copyright 2012 Nobuhiro Iwamatsu 
+ * (C) Copyright 2012 Renesas Solutions Corp.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define CS0BCR_D (0x06C00400)
+#define CS4BCR_D (0x06C00400)
+#define CS0WCR_D (0x55062C42)
+#define CS4WCR_D (0x19051443)
+#define CMNCR_BROMMD0   (1 << 21)
+#define CMNCR_BROMMD1   (1 << 22)
+#define CMN