[PATCH v3 2/4] include: mci: Add new ext. CSD field defines

2015-09-02 Thread Daniel Schultz
Added missing defines for the extended CSD register until standard 5.1.

Signed-off-by: Daniel Schultz 
---

Changes:
v2:
Changed patch order
Removed whitespaces from old defines

v3:
No changes

 include/mci.h | 99 +++
 1 file changed, 99 insertions(+)

diff --git a/include/mci.h b/include/mci.h
index a7bf8cd..9e4d18b 100644
--- a/include/mci.h
+++ b/include/mci.h
@@ -183,6 +183,105 @@
 #define EXT_CSD_CACHE_SIZE 249 /* RO, 4 bytes */
 #define EXT_CSD_HPI_FEATURES   503 /* RO */
 
+/* Added with the 5.1 standard */
+#define EXT_CSD_CMDQ_MODE_EN   15  /* RO */
+#define EXT_CSD_SECURE_REMOVAL_TYPE16  /* R/W */
+#define EXT_CSD_PRODUCT_ST8_AWARENSS_ENABLEMENT17  /* R/W */
+#define EXT_CSD_MAX_PRE_LOADING_DATA_SIZE  18  /* RO, 4 bytes */
+#define EXT_CSD_PRE_LOADING_DATA_SIZE  22  /* R/W, 4 bytes */
+#define EXT_CSD_FFU_STATUS 26  /* RO */
+#define EXT_CSD_MODE_OPERATION_CODES   29  /* W */
+#define EXT_CSD_MODE_CONFIG30  /* R/W */
+#define EXT_CSD_BARRIER_CTRL   31  /* R/W */
+#define EXT_CSD_PACKED_FAILURE_INDEX   35  /* RO */
+#define EXT_CSD_PACKED_COMMAND_STATUS  36  /* RO */
+#define EXT_CSD_CONTEXT_CONF   37  /* R/W, 15 bytes */
+#define EXT_CSD_EXT_PARTITIONS_ATTRIBUTE   52  /* R/W, 2 bytes */
+#define EXT_CSD_EXCEPTION_EVENTS_STATUS54  /* RO, 2 bytes 
*/
+#define EXT_CSD_EXCEPTION_EVENTS_CTRL  56  /* R/W, 2 bytes */
+#define EXT_CSD_CLASS_6_CTRL   59  /* R/W */
+#define EXT_CSD_INI_TIMEOUT_EMU60  /* RO */
+#define EXT_CSD_DATA_SECTOR_SIZE   61  /* RO */
+#define EXT_CSD_USE_NATIVE_SECTOR  62  /* RO */
+#define EXT_CSD_NATIVE_SECTOR_SIZE 63  /* RO */
+#define EXT_CSD_PROGRAM_CID_CSD_DDR_SUPPORT130 /* R/W */
+#define EXT_CSD_PERIODIC_WAKEUP131 /* R/W/ */
+#define EXT_CSD_TCASE_SUPPORT  132 /* R/W */
+#define EXT_CSD_PRODUCTION_STATE_AWARENESS 133 /* R/W */
+#define EXT_CSD_SEC_BAD_BLK_MGMNT  134 /* R/W */
+#define EXT_CSD_ENH_START_ADDR 136 /* R/W, 4 bytes */
+#define EXT_CSD_ENH_SIZE_MULT  140 /* R/W, 3 bytes */
+#define EXT_CSD_PARTITION_SETTING_COMPLETED155 /* R/W */
+#define EXT_CSD_PARTITIONS_ATTRIBUTE   156 /* R/W */
+#define EXT_CSD_MAX_ENH_SIZE_MULT  157 /* RO, 3 bytes */
+#define EXT_CSD_PARTITIONING_SUPPORT   160 /* RO */
+#define EXT_CSD_BKOPS_EN   163 /* R/W */
+#define EXT_CSD_BKOPS_START164 /* WO */
+#define EXT_CSD_WR_REL_SET 167 /* R/W */
+#define EXT_CSD_RPMB_SIZE_MULT 168 /* RO */
+#define EXT_CSD_FW_CONFIG  169 /* R/W */
+#define EXT_CSD_USER_WP171 /* R/W */
+#define EXT_CSD_BOOT_WP_STATUS 174 /* RO */
+#define EXT_CSD_BOOT_BUS_CONDITIONS177 /* R/W */
+#define EXT_CSD_BOOT_CONFIG_PROT   178 /* R/W */
+#define EXT_CSD_PARTITION_CONFIG   179 /* R/W */
+#define EXT_CSD_STROBE_SUPPORT 184 /* RO */
+#define EXT_CSD_CMD_SET_REV189 /* R/W */
+#define EXT_CSD_CMD_SET191 /* R/W */
+#define EXT_CSD_CSD_STRUCTURE  194 /* RO */
+#define EXT_CSD_DEVICE_TYPE196 /* RO */
+#define EXT_CSD_DRIVER_STRENGTH197 /* RO */
+#define EXT_CSD_PART_SWITCH_TIME   199 /* RO */
+#define EXT_CSD_PARTITION_SWITCH_TIME  199 /* RO */
+#define EXT_CSD_MIN_PERF_R_4_26205 /* RO */
+#define EXT_CSD_MIN_PERF_W_4_26206 /* RO */
+#define EXT_CSD_MIN_PERF_R_8_26_4_52   207 /* RO */
+#define EXT_CSD_MIN_PERF_W_8_26_4_52   208 /* RO */
+#define EXT_CSD_MIN_PERF_R_8_52209 /* RO */
+#define EXT_CSD_MIN_PERF_W_8_52210 /* RO */
+#define EXT_CSD_SECURE_WP_INFO 211 /* RO */
+#define EXT_CSD_SEC_COUNT  212 /* RO, 4 bytes */
+#define EXT_CSD_SLEEP_NOTIFICATION_TIME216 /* RO */
+#define EXT_CSD_PRODUCTION_ST8_AWARENSS_TIMEOUT218 /* RO */
+#define EXT_CSD_S_C_VCCQ   219 /* RO */
+#define EXT_CSD_S_C_VCC220 /* RO */
+#define EXT_CSD_ACC_SIZE   225 /* RO */
+#define EXT_CSD_BOOT_SIZE_MULT 226 /* RO */

