[PATCH] edit: Add a status line
When invoked from a skript it's useful to know which file is edited. Also Add information how to exit the editor to the status line. Signed-off-by: Sascha Hauer --- commands/edit.c | 17 ++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/commands/edit.c b/commands/edit.c index fae76cd..eddec0b 100644 --- a/commands/edit.c +++ b/commands/edit.c @@ -62,7 +62,7 @@ static int scrcol = 0;/* the first column on screen */ static void pos(int x, int y) { - printf("%c[%d;%dH", 27, y + 1, x + 1); + printf("%c[%d;%dH", 27, y + 2, x + 1); } static char *screenline(char *line, int *pos) @@ -409,6 +409,17 @@ static int do_edit(int argc, char *argv[]) lastscrcol = 0; printf("%c[2J", 27); + + pos(0, -1); + + printf("%c[7m %-25s : Save and quit : quit %c[0m", + 27, argv[1], 27); + printf("%c[2;%dr", 27, screenheight); + + screenheight--; /* status line */ + + pos(0, 0); + refresh(1); while (1) { @@ -416,7 +427,7 @@ static int do_edit(int argc, char *argv[]) if (textx > curlen) textx = curlen; - if (textx < 0) + if (textx < 1) textx = 0; screenline(curline->data, &linepos); @@ -531,7 +542,7 @@ static int do_edit(int argc, char *argv[]) } out: free_buffer(); - printf("%c[2J", 27); + printf("%c[2J%c[r", 27, 27); printf("\n"); return 0; } -- 1.7.10 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH] dns: fix recursive loop
resolv() uses getenv_ip() which in turn calls resolv(). Fix this inifinite loop by not using getenv_ip directly. Signed-off-by: Sascha Hauer --- net/dns.c | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/net/dns.c b/net/dns.c index e13d654..eb96c57 100644 --- a/net/dns.c +++ b/net/dns.c @@ -197,6 +197,7 @@ static void dns_handler(void *ctx, char *packet, unsigned len) IPaddr_t resolv(char *host) { IPaddr_t ip; + const char *ns; if (!string_to_ip(host, &ip)) return ip; @@ -205,8 +206,14 @@ IPaddr_t resolv(char *host) dns_state = STATE_INIT; - ip = getenv_ip("net.nameserver"); - if (!ip) + ns = getenv("net.nameserver"); + if (!ns || !*ns) { + printk("%s: no nameserver specified in $net.nameserver\n", + __func__); + return 0; + } + + if (string_to_ip(ns, &ip)) return 0; debug("resolving host %s via nameserver %s\n", host, ip_to_string(ip)); -- 1.7.10 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH] ramfs: rember last accessed chunk
Writing big files takes longer and longer because of the chunk list By storing a pointer of the recent used chunk in the inode, access times are improved. Testet on with tftp 10M: OMAP4 chunk size 4096: 12244ms 8192: 4239ms patched2647ms2785ms i.MX35 chunk size 8192: 7225ms patched 2691ms No impact on much smaller files seen Signed-off-by: Jan Weitzel --- v2: I will use checkpatch fs/ramfs.c | 47 +-- 1 files changed, 37 insertions(+), 10 deletions(-) diff --git a/fs/ramfs.c b/fs/ramfs.c index 83ab6df..cec5e76 100644 --- a/fs/ramfs.c +++ b/fs/ramfs.c @@ -48,6 +48,10 @@ struct ramfs_inode { ulong size; struct ramfs_chunk *data; + + /* Points to recently used chunk */ + int recent_chunk; + struct ramfs_chunk *recent_chunkp; }; struct ramfs_priv { @@ -297,6 +301,35 @@ static int ramfs_close(struct device_d *dev, FILE *f) return 0; } +static struct ramfs_chunk *ramfs_find_chunk(struct ramfs_inode *node, int chunk) +{ + struct ramfs_chunk *data; + int left = chunk; + + if (chunk == 0) + return node->data; + + if (node->recent_chunk == chunk) + return node->recent_chunkp; + + if (node->recent_chunk < chunk && node->recent_chunk != 0) { + /* Start at last known chunk */ + data = node->recent_chunkp; + left -= node->recent_chunk; + } else { + /* Start at first chunk */ + data = node->data; + } + + while (left--) + data = data->next; + + node->recent_chunkp = data; + node->recent_chunk = chunk; + + return data; +} + static int ramfs_read(struct device_d *_dev, FILE *f, void *buf, size_t insize) { struct ramfs_inode *node = (struct ramfs_inode *)f->inode; @@ -311,11 +344,7 @@ static int ramfs_read(struct device_d *_dev, FILE *f, void *buf, size_t insize) debug("%s: reading from chunk %d\n", __FUNCTION__, chunk); /* Position ourself in stream */ - data = node->data; - while (chunk) { - data = data->next; - chunk--; - } + data = ramfs_find_chunk(node, chunk); ofs = f->pos % CHUNK_SIZE; /* Read till end of current chunk */ @@ -364,11 +393,7 @@ static int ramfs_write(struct device_d *_dev, FILE *f, const void *buf, size_t i debug("%s: writing to chunk %d\n", __FUNCTION__, chunk); /* Position ourself in stream */ - data = node->data; - while (chunk) { - data = data->next; - chunk--; - } + data = ramfs_find_chunk(node, chunk); ofs = f->pos % CHUNK_SIZE; /* Write till end of current chunk */ @@ -429,6 +454,8 @@ static int ramfs_truncate(struct device_d *dev, FILE *f, ulong size) ramfs_put_chunk(data); data = tmp; } + if (node->recent_chunk > newchunks) + node->recent_chunk = 0; } if (newchunks > oldchunks) { -- 1.7.0.4 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
build timestamps don't work
Hi! I have found that on my Debian testing build system generation of timestamps don't work correctly. $ cd barebox.git $ git checkout next $ make mrproper $ make qemu-malta_defconfig $ make $ cat .version 0 $ edit ... $ edit ... $ edit ... $ make $ cat .version 0 $ echo 4 > .version $ make $ edit ... $ edit ... $ edit ... $ make $ cat .version 4 -- Best regards, Antony Pavlov ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 5/5] arch/arm: mioa701 improve barebox_update script
Add a check to verify if /barebox.BIP0 exists, and if so, unlock the protection area, flash barebox, and reprotect the area. Signed-off-by: Robert Jarzmik --- arch/arm/boards/mioa701/env/bin/barebox_update |5 + 1 file changed, 5 insertions(+) diff --git a/arch/arm/boards/mioa701/env/bin/barebox_update b/arch/arm/boards/mioa701/env/bin/barebox_update index 564549b..b544563 100644 --- a/arch/arm/boards/mioa701/env/bin/barebox_update +++ b/arch/arm/boards/mioa701/env/bin/barebox_update @@ -3,3 +3,8 @@ # Page+OOB specific partitions addpart /dev/mtdraw0 1081344@3649536(msipl) addpart /dev/mtdraw0 270336@3649536(barebox) + +if [ -r /barebox.BIP0 ]; then + erase /dev/mtdraw0.barebox + cp -v /barebox.BIP0 /dev/mtdraw0.barebox +fi -- 1.7.10 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 3/5] arch/arm: mioa701 add IPL and DPS1 updater
In order for barebox to be functional, the docg3 DPS1 has to protect barebox from writes, and have its embedded IPL coded to load barebox (as barebox is the SPL). Add a raw DPS1, which : - protects the area from block 6 to block 123 This is DPS1 + barebox + barebox-logo - encodes the 2048 bytes IPL Signed-off-by: Robert Jarzmik --- arch/arm/boards/mioa701/env/bin/dps1_unlock | 12 arch/arm/boards/mioa701/env/bin/dps1_update | 12 arch/arm/boards/mioa701/env/data/dps1.raw.gz | Bin 0 -> 1239 bytes 3 files changed, 24 insertions(+) create mode 100644 arch/arm/boards/mioa701/env/bin/dps1_unlock create mode 100644 arch/arm/boards/mioa701/env/bin/dps1_update create mode 100644 arch/arm/boards/mioa701/env/data/dps1.raw.gz diff --git a/arch/arm/boards/mioa701/env/bin/dps1_unlock b/arch/arm/boards/mioa701/env/bin/dps1_unlock new file mode 100644 index 000..2d7dab8 --- /dev/null +++ b/arch/arm/boards/mioa701/env/bin/dps1_unlock @@ -0,0 +1,12 @@ +#!/bin/sh +# +# Shell to unlock the DPS1 with "12345678" key. + +mw -b 0x105e 0x31 +mw -b 0x105e 0x32 +mw -b 0x105e 0x33 +mw -b 0x105e 0x34 +mw -b 0x105e 0x35 +mw -b 0x105e 0x36 +mw -b 0x105e 0x37 +mw -b 0x105e 0x38 diff --git a/arch/arm/boards/mioa701/env/bin/dps1_update b/arch/arm/boards/mioa701/env/bin/dps1_update new file mode 100644 index 000..a9d72da --- /dev/null +++ b/arch/arm/boards/mioa701/env/bin/dps1_update @@ -0,0 +1,12 @@ +#!/bin/sh + +# Page+OOB specific partitions +addpart /dev/mtdraw0 67584@202752(dps1) +uncompress /env/data/dps1.raw.gz /dps1.raw + +if [ -r /dps1.raw ]; then + dps1_unlock + erase /dev/mtdraw0.dps1 + cp -v /dps1.raw /dev/mtdraw0.dps1 + dps1_unlock +fi diff --git a/arch/arm/boards/mioa701/env/data/dps1.raw.gz b/arch/arm/boards/mioa701/env/data/dps1.raw.gz new file mode 100644 index ..93112bfca14762534de50443d4e0b4c9333d0936 GIT binary patch literal 1239 zcmV;|1StC-iwFqP5SLE?17vV>F)ngpcL42GPiS0482{ex+hmijd6T#{>2_^iLe#A$ zxW+Z6Aju=GQZ>@G4bnpnE9B5a)%fSolbPK_@lVlh=}D9w1SOz{5PIrCv#p3ot1VLF z!Q#Fh$3sGwC?XXD>u)yMHZ6%>JjwjvW9IwKH{YB2X6E;TG(->dKbU%G;Nih25w-ns z^~>nT{Z#`41B0N^2Ll5G1A|Rq{tpHQ23x`CgTX(6N{-)I`bK_NdPlab?DnG;Eq_n6 zoC+3HI}@^pam5O(;^dpkJ>Xg$r^1}J3X$;bl>_BtBqVdJn>e(x-3eFPoyN+0FwNhv z65@lE9|HvyXL-e3ApWV+8B>J`+-W0q#yA`LK|kc_A%N$cTGMgmQ_|qDdjE86jUrJ*Hqo;F`dF2=00K-Dsaf%ahaP$IuQ=X3J+@ zEMi@Ys)3lSRI4%0g?tKQtIrnHJT3b3?xMd7-_W_V1;QNh&-hmn8|H};_PsQNIsKS3 ztaCf4FY)qx8gtX97KmDY8A6EZ-lT0ORwRg;#h-4)XcvfEn9qlnJtW# zb?h(IYV$T4^TQaUHCR`E9X#~&9hWJ9z1Y-Lvb-6@rsWlU%S-Mpe_pLF>2uZVvvhr| zf{Nn&c)Td1sQU!^Z^Vjn0{t-hn;DO^N?f^S@w<>MLijDHC836$*k>F18T8}m*E#L) zK^mbMU}dRYoKX=0QGfkaZ{^nuE*>3uiM7+=gyqJioNPMnsdcoSC@Ika{wYH@D99@ z$I}O#w}@KO!tbC?6^Er*r*hpB%1R0uq=SA4XEfecP%i4K?>UdH-E$k~un)ZU>tmWv zf$Kn<#Jh>RT=k;u=;A5?UccqzeL^O{$HDi2?*JbGABE4r*Y87M_Y3<5Ui+GiJ{Wy4 z`e5|I=!4M*qYp+Oj6N8BF#2Hh;lI)c)~3&ys|dy;h{w|97<|GzI*j;htpzo{?q}f7 z#zgH7X#a@27JqczpM<}PJton&(YM{a3h6V2o$kW-@y-{9r^}3;R6%-L*Y62|{QLI_ z8D=xML#JwaBJPZexTk8l8F&WX0v`qc3gQ#sjv`+#{0aC;_~YNHY_uaw|z*2~@V#4o&S#Hj^5y$&-((64d`CU1=a1Yuhttp://lists.infradead.org/mailman/listinfo/barebox
[PATCH 0/5] arch/arm: mioa701 linux booting
This patch serie makes linux autobooting and barebox flashing and reflashing much more automated. This serie serves as the first fully working barebox setup, fully replacing the existing legacy boot code on the mioa701. -- Robert Robert Jarzmik (5): arm/board: mioa701 align kernel options with kernel mtd arch/arm: mioa701 make autoboot of Linux work arch/arm: mioa701 add IPL and DPS1 updater arch/arm: mioa701 use maximum CPU frequency arch/arm: mioa701 improve barebox_update script arch/arm/boards/mioa701/board.c| 13 +++-- arch/arm/boards/mioa701/env/bin/barebox_update |5 + arch/arm/boards/mioa701/env/bin/dps1_unlock| 12 arch/arm/boards/mioa701/env/bin/dps1_update| 12 arch/arm/boards/mioa701/env/bin/init | 19 --- arch/arm/boards/mioa701/env/data/dps1.raw.gz | Bin 0 -> 1239 bytes 6 files changed, 52 insertions(+), 9 deletions(-) create mode 100644 arch/arm/boards/mioa701/env/bin/dps1_unlock create mode 100644 arch/arm/boards/mioa701/env/bin/dps1_update create mode 100644 arch/arm/boards/mioa701/env/data/dps1.raw.gz -- 1.7.10 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 1/5] arm/board: mioa701 align kernel options with kernel mtd
Recent evolutions of linux kernel's drivers for docg3 chip, ie. it's renaming for mtdparts option, is handled by this patch. Signed-off-by: Robert Jarzmik --- arch/arm/boards/mioa701/env/bin/init |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/boards/mioa701/env/bin/init b/arch/arm/boards/mioa701/env/bin/init index 8a54da0..2e806b9 100644 --- a/arch/arm/boards/mioa701/env/bin/init +++ b/arch/arm/boards/mioa701/env/bin/init @@ -31,5 +31,5 @@ if [ $? != 0 ]; then fi echo "Booting linux kernel on docg3 chip ..." -bootargs="$bootargs mtdparts=mtd0:$mtdparts root=/dev/mtd4" +bootargs="$bootargs mtdparts=docg3.0:$mtdparts ubi.mtd=4 rootfstype=ubifs root=ubi0:linux_root ro" bootm /dev/mtd0.kernel -- 1.7.10 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 4/5] arch/arm: mioa701 use maximum CPU frequency
To speed-up linux kernel loading, switch the PXA cpu to the maximum allowed frequency (520 MHz). This improves the load time from several seconds to less than a second from the MTD. Signed-off-by: Robert Jarzmik --- arch/arm/boards/mioa701/board.c | 13 +++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/arch/arm/boards/mioa701/board.c b/arch/arm/boards/mioa701/board.c index 14c8110..ab5a493 100644 --- a/arch/arm/boards/mioa701/board.c +++ b/arch/arm/boards/mioa701/board.c @@ -261,8 +261,17 @@ static int mioa701_coredevice_init(void) /* route pins */ pxa2xx_mfp_config(ARRAY_AND_SIZE(mioa701_pin_config)); - CCCR = CCCR_A | 0x20110; - cclk = 0x02; + /* +* Put the board in superspeed (520 MHz) to speed-up logo/OS loading. +* This requires to command the Maxim 1586 to upgrade core voltage to +* 1.475 V, on the power I2C bus (device 0x14). +*/ + CCCR = CCCR_A | 0x20290; + PCFR = PCFR_GPR_EN | PCFR_FVC | PCFR_DC_EN | PCFR_PI2C_EN | PCFR_OPDE; + PCMD(0) = PCMD_LC | 0x1f; + PVCR = 0x14; + + cclk = 0x0b; asm volatile("mcr p14, 0, %0, c6, c0, 0 @ set CCLK" : : "r" (cclk) : "cc"); -- 1.7.10 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 2/5] arch/arm: mioa701 make autoboot of Linux work
Make the autoboot work : - if no USB cuable is plugged, continue directly to autoboot - if an USB cable is plugged, wait for 3 seconds for any input on the USB serial gadget, and if none happens, continue to autoboot linux kernel - else interrupt autoboot and interact on barebox console Signed-off-by: Robert Jarzmik --- arch/arm/boards/mioa701/env/bin/init | 17 +++-- 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/arch/arm/boards/mioa701/env/bin/init b/arch/arm/boards/mioa701/env/bin/init index 2e806b9..494d067 100644 --- a/arch/arm/boards/mioa701/env/bin/init +++ b/arch/arm/boards/mioa701/env/bin/init @@ -22,12 +22,17 @@ if [ $? = 0 ]; then fi echo "No custom environment found" -echo -n "Hit any key to stop autoboot: " -timeout -a $autoboot_timeout -if [ $? != 0 ]; then - echo - echo "Welcome to barebox console" - exit + +gpio_get_value 22 +is_usb_connected=$? +if [ $is_usb_connected != 0 ]; then + echo -n "Hit any key to stop autoboot: " + timeout -a $autoboot_timeout + if [ $? != 0 ]; then + echo + echo "Welcome to barebox console" + exit + fi fi echo "Booting linux kernel on docg3 chip ..." -- 1.7.10 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [RFC] ramfs: rember last accessed chunk
Hi Jan, On Tue, May 15, 2012 at 11:15:46AM +0200, Jan Weitzel wrote: > Writing big files takes longer and longer because of the chunk list > By storing a pointer of the recent used chunk in the inode, access times are > improved. > Testet on with tftp 10M: > OMAP4 chunk size 4096: 12244ms 8192: 4239ms > patched2647ms2785ms > i.MX35 chunk size 8192: 7225ms > patched 2691ms > The numbers look good and the code looks sane. We can give it a try. Two nitpicks below. > No impact on much smaller files seen > > Signed-off-by: Jan Weitzel > --- > fs/ramfs.c | 46 -- > 1 files changed, 36 insertions(+), 10 deletions(-) > > diff --git a/fs/ramfs.c b/fs/ramfs.c > index 83ab6df..5c7410b 100644 > --- a/fs/ramfs.c > +++ b/fs/ramfs.c > @@ -48,6 +48,10 @@ struct ramfs_inode { > > ulong size; > struct ramfs_chunk *data; > + Trailing whitespace here. > + /* Points to recently used chunk */ > + int recent_chunk; > + struct ramfs_chunk *recent_chunkp; > }; > > struct ramfs_priv { > @@ -297,6 +301,34 @@ static int ramfs_close(struct device_d *dev, FILE *f) > return 0; > } > > +static struct ramfs_chunk *ramfs_find_chunk(struct ramfs_inode *node, int > chunk) > +{ > + struct ramfs_chunk *data; > + int left = chunk; > + > + if (chunk == 0) > + return node->data; > + > + if (node->recent_chunk == chunk) > + return node->recent_chunkp; > + > + if (node->recent_chunk < chunk && node->recent_chunk != 0) { > + /* Start at last known chunk */ > + data = node->recent_chunkp; > + left -= node->recent_chunk; > + } else > + /* Start at first chunk */ > + data = node->data; if you have brackets in the if path you should add them in the else path aswell. > } > + if (node->recent_chunk > newchunks) Also trailing whitespace Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH] PCM970: Added support for CompactFlash
Added support for CompactFlash cards for PCM970 development board via PCMCIA window. Directly we cannot use this feature, because some signals connects to i.MX pins which cannot be configured as GPIO. This is first try to make this interface works, so comments are welcome. Test output: barebox 2012.04.0-00362-gfe020d1-dirty #3 Tue May 15 22:34:45 MSK 2012 Board: Phytec phyCORE-i.MX27 registered netconsole as cs1 mc13xxx-spi@mc13xxx-spi0: Found MC13783 ID: 0x9b [Rev: 3.1] cfi_flash@cfi_flash0: found cfi flash at c000, size 33554432 NAND device: Manufacturer ID: 0x20, Chip ID: 0x36 (ST Micro NAND 64MiB 1,8V 8-bit) Bad block table found at page 131040, version 0x01 Bad block table found at page 131008, version 0x01 cfi_protect: protect 0xc008 (size 1048576) Using environment in NOR Flash Found NXP ISP150x ULPI transceiver (0x04cc:0x1504). ehci@ehci0: USB EHCI 1.00 S/N: SP3A0426041124000132 Firmware version: 04/05/06 Product model number: SAMSUNG CF/ATA Capablity: 2041200 sectors id[49]: capabilities = 0x0200 id[53]: field valid = 0x0001 id[63]: mwdma = 0x id[64]: pio = 0x id[75]: queue depth = 0x id[76]: sata capablity = 0x id[78]: sata features supported = 0x id[79]: sata features enable = 0x id[80]: major version = 0x id[81]: minor version = 0x id[82]: command set supported 1 = 0x id[83]: command set supported 2 = 0x id[84]: command set extension = 0x id[85]: command set enable 1 = 0x id[86]: command set enable 2 = 0x id[87]: command set default = 0x id[88]: udma = 0x id[93]: hardware reset result = 0x Malloc space: 0xa6f0 -> 0xa7ef (size 16 MB) Stack space : 0xa6ef8000 -> 0xa6f0 (size 32 kB) envfs: wrong magic on /dev/env0 no valid environment found on /dev/env0. Using default environment running /env/bin/init... Hit any key to stop autoboot: 3 barebox@Phytec phyCORE-i.MX27:/ mkdir /d barebox@Phytec phyCORE-i.MX27:/ mount /dev/disk0.0 fat /d barebox@Phytec phyCORE-i.MX27:/ ls /d test.txt barebox@Phytec phyCORE-i.MX27:/ Signed-off-by: Alexander Shiyan --- arch/arm/boards/pcm038/pcm970.c | 107 +++ arch/arm/mach-imx/include/mach/imx27-regs.h | 13 +++ 2 files changed, 120 insertions(+), 0 deletions(-) diff --git a/arch/arm/boards/pcm038/pcm970.c b/arch/arm/boards/pcm038/pcm970.c index cd80677..eb517ea 100644 --- a/arch/arm/boards/pcm038/pcm970.c +++ b/arch/arm/boards/pcm038/pcm970.c @@ -18,11 +18,17 @@ #include #include #include +#include +#include #include #include #include #include +#define GPIO_IDE_POWER (GPIO_PORTE + 18) +#define GPIO_IDE_PCOE (GPIO_PORTF + 7) +#define GPIO_IDE_RESET (GPIO_PORTF + 10) + #ifdef CONFIG_USB static void pcm970_usbh2_init(void) { @@ -45,6 +51,103 @@ static void pcm970_usbh2_init(void) } #endif +#ifdef CONFIG_DISK_INTF_PLATFORM_IDE +static struct resource pcm970_ide_resources[] = { + { + .start = IMX_PCMCIA_MEM_BASE, + .size = SZ_1K, + .flags = IORESOURCE_MEM, + }, +}; + +static void pcm970_ide_reset(int state) +{ + /* Switch reset line to low/high state */ + gpio_set_value(GPIO_IDE_RESET, !!state); +} + +static struct ide_port_info pcm970_ide_pdata = { + .ioport_shift = 0, + .reset = &pcm970_ide_reset, +}; + +static struct device_d pcm970_ide_device = { + .id = -1, + .name = "ide_intf", + .num_resources = ARRAY_SIZE(pcm970_ide_resources), + .resource = pcm970_ide_resources, + .platform_data = &pcm970_ide_pdata, +}; + +static void pcm970_ide_init(void) +{ + uint32_t i; + unsigned int mode[] = { + /* PCMCIA */ + PF20_PF_PC_CD1, + PF19_PF_PC_CD2, + PF18_PF_PC_WAIT, + PF17_PF_PC_READY, + PF16_PF_PC_PWRON, + PF14_PF_PC_VS1, + PF13_PF_PC_VS2, + PF12_PF_PC_BVD1, + PF11_PF_PC_BVD2, + PF9_PF_PC_IOIS16, + PF8_PF_PC_RW, + GPIO_IDE_PCOE | GPIO_GPIO | GPIO_OUT, /* PCOE */ + GPIO_IDE_RESET | GPIO_GPIO | GPIO_OUT, /* Reset */ + GPIO_IDE_POWER | GPIO_GPIO | GPIO_OUT, /* Power */ + }; + + for (i = 0; i < ARRAY_SIZE(mode); i++) + imx_gpio_mode(mode[i] | GPIO_PUEN); + + /* Always set PCOE signal to low */ + gpio_set_value(GPIO_IDE_PCOE, 0); + + /* Assert RESET line */ + gpio_set_value(GPIO_IDE_RESET, 0); + + /* Power up CF-card (Also switched on User-LED) */ + gpio_set_value(GPIO_IDE_POWER, 1); + mdelay(10); + + /* Reset PCMCIA Status Change Register */ + PCMCIA_PSCR = 0x0fff; + mdelay(10); + + /* Check PCMCIA Input Pins Register for Card Detect & Power */ + if ((PCMCIA_PIPR & ((1 << 8) | (3 << 3))) != (1 << 8)) { + printf("CompactFlash card not found
[PATCH 7/7] Add FriendlyArm Tiny210 board (S5PV210)
Signed-off-by: Alexey Galakhov --- arch/arm/Makefile |1 + arch/arm/boards/tiny210/Makefile |1 + arch/arm/boards/tiny210/config.h | 21 +++ arch/arm/boards/tiny210/lowlevel.c | 76 arch/arm/boards/tiny210/tiny210.c | 113 arch/arm/configs/tiny210_defconfig | 17 ++ arch/arm/mach-samsung/Kconfig |7 +++ 7 files changed, 236 insertions(+) create mode 100644 arch/arm/boards/tiny210/Makefile create mode 100644 arch/arm/boards/tiny210/config.h create mode 100644 arch/arm/boards/tiny210/lowlevel.c create mode 100644 arch/arm/boards/tiny210/tiny210.c create mode 100644 arch/arm/configs/tiny210_defconfig diff --git a/arch/arm/Makefile b/arch/arm/Makefile index 40291aa..fc29aca 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -133,6 +133,7 @@ board-$(CONFIG_MACH_TX25) := karo-tx25 board-$(CONFIG_MACH_TQMA53):= tqma53 board-$(CONFIG_MACH_TX51) := karo-tx51 board-$(CONFIG_MACH_MX6Q_ARM2) := freescale-mx6-arm2 +board-$(CONFIG_MACH_TINY210) := tiny210 machdirs := $(patsubst %,arch/arm/mach-%/,$(machine-y)) diff --git a/arch/arm/boards/tiny210/Makefile b/arch/arm/boards/tiny210/Makefile new file mode 100644 index 000..9c38e60 --- /dev/null +++ b/arch/arm/boards/tiny210/Makefile @@ -0,0 +1 @@ +obj-y += tiny210.o lowlevel.o diff --git a/arch/arm/boards/tiny210/config.h b/arch/arm/boards/tiny210/config.h new file mode 100644 index 000..5b0a3e6 --- /dev/null +++ b/arch/arm/boards/tiny210/config.h @@ -0,0 +1,21 @@ +#define S5PCXX_CLOCK_REFERENCE 2400 + +#define set_pll(mdiv, pdiv, sdiv) (1<<31 | mdiv<<16 | pdiv<<8 | sdiv) + +#define BOARD_APLL_VAL set_pll(0x7d, 0x3, 0x1) +#define BOARD_MPLL_VAL set_pll(0x29b, 0xc, 0x1) +#define BOARD_EPLL_VAL set_pll(0x60, 0x6, 0x2) +#define BOARD_VPLL_VAL set_pll(0x6c, 0x6, 0x3) + +#define BOARD_CLK_DIV0_MASK0x +#define BOARD_CLK_DIV0_VAL 0x14131440 +#define BOARD_APLL_LOCKTIME0x2cf + +#define S5P_DRAM_DDR2 + +#define S5P_DRAM_WR3 +#define S5P_DRAM_CAS 4 +#define DMC_TIMING_AREF0x0618 +#define DMC_TIMING_ROW 0x2B34438A +#define DMC_TIMING_DATA0x2424 +#define DMC_TIMING_PWR 0x0BDC0343 diff --git a/arch/arm/boards/tiny210/lowlevel.c b/arch/arm/boards/tiny210/lowlevel.c new file mode 100644 index 000..7dbdc69 --- /dev/null +++ b/arch/arm/boards/tiny210/lowlevel.c @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2012 Alexey Galakhov + * + * 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 + * version 2 as published by the Free Software Foundation. + * + * 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 + +/* + * iROM boot from MMC + * TODO: replace this by native boot + */ + +#define ADDR_V210_SDMMC_BASE 0xD0037488 +#define ADDR_CopySDMMCtoMem0xD0037F98 + +#define RR(x) (*(volatile uint32_t*)(x)) + +int __bare_init s5p_irom_load_mmc(void *dest, uint32_t start_block, uint16_t block_count) +{ + typedef uint32_t (*func_t) (int32_t, uint32_t, uint16_t, uint32_t*, int8_t); + uint32_t chbase = RR(ADDR_V210_SDMMC_BASE); + func_t func = (func_t)RR(ADDR_CopySDMMCtoMem); + int chan = (chbase - 0xEB00) >> 20; + if (chan != 0 && chan != 2) + return 0; + return func(chan, start_block, block_count, (uint32_t*)dest, 0) ? 1 : 0; +} + + +void __bare_init board_init_lowlevel(void) +{ + uint32_t r; + +#ifdef CONFIG_S3C_PLL_INIT + s5p_init_pll(); +#endif + + if (get_pc() < 0xD000) /* Are we running from iRAM? */ + return; /* No, we don't. */ + +#ifdef CONFIG_S3C_SDRAM_INIT + s5p_init_dram_bank(S5P_DMC0_BASE, 0x20E00323, 0); +#endif + + if (! s5p_irom_load_mmc((void*)TEXT_BASE - 16, 1, (barebox_image_size + 16 + 511) / 512)) + while (1) { } /* hang */ + + /* Jump to SDRAM */ + r = (unsigned)TEXT_BASE; + __asm__ __volatile__("mov pc, %0" : : "r"(r)); + while (1) { } /* hang */ +} diff --git a/arch/arm/boards/tiny210/tiny210.c b/arch/arm/boards/tiny210/tiny210.c new file mode 100644 index 000..f3a5d33 --- /dev/null +++ b/arch/arm/boards/tiny210/tiny210.c @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2012 Alexey Ga
[PATCH 3/7] Add support for Samsung S5P architecture (S5PV210)
Signed-off-by: Alexey Galakhov --- arch/arm/Kconfig |6 + arch/arm/mach-samsung/Kconfig | 22 + arch/arm/mach-samsung/Makefile |1 + arch/arm/mach-samsung/clocks-s5pcxx.c | 98 +++ arch/arm/mach-samsung/gpio-s5pcxx.c| 123 +++ arch/arm/mach-samsung/include/mach/gpio.h |3 + arch/arm/mach-samsung/include/mach/iomux-s5pcxx.h | 798 arch/arm/mach-samsung/include/mach/s3c-clocks.h|3 + arch/arm/mach-samsung/include/mach/s3c-iomap.h |3 + arch/arm/mach-samsung/include/mach/s5pcxx-clocks.h | 55 ++ arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h | 49 ++ 11 files changed, 1161 insertions(+) create mode 100644 arch/arm/mach-samsung/clocks-s5pcxx.c create mode 100644 arch/arm/mach-samsung/gpio-s5pcxx.c create mode 100644 arch/arm/mach-samsung/include/mach/iomux-s5pcxx.h create mode 100644 arch/arm/mach-samsung/include/mach/s5pcxx-clocks.h create mode 100644 arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 8a4e1a2..f465084 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -73,6 +73,12 @@ config ARCH_S3C24xx select CPU_ARM920T select GENERIC_GPIO +config ARCH_S5PCxx + bool "Samsung S5PC110, S5PV210" + select ARCH_SAMSUNG + select CPU_V7 + select GENERIC_GPIO + config ARCH_VERSATILE bool "ARM Versatile boards (ARM926EJ-S)" select CPU_ARM926T diff --git a/arch/arm/mach-samsung/Kconfig b/arch/arm/mach-samsung/Kconfig index 63c29ef..65e2acb 100644 --- a/arch/arm/mach-samsung/Kconfig +++ b/arch/arm/mach-samsung/Kconfig @@ -14,6 +14,10 @@ config BOARDINFO default "Digi A9M2440" if MACH_A9M2440 default "Digi A9M2410" if MACH_A9M2410 +config ARCH_BAREBOX_MAX_BARE_INIT_SIZE + hex + default 0x1ff0 if ARCH_S5PCxx + if ARCH_S3C24xx config CPU_S3C2410 @@ -80,6 +84,24 @@ endmenu endif +if ARCH_S5PCxx + +config CPU_S5PC110 + bool + +config CPU_S5PV210 + bool + +choice + + prompt "S5PCxx board type" + + +endchoice + +endif + + menu "S3C Features " config S3C_LOWLEVEL_INIT diff --git a/arch/arm/mach-samsung/Makefile b/arch/arm/mach-samsung/Makefile index bde707f..0b95e14 100644 --- a/arch/arm/mach-samsung/Makefile +++ b/arch/arm/mach-samsung/Makefile @@ -1,4 +1,5 @@ obj-y += s3c-timer.o generic.o obj-lowlevel-$(CONFIG_ARCH_S3C24xx) += lowlevel-s3c24x0.o obj-$(CONFIG_ARCH_S3C24xx) += gpio-s3c24x0.o s3c24xx-clocks.o mem-s3c24x0.o +obj-$(CONFIG_ARCH_S5PCxx) += gpio-s5pcxx.o clocks-s5pcxx.o obj-$(CONFIG_S3C_LOWLEVEL_INIT) += $(obj-lowlevel-y) diff --git a/arch/arm/mach-samsung/clocks-s5pcxx.c b/arch/arm/mach-samsung/clocks-s5pcxx.c new file mode 100644 index 000..1f4790b --- /dev/null +++ b/arch/arm/mach-samsung/clocks-s5pcxx.c @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2012 Alexey Galakhov + * Copyright (C) 2012 Juergen Beisert, Pengutronix + * + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +static inline uint32_t clkdiv(uint32_t clk, unsigned bit, unsigned mask) +{ + uint32_t ratio = (readl(S5P_CLK_DIV0) >> bit) & mask; + return clk / (ratio + 1); +} + +uint32_t s3c_get_mpllclk(void) +{ + uint32_t m, p, s; + uint32_t reg = readl(S5P_xPLL_CON + S5P_MPLL); + m = (reg >> 16) & 0x3ff; + p = (reg >> 8) & 0x3f; + s = (reg >> 0) & 0x7; + return m * ((S5PCXX_CLOCK_REFERENCE) / (p << s)); +} + +uint32_t s3c_get_apllclk(void) +{ + uint32_t m, p, s; + uint32_t reg = readl(S5P_xPLL_CON + S5P_APLL); + m = (reg >> 16) & 0x3ff; + p = (reg >> 8) & 0x3f; + s = (reg >> 0) & 0x7; + s -= 1; + return m * ((S5PCXX_CLOCK_REFERENCE) / (p << s)); +} + +static uint32_t s5p_get_a2mclk(void) +{ + return clkdiv(s3c_get_apllclk(), 4, 0x7); +} + +static uint32_t s5p_get_moutpsysclk(void) +{ + if (readl(S5P_CLK_SRC0) & (1 << 24)) /* MUX_PSYS */ + return s5p_get_a2mclk(); +else + return s3c_get_mpllclk(); +} + +uint32_t s3c_get_hclk(void) +{ + return clkdiv(s5p_get_moutpsysclk(), 24, 0xf); +} + +uint32_t s3c_get_pclk(void) +{ + return clkdiv(s3c_get_hclk(), 28, 0x7); +} + +/* we are using the internal 'uclk1' as the UART source */ +static unsigned s3c_get_uart_clk_uclk1(void) +{ + unsigne
[PATCH 6/7] S5P DRAM support
Signed-off-by: Alexey Galakhov --- arch/arm/mach-samsung/Makefile|2 +- arch/arm/mach-samsung/include/mach/s3c-generic.h |1 + arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h |3 + arch/arm/mach-samsung/mem-s5pcxx.c| 260 + 4 files changed, 265 insertions(+), 1 deletion(-) create mode 100644 arch/arm/mach-samsung/mem-s5pcxx.c diff --git a/arch/arm/mach-samsung/Makefile b/arch/arm/mach-samsung/Makefile index d7344c8..6020587 100644 --- a/arch/arm/mach-samsung/Makefile +++ b/arch/arm/mach-samsung/Makefile @@ -2,5 +2,5 @@ obj-y += s3c-timer.o generic.o obj-lowlevel-$(CONFIG_ARCH_S3C24xx) += lowlevel-s3c24x0.o obj-lowlevel-$(CONFIG_ARCH_S5PCxx) += lowlevel-s5pcxx.o obj-$(CONFIG_ARCH_S3C24xx) += gpio-s3c24x0.o s3c24xx-clocks.o mem-s3c24x0.o -obj-$(CONFIG_ARCH_S5PCxx) += gpio-s5pcxx.o clocks-s5pcxx.o +obj-$(CONFIG_ARCH_S5PCxx) += gpio-s5pcxx.o clocks-s5pcxx.o mem-s5pcxx.o obj-$(CONFIG_S3C_LOWLEVEL_INIT) += $(obj-lowlevel-y) diff --git a/arch/arm/mach-samsung/include/mach/s3c-generic.h b/arch/arm/mach-samsung/include/mach/s3c-generic.h index 578aae1..9a5a642 100644 --- a/arch/arm/mach-samsung/include/mach/s3c-generic.h +++ b/arch/arm/mach-samsung/include/mach/s3c-generic.h @@ -41,4 +41,5 @@ void s3c24xx_disable_second_sdram_bank(void); #ifdef CONFIG_ARCH_S5PCxx void s5p_init_pll(void); +void s5p_init_dram_bank(uint32_t base, uint32_t mc0, uint32_t mc1); #endif diff --git a/arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h b/arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h index cb05527..248f868 100644 --- a/arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h +++ b/arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h @@ -47,3 +47,6 @@ #define S3C_UART3_SIZE 0x400 #define S3C_UART_HAS_UBRDIVSLOT #define S3C_UART_HAS_UINTM + +#define S5P_DMC0_BASE 0xF000 +#define S5P_DMC1_BASE 0xF140 diff --git a/arch/arm/mach-samsung/mem-s5pcxx.c b/arch/arm/mach-samsung/mem-s5pcxx.c new file mode 100644 index 000..f3d325a --- /dev/null +++ b/arch/arm/mach-samsung/mem-s5pcxx.c @@ -0,0 +1,260 @@ +/* + * Copyright (C) 2012 Alexey Galakhov + * + * Based on code from u-boot found somewhere on the web + * that seems to originate from Samsung + * + * 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. + */ + +#include +#include +#include +#include +#include +#include + +#define S5P_DMC_CONCONTROL 0x00 +#define S5P_DMC_MEMCONTROL 0x04 +#define S5P_DMC_MEMCONFIG0 0x08 +#define S5P_DMC_MEMCONFIG1 0x0C +#define S5P_DMC_DIRECTCMD 0x10 +#define S5P_DMC_PRECHCONFIG0x14 +#define S5P_DMC_PHYCONTROL00x18 +#define S5P_DMC_PHYCONTROL10x1C +#define S5P_DMC_PWRDNCONFIG0x28 +#define S5P_DMC_TIMINGAREF 0x30 +#define S5P_DMC_TIMINGROW 0x34 +#define S5P_DMC_TIMINGDATA 0x38 +#define S5P_DMC_TIMINGPOWER0x3C +#define S5P_DMC_PHYSTATUS 0x40 + +/* DRAM commands */ +#define CMD(x) ((x) << 24) +#define BANK(x) ((x) << 16) +#define CHIP(x) ((x) << 20) +#define ADDR(x) (x) + +/** + * MR definition: + * 1 11 + * 2 1098 7654 3210 + * | | ^^^- burst length, 010=4, 011=8 + * | | ^- burst type 0=sequnential, 1=interleaved + * | ^^^-- CAS latency + * | ^- test, 0=normal, 1=test + * |^ DLL reset, 1=yes + *^^^- WR, 1=2, 2=3 etc. + * ^--- PD, 0=fast exit, 1=low power + * + * EMR1 definition: + * 1 11 + * 2 1098 7654 3210 + * | ^- DLL, 0=enable + * | ^-- output strength, 0=full, 1=reduced + * |^.. .^--- Rtt, 00=off, 01=75, 10=150, 11=50 Ohm + * | ^^ ^-- Posted CAS# AL, 0-6 + * ^^ ^-- OCD: 000=OCD exit, 111=enable defaults + * ^-- DQS#, 0=enable, 1=disable + *^--- RDQS enable, 0=no, 1=yes + * ^ outputs, 0=enabled, 1=disabled + * + * EMR2 definition: + * bit 7 + * 1 1 + * 2 1098 7654 3210 + * ^-- SRT, 0=1x (0-85 deg.C), 1=2x (>85 deg.C) + * all other bits = 0 + * + * EMR3 definition: all bits 0 + */ + +#define MRSCMD(0x0) +#define PALL CMD(0x1) +#define PRECMD(0x2) +#define DPDCMD(0x3) +#define REFS CMD(0x4) +#define REFA CMD(0x5) +#define CKEL CMD(0x6) +#define NOPCMD(0x7) +#define REFSX CMD(0x8) +#define MRRCMD(0x9) + +#define EMRS1 (MRS | BANK(1)) +#define EMRS2 (MRS | BANK(2)) +#define EMRS3 (MRS | BANK(3)) + +/* Burst is (1 << S5P_DRAM_BURST), i.e. S5P_DRAM_BURST=2 for burst 4 */ +#ifndef S5P_DRAM_BURST +/* (LP)DDR2 supports burst 4 only, make it default */ +# define S5P_DRAM_BURST 2
[PATCH 5/7] S5P lowlevel clock init
Signed-off-by: Alexey Galakhov --- arch/arm/mach-samsung/Makefile |1 + arch/arm/mach-samsung/include/mach/s3c-generic.h |4 ++ arch/arm/mach-samsung/lowlevel-s5pcxx.c | 61 ++ 3 files changed, 66 insertions(+) create mode 100644 arch/arm/mach-samsung/lowlevel-s5pcxx.c diff --git a/arch/arm/mach-samsung/Makefile b/arch/arm/mach-samsung/Makefile index 0b95e14..d7344c8 100644 --- a/arch/arm/mach-samsung/Makefile +++ b/arch/arm/mach-samsung/Makefile @@ -1,5 +1,6 @@ obj-y += s3c-timer.o generic.o obj-lowlevel-$(CONFIG_ARCH_S3C24xx) += lowlevel-s3c24x0.o +obj-lowlevel-$(CONFIG_ARCH_S5PCxx) += lowlevel-s5pcxx.o obj-$(CONFIG_ARCH_S3C24xx) += gpio-s3c24x0.o s3c24xx-clocks.o mem-s3c24x0.o obj-$(CONFIG_ARCH_S5PCxx) += gpio-s5pcxx.o clocks-s5pcxx.o obj-$(CONFIG_S3C_LOWLEVEL_INIT) += $(obj-lowlevel-y) diff --git a/arch/arm/mach-samsung/include/mach/s3c-generic.h b/arch/arm/mach-samsung/include/mach/s3c-generic.h index 62d2c93..578aae1 100644 --- a/arch/arm/mach-samsung/include/mach/s3c-generic.h +++ b/arch/arm/mach-samsung/include/mach/s3c-generic.h @@ -38,3 +38,7 @@ uint32_t s3c_get_memory_size(void); #ifdef CONFIG_ARCH_S3C24xx void s3c24xx_disable_second_sdram_bank(void); #endif + +#ifdef CONFIG_ARCH_S5PCxx +void s5p_init_pll(void); +#endif diff --git a/arch/arm/mach-samsung/lowlevel-s5pcxx.c b/arch/arm/mach-samsung/lowlevel-s5pcxx.c new file mode 100644 index 000..15afa47 --- /dev/null +++ b/arch/arm/mach-samsung/lowlevel-s5pcxx.c @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2012 Alexey Galakhov + * + * Based on code from u-boot found somewhere on the web + * that seems to originate from Samsung + * + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include + +#ifdef CONFIG_S3C_PLL_INIT +void __bare_init s5p_init_pll(void) +{ +uint32_t reg; +int i; + +/* Set Mux to FIN */ +writel(0, S5P_CLK_SRC0); + +writel(BOARD_APLL_LOCKTIME, S5P_xPLL_LOCK + S5P_APLL); + +/* Disable PLL */ +writel(0, S5P_xPLL_CON + S5P_APLL); +writel(0, S5P_xPLL_CON + S5P_MPLL); + +/* Set up dividers */ +reg = readl(S5P_CLK_DIV0); +reg &= ~(BOARD_CLK_DIV0_MASK); +reg |= (BOARD_CLK_DIV0_VAL); +writel(reg, S5P_CLK_DIV0); + +/* Set up PLLs */ +writel(BOARD_APLL_VAL, S5P_xPLL_CON + S5P_APLL); +writel(BOARD_MPLL_VAL, S5P_xPLL_CON + S5P_MPLL); +writel(BOARD_EPLL_VAL, S5P_xPLL_CON + S5P_EPLL); +writel(BOARD_VPLL_VAL, S5P_xPLL_CON + S5P_VPLL); + +/* Wait for sync */ +for (i = 0; i < 0x1; ++i) +barrier(); + +reg = readl(S5P_CLK_SRC0); +reg |= 0x; /* switch MUX to PLL outputs */ +writel(reg, S5P_CLK_SRC0); +} +#endif /* CONFIG_S3C_PLL_INIT */ -- 1.7.10 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 4/7] S5P boot header and image generator
Signed-off-by: Alexey Galakhov --- .gitignore |2 + Makefile|2 +- arch/arm/Makefile |7 +++ scripts/Makefile|1 + scripts/s5p_cksum.c | 140 +++ 5 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 scripts/s5p_cksum.c diff --git a/.gitignore b/.gitignore index 8e208e0..df0ed2c 100644 --- a/.gitignore +++ b/.gitignore @@ -33,6 +33,7 @@ barebox.S barebox.bin barebox.srec barebox.netx +barebox.s5p barebox.map System.map Module.symvers @@ -63,3 +64,4 @@ cscope.* # patches *.patch scripts/gen_netx_image +scripts/s5p_cksum diff --git a/Makefile b/Makefile index 44b7dbd..91ded1b 100644 --- a/Makefile +++ b/Makefile @@ -1003,7 +1003,7 @@ CLEAN_DIRS += $(MODVERDIR) CLEAN_FILES += barebox System.map include/generated/barebox_default_env.h \ .tmp_version .tmp_barebox* barebox.bin barebox.map barebox.S \ .tmp_kallsyms* barebox_default_env* barebox.ldr \ - Doxyfile.version barebox.srec + Doxyfile.version barebox.srec barebox.s5p # Directories & files removed with 'make mrproper' MRPROPER_DIRS += include/config include2 usr/include diff --git a/arch/arm/Makefile b/arch/arm/Makefile index d0bfd71..40291aa 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -164,6 +164,13 @@ ifeq ($(machine-y),netx) KBUILD_IMAGE := barebox.netx endif +barebox.s5p: barebox.bin + $(Q)scripts/s5p_cksum barebox.bin barebox.s5p + +ifeq ($(CONFIG_ARCH_S5PCxx),y) +KBUILD_IMAGE := barebox.s5p +endif + MLO: barebox.bin @echo " IFT" $@ $(Q)scripts/omap_signGP barebox.bin $(TEXT_BASE) 1 diff --git a/scripts/Makefile b/scripts/Makefile index cb049fd..784d205 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -10,6 +10,7 @@ hostprogs-y += mkimage hostprogs-y += bareboxenv hostprogs-$(CONFIG_ARCH_NETX)+= gen_netx_image hostprogs-$(CONFIG_ARCH_OMAP)+= omap_signGP +hostprogs-$(CONFIG_ARCH_S5PCxx) += s5p_cksum always := $(hostprogs-y) $(hostprogs-m) diff --git a/scripts/s5p_cksum.c b/scripts/s5p_cksum.c new file mode 100644 index 000..7142532 --- /dev/null +++ b/scripts/s5p_cksum.c @@ -0,0 +1,140 @@ +/* + * Copyright (C) 2012 Alexey Galakhov + * + * 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 + * version 2 as published by the Free Software Foundation. + * + * 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 + +#define DEFAULT_BUF_SIZE 8192 + +static int usage(const char* me) +{ + printf("Usage: %s [> 8) & 0xFF; + ptr[2] = (value >> 16) & 0xFF; + ptr[3] = (value >> 24) & 0xFF; +} + +static size_t safe_fread(void *buf, size_t len, FILE* file) +{ + size_t rd = fread(buf, 1, len, file); + if (! rd) { + if (ferror(file)) + fprintf(stderr, "Error reading file: %s\n", strerror(errno)); + else + fprintf(stderr, "Unexpected end of file\n"); + } + return rd; +} + +static size_t safe_fwrite(const void *buf, size_t len, FILE* file) +{ + size_t wr = fwrite(buf, 1, len, file); + if (wr != len) { + fprintf(stderr, "Error writing file: %s\n", strerror(errno)); + return 0; + } + return wr; +} + +static int process(FILE *input, FILE *output, uint8_t *buf, unsigned bufsize) +{ + size_t rd; + unsigned i; + uint32_t cksum; + /* Read first chunk */ + rd = safe_fread(buf + 16, bufsize - 16, input); + if (! rd) + return 4; + /* Calculate header */ + put32(buf + 0, bufsize); + cksum = 0; + for (i = 16; i < bufsize; ++i) + cksum += (uint32_t)buf[i]; + put32(buf + 8, cksum); + if (! safe_fwrite(buf, bufsize, output)) + return 4; + /* Copy the rest of file */ + while (! feof(input)) { + rd = safe_fread(buf, bufsize, input); + if (! rd) + return 4; + if (! safe_fwrite(buf, rd, output)) + return 4; + } + return 0; +} + +static int work(const char* me, const char *infile, const char *outfile, unsigned bufsize) +{ + uint8_t *buf; + FILE *input; +
[PATCH 2/7] Split S3C generic and S3C24xx specific code
Signed-off-by: Alexey Galakhov --- arch/arm/boards/a9m2410/a9m2410.c |2 +- arch/arm/boards/a9m2440/a9m2440.c |2 +- arch/arm/boards/mini2440/mini2440.c|2 +- arch/arm/mach-samsung/Makefile |5 +- arch/arm/mach-samsung/generic.c| 113 --- arch/arm/mach-samsung/include/mach/s3c-clocks.h| 22 +- arch/arm/mach-samsung/include/mach/s3c-generic.h |4 +- arch/arm/mach-samsung/include/mach/s3c-iomap.h | 53 +--- .../arm/mach-samsung/include/mach/s3c24xx-clocks.h | 24 ++ arch/arm/mach-samsung/include/mach/s3c24xx-gpio.h |6 +- arch/arm/mach-samsung/include/mach/s3c24xx-iomap.h | 69 + arch/arm/mach-samsung/lowlevel-init.S | 317 arch/arm/mach-samsung/lowlevel-s3c24x0.S | 317 arch/arm/mach-samsung/mem-s3c24x0.c| 143 + 14 files changed, 579 insertions(+), 500 deletions(-) create mode 100644 arch/arm/mach-samsung/include/mach/s3c24xx-clocks.h create mode 100644 arch/arm/mach-samsung/include/mach/s3c24xx-iomap.h delete mode 100644 arch/arm/mach-samsung/lowlevel-init.S create mode 100644 arch/arm/mach-samsung/lowlevel-s3c24x0.S create mode 100644 arch/arm/mach-samsung/mem-s3c24x0.c diff --git a/arch/arm/boards/a9m2410/a9m2410.c b/arch/arm/boards/a9m2410/a9m2410.c index eaafdbd..31ed772 100644 --- a/arch/arm/boards/a9m2410/a9m2410.c +++ b/arch/arm/boards/a9m2410/a9m2410.c @@ -51,7 +51,7 @@ static int a9m2410_mem_init(void) * Note: On this card the second SDRAM page is not used */ s3c24xx_disable_second_sdram_bank(); - size = s3c24xx_get_memory_size(); + size = s3c_get_memory_size(); /* -- configure the GPIOs - */ writel(0x007F, S3C_GPACON); diff --git a/arch/arm/boards/a9m2440/a9m2440.c b/arch/arm/boards/a9m2440/a9m2440.c index 1d20248..a27c748 100644 --- a/arch/arm/boards/a9m2440/a9m2440.c +++ b/arch/arm/boards/a9m2440/a9m2440.c @@ -99,7 +99,7 @@ static int a9m2440_mem_init(void) break; } - arm_add_mem_device("ram0", S3C_SDRAM_BASE, s3c24xx_get_memory_size()); + arm_add_mem_device("ram0", S3C_SDRAM_BASE, s3c_get_memory_size()); return 0; } diff --git a/arch/arm/boards/mini2440/mini2440.c b/arch/arm/boards/mini2440/mini2440.c index 3d3b820..066fd1c 100644 --- a/arch/arm/boards/mini2440/mini2440.c +++ b/arch/arm/boards/mini2440/mini2440.c @@ -268,7 +268,7 @@ static const unsigned pin_usage[] = { static int mini2440_mem_init(void) { - arm_add_mem_device("ram0", S3C_SDRAM_BASE, s3c24xx_get_memory_size()); + arm_add_mem_device("ram0", S3C_SDRAM_BASE, s3c_get_memory_size()); return 0; } diff --git a/arch/arm/mach-samsung/Makefile b/arch/arm/mach-samsung/Makefile index 349ba9b..bde707f 100644 --- a/arch/arm/mach-samsung/Makefile +++ b/arch/arm/mach-samsung/Makefile @@ -1,3 +1,4 @@ obj-y += s3c-timer.o generic.o -obj-$(CONFIG_ARCH_S3C24xx) += gpio-s3c24x0.o s3c24xx-clocks.o -obj-$(CONFIG_S3C_LOWLEVEL_INIT) += lowlevel-init.o +obj-lowlevel-$(CONFIG_ARCH_S3C24xx) += lowlevel-s3c24x0.o +obj-$(CONFIG_ARCH_S3C24xx) += gpio-s3c24x0.o s3c24xx-clocks.o mem-s3c24x0.o +obj-$(CONFIG_S3C_LOWLEVEL_INIT) += $(obj-lowlevel-y) diff --git a/arch/arm/mach-samsung/generic.c b/arch/arm/mach-samsung/generic.c index 7706be2..7095294 100644 --- a/arch/arm/mach-samsung/generic.c +++ b/arch/arm/mach-samsung/generic.c @@ -25,65 +25,9 @@ #include #include #include -#include #include -#include #include #include -#include -#include - -/** - * Calculate the amount of connected and available memory - * @return Memory size in bytes - */ -uint32_t s3c24xx_get_memory_size(void) -{ - uint32_t reg, size; - - /* -* detect the current memory size -*/ - reg = readl(S3C_BANKSIZE); - - switch (reg & 0x7) { - case 0: - size = SZ_32M; - break; - case 1: - size = SZ_64M; - break; - case 2: - size = SZ_128M; - break; - case 4: - size = SZ_2M; - break; - case 5: - size = SZ_4M; - break; - case 6: - size = SZ_8M; - break; - default: - size = SZ_16M; - break; - } - - /* -* Is bank7 also configured for SDRAM usage? -*/ - if ((readl(S3C_BANKCON7) & (0x3 << 15)) == (0x3 << 15)) - size <<= 1; /* also count this bank */ - - return size; -} - -void s3c24xx_disable_second_sdram_bank(void) -{ - writel(readl(S3C_BANKCON7) & ~(0x3 << 15), S3C_BANKCON7); - writel(readl(S3C_MISCCR) | (1 << 18), S3C_MISCCR); /* disable its clock */ -} #define S3C_WTCON (S3C_WATCHDOG_BASE) #define S3C_WTDAT (S3C_WATCHDOG_BASE + 0x04) @@ -105,60
[PATCH 1/7] Make S3C24xx config options available for all S3Cs
Signed-off-by: Alexey Galakhov --- arch/arm/boards/a9m2410/a9m2410.c |2 +- arch/arm/boards/a9m2410/config.h |2 +- arch/arm/boards/a9m2410/lowlevel_init.S |2 +- arch/arm/boards/a9m2440/a9m2440.c |2 +- arch/arm/boards/a9m2440/config.h |2 +- arch/arm/boards/a9m2440/lowlevel_init.S |2 +- arch/arm/boards/mini2440/config.h |2 +- arch/arm/boards/mini2440/lowlevel_init.S |2 +- arch/arm/boards/mini2440/mini2440.c |2 +- arch/arm/configs/a9m2410_defconfig|2 +- arch/arm/configs/a9m2440_defconfig|4 +-- arch/arm/configs/mini2440_defconfig |2 +- arch/arm/mach-samsung/Kconfig | 28 ++--- arch/arm/mach-samsung/Makefile|2 +- arch/arm/mach-samsung/include/mach/s3c-iomap.h|2 +- arch/arm/mach-samsung/include/mach/s3c24xx-nand.h |2 +- arch/arm/mach-samsung/lowlevel-init.S | 12 - drivers/mtd/nand/nand_s3c24xx.c | 10 18 files changed, 41 insertions(+), 41 deletions(-) diff --git a/arch/arm/boards/a9m2410/a9m2410.c b/arch/arm/boards/a9m2410/a9m2410.c index 7c51d58..eaafdbd 100644 --- a/arch/arm/boards/a9m2410/a9m2410.c +++ b/arch/arm/boards/a9m2410/a9m2410.c @@ -136,7 +136,7 @@ static int a9m2410_devices_init(void) device_initcall(a9m2410_devices_init); -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CONFIG_S3C_NAND_BOOT void __bare_init nand_boot(void) { s3c24x0_nand_load_image((void *)TEXT_BASE, 256 * 1024, 0); diff --git a/arch/arm/boards/a9m2410/config.h b/arch/arm/boards/a9m2410/config.h index 87b05fc..4b8a9a2 100644 --- a/arch/arm/boards/a9m2410/config.h +++ b/arch/arm/boards/a9m2410/config.h @@ -115,7 +115,7 @@ #define A9M2410_TWRPH1 1 /* needed in the generic NAND boot code only */ -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CONFIG_S3C_NAND_BOOT # define BOARD_DEFAULT_NAND_TIMING CALC_NFCONF_TIMING(A9M2410_TACLS, A9M2410_TWRPH0, A9M2410_TWRPH1) #endif diff --git a/arch/arm/boards/a9m2410/lowlevel_init.S b/arch/arm/boards/a9m2410/lowlevel_init.S index a106d53..0463b26 100644 --- a/arch/arm/boards/a9m2410/lowlevel_init.S +++ b/arch/arm/boards/a9m2410/lowlevel_init.S @@ -28,7 +28,7 @@ board_init_lowlevel: bl s3c24x0_sdram_init -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CONFIG_S3C_NAND_BOOT mov lr, r10 /* restore the link register */ /* up to here we are running from the internal SRAM area */ b s3c24x0_nand_boot /* does return directly to our caller into SDRAM */ diff --git a/arch/arm/boards/a9m2440/a9m2440.c b/arch/arm/boards/a9m2440/a9m2440.c index fcb8729..1d20248 100644 --- a/arch/arm/boards/a9m2440/a9m2440.c +++ b/arch/arm/boards/a9m2440/a9m2440.c @@ -155,7 +155,7 @@ static int a9m2440_devices_init(void) device_initcall(a9m2440_devices_init); -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CONFIG_S3C_NAND_BOOT void __bare_init nand_boot(void) { s3c24x0_nand_load_image((void *)TEXT_BASE, 256 * 1024, 0); diff --git a/arch/arm/boards/a9m2440/config.h b/arch/arm/boards/a9m2440/config.h index 43cb6ab..09ad949 100644 --- a/arch/arm/boards/a9m2440/config.h +++ b/arch/arm/boards/a9m2440/config.h @@ -66,7 +66,7 @@ #define A9M2440_TWRPH1 1 /* needed in the generic NAND boot code only */ -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CONFIG_S3C_NAND_BOOT # define BOARD_DEFAULT_NAND_TIMING CALC_NFCONF_TIMING(A9M2440_TACLS, A9M2440_TWRPH0, A9M2440_TWRPH1) #endif diff --git a/arch/arm/boards/a9m2440/lowlevel_init.S b/arch/arm/boards/a9m2440/lowlevel_init.S index e915a16..305014c 100644 --- a/arch/arm/boards/a9m2440/lowlevel_init.S +++ b/arch/arm/boards/a9m2440/lowlevel_init.S @@ -232,7 +232,7 @@ board_init_lowlevel: bl sdram_init -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CONFIG_S3C_NAND_BOOT mov lr, r10 /* restore the link register */ /* up to here we are running from the internal SRAM area */ b s3c24x0_nand_boot /* does return directly to our caller into SDRAM */ diff --git a/arch/arm/boards/mini2440/config.h b/arch/arm/boards/mini2440/config.h index 8d36193..674d974 100644 --- a/arch/arm/boards/mini2440/config.h +++ b/arch/arm/boards/mini2440/config.h @@ -66,7 +66,7 @@ #define MINI2440_TWRPH1 1 /* needed in the generic NAND boot code only */ -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CONFIG_S3C_NAND_BOOT # define BOARD_DEFAULT_NAND_TIMING \ CALC_NFCONF_TIMING(MINI2440_TACLS, MINI2440_TWRPH0, MINI2440_TWRPH1) #endif diff --git a/arch/arm/boards/mini2440/lowlevel_init.S b/arch/arm/boards/mini2440/lowlevel_init.S index 1c8860a..827cf00 100644 --- a/arch/arm/boards/mini2440/lowlevel_init.S +++ b/arch/arm/boards/mini2440/lowlevel_init.S @@ -30,7 +30,7 @@ board_init_lowlevel: bl s3c24x0_sdram_init -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CON
[PATCHv3 0/7] Cleaned up version of S5PV210 code
Hello, I cleaned up the S5PV210/Tiny210 patches as discussed before. Thank you for useful comments. Alexey Galakhov (7): Make S3C24xx config options available for all S3Cs Split S3C generic and S3C24xx specific code Add support for Samsung S5P architecture (S5PV210) S5P boot header and image generator S5P lowlevel clock init S5P DRAM support Add FriendlyArm Tiny210 board (S5PV210) .gitignore |2 + Makefile |2 +- arch/arm/Kconfig |6 + arch/arm/Makefile |8 + arch/arm/boards/a9m2410/a9m2410.c |4 +- arch/arm/boards/a9m2410/config.h |2 +- arch/arm/boards/a9m2410/lowlevel_init.S|2 +- arch/arm/boards/a9m2440/a9m2440.c |4 +- arch/arm/boards/a9m2440/config.h |2 +- arch/arm/boards/a9m2440/lowlevel_init.S|2 +- arch/arm/boards/mini2440/config.h |2 +- arch/arm/boards/mini2440/lowlevel_init.S |2 +- arch/arm/boards/mini2440/mini2440.c|4 +- arch/arm/boards/tiny210/Makefile |1 + arch/arm/boards/tiny210/config.h | 21 + arch/arm/boards/tiny210/lowlevel.c | 76 ++ arch/arm/boards/tiny210/tiny210.c | 113 +++ arch/arm/configs/a9m2410_defconfig |2 +- arch/arm/configs/a9m2440_defconfig |4 +- arch/arm/configs/mini2440_defconfig|2 +- arch/arm/configs/tiny210_defconfig | 17 + arch/arm/mach-samsung/Kconfig | 57 +- arch/arm/mach-samsung/Makefile |7 +- arch/arm/mach-samsung/clocks-s5pcxx.c | 98 +++ arch/arm/mach-samsung/generic.c| 113 --- arch/arm/mach-samsung/gpio-s5pcxx.c| 123 +++ arch/arm/mach-samsung/include/mach/gpio.h |3 + arch/arm/mach-samsung/include/mach/iomux-s5pcxx.h | 798 arch/arm/mach-samsung/include/mach/s3c-clocks.h| 25 +- arch/arm/mach-samsung/include/mach/s3c-generic.h |9 +- arch/arm/mach-samsung/include/mach/s3c-iomap.h | 56 +- .../arm/mach-samsung/include/mach/s3c24xx-clocks.h | 24 + arch/arm/mach-samsung/include/mach/s3c24xx-gpio.h |6 +- arch/arm/mach-samsung/include/mach/s3c24xx-iomap.h | 69 ++ arch/arm/mach-samsung/include/mach/s3c24xx-nand.h |2 +- arch/arm/mach-samsung/include/mach/s5pcxx-clocks.h | 55 ++ arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h | 52 ++ arch/arm/mach-samsung/lowlevel-init.S | 317 arch/arm/mach-samsung/lowlevel-s3c24x0.S | 317 arch/arm/mach-samsung/lowlevel-s5pcxx.c| 61 ++ arch/arm/mach-samsung/mem-s3c24x0.c| 143 arch/arm/mach-samsung/mem-s5pcxx.c | 260 +++ drivers/mtd/nand/nand_s3c24xx.c| 10 +- scripts/Makefile |1 + scripts/s5p_cksum.c| 140 45 files changed, 2490 insertions(+), 534 deletions(-) create mode 100644 arch/arm/boards/tiny210/Makefile create mode 100644 arch/arm/boards/tiny210/config.h create mode 100644 arch/arm/boards/tiny210/lowlevel.c create mode 100644 arch/arm/boards/tiny210/tiny210.c create mode 100644 arch/arm/configs/tiny210_defconfig create mode 100644 arch/arm/mach-samsung/clocks-s5pcxx.c create mode 100644 arch/arm/mach-samsung/gpio-s5pcxx.c create mode 100644 arch/arm/mach-samsung/include/mach/iomux-s5pcxx.h create mode 100644 arch/arm/mach-samsung/include/mach/s3c24xx-clocks.h create mode 100644 arch/arm/mach-samsung/include/mach/s3c24xx-iomap.h create mode 100644 arch/arm/mach-samsung/include/mach/s5pcxx-clocks.h create mode 100644 arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h delete mode 100644 arch/arm/mach-samsung/lowlevel-init.S create mode 100644 arch/arm/mach-samsung/lowlevel-s3c24x0.S create mode 100644 arch/arm/mach-samsung/lowlevel-s5pcxx.c create mode 100644 arch/arm/mach-samsung/mem-s3c24x0.c create mode 100644 arch/arm/mach-samsung/mem-s5pcxx.c create mode 100644 scripts/s5p_cksum.c -- 1.7.10 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[RFC] ramfs: rember last accessed chunk
Writing big files takes longer and longer because of the chunk list By storing a pointer of the recent used chunk in the inode, access times are improved. Testet on with tftp 10M: OMAP4 chunk size 4096: 12244ms 8192: 4239ms patched2647ms2785ms i.MX35 chunk size 8192: 7225ms patched 2691ms No impact on much smaller files seen Signed-off-by: Jan Weitzel --- fs/ramfs.c | 46 -- 1 files changed, 36 insertions(+), 10 deletions(-) diff --git a/fs/ramfs.c b/fs/ramfs.c index 83ab6df..5c7410b 100644 --- a/fs/ramfs.c +++ b/fs/ramfs.c @@ -48,6 +48,10 @@ struct ramfs_inode { ulong size; struct ramfs_chunk *data; + + /* Points to recently used chunk */ + int recent_chunk; + struct ramfs_chunk *recent_chunkp; }; struct ramfs_priv { @@ -297,6 +301,34 @@ static int ramfs_close(struct device_d *dev, FILE *f) return 0; } +static struct ramfs_chunk *ramfs_find_chunk(struct ramfs_inode *node, int chunk) +{ + struct ramfs_chunk *data; + int left = chunk; + + if (chunk == 0) + return node->data; + + if (node->recent_chunk == chunk) + return node->recent_chunkp; + + if (node->recent_chunk < chunk && node->recent_chunk != 0) { + /* Start at last known chunk */ + data = node->recent_chunkp; + left -= node->recent_chunk; + } else + /* Start at first chunk */ + data = node->data; + + while (left--) + data = data->next; + + node->recent_chunkp = data; + node->recent_chunk = chunk; + + return data; +} + static int ramfs_read(struct device_d *_dev, FILE *f, void *buf, size_t insize) { struct ramfs_inode *node = (struct ramfs_inode *)f->inode; @@ -311,11 +343,7 @@ static int ramfs_read(struct device_d *_dev, FILE *f, void *buf, size_t insize) debug("%s: reading from chunk %d\n", __FUNCTION__, chunk); /* Position ourself in stream */ - data = node->data; - while (chunk) { - data = data->next; - chunk--; - } + data = ramfs_find_chunk(node, chunk); ofs = f->pos % CHUNK_SIZE; /* Read till end of current chunk */ @@ -364,11 +392,7 @@ static int ramfs_write(struct device_d *_dev, FILE *f, const void *buf, size_t i debug("%s: writing to chunk %d\n", __FUNCTION__, chunk); /* Position ourself in stream */ - data = node->data; - while (chunk) { - data = data->next; - chunk--; - } + data = ramfs_find_chunk(node, chunk); ofs = f->pos % CHUNK_SIZE; /* Write till end of current chunk */ @@ -429,6 +453,8 @@ static int ramfs_truncate(struct device_d *dev, FILE *f, ulong size) ramfs_put_chunk(data); data = tmp; } + if (node->recent_chunk > newchunks) + node->recent_chunk = 0; } if (newchunks > oldchunks) { -- 1.7.0.4 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Add magicvar description for flexible bootargs
Sascha Hauer (2): magicvar: Add magicvar macro with additional name argument flexible bootargs: Add magicvar descriptions common/bootargs.c |4 include/magicvar.h |8 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 1/2] magicvar: Add magicvar macro with additional name argument
Currently magicvar fails on variables containing a '.' because we can't use these as C names. Overcome this by adding a new macro which allows to specify a name seperately. Signed-off-by: Sascha Hauer --- include/magicvar.h |8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/magicvar.h b/include/magicvar.h index d27a2e3..bb5bd25 100644 --- a/include/magicvar.h +++ b/include/magicvar.h @@ -18,14 +18,18 @@ extern struct magicvar __barebox_magicvar_end; #endif #ifdef CONFIG_CMD_MAGICVAR -#define BAREBOX_MAGICVAR(_name, _description) \ +#define BAREBOX_MAGICVAR_NAMED(_name, _varname, _description) \ extern const struct magicvar __barebox_magicvar_##_name; \ const struct magicvar __barebox_magicvar_##_name \ __attribute__ ((unused,section (".barebox_magicvar_" __stringify(_name = { \ -.name = #_name, \ +.name = #_varname,\ .description = MAGICVAR_DESCRIPTION(_description), \ }; + +#define BAREBOX_MAGICVAR(_name, _description) \ + BAREBOX_MAGICVAR_NAMED(_name, _name, _description) #else +#define BAREBOX_MAGICVAR_NAMED(_name, _varname, _description) #define BAREBOX_MAGICVAR(_name, _description) #endif -- 1.7.10 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 2/2] flexible bootargs: Add magicvar descriptions
Signed-off-by: Sascha Hauer --- common/bootargs.c |4 1 file changed, 4 insertions(+) diff --git a/common/bootargs.c b/common/bootargs.c index b17e6d1..60e936d 100644 --- a/common/bootargs.c +++ b/common/bootargs.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -77,3 +78,6 @@ int linux_bootargs_overwrite(const char *bootargs) return 0; } + +BAREBOX_MAGICVAR_NAMED(global_linux_bootargs_, global.linux.bootargs.*, "Linux bootargs variables"); +BAREBOX_MAGICVAR_NAMED(global_linux_mtdparts_, global.linux.mtdparts.*, "Linux mtdparts variables"); -- 1.7.10 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox