U-Boot
Threads by month
- ----- 2025 -----
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2000 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
March 2013
- 176 participants
- 559 discussions
Hi,
I've got a NAS which uses uboot:
U-Boot 1.1.4 (Feb 6 2012 - 14:40:46) Marvell version: 3.4.27
It's a Netgear ReadyNAS Duo V2, and the original sofware sucks. ;)
I would like to start with the original kernel (because it contains some
patches) and a custom debian made with multistrap.
Where do I start?
I'll add some information about the config.
I believe these are the most important boot options.
standalone=fsload 0x2000000 $(image_name);setenv bootargs $(console)
root=/dev/mtdblock0 rw ip=$(ipaddr):$(serverip)$(bootargs_end)
$(mvPhoneConfig); bootm 0x2000000;
bootcmd=nand read.e 0x1200000 0x200000 0x600000;nand read.e 0x2000000
0x800000 0x1000000;bootm 0x1200000 0x2000000
bootargs=console=ttyS0,115200 reason=normal
mtdparts=nand_mtd:0x180000@0(u-boot),0x20000@0x180000(u-boot-env),0x600000@0x200000(uImage),0x1000000@0x800000(minirootfs),0x6800000@0x1800000(jffs2);
there are 5 mtds:
1,5M mtd0 - ?
128K mtd1 - ?
6,0M mtd2 - kernel
2,2M mtd3 - initrd (gzipped)
89M mtd4 - jffs2 image, I think it contains a rescue image of the
filesystem which is applied to the harddisks.
I dumped the kernel from mtd2, it is:
u-boot legacy uImage, Linux-2.6.31.8.duov2, Linux/ARM, OS Kernel Image
(Not compressed), 3442208 bytes, Tue Aug 28 05:21:43 2012, Load Address:
0x00008000, Entry Point: 0x00008000, Header CRC: 0xDA1ECA31, Data CRC:
0x269C27DE
I tried to load the kernel through tftp, but it crashed:
Marvell>> dhcp
BOOTP broadcast 1
*** Unhandled DHCP Option in OFFER/ACK: 28
*** Unhandled DHCP Option in OFFER/ACK: 28
DHCP client bound to address 192.168.20.35
Marvell>> set serverip 192.168.20.24
Marvell>> tftpboot 0x02000000 /boot/kernel.img
Using egiga0 device
TFTP from server 192.168.20.24; our IP address is 192.168.20.35
Filename '/boot/kernel.img'.
Load address: 0x2000000
Loading: #################################################################
...
done
Bytes transferred = 3442272 (348660 hex)
Marvell>> go 0x02000000
## Starting application at 0x02000000 ...
software interrupt
pc : [<0200001c>] lr : [<00633cac>]
sp : 005fef68 ip : ffffffff fp : 005ff7de
r10: 005ff3de r9 : ffffe804 r8 : 005fffcc
r7 : 005ff388 r6 : 00000001 r5 : 005ff38c r4 : 02000000
r3 : 30383101 r2 : f1012000 r1 : 005ff38c r0 : c0c0e0c4
Flags: nZCv IRQs off FIQs off Mode SVC_32
Resetting CPU ...
thanks for any help,
JPT
4
7

