[PATCH] integrate CFI Flash driver into mtd

2013-02-15 Thread Sascha Hauer
This is some general mtd cleanup and the integration of the CFI
Flash driver into mtd. Background is that current ubiformat
implementation relies on the mtd API.

First the mtd_read/write and friends we currently have are renamed
to libmtd_*, because they implement the functions from libmtd.
Then our internal mtd_read/write functions are renamed to mtd_op_*
because they implement the file_operations. Then we finally have
our namespace clean and can implement mtd_read/write as global
(kernel compatible) functions.
We currently miss the mtd_(un)lock functions needed for CFI
flash.
With this in place the final patch integrates the CFI driver into
mtd.

Sascha


Sascha Hauer (6):
  libmtd: rename functions from mtd_* to libmtd_*
  mtd: rename mtd file operations callback functions
  mtd: Add mtd_* functions
  mtd: Use mtd_* functions where appropriate
  mtd: implement mtd_lock and mtd_unlock
  nor flash: integrate into mtd

 arch/arm/configs/edb93xx_defconfig|1 +
 arch/arm/configs/eukrea_cpuimx27_defconfig|1 +
 arch/arm/configs/freescale_mx51_babbage_defconfig |1 +
 arch/arm/configs/mmccpu_defconfig |1 +
 arch/arm/configs/mx21ads_defconfig|1 +
 arch/arm/configs/mx27ads_defconfig|1 +
 arch/arm/configs/netx_nxdb500_defconfig   |1 +
 arch/arm/configs/pcm027_defconfig |1 +
 arch/arm/configs/pm9263_defconfig |1 +
 arch/arm/configs/scb9328_defconfig|1 +
 arch/blackfin/configs/ipe337_defconfig|1 +
 arch/nios2/configs/generic_defconfig  |1 +
 arch/ppc/configs/pcm030_defconfig |1 +
 commands/ubiformat.c  |8 +-
 drivers/Kconfig   |1 -
 drivers/Makefile  |1 -
 drivers/mtd/Kconfig   |1 +
 drivers/mtd/Makefile  |1 +
 drivers/mtd/core.c|  111 +
 drivers/mtd/mtdraw.c  |2 +-
 drivers/mtd/nand/nand_bbt.c   |4 +-
 drivers/{ = mtd}/nor/Kconfig |6 +-
 drivers/{ = mtd}/nor/Makefile|0
 drivers/{ = mtd}/nor/cfi_flash.c |   82 ---
 drivers/{ = mtd}/nor/cfi_flash.h |1 -
 drivers/{ = mtd}/nor/cfi_flash_amd.c |0
 drivers/{ = mtd}/nor/cfi_flash_intel.c   |0
 drivers/mtd/ubi/io.c  |8 +-
 include/linux/mtd/mtd.h   |9 ++
 include/mtd/libmtd.h  |8 +-
 lib/libmtd.c  |   14 +--
 lib/libscan.c |2 +-
 32 files changed, 157 insertions(+), 115 deletions(-)
 rename drivers/{ = mtd}/nor/Kconfig (96%)
 rename drivers/{ = mtd}/nor/Makefile (100%)
 rename drivers/{ = mtd}/nor/cfi_flash.c (93%)
 rename drivers/{ = mtd}/nor/cfi_flash.h (99%)
 rename drivers/{ = mtd}/nor/cfi_flash_amd.c (100%)
 rename drivers/{ = mtd}/nor/cfi_flash_intel.c (100%)

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 5/6] mtd: implement mtd_lock and mtd_unlock

2013-02-15 Thread Sascha Hauer
Needed for NOR flashes.

Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
---
 drivers/mtd/core.c  |   37 +
 include/linux/mtd/mtd.h |2 ++
 2 files changed, 39 insertions(+)

diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c
index e852fb6..4ddf9d1 100644
--- a/drivers/mtd/core.c
+++ b/drivers/mtd/core.c
@@ -95,6 +95,20 @@ static int mtd_op_erase(struct cdev *cdev, size_t count, 
loff_t offset)
 
return 0;
 }
+
+static ssize_t mtd_op_protect(struct cdev *cdev, size_t count, loff_t offset, 
int prot)
+{
+   struct mtd_info *mtd = cdev-priv;
+
+   if (!mtd-unlock || !mtd-lock)
+   return -ENOSYS;
+
+   if (prot)
+   return mtd_lock(mtd, offset, count);
+   else
+   return mtd_unlock(mtd, offset, count);
+}
+
 #endif /* CONFIG_MTD_WRITE */
 
 int mtd_ioctl(struct cdev *cdev, int request, void *buf)
@@ -161,6 +175,28 @@ int mtd_ioctl(struct cdev *cdev, int request, void *buf)
return ret;
 }
 
+int mtd_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
+{
+   if (!mtd-lock)
+   return -EOPNOTSUPP;
+   if (ofs  0 || ofs  mtd-size || len  mtd-size - ofs)
+   return -EINVAL;
+   if (!len)
+   return 0;
+   return mtd-lock(mtd, ofs, len);
+}
+
+int mtd_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
+{
+   if (!mtd-unlock)
+   return -EOPNOTSUPP;
+   if (ofs  0 || ofs  mtd-size || len  mtd-size - ofs)
+   return -EINVAL;
+   if (!len)
+   return 0;
+   return mtd-unlock(mtd, ofs, len);
+}
+
 int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs)
 {
if (!mtd-block_isbad)
@@ -206,6 +242,7 @@ static struct file_operations mtd_ops = {
 #ifdef CONFIG_MTD_WRITE
.write  = mtd_op_write,
.erase  = mtd_op_erase,
+   .protect = mtd_op_protect,
 #endif
.ioctl  = mtd_ioctl,
.lseek  = dev_lseek_default,
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index c1760de..3892bed 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -257,6 +257,8 @@ static inline void mtd_erase_callback(struct erase_info 
*instr)
 }
 #endif
 
+int mtd_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
+int mtd_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
 int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs);
 int mtd_block_markbad(struct mtd_info *mtd, loff_t ofs);
 
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 2/6] mtd: rename mtd file operations callback functions

2013-02-15 Thread Sascha Hauer
These are currently named mtd_read/write/erase. Functions with
the same name exist as global functions in the kernel. Rename
them to mtd_op_* to avoid name clashes with future mtd updates.

Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
---
 drivers/mtd/core.c |   17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c
index 070fda6..40c522f 100644
--- a/drivers/mtd/core.c
+++ b/drivers/mtd/core.c
@@ -39,7 +39,7 @@ int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs)
return mtd-block_isbad(mtd, ofs);
 }
 
-static ssize_t mtd_read(struct cdev *cdev, void* buf, size_t count,
+static ssize_t mtd_op_read(struct cdev *cdev, void* buf, size_t count,
  loff_t _offset, ulong flags)
 {
struct mtd_info *mtd = cdev-priv;
@@ -47,7 +47,8 @@ staticssize_t mtd_read(struct cdev *cdev, void* buf, 
size_t count,
int ret;
unsigned long offset = _offset;
 
-   debug(mtd_read: 0x%08lx 0x%08x\n, offset, count);
+   dev_dbg(cdev-dev, read ofs: 0x%08lx count: 0x%08x\n,
+   offset, count);
 
ret = mtd-read(mtd, offset, count, retlen, buf);
 
@@ -62,7 +63,7 @@ staticssize_t mtd_read(struct cdev *cdev, void* buf, 
size_t count,
 #define MTDPGALG(x) ((x)  ~(mtd-writesize - 1))
 
 #ifdef CONFIG_MTD_WRITE
-static ssize_t mtd_write(struct cdev* cdev, const void *buf, size_t _count,
+static ssize_t mtd_op_write(struct cdev* cdev, const void *buf, size_t _count,
  loff_t _offset, ulong flags)
 {
struct mtd_info *mtd = cdev-priv;
@@ -74,7 +75,7 @@ static ssize_t mtd_write(struct cdev* cdev, const void *buf, 
size_t _count,
return ret ? ret : _count;
 }
 
-static int mtd_erase(struct cdev *cdev, size_t count, loff_t offset)
+static int mtd_op_erase(struct cdev *cdev, size_t count, loff_t offset)
 {
struct mtd_info *mtd = cdev-priv;
struct erase_info erase;
@@ -130,7 +131,7 @@ int mtd_ioctl(struct cdev *cdev, int request, void *buf)
ret = mtd-block_markbad(mtd, *offset);
break;
case MEMERASE:
-   ret = mtd_erase(cdev, ei-length, ei-start + cdev-offset);
+   ret = mtd_op_erase(cdev, ei-length, ei-start + cdev-offset);
break;
 #endif
case MEMGETINFO:
@@ -170,10 +171,10 @@ int mtd_ioctl(struct cdev *cdev, int request, void *buf)
 }
 
 static struct file_operations mtd_ops = {
-   .read   = mtd_read,
+   .read   = mtd_op_read,
 #ifdef CONFIG_MTD_WRITE
-   .write  = mtd_write,
-   .erase  = mtd_erase,
+   .write  = mtd_op_write,
+   .erase  = mtd_op_erase,
 #endif
.ioctl  = mtd_ioctl,
.lseek  = dev_lseek_default,
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 3/6] mtd: Add mtd_* functions

2013-02-15 Thread Sascha Hauer
The Kernel has mtd_read, mtd_write, mtd_erase and mtd_block_markbad.
Add these functions to barebox aswell to make future mtd synchronizations
with the kernel easier.

Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
---
 drivers/mtd/core.c  |   49 ++-
 include/linux/mtd/mtd.h |7 +++
 2 files changed, 47 insertions(+), 9 deletions(-)

diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c
index 40c522f..47c0226 100644
--- a/drivers/mtd/core.c
+++ b/drivers/mtd/core.c
@@ -30,15 +30,6 @@
 
 static LIST_HEAD(mtd_register_hooks);
 
-int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs)
-{
-   if (!mtd-block_isbad)
-   return 0;
-   if (ofs  0 || ofs  mtd-size)
-   return -EINVAL;
-   return mtd-block_isbad(mtd, ofs);
-}
-
 static ssize_t mtd_op_read(struct cdev *cdev, void* buf, size_t count,
  loff_t _offset, ulong flags)
 {
@@ -170,6 +161,46 @@ int mtd_ioctl(struct cdev *cdev, int request, void *buf)
return ret;
 }
 
+int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs)
+{
+   if (!mtd-block_isbad)
+   return 0;
+
+   if (ofs  0 || ofs  mtd-size)
+   return -EINVAL;
+
+   return mtd-block_isbad(mtd, ofs);
+}
+
+int mtd_block_markbad(struct mtd_info *mtd, loff_t ofs)
+{
+   int ret;
+
+   if (mtd-block_markbad)
+   ret = mtd-block_markbad(mtd, ofs);
+   else
+   ret = -ENOSYS;
+
+   return ret;
+}
+
+int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
+   u_char *buf)
+{
+   return mtd-read(mtd, from, len, retlen, buf);
+}
+
+int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
+   const u_char *buf)
+{
+   return mtd-write(mtd, to, len, retlen, buf);
+}
+
+int mtd_erase(struct mtd_info *mtd, struct erase_info *instr)
+{
+   return mtd-erase(mtd, instr);
+}
+
 static struct file_operations mtd_ops = {
.read   = mtd_op_read,
 #ifdef CONFIG_MTD_WRITE
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index cb8b3bc..c1760de 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -207,6 +207,12 @@ struct mtd_info {
char *size_str;
 };
 
+int mtd_erase(struct mtd_info *mtd, struct erase_info *instr);
+int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
+u_char *buf);
+int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
+ const u_char *buf);
+
 static inline uint32_t mtd_div_by_eb(uint64_t sz, struct mtd_info *mtd)
 {
do_div(sz, mtd-erasesize);
@@ -252,6 +258,7 @@ static inline void mtd_erase_callback(struct erase_info 
*instr)
 #endif
 
 int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs);
+int mtd_block_markbad(struct mtd_info *mtd, loff_t ofs);
 
 /*
  * Debugging macro and defines
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] Add missing SZ_xx defines

2013-02-15 Thread Sascha Hauer
On Thu, Feb 14, 2013 at 01:59:22PM +0400, Alexander Shiyan wrote:
 
 Signed-off-by: Alexander Shiyan shc_w...@mail.ru
 ---
  include/sizes.h |   12 
  1 files changed, 12 insertions(+), 0 deletions(-)
 
 diff --git a/include/sizes.h b/include/sizes.h
 index c47f906..321d40c 100644
 --- a/include/sizes.h
 +++ b/include/sizes.h
 @@ -17,7 +17,19 @@
  #define __sizes_h1
  
  /* handy sizes */
 +#define SZ_1 0x0001
 +#define SZ_2 0x0002
 +#define SZ_4 0x0004
 +#define SZ_8 0x0008
 +#define SZ_160x0010
 +#define SZ_320x8020

There is a tiny bug in the line above, can you find it? ;)

Fixed this. Reported-by: Steffen Trumtrar, who seems to have good eyes.

Sascha

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 2/5] filetype: add GPT support

2013-02-15 Thread Sascha Hauer
On Thu, Feb 14, 2013 at 11:44:30PM +0100, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
 GPT need to be check before MBR
 
 Cc: Rob Herring rob.herr...@calxeda.com
 Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
 ---
  common/filetype.c  |   47 +++
  include/filetype.h |1 +
  2 files changed, 48 insertions(+)
 
 diff --git a/common/filetype.c b/common/filetype.c
 index 22fc621..a685ea5 100644
 --- a/common/filetype.c
 +++ b/common/filetype.c
 @@ -48,6 +48,7 @@ static const struct filetype_str filetype_str[] = {
   [filetype_bmp] = { BMP image, bmp },
   [filetype_png] = { PNG image, png },
   [filetype_ext] = { ext filesystem, ext },
 + [filetype_gpt] = { GUID Partition Table, gpt },
  };
  
  const char *file_type_to_string(enum filetype f)
 @@ -69,9 +70,52 @@ const char *file_type_to_short_string(enum filetype f)
  #define MBR_StartSector  8   /* MBR: Offset of Starting 
 Sector in Partition Table Entry */
  #define BS_55AA  510 /* Boot sector signature (2) */
  #define MBR_Table446 /* MBR: Partition table offset (2) */
 +#define MBR_partition_size   16  /* MBR: Partition table offset (2) */
  #define BS_FilSysType32  82  /* File system type (1) */
  #define BS_FilSysType54  /* File system type (1) */
  
 +#define MBR_PART_sys_ind 4
 +#define MBR_PART_start_sect  8
 +#define MBR_OSTYPE_EFI_GPT   0xee
 +
 +static inline int pmbr_part_valid(const uint8_t *buf)
 +{
 + if (buf[MBR_PART_sys_ind] == MBR_OSTYPE_EFI_GPT 
 + get_unaligned_le32(buf[MBR_PART_start_sect]) == 1UL) {
 + return 1;
 + }
 +
 + return 0;
 +}
 +
 +/**
 + * is_pmbr_valid(): test Protective MBR for validity
 + * @mbr: pointer to a legacy mbr structure
 + *
 + * Description: Returns 1 if PMBR is valid, 0 otherwise.
 + * Validity depends on two things:
 + *  1) MSDOS signature is in the last two bytes of the MBR
 + *  2) One partition of type 0xEE is found
 + */
 +static int is_gpt_valid(const uint8_t *buf)