[PATCH v3 1/4] drivers: mci: Make two functions public

2015-09-02 Thread Daniel Schultz
There is no possibility to read/write to the extended CSD register of
MMC devices from a command. To avoid duplicated driver code, two driver
functions have to be public.

Signed-off-by: Daniel Schultz 
---

Changes:
v2:
Changed patch order

v3:
No changes

 drivers/mci/mci-core.c | 4 ++--
 include/mci.h  | 3 +++
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index bd5cae2..c22f932 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -370,7 +370,7 @@ static int mmc_send_op_cond(struct mci *mci)
  * Note: Only cards newer than Version 1.1 (Physical Layer Spec) support
  * this command
  */
-static int mci_send_ext_csd(struct mci *mci, char *ext_csd)
+int mci_send_ext_csd(struct mci *mci, char *ext_csd)
 {
struct mci_cmd cmd;
struct mci_data data;
@@ -394,7 +394,7 @@ static int mci_send_ext_csd(struct mci *mci, char *ext_csd)
  * @param value FIXME
  * @return Transaction status (0 on success)
  */
-static int mci_switch(struct mci *mci, unsigned set, unsigned index,
+int mci_switch(struct mci *mci, unsigned set, unsigned index,
unsigned value)
 {
struct mci_cmd cmd;
diff --git a/include/mci.h b/include/mci.h
index c5ab5b3..a7bf8cd 100644
--- a/include/mci.h
+++ b/include/mci.h
@@ -372,6 +372,9 @@ struct mci {
 int mci_register(struct mci_host*);
 void mci_of_parse(struct mci_host *host);
 int mci_detect_card(struct mci_host *);
+int mci_send_ext_csd(struct mci *mci, char *ext_csd);
+int mci_switch(struct mci *mci, unsigned set, unsigned index,
+   unsigned value);
 
 static inline int mmc_host_is_spi(struct mci_host *host)
 {
-- 
1.9.1


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


[PATCH 2/2] ARM: am335x: Register eMMC MLO handler

2015-09-02 Thread Daniel Schultz
Register the eMMC MLO handler to the barebox_update command.

Signed-off-by: Daniel Schultz 
---
 arch/arm/boards/beaglebone/board.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boards/beaglebone/board.c 
b/arch/arm/boards/beaglebone/board.c
index 4e0e374..5717c45 100644
--- a/arch/arm/boards/beaglebone/board.c
+++ b/arch/arm/boards/beaglebone/board.c
@@ -38,6 +38,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "beaglebone.h"
 
@@ -92,6 +93,9 @@ static int beaglebone_devices_init(void)
 
armlinux_set_architecture(MACH_TYPE_BEAGLEBONE);
 
+   /* Register update handler */
+   am33xx_bbu_emmc_mlo_register_handler("MLO.emmc", "/dev/mmc1");
+
if (IS_ENABLED(CONFIG_SHELL_NONE))
return am33xx_of_register_bootdevice();
 
-- 
1.9.1


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


[PATCH 2/2] ARM: dts: Include strip file to Phytec am335x MLOs

2015-09-02 Thread Daniel Schultz
This patch disables the clocks in the Phytec am335x MLOs and reduce the MLO
size by 9kb.

Signed-off-by: Daniel Schultz 
---
 arch/arm/dts/am335x-phytec-phycard-som-mlo.dts | 1 +
 arch/arm/dts/am335x-phytec-phycore-som-mlo.dts | 1 +
 arch/arm/dts/am335x-phytec-phyflex-som-mlo.dts | 1 +
 3 files changed, 3 insertions(+)

diff --git a/arch/arm/dts/am335x-phytec-phycard-som-mlo.dts 
b/arch/arm/dts/am335x-phytec-phycard-som-mlo.dts
index f9ed627..a1755fd 100644
--- a/arch/arm/dts/am335x-phytec-phycard-som-mlo.dts
+++ b/arch/arm/dts/am335x-phytec-phycard-som-mlo.dts
@@ -10,6 +10,7 @@
 #include "am33xx.dtsi"
 #include "am335x-phytec-phycard-som.dtsi"
 #include "am33xx-strip.dtsi"
+#include "am33xx-clocks-strip.dtsi"
 
 / {
model = "Phytec phyCARD AM335x";
diff --git a/arch/arm/dts/am335x-phytec-phycore-som-mlo.dts 
b/arch/arm/dts/am335x-phytec-phycore-som-mlo.dts
index f70835f..676001b 100644
--- a/arch/arm/dts/am335x-phytec-phycore-som-mlo.dts
+++ b/arch/arm/dts/am335x-phytec-phycore-som-mlo.dts
@@ -10,6 +10,7 @@
 #include "am33xx.dtsi"
 #include "am335x-phytec-phycore-som.dtsi"
 #include "am33xx-strip.dtsi"
+#include "am33xx-clocks-strip.dtsi"
 
 / {
model = "Phytec phyCORE AM335x";
diff --git a/arch/arm/dts/am335x-phytec-phyflex-som-mlo.dts 
b/arch/arm/dts/am335x-phytec-phyflex-som-mlo.dts
index 736d7ef..e848a29 100644
--- a/arch/arm/dts/am335x-phytec-phyflex-som-mlo.dts
+++ b/arch/arm/dts/am335x-phytec-phyflex-som-mlo.dts
@@ -10,6 +10,7 @@
 #include "am33xx.dtsi"
 #include "am335x-phytec-phyflex-som.dtsi"
 #include "am33xx-strip.dtsi"
+#include "am33xx-clocks-strip.dtsi"
 
 / {
model = "Phytec phyFLEX AM335x";
-- 
1.9.1


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


[PATCH 1/2] ARM: dts: Add include to strip am33xx clocks

2015-09-02 Thread Daniel Schultz
Include this file to disable all clocks.

Signed-off-by: Daniel Schultz 
---
 arch/arm/dts/am33xx-clocks-strip.dtsi | 79 +++
 1 file changed, 79 insertions(+)
 create mode 100644 arch/arm/dts/am33xx-clocks-strip.dtsi

diff --git a/arch/arm/dts/am33xx-clocks-strip.dtsi 
b/arch/arm/dts/am33xx-clocks-strip.dtsi
new file mode 100644
index 000..831f163
--- /dev/null
+++ b/arch/arm/dts/am33xx-clocks-strip.dtsi
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2015 PHYTEC Messtechnik GmbH,
+ * Author: Daniel Schultz 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+/delete-node/ _tsc_fck;
+/delete-node/ _fck;
+/delete-node/ _fck;
+/delete-node/ _fck;
+/delete-node/ _fck;
+/delete-node/ _fck;
+/delete-node/ _fck;
+/delete-node/ _fck;
+/delete-node/ _fck;
+/delete-node/ _fck;
+/delete-node/ _tbclk;
+/delete-node/ _tbclk;
+/delete-node/ _tbclk;
+/delete-node/ _32768_ck;
+/delete-node/ _rc32k_ck;
+/delete-node/ _ck;
+/delete-node/ _core_m6_ck;
+/delete-node/ _mpu_m2_ck;
+/delete-node/ _ddr_ck;
+/delete-node/ _ddr_m2_ck;
+/delete-node/ _ddr_m2_div2_ck;
+/delete-node/ _disp_ck;
+/delete-node/ _disp_m2_ck;
+/delete-node/ _per_ck;
+/delete-node/ _per_m2_ck;
+/delete-node/ _per_m2_div4_wkupdm_ck;
+/delete-node/ _per_m2_div4_ck;
+/delete-node/ _fck;
+/delete-node/ _24mhz;
+/delete-node/ _ck;
+/delete-node/ _ick;
+/delete-node/ _gclk;
+/delete-node/ _ocp_gclk;
+/delete-node/ _fck;
+/delete-node/ _fck;
+/delete-node/ _fck;
+/delete-node/ _fck;
+/delete-node/ _fck;
+/delete-node/ _fck;
+/delete-node/ _fck;
+/delete-node/ _fck;
+/delete-node/ _fck;
+/delete-node/ _core_m4_div2_ck;
+/delete-node/ _fck;
+/delete-node/ _fck;
+/delete-node/ _rtc_gclk;
+/delete-node/ _gclk;
+/delete-node/ _gclk;
+/delete-node/ _gclk;
+/delete-node/ _gclk;
+/delete-node/ _div_ck;
+/delete-node/ _dbclk_mux_ck;
+/delete-node/ _dbclk;
+/delete-node/ _dbclk;
+/delete-node/ _dbclk;
+/delete-node/ _dbclk;
+/delete-node/ _gclk;
+/delete-node/ _clk;
+/delete-node/ _fclk_clksel_ck;
+/delete-node/ _fck_div_ck;
+/delete-node/ _pre_ck;
+/delete-node/ _div_ck;
+/delete-node/ _sysclk_ck;
+/delete-node/ _clka_ck;
+/delete-node/ _pmd_clock_mux_ck;
+/delete-node/ _pmd_clk_mux_ck;
+/delete-node/ _clk_div_ck;
+/delete-node/ _clk_div_ck;
+/delete-node/ _ck;
+/delete-node/ _24mhz_clkdm;
-- 
1.9.1


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


[PATCH resend 1/2] video: vpl: depend on OFTREE

2015-09-02 Thread Lucas Stach
VPL uses the of_graph bindings, which are only available if OFTREE
support is compiled in.

Also fix the drivers using VPL to depend on OFTREE.

Signed-off-by: Lucas Stach 
---
 drivers/video/Kconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 501e9fa7d353..d31bdfe8f07a 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -13,6 +13,7 @@ config FRAMEBUFFER_CONSOLE
prompt "framebuffer console support"
 
 config VIDEO_VPL
+   depends on OFTREE
bool
 
 config DRIVER_VIDEO_ATMEL
@@ -121,6 +122,7 @@ config DRIVER_VIDEO_MTL017
bool "MTL017 LVDS encoder"
select VIDEO_VPL
depends on I2C
+   depends on OFTREE
help
  The MTL017 is a parallel to lvds video encoder chip found on the
  Efika MX Smartbook.
@@ -128,6 +130,7 @@ config DRIVER_VIDEO_MTL017
 config DRIVER_VIDEO_SIMPLE_PANEL
bool "Simple panel support"
select VIDEO_VPL
+   depends on OFTREE
help
  This enabled support for simple panels, i.e. panels which consist of
  a mode definition and enable gpios in the devicetree. Unlike the
-- 
2.5.0


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


[PATCH resend 2/2] video: imx-hdmi: depend on EDID support

2015-09-02 Thread Lucas Stach
HDMI support is not generally useful without EDID support.

Fixes:
In function `imx_hdmi_ioctl':
undefined reference to `edid_read_i2c'
undefined reference to `edid_to_display_timings'

Signed-off-by: Lucas Stach 
---
 drivers/video/imx-ipu-v3/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/video/imx-ipu-v3/Kconfig b/drivers/video/imx-ipu-v3/Kconfig
index 386ff5bc2ef0..b5ee4efb1566 100644
--- a/drivers/video/imx-ipu-v3/Kconfig
+++ b/drivers/video/imx-ipu-v3/Kconfig
@@ -13,6 +13,7 @@ config DRIVER_VIDEO_IMX_IPUV3_LVDS
 
 config DRIVER_VIDEO_IMX_IPUV3_HDMI
bool "IPUv3 HDMI support"
+   depends on DRIVER_VIDEO_EDID
select OFDEVICE
 
 endif
-- 
2.5.0


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


[PATCH v3 4/4] commands: Add MMC ext. CSD register tool

2015-09-02 Thread Daniel Schultz
This tools can read/write to the extended CSD register of MMC devices.

Signed-off-by: Daniel Schultz 
---

Changes:
v2:
Changed patch order

v3:
Splitted output in different functions to reduce the indentation.
Minimized strings and optimized printfs.
Refactored main function

 commands/Kconfig  |   16 +
 commands/Makefile |1 +
 commands/mmc_extcsd.c | 2041 +
 3 files changed, 2058 insertions(+)
 create mode 100644 commands/mmc_extcsd.c

diff --git a/commands/Kconfig b/commands/Kconfig
index 133dcbf..c7be573 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -242,6 +242,22 @@ config CMD_VERSION
 
  barebox 2014.05.0-00142-gb289373 #177 Mon May 12 20:35:55 CEST 2014
 
+config CMD_MMC_EXTCSD
+   tristate
+   prompt "read/write eMMC ext. CSD register"
+   depends on MCI
+   help
+ Read or write the extended CSD register of a MMC device.
+
+ Usage: mmc_extcsd dev [-r | -i index [-r | -v value -y]]
+
+ Options:
+ -i  field index of the register
+ -r  print the register as raw data
+ -v  value which will be written
+ -y  don't request when writing to one time programmable 
fields
+ __CAUTION__: this could damage the device!
+
 # end Information commands
 endmenu
 
diff --git a/commands/Makefile b/commands/Makefile
index 3d594c3..d985341 100644
--- a/commands/Makefile
+++ b/commands/Makefile
@@ -114,3 +114,4 @@ obj-$(CONFIG_CMD_STATE) += state.o
 obj-$(CONFIG_CMD_DHCP) += dhcp.o
 obj-$(CONFIG_CMD_DHRYSTONE)+= dhrystone.o
 obj-$(CONFIG_CMD_SPD_DECODE)   += spd_decode.o
+obj-$(CONFIG_CMD_MMC_EXTCSD)   += mmc_extcsd.o
diff --git a/commands/mmc_extcsd.c b/commands/mmc_extcsd.c
new file mode 100644
index 000..7c5af48
--- /dev/null
+++ b/commands/mmc_extcsd.c
@@ -0,0 +1,2041 @@
+/*
+ *
+ * (C) Copyright 2015 Phytec Messtechnik GmbH
+ * Author: Daniel Schultz 
+ *
+ * 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define EXT_CSD_BLOCKSIZE  512
+
+/* Access types */
+#define R  "R"
+#define RW "R/W"
+#define RWaR   "R/W & R"
+#define RWaRWE "R/W & R/W/E"
+#define RWaRWC_P   "R/W & R/W/C_P"
+#define RWaRWC_PaRWE_P "R/W, R/W/C_P & R/W/E_P"
+#define WE "W/E"
+#define RWE"R/W/E"
+#define RWEaR  "R/W/E & R"
+#define RWEaRWE_P  "R/W/E & R/W/E_P"
+#define RWC_P  "R/W/C_P"
+#define RWE_P  "R/W/E_P"
+#define WE_P   "W/E_P"
+
+#define print_field_caption(reg_name, access_mode)\
+   do {   \
+   printf(#reg_name"[%u]:\n", EXT_CSD_##reg_name);\
+   printf("\tValue: %#02x\n", reg[index]);\
+   printf("\tAccess: "access_mode"\n");   \
+   } while (false);
+
+#define print_field_caption_with_offset(reg_name, offset, access_mode)\
+   do {   \
+   printf(#reg_name"[%u]:\n", EXT_CSD_##reg_name + offset);   \
+   printf("\tValue: %#02x\n", reg[index]);\
+   printf("\tAccess: "access_mode"\n");   \
+   } while (false);
+
+#define get_field_val(reg_name, offset, mask) \
+   ((reg[EXT_CSD_##reg_name] >> offset) & mask)
+
+#define get_field_val_with_index(index, offset, mask) \
+   ((reg[index] >> offset) & mask)
+
+static void print_access_type_key(void)
+{
+   printf("\nR:   Read only.\n");
+   printf("W:   One time programmable and not readable.\n");
+   printf("R/W: One time programmable and readable.\n");
+   printf("W/E: Multiple writable with value kept after power failure, 
H/W reset assertion and any CMD0 reset and not readable.\n");
+   printf("R/W/E:   Multiple writable with value kept after power failure, 
H/W reset assertion and any CMD0 reset and readable.\n");
+   printf("R/W/C_P: Writable after value cleared by power failure and 
HW/rest assertion (the value not cleared by CMD0 reset) and 

[PATCH v3 3/4] drivers: mci: Add mci_get_device_by_name function

2015-09-02 Thread Daniel Schultz
Get a 'struct mci' by search after the device name.

Signed-off-by: Daniel Schultz 
---

Changes:
v3:
New with patch v3

 drivers/mci/mci-core.c | 16 
 include/mci.h  |  8 
 2 files changed, 24 insertions(+)

diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index c22f932..d6865d1 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -53,6 +53,8 @@
__res & __mask; \
})
 
+LIST_HEAD(mci_list);
+
 /**
  * @file
  * @brief Memory Card framework
@@ -1753,6 +1755,8 @@ int mci_register(struct mci_host *host)
mci->dev.id = DEVICE_ID_DYNAMIC;
}
 
+   list_add_tail(>list, _list);
+
mci->dev.platform_data = host;
mci->dev.parent = host->hw_dev;
mci->host = host;
@@ -1844,3 +1848,15 @@ void mci_of_parse(struct mci_host *host)
 
host->non_removable = of_property_read_bool(np, "non-removable");
 }
+
+struct mci *mci_get_device_by_name(const char *name)
+{
+   struct mci *dev;
+
+   for_each_mci_device(dev) {
+   if (!strcmp(dev->cdevname, name))
+   return dev;
+   }
+
+   return NULL;
+}
diff --git a/include/mci.h b/include/mci.h
index 9e4d18b..3c7b407 100644
--- a/include/mci.h
+++ b/include/mci.h
@@ -466,6 +466,8 @@ struct mci {
 
struct mci_part *part_curr;
u8 ext_csd_part_config;
+
+   struct list_head list; /* The list of all mci devices */
 };
 
 int mci_register(struct mci_host*);
@@ -483,4 +485,10 @@ static inline int mmc_host_is_spi(struct mci_host *host)
return 0;
 }
 
+/* Iterate over all mci devices
+ */
+#define for_each_mci_device(dev) list_for_each_entry(dev, _list, list)
+
+struct mci *mci_get_device_by_name(const char *name);
+
 #endif /* _MCI_H_ */
-- 
1.9.1


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


[PATCH 1/2] ARM: am33xx: Add barebox_update eMMC option

2015-09-02 Thread Daniel Schultz
With this patch the barebox_update command will be extended by the possibility
to flash the MLO to eMMC devices.

The MLO will be flashed to the following addresses:
0x2
0x4
0x6

The MBR at addr. 0x0 won't be overwritten.
Therefore it's necessary to remove the MLO in the boot partition.

Signed-off-by: Daniel Schultz 
---
 arch/arm/configs/am335x_defconfig |  1 +
 arch/arm/mach-omap/Kconfig|  7 
 arch/arm/mach-omap/Makefile   |  1 +
 arch/arm/mach-omap/am33xx_bbu_emmc.c  | 78 +++
 arch/arm/mach-omap/include/mach/bbu.h | 18 
 5 files changed, 105 insertions(+)
 create mode 100644 arch/arm/mach-omap/am33xx_bbu_emmc.c

diff --git a/arch/arm/configs/am335x_defconfig 
b/arch/arm/configs/am335x_defconfig
index 559f56a..c5ab3c9 100644
--- a/arch/arm/configs/am335x_defconfig
+++ b/arch/arm/configs/am335x_defconfig
@@ -1,6 +1,7 @@
 CONFIG_ARCH_OMAP=y
 CONFIG_BAREBOX_UPDATE_AM33XX_SPI_NOR_MLO=y
 CONFIG_BAREBOX_UPDATE_AM33XX_NAND=y
+CONFIG_BAREBOX_UPDATE_AM33XX_EMMC=y
 CONFIG_OMAP_MULTI_BOARDS=y
 CONFIG_MACH_AFI_GF=y
 CONFIG_MACH_BEAGLEBONE=y
diff --git a/arch/arm/mach-omap/Kconfig b/arch/arm/mach-omap/Kconfig
index fb17df0..0df38e1 100644
--- a/arch/arm/mach-omap/Kconfig
+++ b/arch/arm/mach-omap/Kconfig
@@ -105,6 +105,13 @@ config BAREBOX_UPDATE_AM33XX_NAND
  This also includes a handler for updating the regular barebox binary
  in NAND.
 
+config BAREBOX_UPDATE_AM33XX_EMMC
+   prompt "barebox update eMMC handler"
+   bool
+   depends on BAREBOX_UPDATE
+   help
+ Say Y for barebox update eMMC handler.
+
 config ARCH_TEXT_BASE
hex
default 0x80e8 if MACH_OMAP343xSDP
diff --git a/arch/arm/mach-omap/Makefile b/arch/arm/mach-omap/Makefile
index bef1d05..82f1a9e 100644
--- a/arch/arm/mach-omap/Makefile
+++ b/arch/arm/mach-omap/Makefile
@@ -34,3 +34,4 @@ obj-$(CONFIG_OMAP4_USBBOOT) += omap4_rom_usb.o
 obj-$(CONFIG_CMD_BOOT_ORDER) += boot_order.o
 obj-$(CONFIG_BAREBOX_UPDATE_AM33XX_SPI_NOR_MLO) += am33xx_bbu_spi_mlo.o
 obj-$(CONFIG_BAREBOX_UPDATE_AM33XX_NAND) += am33xx_bbu_nand.o
+obj-$(CONFIG_BAREBOX_UPDATE_AM33XX_EMMC) += am33xx_bbu_emmc.o
diff --git a/arch/arm/mach-omap/am33xx_bbu_emmc.c 
b/arch/arm/mach-omap/am33xx_bbu_emmc.c
new file mode 100644
index 000..1c1bebc
--- /dev/null
+++ b/arch/arm/mach-omap/am33xx_bbu_emmc.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2015 Phytec Messtechnik GmbH
+ * Author: Daniel Schultz 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int emmc_mlo_handler(struct bbu_handler *handler, struct bbu_data *data)
+{
+   int ret = 0;
+   int i = 0;
+   int fd;
+   const void *image = data->image;
+   size_t size = data->len;
+
+   if (file_detect_type(image, size) != filetype_ch_image) {
+   pr_err("%s is not a valid ch-image\n", data->imagefile);
+   return -EINVAL;
+   }
+   ret = bbu_confirm(data);
+   if (ret != 0)
+   return ret;
+
+   fd = open(handler->devicefile, O_WRONLY);
+   if (fd < 0) {
+   pr_err("could not open %s: %s\n", handler->devicefile,
+   errno_str());
+   return fd;
+   }
+
+   for (i = 1; i < 4; i++) {
+   ret = pwrite(fd, image, size, i * 0x2);
+   if (ret < 0) {
+   pr_err("could not write to fd %s: %s\n",
+   handler->devicefile, errno_str());
+   close(fd);
+   return ret;
+   }
+   }
+   close(fd);
+
+   printf("Remove the MLO from the %s boot partition.\nOtherwise the wrong 
MLO may be loaded!\n",
+   handler->devicefile);
+
+   return 0;
+}
+
+int am33xx_bbu_emmc_mlo_register_handler(const char *name, char *devicefile)
+{
+   struct bbu_handler *handler;
+   int ret;
+
+   handler = xzalloc(sizeof(*handler));
+   handler->devicefile = devicefile;
+   handler->name = name;
+   handler->handler = emmc_mlo_handler;
+
+   ret = bbu_register_handler(handler);
+
+   if (ret)
+   free(handler);
+
+   return ret;
+}
diff --git a/arch/arm/mach-omap/include/mach/bbu.h 
b/arch/arm/mach-omap/include/mach/bbu.h
index 36d87e1..4d1b4fa 100644
--- a/arch/arm/mach-omap/include/mach/bbu.h
+++ b/arch/arm/mach-omap/include/mach/bbu.h
@@ -37,4 +37,22 @@ static inline int 

[PATCH] ata: ide-sff: fix integer overflow in ata_wait_ready()

2015-09-02 Thread Peter Mamonov
Signed-off-by: Peter Mamonov 
---
 drivers/ata/ide-sff.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ata/ide-sff.c b/drivers/ata/ide-sff.c
index a8f2b26..e32cc3f 100644
--- a/drivers/ata/ide-sff.c
+++ b/drivers/ata/ide-sff.c
@@ -118,7 +118,7 @@ static int ata_wait_ready(struct ide_port *ide, unsigned 
timeout)
 {
uint8_t status;
uint64_t start = get_time_ns();
-   uint64_t toffs = timeout * 1000 * 1000;
+   uint64_t toffs = timeout * MSECOND;
 
do {
status = ata_rd_status(ide);
-- 
2.1.4


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