[U-Boot] [PATCH] dfu:mmc: When doing block operations, operate on the given length
by Tom Rini 08 Mar '13
by Tom Rini 08 Mar '13
08 Mar '13
When working on RAW partitions, it's possible that the whole area
is larger than DDR. So what we need to do is make sure that the length
we are given is aligned with the LBA block size, then pass that length
in as our count of LBA blocks to operate on. In doing this, we no
longer need to modify *len on read operations.
Cc: Lukasz Majewski <l.majewski(a)samsung.com>
Signed-off-by: Tom Rini <trini(a)ti.com>
---
drivers/dfu/dfu_mmc.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c
index 083d745..0bed405 100644
--- a/drivers/dfu/dfu_mmc.c
+++ b/drivers/dfu/dfu_mmc.c
@@ -34,14 +34,21 @@ static int mmc_block_op(enum dfu_mmc_op op, struct dfu_entity *dfu,
{
char cmd_buf[DFU_CMD_BUF_SIZE];
- sprintf(cmd_buf, "mmc %s 0x%x %x %x",
- op == DFU_OP_READ ? "read" : "write",
- (unsigned int) buf,
- dfu->data.mmc.lba_start,
- dfu->data.mmc.lba_size);
+ /*
+ * We must ensure that we read in lba_blk_size chunks, so ALIGN
+ * this value.
+ */
+ *len = ALIGN(*len, dfu->data.mmc.lba_blk_size);
+
+ if (*len > (dfu->data.mmc.lba_size * dfu->data.mmc.lba_blk_size)) {
+ puts("Request would exceed designated area!\n");
+ return -EINVAL;
+ }
- if (op == DFU_OP_READ)
- *len = dfu->data.mmc.lba_blk_size * dfu->data.mmc.lba_size;
+ sprintf(cmd_buf, "mmc %s 0x%x %x %lx",
+ op == DFU_OP_READ ? "read" : "write",
+ (unsigned int) buf, dfu->data.mmc.lba_start,
+ *len / dfu->data.mmc.lba_blk_size);
debug("%s: %s 0x%p\n", __func__, cmd_buf, cmd_buf);
return run_command(cmd_buf, 0);
--
1.7.9.5
3
5

08 Mar '13
Hi simon,
>+ Albert, Tom who might know about this
>
>Hi Akshay,
>
>On Wed, Mar 6, 2013 at 7:36 AM, Akshay Saraswat <akshay.s(a)samsung.com> wrote:
>> Hi Simon,
>>
>>>Hi Akshay,
>>>
>>>On Tue, Mar 5, 2013 at 2:53 AM, Akshay Saraswat <akshay.s(a)samsung.com> wrote:
>>>> This patch subtracts a part of clock init from spl
>>>> and executes it after relocation. spl_clock_init
>>>> executes in spl and system_clock_init executes after
>>>> relocation in u-boot. This is done to gain some space by
>>>> removing initially not necessary code.
>>>>
>>>> Signed-off-by: Akshay Saraswat <akshay.s(a)samsung.com>
>>>> ---
>>>
>>>Looks good - just one question below.
>>>
>>>> Changes since v1:
>>>> - Rebased on ToT.
>>>>
>>>> board/samsung/smdk5250/Makefile | 3 +-
>>>> board/samsung/smdk5250/clock_init.c | 429 +----------------------------
>>>> board/samsung/smdk5250/clock_init.h | 2 +
>>>> board/samsung/smdk5250/lowlevel_init.S | 4 +-
>>>> board/samsung/smdk5250/setup.h | 1 +
>>>> board/samsung/smdk5250/smdk5250.c | 4 +
>>>> board/samsung/smdk5250/spl_clock_init.c | 469 ++++++++++++++++++++++++++++++++
>>>> 7 files changed, 482 insertions(+), 430 deletions(-)
>>>> create mode 100644 board/samsung/smdk5250/spl_clock_init.c
>>>>
>>>> diff --git a/board/samsung/smdk5250/Makefile b/board/samsung/smdk5250/Makefile
>>>> index 47c6a5a..3ceb7e2 100644
>>>> --- a/board/samsung/smdk5250/Makefile
>>>> +++ b/board/samsung/smdk5250/Makefile
>>>> @@ -26,12 +26,13 @@ LIB = $(obj)lib$(BOARD).o
>>>>
>>>> SOBJS := lowlevel_init.o
>>>>
>>>> -COBJS := clock_init.o
>>>> +COBJS := spl_clock_init.o
>>>
>>>Shouldn't this only be included in the SPL build?
>>
>> I tried to do that but, since other files are using some of the data
>> defined in this file, we need it in u-boot as well. Please tell me if
>> it's required I'll make another file for common data.
>
>Are you saying that U-Boot proper is using the same data as SPL? I'm
>not sure, but I believe that we should not access SPL data from
>U-Boot, since they should be setting up separate things. Can you
>please be more specific about what is being shared?
>
Sorry, misunderstood the compiler errors. Actually data is not shared in spl and u-boot,
but in the Makefile if I keep all the spl related files in "ifdef CONFIG_SPL_BUILD"
lowlevel_init.s is not able to find tzpc, dmc and clock init function definitions.
And if I keep lowlevel init as well in "ifdef CONFIG_SPL_BUILD", start.o is not able to
find function definitions in lowlevel_init.s. In the next version of this patch-set, I'll fix it.
>
>>
>>>
>>>> COBJS += dmc_common.o dmc_init_ddr3.o
>>>> COBJS += tzpc_init.o
>>>> COBJS += smdk5250_spl.o
>>>>
>>>> ifndef CONFIG_SPL_BUILD
>>>> +COBJS += clock_init.o
>>>> COBJS += smdk5250.o
>>>> endif
>>>>
>>>...
>
>Regards,
>Simon
>
Regards,
Akshay Saraswat
1
0

08 Mar '13
+U-Boot et al
Hi,
On Thu, Mar 7, 2013 at 2:35 AM, Adnan Ali <adnan.ali(a)codethink.co.uk> wrote:
> Introduces btrfs file-system to read file
> from volume/sub-volumes with btrload command. This
> implementation has read-only support.
> This btrfs implementation is based on syslinux btrfs
> code, commit 269ebc845ebc8b46ef4b0be7fa0005c7fdb95b8d.
Here are some comments, hope it helps.
>
> v4: btrls command added.
> v3: patch re-formated.
> v2: patch error removed.
>
> Signed-off-by: Adnan Ali <adnan.ali(a)codethink.co.uk>
> ---
> Makefile | 1 +
> common/Makefile | 1 +
> common/cmd_btr.c | 65 +++
> fs/btrfs/Makefile | 51 ++
> fs/btrfs/btrfs.c | 1209 ++++++++++++++++++++++++++++++++++++++++++++
> fs/btrfs/crc32_c.c | 54 ++
> fs/fs.c | 86 +++-
> include/btrfs.h | 391 ++++++++++++++
> include/config_fallbacks.h | 4 +
> include/fs.h | 1 +
> 10 files changed, 1860 insertions(+), 3 deletions(-)
> create mode 100644 common/cmd_btr.c
> create mode 100644 fs/btrfs/Makefile
> create mode 100644 fs/btrfs/btrfs.c
> create mode 100644 fs/btrfs/crc32_c.c
> create mode 100644 include/btrfs.h
>
> diff --git a/Makefile b/Makefile
> index 3305e8c..cc35e7b 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -261,6 +261,7 @@ endif
> LIBS-$(CONFIG_OF_EMBED) += dts/libdts.o
> LIBS-y += arch/$(ARCH)/lib/lib$(ARCH).o
> LIBS-y += fs/libfs.o \
> + fs/btrfs/libbtrfs.o \
> fs/cbfs/libcbfs.o \
> fs/cramfs/libcramfs.o \
> fs/ext4/libext4fs.o \
> diff --git a/common/Makefile b/common/Makefile
> index 54fcc81..093dd35 100644
> --- a/common/Makefile
> +++ b/common/Makefile
> @@ -73,6 +73,7 @@ COBJS-$(CONFIG_CMD_BEDBUG) += bedbug.o cmd_bedbug.o
> COBJS-$(CONFIG_CMD_BMP) += cmd_bmp.o
> COBJS-$(CONFIG_CMD_BOOTLDR) += cmd_bootldr.o
> COBJS-$(CONFIG_CMD_BOOTSTAGE) += cmd_bootstage.o
> +COBJS-$(CONFIG_CMD_BTR) += cmd_btr.o
I actually wonder if you should avoid adding a new command and just
use the generic 'load' and 'fs' commands instead?
> COBJS-$(CONFIG_CMD_CACHE) += cmd_cache.o
> COBJS-$(CONFIG_CMD_CBFS) += cmd_cbfs.o
> COBJS-$(CONFIG_CMD_CONSOLE) += cmd_console.o
> diff --git a/common/cmd_btr.c b/common/cmd_btr.c
> new file mode 100644
> index 0000000..387e846
> --- /dev/null
> +++ b/common/cmd_btr.c
> @@ -0,0 +1,65 @@
> +/*
> + * (C) Copyright 2013 Codethink Limited
> + * Btrfs port to Uboot by
> + * Adnan Ali <adnan.ali(a)codethink.co.uk>
> + * 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
> + */
> +
> +/*
> + * Boot support
> + */
> +#include <fs.h>
> +#include <btrfs.h>
> +
> +char subvolname[MAX_SUBVOL_NAME];
> +
> +int do_btr_fsload(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> +{
> + if (argc > 5)
> + strcpy(subvolname, argv[5]);
> + else
> + strcpy(subvolname, "");
This seems a bit odd. Where does subvolname go within U-Boot?
> +
> + return do_load(cmdtp, flag, argc, argv, FS_TYPE_BTR, 16);
> +}
> +
> +
> +U_BOOT_CMD(
> + btrload, 7, 0, do_btr_fsload,
> + "load binary file from a btr filesystem",
> + "<interface> [<dev[:part]>] <addr> <filename> [subvol_name]\n"
> + " - Load binary file 'filename' from 'dev' on 'interface'\n"
> + " to address 'addr' from better filesystem.\n"
> + " the load stops on end of file.\n"
> + " subvol_name is used read that file from this subvolume.\n"
> + " All numeric parameters are assumed to be hex."
With the 'load' command we have bytes and pos as two extra arguments.
I think your subvol argument should be done another way.
I wonder if it should be '-s <subvol name>' before the arguments?
> +);
> +
> +static int do_btr_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> +{
> + return do_ls(cmdtp, flag, argc, argv, FS_TYPE_BTR);
> +}
> +
> +U_BOOT_CMD(
> + btrls, 4, 1, do_btr_ls,
> + "list files in a directory (default /)",
> + "<interface> [<dev[:part]>] [directory]\n"
> + " - list files from 'dev' on 'interface' in a 'directory'"
> +);
> +
> diff --git a/fs/btrfs/Makefile b/fs/btrfs/Makefile
> new file mode 100644
> index 0000000..0dd469c
> --- /dev/null
> +++ b/fs/btrfs/Makefile
> @@ -0,0 +1,51 @@
> +#
> +# (C) Copyright 2006
> +# Wolfgang Denk, DENX Software Engineering, wd(a)denx.de.
> +#
> +# (C) Copyright 2003
> +# Pavel Bartusek, Sysgo Real-Time Solutions AG, pba(a)sysgo.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)libbtrfs.o
> +
> +AOBJS =
> +COBJS-$(CONFIG_FS_BTR) := crc32_c.o btrfs.o
> +
> +SRCS := $(AOBJS:.o=.S) $(COBJS-y:.o=.c)
> +OBJS := $(addprefix $(obj),$(AOBJS) $(COBJS-y))
> +
> +
> +all: $(LIB) $(AOBJS)
> +
> +$(LIB): $(obj).depend $(OBJS)
> + $(call cmd_link_o_target, $(OBJS))
> +
> +#########################################################################
> +
> +# defines $(obj).depend target
> +include $(SRCTREE)/rules.mk
> +
> +sinclude $(obj).depend
> +
> +#########################################################################
> diff --git a/fs/btrfs/btrfs.c b/fs/btrfs/btrfs.c
> new file mode 100644
> index 0000000..84a72f4
> --- /dev/null
> +++ b/fs/btrfs/btrfs.c
> @@ -0,0 +1,1209 @@
> +/*
> + * (C) Copyright 2013 Codethink Limited
> + * Btrfs port to Uboot by
> + * Adnan Ali <adnan.ali(a)codethink.co.uk>
> +
> + * btrfs.c -- readonly btrfs support for syslinux
> + * Some data structures are derivated from btrfs-tools-0.19 ctree.h
> + * Copyright 2009 Intel Corporation; author: alek.du(a)intel.com
> + *
> + * 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, Inc., 53 Temple Place Ste 330,
> + * Boston MA 02111-1307, USA; either version 2 of the License, or
> + * (at your option) any later version; incorporated herein by reference.
> + *
> + */
> +
> +#include <linux/stat.h>
> +#include <command.h>
> +#include <asm/byteorder.h>
> +#include <linux/compiler.h>
> +#include <common.h>
> +#include <config.h>
> +#include <fs.h>
> +#include <btrfs.h>
> +#include <linux/ctype.h>
Should put:
common first
then U-Boot ones, in alpha order
then asm
then linux
> +
> +unsigned long btr_part_offset;
> +/* Actual file structures (we don't have malloc yet...) */
> +struct file files[MAX_OPEN];
> +static u32 btrfs_crc32_table[256];
> +static block_dev_desc_t *btrfs_block_dev_desc;
> +static disk_partition_t *part_info;
> +struct inode parent_inode;
> +extern char subvolname[MAX_SUBVOL_NAME];
> +
> +static void btrfs_init_crc32c(void)
> +{
> + /* Bit-reflected CRC32C polynomial */
> + crc32c_init(btrfs_crc32_table, 0x82F63B78);
> +}
> +
> +static inline u32 crc32c_le(u32 crc, const char *data, size_t length)
> +{
> + return crc32c_cal(crc, data, length, btrfs_crc32_table);
> +}
> +
> +void btrfs_set_blk_dev(block_dev_desc_t *rbdd, disk_partition_t *info)
> +{
> + btrfs_block_dev_desc = rbdd;
> + part_info = info;
> + btr_part_offset = info->start;
> +}
> +
> +void btrfs_type(char num)
> +{
> +
> + switch(num)
> + {
> + case 1: printf("<FILE> "); break;
> + case 2: printf("<DIR> "); break;
> + case 7: printf("<SYM> "); break;
Spaces? Can we have enums/#define for these numbers?
> + default: printf("<UNKNOWN>"); break;
> + }
> +
Remove blank line
> +}
> +
> +/* compare function used for bin_search */
> +typedef int (*cmp_func)(void *ptr1, void *ptr2);
> +
> +static int bin_search(void *ptr, int item_size, void *cmp_item, cmp_func func,
> + int min, int max, int *slot)
> +{
> + int low = min;
> + int high = max;
> + int mid;
> + int ret;
> + unsigned long offset;
> + void *item;
> +
> + while (low < high) {
> + mid = (low + high) / 2;
> + offset = mid * item_size;
> +
> + item = ptr + offset;
> + ret = func(item, cmp_item);
> +
> + if (ret < 0)
> + low = mid + 1;
> + else if (ret > 0)
> + high = mid;
> + else {
> + *slot = mid;
> + return 0;
> + }
> + }
> + *slot = low;
> + return 1;
> +}
> +
Perhaps put this function in a new lib/bsearch.c file?
> +/* XXX: these should go into the filesystem instance structure */
> +static struct btrfs_chunk_map chunk_map;
> +static struct btrfs_super_block sb;
> +static u64 fs_tree;
> +
> +static int btrfs_comp_chunk_map(struct btrfs_chunk_map_item *m1,
> + struct btrfs_chunk_map_item *m2)
This function could do with a comment.
> +{
> + if (__le64_to_cpu(m1->logical) > __le64_to_cpu(m2->logical))
> + return 1;
> + if (__le64_to_cpu(m1->logical) < __le64_to_cpu(m2->logical))
> + return -1;
> + return 0;
> +}
> +
> +/* insert a new chunk mapping item */
> +static void insert_map(struct btrfs_chunk_map_item *item)
> +{
> + int ret;
> + int slot;
> + int i;
> +
> + if (chunk_map.map == NULL) { /* first item */
> + chunk_map.map_length = BTRFS_MAX_CHUNK_ENTRIES;
> + chunk_map.map = (struct btrfs_chunk_map_item *)
> + malloc(chunk_map.map_length * sizeof(*chunk_map.map));
> + chunk_map.map[0] = *item;
> + chunk_map.cur_length = 1;
> + return;
> + }
> + ret = bin_search(chunk_map.map, sizeof(*item), item,
> + (cmp_func)btrfs_comp_chunk_map, 0,
> + chunk_map.cur_length, &slot);
> + if (ret == 0)/* already in map */
> + return;
> + if (chunk_map.cur_length == BTRFS_MAX_CHUNK_ENTRIES) {
> + /* should be impossible */
> + printf("too many chunk items\n");
> + return;
Should be error return code here, right?
> + }
> + for (i = chunk_map.cur_length; i > slot; i--)
> + chunk_map.map[i] = chunk_map.map[i-1];
> + chunk_map.map[slot] = *item;
> + chunk_map.cur_length++;
> +}
> +
> +/*
> + * from sys_chunk_array or chunk_tree, we can convert a logical address to
> + * a physical address we can not support multi device case yet
> + */
> +static u64 logical_physical(u64 logical)
u64 but below you return -1. Is this an error code? I suggest you
fully comment your non-trivial functions with @arg, @return, etc.
> +{
> + struct btrfs_chunk_map_item item;
> + int slot, ret;
> +
> + item.logical = logical;
> + ret = bin_search(chunk_map.map, sizeof(*chunk_map.map), &item,
> + (cmp_func)btrfs_comp_chunk_map, 0,
> + chunk_map.cur_length, &slot);
> + if (ret == 0)
> + slot++;
> + else if (slot == 0)
> + return -1;
> + if (logical >=
> + chunk_map.map[slot-1].logical + chunk_map.map[slot-1].length)
> + return -1;
> + return chunk_map.map[slot-1].physical + logical -
> + chunk_map.map[slot-1].logical;
> +}
> +
> +int btrfs_devread(int sector, int byte_offset, int byte_len, char* buf)
> +{
> + ALLOC_CACHE_ALIGN_BUFFER(char, sec_buf, SECTOR_SIZE);
> + unsigned block_len;
> +
> + /* Get the read to the beginning of a partition */
> + sector += byte_offset >> SECTOR_BITS;
> + byte_offset &= SECTOR_SIZE - 1;
> +
> + if (btrfs_block_dev_desc == NULL) {
> + printf("** Invalid Block Device Descriptor (NULL)\n");
> + return 0;
> + }
> + if (byte_offset != 0) {
> + /* read first part which isn't aligned with start of sector */
> + if (btrfs_block_dev_desc->
> + block_read(btrfs_block_dev_desc->dev,
> + part_info->start + sector, 1,
> + (unsigned long *) sec_buf) != 1) {
> + printf(" ** btrfs_devread() read error **\n");
> + return 0;
> + }
> + memcpy(buf, sec_buf + byte_offset,
> + min(SECTOR_SIZE - byte_offset, byte_len));
> + buf += min(SECTOR_SIZE - byte_offset, byte_len);
> + byte_len -= min(SECTOR_SIZE - byte_offset, byte_len);
> + sector++;
> + }
> + /* read sector aligned part */
> +
> + block_len = byte_len & ~(SECTOR_SIZE - 1);
> +
> + if (block_len == 0) {
> + ALLOC_CACHE_ALIGN_BUFFER(u8, p, SECTOR_SIZE);
> +
> + block_len = SECTOR_SIZE;
> + btrfs_block_dev_desc->block_read(btrfs_block_dev_desc->dev,
> + part_info->start + sector,
> + 1, (unsigned long *)p);
> + memcpy(buf, p, byte_len);
> + return 1;
> + }
> + ALLOC_CACHE_ALIGN_BUFFER(u8, t, block_len);
> + if (btrfs_block_dev_desc->block_read(btrfs_block_dev_desc->dev,
> + part_info->start + sector,
> + block_len / SECTOR_SIZE,
> + (unsigned long *) t) !=
> + block_len / SECTOR_SIZE) {
> + printf(" ** %s read error - block\n", __func__);
> + return 0;
> + }
> +
> + memcpy(buf, t, block_len);
> + block_len = byte_len & ~(SECTOR_SIZE - 1);
> + buf += block_len;
> + byte_len -= block_len;
> + sector += block_len / SECTOR_SIZE;
> + if (byte_len != 0) {
> + /* read rest of data which are not in whole sector */
> + if (btrfs_block_dev_desc->
> + block_read(btrfs_block_dev_desc->dev,
> + part_info->start + sector, 1,
> + (unsigned long *) sec_buf) != 1) {
> + printf("* %s read error - last part\n", __func__);
> + return 0;
> + }
> + memcpy(buf, sec_buf, byte_len);
> + }
> +
> +
> + return 1;
So this function returns 1 if OK? I t might be better to return 0 if
ok, -ve on error. There is an errno.h file also if you want to use it.
> +}
> +/* btrfs has several super block mirrors, need to calculate their location */
> +static inline u64 btrfs_sb_offset(int mirror)
> +{
> + u64 start = 16 * 1024;
blank line here
> + if (mirror)
> + return start << (BTRFS_SUPER_MIRROR_SHIFT * mirror);
> + return BTRFS_SUPER_INFO_OFFSET;
> +}
> +
> +/* find the most recent super block */
> +static int btrfs_read_super_block(struct fs_info *fs)
> +{
> + int i;
> + int ret;
> + u8 fsid[BTRFS_FSID_SIZE];
> + u8 boots[512];
Does this need to be cache-aligned?
> + u64 offset;
> + u64 transid = 0;
> + struct btrfs_super_block buf;
> +
> + sb.total_bytes = ~0; /* Unknown as of yet */
> +
> + /*Only first header is checked for filesystem verification
> + mirror of this header can be used if required*/
> + offset = btrfs_sb_offset(0);
> +
> + if ( btrfs_devread(128, 0, sizeof(struct btrfs_super_block), (char*)&buf)!=1)
> + return -1;
> +
Extra blank line - actually you should check with patman/checkpatch I think.
> +
> + if (buf.bytenr != offset ||
> + strncmp((char *)(&buf.magic), BTRFS_MAGIC, sizeof(buf.magic)))
> + {
> + return -1;
> + }
Don't need {}
> +
> + if (i == 0)
> + memcpy(fsid, buf.fsid, sizeof(fsid));
> + else if (memcmp(fsid, buf.fsid, sizeof(fsid)))
> + return -1;
If this is an error then it's nice to add
debug("%s: Failed to whatever you failed to do...", __func__);
in these cases. In general it's nice to avoid printf() in drivers I think.
> +
> + if (buf.generation > transid) {
> + memcpy(&sb, &buf, sizeof(sb));
> + transid = buf.generation;
> + }
> + return 0;
> +}
> +
> +static inline unsigned long btrfs_chunk_item_size(int num_stripes)
> +{
> + return sizeof(struct btrfs_chunk) +
> + sizeof(struct btrfs_stripe) * (num_stripes - 1);
> +}
> +
> +static void clear_path(struct btrfs_path *path)
> +{
> + memset(path, 0, sizeof(*path));
> +}
> +
> +static int btrfs_comp_keys(struct btrfs_disk_key *k1, struct btrfs_disk_key *k2)
> +{
> + if (k1->objectid > k2->objectid)
> + return 1;
> + if (k1->objectid < k2->objectid)
> + return -1;
> + if (k1->type > k2->type)
> + return 1;
> + if (k1->type < k2->type)
> + return -1;
> + if (k1->offset > k2->offset)
> + return 1;
> + if (k1->offset < k2->offset)
> + return -1;
> + return 0;
> +}
> +
> +/* compare keys but ignore offset, is useful to enumerate all same kind keys */
> +static int btrfs_comp_keys_type(struct btrfs_disk_key *k1,
> + struct btrfs_disk_key *k2)
> +{
> + if (k1->objectid > k2->objectid)
> + return 1;
> + if (k1->objectid < k2->objectid)
> + return -1;
> + if (k1->type > k2->type)
> + return 1;
> + if (k1->type < k2->type)
> + return -1;
> + return 0;
> +}
> +
> +/* seach tree directly on disk ... */
> +static int search_tree(struct fs_info *fs, u64 loffset,
> + struct btrfs_disk_key *key, struct btrfs_path *path)
> +{
> + u8 buf[BTRFS_MAX_LEAF_SIZE];
> + struct btrfs_header *header = (struct btrfs_header *)buf;
> + struct btrfs_node *node = (struct btrfs_node *)buf;
> + struct btrfs_leaf *leaf = (struct btrfs_leaf *)buf;
> + int slot, ret;
> + u64 offset;
> +
> + offset = logical_physical(loffset);
> + btrfs_devread(offset/SECTOR_SIZE, (offset%SECTOR_SIZE), sizeof(*header), (char*)header);
Does this need to be cache-aligned?
> + if (header->level) {/*node*/
> + btrfs_devread(((offset+sizeof(*header))/SECTOR_SIZE),((offset+sizeof(*header))%SECTOR_SIZE) ,
> + __le32_to_cpu(sb.nodesize) - sizeof(*header), (char *)&node->ptrs[0]);
Error check?
> + path->itemsnr[header->level] = header->nritems;
> + path->offsets[header->level] = loffset;
> + ret = bin_search(&node->ptrs[0], sizeof(struct btrfs_key_ptr),
> + key, (cmp_func)btrfs_comp_keys,
> + path->slots[header->level], header->nritems, &slot);
> + if (ret && slot > path->slots[header->level])
> + slot--;
> + path->slots[header->level] = slot;
> + ret = search_tree(fs, node->ptrs[slot].blockptr, key, path);
> + } else {/*leaf*/
> +
> + btrfs_devread(((offset+sizeof(*header))/SECTOR_SIZE), ((offset+sizeof(*header))%SECTOR_SIZE),
> + (sb.leafsize) - sizeof(*header), (char *)&leaf->items);
> + path->itemsnr[header->level] = header->nritems;
> + path->offsets[0] = loffset;
> + ret = bin_search(&leaf->items[0], sizeof(struct btrfs_item),
> + key, (cmp_func)btrfs_comp_keys, path->slots[0],
> + header->nritems, &slot);
> + if (ret && slot > path->slots[header->level])
> + slot--;
> + path->slots[0] = slot;
> + path->item = leaf->items[slot];
> + btrfs_devread(((offset + sizeof(*header) + leaf->items[slot].offset)/SECTOR_SIZE),
> + ((offset + sizeof(*header) + leaf->items[slot].offset)%SECTOR_SIZE),
> + leaf->items[slot].size, (char*)&path->data);
Error check?
> + }
> + return ret;
> +}
> +
> +/* return 0 if leaf found */
> +static int next_leaf(struct fs_info *fs, struct btrfs_disk_key *key, struct btrfs_path *path)
> +{
> + int slot;
> + int level = 1;
> +
> + while (level < BTRFS_MAX_LEVEL) {
> + if (!path->itemsnr[level]) /* no more nodes */
> + return 1;
> + slot = path->slots[level] + 1;
> + if (slot >= path->itemsnr[level]) {
> + level++;
> + continue;;
> + }
> + path->slots[level] = slot;
> + path->slots[level-1] = 0; /* reset low level slots info */
> + search_tree(fs, path->offsets[level], key, path);
> + break;
> + }
> + if (level == BTRFS_MAX_LEVEL)
> + return 1;
BTW it seems pretty common in U-Boot to add a blank line before the return.
> + return 0;
> +}
> +
> +/* return 0 if slot found */
> +static int next_slot(struct fs_info *fs, struct btrfs_disk_key *key, struct btrfs_path *path)
> +{
> + int slot;
> +
> + if (!path->itemsnr[0])
> + return 1;
> + slot = path->slots[0] + 1;
> + if (slot >= path->itemsnr[0])
> + return 1;
> + path->slots[0] = slot;
> + search_tree(fs, path->offsets[0], key, path);
Error check on this call?
> + return 0;
> +}
> +
> +/*
> + * read chunk_array in super block
> + */
> +static void btrfs_read_sys_chunk_array(void)
> +{
> + struct btrfs_chunk_map_item item;
> + struct btrfs_disk_key *key;
> + struct btrfs_chunk *chunk;
> + int cur;
> +
> + /* read chunk array in superblock */
> + cur = 0;
> +
> + while (cur < __le32_to_cpu(sb.sys_chunk_array_size)) {
> + key = (struct btrfs_disk_key *)(sb.sys_chunk_array + cur);
> + cur += sizeof(*key);
> + chunk = (struct btrfs_chunk *)(sb.sys_chunk_array + cur);
> + cur += btrfs_chunk_item_size(chunk->num_stripes);
> + /* insert to mapping table, ignore multi stripes */
> + item.logical = key->offset;
> + item.length = chunk->length;
> + item.devid = chunk->stripe.devid;
> + item.physical = chunk->stripe.offset;/*ignore other stripes */
> +
Another extra line, please fix globally.
> +
> + insert_map(&item);
> + }
> +}
> +
> +/* read chunk items from chunk_tree and insert them to chunk map */
> +static void btrfs_read_chunk_tree(struct fs_info *fs)
Surely this function can fail?
> +{
> + struct btrfs_disk_key search_key;
> + struct btrfs_chunk *chunk;
> + struct btrfs_chunk_map_item item;
> + struct btrfs_path path;
> + int status;
Inconsistent indent here I think. Please fix globally.
> +
> + if (!(__le64_to_cpu(sb.flags) & BTRFS_SUPER_FLAG_METADUMP)) {
> + if (__le64_to_cpu(sb.num_devices) > 1)
> + {
> + printf("warning: only support one btrfs device %d\n",
> + __le64_to_cpu(sb.num_devices));
> + return;
> + }
> + /* read chunk from chunk_tree */
> + search_key.objectid = BTRFS_FIRST_CHUNK_TREE_OBJECTID;
> + search_key.type = BTRFS_CHUNK_ITEM_KEY;
> + search_key.offset = 0;
> + clear_path(&path);
> + search_tree(fs, (sb.chunk_root), &search_key, &path);
> + do {
> + do {
> +
> + if (status=btrfs_comp_keys_type(&search_key,
> + &path.item.key))
> + break;
> + chunk = (struct btrfs_chunk *)(path.data);
> + /* insert to mapping table, ignore stripes */
> + item.logical = path.item.key.offset;
> + item.length = chunk->length;
> + item.devid = chunk->stripe.devid;
> + item.physical = chunk->stripe.offset;
> + insert_map(&item);
> + } while (!next_slot(fs, &search_key, &path));
> + if (btrfs_comp_keys_type(&search_key, &path.item.key))
> + break;
> + } while (!next_leaf(fs, &search_key, &path));
> + }
> +}
> +
> +static inline u64 btrfs_name_hash(const char *name, int len)
> +{
> + return btrfs_crc32c((u32)~1, name, len);
> +}
> +
> +static struct inode *btrfs_iget_by_inr(struct fs_info *fs, u64 inr)
> +{
> + struct inode *inode;
> + struct btrfs_inode_item inode_item;
> + struct btrfs_disk_key search_key;
> + struct btrfs_path path;
> + int ret;
> +
> + /* FIXME: some BTRFS inode member are u64, while our logical inode
> + is u32, we may need change them to u64 later */
Assuming you can't resolve this now, comment style:
/*
* FIXME(your email): ...
* ...
*/
> + search_key.objectid = inr;
> + search_key.type = BTRFS_INODE_ITEM_KEY;
> + search_key.offset = 0;
> + clear_path(&path);
> + ret = search_tree(fs, fs_tree, &search_key, &path);
> + if (ret)
> + {
> + printf("%s search_tree failed\n", __func__);
> + return NULL;
> + }
> +
> + inode_item = *(struct btrfs_inode_item *)path.data;
> + if (!(inode = alloc_inode(fs, inr, sizeof(struct btrfs_pvt_inode))))
> + {
> + printf("%s alloc_inode failed\n", __func__);
> + return NULL;
> + }
> + inode->ino = inr;
> + inode->size = inode_item.size;
> + inode->mode = IFTODT(inode_item.mode);
> + if (inode->mode == DT_REG || inode->mode == DT_LNK) {
> + struct btrfs_file_extent_item extent_item;
> + u64 offset;
> +
> + /* get file_extent_item */
> + search_key.type = BTRFS_EXTENT_DATA_KEY;
> + search_key.offset = 0;
> + clear_path(&path);
> + ret = search_tree(fs, fs_tree, &search_key, &path);
> + if (ret)
> + return NULL; /* impossible */
> + extent_item = *(struct btrfs_file_extent_item *)path.data;
> + if (extent_item.type == BTRFS_FILE_EXTENT_INLINE)/* inline file */
Space between ) and /*
> + offset = path.offsets[0] + sizeof(struct btrfs_header)
> + + path.item.offset
> + + offsetof(struct btrfs_file_extent_item, disk_bytenr);
> + else
> + offset = extent_item.disk_bytenr;
> + PVT(inode)->offset = offset;
> + }
> + return inode;
> +}
> +
> +static struct inode *btrfs_iget_root(struct fs_info *fs)
> +{
> + /* BTRFS_FIRST_CHUNK_TREE_OBJECTID(256) actually is first OBJECTID for FS_TREE */
> + return btrfs_iget_by_inr(fs, BTRFS_FIRST_CHUNK_TREE_OBJECTID);
> +}
> +
> +static struct inode *btrfs_iget(const char *name, struct inode *parent)
> +{
> + struct fs_info *fs = parent->fs;
> + struct btrfs_disk_key search_key;
> + struct btrfs_path path;
> + struct btrfs_dir_item dir_item;
> + int ret;
> +
> + search_key.objectid = parent->ino;
> + search_key.type = BTRFS_DIR_ITEM_KEY;
> + search_key.offset = btrfs_name_hash(name, strlen(name));
> + clear_path(&path);
> + ret = search_tree(fs, fs_tree, &search_key, &path);
> + if (ret)
> + return NULL;
> + dir_item = *(struct btrfs_dir_item *)path.data;
> +
> + return btrfs_iget_by_inr(fs, dir_item.location.objectid);
> +}
> +
> +static int btrfs_readlink(struct inode *inode, char *buf)
> +{
> + btrfs_devread((logical_physical(PVT(inode)->offset)/SECTOR_SIZE),
> + (logical_physical(PVT(inode)->offset)%SECTOR_SIZE), inode->size, (char*)buf);
Error check?
> + buf[inode->size] = '\0';
> + return inode->size;
> +}
> +
> +static int btrfs_readdir(struct file *file, struct dirent *dirent)
> +{
> + struct fs_info *fs = file->fs;
> + struct inode *inode = file->inode;
> + struct btrfs_disk_key search_key;
> + struct btrfs_path path;
> + struct btrfs_dir_item *dir_item;
> + int ret;
> +
> + /*
> + * we use file->offset to store last search key.offset, will will search
> + * key that lower that offset, 0 means first search and we will search
> + * -1UL, which is the biggest possible key
> + */
> + search_key.objectid = inode->ino;
> + search_key.type = BTRFS_DIR_ITEM_KEY;
> + search_key.offset = file->offset - 1;
> + clear_path(&path);
> + ret = search_tree(fs, fs_tree, &search_key, &path);
> +
> + if (ret) {
> + if (btrfs_comp_keys_type(&search_key, &path.item.key))
> + return -1;
> + }
> +
> + dir_item = (struct btrfs_dir_item *)path.data;
> + file->offset = path.item.key.offset;
> + dirent->d_ino = dir_item->location.objectid;
> + dirent->d_off = file->offset;
> + dirent->d_reclen = offsetof(struct dirent, d_name)
> + + dir_item->name_len + 1;
> + dirent->d_type = IFTODT(dir_item->type);
> + memcpy(dirent->d_name, dir_item + 1, dir_item->name_len);
> + dirent->d_name[dir_item->name_len] = '\0';
> + btrfs_type(dir_item->type);
> + printf(" %s\n", dirent->d_name);
> +
> + return 0;
> +}
> +
> +static int btrfs_next_extent(struct inode *inode, uint32_t lstart)
> +{
> + struct btrfs_disk_key search_key;
> + struct btrfs_file_extent_item extent_item;
> + struct btrfs_path path;
> + int ret;
> + u64 offset;
> + struct fs_info *fs = inode->fs;
> + u32 sec_shift = SECTOR_BITS;
> + u32 sec_size = SECTOR_SIZE;
> +
> + search_key.objectid = inode->ino;
> + search_key.type = BTRFS_EXTENT_DATA_KEY;
> + search_key.offset = lstart << sec_shift;
> + clear_path(&path);
> + ret = search_tree(fs, fs_tree, &search_key, &path);
> + if (ret) { /* impossible */
> + printf("btrfs: search extent data error\n");
These printf()s should be debug()s I think.
> + return -1;
> + }
> + extent_item = *(struct btrfs_file_extent_item *)path.data;
> +
> + if (extent_item.encryption) {
> + printf("btrfs: found encrypted data, cannot continue\n");
> + return -1;
> + }
> + if (extent_item.compression) {
> + printf("btrfs: found compressed data, cannot continue\n");
> + return -1;
> + }
> +
> + if (extent_item.type == BTRFS_FILE_EXTENT_INLINE) {/* inline file */
> + /* we fake a extent here, and PVT of inode will tell us */
> + offset = path.offsets[0] + sizeof(struct btrfs_header)
> + + path.item.offset
> + + offsetof(struct btrfs_file_extent_item, disk_bytenr);
> + inode->next_extent.len =
> + (inode->size + sec_size -1) >> sec_shift;
> + } else {
> + offset = extent_item.disk_bytenr + extent_item.offset;
> + inode->next_extent.len =
> + (extent_item.num_bytes + sec_size - 1) >> sec_shift;
> + }
> + inode->next_extent.pstart =
> + logical_physical(offset) >> sec_shift;
> + PVT(inode)->offset = offset;
> + return 0;
> +}
> +
> +static uint32_t btrfs_getfssec(struct file *file, char *buf, int sectors,
> + char *have_more)
> +{
> + u32 ret;
> + struct fs_info *fs = file->fs;
> + u32 off = PVT(file->inode)->offset % SECTOR_SIZE;
> + char handle_inline = 0;
> +
> + if (off && !file->offset) {/* inline file first read patch */
> + file->inode->size += off;
> + handle_inline = 1;
> + }
> + ret = generic_getfssec(file, buf, sectors, have_more);
> + if (!ret)
> + return ret;
> + off = PVT(file->inode)->offset % SECTOR_SIZE;
> + if (handle_inline) {/* inline file patch */
> + ret -= off;
> + memcpy(buf, buf + off, ret);
> + }
> + return ret;
> +}
> +
> +static void btrfs_get_fs_tree(struct fs_info *fs)
> +{
> + struct btrfs_disk_key search_key;
> + struct btrfs_path path;
> + struct btrfs_root_item *tree;
> + char subvol_ok = 0;
> +
> + /* check if subvol is filled by installer */
> + if (*subvolname) {
> + search_key.objectid = BTRFS_FS_TREE_OBJECTID;
> + search_key.type = BTRFS_ROOT_REF_KEY;
> + search_key.offset = 0;
> + clear_path(&path);
> + if (search_tree(fs, __le64_to_cpu(sb.root), &search_key, &path))
> + next_slot(fs, &search_key, &path);
> + do {
> + do {
> + struct btrfs_root_ref *ref;
> + int pathlen, status;
> +
> + if (status=btrfs_comp_keys_type(&search_key,
> + &path.item.key))
> + break;
> + ref = (struct btrfs_root_ref *)path.data;
> + pathlen = path.item.size - sizeof(struct btrfs_root_ref);
> + printf("sub_vol found %s\n", (char*)(ref+1));
> + if (!strncmp((char*)(ref + 1), subvolname, pathlen)) {
> + subvol_ok = 1;
> + break;
> + }
> + } while (!next_slot(fs, &search_key, &path));
> + if (subvol_ok)
> + break;
> + if (btrfs_comp_keys_type(&search_key, &path.item.key))
> + break;
> + } while (!next_leaf(fs, &search_key, &path));
This code looks familiar - did you repeat it or something similar above?
> + if (!subvol_ok) /* should be impossible */
> + printf("no subvol found\n");
> + }
> + /* find fs_tree from tree_root */
> + if (subvol_ok)
> + search_key.objectid = path.item.key.offset;
> + else /* "default" volume */
> + search_key.objectid = BTRFS_FS_TREE_OBJECTID;
> + search_key.type = BTRFS_ROOT_ITEM_KEY;
> + search_key.offset =-1;
> + clear_path(&path);
> + search_tree(fs, (sb.root), &search_key, &path);
> + tree = (struct btrfs_root_item *)path.data;
> + fs_tree = tree->bytenr;
> +}
> +
> +/* init. the fs meta data, return the block size shift bits. */
> +int btrfs_fs_init(struct fs_info *fs)
> +{
> +
> + btrfs_init_crc32c();
> + btrfs_read_super_block(fs);
> + if (strncmp((char *)(&sb.magic), BTRFS_MAGIC, sizeof(sb.magic)))
> + return -1;
> +
> + btrfs_read_sys_chunk_array();
> + btrfs_read_chunk_tree(fs);
> + btrfs_get_fs_tree(fs);
> + fs->root = btrfs_iget_root(fs);
> + parent_inode=*(fs->root);
> +
> + return 1;
> +}
> +static inline uint16_t file_to_handle(struct file *file)
> +{
> + return file ? (file - files)+1 : 0;
> +}
> +
> +static inline struct file *handle_to_file(uint16_t handle)
> +{
> + return handle ? &files[handle-1] : NULL;
> +}
> +
> +/*
> + * Free a refcounted inode
> + */
> +void put_inode(struct inode *inode)
> +{
> + while (inode && --inode->refcnt == 0) {
> + struct inode *dead = inode;
> + inode = inode->parent;
> + if (dead->name)
> + free((char *)dead->name);
> + free(dead);
> + }
> +}
> +
> +/*
> + * Get a new inode structure
> + */
> +struct inode *alloc_inode(struct fs_info *fs, uint32_t ino, size_t data)
> +{
> + struct inode *inode = malloc(sizeof(struct inode) + data);
blank line
> + if (inode) {
> + inode->fs = fs;
> + inode->ino = ino;
> + inode->refcnt = 1;
> + }
> + return inode;
> +}
> +
> +/*
> + * Get an empty file structure
> + */
> +static struct file *alloc_file(void)
> +{
> + int i;
> + struct file *file = files;
> +
> + for (i = 0; i < MAX_OPEN; i++) {
> + if (!file->fs)
> + return file;
> + file++;
> + }
> +
> + return NULL;
> +}
> +
> +/*
> + * Close and free a file structure
> + */
> +static inline void free_file(struct file *file)
> +{
> + memset(file, 0, sizeof *file);
> +}
> +
> +void generic_close_file(struct file *file)
> +{
> + if (file->inode) {
> + file->offset = 0;
> + put_inode(file->inode);
> + }
> +}
> +
> +void _close_file(struct file *file)
> +{
> + if (file->fs)
> + generic_close_file(file);
> + free_file(file);
> +}
> +
> +void btrfs_mangle_name(char *dst, const char *src)
Any idea what this function does, please?
> +{
> + char *p = dst,ch,len;
> + int i = FILENAME_MAX-1;
> +
> + len = strlen(src);
> + ch = *src;
> + while (!isspace(ch)) {
> + if (*src == '/') {
> + if (src[1] == '/') {
> + src++;
> + i--;
> + continue;
> + }
> + }
> + if(!len)
> + break;
> + i--;
> + len--;
> + *dst++ = *src++;
> + ch = *src;
> + }
> + while (1) {
> + if (dst == p)
> + break;
> + if (dst[-1] != '/')
> + break;
> + if ((dst[-1] == '/') && ((dst - 1) == p))
> + break;
> +
> + dst--;
> + i++;
> + }
> +
> + i++;
> + for (; i > 0; i --)
> + *dst++ = '\0';
> +
> +}
> +int btrfs_open_file(const char *name, struct com32_filedata *filedata)
> +{
> + int rv;
> + struct file *file;
> + char mangled_name[FILENAME_MAX];
> +
> + btrfs_mangle_name(mangled_name, name);
> + rv = searchdir(mangled_name);
> + if (rv < 0)
> + return rv;
> +
> + file = handle_to_file(rv);
> + filedata->size = file->inode->size;
> + filedata->handle = rv;
> + return rv;
> +}
> +
> +int searchdir(const char *name)
> +{
> + struct inode *inode = NULL;
> + struct inode *parent = &parent_inode;
> + struct file *file;
> + char *pathbuf = NULL;
> + char *part, *p, echar;
> + int symlink_count = MAX_SYMLINK_CNT;
> +
> + if (!(file = alloc_file()))
> + goto err_no_close;
> +
> + p = pathbuf = strdup(name);
> + if (!pathbuf)
> + goto err;
> +
> + do {
> + got_link:
> + if (*p == '/') {
> + put_inode(parent);
> + parent = &parent_inode;// get_inode(this_fs->root);
> + }
> +
> + do {
> + inode = get_inode(parent);
> +
> + while (*p == '/')
> + p++;
> +
> + if (!*p)
> + break;
> +
> + part = p;
> + while ((echar = *p) && echar != '/')
> + p++;
> + *p++ = '\0';
> + if (part[0] == '.' && part[1] == '.' && part[2] == '\0') {
> + if (inode->parent) {
> + put_inode(parent);
> + parent = get_inode(inode->parent);
> + put_inode(inode);
> + inode = NULL;
> + if (!echar) {
> + /* Terminal double dots */
> + inode = parent;
> + parent = inode->parent ?
> + get_inode(inode->parent) : NULL;
> + }
> + }
> + } else if (part[0] != '.' || part[1] != '\0') {
> + inode = btrfs_iget(part, parent);
> + if (!inode)
> + goto err;
> + if (inode->mode == DT_LNK) {
> + char *linkbuf, *q;
> + int name_len = echar ? strlen(p) : 0;
> + int total_len = inode->size + name_len + 2;
> + int link_len;
> +
> + if (/*!this_fs->fs_ops->readlink ||*/
> + --symlink_count == 0 || /* limit check */
> + total_len > MAX_SYMLINK_BUF)
> + goto err;
> +
> + linkbuf = malloc(total_len);
> + if (!linkbuf)
debug()
> + goto err;
> +
> + link_len = btrfs_readlink(inode, linkbuf);
> + if (link_len <= 0) {
> + free(linkbuf);
> + goto err;
> + }
> +
> + q = linkbuf + link_len;
> +
> + if (echar) {
> + if (link_len > 0 && q[-1] != '/')
> + *q++ = '/';
> +
> + memcpy(q, p, name_len+1);
> + } else {
> + *q = '\0';
> + }
> +
> + free(pathbuf);
> + p = pathbuf = linkbuf;
> + put_inode(inode);
> + inode = NULL;
> + goto got_link;
> + }
> +
> + inode->name = strdup(part);
> +
> + inode->parent = parent;
> + parent = NULL;
> +
> + if (!echar)
> + break;
> +
> + if (inode->mode != DT_DIR)
> + goto err;
> +
> + parent = inode;
> + inode = NULL;
> + }
> + } while (echar);
> + } while (0);
> +
> + free(pathbuf);
> + pathbuf = NULL;
> + put_inode(parent);
> + parent = NULL;
> +
> + if (!inode)
> + goto err;
> +
> + file->inode = inode;
> + file->offset = 0;
> + return file_to_handle(file);
> +
> +err:
> + put_inode(inode);
> + put_inode(parent);
> + if (pathbuf)
> + free(pathbuf);
You don't need the if() - U-Boot ignores free(NULL)
> + _close_file(file);
> +err_no_close:
> + return -1;
> +}
> +
> +static void get_next_extent(struct inode *inode)
> +{
> + /* The logical start address that we care about... */
> + uint32_t lstart = inode->this_extent.lstart + inode->this_extent.len;
> +
> + if (btrfs_next_extent(inode, lstart))
> + inode->next_extent.len = 0; /* ERROR */
> + inode->next_extent.lstart = lstart;
> +}
> +
> +int getfssec(struct com32_filedata *filedata, char * buf)
> +{
> + int sectors;
> + char have_more;
> + uint32_t bytes_read;
> + struct file *file;
> + uint16_t handle;
> + if(filedata->size>=512)
> + {
> + sectors = filedata->size/SECTOR_SIZE;
> + sectors += (filedata->size%SECTOR_SIZE)?1:0;
> + }
> + else sectors=2;
> +
> + file = handle_to_file(filedata->handle);
> +
> + bytes_read = btrfs_getfssec(file, buf, sectors, &have_more);
> + if (!have_more) {
> + }
What is intended here?
> + return bytes_read;
> +}
> +
> +uint32_t generic_getfssec(struct file *file, char *buf,
> + int sectors, char *have_more)
> +{
> + struct inode *inode = file->inode;
> + struct fs_info *fs = file->fs;
> + uint32_t bytes_read = 0;
> + uint32_t bytes_left = inode->size - file->offset;
> + uint32_t sectors_left =
> + (bytes_left + SECTOR_SIZE - 1) >> 9;
> + uint32_t lsector;
> +
> + if (sectors > sectors_left)
> + sectors = sectors_left;
> +
> + if (!sectors)
> + return 0;
> +
> + lsector = file->offset >> 9;
> +
> + if (lsector < inode->this_extent.lstart ||
> + lsector >= inode->this_extent.lstart + inode->this_extent.len) {
> + /* inode->this_extent unusable, maybe next_extent is... */
> + inode->this_extent = inode->next_extent;
> + }
> +
> + if (lsector < inode->this_extent.lstart ||
> + lsector >= inode->this_extent.lstart + inode->this_extent.len) {
> + /* Still nothing useful... */
> + inode->this_extent.lstart = lsector;
> + inode->this_extent.len = 0;
> + } else {
> + /* We have some usable information */
> + uint32_t delta = lsector - inode->this_extent.lstart;
> + inode->this_extent.lstart = lsector;
> + inode->this_extent.len -= delta;
> + inode->this_extent.pstart
> + = next_psector(inode->this_extent.pstart, delta);
> + }
> +
> +
> + while (sectors) {
> + uint32_t chunk;
> + size_t len;
> +
> + while (sectors > inode->this_extent.len) {
> + if (!inode->next_extent.len ||
> + inode->next_extent.lstart !=
> + inode->this_extent.lstart + inode->this_extent.len)
> + get_next_extent(inode);
> + if (!inode->this_extent.len) {
> + /* Doesn't matter if it's contiguous... */
> + inode->this_extent = inode->next_extent;
> + if (!inode->next_extent.len) {
> + sectors = 0; /* Failed to get anything... we're dead */
Return some sort of error here?
> + break;
> + }
> + } else if (inode->next_extent.len &&
> + inode->next_extent.pstart == next_pstart(&inode->this_extent)) {
> + /* Coalesce extents and loop */
> + inode->this_extent.len += inode->next_extent.len;
> + } else {
> + /* Discontiguous extents */
> + break;
> + }
> + }
> +
> +
> + chunk = min(sectors, inode->this_extent.len);
> + len = chunk << 9;//SECTOR_SHIFT(fs);
> +
> +
> + if (inode->this_extent.pstart == EXTENT_ZERO) {
> + memset(buf, 0, len);
> + } else {
> + btrfs_block_dev_desc->block_read( btrfs_block_dev_desc->dev,
> + part_info->start+(inode->this_extent.pstart), chunk, buf);
> + inode->this_extent.pstart += chunk;
> + }
> +
> + buf += len;
> + sectors -= chunk;
> + bytes_read += len;
> + inode->this_extent.lstart += chunk;
> + inode->this_extent.len -= chunk;
> + }
> +
> + bytes_read = min(bytes_read, bytes_left);
> + file->offset += bytes_read;
> +
> + if (have_more)
> + *have_more = bytes_read < bytes_left;
> +
> + return bytes_read;
> +}
> +
> +/*
> + * Open a directory
> + */
> +DIR *opendir(const char *path)
> +{
> + int rv;
> + struct file *file;
> + rv = searchdir(path);
> + if (rv < 0)
> + return NULL;
> +
> + file = handle_to_file(rv);
Can this return NULL?
> +
> + if (file->inode->mode != DT_DIR) {
> + _close_file(file);
> + return NULL;
> + }
> + return (DIR *)file;
> +}
> +
> +/*
> + * Read one directory entry at one time
> + */
> +struct dirent *readdir(DIR *dir)
> +{
> + static struct dirent buf;
> + struct file *dd_dir = (struct file *)dir;
> + int rv = -1;
> +
> + if (dd_dir) {
> + rv = btrfs_readdir(dd_dir, &buf);
> + }
> + return rv < 0 ? NULL : &buf;
> +}
> +
> +/*
> + * Show directory entries
> + */
> +char btrfs_ls(char *dirname)
> +{
> + struct dirent *de;
> + DIR *dir;
> +
> + if(*dirname == '/' && *(dirname+1) == 0)
> + *dirname = '.';
> +
> + dir = opendir(dirname);
> + if (dir == NULL)
> + return -1;
> +
> + while ((de = readdir(dir)) != NULL)
> + ;
> +
> + return 0;
> +}
> +
> diff --git a/fs/btrfs/crc32_c.c b/fs/btrfs/crc32_c.c
> new file mode 100644
> index 0000000..78d0447
> --- /dev/null
> +++ b/fs/btrfs/crc32_c.c
> @@ -0,0 +1,54 @@
> +/*
> + * Copied from Linux kernel crypto/crc32c.c
> + * Copyright (c) 2004 Cisco Systems, Inc.
> + * Copyright (c) 2008 Herbert Xu <herbert(a)gondor.apana.org.au>
> + *
> + * 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 is the CRC-32C table
> + * Generated with:
> + * width = 32 bits
> + * poly = 0x1EDC6F41
> + * reflect input bytes = true
> + * reflect output bytes = true
> + */
> +
> +/*
> + * Steps through buffer one byte at at time, calculates reflected
> + * crc using table.
> + */
> +#include <linux/stat.h>
> +#include <command.h>
> +#include <asm/byteorder.h>
> +#include <linux/compiler.h>
> +#include <common.h>
> +#include <config.h>
> +
> +inline u32 crc32c_cal(u32 crc, const char *data, size_t length, u32 *crc32c_table)
> +{
> + while (length--)
> + crc = crc32c_table[(u8)(crc ^ *data++)] ^ (crc >> 8);
> +
> + return crc;
> +}
> +
> +inline void crc32c_init(u32 *crc32c_table, u32 pol)
> +{
> + int i, j;
> + u32 v;
> + const u32 poly = pol; /* Bit-reflected CRC32C polynomial */
> +
> + for (i = 0; i < 256; i++) {
> + v = i;
> + for (j = 0; j < 8; j++) {
> + v = (v >> 1) ^ ((v & 1) ? poly : 0);
> + }
> + crc32c_table[i] = v;
> + }
> +}
> diff --git a/fs/fs.c b/fs/fs.c
> index 023e7ef..c5ca56c 100644
> --- a/fs/fs.c
> +++ b/fs/fs.c
> @@ -20,9 +20,8 @@
> #include <ext4fs.h>
> #include <fat.h>
> #include <fs.h>
> -
> +#include <btrfs.h>
Alpha order for headers
> DECLARE_GLOBAL_DATA_PTR;
> -
Why remove this blank line?
> static block_dev_desc_t *fs_dev_desc;
> static disk_partition_t fs_partition;
> static int fs_type = FS_TYPE_ANY;
> @@ -79,6 +78,74 @@ static inline void fs_close_fat(void)
> #define fs_read_fat fs_read_unsupported
> #endif
>
> +
> +#ifdef CONFIG_FS_BTR
> +struct fs_info fs;
> +static int fs_probe_btr(void)
> +{
> +
> + btrfs_set_blk_dev(fs_dev_desc, &fs_partition);
> +
> + if (btrfs_fs_init(&fs)==-1) {
> + printf("btrfs probe failed\n");
> + return -1;
> + }
> +
> + return 0;
> +}
> +
> +static void fs_close_btr(void)
> +{
> +}
> +
> +#define fs_ls_btr btrfs_ls
Please can you check latest mainline for this? I think you can use the
fstypes[] array now.
> +static int fs_read_btr(const char *filename, ulong addr, int offset, int len)
> +{
> + int file_len=0;
> + int len_read;
> + struct com32_filedata filedata;
> + int handle;
> + if (offset != 0) {
> + printf("** Cannot support non-zero offset **\n");
> + return -1;
> + }
> +
> + handle=btrfs_open_file(filename, &filedata);
> + if (handle < 0) {
> + printf("** File not found %s Invalid handle**\n", filename);
> + return -1;
> + }
> +
> + /*file handle is valid get the size of the file*/
> + len = filedata.size;
> + if (len == 0)
> + len = file_len;
> +
> + len_read = getfssec(&filedata, (char *)addr);
> + if (len_read != len) {
> + printf("** Unable to read file %s **\n", filename);
> + return -1;
> + }
> +
> + return len_read;
> +}
> +
> +#else
> +static inline int fs_probe_btr(void)
> +{
> + return -1;
> +}
> +
> +static inline void fs_close_btr(void)
> +{
> +}
> +
> +#define fs_ls_btr fs_ls_unsupported
> +#define fs_read_btr fs_read_unsupported
> +#endif
> +
> +
> +
> #ifdef CONFIG_FS_EXT4
> static int fs_probe_ext(void)
> {
> @@ -155,6 +222,10 @@ static struct {
> .fstype = FS_TYPE_EXT,
> .probe = fs_probe_ext,
> },
> + {
> + .fstype = FS_TYPE_BTR,
> + .probe = fs_probe_btr,
> + },
> };
>
> int fs_set_blk_dev(const char *ifname, const char *dev_part_str, int fstype)
> @@ -198,6 +269,9 @@ static void fs_close(void)
> case FS_TYPE_EXT:
> fs_close_ext();
> break;
> + case FS_TYPE_BTR:
> + fs_close_btr();
> + break;
> default:
> break;
> }
> @@ -216,6 +290,9 @@ int fs_ls(const char *dirname)
> case FS_TYPE_EXT:
> ret = fs_ls_ext(dirname);
> break;
> + case FS_TYPE_BTR:
> + ret = fs_ls_btr(dirname);
> + break;
> default:
> ret = fs_ls_unsupported(dirname);
> break;
> @@ -237,11 +314,14 @@ int fs_read(const char *filename, ulong addr, int offset, int len)
> case FS_TYPE_EXT:
> ret = fs_read_ext(filename, addr, offset, len);
> break;
> + case FS_TYPE_BTR:
> + ret = fs_read_btr(filename, addr, offset, len);
> + break;
> default:
> ret = fs_read_unsupported(filename, addr, offset, len);
> break;
> }
> -
> +
> fs_close();
>
> return ret;
> diff --git a/include/btrfs.h b/include/btrfs.h
> new file mode 100644
> index 0000000..76fde8c
> --- /dev/null
> +++ b/include/btrfs.h
> @@ -0,0 +1,391 @@
> +#ifndef _BTRFS_H_
> +#define _BTRFS_H_
> +
> +#include <asm/byteorder.h>
> +/* type that store on disk, but it is same as cpu type for i386 arch */
> +
> +#define CURRENTDIR_MAX 15
> +#define MAX_OPEN 5
> +#define FILENAME_MAX 20
> +#define MAX_SYMLINK_CNT 20
> +#define MAX_SYMLINK_BUF 4096
> +#define SECTOR_SHIFT(fs) ((fs)->sector_shift)
> +#define IFTODT(mode) (((mode) & 0170000) >> 12)
> +#define SECTOR_SIZE 0x200
> +#define SECTOR_BITS 9
> +#define EXTENT_ZERO ((__le32)-1) /* All-zero extent */
> +#define EXTENT_VOID ((__le32)-2) /* Invalid information */
> +#define DT_LNK 10
> +#define DT_REG 8
> +#define DT_DIR 4
I wonder if these should either go in the C file or have some sort of
prefix to avoid name collision?
> +
> +
> +#define EXTENT_SPECIAL(x) ((x) >= EXTENT_VOID)
> +#define MAX_SUBVOL_NAME 50
> +struct _DIR_;
> +typedef struct _DIR_ DIR;
Should avoid typedef, and capitalized structure names.
> +struct com32_filedata {
> + size_t size; /* File size */
> + int blocklg2; /* log2(block size) */
> + uint16_t handle; /* File handle */
> +};
> +
> +struct fs_info {
btrfs_info?
> + const struct fs_ops *fs_ops;
> + struct device *fs_dev;
> + void *fs_info; /* The fs-specific information */
> + int sector_shift, sector_size;
> + int block_shift, block_size;
> + struct inode *root, *cwd; /* Root and current directories */
> + char cwd_name[CURRENTDIR_MAX]; /* Current directory by name */
> +};
> +/*
> + * Extent structure: contains the mapping of some chunk of a file
> + * that is contiguous on disk.
> + */
> +struct extent {
> + __le64 pstart;
> + __le32 lstart; /* Logical start sector */
> + __le32 len; /* Number of contiguous sectors */
> +}__attribute__ ((__packed__));
> +
> +
> +struct inode {
> + struct fs_info *fs; /* The filesystem this inode is associated with */
> + struct inode *parent; /* Parent directory, if any */
> + const u8 *name; /* Name, valid for generic path search only */
> + __le32 refcnt;
> + __le32 mode; /* FILE , DIR or SYMLINK */
> + __le32 size;
> + __le32 blocks; /* How many blocks the file take */
> + __le32 ino; /* Inode number */
> + __le32 atime; /* Access time */
> + __le32 mtime; /* Modify time */
> + __le32 ctime; /* Create time */
> + __le32 dtime; /* Delete time */
> + __le32 flags;
> + __le32 file_acl;
Can/should these type be int32_t / uin64_t / etc?
> + struct extent this_extent, next_extent;
> + u8 pvt[0]; /* Private filesystem data */
> +}__attribute__ ((__packed__));
> +struct file {
> + struct fs_info *fs;
> + __le64 offset; /* for next read */
> + struct inode *inode; /* The file-specific information */
> +}__attribute__ ((__packed__));
> +
> +#define NAME_MAX 20
> +struct dirent {
> + uint32_t d_ino;
> + uint32_t d_off;
> + uint16_t d_reclen;
> + uint16_t d_type;
> + char d_name[NAME_MAX + 1];
> +};
btrfs_dirent perhaps?
> +
> +
> +#define btrfs_crc32c crc32c_le
Do you need this?
> +
> +#define BTRFS_SUPER_INFO_OFFSET (64 * 1024)
> +#define BTRFS_SUPER_INFO_SIZE 4096
> +#define BTRFS_MAX_LEAF_SIZE 4096
> +#define BTRFS_BLOCK_SHIFT 12
> +
> +#define BTRFS_SUPER_MIRROR_MAX 3
> +#define BTRFS_SUPER_MIRROR_SHIFT 12
> +#define BTRFS_CSUM_SIZE 32
> +#define BTRFS_FSID_SIZE 16
> +#define BTRFS_LABEL_SIZE 256
> +#define BTRFS_SYSTEM_CHUNK_ARRAY_SIZE 2048
> +#define BTRFS_UUID_SIZE 16
> +
> +#define BTRFS_MAGIC "_BHRfS_M"
> +
> +#define BTRFS_SUPER_FLAG_METADUMP (1ULL << 33)
> +
> +#define BTRFS_DEV_ITEM_KEY 216
> +#define BTRFS_CHUNK_ITEM_KEY 228
> +#define BTRFS_ROOT_REF_KEY 156
> +#define BTRFS_ROOT_ITEM_KEY 132
> +#define BTRFS_EXTENT_DATA_KEY 108
> +#define BTRFS_DIR_ITEM_KEY 84
> +#define BTRFS_INODE_ITEM_KEY 1
Might be nice to line up the values somewhat with tabs.
> +
> +#define BTRFS_EXTENT_TREE_OBJECTID 2ULL
> +#define BTRFS_FS_TREE_OBJECTID 5ULL
> +
> +#define BTRFS_FIRST_CHUNK_TREE_OBJECTID 256ULL
> +
> +#define BTRFS_FILE_EXTENT_INLINE 0
> +#define BTRFS_FILE_EXTENT_REG 1
> +#define BTRFS_FILE_EXTENT_PREALLOC 2
> +
> +#define BTRFS_MAX_LEVEL 8
> +#define BTRFS_MAX_CHUNK_ENTRIES 256
> +
> +#define BTRFS_FT_REG_FILE 1
> +#define BTRFS_FT_DIR 2
> +#define BTRFS_FT_SYMLINK 7
> +
> +#define ROOT_DIR_WORD 0x002f
> +
> +struct btrfs_dev_item {
> + __le64 devid;
> + __le64 total_bytes;
> + __le64 bytes_used;
> + __le32 io_align;
> + __le32 io_width;
> + __le32 sector_size;
> + __le64 type;
> + __le64 generation;
> + __le64 start_offset;
> + __le32 dev_group;
> + u8 seek_speed;
> + u8 bandwidth;
> + u8 uuid[BTRFS_UUID_SIZE];
> + u8 fsid[BTRFS_UUID_SIZE];
> +} __attribute__ ((__packed__));
> +
> +struct btrfs_super_block {
> + u8 csum[BTRFS_CSUM_SIZE];
> + /* the first 4 fields must match struct btrfs_header */
> + u8 fsid[BTRFS_FSID_SIZE]; /* FS specific uuid */
> + __le64 bytenr; /* this block number */
> + __le64 flags;
> +
> + /* allowed to be different from the btrfs_header from here own down */
> + __le64 magic;
> + __le64 generation;
> + __le64 root;
> + __le64 chunk_root;
> + __le64 log_root;
> +
> + /* this will help find the new super based on the log root */
> + __le64 log_root_transid;
> + __le64 total_bytes;
> + __le64 bytes_used;
> + __le64 root_dir_objectid;
> + __le64 num_devices;
> + __le32 sectorsize;
> + __le32 nodesize;
> + __le32 leafsize;
> + __le32 stripesize;
> + __le32 sys_chunk_array_size;
> + __le64 chunk_root_generation;
> + __le64 compat_flags;
> + __le64 compat_ro_flags;
> + __le64 incompat_flags;
> + __le16 csum_type;
> + u8 root_level;
> + u8 chunk_root_level;
> + u8 log_root_level;
> + struct btrfs_dev_item dev_item;
> +
> + char label[BTRFS_LABEL_SIZE];
> +
> + __le64 cache_generation;
> +
> + /* future expansion */
> + __le64 reserved[31];
> + u8 sys_chunk_array[BTRFS_SYSTEM_CHUNK_ARRAY_SIZE];
> +} __attribute__ ((__packed__));
> +struct btrfs_disk_key {
> + __le64 objectid;
> + u8 type;
> + __le64 offset;
> +} __attribute__ ((__packed__));
> +
> +struct btrfs_stripe {
> + __le64 devid;
> + __le64 offset;
> + u8 dev_uuid[BTRFS_UUID_SIZE];
> +} __attribute__ ((__packed__));
> +
> +struct btrfs_chunk {
> + __le64 length;
> + __le64 owner;
> + __le64 stripe_len;
> + __le64 type;
> + __le32 io_align;
> + __le32 io_width;
> + __le32 sector_size;
> + __le16 num_stripes;
> + __le16 sub_stripes;
> + struct btrfs_stripe stripe;
> +} __attribute__ ((__packed__));
> +
> +struct btrfs_header {
> + /* these first four must match the super block */
> + u8 csum[BTRFS_CSUM_SIZE];
> + u8 fsid[BTRFS_FSID_SIZE]; /* FS specific uuid */
> + __le64 bytenr; /* which block this node is supposed to live in */
> + __le64 flags;
> +
> + /* allowed to be different from the super from here on down */
> + u8 chunk_tree_uuid[BTRFS_UUID_SIZE];
> + __le64 generation;
> + __le64 owner;
> + __le32 nritems;
> + u8 level;
> +} __attribute__ ((__packed__));
> +
> +struct btrfs_item {
> + struct btrfs_disk_key key;
> + __le32 offset;
> + __le32 size;
> +} __attribute__ ((__packed__));
> +
> +struct btrfs_leaf {
> + struct btrfs_header header;
> + struct btrfs_item items[];
> +} __attribute__ ((__packed__));
> +
> +struct btrfs_key_ptr {
> + struct btrfs_disk_key key;
> + __le64 blockptr;
> + __le64 generation;
> +} __attribute__ ((__packed__));
> +
> +struct btrfs_node {
> + struct btrfs_header header;
> + struct btrfs_key_ptr ptrs[];
> +} __attribute__ ((__packed__));
> +
> +/* remember how we get to a node/leaf */
> +struct btrfs_path {
> + __le64 offsets[BTRFS_MAX_LEVEL];
> + __le32 itemsnr[BTRFS_MAX_LEVEL];
> + __le32 slots[BTRFS_MAX_LEVEL];
> + /* remember last slot's item and data */
> + struct btrfs_item item;
> + u8 data[BTRFS_MAX_LEAF_SIZE];
> +}__attribute__ ((__packed__));
> +
> +/* store logical offset to physical offset mapping */
> +struct btrfs_chunk_map_item {
> + __le64 logical;
> + __le64 length;
> + __le64 devid;
> + __le64 physical;
> +} __attribute__ ((__packed__));
> +
> +struct btrfs_chunk_map {
> + struct btrfs_chunk_map_item *map;
> + __le32 map_length;
> + __le32 cur_length;
> +} __attribute__ ((__packed__));;
> +
> +struct btrfs_timespec {
> + __le64 sec;
> + __le32 nsec;
> +} __attribute__ ((__packed__));
> +
> +struct btrfs_inode_item {
> + /* nfs style generation number */
> + __le64 generation;
> + /* transid that last touched this inode */
> + __le64 transid;
> + __le64 size;
> + __le64 nbytes;
> + __le64 block_group;
> + __le32 nlink;
> + __le32 uid;
> + __le32 gid;
> + __le32 mode;
> + __le64 rdev;
> + __le64 flags;
> +
> + /* modification sequence number for NFS */
> + __le64 sequence;
> +
> + /*
> + * a little future expansion, for more than this we can
> + * just grow the inode item and version it
> + */
> + __le64 reserved[4];
> + struct btrfs_timespec atime;
> + struct btrfs_timespec ctime;
> + struct btrfs_timespec mtime;
> + struct btrfs_timespec otime;
> +} __attribute__ ((__packed__));
> +
> +struct btrfs_root_item {
> + struct btrfs_inode_item inode;
> + __le64 generation;
> + __le64 root_dirid;
> + __le64 bytenr;
> + __le64 byte_limit;
> + __le64 bytes_used;
> + __le64 last_snapshot;
> + __le64 flags;
> + __le32 refs;
> + struct btrfs_disk_key drop_progress;
> + u8 drop_level;
> + u8 level;
> +} __attribute__ ((__packed__));
> +
> +struct btrfs_dir_item {
> + struct btrfs_disk_key location;
> + __le64 transid;
> + __le16 data_len;
> + __le16 name_len;
> + u8 type;
> +} __attribute__ ((__packed__));
> +
> +struct btrfs_file_extent_item {
> + __le64 generation;
> + __le64 ram_bytes;
> + u8 compression;
> + u8 encryption;
> + __le16 other_encoding; /* spare for later use */
> + u8 type;
> + __le64 disk_bytenr;
> + __le64 disk_num_bytes;
> + __le64 offset;
> + __le64 num_bytes;
> +} __attribute__ ((__packed__));
> +
> +struct btrfs_root_ref {
> + __le64 dirid;
> + __le64 sequence;
> + __le16 name_len;
> +} __attribute__ ((__packed__));
> +
> +/*
> + * btrfs private inode information
> + */
> +struct btrfs_pvt_inode {
> + __le64 offset;
> +}__attribute__ ((__packed__));
There is actually a __packed in linux/compiler BTW.
> +
Nice to have comments on these functions
> +void btrfs_set_blk_dev(block_dev_desc_t* rbdd , disk_partition_t *info);
> +int btrfs_fs_init(struct fs_info *fs);
> +void put_inode(struct inode *inode);
> +struct inode *alloc_inode(struct fs_info *fs, uint32_t ino, size_t data);
> +int btrfs_open_file(const char *name, struct com32_filedata *filedata);
> +int getfssec(struct com32_filedata *filedata, char * buf);
> +uint32_t generic_getfssec(struct file *file, char *buf,
> + int sectors, char *have_more);
> +char btrfs_ls(char* );
> +#define PVT(i) ((struct btrfs_pvt_inode *)((i)->pvt))
> +static inline __le32 next_psector(__le32 psector, uint32_t skip)
> +{
> + if (EXTENT_SPECIAL(psector))
> + return psector;
> + else
> + return psector + skip;
> +}
> +
> +static inline __le32 next_pstart(const struct extent *e)
> +{
> + return next_psector(e->pstart, e->len);
> +}
> +
> +static inline struct inode *get_inode(struct inode *inode)
> +{
> + inode->refcnt++;
> + return inode;
> +}
Perhaps just put these in the C file, since they are probably not
called from elsewhere?
> +
> +
> +#endif
> diff --git a/include/config_fallbacks.h b/include/config_fallbacks.h
> index bfb9680..28a0a66 100644
> --- a/include/config_fallbacks.h
> +++ b/include/config_fallbacks.h
> @@ -26,4 +26,8 @@
> #define CONFIG_EXT4_WRITE
> #endif
>
> +#if defined(CONFIG_CMD_BTR) && !defined(CONFIG_FS_BTR)
> +#define CONFIG_FS_BTR
> +#endif
> +
> #endif /* __CONFIG_FALLBACKS_H */
> diff --git a/include/fs.h b/include/fs.h
> index 4f30a38..3a0e7d4 100644
> --- a/include/fs.h
> +++ b/include/fs.h
> @@ -21,6 +21,7 @@
> #define FS_TYPE_ANY 0
> #define FS_TYPE_FAT 1
> #define FS_TYPE_EXT 2
> +#define FS_TYPE_BTR 3
>
> /*
> * Tell the fs layer which block device an partition to use for future
> --
> 1.7.9.5
>
Regards,
Simon
2
1
Hi Friends,
I have successfully run u-boot our my custom board but I can't run kernel.
Problem is that I have saved uImage.bin at NOR location 0x800000 and load into DRAM:0x41000000. Here u-boot can get kernel info and print into UART consol but after loading uncompressed image from 0x41000000 to 0x40020000 u-boot transfer its control to linux kernel and here my hardware goes reset means can't run kernel at 0x40020000.
Following is the log of consol:
U-Boot 2011.09 (Jan 23 2013 - 17:16:07)
CPU: BTAM MCF5329 (Mask:54 Version:2)
CPU CLK 240 MHz BUS CLK 80 MHz
Board: BTAM 5329
I2C: ready
DRAM: 32 MiB
Flash: 16 MiB
In: serial
Out: serial
Err: serial
Net: Link UP timeout
FEC0
Hit any key to stop autoboot: 5 4 3 2 1 0
## Booting kernel from Legacy Image at 41000000 ...
Image Name:
Created: 2013-03-04 12:03:52 UTC
Image Type: M68K Linux Kernel Image (gzip compressed)
Data Size: 1549021 Bytes = 1.5 MiB
Load Address: 40020000
Entry Point: 40020000
Verifying Checksum ... OK
Uncompressing Kernel Image ... OK
U-Boot 2011.09 (Jan 23 2013 - 17:16:07)
CPU: BTAM MCF5329 (Mask:54 Version:2)
CPU CLK 240 MHz BUS CLK 80 MHz
Board: BTAM 5329
I2C: ready
DRAM: 32 MiB
Flash: 16 MiB
In: serial
Out: serial
Err: serial
Net: Link UP timeout
FEC0
Hit any key to stop autoboot: 5 4 3 2 1 0
## Booting kernel from Legacy Image at 41000000 ...
Image Name:
Created: 2013-03-04 12:03:52 UTC
Image Type: M68K Linux Kernel Image (gzip compressed)
Data Size: 1549021 Bytes = 1.5 MiB
Load Address: 40020000
Entry Point: 40020000
Verifying Checksum ... OK
Uncompressing Kernel Image ... OK
U-Boot 2011.09 (Jan 23 2013 - 17:16:07)
CPU: BTAM MCF5329 (Mask:54 Version:2)
CPU CLK 240 MHz BUS CLK 80 MHz
Thanks & Regards,
Ramesh
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Disclaimer~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Information contained and transmitted by this e-mail is confidential and proprietary to iGATE and its affiliates and is intended for use only by the recipient. If you are not the intended recipient, you are hereby notified that any dissemination, distribution, copying or use of this e-mail is strictly prohibited and you are requested to delete this e-mail immediately and notify the originator or mailadmin(a)igate.com <mailto:mailadmin@igate.com>. iGATE does not enter into any agreement with any party by e-mail. Any views expressed by an individual do not necessarily reflect the view of iGATE. iGATE is not responsible for the consequences of any actions taken on the basis of information provided, through this email. The contents of an attachment to this e-mail may contain software viruses, which could damage your own computer system. While iGATE has taken every reasonable precaution to minimise this risk, we cannot accept liability for any damage which you sustain as a result of software viruses. You should carry out your own virus checks before opening an attachment. To know more about iGATE please visit www.igate.com <http://www.igate.com>.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2
1
This patch series add sama5d3xek board support.
Included features
- boot from NAND flash, PMECC support, 4bit ECC @ 512 bytes sector
- boot from SPI flash support
- boot from SD card support
- LCD support
- EMAC support
- USB support
Will do
- Add GMAC support
- Add of control support
Bo Shen (4):
USB: ohci-at91: support sama5d3x devices
NET: macb: support sama5d3x devices
SPI: atmel_spi: support sama5d3x devices
ARM: atmel: add sama5d3ek support
MAINTAINERS | 1 +
arch/arm/cpu/armv7/at91/Makefile | 49 +++++
arch/arm/cpu/armv7/at91/clock.c | 116 +++++++++++
arch/arm/cpu/armv7/at91/cpu.c | 115 +++++++++++
arch/arm/cpu/armv7/at91/reset.c | 44 +++++
arch/arm/cpu/armv7/at91/sama5d3_devices.c | 219 ++++++++++++++++++++
arch/arm/cpu/armv7/at91/timer.c | 136 +++++++++++++
arch/arm/include/asm/arch-at91/at91_dbu.h | 4 +
arch/arm/include/asm/arch-at91/at91_pmc.h | 7 +-
arch/arm/include/asm/arch-at91/clk.h | 1 +
arch/arm/include/asm/arch-at91/hardware.h | 2 +
arch/arm/include/asm/arch-at91/sama5d3.h | 220 +++++++++++++++++++++
arch/arm/include/asm/arch-at91/sama5d3_smc.h | 79 ++++++++
board/atmel/sama5d3xek/Makefile | 48 +++++
board/atmel/sama5d3xek/sama5d3xek.c | 274 ++++++++++++++++++++++++++
boards.cfg | 3 +
drivers/net/macb.c | 6 +-
drivers/spi/atmel_spi.c | 3 +-
drivers/usb/host/ohci-at91.c | 14 +-
include/configs/sama5d3xek.h | 268 +++++++++++++++++++++++++
20 files changed, 1603 insertions(+), 6 deletions(-)
create mode 100644 arch/arm/cpu/armv7/at91/Makefile
create mode 100644 arch/arm/cpu/armv7/at91/clock.c
create mode 100644 arch/arm/cpu/armv7/at91/cpu.c
create mode 100644 arch/arm/cpu/armv7/at91/reset.c
create mode 100644 arch/arm/cpu/armv7/at91/sama5d3_devices.c
create mode 100644 arch/arm/cpu/armv7/at91/timer.c
create mode 100644 arch/arm/include/asm/arch-at91/sama5d3.h
create mode 100644 arch/arm/include/asm/arch-at91/sama5d3_smc.h
create mode 100644 board/atmel/sama5d3xek/Makefile
create mode 100644 board/atmel/sama5d3xek/sama5d3xek.c
create mode 100644 include/configs/sama5d3xek.h
--
1.7.9.5
3
15

[U-Boot] [PATCH 0/15] Enhance SPI/SPI flash probing, add support for Intel ICH controller
by Simon Glass 08 Mar '13
by Simon Glass 08 Mar '13
08 Mar '13
Adding new fields to struct spi_slave and struct spi_flash is painful,
because most drivers don't zero the fields they don't use. Anyway it
seems better to have the SPI/SPI flash infrastructure provide a simple
way of doing this that all drivers can use.
So the first part of this series adds spi_alloc_slave(), for SPI, and
spi_flash_alloc() for SPI flash.
Support is added for the Intel ICH SPI controller, possibly the oddest
SPI controller in U-Boot. It is designed for use with SPI flash only,
and has a number of high-level features which are dedicated to flash.
As such it is a bit of a challenge to get it to behave just like a
normal U-Boot SPI device.
The ICH driver has two interesting features. Firstly it is impossible
to read or write more than 64 bytes at a time! For SPI reading it is
possible to hide this within the SPI driver. For SPI writing it
unfortunately isn't, since the spi_flash layer has to send an unlock
command and a new address for every write. It would be an egregious
hack to try to fake this in the driver. So a new property is added
to spi_flash to allow the maximum transfer size to be set.
Secondly, the ICH SPI flash can be memory mapped. On a lot of x86
devices this improves performance significantly. For example, the standard
driver gets maybe 12Mbps throughput from a 33Mbps dual interface, roughly
20% utilisation. With memory mapping, many platforms can achieve about
40Mbps. To implement memory mapping, a new property is provided in the
device tree to set the memory map address, which varies by platform. Some
x86 platforms will see a speed increase with memory mapping, some won't.
The memory mapping feature only works for reading. When in use, the
spi_flash layer bypasses the SPI driver completely, and just copies the
flash data from the correct place in the memory map.
Simon Glass (15):
fdt: Use sed instead of cpp to pre-process the dtc
fdt: Add fdtdec_get_addr_size() to read reg properties
spi: Add function to allocate a new SPI slave
spi: Use spi_alloc_slave() in each SPI driver
sf: Add spi_flash_alloc() to create a new SPI flash struct
sf: Use spi_flash_alloc() in each SPI flash driver
x86: spi: Add Intel ICH driver
spi: Add parameter for maximum write size
sf: Respect maximum SPI write size
x86: spi: Set maximum write size for ICH
sf: Enable FDT-based configuration and memory mapping
x86: Move PCI init before SPI init
x86: Add FDT SPI node for link
x86: Enable SPI flash support for coreboot
x86: Enable time command for coreboot
arch/x86/lib/board.c | 8 +-
board/chromebook-x86/dts/link.dts | 11 +
drivers/mtd/spi/atmel.c | 8 +-
drivers/mtd/spi/eon.c | 8 +-
drivers/mtd/spi/macronix.c | 8 +-
drivers/mtd/spi/ramtron.c | 4 +-
drivers/mtd/spi/spansion.c | 8 +-
drivers/mtd/spi/spi_flash.c | 81 ++++-
drivers/mtd/spi/sst.c | 8 +-
drivers/mtd/spi/stmicro.c | 8 +-
drivers/mtd/spi/winbond.c | 8 +-
drivers/spi/Makefile | 4 +
drivers/spi/altera_spi.c | 4 +-
drivers/spi/andes_spi.c | 4 +-
drivers/spi/armada100_spi.c | 4 +-
drivers/spi/atmel_spi.c | 4 +-
drivers/spi/bfin_spi.c | 4 +-
drivers/spi/cf_qspi.c | 4 +-
drivers/spi/cf_spi.c | 4 +-
drivers/spi/davinci_spi.c | 4 +-
drivers/spi/fsl_espi.c | 4 +-
drivers/spi/ich.c | 752 +++++++++++++++++++++++++++++++++++++
drivers/spi/ich.h | 144 +++++++
drivers/spi/kirkwood_spi.c | 5 +-
drivers/spi/mpc52xx_spi.c | 5 +-
drivers/spi/mpc8xxx_spi.c | 5 +-
drivers/spi/mxc_spi.c | 4 +-
drivers/spi/mxs_spi.c | 4 +-
drivers/spi/oc_tiny_spi.c | 5 +-
drivers/spi/omap3_spi.c | 27 +-
drivers/spi/sh_spi.c | 4 +-
drivers/spi/soft_spi.c | 4 +-
drivers/spi/spi.c | 39 ++
drivers/spi/tegra_spi.c | 4 +-
drivers/spi/xilinx_spi.c | 4 +-
dts/Makefile | 10 +-
include/configs/coreboot.h | 13 +-
include/fdtdec.h | 16 +
include/spi.h | 44 +++
include/spi_flash.h | 39 ++
lib/fdtdec.c | 27 ++-
41 files changed, 1208 insertions(+), 147 deletions(-)
create mode 100644 drivers/spi/ich.c
create mode 100644 drivers/spi/ich.h
create mode 100644 drivers/spi/spi.c
--
1.7.7.3
3
22

08 Mar '13
Based on 'master' branch of u-boot-samsung.
Changes from v3:
- Adding necesasry check for return error of exynos_usb_parse_dt()
and returning accordingly from ehci_hcd_init().
- Removing unnecessary parentheses around ctx->hcd.
Vivek Gautam (2):
usb: ehci: exynos: Fix multiple FDT decode
usb: ehci: exynos: Enable non-dt path
drivers/usb/host/ehci-exynos.c | 51 ++++++++++++++++++----------------------
1 files changed, 23 insertions(+), 28 deletions(-)
--
1.7.6.5
4
6
This patch adds fdt nodes for peripherals which require
pin muxing and configuration. Device tree bindings for pinctrl
are kept same as required for Linux. Existing pinmux code
modified to retrieve gpio range and function related info from fdt.
Depends-on: [U-Boot] [PATCH 0/4 V3] EXYNOS5: Add GPIO numbering feature
URL: http://lists.denx.de/pipermail/u-boot/2013-February/146151.html
Signed-off-by: Akshay Saraswat <akshay.s(a)samsung.com>
---
Changes since v1:
- Device tree bindings changed to linux style.
- Added documentation for samsung pinctrl.
Changes since v2:
- Rebased as per new version of GPIO numbering patch-set.
Changes since v3:
- Added comments to reduce ambiguity and increase readability.
- Fixed few other nits.
Changes since v4:
- Added support for reading peripheral pinctrl subnode names from preipheral's node instead of hard coding.
arch/arm/cpu/armv7/exynos/pinmux.c | 357 +++++++-------
arch/arm/dts/exynos5250-pinctrl.dtsi | 675 +++++++++++++++++++++++++++
arch/arm/dts/exynos5250.dtsi | 92 ++++
board/samsung/dts/exynos5250-smdk5250.dts | 11 +
doc/device-tree-bindings/samsung-pinctrl.txt | 253 ++++++++++
include/fdtdec.h | 4 +
lib/fdtdec.c | 4 +
7 files changed, 1231 insertions(+), 165 deletions(-)
create mode 100644 arch/arm/dts/exynos5250-pinctrl.dtsi
create mode 100644 doc/device-tree-bindings/samsung-pinctrl.txt
diff --git a/arch/arm/cpu/armv7/exynos/pinmux.c b/arch/arm/cpu/armv7/exynos/pinmux.c
index a01ce0c..119db82 100644
--- a/arch/arm/cpu/armv7/exynos/pinmux.c
+++ b/arch/arm/cpu/armv7/exynos/pinmux.c
@@ -23,10 +23,20 @@
#include <common.h>
#include <fdtdec.h>
+#include <linux/ctype.h>
#include <asm/arch/gpio.h>
#include <asm/arch/pinmux.h>
#include <asm/arch/sromc.h>
+DECLARE_GLOBAL_DATA_PTR;
+
+/* Struct for temporarily storing pin related info */
+struct pin_group {
+ uint8_t function; /* Pin function */
+ uint8_t pull_mode; /* Pin pull mode */
+ uint8_t drive_strength; /* Pin drive strength */
+};
+
struct gpio_name_num_table exynos5_gpio_table[] = {
{ 'a', GPIO_A00 },
{ 'b', GPIO_B00 },
@@ -42,252 +52,271 @@ struct gpio_name_num_table exynos5_gpio_table[] = {
{ 'z', GPIO_Z0 },
};
-static void exynos5_uart_config(int peripheral)
+/* Extract and set pins in a particular pinctrl node */
+static void pinmux_set_pins(const char *fprop_data,
+ struct pin_group *pingrp)
{
- int i, start, count;
+ int i;
+ char gpio[5];
+
+ /*
+ * Get all the pin names from fdt and fill the gpio array
+ * with corresponding enum values(Pin numbers).
+ */
+ for (i = 0; !(fprop_data[i] == (int)NULL &&
+ fprop_data[i+1] == (int)NULL); i += 7) {
+ int pin_num = -1;
+
+ /*
+ * Modify pin name retrieved from fdt,
+ * so that name_to_gpio may understand.
+ */
+ gpio[0] = fprop_data[i];
+ gpio[1] = fprop_data[i + 1];
+ gpio[2] = fprop_data[i + 2];
+ gpio[3] = fprop_data[i + 3];
+ gpio[4] = fprop_data[i + 5];
+
+ pin_num = name_to_gpio(gpio);
+
+ /*
+ * If pin number is valid, add it to the pin array
+ * and increment pin count.
+ */
+ if (pin_num >= 0) {
+ gpio_cfg_pin(pin_num,
+ S5P_GPIO_FUNC(pingrp->function));
+ gpio_set_pull(pin_num, pingrp->pull_mode);
+ gpio_set_drv(pin_num, pingrp->drive_strength);
+ }
+ }
+}
+
+/* Extract all the config info from pinctrl periph subnodei */
+static int pinmux_do_config(struct pin_group *pingrp, const char * dev_name)
+{
+ int node, subnode;
+ const char *fprop_data;
+
+ /* Loop for all pinctrl nodes in fdt */
+ for (node = fdtdec_next_compatible(gd->fdt_blob, 0,
+ COMPAT_SAMSUNG_PINCTRL); node >= 0;
+ node = fdtdec_next_compatible(gd->fdt_blob, node,
+ COMPAT_SAMSUNG_PINCTRL)) {
+ /* Get the subnode from FDT for this peripheral*/
+ subnode = fdt_subnode_offset(gd->fdt_blob,
+ node, dev_name);
+ if (subnode < 0)
+ continue;
+
+ /* Get names of pins to be configured from fdt */
+ fprop_data = fdt_getprop(gd->fdt_blob,
+ subnode, "samsung,pins", NULL);
+
+ /* Get the pin function from fdt */
+ pingrp->function = fdtdec_get_int(gd->fdt_blob,
+ subnode, "samsung,pin-function", 0);
+
+ /* Get the pull mode for pins from fdt */
+ pingrp->pull_mode = fdtdec_get_int(gd->fdt_blob,
+ subnode, "samsung,pin-pud", 0);
+
+ /* Get the drive strength for pins from fdt */
+ pingrp->drive_strength = fdtdec_get_int(gd->fdt_blob,
+ subnode, "samsung,pin-drv", 0);
+
+ /* Convert pin names to pin numbers */
+ pinmux_set_pins(fprop_data, pingrp);
+
+ return 0;
+ }
+
+ return -1;
+}
+
+/* Set configuration for all pins as per fdt for a peripheral */
+static int pinmux_group_set(struct pin_group *pingrp, int pnode)
+{
+ int err, i = 0;
+ const char *fprop_data;
+ const char *dev_name;
+
+ fprop_data = fdt_getprop(gd->fdt_blob, pnode,
+ "samsung,pinctrl-names", NULL);
+
+ do {
+ dev_name = (fprop_data + i);
+ err = pinmux_do_config(pingrp, dev_name);
+ if (err)
+ break;
+ while (fprop_data[i] != (int)NULL)
+ i++;
+ } while (isalnum(fprop_data[++i]));
+
+ return err;
+}
+
+static int exynos5_uart_config(int peripheral)
+{
+ int suffix, pnode;
+ struct pin_group pingrp;
switch (peripheral) {
case PERIPH_ID_UART0:
- start = GPIO_A00;
- count = 4;
+ suffix = 0;
break;
case PERIPH_ID_UART1:
- start = GPIO_D00;
- count = 4;
+ suffix = 1;
break;
case PERIPH_ID_UART2:
- start = GPIO_A10;
- count = 4;
+ suffix = 2;
break;
case PERIPH_ID_UART3:
- start = GPIO_A14;
- count = 2;
+ suffix = 3;
break;
}
- for (i = start; i < start + count; i++) {
- gpio_set_pull(i, S5P_GPIO_PULL_NONE);
- gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2));
- }
+
+ pnode = fdtdec_next_alias(gd->fdt_blob, "uart",
+ COMPAT_SAMSUNG_EXYNOS_UART, &suffix);
+
+ return pinmux_group_set(&pingrp, pnode);
}
-static int exynos5_mmc_config(int peripheral, int flags)
+static int exynos5_mmc_config(int peripheral)
{
- int i, start, start_ext, gpio_func = 0;
+ int suffix, pnode;
+ struct pin_group pingrp;
switch (peripheral) {
case PERIPH_ID_SDMMC0:
- start = GPIO_C00;
- start_ext = GPIO_C10;
- gpio_func = S5P_GPIO_FUNC(0x2);
+ suffix = 0;
break;
case PERIPH_ID_SDMMC1:
- start = GPIO_C20;
- start_ext = 0;
+ suffix = 1;
break;
case PERIPH_ID_SDMMC2:
- start = GPIO_C30;
- start_ext = GPIO_C43;
- gpio_func = S5P_GPIO_FUNC(0x3);
+ suffix = 2;
break;
case PERIPH_ID_SDMMC3:
- start = GPIO_C40;
- start_ext = 0;
+ suffix = 3;
break;
}
- if ((flags & PINMUX_FLAG_8BIT_MODE) && !start_ext) {
- debug("SDMMC device %d does not support 8bit mode",
- peripheral);
- return -1;
- }
- if (flags & PINMUX_FLAG_8BIT_MODE) {
- for (i = start_ext; i <= (start_ext + 3); i++) {
- gpio_cfg_pin(i, gpio_func);
- gpio_set_pull(i, S5P_GPIO_PULL_UP);
- gpio_set_drv(i, S5P_GPIO_DRV_4X);
- }
- }
- for (i = 0; i < 2; i++) {
- gpio_cfg_pin(start + i, S5P_GPIO_FUNC(0x2));
- gpio_set_pull(start + i, S5P_GPIO_PULL_NONE);
- gpio_set_drv(start + i, S5P_GPIO_DRV_4X);
- }
- for (i = 3; i <= 6; i++) {
- gpio_cfg_pin(start + i, S5P_GPIO_FUNC(0x2));
- gpio_set_pull(start + i, S5P_GPIO_PULL_UP);
- gpio_set_drv(start + i, S5P_GPIO_DRV_4X);
- }
- return 0;
+ pnode = fdtdec_next_alias(gd->fdt_blob, "mshc",
+ COMPAT_SAMSUNG_EXYNOS_MSHC, &suffix);
+
+ return pinmux_group_set(&pingrp, pnode);
}
-static void exynos5_sromc_config(int flags)
+static int exynos5_sromc_config(void)
{
- int i;
-
- /*
- * SROM:CS1 and EBI
- *
- * GPY0[0] SROM_CSn[0]
- * GPY0[1] SROM_CSn[1](2)
- * GPY0[2] SROM_CSn[2]
- * GPY0[3] SROM_CSn[3]
- * GPY0[4] EBI_OEn(2)
- * GPY0[5] EBI_EEn(2)
- *
- * GPY1[0] EBI_BEn[0](2)
- * GPY1[1] EBI_BEn[1](2)
- * GPY1[2] SROM_WAIT(2)
- * GPY1[3] EBI_DATA_RDn(2)
- */
- gpio_cfg_pin(GPIO_Y00 + (flags & PINMUX_FLAG_BANK),
- S5P_GPIO_FUNC(2));
- gpio_cfg_pin(GPIO_Y04, S5P_GPIO_FUNC(2));
- gpio_cfg_pin(GPIO_Y05, S5P_GPIO_FUNC(2));
-
- for (i = 0; i < 4; i++)
- gpio_cfg_pin(GPIO_Y10 + i, S5P_GPIO_FUNC(2));
-
- /*
- * EBI: 8 Addrss Lines
- *
- * GPY3[0] EBI_ADDR[0](2)
- * GPY3[1] EBI_ADDR[1](2)
- * GPY3[2] EBI_ADDR[2](2)
- * GPY3[3] EBI_ADDR[3](2)
- * GPY3[4] EBI_ADDR[4](2)
- * GPY3[5] EBI_ADDR[5](2)
- * GPY3[6] EBI_ADDR[6](2)
- * GPY3[7] EBI_ADDR[7](2)
- *
- * EBI: 16 Data Lines
- *
- * GPY5[0] EBI_DATA[0](2)
- * GPY5[1] EBI_DATA[1](2)
- * GPY5[2] EBI_DATA[2](2)
- * GPY5[3] EBI_DATA[3](2)
- * GPY5[4] EBI_DATA[4](2)
- * GPY5[5] EBI_DATA[5](2)
- * GPY5[6] EBI_DATA[6](2)
- * GPY5[7] EBI_DATA[7](2)
- *
- * GPY6[0] EBI_DATA[8](2)
- * GPY6[1] EBI_DATA[9](2)
- * GPY6[2] EBI_DATA[10](2)
- * GPY6[3] EBI_DATA[11](2)
- * GPY6[4] EBI_DATA[12](2)
- * GPY6[5] EBI_DATA[13](2)
- * GPY6[6] EBI_DATA[14](2)
- * GPY6[7] EBI_DATA[15](2)
- */
- for (i = 0; i < 8; i++) {
- gpio_cfg_pin(GPIO_Y30 + i, S5P_GPIO_FUNC(2));
- gpio_set_pull(GPIO_Y30 + i, S5P_GPIO_PULL_UP);
+ int pnode;
+ static struct pin_group pingrp;
- gpio_cfg_pin(GPIO_Y50 + i, S5P_GPIO_FUNC(2));
- gpio_set_pull(GPIO_Y50 + i, S5P_GPIO_PULL_UP);
+ pnode = fdtdec_next_compatible(gd->fdt_blob, 0,
+ COMPAT_SAMSUNG_EXYNOS5_SROMC);
- gpio_cfg_pin(GPIO_Y60 + i, S5P_GPIO_FUNC(2));
- gpio_set_pull(GPIO_Y60 + i, S5P_GPIO_PULL_UP);
- }
+ return pinmux_group_set(&pingrp, pnode);
}
-static void exynos5_i2c_config(int peripheral, int flags)
+static int exynos5_i2c_config(int peripheral)
{
+ int suffix, pnode;
+ struct pin_group pingrp;
switch (peripheral) {
case PERIPH_ID_I2C0:
- gpio_cfg_pin(GPIO_B30, S5P_GPIO_FUNC(0x2));
- gpio_cfg_pin(GPIO_B31, S5P_GPIO_FUNC(0x2));
+ suffix = 0;
break;
case PERIPH_ID_I2C1:
- gpio_cfg_pin(GPIO_B32, S5P_GPIO_FUNC(0x2));
- gpio_cfg_pin(GPIO_B33, S5P_GPIO_FUNC(0x2));
+ suffix = 1;
break;
case PERIPH_ID_I2C2:
- gpio_cfg_pin(GPIO_A06, S5P_GPIO_FUNC(0x3));
- gpio_cfg_pin(GPIO_A07, S5P_GPIO_FUNC(0x3));
+ suffix = 2;
break;
case PERIPH_ID_I2C3:
- gpio_cfg_pin(GPIO_A12, S5P_GPIO_FUNC(0x3));
- gpio_cfg_pin(GPIO_A13, S5P_GPIO_FUNC(0x3));
+ suffix = 3;
break;
case PERIPH_ID_I2C4:
- gpio_cfg_pin(GPIO_A20, S5P_GPIO_FUNC(0x3));
- gpio_cfg_pin(GPIO_A21, S5P_GPIO_FUNC(0x3));
+ suffix = 4;
break;
case PERIPH_ID_I2C5:
- gpio_cfg_pin(GPIO_A22, S5P_GPIO_FUNC(0x3));
- gpio_cfg_pin(GPIO_A23, S5P_GPIO_FUNC(0x3));
+ suffix = 5;
break;
case PERIPH_ID_I2C6:
- gpio_cfg_pin(GPIO_B13, S5P_GPIO_FUNC(0x4));
- gpio_cfg_pin(GPIO_B14, S5P_GPIO_FUNC(0x4));
+ suffix = 6;
break;
case PERIPH_ID_I2C7:
- gpio_cfg_pin(GPIO_B22, S5P_GPIO_FUNC(0x3));
- gpio_cfg_pin(GPIO_B23, S5P_GPIO_FUNC(0x3));
+ suffix = 7;
break;
}
+
+ pnode = fdtdec_next_alias(gd->fdt_blob, "i2c",
+ COMPAT_SAMSUNG_S3C2440_I2C, &suffix);
+
+ return pinmux_group_set(&pingrp, pnode);
}
-static void exynos5_i2s_config(int peripheral)
+static int exynos5_i2s_config(int peripheral)
{
- int i;
+ int suffix, pnode;
+ struct pin_group pingrp;
+
+ if (peripheral == PERIPH_ID_I2S1) {
+ suffix = 1;
+ pnode = fdtdec_next_alias(gd->fdt_blob, "i2s",
+ COMPAT_SAMSUNG_EXYNOS_I2S, &suffix);
+ }
- for (i = 0; i < 5; i++)
- gpio_cfg_pin(GPIO_B00+i, S5P_GPIO_FUNC(0x02));
+ return pinmux_group_set(&pingrp, pnode);
}
-void exynos5_spi_config(int peripheral)
+int exynos5_spi_config(int peripheral)
{
- int cfg = 0, pin = 0, i;
+ int suffix, pnode;
+ static struct pin_group pingrp;
switch (peripheral) {
case PERIPH_ID_SPI0:
- cfg = S5P_GPIO_FUNC(0x2);
- pin = GPIO_A20;
+ suffix = 0;
break;
case PERIPH_ID_SPI1:
- cfg = S5P_GPIO_FUNC(0x2);
- pin = GPIO_A24;
+ suffix = 1;
break;
case PERIPH_ID_SPI2:
- cfg = S5P_GPIO_FUNC(0x5);
- pin = GPIO_B11;
+ suffix = 2;
break;
case PERIPH_ID_SPI3:
- cfg = S5P_GPIO_FUNC(0x2);
- pin = GPIO_F10;
+ suffix = 3;
break;
case PERIPH_ID_SPI4:
- for (i = 0; i < 2; i++) {
- gpio_cfg_pin(GPIO_F02 + i, S5P_GPIO_FUNC(0x4));
- gpio_cfg_pin(GPIO_E04 + i, S5P_GPIO_FUNC(0x4));
- }
+ suffix = 4;
break;
}
- if (peripheral != PERIPH_ID_SPI4) {
- for (i = pin; i < pin + 4; i++)
- gpio_cfg_pin(i, cfg);
- }
+
+ pnode = fdtdec_next_alias(gd->fdt_blob, "spi",
+ COMPAT_SAMSUNG_EXYNOS_SPI, &suffix);
+
+ return pinmux_group_set(&pingrp, pnode);
}
-static int exynos5_pinmux_config(int peripheral, int flags)
+static int exynos5_pinmux_config(int peripheral)
{
switch (peripheral) {
case PERIPH_ID_UART0:
case PERIPH_ID_UART1:
case PERIPH_ID_UART2:
case PERIPH_ID_UART3:
- exynos5_uart_config(peripheral);
+ return exynos5_uart_config(peripheral);
break;
case PERIPH_ID_SDMMC0:
case PERIPH_ID_SDMMC1:
case PERIPH_ID_SDMMC2:
case PERIPH_ID_SDMMC3:
- return exynos5_mmc_config(peripheral, flags);
+ return exynos5_mmc_config(peripheral);
+ break;
case PERIPH_ID_SROMC:
- exynos5_sromc_config(flags);
+ return exynos5_sromc_config();
break;
case PERIPH_ID_I2C0:
case PERIPH_ID_I2C1:
@@ -297,24 +326,22 @@ static int exynos5_pinmux_config(int peripheral, int flags)
case PERIPH_ID_I2C5:
case PERIPH_ID_I2C6:
case PERIPH_ID_I2C7:
- exynos5_i2c_config(peripheral, flags);
+ return exynos5_i2c_config(peripheral);
break;
case PERIPH_ID_I2S1:
- exynos5_i2s_config(peripheral);
+ return exynos5_i2s_config(peripheral);
break;
case PERIPH_ID_SPI0:
case PERIPH_ID_SPI1:
case PERIPH_ID_SPI2:
case PERIPH_ID_SPI3:
case PERIPH_ID_SPI4:
- exynos5_spi_config(peripheral);
+ return exynos5_spi_config(peripheral);
break;
default:
debug("%s: invalid peripheral %d", __func__, peripheral);
return -1;
}
-
- return 0;
}
static void exynos4_i2c_config(int peripheral, int flags)
@@ -427,7 +454,7 @@ static int exynos4_pinmux_config(int peripheral, int flags)
int exynos_pinmux_config(int peripheral, int flags)
{
if (cpu_is_exynos5())
- return exynos5_pinmux_config(peripheral, flags);
+ return exynos5_pinmux_config(peripheral);
else if (cpu_is_exynos4())
return exynos4_pinmux_config(peripheral, flags);
else {
@@ -495,6 +522,6 @@ int name_to_gpio(const char *name)
if (i == ARRAY_SIZE(exynos5_gpio_table))
return -1;
-
+
return num;
}
diff --git a/arch/arm/dts/exynos5250-pinctrl.dtsi b/arch/arm/dts/exynos5250-pinctrl.dtsi
new file mode 100644
index 0000000..3f4dc59
--- /dev/null
+++ b/arch/arm/dts/exynos5250-pinctrl.dtsi
@@ -0,0 +1,675 @@
+/*
+ * Samsung's Exynos5250 SoC pin-mux and pin-config device tree source
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * Samsung's Exynos5250 SoC pin-mux and pin-config options are listed as device
+ * tree nodes in this file.
+ *
+ * Note: This file does not include pin-ctrl subnodes for all the controllers in
+ * Exynos5250 SoC. It can be updated as per need in future.
+ *
+ * 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.
+*/
+
+/ {
+ pinctrl_0: pinctrl@11400000 {
+ compatible = "samsung,pinctrl";
+ reg = <0x11400000 0x1000>;
+ interrupts = <0 46 0>;
+
+ gpa0: gpa0 {
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
+
+ gpa1: gpa1 {
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
+
+ gpa2: gpa2 {
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
+
+ gpb0: gpb0 {
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
+
+ gpb1: gpb1 {
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
+
+ gpb2: gpb2 {
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
+
+ gpb3: gpb3 {
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
+
+ gpc0: gpc0 {
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
+
+ gpc1: gpc1 {
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
+
+ gpc2: gpc2 {
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
+
+ gpc3: gpc3 {
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
+
+ gpd0: gpd0 {
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
+
+ gpd1: gpd1 {
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
+
+ gpy0: gpy0 {
+ gpio-controller;
+ #gpio-cells = <2>;
+ };
+
+ gpy1: gpy1 {
+ gpio-controller;
+ #gpio-cells = <2>;
+ };
+
+ gpy2: gpy2 {
+ gpio-controller;
+ #gpio-cells = <2>;
+ };
+
+ gpy3: gpy3 {
+ gpio-controller;
+ #gpio-cells = <2>;
+ };
+
+ gpy4: gpy4 {
+ gpio-controller;
+ #gpio-cells = <2>;
+ };
+
+ gpy5: gpy5 {
+ gpio-controller;
+ #gpio-cells = <2>;
+ };
+
+ gpy6: gpy6 {
+ gpio-controller;
+ #gpio-cells = <2>;
+ };
+
+ gpc4: gpc4 {
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
+
+ gpx0: gpx0 {
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
+
+ gpx1: gpx1 {
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
+
+ gpx2: gpx2 {
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
+
+ gpx3: gpx3 {
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
+
+ uart0_data: uart0-data {
+ samsung,pins = "gpa0-0", "gpa0-1";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <0>;
+ samsung,pin-drv = <0>;
+ };
+
+ uart0_fctl: uart0-fctl {
+ samsung,pins = "gpa0-2", "gpa0-3";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <0>;
+ samaung,pin-drv = <0>;
+ };
+
+ uart1_data: uart1-data {
+ samsung,pins = "gpd0-0", "gpd0-1";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <0>;
+ samsung,pin-drv = <0>;
+ };
+
+ uart1_fctl: uart1-fctl {
+ samsung,pins = "gpd0-2", "gpd0-3";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <0>;
+ samaung,pin-drv = <0>;
+ };
+
+ uart2_data: uart2-data {
+ samsung,pins = "gpa1-0", "gpa1-1";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <0>;
+ samsung,pin-drv = <0>;
+ };
+
+ uart2_fctl: uart2-fctl {
+ samsung,pins = "gpa1-2", "gpa1-3";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <0>;
+ samaung,pin-drv = <0>;
+ };
+
+ uart3_data: uart3-data {
+ samsung,pins = "gpa1-4", "gpa1-5";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <0>;
+ samsung,pin-drv = <0>;
+ };
+
+ sd0_clk: sd0-clk {
+ samsung,pins = "gpc0-0";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <0>;
+ samsung,pin-drv = <3>;
+ };
+
+ sd0_cmd: sd0-cmd {
+ samsung,pins = "gpc0-1";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <0>;
+ samsung,pin-drv = <3>;
+ };
+
+ sd0_cd: sd0-cd {
+ samsung,pins = "gpc0-2";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <3>;
+ samsung,pin-drv = <3>;
+ };
+
+ sd0_bus1: sd0-bus-width1 {
+ samsung,pins = "gpc0-3";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <3>;
+ samsung,pin-drv = <3>;
+ };
+
+ sd0_bus4: sd0-bus-width4 {
+ samsung,pins = "gpc0-3", "gpc0-4", "gpc0-5", "gpc0-6";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <3>;
+ samsung,pin-drv = <3>;
+ };
+
+ sd0_bus8: sd0-bus-width8 {
+ samsung,pins = "gpc1-0", "gpc1-1", "gpc1-2", "gpc1-3";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <3>;
+ samsung,pin-drv = <3>;
+ };
+
+ sd1_clk: sd1-clk {
+ samsung,pins = "gpc2-0";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <0>;
+ samsung,pin-drv = <3>;
+ };
+
+ sd1_cmd: sd1-cmd {
+ samsung,pins = "gpc2-1";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <0>;
+ samsung,pin-drv = <3>;
+ };
+
+ sd1_cd: sd1-cd {
+ samsung,pins = "gpc2-2";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <3>;
+ samsung,pin-drv = <3>;
+ };
+
+ sd1_bus1: sd1-bus-width1 {
+ samsung,pins = "gpc2-3";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <3>;
+ samsung,pin-drv = <3>;
+ };
+
+ sd1_bus4: sd1-bus-width4 {
+ samsung,pins = "gpc2-3", "gpc2-4", "gpc2-5", "gpc2-6";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <3>;
+ samsung,pin-drv = <3>;
+ };
+
+ sd2_clk: sd2-clk {
+ samsung,pins = "gpc3-0";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <0>;
+ samsung,pin-drv = <3>;
+ };
+
+ sd2_cmd: sd2-cmd {
+ samsung,pins = "gpc3-1";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <0>;
+ samsung,pin-drv = <3>;
+ };
+
+ sd2_cd: sd2-cd {
+ samsung,pins = "gpc3-2";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <3>;
+ samsung,pin-drv = <3>;
+ };
+
+ sd2_bus1: sd2-bus-width1 {
+ samsung,pins = "gpc3-3";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <3>;
+ samsung,pin-drv = <3>;
+ };
+
+ sd2_bus4: sd2-bus-width4 {
+ samsung,pins = "gpc3-3", "gpc3-4", "gpc3-5", "gpc3-6";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <3>;
+ samsung,pin-drv = <3>;
+ };
+
+ sd2_bus8: sd2-bus-width8 {
+ samsung,pins = "gpc4-3", "gpc4-4", "gpc4-5", "gpc4-6";
+ samsung,pin-function = <3>;
+ samsung,pin-pud = <3>;
+ samsung,pin-drv = <3>;
+ };
+
+ sd3_clk: sd3-clk {
+ samsung,pins = "gpc4-0";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <0>;
+ samsung,pin-drv = <3>;
+ };
+
+ sd3_cmd: sd3-cmd {
+ samsung,pins = "gpc4-1";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <0>;
+ samsung,pin-drv = <3>;
+ };
+
+ sd3_cd: sd3-cd {
+ samsung,pins = "gpc4-2";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <3>;
+ samsung,pin-drv = <3>;
+ };
+
+ sd3_bus1: sd3-bus-width1 {
+ samsung,pins = "gpc4-3";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <3>;
+ samsung,pin-drv = <3>;
+ };
+
+ sd3_bus4: sd3-bus-width4 {
+ samsung,pins = "gpc4-3", "gpc4-4", "gpc4-5", "gpc4-6";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <3>;
+ samsung,pin-drv = <3>;
+ };
+
+ srom_cs1: srom-cs1 {
+ samsung,pins = "gpy0-1", "gpy0-4", "gpy0-5";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <0>;
+ samsung,pin-drv = <0>;
+ };
+
+ srom_ebi: srom-ebi-enable {
+ samsung,pins = "gpy1-0", "gpy1-1", "gpy1-2", "gpy1-3";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <0>;
+ samsung,pin-drv = <0>;
+ };
+
+ srom_ebi_a: srom-ebi-addr-lines {
+ samsung,pins = "gpy3-0", "gpy3-1", "gpy3-2", "gpy3-3",
+ "gpy3-4", "gpy3-5", "gpy3-6", "gpy3-7";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <3>;
+ samsung,pin-drv = <0>;
+ };
+
+ srom_ebi_d: srom-ebi-data-lines {
+ samsung,pins = "gpy5-0", "gpy5-1", "gpy5-2", "gpy5-3",
+ "gpy5-4", "gpy5-5", "gpy5-6", "gpy5-7",
+ "gpy6-0", "gpy6-1", "gpy6-2", "gpy6-3",
+ "gpy6-4", "gpy6-5", "gpy6-6", "gpy6-7";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <3>;
+ samsung,pin-drv = <0>;
+ };
+
+ i2s: i2s {
+ samsung,pins = "gpb0-0", "gpb0-1", "gpb0-2", "gpb0-3",
+ "gpb0-4";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <0>;
+ samsung,pin-drv = <0>;
+ };
+
+ spi0_bus: spi0-bus {
+ samsung,pins = "gpa2-0", "gpa2-1", "gpa2-2", "gpa2-3";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <3>;
+ samsung,pin-drv = <0>;
+ };
+
+ spi1_bus: spi1-bus {
+ samsung,pins = "gpa2-4", "gpa2-5", "gpa2-6", "gpa2-7";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <3>;
+ samsung,pin-drv = <0>;
+ };
+
+ spi2_bus: spi2-bus {
+ samsung,pins = "gpb1-1", "gpb1-2", "gpb1-3", "gpb1-4";
+ samsung,pin-function = <5>;
+ samsung,pin-pud = <3>;
+ samsung,pin-drv = <0>;
+ };
+
+ i2c0_bus: i2c0-bus {
+ samsung,pins = "gpb3-0", "gpb3-1";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <3>;
+ samsung,pin-drv = <0>;
+ };
+
+ i2c1_bus: i2c1-bus {
+ samsung,pins = "gpb3-2", "gpb3-3";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <3>;
+ samsung,pin-drv = <0>;
+ };
+
+ i2c2_bus: i2c2-bus {
+ samsung,pins = "gpa0-6", "gpa0-7";
+ samsung,pin-function = <3>;
+ samsung,pin-pud = <3>;
+ samaung,pin-drv = <0>;
+ };
+
+ i2c3_bus: i2c3-bus {
+ samsung,pins = "gpa1-2", "gpa1-3";
+ samsung,pin-function = <3>;
+ samsung,pin-pud = <3>;
+ samaung,pin-drv = <0>;
+ };
+
+ i2c4_bus: i2c4-bus {
+ samsung,pins = "gpa2-0", "gpa2-1";
+ samsung,pin-function = <3>;
+ samsung,pin-pud = <3>;
+ samaung,pin-drv = <0>;
+ };
+
+ i2c5_bus: i2c5-bus {
+ samsung,pins = "gpa2-2", "gpa2-3";
+ samsung,pin-function = <3>;
+ samsung,pin-pud = <3>;
+ samaung,pin-drv = <0>;
+ };
+
+ i2c6_bus: i2c6-bus {
+ samsung,pins = "gpb1-3", "gpb1-4";
+ samsung,pin-function = <4>;
+ samsung,pin-pud = <3>;
+ samsung,pin-drv = <0>;
+ };
+
+ i2c7_bus: i2c7-bus {
+ samsung,pins = "gpb2-2", "gpb2-3";
+ samsung,pin-function = <3>;
+ samsung,pin-pud = <3>;
+ samsung,pin-drv = <0>;
+ };
+ };
+
+ pinctrl_1: pinctrl@13400000 {
+ compatible = "samsung,pinctrl";
+ reg = <0x13400000 0x1000>;
+ interrupts = <0 45 0>;
+
+ gpe0: gpe0 {
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
+
+ gpe1: gpe1 {
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
+
+ gpf0: gpf0 {
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
+
+ gpf1: gpf1 {
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
+
+ gpg0: gpg0 {
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
+
+ gpg1: gpg1 {
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
+
+ gpg2: gpg2 {
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
+
+ gph0: gph0 {
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
+
+ gph1: gph1 {
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
+
+ spi3_bus: spi3-bus {
+ samsung,pins = "gpf1-0", "gpf1-1", "gpf1-2", "gpf1-3";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <3>;
+ samsung,pin-drv = <0>;
+ };
+
+ spi4_bus: spi4-bus {
+ samsung,pins = "gpf0-2", "gpf0-3", "gpe0-4", "gpe0-5";
+ samsung,pin-function = <4>;
+ samsung,pin-pud = <3>;
+ samsung,pin-drv = <0>;
+ };
+ };
+
+ pinctrl_2: pinctrl@10d10000 {
+ compatible = "samsung,pinctrl-exynos5250";
+ reg = <0x10d10000 0x1000>;
+ interrupts = <0 45 0>;
+
+ gpv0: gpv0 {
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
+
+ gpv1: gpv1 {
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
+
+ gpv2: gpv2 {
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
+
+ gpv3: gpv3 {
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
+
+ gpv4: gpv4 {
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
+ };
+
+ pinctrl_3: pinctrl@03680000 {
+ compatible = "samsung,pinctrl-exynos5250";
+ reg = <0x03680000 0x1000>;
+ interrupts = <0 45 0>;
+
+ gpz: gpz {
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
+ };
+};
diff --git a/arch/arm/dts/exynos5250.dtsi b/arch/arm/dts/exynos5250.dtsi
index ed8c8dd..cbe31a1 100644
--- a/arch/arm/dts/exynos5250.dtsi
+++ b/arch/arm/dts/exynos5250.dtsi
@@ -18,6 +18,7 @@
*/
/include/ "skeleton.dtsi"
+/include/ "exynos5250-pinctrl.dtsi"
/ {
compatible = "samsung,exynos5250";
@@ -27,6 +28,10 @@
reg = <0x12250000 0x20>;
#address-cells = <1>;
#size-cells = <0>;
+ samsung,pinctrl-names = "srom-cs1",
+ "srom-ebi-enable",
+ "srom-ebi-addr-lines",
+ "srom-ebi-data-lines";
};
i2c@12c60000 {
@@ -35,6 +40,7 @@
compatible = "samsung,s3c2440-i2c";
reg = <0x12C60000 0x100>;
interrupts = <0 56 0>;
+ samsung,pinctrl-names = "i2c0-bus";
};
i2c@12c70000 {
@@ -43,6 +49,7 @@
compatible = "samsung,s3c2440-i2c";
reg = <0x12C70000 0x100>;
interrupts = <0 57 0>;
+ samsung,pinctrl-names = "i2c1-bus";
};
i2c@12c80000 {
@@ -51,6 +58,7 @@
compatible = "samsung,s3c2440-i2c";
reg = <0x12C80000 0x100>;
interrupts = <0 58 0>;
+ samsung,pinctrl-names = "i2c2-bus";
};
i2c@12c90000 {
@@ -59,6 +67,7 @@
compatible = "samsung,s3c2440-i2c";
reg = <0x12C90000 0x100>;
interrupts = <0 59 0>;
+ samsung,pinctrl-names = "i2c3-bus";
};
i2c@12ca0000 {
@@ -67,6 +76,7 @@
compatible = "samsung,s3c2440-i2c";
reg = <0x12CA0000 0x100>;
interrupts = <0 60 0>;
+ samsung,pinctrl-names = "i2c4-bus";
};
i2c@12cb0000 {
@@ -75,6 +85,7 @@
compatible = "samsung,s3c2440-i2c";
reg = <0x12CB0000 0x100>;
interrupts = <0 61 0>;
+ samsung,pinctrl-names = "i2c5-bus";
};
i2c@12cc0000 {
@@ -83,6 +94,7 @@
compatible = "samsung,s3c2440-i2c";
reg = <0x12CC0000 0x100>;
interrupts = <0 62 0>;
+ samsung,pinctrl-names = "i2c6-bus";
};
i2c@12cd0000 {
@@ -91,6 +103,7 @@
compatible = "samsung,s3c2440-i2c";
reg = <0x12CD0000 0x100>;
interrupts = <0 63 0>;
+ samsung,pinctrl-names = "i2c7-bus";
};
sound@12d60000 {
@@ -104,6 +117,7 @@
compatible = "samsung,exynos-spi";
reg = <0x12d20000 0x30>;
interrupts = <0 68 0>;
+ samsung,pinctrl-names = "spi0-bus";
};
spi@12d30000 {
@@ -112,6 +126,7 @@
compatible = "samsung,exynos-spi";
reg = <0x12d30000 0x30>;
interrupts = <0 69 0>;
+ samsung,pinctrl-names = "spi1-bus";
};
spi@12d40000 {
@@ -121,6 +136,7 @@
reg = <0x12d40000 0x30>;
clock-frequency = <50000000>;
interrupts = <0 70 0>;
+ samsung,pinctrl-names = "spi2-bus";
};
spi@131a0000 {
@@ -129,6 +145,7 @@
compatible = "samsung,exynos-spi";
reg = <0x131a0000 0x30>;
interrupts = <0 129 0>;
+ samsung,pinctrl-names = "spi3-bus";
};
spi@131b0000 {
@@ -137,6 +154,7 @@
compatible = "samsung,exynos-spi";
reg = <0x131b0000 0x30>;
interrupts = <0 130 0>;
+ samsung,pinctrl-names = "spi4-bus";
};
ehci@12110000 {
@@ -151,4 +169,78 @@
};
};
+ serial@12C00000 {
+ compatible = "samsung,exynos-uart";
+ reg = <0x12C00000 0x100>;
+ samsung,pinctrl-names = "uart0-data",
+ "uart0-fctl";
+ };
+
+ serial@12C10000 {
+ compatible = "samsung,exynos-uart";
+ reg = <0x12C10000 0x100>;
+ samsung,pinctrl-names = "uart1-data",
+ "uart1-fctl";
+ };
+
+ serial@12C20000 {
+ compatible = "samsung,exynos-uart";
+ reg = <0x12C20000 0x100>;
+ samsung,pinctrl-names = "uart2-data",
+ "uart2-fctl";
+ };
+
+ serial@12C30000 {
+ compatible = "samsung,exynos-uart";
+ reg = <0x12C30000 0x100>;
+ samsung,pinctrl-names = "uart3-data";
+ };
+
+ dwmmc@12200000 {
+ compatible = "samsung,exynos-mshc";
+ reg = <0x12200000 0x1000>;
+ samsung,pinctrl-names = "sd0-clk", "sd0-cmd",
+ "sd0-bus-width4",
+ "sd0-bus-width8";
+ };
+
+ dwmmc@12210000 {
+ compatible = "samsung,exynos-mshc";
+ reg = <0x12210000 0x1000>;
+ samsung,pinctrl-names = "sd1-clk", "sd1-cmd",
+ "sd1-bus-width4";
+ };
+
+ dwmmc@12220000 {
+ compatible = "samsung,exynos-mshc";
+ reg = <0x12220000 0x1000>;
+ samsung,pinctrl-names = "sd2-clk", "sd2-cmd",
+ "sd2-bus-width4",
+ "sd2-bus-width8";
+ };
+
+ dwmmc@12230000 {
+ compatible = "samsung,exynos-mshc";
+ reg = <0x12230000 0x1000>;
+ samsung,pinctrl-names = "sd3-clk", "sd3-cmd",
+ "sd3-bus-width4";
+ };
+
+ i2s@03830000 {
+ compatible = "samsung,exynos-i2s";
+ reg = <0x03830000 0x100>;
+ samsung,pinctrl-names = "i2s0";
+ };
+
+ i2s@12d60000 {
+ compatible = "samsung,exynos-i2s";
+ reg = <0x12d60000 0x100>;
+ samsung,pinctrl-names = "i2s1";
+ };
+
+ i2s@12D70000 {
+ compatible = "samsung,exynos-i2s";
+ reg = <0x12D70000 0x100>;
+ samsung,pinctrl-names = "i2s2";
+ };
};
diff --git a/board/samsung/dts/exynos5250-smdk5250.dts b/board/samsung/dts/exynos5250-smdk5250.dts
index cbfab6f..30ba5aa 100644
--- a/board/samsung/dts/exynos5250-smdk5250.dts
+++ b/board/samsung/dts/exynos5250-smdk5250.dts
@@ -30,6 +30,17 @@
spi2 = "/spi@12d40000";
spi3 = "/spi@131a0000";
spi4 = "/spi@131b0000";
+ mshc0 = "/dwmmc@12200000";
+ mshc1 = "/dwmmc@12210000";
+ mshc2 = "/dwmmc@12220000";
+ mshc3 = "/dwmmc@12230000";
+ uart0 = "/serial@12C00000";
+ uart1 = "/serial@12C10000";
+ uart2 = "/serial@12C20000";
+ uart3 = "/serial@12C30000";
+ i2s0 = "/i2s@03830000";
+ i2s1 = "/sound@12d60000";
+ i2s2 = "/i2s@12D70000";
};
sromc@12250000 {
diff --git a/doc/device-tree-bindings/samsung-pinctrl.txt b/doc/device-tree-bindings/samsung-pinctrl.txt
new file mode 100644
index 0000000..708ca45
--- /dev/null
+++ b/doc/device-tree-bindings/samsung-pinctrl.txt
@@ -0,0 +1,253 @@
+Samsung GPIO and Pin Mux/Config controller
+
+Samsung's ARM based SoC's integrates a GPIO and Pin mux/config hardware
+controller. It controls the input/output settings on the available pads/pins
+and also provides ability to multiplex and configure the output of various
+on-chip controllers onto these pads.
+
+Required Properties:
+- compatible: should be one of the following.
+ - "samsung,pinctrl": for Exynos compatible pin-controller.
+
+- reg: Base address of the pin controller hardware module and length of
+ the address space it occupies.
+
+- Pin banks as child nodes: Pin banks of the controller are represented by child
+ nodes of the controller node. Bank name is taken from name of the node. Each
+ bank node must contain following properties:
+
+ - gpio-controller: identifies the node as a gpio controller and pin bank.
+ - #gpio-cells: number of cells in GPIO specifier. Since the generic GPIO
+ binding is used, the amount of cells must be specified as 2. See generic
+ GPIO binding documentation for description of particular cells.
+
+- Pin mux/config groups as child nodes: The pin mux (selecting pin function
+ mode) and pin config (pull up/down, driver strength) settings are represented
+ as child nodes of the pin-controller node. There should be atleast one
+ child node and there is no limit on the count of these child nodes.
+
+ The child node should contain a list of pin(s) on which a particular pin
+ function selection or pin configuration (or both) have to applied. This
+ list of pins is specified using the property name "samsung,pins". There
+ should be atleast one pin specfied for this property and there is no upper
+ limit on the count of pins that can be specified. The pins are specified
+ using pin names which are derived from the hardware manual of the SoC. As
+ an example, the pins in GPA0 bank of the pin controller can be represented
+ as "gpa0-0", "gpa0-1", "gpa0-2" and so on. The names should be in lower case.
+ The format of the pin names should be (as per the hardware manual)
+ "[pin bank name]-[pin number within the bank]".
+
+ The pin function selection that should be applied on the pins listed in the
+ child node is specified using the "samsung,pin-function" property. The value
+ of this property that should be applied to each of the pins listed in the
+ "samsung,pins" property should be picked from the hardware manual of the SoC
+ for the specified pin group. This property is optional in the child node if
+ no specific function selection is desired for the pins listed in the child
+ node. The value of this property is used as-is to program the pin-controller
+ function selector register of the pin-bank.
+
+ The child node can also optionally specify one or more of the pin
+ configuration that should be applied on all the pins listed in the
+ "samsung,pins" property of the child node. The following pin configuration
+ properties are supported.
+
+ - samsung,pin-pud: Pull up/down configuration.
+ - samsung,pin-drv: Drive strength configuration.
+ - samsung,pin-pud-pdn: Pull up/down configuration in power down mode.
+ - samsung,pin-drv-pdn: Drive strength configuration in power down mode.
+
+ The values specified by these config properties should be derived from the
+ hardware manual and these values are programmed as-is into the pin
+ pull up/down and driver strength register of the pin-controller.
+
+ Note: A child should include atleast a pin function selection property or
+ pin configuration property (one or more) or both.
+
+ The client nodes that require a particular pin function selection and/or
+ pin configuration should use the bindings listed in the "pinctrl-bindings.txt"
+ file.
+
+External GPIO and Wakeup Interrupts:
+
+The controller supports two types of external interrupts over gpio. The first
+is the external gpio interrupt and second is the external wakeup interrupts.
+The difference between the two is that the external wakeup interrupts can be
+used as system wakeup events.
+
+A. External GPIO Interrupts: For supporting external gpio interrupts, the
+ following properties should be specified in the pin-controller device node.
+
+ - interrupt-parent: phandle of the interrupt parent to which the external
+ GPIO interrupts are forwarded to.
+ - interrupts: interrupt specifier for the controller. The format and value of
+ the interrupt specifier depends on the interrupt parent for the controller.
+
+ In addition, following properties must be present in node of every bank
+ of pins supporting GPIO interrupts:
+
+ - interrupt-controller: identifies the controller node as interrupt-parent.
+ - #interrupt-cells: the value of this property should be 2.
+ - First Cell: represents the external gpio interrupt number local to the
+ external gpio interrupt space of the controller.
+ - Second Cell: flags to identify the type of the interrupt
+ - 1 = rising edge triggered
+ - 2 = falling edge triggered
+ - 3 = rising and falling edge triggered
+ - 4 = high level triggered
+ - 8 = low level triggered
+
+B. External Wakeup Interrupts: For supporting external wakeup interrupts, a
+ child node representing the external wakeup interrupt controller should be
+ included in the pin-controller device node. This child node should include
+ the following properties.
+
+ - compatible: identifies the type of the external wakeup interrupt controller
+ The possible values are:
+ - samsung,wakeup-eint: represents wakeup interrupt controller
+ found on Samsung Exynos SoC.
+ - interrupt-parent: phandle of the interrupt parent to which the external
+ wakeup interrupts are forwarded to.
+ - interrupts: interrupt used by multiplexed wakeup interrupts.
+
+ In addition, following properties must be present in node of every bank
+ of pins supporting wake-up interrupts:
+
+ - interrupt-controller: identifies the node as interrupt-parent.
+ - #interrupt-cells: the value of this property should be 2
+ - First Cell: represents the external wakeup interrupt number local to
+ the external wakeup interrupt space of the controller.
+ - Second Cell: flags to identify the type of the interrupt
+ - 1 = rising edge triggered
+ - 2 = falling edge triggered
+ - 3 = rising and falling edge triggered
+ - 4 = high level triggered
+ - 8 = low level triggered
+
+ Node of every bank of pins supporting direct wake-up interrupts (without
+ multiplexing) must contain following properties:
+
+ - interrupt-parent: phandle of the interrupt parent to which the external
+ wakeup interrupts are forwarded to.
+ - interrupts: interrupts of the interrupt parent which are used for external
+ wakeup interrupts from pins of the bank, must contain interrupts for all
+ pins of the bank.
+
+Aliases:
+
+All the pin controller nodes should be represented in the aliases node using
+the following format 'pinctrl{n}' where n is a unique number for the alias.
+
+Example: A pin-controller node with pin banks:
+
+ pinctrl_0: pinctrl@11400000 {
+ compatible = "samsung,pinctrl;
+ reg = <0x11400000 0x1000>;
+ interrupts = <0 47 0>;
+
+ /* ... */
+
+ /* Pin bank without external interrupts */
+ gpy0: gpy0 {
+ gpio-controller;
+ #gpio-cells = <2>;
+ };
+
+ /* ... */
+
+ /* Pin bank with external GPIO or muxed wake-up interrupts */
+ gpj0: gpj0 {
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
+
+ /* ... */
+
+ /* Pin bank with external direct wake-up interrupts */
+ gpx0: gpx0 {
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ interrupt-controller;
+ interrupt-parent = <&gic>;
+ interrupts = <0 16 0>, <0 17 0>, <0 18 0>, <0 19 0>,
+ <0 20 0>, <0 21 0>, <0 22 0>, <0 23 0>;
+ #interrupt-cells = <2>;
+ };
+
+ /* ... */
+ };
+
+Example 1: A pin-controller node with pin groups.
+
+ pinctrl_0: pinctrl@11400000 {
+ compatible = "samsung,pinctrl";
+ reg = <0x11400000 0x1000>;
+ interrupts = <0 47 0>;
+
+ /* ... */
+
+ uart0_data: uart0-data {
+ samsung,pins = "gpa0-0", "gpa0-1";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <0>;
+ samsung,pin-drv = <0>;
+ };
+
+ uart0_fctl: uart0-fctl {
+ samsung,pins = "gpa0-2", "gpa0-3";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <0>;
+ samsung,pin-drv = <0>;
+ };
+
+ uart1_data: uart1-data {
+ samsung,pins = "gpa0-4", "gpa0-5";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <0>;
+ samsung,pin-drv = <0>;
+ };
+
+ uart1_fctl: uart1-fctl {
+ samsung,pins = "gpa0-6", "gpa0-7";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <0>;
+ samsung,pin-drv = <0>;
+ };
+
+ i2c2_bus: i2c2-bus {
+ samsung,pins = "gpa0-6", "gpa0-7";
+ samsung,pin-function = <3>;
+ samsung,pin-pud = <3>;
+ samsung,pin-drv = <0>;
+ };
+ };
+
+Example 2: A pin-controller node with external wakeup interrupt controller node.
+
+ pinctrl_1: pinctrl@11000000 {
+ compatible = "samsung,pinctrl";
+ reg = <0x11000000 0x1000>;
+ interrupts = <0 46 0>
+
+ /* ... */
+
+ wakeup-interrupt-controller {
+ compatible = "samsung,wakeup-eint";
+ interrupt-parent = <&gic>;
+ interrupts = <0 32 0>;
+ };
+ };
+
+Example 3: A uart client node that supports 'default' and 'flow-control' states.
+
+ uart@13800000 {
+ compatible = "samsung,uart";
+ reg = <0x13800000 0x100>;
+ interrupts = <0 52 0>;
+ pinctrl-names = "default", "flow-control;
+ pinctrl-0 = <&uart0_data>;
+ pinctrl-1 = <&uart0_data &uart0_fctl>;
+ };
diff --git a/include/fdtdec.h b/include/fdtdec.h
index 77f244f..26692e5 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -81,6 +81,10 @@ enum fdt_compat_id {
COMPAT_SAMSUNG_EXYNOS_EHCI, /* Exynos EHCI controller */
COMPAT_SAMSUNG_EXYNOS_USB_PHY, /* Exynos phy controller for usb2.0 */
COMPAT_MAXIM_MAX77686_PMIC, /* MAX77686 PMIC */
+ COMPAT_SAMSUNG_EXYNOS_UART, /* Exynos serial */
+ COMPAT_SAMSUNG_EXYNOS_MSHC, /* Exynos MMC controller */
+ COMPAT_SAMSUNG_EXYNOS_I2S, /* Exynos MMC controller */
+ COMPAT_SAMSUNG_PINCTRL, /* PINCTRL */
COMPAT_COUNT,
};
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 3ae348d..88dd669 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -56,6 +56,10 @@ static const char * const compat_names[COMPAT_COUNT] = {
COMPAT(SAMSUNG_EXYNOS_EHCI, "samsung,exynos-ehci"),
COMPAT(SAMSUNG_EXYNOS_USB_PHY, "samsung,exynos-usb-phy"),
COMPAT(MAXIM_MAX77686_PMIC, "maxim,max77686_pmic"),
+ COMPAT(SAMSUNG_EXYNOS_UART, "samsung,exynos-uart"),
+ COMPAT(SAMSUNG_EXYNOS_MSHC, "samsung,exynos-mshc"),
+ COMPAT(SAMSUNG_EXYNOS_I2S, "samsung,exynos-i2s"),
+ COMPAT(SAMSUNG_PINCTRL, "samsung,pinctrl"),
};
const char *fdtdec_get_compatible(enum fdt_compat_id id)
--
1.8.0
2
1
This patch set tries to gain some space in spl by
restructuring and reorganising some code in two different
clock init's for two different times of execution.
Compiler arm-2011.09:
With patches u-boot-spl.bin size - 3900 bytes.
Without patches u-boot-spl.bin size - 4924 bytes.
Compiler arm-2009q3:
With patches u-boot-spl.bin size - 4412 bytes.
Without patches u-boot-spl.bin size - 5692 bytes.
Changes since v1:
- Patch1: Rebased on ToT.
- Patch2: Rebased on ToT.
Changes since v2:
- Patch1:
- Replaced non_spl_clock_div with clock_div.
- Replaced ns_clk_div with clk_div.
- Added few new comments.
- Modified few comments.
- Patch2: None.
Akshay Saraswat (2):
Exynos5: spl: Reorganize mem_timing struct to gain space in spl
Exynos5: spl: Reduce clock init in spl
board/samsung/smdk5250/Makefile | 3 +-
board/samsung/smdk5250/clock_init.c | 493 +-------------------------------
board/samsung/smdk5250/clock_init.h | 76 +++--
board/samsung/smdk5250/dmc_common.c | 40 +--
board/samsung/smdk5250/dmc_init_ddr3.c | 116 ++++----
board/samsung/smdk5250/lowlevel_init.S | 4 +-
board/samsung/smdk5250/setup.h | 16 +-
board/samsung/smdk5250/smdk5250.c | 4 +
board/samsung/smdk5250/spl_clock_init.c | 469 ++++++++++++++++++++++++++++++
9 files changed, 641 insertions(+), 580 deletions(-)
create mode 100644 board/samsung/smdk5250/spl_clock_init.c
--
1.8.0
2
3