The function name doesn't match the description.

Sascha

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] clk-fixed-factor: Using parent flags

2013-02-15 Thread Alexander Shiyan
This patch allow using parent flags for newly created clocks, so if
parent clock, for example, have flag CLK_ALWAYS_ENABLED, we will use it.

Signed-off-by: Alexander Shiyan shc_w...@mail.ru
---
 drivers/clk/clk-fixed-factor.c |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/clk/clk-fixed-factor.c b/drivers/clk/clk-fixed-factor.c
index 52e7c16..56aa63e 100644
--- a/drivers/clk/clk-fixed-factor.c
+++ b/drivers/clk/clk-fixed-factor.c
@@ -43,6 +43,7 @@ struct clk *clk_fixed_factor(const char *name,
const char *parent, unsigned int mult, unsigned int div)
 {
struct clk_fixed_factor *f = xzalloc(sizeof(*f));
+   struct clk *parent_clk;
int ret;
 
f-mult = mult;
@@ -53,6 +54,10 @@ struct clk *clk_fixed_factor(const char *name,
f-clk.parent_names = f-parent;
f-clk.num_parents = 1;
 
+   parent_clk = clk_lookup(parent);
+   if (!IS_ERR(parent_clk))
+   f-clk.flags = parent_clk-flags;
+
ret = clk_register(f-clk);
if (ret) {
free(f);
-- 
1.7.3.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 1/2] at91sam9260/9g20ek: use IS_ENABLED instead of #if/#ifdef

2013-02-15 Thread Fabio Porcedda
Using IS_ENABLED instead of #if/#ifdef the compiler can check
all the code.
Using IS_ENABLED for configuring smc-mode is an optimization,
reduce init.o text from 905 to 877.

Signed-off-by: Fabio Porcedda fabio.porce...@gmail.com
Cc: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 arch/arm/boards/at91sam9260ek/init.c | 19 ++-
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/arch/arm/boards/at91sam9260ek/init.c 
b/arch/arm/boards/at91sam9260ek/init.c
index 06a53f2..bb0025d 100644
--- a/arch/arm/boards/at91sam9260ek/init.c
+++ b/arch/arm/boards/at91sam9260ek/init.c
@@ -37,9 +37,8 @@ static void ek_set_board_type(void)
 {
if (machine_is_at91sam9g20ek()) {
armlinux_set_architecture(MACH_TYPE_AT91SAM9G20EK);
-#ifdef CONFIG_AT91_HAVE_2MMC
-   armlinux_set_revision(HAVE_2MMC);
-#endif
+   if (IS_ENABLED(CONFIG_AT91_HAVE_2MMC))
+   armlinux_set_revision(HAVE_2MMC);
} else {
armlinux_set_architecture(MACH_TYPE_AT91SAM9260EK);
}
@@ -107,10 +106,12 @@ static void ek_add_device_nand(void)
smc = ek_9260_nand_smc_config;
 
/* setup bus-width (8 or 16) */
-   if (nand_pdata.bus_width_16)
+   if (IS_ENABLED(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16)) {
+   nand_pdata.bus_width_16 = 1;
smc-mode |= AT91_SMC_DBW_16;
-   else
+   } else {
smc-mode |= AT91_SMC_DBW_8;
+   }
 
/* configure chip-select 3 (NAND) */
sam9_smc_configure(0, 3, smc);
@@ -209,10 +210,10 @@ static void __init ek_add_led(void)
 {
int i;
 
-#ifdef CONFIG_AT91_HAVE_2MMC
-   leds[0].gpio = AT91_PIN_PB8;
-   leds[1].gpio = AT91_PIN_PB9;
-#endif
+   if (IS_ENABLED(CONFIG_AT91_HAVE_2MMC)) {
+   leds[0].gpio = AT91_PIN_PB8;
+   leds[1].gpio = AT91_PIN_PB9;
+   }
 
for (i = 0; i  ARRAY_SIZE(leds); i++) {
at91_set_gpio_output(leds[i].gpio, leds[i].active_low);
-- 
1.8.1.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 2/2] at91sam9260/9g20ek: remove #ifdef for ek_usb_add_device_mci()

2013-02-15 Thread Fabio Porcedda
Remove #ifdef for ek_usb_add_device_mci() because there is already
the #ifdef inside at91_add_device_mci(), this way the compiler can check
always the code without any penality.

Signed-off-by: Fabio Porcedda fabio.porce...@gmail.com
Cc: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 arch/arm/boards/at91sam9260ek/init.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/arch/arm/boards/at91sam9260ek/init.c 
b/arch/arm/boards/at91sam9260ek/init.c
index bb0025d..e6de72f 100644
--- a/arch/arm/boards/at91sam9260ek/init.c
+++ b/arch/arm/boards/at91sam9260ek/init.c
@@ -158,7 +158,6 @@ static void at91sam9260ek_phy_reset(void)
 /*
  * MCI (SD/MMC)
  */
-#if defined(CONFIG_MCI_ATMEL)
 static struct atmel_mci_platform_data __initdata ek_mci_data = {
.bus_width  = 4,
.slot_b = 1,
@@ -171,9 +170,6 @@ static void ek_usb_add_device_mci(void)
 
at91_add_device_mci(0, ek_mci_data);
 }
-#else
-static void ek_usb_add_device_mci(void) {}
-#endif
 
 /*
  * USB Host port
-- 
1.8.1.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 2/2] at91sam9260/9g20ek: remove #ifdef for ek_usb_add_device_mci()

2013-02-15 Thread Jean-Christophe PLAGNIOL-VILLARD
On 11:41 Fri 15 Feb , Fabio Porcedda wrote:
 Remove #ifdef for ek_usb_add_device_mci() because there is already
 the #ifdef inside at91_add_device_mci(), this way the compiler can check
 always the code without any penality.
 it's not the struct will be keep

 keep the ifdef

Best Regards,
J.

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 1/2] at91sam9260/9g20ek: use IS_ENABLED instead of #if/#ifdef

2013-02-15 Thread Fabio Porcedda
On Fri, Feb 15, 2013 at 11:41 AM, Fabio Porcedda
fabio.porce...@gmail.com wrote:
 Using IS_ENABLED instead of #if/#ifdef the compiler can check
 all the code.
 Using IS_ENABLED for configuring smc-mode is an optimization,
 reduce init.o text from 905 to 877.

 Signed-off-by: Fabio Porcedda fabio.porce...@gmail.com
 Cc: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
 ---
  arch/arm/boards/at91sam9260ek/init.c | 19 ++-
  1 file changed, 10 insertions(+), 9 deletions(-)

 diff --git a/arch/arm/boards/at91sam9260ek/init.c 
 b/arch/arm/boards/at91sam9260ek/init.c
 index 06a53f2..bb0025d 100644
 --- a/arch/arm/boards/at91sam9260ek/init.c
 +++ b/arch/arm/boards/at91sam9260ek/init.c
 @@ -37,9 +37,8 @@ static void ek_set_board_type(void)
  {
 if (machine_is_at91sam9g20ek()) {
 armlinux_set_architecture(MACH_TYPE_AT91SAM9G20EK);
 -#ifdef CONFIG_AT91_HAVE_2MMC
 -   armlinux_set_revision(HAVE_2MMC);
 -#endif
 +   if (IS_ENABLED(CONFIG_AT91_HAVE_2MMC))
 +   armlinux_set_revision(HAVE_2MMC);
 } else {
 armlinux_set_architecture(MACH_TYPE_AT91SAM9260EK);
 }
 @@ -107,10 +106,12 @@ static void ek_add_device_nand(void)
 smc = ek_9260_nand_smc_config;

 /* setup bus-width (8 or 16) */
 -   if (nand_pdata.bus_width_16)
 +   if (IS_ENABLED(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16)) {
 +   nand_pdata.bus_width_16 = 1;
 smc-mode |= AT91_SMC_DBW_16;
 -   else
 +   } else {
 smc-mode |= AT91_SMC_DBW_8;
 +   }

I will push a v2 because the nand_pdata.bus_width_16 must be removed
in the struct definition.


 /* configure chip-select 3 (NAND) */
 sam9_smc_configure(0, 3, smc);
 @@ -209,10 +210,10 @@ static void __init ek_add_led(void)
  {
 int i;

 -#ifdef CONFIG_AT91_HAVE_2MMC
 -   leds[0].gpio = AT91_PIN_PB8;
 -   leds[1].gpio = AT91_PIN_PB9;
 -#endif
 +   if (IS_ENABLED(CONFIG_AT91_HAVE_2MMC)) {
 +   leds[0].gpio = AT91_PIN_PB8;
 +   leds[1].gpio = AT91_PIN_PB9;
 +   }

 for (i = 0; i  ARRAY_SIZE(leds); i++) {
 at91_set_gpio_output(leds[i].gpio, leds[i].active_low);
 --
 1.8.1.1




--
Fabio Porcedda

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 2/5] filetype: add GPT support

2013-02-15 Thread Jean-Christophe PLAGNIOL-VILLARD
On 08:43 Fri 15 Feb , Johannes Stezenbach wrote:
 On Thu, Feb 14, 2013 at 11:08:55PM +0100, Jean-Christophe PLAGNIOL-VILLARD 
 wrote:
  On 20:17 Thu 14 Feb , Sascha Hauer wrote:
   On Thu, Feb 14, 2013 at 06:05:07PM +0100, Johannes Stezenbach wrote:
On Thu, Feb 14, 2013 at 05:53:23PM +0100, Jean-Christophe 
PLAGNIOL-VILLARD wrote:
 On 17:36 Thu 14 Feb , Sascha Hauer wrote:
  On Thu, Feb 14, 2013 at 04:52:24PM +0100, Jean-Christophe 
  PLAGNIOL-VILLARD wrote:
   GPT need to be check before MBR
 ...
   + if (bufsize = 520  strncmp(buf8[512], EFI PART, 8) == 0)
   + return filetype_gpt;
   +
  
  The list is sorted by size, so please move this below:
 on purpose
 
 EFI need to be detect before mbr

IMHO the check is too simple, it will give false positive if
GPT is replaced by DOS MBR and not zeroed out.  Need to check
for protective MBR.
   
   So is_fat_or_mbr() should test if the MBR is a protective MBR and return
   false in this case?
  
  no as the efi is more I do the check in efi.c protective bit and right type
  
  I move the code to filetype
  
  but efi need to be before MBR as you could have both for retro compatibility
 
 Yes, Wikipedia says Apple Bootcamp creates hybrid MBR.
 But if you run fdisk to create DOS MBR it will only
 replace the first sector and leave the GPT alone.
 Thus I think for usability it is important to check MBR
 (for 0xAA55 marker and one of the part types must be 0xee).
Do not take Wikipedia for the bible

We implemenb the EFI spec

Best Regards,
J.
 
 Johannes

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 2/2] at91sam9260/9g20ek: remove #ifdef for ek_usb_add_device_mci()

2013-02-15 Thread Fabio Porcedda
On Fri, Feb 15, 2013 at 11:44 AM, Jean-Christophe PLAGNIOL-VILLARD
plagn...@jcrosoft.com wrote:
 On 11:41 Fri 15 Feb , Fabio Porcedda wrote:
 Remove #ifdef for ek_usb_add_device_mci() because there is already
 the #ifdef inside at91_add_device_mci(), this way the compiler can check
 always the code without any penality.
  it's not the struct will be keep

The struct isn't keep
without this patch:
  text   databssdechexfilename
877192  0   106942d
arch/arm/boards/at91sam9260ek/init.o
with this patch:
 text   databssdechexfilename
877192  0   106942d
arch/arm/boards/at91sam9260ek/init.o

  keep the ifdef
 Best Regards,
 J.

Best regards
--
Fabio Porcedda

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 2/5] filetype: add GPT support

2013-02-15 Thread Sascha Hauer
On Fri, Feb 15, 2013 at 11:45:26AM +0100, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
 On 10:00 Fri 15 Feb , Sascha Hauer wrote:
  On Thu, Feb 14, 2013 at 11:44:30PM +0100, Jean-Christophe PLAGNIOL-VILLARD 
  wrote:
   GPT need to be check before MBR
   
   Cc: Rob Herring rob.herr...@calxeda.com
   Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
   ---
common/filetype.c  |   47 +++
include/filetype.h |1 +
2 files changed, 48 insertions(+)
   
   diff --git a/common/filetype.c b/common/filetype.c
   index 22fc621..a685ea5 100644
   --- a/common/filetype.c
   +++ b/common/filetype.c
   @@ -48,6 +48,7 @@ static const struct filetype_str filetype_str[] = {
 [filetype_bmp] = { BMP image, bmp },
 [filetype_png] = { PNG image, png },
 [filetype_ext] = { ext filesystem, ext },
   + [filetype_gpt] = { GUID Partition Table, gpt },
};

const char *file_type_to_string(enum filetype f)
   @@ -69,9 +70,52 @@ const char *file_type_to_short_string(enum filetype f)
#define MBR_StartSector  8   /* MBR: Offset of Starting 
   Sector in Partition Table Entry */
#define BS_55AA  510 /* Boot sector signature (2) */
#define MBR_Table446 /* MBR: Partition table offset 
   (2) */
   +#define MBR_partition_size   16  /* MBR: Partition table offset 
   (2) */
#define BS_FilSysType32  82  /* File system type (1) */
#define BS_FilSysType54  /* File system type (1) */

   +#define MBR_PART_sys_ind 4
   +#define MBR_PART_start_sect  8
   +#define MBR_OSTYPE_EFI_GPT   0xee
   +
   +static inline int pmbr_part_valid(const uint8_t *buf)
   +{
   + if (buf[MBR_PART_sys_ind] == MBR_OSTYPE_EFI_GPT 
   + get_unaligned_le32(buf[MBR_PART_start_sect]) == 1UL) {
   + return 1;
   + }
   +
   + return 0;
   +}
   +
   +/**
   + * is_pmbr_valid(): test Protective MBR for validity
   + * @mbr: pointer to a legacy mbr structure
   + *
   + * Description: Returns 1 if PMBR is valid, 0 otherwise.
   + * Validity depends on two things:
   + *  1) MSDOS signature is in the last two bytes of the MBR
   + *  2) One partition of type 0xEE is found
   + */
   +static int is_gpt_valid(const uint8_t *buf)
  
  The function name doesn't match the description.
 can you fix while applying?

Nope, because I don't know whether the description or the implementation
matches what you intend to do.

Sascha


-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 1/2] at91sam9260/9g20ek: use IS_ENABLED instead of #if/#ifdef

2013-02-15 Thread Fabio Porcedda
Using IS_ENABLED instead of #if/#ifdef the compiler can check
all the code.
Using IS_ENABLED for configuring smc-mode is an optimization,
reduce init.o text from 905 to 877.

Signed-off-by: Fabio Porcedda fabio.porce...@gmail.com
Cc: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 arch/arm/boards/at91sam9260ek/init.c | 24 ++--
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/arch/arm/boards/at91sam9260ek/init.c 
b/arch/arm/boards/at91sam9260ek/init.c
index 06a53f2..5b163b7 100644
--- a/arch/arm/boards/at91sam9260ek/init.c
+++ b/arch/arm/boards/at91sam9260ek/init.c
@@ -37,9 +37,8 @@ static void ek_set_board_type(void)
 {
if (machine_is_at91sam9g20ek()) {
armlinux_set_architecture(MACH_TYPE_AT91SAM9G20EK);
-#ifdef CONFIG_AT91_HAVE_2MMC
-   armlinux_set_revision(HAVE_2MMC);
-#endif
+   if (IS_ENABLED(CONFIG_AT91_HAVE_2MMC))
+   armlinux_set_revision(HAVE_2MMC);
} else {
armlinux_set_architecture(MACH_TYPE_AT91SAM9260EK);
}
@@ -51,11 +50,6 @@ static struct atmel_nand_data nand_pdata = {
.det_pin= -EINVAL,
.rdy_pin= AT91_PIN_PC13,
.enable_pin = AT91_PIN_PC14,
-#if defined(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16)
-   .bus_width_16   = 1,
-#else
-   .bus_width_16   = 0,
-#endif
.on_flash_bbt   = 1,
 };
 
@@ -107,10 +101,12 @@ static void ek_add_device_nand(void)
smc = ek_9260_nand_smc_config;
 
/* setup bus-width (8 or 16) */
-   if (nand_pdata.bus_width_16)
+   if (IS_ENABLED(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16)) {
+   nand_pdata.bus_width_16 = 1;
smc-mode |= AT91_SMC_DBW_16;
-   else
+   } else {
smc-mode |= AT91_SMC_DBW_8;
+   }
 
/* configure chip-select 3 (NAND) */
sam9_smc_configure(0, 3, smc);
@@ -209,10 +205,10 @@ static void __init ek_add_led(void)
 {
int i;
 
-#ifdef CONFIG_AT91_HAVE_2MMC
-   leds[0].gpio = AT91_PIN_PB8;
-   leds[1].gpio = AT91_PIN_PB9;
-#endif
+   if (IS_ENABLED(CONFIG_AT91_HAVE_2MMC)) {
+   leds[0].gpio = AT91_PIN_PB8;
+   leds[1].gpio = AT91_PIN_PB9;
+   }
 
for (i = 0; i  ARRAY_SIZE(leds); i++) {
at91_set_gpio_output(leds[i].gpio, leds[i].active_low);
-- 
1.8.1.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 0/2] at91sam9260/9g20ek: cleanup and optimization

2013-02-15 Thread Fabio Porcedda
Some cleanup and optimization removing #if/#ifdef and using IS_ENABLED.

Best regards

v2:
 - fixed the first patch by removing the #ifdef inside nand_pdata definition.


Fabio Porcedda (2):
  at91sam9260/9g20ek: use IS_ENABLED instead of #if/#ifdef
  at91sam9260/9g20ek: remove #ifdef for ek_usb_add_device_mci()

 arch/arm/boards/at91sam9260ek/init.c | 28 ++--
 1 file changed, 10 insertions(+), 18 deletions(-)

-- 
1.8.1.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 2/2] at91sam9260/9g20ek: remove #ifdef for ek_usb_add_device_mci()

2013-02-15 Thread Fabio Porcedda
Remove #ifdef for ek_usb_add_device_mci() because there is already
the #ifdef inside at91_add_device_mci(), this way the compiler can check
always the code without any penality.

Signed-off-by: Fabio Porcedda fabio.porce...@gmail.com
Cc: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 arch/arm/boards/at91sam9260ek/init.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/arch/arm/boards/at91sam9260ek/init.c 
b/arch/arm/boards/at91sam9260ek/init.c
index 5b163b7..ed4f0dd 100644
--- a/arch/arm/boards/at91sam9260ek/init.c
+++ b/arch/arm/boards/at91sam9260ek/init.c
@@ -153,7 +153,6 @@ static void at91sam9260ek_phy_reset(void)
 /*
  * MCI (SD/MMC)
  */
-#if defined(CONFIG_MCI_ATMEL)
 static struct atmel_mci_platform_data __initdata ek_mci_data = {
.bus_width  = 4,
.slot_b = 1,
@@ -166,9 +165,6 @@ static void ek_usb_add_device_mci(void)
 
at91_add_device_mci(0, ek_mci_data);
 }
-#else
-static void ek_usb_add_device_mci(void) {}
-#endif
 
 /*
  * USB Host port
-- 
1.8.1.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 2/2] at91sam9260/9g20ek: remove #ifdef for ek_usb_add_device_mci()

2013-02-15 Thread Fabio Porcedda
On Fri, Feb 15, 2013 at 11:52 AM, Fabio Porcedda
fabio.porce...@gmail.com wrote:
 On Fri, Feb 15, 2013 at 11:44 AM, Jean-Christophe PLAGNIOL-VILLARD
 plagn...@jcrosoft.com wrote:
 On 11:41 Fri 15 Feb , Fabio Porcedda wrote:
 Remove #ifdef for ek_usb_add_device_mci() because there is already
 the #ifdef inside at91_add_device_mci(), this way the compiler can check
 always the code without any penality.
  it's not the struct will be keep

 The struct isn't keep
 without this patch:
   text   databssdechexfilename
 877192  0   106942d
 arch/arm/boards/at91sam9260ek/init.o
 with this patch:
  text   databssdechexfilename
 877192  0   106942d
 arch/arm/boards/at91sam9260ek/init.o


I'm sorry, you are right, i've made i mistake when checking.

  text   databssdechexfilename
861176  0   103740d
arch/arm/boards/at91sam9260ek/init.o

  text   databssdechexfilename
877192  0   106942d
arch/arm/boards/at91sam9260ek/init.o


  keep the ifdef
 Best Regards,
 J.

 Best regards
 --
 Fabio Porcedda



--
Fabio Porcedda

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v3] at91sam9260/9g20ek: use IS_ENABLED instead of #if/#ifdef

2013-02-15 Thread Fabio Porcedda
Using IS_ENABLED instead of #if/#ifdef the compiler can check
all the code.
Using IS_ENABLED for configuring smc-mode is an optimization,
reduce init.o text from 905 to 877.

Signed-off-by: Fabio Porcedda fabio.porce...@gmail.com
Cc: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
v3:
 - fix second patch using IS_ENABLED to discard the struct.
 - squash them because both use IS_ENABLED in the same way.
v2:
 - fixed the first patch by removing the #ifdef inside nand_pdata definition.

 arch/arm/boards/at91sam9260ek/init.c | 31 +--
 1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/arch/arm/boards/at91sam9260ek/init.c 
b/arch/arm/boards/at91sam9260ek/init.c
index 06a53f2..77ca6bb 100644
--- a/arch/arm/boards/at91sam9260ek/init.c
+++ b/arch/arm/boards/at91sam9260ek/init.c
@@ -37,9 +37,8 @@ static void ek_set_board_type(void)
 {
if (machine_is_at91sam9g20ek()) {
armlinux_set_architecture(MACH_TYPE_AT91SAM9G20EK);
-#ifdef CONFIG_AT91_HAVE_2MMC
-   armlinux_set_revision(HAVE_2MMC);
-#endif
+   if (IS_ENABLED(CONFIG_AT91_HAVE_2MMC))
+   armlinux_set_revision(HAVE_2MMC);
} else {
armlinux_set_architecture(MACH_TYPE_AT91SAM9260EK);
}
@@ -51,11 +50,6 @@ static struct atmel_nand_data nand_pdata = {
.det_pin= -EINVAL,
.rdy_pin= AT91_PIN_PC13,
.enable_pin = AT91_PIN_PC14,
-#if defined(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16)
-   .bus_width_16   = 1,
-#else
-   .bus_width_16   = 0,
-#endif
.on_flash_bbt   = 1,
 };
 
@@ -107,10 +101,12 @@ static void ek_add_device_nand(void)
smc = ek_9260_nand_smc_config;
 
/* setup bus-width (8 or 16) */
-   if (nand_pdata.bus_width_16)
+   if (IS_ENABLED(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16)) {
+   nand_pdata.bus_width_16 = 1;
smc-mode |= AT91_SMC_DBW_16;
-   else
+   } else {
smc-mode |= AT91_SMC_DBW_8;
+   }
 
/* configure chip-select 3 (NAND) */
sam9_smc_configure(0, 3, smc);
@@ -157,7 +153,6 @@ static void at91sam9260ek_phy_reset(void)
 /*
  * MCI (SD/MMC)
  */
-#if defined(CONFIG_MCI_ATMEL)
 static struct atmel_mci_platform_data __initdata ek_mci_data = {
.bus_width  = 4,
.slot_b = 1,
@@ -165,14 +160,14 @@ static struct atmel_mci_platform_data __initdata 
ek_mci_data = {
 
 static void ek_usb_add_device_mci(void)
 {
+   if (!IS_ENABLED(CONFIG_MCI_ATMEL))
+   return;
+
if (machine_is_at91sam9g20ek())
ek_mci_data.detect_pin = AT91_PIN_PC9;
 
at91_add_device_mci(0, ek_mci_data);
 }
-#else
-static void ek_usb_add_device_mci(void) {}
-#endif
 
 /*
  * USB Host port
@@ -209,10 +204,10 @@ static void __init ek_add_led(void)
 {
int i;
 
-#ifdef CONFIG_AT91_HAVE_2MMC
-   leds[0].gpio = AT91_PIN_PB8;
-   leds[1].gpio = AT91_PIN_PB9;
-#endif
+   if (IS_ENABLED(CONFIG_AT91_HAVE_2MMC)) {
+   leds[0].gpio = AT91_PIN_PB8;
+   leds[1].gpio = AT91_PIN_PB9;
+   }
 
for (i = 0; i  ARRAY_SIZE(leds); i++) {
at91_set_gpio_output(leds[i].gpio, leds[i].active_low);
-- 
1.8.1.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] clk-fixed-factor: Using parent flags

2013-02-15 Thread Sascha Hauer
On Fri, Feb 15, 2013 at 02:09:35PM +0400, Alexander Shiyan wrote:
 This patch allow using parent flags for newly created clocks, so if
 parent clock, for example, have flag CLK_ALWAYS_ENABLED, we will use it.
 
 Signed-off-by: Alexander Shiyan shc_w...@mail.ru
 ---
  drivers/clk/clk-fixed-factor.c |5 +
  1 files changed, 5 insertions(+), 0 deletions(-)
 
 diff --git a/drivers/clk/clk-fixed-factor.c b/drivers/clk/clk-fixed-factor.c
 index 52e7c16..56aa63e 100644
 --- a/drivers/clk/clk-fixed-factor.c
 +++ b/drivers/clk/clk-fixed-factor.c
 @@ -43,6 +43,7 @@ struct clk *clk_fixed_factor(const char *name,
   const char *parent, unsigned int mult, unsigned int div)
  {
   struct clk_fixed_factor *f = xzalloc(sizeof(*f));
 + struct clk *parent_clk;
   int ret;
  
   f-mult = mult;
 @@ -53,6 +54,10 @@ struct clk *clk_fixed_factor(const char *name,
   f-clk.parent_names = f-parent;
   f-clk.num_parents = 1;
  
 + parent_clk = clk_lookup(parent);
 + if (!IS_ERR(parent_clk))
 + f-clk.flags = parent_clk-flags;
 +

So we unconditionally overwrite the fixed factor clock flags. As long as
CLK_ALWAYS_ENABLED is the only flag we have this might be ok, but this
will lead to strange behaviour when we get other flags.

There should rather be some mechanism which detects that a clock must be
enabled because all parents have no disable callback or have the
CLK_ALWAYS_ENABLED flag set.

I have no idea currently though how to implement this.

Sascha

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 0/5 v3] add EFI GUID Partition Table support

2013-02-15 Thread Jean-Christophe PLAGNIOL-VILLARD
HI,

v3:
 fix function name

v2:
 fix memory leak
 filetype: full check
 part name: comment
 efi: make gpt primary and alternate check optional

this add the support of the EFI GPT and named partition

The following changes since commit a40e76cebcbe8b025bafdefdc6e27b7553209ed7:

  Add warning above get_ram_size (2013-02-13 18:14:38 +0100)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git delivery/efi_gpt

for you to fetch changes up to c572474854bf97ea8c91ea3602950bd352d9a3b4:

  disk: partitions: add EFI GUID Partition Table (2013-02-14 18:50:16 +0800)


Jean-Christophe PLAGNIOL-VILLARD (5):
  linux/types: import __aligned_x64 from the kernel
  filetype: add GPT support
  partitons: add framework
  disk: introduce partition name
  disk: partitions: add EFI GUID Partition Table

 common/Kconfig |   14 +--
 common/Makefile|2 +-
 common/filetype.c  |   47 +
 common/partitions.c|  187 
+--
 common/partitions/Kconfig  |   32 +++
 common/partitions/Makefile |2 +
 common/partitions/dos.c|   88 +++
 common/partitions/efi.c|  477 
++
 common/partitions/efi.h|  123 
++
 common/partitions/parser.h |   37 +
 include/filetype.h |1 +
 include/linux/efi.h|  547 
+
 include/linux/types.h  |   13 ++
 13 files changed, 1462 insertions(+), 108 deletions(-)
 create mode 100644 common/partitions/Kconfig
 create mode 100644 common/partitions/Makefile
 create mode 100644 common/partitions/dos.c
 create mode 100644 common/partitions/efi.c
 create mode 100644 common/partitions/efi.h
 create mode 100644 common/partitions/parser.h
 create mode 100644 include/linux/efi.h

Best Regards,
J.

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 1/5] linux/types: import __aligned_x64 from the kernel

2013-02-15 Thread Jean-Christophe PLAGNIOL-VILLARD
need it by upcoming EFI GPT support

Cc: Rob Herring rob.herr...@calxeda.com
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 include/linux/types.h |   13 +
 1 file changed, 13 insertions(+)

diff --git a/include/linux/types.h b/include/linux/types.h
index 76c6b67..14f8315 100644
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -142,6 +142,19 @@ typedef __u64 __bitwise __be64;
 typedef __u16 __bitwise __sum16;
 typedef __u32 __bitwise __wsum;
 
+/*
+ * aligned_u64 should be used in defining kernel-userspace ABIs to avoid
+ * common 32/64-bit compat problems.
+ * 64-bit values align to 4-byte boundaries on x86_32 (and possibly other
+ * architectures) and to 8-byte boundaries on 64-bit architectures.  The new
+ * aligned_64 type enforces 8-byte alignment so that structs containing
+ * aligned_64 values have the same alignment on 32-bit and 64-bit 
architectures.
+ * No conversions are necessary between 32-bit user-space and a 64-bit kernel.
+ */
+#define __aligned_u64 __u64 __attribute__((aligned(8)))
+#define __aligned_be64 __be64 __attribute__((aligned(8)))
+#define __aligned_le64 __le64 __attribute__((aligned(8)))
+
 #ifdef CONFIG_PHYS_ADDR_T_64BIT
 typedef u64 phys_addr_t;
 typedef u64 phys_size_t;
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 4/5] disk: introduce partition name

2013-02-15 Thread Jean-Christophe PLAGNIOL-VILLARD
so we can register partion with name as present in EFI GPT

Cc: Rob Herring rob.herr...@calxeda.com
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 common/partitions.c|   54 ++--
 common/partitions/parser.h |2 ++
 2 files changed, 44 insertions(+), 12 deletions(-)

diff --git a/common/partitions.c b/common/partitions.c
index c1578c9..b0f48be 100644
--- a/common/partitions.c
+++ b/common/partitions.c
@@ -44,15 +44,43 @@ LIST_HEAD(partition_parser_list);
 static int register_one_partition(struct block_device *blk,
struct partition *part, int no)
 {
-   char partition_name[19];
+   char *partition_name;
+   int ret;
+   uint64_t start = part-first_sec * SECTOR_SIZE;
+   uint64_t size = part-size * SECTOR_SIZE;
+
+   partition_name = asprintf(%s.%d, blk-cdev.name, no);
+   if (!partition_name)
+   return -ENOMEM;
+   dev_dbg(blk-dev, Registering partition %s on drive %s\n,
+   partition_name, blk-cdev.name);
+   ret = devfs_add_partition(blk-cdev.name,
+   start, size, 0, partition_name);
+   if (ret)
+   goto out;
+
+   free(partition_name);
+
+   if (!part-name[0])
+   return 0;
+
+   partition_name = asprintf(%s.%s, blk-cdev.name, part-name);
+   if (!partition_name)
+   return -ENOMEM;
 
-   sprintf(partition_name, %s.%d, blk-cdev.name, no);
dev_dbg(blk-dev, Registering partition %s on drive %s\n,
partition_name, blk-cdev.name);
-   return devfs_add_partition(blk-cdev.name,
-   part-first_sec * SECTOR_SIZE,
-   part-size * SECTOR_SIZE,
-   0, partition_name);
+   ret = devfs_add_partition(blk-cdev.name,
+   start, size, 0, partition_name);
+
+   if (ret)
+   dev_warn(blk-dev, Registering partition %s on drive %s 
failled\n,
+   partition_name, blk-cdev.name);
+
+   ret = 0;
+out:
+   free(partition_name);
+   return 0;
 }
 
 static struct partition_parser *partition_parser_get_by_filetype(uint8_t *buf)
@@ -91,12 +119,13 @@ static struct partition_parser 
*partition_parser_get_by_filetype(uint8_t *buf)
  */
 int parse_partition_table(struct block_device *blk)
 {
-   struct partition_desc pdesc = { .used_entries = 0, };
+   struct partition_desc *pdesc;
int i;
int rc = 0;
struct partition_parser *parser;
uint8_t *buf;
 
+   pdesc = xzalloc(sizeof(*pdesc));
buf = dma_alloc(SECTOR_SIZE * 2);
 
rc = blk-ops-read(blk, buf, 0, 2);
@@ -109,14 +138,14 @@ int parse_partition_table(struct block_device *blk)
if (!parser)
goto on_error;
 
-   parser-parse(buf, blk, pdesc);
+   parser-parse(buf, blk, pdesc);
 
-   if (!pdesc.used_entries)
-   return 0;
+   if (!pdesc-used_entries)
+   goto on_error;
 
/* at least one partition description found */
-   for (i = 0; i  pdesc.used_entries; i++) {
-   rc = register_one_partition(blk, pdesc.parts[i], i);
+   for (i = 0; i  pdesc-used_entries; i++) {
+   rc = register_one_partition(blk, pdesc-parts[i], i);
if (rc != 0)
dev_err(blk-dev,
Failed to register partition %d on %s (%d)\n,
@@ -127,6 +156,7 @@ int parse_partition_table(struct block_device *blk)
 
 on_error:
dma_free(buf);
+   free(pdesc);
return rc;
 }
 
diff --git a/common/partitions/parser.h b/common/partitions/parser.h
index 13506c0..f5bdbd1 100644
--- a/common/partitions/parser.h
+++ b/common/partitions/parser.h
@@ -12,8 +12,10 @@
 #include linux/list.h
 
 #define MAX_PARTITION  8
+#define MAX_PARTITION_NAME 38
 
 struct partition {
+   char name[MAX_PARTITION_NAME];
uint64_t first_sec;
uint64_t size;
 };
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 3/5] partitons: add framework

2013-02-15 Thread Jean-Christophe PLAGNIOL-VILLARD
so we can support multiple format

use filetpye to detect the parser to use

Cc: Rob Herring rob.herr...@calxeda.com
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 common/Kconfig |   14 +
 common/Makefile|2 +-
 common/partitions.c|  141 +---
 common/partitions/Kconfig  |   13 
 common/partitions/Makefile |1 +
 common/partitions/dos.c|   88 +++
 common/partitions/parser.h |   35 +++
 7 files changed, 194 insertions(+), 100 deletions(-)
 create mode 100644 common/partitions/Kconfig
 create mode 100644 common/partitions/Makefile
 create mode 100644 common/partitions/dos.c
 create mode 100644 common/partitions/parser.h

diff --git a/common/Kconfig b/common/Kconfig
index 3f6c11e..3a55e01 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -478,19 +478,7 @@ config PARTITION
bool
prompt Enable Partitions
 
-config PARTITION_DISK
-   depends on PARTITION
-   bool DISK partition support
-   help
- Add support for handling common partition tables on all kind of disk
- like devices (harddisks, CF cards, SD cards and so on)
-
-config PARTITION_DISK_DOS
-   depends on PARTITION_DISK
-   default y
-   bool DOS partition support
-   help
- Add support to handle partitions in DOS style.
+source common/partitions/Kconfig
 
 config DEFAULT_ENVIRONMENT
bool
diff --git a/common/Makefile b/common/Makefile
index 7206eed..b264cb8 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -7,7 +7,7 @@ obj-$(CONFIG_ENV_HANDLING)  += environment.o
 obj-$(CONFIG_AUTO_COMPLETE)+= complete.o
 obj-$(CONFIG_POLLER)   += poller.o
 obj-$(CONFIG_BLOCK)+= block.o
-obj-$(CONFIG_PARTITION_DISK)   += partitions.o
+obj-$(CONFIG_PARTITION_DISK)   += partitions.o partitions/
 
 obj-$(CONFIG_CMD_LOADS)+= s_record.o
 obj-$(CONFIG_OFTREE)   += oftree.o
diff --git a/common/partitions.c b/common/partitions.c
index 24310a3..c1578c9 100644
--- a/common/partitions.c
+++ b/common/partitions.c
@@ -27,92 +27,12 @@
 #include block.h
 #include asm/unaligned.h
 #include disks.h
-#include dma.h
 #include filetype.h
+#include dma.h
 
-struct partition {
-   uint64_t first_sec;
-   uint64_t size;
-};
-
-struct partition_desc {
-   int used_entries;
-   struct partition parts[8];
-};
-
-/**
- * Guess the size of the disk, based on the partition table entries
- * @param dev device to create partitions for
- * @param table partition table
- * @return sector count
- */
-static int disk_guess_size(struct device_d *dev, struct partition_entry *table)
-{
-   uint64_t size = 0;
-   int i;
-
-   for (i = 0; i  4; i++) {
-   if (table[i].partition_start != 0) {
-   size += get_unaligned_le32(table[i].partition_start) - 
size;
-   size += get_unaligned_le32(table[i].partition_size);
-   }
-   }
-
-   return (int)size;
-}
-
-/**
- * Check if a DOS like partition describes this block device
- * @param blk Block device to register to
- * @param pd Where to store the partition information
- *
- * It seems at least on ARM this routine canot use temp. stack space for the
- * sector. So, keep the malloc/free.
- */
-static void __maybe_unused try_dos_partition(struct block_device *blk,
-   struct partition_desc *pd)
-{
-   uint8_t *buffer;
-   struct partition_entry *table;
-   struct partition pentry;
-   int i, rc;
-
-   buffer = dma_alloc(SECTOR_SIZE);
-
-   /* read in the MBR to get the partition table */
-   rc = blk-ops-read(blk, buffer, 0, 1);
-   if (rc != 0) {
-   dev_err(blk-dev, Cannot read MBR/partition table\n);
-   goto on_error;
-   }
-
-   if (is_fat_or_mbr(buffer, NULL) != filetype_mbr) {
-   dev_info(blk-dev, No partition table found\n);
-   goto on_error;
-   }
-
-   table = (struct partition_entry *)buffer[446];
-
-   /* valid for x86 BIOS based disks only */
-   if (IS_ENABLED(CONFIG_DISK_BIOS)  blk-num_blocks == 0)
-   blk-num_blocks = disk_guess_size(blk-dev, table);
-
-   for (i = 0; i  4; i++) {
-   pentry.first_sec = 
get_unaligned_le32(table[i].partition_start);
-   pentry.size = get_unaligned_le32(table[i].partition_size);
-
-   if (pentry.first_sec != 0) {
-   pd-parts[pd-used_entries].first_sec = 
pentry.first_sec;
-   pd-parts[pd-used_entries].size = pentry.size;
-   pd-used_entries++;
-   } else {
-   dev_dbg(blk-dev, Skipping empty partition %d\n, i);
-   }
-   }
+#include partitions/parser.h
 
-on_error:
-   dma_free(buffer);
-}
+LIST_HEAD(partition_parser_list);
 
 /**
  * 

[PATCH 5/5] disk: partitions: add EFI GUID Partition Table

2013-02-15 Thread Jean-Christophe PLAGNIOL-VILLARD
form linux 3.8

so you can have part by num or name
not by GUID as this is a non human reading name

 ` ffe08000.sata
  ` 0x-0x3fff: /dev/ata0
  ` 0x0010-0x063f: /dev/ata0.0
  ` 0x0010-0x063f: /dev/ata0.boot
  ` 0x0640-0x3fef: /dev/ata0.1
  ` 0x0640-0x3fef: /dev/ata0.linux

Cc: Rob Herring rob.herr...@calxeda.com
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 common/partitions/Kconfig  |   19 ++
 common/partitions/Makefile |1 +
 common/partitions/efi.c|  477 ++
 common/partitions/efi.h|  123 ++
 include/linux/efi.h|  547 
 5 files changed, 1167 insertions(+)
 create mode 100644 common/partitions/efi.c
 create mode 100644 common/partitions/efi.h
 create mode 100644 include/linux/efi.h

diff --git a/common/partitions/Kconfig b/common/partitions/Kconfig
index 3f81c2f..ca4452b 100644
--- a/common/partitions/Kconfig
+++ b/common/partitions/Kconfig
@@ -11,3 +11,22 @@ config PARTITION_DISK_DOS
bool DOS partition support
help
  Add support to handle partitions in DOS style.
+
+config PARTITION_DISK_EFI
+   depends on PARTITION_DISK
+   default y
+   bool EFI: GPT partition support
+   help
+ Add support to handle partitions in GUID Partition Table style.
+
+config PARTITION_DISK_EFI_GPT_NO_FORCE
+   depends on PARTITION_DISK_EFI
+   default y
+   bool EFI: GPT: force test Protective MBR for validity
+   help
+ This will be added to the EFI Spec. per Intel after v1.02
+
+config PARTITION_DISK_EFI_GPT_COMPARE
+   depends on PARTITION_DISK_EFI
+   default y
+   bool EFI: GPT: compare primary and Alternate GPT header for validity
diff --git a/common/partitions/Makefile b/common/partitions/Makefile
index 0a5c70d..2b0c5b4 100644
--- a/common/partitions/Makefile
+++ b/common/partitions/Makefile
@@ -1 +1,2 @@
 obj-$(CONFIG_PARTITION_DISK_DOS)   += dos.o
+obj-$(CONFIG_PARTITION_DISK_EFI)   += efi.o
diff --git a/common/partitions/efi.c b/common/partitions/efi.c
new file mode 100644
index 000..59f14b3
--- /dev/null
+++ b/common/partitions/efi.c
@@ -0,0 +1,477 @@
+/
+ * EFI GUID Partition Table handling
+ *
+ * http://www.uefi.org/specs/
+ * http://www.intel.com/technology/efi/
+ *
+ * efi.[ch] by Matt Domsch matt_dom...@dell.com
+ *   Copyright 2000,2001,2002,2004 Dell Inc.
+ *
+ * Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
+ *
+ * Under GPLv2 only
+ */
+
+#include common.h
+#include disks.h
+#include init.h
+#include asm/unaligned.h
+#include dma.h
+#include linux/ctype.h
+
+#include efi.h
+#include parser.h
+
+static int force_gpt = IS_ENABLED(CONFIG_PARTITION_DISK_EFI_GPT_NO_FORCE);
+
+/**
+ * efi_crc32() - EFI version of crc32 function
+ * @buf: buffer to calculate crc32 of
+ * @len - length of buf
+ *
+ * Description: Returns EFI-style CRC32 value for @buf
+ * 
+ * This function uses the little endian Ethernet polynomial
+ * but seeds the function with ~0, and xor's with ~0 at the end.
+ * Note, the EFI Specification, v1.02, has a reference to
+ * Dr. Dobbs Journal, May 1994 (actually it's in May 1992).
+ */
+static inline u32
+efi_crc32(const void *buf, unsigned long len)
+{
+   return crc32(0, buf, len);
+}
+
+/**
+ * last_lba(): return number of last logical block of device
+ * @bdev: block device
+ * 
+ * Description: Returns last LBA value on success, 0 on error.
+ * This is stored (by sd and ide-geometry) in
+ *  the part[0] entry for this disk, and is the number of
+ *  physical sectors available on the disk.
+ */
+static u64 last_lba(struct block_device *bdev)
+{
+   if (!bdev)
+   return 0;
+   return bdev-num_blocks;
+}
+
+/**
+ * alloc_read_gpt_entries(): reads partition entries from disk
+ * @dev_desc
+ * @gpt - GPT header
+ *
+ * Description: Returns ptes on success,  NULL on error.
+ * Allocates space for PTEs based on information found in @gpt.
+ * Notes: remember to free pte when you're done!
+ */
+static gpt_entry *alloc_read_gpt_entries(struct block_device *blk,
+gpt_header * pgpt_head)
+{
+   size_t count = 0;
+   gpt_entry *pte = NULL;
+   unsigned long from, size;
+   int ret;
+
+   count = le32_to_cpu(pgpt_head-num_partition_entries) *
+   le32_to_cpu(pgpt_head-sizeof_partition_entry);
+
+   if (!count)
+   return NULL;
+   pte = kzalloc(count, GFP_KERNEL);
+   if (!pte)
+   return NULL;
+
+   from = le64_to_cpu(pgpt_head-partition_entry_lba);
+   size = count / GPT_BLOCK_SIZE;
+   ret = blk-ops-read(blk, pte, from, size);
+   if (ret) {
+   kfree(pte);
+   pte=NULL;
+   return NULL;
+  

[PATCH] fix brown paper bag bug introduced with compile time loglevel

2013-02-15 Thread Sascha Hauer
__dev_printf is a define which uses a local variable 'ret'. This
means that whenever someone does a dev_*(dev, ret: %d\n, ret);
ret will be 0.

Fix this by removing the variable. The return value of dev_* is
never checked anyway.

Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
---

I'm glad it was myself who stumbled upon this...

 include/printk.h |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/include/printk.h b/include/printk.h
index 1d45616..3f8f786 100644
--- a/include/printk.h
+++ b/include/printk.h
@@ -23,10 +23,8 @@ int dev_printf(const struct device_d *dev, const char 
*format, ...)
 
 #define __dev_printf(level, dev, format, args...) \
({  \
-   int ret = 0; \
if (level = LOGLEVEL) \
-   ret = dev_printf(dev, format, ##args);  \
-   ret;\
+   dev_printf(dev, format, ##args);\
 })
 
 
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2] fix brown paper bag bug introduced with compile time loglevel

2013-02-15 Thread Sascha Hauer
__dev_printf is a define which uses a local variable 'ret'. This
means that whenever someone does a dev_*(dev, ret: %d\n, ret);
ret will be 0.

Fix this by writing this without a local variable.

Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
---
 include/printk.h |5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/include/printk.h b/include/printk.h
index 1d45616..3de8905 100644
--- a/include/printk.h
+++ b/include/printk.h
@@ -23,10 +23,7 @@ int dev_printf(const struct device_d *dev, const char 
*format, ...)
 
 #define __dev_printf(level, dev, format, args...) \
({  \
-   int ret = 0; \
-   if (level = LOGLEVEL) \
-   ret = dev_printf(dev, format, ##args);  \
-   ret;\
+   (level) = LOGLEVEL ? dev_printf((dev), (format), ##args) : 0; \
 })
 
 
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 2/2] ARM i.MX21: Fix device names for gpio

2013-02-15 Thread Sascha Hauer
The i.MX21 has a imx1 gpio type. Change the name accordingly, otherwise
the gpio driver does not probe successfully.

Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
---
 arch/arm/mach-imx/imx21.c |   12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-imx/imx21.c b/arch/arm/mach-imx/imx21.c
index cddf3c0..91cd4bd 100644
--- a/arch/arm/mach-imx/imx21.c
+++ b/arch/arm/mach-imx/imx21.c
@@ -30,12 +30,12 @@ static int imx21_init(void)
 
add_generic_device(imx21-ccm, 0, NULL, MX21_CCM_BASE_ADDR, 0x100, 
IORESOURCE_MEM, NULL);
add_generic_device(imx1-gpt, 0, NULL, MX21_GPT1_BASE_ADDR, 0x100, 
IORESOURCE_MEM, NULL);
-   add_generic_device(imx-gpio, 0, NULL, MX21_GPIO1_BASE_ADDR, 0x100, 
IORESOURCE_MEM, NULL);
-   add_generic_device(imx-gpio, 1, NULL, MX21_GPIO2_BASE_ADDR, 0x100, 
IORESOURCE_MEM, NULL);
-   add_generic_device(imx-gpio, 2, NULL, MX21_GPIO3_BASE_ADDR, 0x100, 
IORESOURCE_MEM, NULL);
-   add_generic_device(imx-gpio, 3, NULL, MX21_GPIO4_BASE_ADDR, 0x100, 
IORESOURCE_MEM, NULL);
-   add_generic_device(imx-gpio, 4, NULL, MX21_GPIO5_BASE_ADDR, 0x100, 
IORESOURCE_MEM, NULL);
-   add_generic_device(imx-gpio, 5, NULL, MX21_GPIO6_BASE_ADDR, 0x100, 
IORESOURCE_MEM, NULL);
+   add_generic_device(imx1-gpio, 0, NULL, MX21_GPIO1_BASE_ADDR, 0x100, 
IORESOURCE_MEM, NULL);
+   add_generic_device(imx1-gpio, 1, NULL, MX21_GPIO2_BASE_ADDR, 0x100, 
IORESOURCE_MEM, NULL);
+   add_generic_device(imx1-gpio, 2, NULL, MX21_GPIO3_BASE_ADDR, 0x100, 
IORESOURCE_MEM, NULL);
+   add_generic_device(imx1-gpio, 3, NULL, MX21_GPIO4_BASE_ADDR, 0x100, 
IORESOURCE_MEM, NULL);
+   add_generic_device(imx1-gpio, 4, NULL, MX21_GPIO5_BASE_ADDR, 0x100, 
IORESOURCE_MEM, NULL);
+   add_generic_device(imx1-gpio, 5, NULL, MX21_GPIO6_BASE_ADDR, 0x100, 
IORESOURCE_MEM, NULL);
add_generic_device(imx21-wdt, 0, NULL, MX21_WDOG_BASE_ADDR, 0x100, 
IORESOURCE_MEM, NULL);
 
return 0;
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 1/2] ARM i.MX35: Fix device names for gpio

2013-02-15 Thread Sascha Hauer
The i.MX35 has a imx31 gpio type. Change the name accordingly, otherwise
the gpio driver does not probe successfully.

Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
---
 arch/arm/mach-imx/imx35.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-imx/imx35.c b/arch/arm/mach-imx/imx35.c
index 21c7e90..7b68783 100644
--- a/arch/arm/mach-imx/imx35.c
+++ b/arch/arm/mach-imx/imx35.c
@@ -73,9 +73,9 @@ static int imx35_init(void)
add_generic_device(imx-iomuxv3, 0, NULL, MX35_IOMUXC_BASE_ADDR, 
0x1000, IORESOURCE_MEM, NULL);
add_generic_device(imx35-ccm, 0, NULL, MX35_CCM_BASE_ADDR, 0x1000, 
IORESOURCE_MEM, NULL);
add_generic_device(imx31-gpt, 0, NULL, MX35_GPT1_BASE_ADDR, 0x100, 
IORESOURCE_MEM, NULL);
-   add_generic_device(imx-gpio, 0, NULL, MX35_GPIO1_BASE_ADDR, 0x1000, 
IORESOURCE_MEM, NULL);
-   add_generic_device(imx-gpio, 1, NULL, MX35_GPIO2_BASE_ADDR, 0x1000, 
IORESOURCE_MEM, NULL);
-   add_generic_device(imx-gpio, 2, NULL, MX35_GPIO3_BASE_ADDR, 0x1000, 
IORESOURCE_MEM, NULL);
+   add_generic_device(imx31-gpio, 0, NULL, MX35_GPIO1_BASE_ADDR, 0x1000, 
IORESOURCE_MEM, NULL);
+   add_generic_device(imx31-gpio, 1, NULL, MX35_GPIO2_BASE_ADDR, 0x1000, 
IORESOURCE_MEM, NULL);
+   add_generic_device(imx31-gpio, 2, NULL, MX35_GPIO3_BASE_ADDR, 0x1000, 
IORESOURCE_MEM, NULL);
add_generic_device(imx21-wdt, 0, NULL, MX35_WDOG_BASE_ADDR, 0x4000, 
IORESOURCE_MEM, NULL);
add_generic_device(imx35-esdctl, 0, NULL, MX35_ESDCTL_BASE_ADDR, 
0x1000, IORESOURCE_MEM, NULL);
 
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: Re: [PATCH 1/1] commands/ubi.c: Add support for VID header offset in ubiattach

2013-02-15 Thread Xavier Douville
On 02/14/2013 11:23, Jan Lübbe wrote:

 Which kernel  barebox are you using?


I am using kernel 3.2.0 and barebox 2012.11.0.
Both with patches from Phytec (phyCORE-AM335x-PD12.1.1).


Xavier

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: Re: [PATCH 1/1] commands/ubi.c: Add support for VID header offset in ubiattach

2013-02-15 Thread Jan Lübbe
On Fri, 2013-02-15 at 10:54 -0500, Xavier Douville wrote:
 On 02/14/2013 11:23, Jan Lübbe wrote:
 
  Which kernel  barebox are you using?
 
 
 I am using kernel 3.2.0 and barebox 2012.11.0.
 Both with patches from Phytec (phyCORE-AM335x-PD12.1.1).

I'm not sure if that barebox is different to the latest one regarding
the GPMC NAND support...

Does it actually fail on your board without this patch?

I have here:

...
NAND device: Manufacturer ID: 0x2c, Chip ID: 0xda (Micron NAND 256MiB 3,3V 
8-bit), page size: 2048, OOB size: 64
...
barebox:/ devinfo nand0
resources:
driver: none
bus: none

Parameters:
size = 268435456
   erasesize = 131072
   writesize = 2048
 oobsize = 64 
barebox:/ ubiattach /dev/nand0.root
UBI: attaching mtd0 to ubi0
UBI: physical eraseblock size:   131072 bytes (128 KiB)
UBI: logical eraseblock size:126976 bytes
UBI: smallest flash I/O unit:2048
UBI: VID header offset:  2048 (aligned 2048)
UBI: data offset:4096
registering /dev/ubi0
registering root as /dev/ubi0.root
UBI: attached mtd0 to ubi0
UBI: MTD device name:nand0.root
UBI: MTD device size:96 MiB
UBI: number of good PEBs:768
UBI: number of bad PEBs: 0
UBI: max. allowed volumes:   128
UBI: wear-leveling threshold:4096
UBI: number of internal volumes: 1
UBI: number of user volumes: 1
UBI: available PEBs: 33
UBI: total number of reserved PEBs: 735
UBI: number of PEBs reserved for bad PEB handling: 7
UBI: max/mean erase counter: 15/8
barebox:/ 

So it figures out the VID offset correctly from the writesize of 2048.

Regards,
Jan
-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 1/1] commands/ubi.c: Add support for VID header offset in ubiattach

2013-02-15 Thread Xavier Douville
On 2013-02-15 11:06, Jan Lübbe wrote:
 
 I'm not sure if that barebox is different to the latest one regarding
 the GPMC NAND support...
 
 Does it actually fail on your board without this patch?

I tried barebox 2013.02.0 but it doesn't detect my NAND, so I guess the
patch is still required.

 
 So it figures out the VID offset correctly from the writesize of 2048.
 
 Regards,
 Jan
 

What board and barebox version did you run this on?
I guess that means I should try to fix the problem in my NAND driver?

thanks for your help

Xavier

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH v3] at91sam9260/9g20ek: use IS_ENABLED instead of #if/#ifdef

2013-02-15 Thread Sascha Hauer
On Fri, Feb 15, 2013 at 12:24:52PM +0100, Fabio Porcedda wrote:
 Using IS_ENABLED instead of #if/#ifdef the compiler can check
 all the code.
 Using IS_ENABLED for configuring smc-mode is an optimization,
 reduce init.o text from 905 to 877.
 
 Signed-off-by: Fabio Porcedda fabio.porce...@gmail.com
 Cc: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com

Applied, thanks

Sascha

 ---
 v3:
  - fix second patch using IS_ENABLED to discard the struct.
  - squash them because both use IS_ENABLED in the same way.
 v2:
  - fixed the first patch by removing the #ifdef inside nand_pdata definition.
 
  arch/arm/boards/at91sam9260ek/init.c | 31 +--
  1 file changed, 13 insertions(+), 18 deletions(-)
 
 diff --git a/arch/arm/boards/at91sam9260ek/init.c 
 b/arch/arm/boards/at91sam9260ek/init.c
 index 06a53f2..77ca6bb 100644
 --- a/arch/arm/boards/at91sam9260ek/init.c
 +++ b/arch/arm/boards/at91sam9260ek/init.c
 @@ -37,9 +37,8 @@ static void ek_set_board_type(void)
  {
   if (machine_is_at91sam9g20ek()) {
   armlinux_set_architecture(MACH_TYPE_AT91SAM9G20EK);
 -#ifdef CONFIG_AT91_HAVE_2MMC
 - armlinux_set_revision(HAVE_2MMC);
 -#endif
 + if (IS_ENABLED(CONFIG_AT91_HAVE_2MMC))
 + armlinux_set_revision(HAVE_2MMC);
   } else {
   armlinux_set_architecture(MACH_TYPE_AT91SAM9260EK);
   }
 @@ -51,11 +50,6 @@ static struct atmel_nand_data nand_pdata = {
   .det_pin= -EINVAL,
   .rdy_pin= AT91_PIN_PC13,
   .enable_pin = AT91_PIN_PC14,
 -#if defined(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16)
 - .bus_width_16   = 1,
 -#else
 - .bus_width_16   = 0,
 -#endif
   .on_flash_bbt   = 1,
  };
  
 @@ -107,10 +101,12 @@ static void ek_add_device_nand(void)
   smc = ek_9260_nand_smc_config;
  
   /* setup bus-width (8 or 16) */
 - if (nand_pdata.bus_width_16)
 + if (IS_ENABLED(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16)) {
 + nand_pdata.bus_width_16 = 1;
   smc-mode |= AT91_SMC_DBW_16;
 - else
 + } else {
   smc-mode |= AT91_SMC_DBW_8;
 + }
  
   /* configure chip-select 3 (NAND) */
   sam9_smc_configure(0, 3, smc);
 @@ -157,7 +153,6 @@ static void at91sam9260ek_phy_reset(void)
  /*
   * MCI (SD/MMC)
   */
 -#if defined(CONFIG_MCI_ATMEL)
  static struct atmel_mci_platform_data __initdata ek_mci_data = {
   .bus_width  = 4,
   .slot_b = 1,
 @@ -165,14 +160,14 @@ static struct atmel_mci_platform_data __initdata 
 ek_mci_data = {
  
  static void ek_usb_add_device_mci(void)
  {
 + if (!IS_ENABLED(CONFIG_MCI_ATMEL))
 + return;
 +
   if (machine_is_at91sam9g20ek())
   ek_mci_data.detect_pin = AT91_PIN_PC9;
  
   at91_add_device_mci(0, ek_mci_data);
  }
 -#else
 -static void ek_usb_add_device_mci(void) {}
 -#endif
  
  /*
   * USB Host port
 @@ -209,10 +204,10 @@ static void __init ek_add_led(void)
  {
   int i;
  
 -#ifdef CONFIG_AT91_HAVE_2MMC
 - leds[0].gpio = AT91_PIN_PB8;
 - leds[1].gpio = AT91_PIN_PB9;
 -#endif
 + if (IS_ENABLED(CONFIG_AT91_HAVE_2MMC)) {
 + leds[0].gpio = AT91_PIN_PB8;
 + leds[1].gpio = AT91_PIN_PB9;
 + }
  
   for (i = 0; i  ARRAY_SIZE(leds); i++) {
   at91_set_gpio_output(leds[i].gpio, leds[i].active_low);
 -- 
 1.8.1.1
 
 
 ___
 barebox mailing list
 barebox@lists.infradead.org
 http://lists.infradead.org/mailman/listinfo/barebox
 

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 2/5] filetype: add GPT support

2013-02-15 Thread Sascha Hauer
On Fri, Feb 15, 2013 at 02:35:14PM +0100, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
 GPT need to be check before MBR
 
 Cc: Rob Herring rob.herr...@calxeda.com
 Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
 ---
  common/filetype.c  |   47 +++
  include/filetype.h |1 +
  2 files changed, 48 insertions(+)
 
 diff --git a/common/filetype.c b/common/filetype.c
 index 22fc621..06fa803 100644
 --- a/common/filetype.c
 +++ b/common/filetype.c
 @@ -48,6 +48,7 @@ static const struct filetype_str filetype_str[] = {
   [filetype_bmp] = { BMP image, bmp },
   [filetype_png] = { PNG image, png },
   [filetype_ext] = { ext filesystem, ext },
 + [filetype_gpt] = { GUID Partition Table, gpt },
  };
  
  const char *file_type_to_string(enum filetype f)
 @@ -69,9 +70,52 @@ const char *file_type_to_short_string(enum filetype f)
  #define MBR_StartSector  8   /* MBR: Offset of Starting 
 Sector in Partition Table Entry */
  #define BS_55AA  510 /* Boot sector signature (2) */
  #define MBR_Table446 /* MBR: Partition table offset (2) */
 +#define MBR_partition_size   16  /* MBR: Partition table offset (2) */
  #define BS_FilSysType32  82  /* File system type (1) */
  #define BS_FilSysType54  /* File system type (1) */
  
 +#define MBR_PART_sys_ind 4
 +#define MBR_PART_start_sect  8
 +#define MBR_OSTYPE_EFI_GPT   0xee
 +
 +static inline int pmbr_part_valid(const uint8_t *buf)
 +{
 + if (buf[MBR_PART_sys_ind] == MBR_OSTYPE_EFI_GPT 
 + get_unaligned_le32(buf[MBR_PART_start_sect]) == 1UL) {
 + return 1;
 + }
 +
 + return 0;
 +}
 +
 +/**
 + * is_gpt_valid(): test Protective MBR for validity and EFI PART
 + * @mbr: pointer to a legacy mbr structure
 + *
 + * Description: Returns 1 if PMBR is valid, 0 otherwise.
 + * Validity depends on two things:
 + *  1) MSDOS signature is in the last two bytes of the MBR
 + *  2) One partition of type 0xEE is found

Still wrong. This describes is_pmbr_valid, but the function is named and
implements is_gpt_valid. I suggest implemting a real is_pmbr_valid
function and call it from is_gpt_valid which additionally checks for the
gpt header.

Sascha


 + */
 +static int is_gpt_valid(const uint8_t *buf)
 +{
 + int i;
 +
 + if (get_unaligned_le16(buf[BS_55AA]) != 0xAA55)
 + return 0;
 +
 + if (strncmp(buf[512], EFI PART, 8))
 + return 0;
 +
 + buf += MBR_Table;
 +
 + for (i = 0; i  4; i++, buf += MBR_partition_size) {
 + if (pmbr_part_valid(buf))
 + return 1;
 + }
 + return 0;
 +}
 +
  enum filetype is_fat_or_mbr(const unsigned char *sector, unsigned long 
 *bootsec)
  {
   /*
 @@ -159,6 +203,9 @@ enum filetype file_detect_type(const void *_buf, size_t 
 bufsize)
   if (bufsize  512)
   return filetype_unknown;
  
 + if (bufsize = 520  is_gpt_valid(buf8))
 + return filetype_gpt;
 +
   type = is_fat_or_mbr(buf8, NULL);
   if (type != filetype_unknown)
   return type;
 diff --git a/include/filetype.h b/include/filetype.h
 index 4d43757..78ca5d2 100644
 --- a/include/filetype.h
 +++ b/include/filetype.h
 @@ -23,6 +23,7 @@ enum filetype {
   filetype_bmp,
   filetype_png,
   filetype_ext,
 + filetype_gpt,
   filetype_max,
  };
  
 -- 
 1.7.10.4
 
 
 ___
 barebox mailing list
 barebox@lists.infradead.org
 http://lists.infradead.org/mailman/listinfo/barebox
 

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 3/5] partitons: add framework

2013-02-15 Thread Sascha Hauer
On Fri, Feb 15, 2013 at 02:35:15PM +0100, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
 +#include partitions/parser.h
  
 -on_error:
 - dma_free(buffer);
 -}
 +LIST_HEAD(partition_parser_list);

static

  
  /**
   * Register one partition on the given block device
 @@ -135,6 +55,33 @@ static int register_one_partition(struct block_device 
 *blk,
   0, partition_name);
  }
  
 +static struct partition_parser *partition_parser_get_by_filetype(uint8_t 
 *buf)
 +{
 + enum filetype type;
 + struct partition_parser *parser;
 +
 + /* first new partition table as EFI GPT */
 + type = file_detect_type(buf, SECTOR_SIZE * 2);
 +
 + list_for_each_entry(parser, partition_parser_list, list) {
 + if (parser-type == type)
 + return parser;
 + }
 +
 + /* if not parser found search for old one
 +  * so if EFI GPT not enable take it as MBR
 +  * usefull for compatibility

1 Cent for each time you write useful with double l...



 +
 +struct partition_parser dos = {
 + .parse = dos_partition,
 + .type = filetype_mbr,
 +};

static

Sascha

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 4/5] disk: introduce partition name

2013-02-15 Thread Sascha Hauer
On Fri, Feb 15, 2013 at 02:35:16PM +0100, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
 so we can register partion with name as present in EFI GPT
 
 Cc: Rob Herring rob.herr...@calxeda.com
 Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
 ---
  common/partitions.c|   54 
 ++--
  common/partitions/parser.h |2 ++
  2 files changed, 44 insertions(+), 12 deletions(-)
 
 diff --git a/common/partitions.c b/common/partitions.c
 index c1578c9..b0f48be 100644
 --- a/common/partitions.c
 +++ b/common/partitions.c
 @@ -44,15 +44,43 @@ LIST_HEAD(partition_parser_list);
  static int register_one_partition(struct block_device *blk,
   struct partition *part, int no)
  {
 - char partition_name[19];
 + char *partition_name;
 + int ret;
 + uint64_t start = part-first_sec * SECTOR_SIZE;
 + uint64_t size = part-size * SECTOR_SIZE;
 +
 + partition_name = asprintf(%s.%d, blk-cdev.name, no);
 + if (!partition_name)
 + return -ENOMEM;
 + dev_dbg(blk-dev, Registering partition %s on drive %s\n,
 + partition_name, blk-cdev.name);
 + ret = devfs_add_partition(blk-cdev.name,
 + start, size, 0, partition_name);
 + if (ret)
 + goto out;
 +
 + free(partition_name);
 +
 + if (!part-name[0])
 + return 0;

So when a name is not given then you also don't register the partition
with a number?

 +
 + partition_name = asprintf(%s.%s, blk-cdev.name, part-name);
 + if (!partition_name)
 + return -ENOMEM;
  
 - sprintf(partition_name, %s.%d, blk-cdev.name, no);
   dev_dbg(blk-dev, Registering partition %s on drive %s\n,
   partition_name, blk-cdev.name);
 - return devfs_add_partition(blk-cdev.name,
 - part-first_sec * SECTOR_SIZE,
 - part-size * SECTOR_SIZE,
 - 0, partition_name);
 + ret = devfs_add_partition(blk-cdev.name,
 + start, size, 0, partition_name);
 +
 + if (ret)
 + dev_warn(blk-dev, Registering partition %s on drive %s 
 failled\n,
 + partition_name, blk-cdev.name);

s/failled/failed/

Sascha

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 5/5] disk: partitions: add EFI GUID Partition Table

2013-02-15 Thread Sascha Hauer
On Fri, Feb 15, 2013 at 02:35:17PM +0100, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
 form linux 3.8
 
 +
 +struct partition_parser efi_partition_parser = {
 + .parse = efi_partition,
 + .type = filetype_gpt,
 +};

static

Sascha


-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 2/5] filetype: add GPT support

2013-02-15 Thread Sascha Hauer
On Fri, Feb 15, 2013 at 06:36:55PM +0100, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
 On 18:32 Fri 15 Feb , Sascha Hauer wrote:
  On Fri, Feb 15, 2013 at 02:35:14PM +0100, Jean-Christophe PLAGNIOL-VILLARD 
  wrote:
   GPT need to be check before MBR
   
   Cc: Rob Herring rob.herr...@calxeda.com
   Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
   ---
common/filetype.c  |   47 +++
include/filetype.h |1 +
2 files changed, 48 insertions(+)
   
   diff --git a/common/filetype.c b/common/filetype.c
   index 22fc621..06fa803 100644
   --- a/common/filetype.c
   +++ b/common/filetype.c
   @@ -48,6 +48,7 @@ static const struct filetype_str filetype_str[] = {
 [filetype_bmp] = { BMP image, bmp },
 [filetype_png] = { PNG image, png },
 [filetype_ext] = { ext filesystem, ext },
   + [filetype_gpt] = { GUID Partition Table, gpt },
};

const char *file_type_to_string(enum filetype f)
   @@ -69,9 +70,52 @@ const char *file_type_to_short_string(enum filetype f)
#define MBR_StartSector  8   /* MBR: Offset of Starting 
   Sector in Partition Table Entry */
#define BS_55AA  510 /* Boot sector signature (2) */
#define MBR_Table446 /* MBR: Partition table offset 
   (2) */
   +#define MBR_partition_size   16  /* MBR: Partition table offset 
   (2) */
#define BS_FilSysType32  82  /* File system type (1) */
#define BS_FilSysType54  /* File system type (1) */

   +#define MBR_PART_sys_ind 4
   +#define MBR_PART_start_sect  8
   +#define MBR_OSTYPE_EFI_GPT   0xee
   +
   +static inline int pmbr_part_valid(const uint8_t *buf)
   +{
   + if (buf[MBR_PART_sys_ind] == MBR_OSTYPE_EFI_GPT 
   + get_unaligned_le32(buf[MBR_PART_start_sect]) == 1UL) {
   + return 1;
   + }
   +
   + return 0;
   +}
   +
   +/**
   + * is_gpt_valid(): test Protective MBR for validity and EFI PART
   + * @mbr: pointer to a legacy mbr structure
   + *
   + * Description: Returns 1 if PMBR is valid, 0 otherwise.
   + * Validity depends on two things:
   + *  1) MSDOS signature is in the last two bytes of the MBR
   + *  2) One partition of type 0xEE is found
  
  Still wrong. This describes is_pmbr_valid, but the function is named and
  implements is_gpt_valid. I suggest implemting a real is_pmbr_valid
  function and call it from is_gpt_valid which additionally checks for the
  gpt header.
 
 we test both pmr and EFI PART fo this is right
 
 test Protective MBR for validity and EFI PART
 
 so the comment is correct

The comment says: Returns 1 if PMBR is valid, 0 otherwise, but the
function implements Returns 1 if PBMR is valid *and* an EFI header is
found, 0 otherwise

Sascha

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] addpart: size and offset not needed for already defined partitions

2013-02-15 Thread Carlo Caione
You can use the name of an already defined partition
(i.e. hardcoded in board specific files) without specifying
size and offset that are automatically obtained

i.e.

$ addpart /dev/nor0 (self)
$ addpart /dev/nor0 (env0)

Signed-off-by: Carlo Caione carlo.cai...@gmail.com
---
 commands/partition.c | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/commands/partition.c b/commands/partition.c
index fdd6041..8cb50ca 100644
--- a/commands/partition.c
+++ b/commands/partition.c
@@ -53,6 +53,7 @@ static int mtd_part_do_parse_one(char *devname, const char 
*partstr,
char buf[PATH_MAX] = {};
unsigned long flags = 0;
int ret;
+   struct cdev *cdev;
 
memset(buf, 0, PATH_MAX);
 
@@ -63,7 +64,7 @@ static int mtd_part_do_parse_one(char *devname, const char 
*partstr,
size = strtoul_suffix(partstr, end, 0);
}
 
-   if (*end == '@')
+   if ((*end == '@')  (size != 0))
*offset = strtoul_suffix(end+1, end, 0);
 
if (size == SIZE_REMAINING)
@@ -78,6 +79,18 @@ static int mtd_part_do_parse_one(char *devname, const char 
*partstr,
printf(could not find matching ')'\n);
return -EINVAL;
}
+   memcpy(buf, partstr, end - partstr);
+
+   if (size == 0) {
+   cdev = cdev_by_name(buf);
+   if (!cdev) {
+   printf(%s: partition not found\n, buf);
+   return -EINVAL;
+   }
+
+   size = cdev-size;
+   *offset = cdev-offset;
+   }
 
if (pflags  PART_ADD_DEVNAME)
sprintf(buf, %s., devname);
-- 
1.8.1.3


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 1/1] hush: return exit code a real instead of 0/1 only

2013-02-15 Thread Jean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 common/hush.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/hush.c b/common/hush.c
index 602f8f1..3e89a11 100644
--- a/common/hush.c
+++ b/common/hush.c
@@ -1639,7 +1639,7 @@ static int parse_stream_outer(struct p_context *ctx, 
struct in_str *inp, int fla
b_free(temp);
} while (rcode != -1  !(flag  FLAG_EXIT_FROM_LOOP));   /* loop on 
syntax errors, return on EOF */
 
-   return (code != 0) ? 1 : 0;
+   return code;
 }
 
 static int parse_string_outer(struct p_context *ctx, const char *s, int flag)
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] addpart: size and offset not needed for already defined partitions

2013-02-15 Thread Jean-Christophe PLAGNIOL-VILLARD
On 19:09 Fri 15 Feb , Carlo Caione wrote:
 You can use the name of an already defined partition
 (i.e. hardcoded in board specific files) without specifying
 size and offset that are automatically obtained
 
 i.e.
 
 $ addpart /dev/nor0 (self)
 $ addpart /dev/nor0 (env0)
this is dangerous

specialy when you can knwon for sure that (self) will be in the nor flash

as on sama5d3x as we can boot from different media and barebox detect it
so the self will spi/nor/nand/mmc/eeprom

Best Regards,
J.
 
 Signed-off-by: Carlo Caione carlo.cai...@gmail.com
 ---
  commands/partition.c | 15 ++-
  1 file changed, 14 insertions(+), 1 deletion(-)
 
 diff --git a/commands/partition.c b/commands/partition.c
 index fdd6041..8cb50ca 100644
 --- a/commands/partition.c
 +++ b/commands/partition.c
 @@ -53,6 +53,7 @@ static int mtd_part_do_parse_one(char *devname, const char 
 *partstr,
   char buf[PATH_MAX] = {};
   unsigned long flags = 0;
   int ret;
 + struct cdev *cdev;
  
   memset(buf, 0, PATH_MAX);
  
 @@ -63,7 +64,7 @@ static int mtd_part_do_parse_one(char *devname, const char 
 *partstr,
   size = strtoul_suffix(partstr, end, 0);
   }
  
 - if (*end == '@')
 + if ((*end == '@')  (size != 0))
   *offset = strtoul_suffix(end+1, end, 0);
  
   if (size == SIZE_REMAINING)
 @@ -78,6 +79,18 @@ static int mtd_part_do_parse_one(char *devname, const char 
 *partstr,
   printf(could not find matching ')'\n);
   return -EINVAL;
   }
 + memcpy(buf, partstr, end - partstr);
 +
 + if (size == 0) {
 + cdev = cdev_by_name(buf);
 + if (!cdev) {
 + printf(%s: partition not found\n, buf);
 + return -EINVAL;
 + }
 +
 + size = cdev-size;
 + *offset = cdev-offset;
 + }
  
   if (pflags  PART_ADD_DEVNAME)
   sprintf(buf, %s., devname);
 -- 
 1.8.1.3
 
 
 ___
 barebox mailing list
 barebox@lists.infradead.org
 http://lists.infradead.org/mailman/listinfo/barebox

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 1/1] defaultenv-2: add boot sequence

2013-02-15 Thread Jean-Christophe PLAGNIOL-VILLARD
Boot will boot run sequentially the script in /env/boot.d

if not global.boot.default or global.boot.default == seq
or -s is sepecified
start the boot sequence

we do not boot the boot sequence by default t keep retro compatibility

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 common/Kconfig  |2 +
 defaultenv-2/base/bin/_boot |   42 +++
 defaultenv-2/base/bin/boot  |   78 ---
 defaultenv-2/menu/menu/boot-entries-collect |6 +--
 4 files changed, 104 insertions(+), 24 deletions(-)
 create mode 100644 defaultenv-2/base/bin/_boot

diff --git a/common/Kconfig b/common/Kconfig
index 3a55e01..683460b 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -532,6 +532,8 @@ config DEFAULT_ENVIRONMENT_GENERIC_NEW
select CMD_GLOBAL
select CMD_AUTOMOUNT
select CMD_BASENAME
+   select CMD_READLINK
+   select CMD_DIRNAME
select FLEXIBLE_BOOTARGS
prompt Generic environment template
 
diff --git a/defaultenv-2/base/bin/_boot b/defaultenv-2/base/bin/_boot
new file mode 100644
index 000..a9a6799
--- /dev/null
+++ b/defaultenv-2/base/bin/_boot
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+verbose=
+dryrun=
+
+. /env/data/ansi-colors
+
+# clear linux.bootargs.dyn.* and bootm.*
+global -r linux.bootargs.dyn.
+global -r bootm.
+
+while getopt vdl opt; do
+   if [ ${opt} = v ]; then
+   if [ -n $verbose ]; then
+   verbose=-v -v
+   else
+   verbose=-v
+   fi
+   elif [ ${opt} = d ]; then
+   dryrun=-d
+   fi
+done
+
+file=$1
+scr=
+
+echo -e ${GREEN}booting ${YELLOW}$file${NC}
+[ -f /env/boot.d/$file ]  scr=/env/boot.d/$file
+[ -f /env/boot/$file ]  scr=/env/boot/$file
+
+if [ -z $scr ]; then
+   exit 2
+fi
+
+$scr
+
+if [ -n $dryrun ]; then
+   exit 0
+fi
+
+${global.bootm.image} $verbose
+bootm $verbose
diff --git a/defaultenv-2/base/bin/boot b/defaultenv-2/base/bin/boot
index ebbd951..746607e 100644
--- a/defaultenv-2/base/bin/boot
+++ b/defaultenv-2/base/bin/boot
@@ -2,20 +2,38 @@
 
 verbose=
 dryrun=
+bootsequence=n
 
 usage=
 $0 [OPTIONS] [source]\n
  -v  verbose\n
  -d  dryrun\n
  -l  list boot sources\n
+ -s  start the boot sequence\n
  -h  help
 
+. /env/data/ansi-colors
+
 for i in /env/boot/*; do
basename $i s
sources=$sources$s 
 done
 
-while getopt vdhl opt; do
+if [ -d /env/boot.d ]; then
+   sources=$sources\n\nboot sequence:
+   for i in /env/boot.d/*; do
+   readlink -f $i s
+   basename $s link
+   basename $i s
+   sources=$sources\n ${YELLOW}${s}${NC} - ${CYAN}${link}${NC}
+   done
+   bootsequence=y
+else
+   sources=$sources\n\nboot sequence:\n${GREEN}none${NC}
+   bootsequence=n
+fi
+
+while getopt vdhls opt; do
if [ ${opt} = v ]; then
if [ -n $verbose ]; then
verbose=-v -v
@@ -23,7 +41,9 @@ while getopt vdhl opt; do
verbose=-v
fi
elif [ ${opt} = d ]; then
-   dryrun=1
+   dryrun=-d
+   elif [ ${opt} = s ]; then
+   do_sequence=y
elif [ ${opt} = l ]; then
echo -e boot sources:\n$sources
exit 0
@@ -33,26 +53,46 @@ while getopt vdhl opt; do
fi
 done
 
-# clear linux.bootargs.dyn.* and bootm.*
-global -r linux.bootargs.dyn.
-global -r bootm.
+boot=$1
 
-if [ $# = 0 ]; then
-   scr=$global.boot.default
+if [ $# != 0 ]; then
+   do_sequence=n
 else
-   scr=$1
-fi
-
-if [ -n $scr ]; then
-   if [ ! -f /env/boot/$scr ]; then
-   echo -e /env/boot/$scr does not exist. Valid 
choices:\n$sources
-   exit
+   if [ ${global.boot.default} = seq -o  ${global.boot.default} =  
]; then
+   do_sequence=y
+   else
+   boot=${global.boot.default}
+   do_sequence=n
fi
-   /env/boot/$scr
 fi
 
-if [ -n $dryrun ]; then
-   exit 0
+{if [ ${do_sequence} = y ]; then
+   if [ ${bootsequence} != y ]; then
+   echo -e ${GREEN}boot sequence ${RED}none${NC}
+   exit 1
+   fi
+   echo -e ${GREEN}Start boot sequence${NC}
+   for i in /env/boot.d/*; do
+   readlink -f $i s
+   basename $boot link
+   basename $i boot
+   msg=${GREEN}boot${NC} ${YELLOW}${boot}${NC} - 
${CYAN}${link}${NC}
+   echo -e ${msg}
+   _boot $verbose $dryrun $boot
+   ret=$?
+   echo ${ret}
+   if [ $ret -eq 2 ]; then
+   echo -e ${RED}/env/boot/${boot}{${NC} or 
${RED}/env/boot.d/${boot}${NC} does not exist. Valid choices:\n$sources
+   fi
+   echo -e ${msg} ${RED}failled${NC}
+   done
+   echo -e ${GREEN}boot sequence 

Re: [PATCH 1/1] hush: return exit code a real instead of 0/1 only

2013-02-15 Thread Sascha Hauer
On Fri, Feb 15, 2013 at 07:25:05PM +0100, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
 Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
 ---
  common/hush.c |2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/common/hush.c b/common/hush.c
 index 602f8f1..3e89a11 100644
 --- a/common/hush.c
 +++ b/common/hush.c
 @@ -1639,7 +1639,7 @@ static int parse_stream_outer(struct p_context *ctx, 
 struct in_str *inp, int fla
   b_free(temp);
   } while (rcode != -1  !(flag  FLAG_EXIT_FROM_LOOP));   /* loop on 
 syntax errors, return on EOF */
  
 - return (code != 0) ? 1 : 0;
 + return code;

This breaks the exit command.

Sascha


-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] fix compiler warnings

2013-02-15 Thread Sascha Hauer
Fixes for some compiler warnings on master.

Sascha


Sascha Hauer (3):
  ARM OMAP phycard-a-l1: Add missing include
  ARM at91sam9n12ek_defconfig: Fix reassigning of BAREBOX_MAX_IMAGE_SIZE
  ARM i.MX28: Add missing return value in non-void function

 arch/arm/boards/phycard-a-l1/lowlevel.c  |1 +
 arch/arm/configs/at91sam9n12ek_defconfig |1 -
 arch/arm/mach-mxs/soc-imx28.c|2 ++
 3 files changed, 3 insertions(+), 1 deletion(-)

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 1/3] ARM OMAP phycard-a-l1: Add missing include

2013-02-15 Thread Sascha Hauer
Fixes:

arch/arm/boards/phycard-a-l1/lowlevel.c: In function 'pcaal1_sdrc_init':
arch/arm/boards/phycard-a-l1/lowlevel.c:105:2: warning: implicit declaration of 
function 'get_ram_size' [-Wimplicit-function-declaration]
arch/arm/boards/phycard-a-l1/lowlevel.c:113:3: warning: implicit declaration of 
function 'hang' [-Wimplicit-function-declaration]

Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
---
 arch/arm/boards/phycard-a-l1/lowlevel.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boards/phycard-a-l1/lowlevel.c 
b/arch/arm/boards/phycard-a-l1/lowlevel.c
index d00efcc..30379d8 100644
--- a/arch/arm/boards/phycard-a-l1/lowlevel.c
+++ b/arch/arm/boards/phycard-a-l1/lowlevel.c
@@ -1,3 +1,4 @@
+#include common.h
 #include io.h
 #include init.h
 #include sizes.h
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 3/3] ARM i.MX28: Add missing return value in non-void function

2013-02-15 Thread Sascha Hauer
Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
---
 arch/arm/mach-mxs/soc-imx28.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/mach-mxs/soc-imx28.c b/arch/arm/mach-mxs/soc-imx28.c
index a5f3d68..8972a3d 100644
--- a/arch/arm/mach-mxs/soc-imx28.c
+++ b/arch/arm/mach-mxs/soc-imx28.c
@@ -45,5 +45,7 @@ static int imx28_init(void)
 * of resetting it. Use a software reset only.
 */
writel(HW_CLKCTRL_WDOG_POR_DISABLE, IMX_CCM_BASE + HW_CLKCTRL_RESET);
+
+   return 0;
 }
 postcore_initcall(imx28_init);
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[RFC] Add Generic GPIO driver

2013-02-15 Thread Alexander Shiyan
This patch adds generic memory-mapped GPIO controller support.
Code taken from Linux Kernel and adopted for barebox.

Signed-off-by: Alexander Shiyan shc_w...@mail.ru
---
 drivers/gpio/Kconfig|  10 +
 drivers/gpio/Makefile   |   5 +-
 drivers/gpio/gpio-generic.c | 427 
 drivers/gpio/gpio.c |   5 +
 include/gpio.h  |   2 +
 include/linux/basic_mmio_gpio.h |  68 +++
 6 files changed, 515 insertions(+), 2 deletions(-)
 create mode 100644 drivers/gpio/gpio-generic.c
 create mode 100644 include/linux/basic_mmio_gpio.h

diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 89be684..565f5bd 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -6,10 +6,20 @@ if GPIOLIB
 
 menu GPIO
 
+config GPIO_GENERIC
+   def_bool y
+
 config GPIO_BCM2835
bool GPIO support for BCM2835
depends on ARCH_BCM2835
 
+config GPIO_GENERIC_PLATFORM
+   bool Generic memory-mapped GPIO controller support
+   select GPIO_GENERIC
+   help
+ Say yes here to support basic platform memory-mapped
+ GPIO controllers
+
 config GPIO_PL061
bool PrimeCell PL061 GPIO support
depends on ARM_AMBA
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index 993ab89..1ef345c 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -1,4 +1,5 @@
-obj-$(CONFIG_GPIOLIB) += gpio.o
+obj-$(CONFIG_GPIOLIB)  += gpio.o
 obj-$(CONFIG_GPIO_BCM2835) += gpio-bcm2835.o
+obj-$(CONFIG_GPIO_GENERIC) += gpio-generic.o
 obj-$(CONFIG_GPIO_PL061)   += gpio-pl061.o
-obj-$(CONFIG_GPIO_STMPE) += gpio-stmpe.o
+obj-$(CONFIG_GPIO_STMPE)   += gpio-stmpe.o
diff --git a/drivers/gpio/gpio-generic.c b/drivers/gpio/gpio-generic.c
new file mode 100644
index 000..83f85f7
--- /dev/null
+++ b/drivers/gpio/gpio-generic.c
@@ -0,0 +1,427 @@
+/*
+ * Generic driver for memory-mapped GPIO controllers.
+ *
+ * Based on linux driver by:
+ *  Copyright 2008 MontaVista Software, Inc.
+ *  Copyright 2008,2010 Anton Vorontsov cbouatmai...@gmail.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;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#include init.h
+#include malloc.h
+#include linux/log2.h
+#include linux/basic_mmio_gpio.h
+
+static void bgpio_write8(void __iomem *reg, unsigned int data)
+{
+   writeb(data, reg);
+}
+
+static unsigned int bgpio_read8(void __iomem *reg)
+{
+   return readb(reg);
+}
+
+static void bgpio_write16(void __iomem *reg, unsigned int data)
+{
+   writew(data, reg);
+}
+
+static unsigned int bgpio_read16(void __iomem *reg)
+{
+   return readw(reg);
+}
+
+static void bgpio_write32(void __iomem *reg, unsigned int data)
+{
+   writel(data, reg);
+}
+
+static unsigned int bgpio_read32(void __iomem *reg)
+{
+   return readl(reg);
+}
+
+static unsigned int bgpio_pin2mask(struct bgpio_chip *bgc, unsigned int pin)
+{
+   return 1  pin;
+}
+
+static unsigned int bgpio_pin2mask_be(struct bgpio_chip *bgc, unsigned int pin)
+{
+   return 1  (bgc-bits - 1 - pin);
+}
+
+static int bgpio_get(struct gpio_chip *gc, unsigned int gpio)
+{
+   struct bgpio_chip *bgc = to_bgpio_chip(gc);
+
+   return bgc-read_reg(bgc-reg_dat)  bgc-pin2mask(bgc, gpio);
+}
+
+static void bgpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
+{
+   struct bgpio_chip *bgc = to_bgpio_chip(gc);
+   unsigned int mask = bgc-pin2mask(bgc, gpio);
+
+   if (val)
+   bgc-data |= mask;
+   else
+   bgc-data = ~mask;
+
+   bgc-write_reg(bgc-reg_dat, bgc-data);
+}
+
+static void bgpio_set_with_clear(struct gpio_chip *gc, unsigned int gpio,
+int val)
+{
+   struct bgpio_chip *bgc = to_bgpio_chip(gc);
+   unsigned int mask = bgc-pin2mask(bgc, gpio);
+
+   if (val)
+   bgc-write_reg(bgc-reg_set, mask);
+   else
+   bgc-write_reg(bgc-reg_clr, mask);
+}
+
+static void bgpio_set_set(struct gpio_chip *gc, unsigned int gpio, int val)
+{
+   struct bgpio_chip *bgc = to_bgpio_chip(gc);
+   unsigned int mask = bgc-pin2mask(bgc, gpio);
+
+   if (val)
+   bgc-data |= mask;
+   else
+   bgc-data = ~mask;
+
+   bgc-write_reg(bgc-reg_set, bgc-data);
+}
+
+static int bgpio_simple_dir_in(struct gpio_chip *gc, unsigned int gpio)
+{
+   return 0;
+}
+
+static int bgpio_simple_dir_out(struct gpio_chip *gc, unsigned int gpio,
+   int val)
+{
+   gc-ops-set(gc, gpio, val);
+
+   return 0;
+}
+
+static int bgpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
+{
+   struct bgpio_chip *bgc = to_bgpio_chip(gc);
+
+   bgc-dir = ~bgc-pin2mask(bgc, gpio);
+   bgc-write_reg(bgc-reg_dir, bgc-dir);
+
+   

Re: [PATCH 1/1] hush: return exit code a real instead of 0/1 only

2013-02-15 Thread Sascha Hauer
On Fri, Feb 15, 2013 at 08:06:10PM +0100, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
 On 19:36 Fri 15 Feb , Sascha Hauer wrote:
  On Fri, Feb 15, 2013 at 07:25:05PM +0100, Jean-Christophe PLAGNIOL-VILLARD 
  wrote:
   Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
   ---
common/hush.c |2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
   
   diff --git a/common/hush.c b/common/hush.c
   index 602f8f1..3e89a11 100644
   --- a/common/hush.c
   +++ b/common/hush.c
   @@ -1639,7 +1639,7 @@ static int parse_stream_outer(struct p_context 
   *ctx, struct in_str *inp, int fla
 b_free(temp);
 } while (rcode != -1  !(flag  FLAG_EXIT_FROM_LOOP));   /* loop on 
   syntax errors, return on EOF */

   - return (code != 0) ? 1 : 0;
   + return code;
  
  This breaks the exit command.
 so how can we get the correct exit code of a shell any idea?

Maybe it could be stored in struct p_context.

But beware, changes to this code have many non obvious side effects.
They require a good amount of testing. So if you send another patch in
five minutes I won't look at it.

Sascha

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] mfd: Using MFD_xx prefix for symbols

2013-02-15 Thread Alexander Shiyan
This patch provides rename MFD-related symbols for using MFD-prefix.
Additionally, sorting mfd/Kconfig and mfd/Makefile records.

Signed-off-by: Alexander Shiyan shc_w...@mail.ru
---
 arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c |  4 ++--
 arch/arm/configs/archosg9_defconfig   |  4 ++--
 arch/arm/configs/eukrea_cpuimx27_defconfig|  2 +-
 arch/arm/configs/omap3530_beagle_defconfig|  2 +-
 arch/arm/configs/pcm049_defconfig |  2 +-
 arch/arm/mach-imx/Kconfig |  4 ++--
 arch/arm/mach-omap/Makefile   |  2 +-
 drivers/gpio/Kconfig  |  2 +-
 drivers/mci/Makefile  |  2 +-
 drivers/mci/omap_hsmmc.c  |  4 ++--
 drivers/mfd/Kconfig   | 26 +++
 drivers/mfd/Makefile  | 18 
 drivers/usb/otg/Kconfig   |  2 +-
 include/mfd/mc34704.h |  6 +++---
 include/mfd/twl-core.h|  6 +++---
 include/mfd/twl4030.h |  6 +++---
 include/mfd/twl6030.h |  6 +++---
 17 files changed, 49 insertions(+), 49 deletions(-)

diff --git a/arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c 
b/arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c
index 65b6c44..d690581 100644
--- a/arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c
+++ b/arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c
@@ -230,14 +230,14 @@ console_initcall(eukrea_cpuimx27_console_init);
 
 static int eukrea_cpuimx27_late_init(void)
 {
-#ifdef CONFIG_I2C_LP3972
+#ifdef CONFIG_MFD_LP3972
struct i2c_client *client;
u8 reg[1];
 #endif
console_flush();
imx27_add_fec(fec_info);
 
-#ifdef CONFIG_I2C_LP3972
+#ifdef CONFIG_MFD_LP3972
client = lp3972_get_client();
if (!client)
return -ENODEV;
diff --git a/arch/arm/configs/archosg9_defconfig 
b/arch/arm/configs/archosg9_defconfig
index 9a051da..452d2ec 100644
--- a/arch/arm/configs/archosg9_defconfig
+++ b/arch/arm/configs/archosg9_defconfig
@@ -59,8 +59,8 @@ CONFIG_BAUDRATE=115200
 # CONFIG_SPI is not set
 CONFIG_I2C=y
 CONFIG_I2C_OMAP=y
-CONFIG_I2C_TWLCORE=y
-CONFIG_I2C_TWL6030=y
+CONFIG_MFD_TWLCORE=y
+CONFIG_MFD_TWL6030=y
 CONFIG_MCI=y
 CONFIG_MCI_STARTUP=y
 CONFIG_MCI_OMAP_HSMMC=y
diff --git a/arch/arm/configs/eukrea_cpuimx27_defconfig 
b/arch/arm/configs/eukrea_cpuimx27_defconfig
index 880941d..c751d1c 100644
--- a/arch/arm/configs/eukrea_cpuimx27_defconfig
+++ b/arch/arm/configs/eukrea_cpuimx27_defconfig
@@ -45,7 +45,7 @@ CONFIG_DRIVER_NET_FEC_IMX=y
 # CONFIG_SPI is not set
 CONFIG_I2C=y
 CONFIG_I2C_IMX=y
-CONFIG_I2C_LP3972=y
+CONFIG_MFD_LP3972=y
 CONFIG_DRIVER_CFI=y
 # CONFIG_DRIVER_CFI_AMD is not set
 # CONFIG_DRIVER_CFI_BANK_WIDTH_1 is not set
diff --git a/arch/arm/configs/omap3530_beagle_defconfig 
b/arch/arm/configs/omap3530_beagle_defconfig
index 1807e04..e3eee8d 100644
--- a/arch/arm/configs/omap3530_beagle_defconfig
+++ b/arch/arm/configs/omap3530_beagle_defconfig
@@ -80,7 +80,7 @@ CONFIG_USB_TWL4030=y
 CONFIG_MCI=y
 CONFIG_MCI_STARTUP=y
 CONFIG_MCI_OMAP_HSMMC=y
-CONFIG_I2C_TWL4030=y
+CONFIG_MFD_TWL4030=y
 CONFIG_FS_TFTP=y
 CONFIG_FS_NFS=y
 CONFIG_FS_FAT=y
diff --git a/arch/arm/configs/pcm049_defconfig 
b/arch/arm/configs/pcm049_defconfig
index 19df95a..80dbd71 100644
--- a/arch/arm/configs/pcm049_defconfig
+++ b/arch/arm/configs/pcm049_defconfig
@@ -64,7 +64,7 @@ CONFIG_USB=y
 CONFIG_MCI=y
 CONFIG_MCI_STARTUP=y
 CONFIG_MCI_OMAP_HSMMC=y
-CONFIG_I2C_TWL6030=y
+CONFIG_MFD_TWL6030=y
 CONFIG_FS_TFTP=y
 CONFIG_FS_FAT=y
 CONFIG_FS_FAT_WRITE=y
diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index 4115d35..4ab9767 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -247,7 +247,7 @@ config MACH_EUKREA_CPUIMX25
 config MACH_FREESCALE_MX25_3STACK
bool Freescale MX25 3stack
select I2C
-   select I2C_MC34704
+   select MFD_MC34704
help
  Say Y here if you are using the Freescale MX25 3stack board equipped
  with a Freescale i.MX25 Processor
@@ -354,7 +354,7 @@ config MACH_FREESCALE_MX35_3STACK
select I2C
select I2C_IMX
select MFD_MC13XXX
-   select I2C_MC9SDZ60
+   select MFD_MC9SDZ60
help
  Say Y here if you are using the Freescale MX35 3stack board equipped
  with a Freescale i.MX35 Processor
diff --git a/arch/arm/mach-omap/Makefile b/arch/arm/mach-omap/Makefile
index 94e42c6..aaa0cea 100644
--- a/arch/arm/mach-omap/Makefile
+++ b/arch/arm/mach-omap/Makefile
@@ -28,6 +28,6 @@ obj-$(CONFIG_OMAP3_CLOCK_CONFIG) += omap3_clock.o
 pbl-$(CONFIG_OMAP3_CLOCK_CONFIG) += omap3_clock.o
 obj-$(CONFIG_OMAP_GPMC) += gpmc.o devices-gpmc-nand.o
 obj-$(CONFIG_SHELL_NONE) += xload.o
-obj-$(CONFIG_I2C_TWL6030) += omap4_twl6030_mmc.o
+obj-$(CONFIG_MFD_TWL6030) += 

[PATCH] Make dev_get_resource publicly available

2013-02-15 Thread Alexander Shiyan

Signed-off-by: Alexander Shiyan shc_w...@mail.ru
---
 drivers/base/driver.c | 2 +-
 include/driver.h  | 4 
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index d4066fc..fa30c68 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -230,7 +230,7 @@ int register_driver(struct driver_d *drv)
 }
 EXPORT_SYMBOL(register_driver);
 
-static struct resource *dev_get_resource(struct device_d *dev, int num)
+struct resource *dev_get_resource(struct device_d *dev, int num)
 {
int i, n = 0;
 
diff --git a/include/driver.h b/include/driver.h
index 31f5d69..092a46b 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -193,6 +193,10 @@ static inline const char *dev_name(const struct device_d 
*dev)
 }
 
 /*
+ * get resource 'num' for a device
+ */
+struct resource *dev_get_resource(struct device_d *dev, int num);
+/*
  * get resource base 'name' for a device
  */
 struct resource *dev_get_resource_by_name(struct device_d *dev,
-- 
1.7.12.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox