[PATCH 4/5] common: state: Make find_var public

2017-10-27 Thread Daniel Schultz
Make find_var public to grant access to state variables.

Make also the MAC node public to receive the stored address.

Signed-off-by: Daniel Schultz 
---
 common/state/state.h | 27 +--
 include/state.h  | 26 ++
 2 files changed, 27 insertions(+), 26 deletions(-)

diff --git a/common/state/state.h b/common/state/state.h
index 81aaec2..0fca848 100644
--- a/common/state/state.h
+++ b/common/state/state.h
@@ -1,6 +1,7 @@
 #include 
 #include 
 #include 
+#include 
 
 struct state;
 struct mtd_info_user;
@@ -128,16 +129,6 @@ struct variable_type {
  struct device_node *);
 };
 
-/* instance of a single variable */
-struct state_variable {
-   struct state *state;
-   struct list_head list;
-   const char *name;
-   unsigned int start;
-   unsigned int size;
-   void *raw;
-};
-
 /*
  *  uint32
  */
@@ -161,16 +152,6 @@ struct state_enum32 {
 };
 
 /*
- *  MAC address
- */
-struct state_mac {
-   struct state_variable var;
-   struct param_d *param;
-   uint8_t value[6];
-   uint8_t value_default[6];
-};
-
-/*
  *  string
  */
 struct state_string {
@@ -204,7 +185,6 @@ int state_backend_bucket_circular_create(struct device_d 
*dev, const char *path,
 int state_backend_bucket_cached_create(struct device_d *dev,
   struct state_backend_storage_bucket *raw,
   struct state_backend_storage_bucket 
**out);
-struct state_variable *state_find_var(struct state *state, const char *name);
 struct digest *state_backend_format_raw_get_digest(struct state_backend_format
   *format);
 void state_backend_set_readonly(struct state *state);
@@ -229,11 +209,6 @@ static inline struct state_enum32 *to_state_enum32(struct 
state_variable *s)
return container_of(s, struct state_enum32, var);
 }
 
-static inline struct state_mac *to_state_mac(struct state_variable *s)
-{
-   return container_of(s, struct state_mac, var);
-}
-
 static inline struct state_string *to_state_string(struct state_variable *s)
 {
return container_of(s, struct state_string, var);
diff --git a/include/state.h b/include/state.h
index 63164f9..ae67d95 100644
--- a/include/state.h
+++ b/include/state.h
@@ -5,6 +5,30 @@
 
 struct state;
 
+/* instance of a single variable */
+struct state_variable {
+   struct state *state;
+   struct list_head list;
+   const char *name;
+   unsigned int start;
+   unsigned int size;
+   void *raw;
+};
+
+/*
+ *  MAC address
+ */
+struct state_mac {
+   struct state_variable var;
+   struct param_d *param;
+   uint8_t value[6];
+   uint8_t value_default[6];
+};
+static inline struct state_mac *to_state_mac(struct state_variable *s)
+{
+   return container_of(s, struct state_mac, var);
+}
+
 int state_backend_dtb_file(struct state *state, const char *of_path,
const char *path);
 int state_backend_raw_file(struct state *state, const char *of_path,
@@ -23,4 +47,6 @@ int state_load(struct state *state);
 int state_save(struct state *state);
 void state_info(void);
 
+struct state_variable *state_find_var(struct state *state, const char *name);
+
 #endif /* __STATE_H */
-- 
2.7.4


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


[PATCH 1/5] ARM: boards: phytec-som-am335x: Add unified MLO

2017-10-27 Thread Daniel Schultz
PCM-060 modules only have one-bank RAMs populated, which allows us to
find out the populated RAM size at run-time.

Therefore, a new entry point was create 'PHYTEC_ENTRY_UNIFIED_MLO'. This
creates a MLO for all modules of one family and all existing PCM-060
MLOs were replaced with this new entry point. To provide backward
compatibility for older modules, these were not affected.

In the first step generic RAM timings for the module family get loaded,
because RAM accesses are only possible with an initialized controller.
After that, the RAM size will be calculated and the RAM controller gets
reinitialized with the correct RAM timings.

Signed-off-by: Daniel Schultz 
---
 arch/arm/boards/phytec-som-am335x/lowlevel.c | 150 +++
 images/Makefile.am33xx   |  24 ++---
 2 files changed, 138 insertions(+), 36 deletions(-)

diff --git a/arch/arm/boards/phytec-som-am335x/lowlevel.c 
b/arch/arm/boards/phytec-som-am335x/lowlevel.c
index 77f436f..b1576ee 100644
--- a/arch/arm/boards/phytec-som-am335x/lowlevel.c
+++ b/arch/arm/boards/phytec-som-am335x/lowlevel.c
@@ -46,6 +46,94 @@ static const struct am33xx_cmd_control physom_cmd = {
.invert_clkout2 = 0x0,
 };
 
+/* Module family for the unified MLO
+ *
+ * NONE:Unified MLO is not supported
+ * PHYCORE_R2:  Unified MLO for PCM-060, PCM-062
+ */
+enum {
+   NONE,
+   PHYCORE_R2,
+};
+
+/* @brief Supplies default ram timings for all ram sizes
+ *
+ * Returns generic ram timings for module families to find the correct
+ * ram size.
+ *
+ * @return struct am335x_sdram_timings* or NULL
+ */
+
+static noinline struct am335x_sdram_timings* get_minimal_timings(
+   int module_family)
+{
+   struct am335x_sdram_timings *timing;
+
+   switch (module_family) {
+   case PHYCORE_R2:
+   timing = _timings[PHYCORE_R2_MT41K512M16HA125IT_1024MB];
+   break;
+   default:
+   timing = NULL;
+   }
+
+   return timing;
+}
+
+/* @brief Converts ramsizes to ram timings for phyCORE-R2 modules
+ *
+ * Returns ram timings for a given ram size or NULL, if this size is
+ * not supported.
+ *
+ * @return struct am335x_sdram_timings* or NULL
+ */
+
+static noinline struct am335x_sdram_timings* convert_phycore_r2_timings(
+   u32 ramsize)
+{
+   struct am335x_sdram_timings *timing;
+
+   switch (ramsize) {
+   case SZ_256M:
+   timing = _timings[PHYCORE_R2_MT41K128M16JT_256MB];
+   break;
+   case SZ_512M:
+   timing = _timings[PHYCORE_R2_MT41K256M16TW107IT_512MB];
+   break;
+   case SZ_1G:
+   timing = _timings[PHYCORE_R2_MT41K512M16HA125IT_1024MB];
+   break;
+   default:
+   timing = NULL;
+   }
+
+   return timing;
+}
+
+/* @brief Converts a module family and ram size to ram timings
+ *
+ * Returns ram timings for a given ram size and module family or NULL,
+ * if the ram size or module family is not supported.
+ *
+ * @return struct am335x_sdram_timings* or NULL
+ */
+
+static noinline struct am335x_sdram_timings* get_timings_by_size(
+   int module_family, u32 ramsize)
+{
+   struct am335x_sdram_timings *timing;
+
+   switch (module_family) {
+   case PHYCORE_R2:
+   timing = convert_phycore_r2_timings(ramsize);
+   break;
+   default:
+   timing = NULL;
+   }
+
+   return timing;
+}
+
 /**
  * @brief The basic entry point for board initialization.
  *
@@ -55,9 +143,10 @@ static const struct am33xx_cmd_control physom_cmd = {
  *
  * @return void
  */
-static noinline void physom_board_init(int sdram, void *fdt)
+static noinline void physom_board_init(void *fdt, int sdram, int module_family)
 {
-   struct am335x_sdram_timings *timing = _timings[sdram];
+   struct am335x_sdram_timings *timing = NULL;
+   u32 ramsize;
 
/*
 * WDT1 is already running when the bootloader gets control
@@ -71,6 +160,24 @@ static noinline void physom_board_init(int sdram, void *fdt)
 
am33xx_pll_init(MPUPLL_M_600, DDRPLL_M_400);
 
+   if (module_family == NONE) {
+   timing = _timings[sdram];
+   } else {
+   /* Load generic DDR3 ram timings to find the ram size */
+   timing = get_minimal_timings(module_family);
+   if (!timing)
+   hang();
+   am335x_sdram_init(DDR_IOCTRL, _cmd,
+   >regs,
+   >data);
+
+   /* Find the ram size and set up the correct ram timings */
+   ramsize = get_ram_size((long *) 0x8000, SZ_1G);
+   timing = get_timings_by_size(module_family, ramsize);
+   if (!timing)
+   

[PATCH 2/3] ARM: dts: AM335x: Add dummy i2c nodes

2017-10-27 Thread Daniel Schultz
These i2c nodes are needed for autoenable of i2c clients, because
the autoenable API searches for device tree nodes to get the client
address.

Signed-off-by: Daniel Schultz 
---
 arch/arm/dts/am335x-phytec-phycore-som.dtsi | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/arch/arm/dts/am335x-phytec-phycore-som.dtsi 
b/arch/arm/dts/am335x-phytec-phycore-som.dtsi
index dbc6424..cf2eef3 100644
--- a/arch/arm/dts/am335x-phytec-phycore-som.dtsi
+++ b/arch/arm/dts/am335x-phytec-phycore-som.dtsi
@@ -164,6 +164,20 @@
pagesize = <32>;
reg = <0x52>;
};
+
+   /* The following i2c nodes are for the autoenable */
+   i2c_tmp102: temp@4b {
+   compatible = "ti,tmp102";
+   reg = <0x4b>;
+   status = "disabled";
+   };
+
+   i2c_rtc: rtc@68 {
+   compatible = "rv4162";
+   reg = <0x68>;
+   status = "disabled";
+   };
+
 };
 
  {
-- 
2.7.4


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


[PATCH 2/5] ARM: dts: AM335x: Add state framework

2017-10-27 Thread Daniel Schultz
This patch adds the state framework with an EEPROM partition and two
nodes for MAC addresses. It will be available for all phycore AM335x
images with EEPROMs.

Signed-off-by: Daniel Schultz 
---
 arch/arm/dts/am335x-phytec-phycore-som-emmc.dts|  1 +
 .../dts/am335x-phytec-phycore-som-nand-no-spi.dts  |  1 +
 arch/arm/dts/am335x-phytec-phycore-som-nand.dts|  1 +
 arch/arm/dts/am335x-phytec-state.dtsi  | 52 ++
 4 files changed, 55 insertions(+)
 create mode 100644 arch/arm/dts/am335x-phytec-state.dtsi

diff --git a/arch/arm/dts/am335x-phytec-phycore-som-emmc.dts 
b/arch/arm/dts/am335x-phytec-phycore-som-emmc.dts
index 880700e..f264498 100644
--- a/arch/arm/dts/am335x-phytec-phycore-som-emmc.dts
+++ b/arch/arm/dts/am335x-phytec-phycore-som-emmc.dts
@@ -16,6 +16,7 @@
 
 #include "am33xx.dtsi"
 #include "am335x-phytec-phycore-som.dtsi"
+#include "am335x-phytec-state.dtsi"
 
 / {
model = "Phytec phyCORE EMMC AM335x";
diff --git a/arch/arm/dts/am335x-phytec-phycore-som-nand-no-spi.dts 
b/arch/arm/dts/am335x-phytec-phycore-som-nand-no-spi.dts
index 2c2fab0..b35294c 100644
--- a/arch/arm/dts/am335x-phytec-phycore-som-nand-no-spi.dts
+++ b/arch/arm/dts/am335x-phytec-phycore-som-nand-no-spi.dts
@@ -9,6 +9,7 @@
 
 #include "am33xx.dtsi"
 #include "am335x-phytec-phycore-som.dtsi"
+#include "am335x-phytec-state.dtsi"
 
 / {
model = "Phytec phyCORE AM335x";
diff --git a/arch/arm/dts/am335x-phytec-phycore-som-nand.dts 
b/arch/arm/dts/am335x-phytec-phycore-som-nand.dts
index 6ff2447..4d7606b 100644
--- a/arch/arm/dts/am335x-phytec-phycore-som-nand.dts
+++ b/arch/arm/dts/am335x-phytec-phycore-som-nand.dts
@@ -9,6 +9,7 @@
 
 #include "am33xx.dtsi"
 #include "am335x-phytec-phycore-som.dtsi"
+#include "am335x-phytec-state.dtsi"
 
 / {
model = "Phytec phyCORE AM335x";
diff --git a/arch/arm/dts/am335x-phytec-state.dtsi 
b/arch/arm/dts/am335x-phytec-state.dtsi
new file mode 100644
index 000..fbc35b9
--- /dev/null
+++ b/arch/arm/dts/am335x-phytec-state.dtsi
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+/ {
+   aliases {
+   am335x_phytec_mac_state = _phytec_mac_state;
+   };
+
+   am335x_phytec_mac_state: am335x_phytec_mac_state {
+   magic = <0x3f45620e>;
+   compatible = "barebox,state";
+   backend-type = "raw";
+   backend = <_state_eeprom>;
+   backend-stridesize = <40>;
+
+   #address-cells = <1>;
+   #size-cells = <1>;
+   mac0 {
+   reg = <0x0 0x6>;
+   type = "mac";
+   };
+   mac1 {
+   reg = <0x6 0x6>;
+   type = "mac";
+   };
+
+   };
+};
+
+ {
+   status = "okay";
+   partitions {
+   compatible = "fixed-partitions";
+   #size-cells = <1>;
+   #address-cells = <1>;
+   backend_state_eeprom: state@0 {
+   reg = <0x000 0x120>;
+   label = "state-eeprom";
+   };
+   };
+};
-- 
2.7.4


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


[PATCH 1/3] common: Add autoenable for components

2017-10-27 Thread Daniel Schultz
This patch adds an API to automatically enable either hardware components
with existing device drivers or i2c clients. All functions take a device
tree path to find the hardware and will fix up the node status in the
kernel device tree, if it's accessible.

Signed-off-by: Daniel Schultz 
---
 common/Kconfig   |   9 +
 common/Makefile  |   1 +
 common/autoenable.c  | 109 +++
 include/autoenable.h |  21 ++
 4 files changed, 140 insertions(+)
 create mode 100644 common/autoenable.c
 create mode 100644 include/autoenable.h

diff --git a/common/Kconfig b/common/Kconfig
index 57418ca..8d2a3e6 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -712,6 +712,15 @@ config CONSOLE_NONE
 
 endchoice
 
+config KERNEL_AUTOENABLE
+   bool
+   prompt "Autoenable of components"
+   help
+ Say Y to unlock an API for automatically enable either hardware
+ components with existing device drivers or i2c clients. All functions
+ take a device tree path to find the hardware and will fix up the node
+ status in the kernel device tree, if it's accessible.
+
 choice
prompt "Console activation strategy"
depends on CONSOLE_FULL
diff --git a/common/Makefile b/common/Makefile
index 8cd0ab3..4d7b0f9 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -31,6 +31,7 @@ obj-$(CONFIG_FLEXIBLE_BOOTARGS)   += bootargs.o
 obj-$(CONFIG_GLOBALVAR)+= globalvar.o
 obj-$(CONFIG_GREGORIAN_CALENDER) += date.o
 obj-$(CONFIG_KALLSYMS) += kallsyms.o
+obj-$(CONFIG_KERNEL_AUTOENABLE) += autoenable.o
 obj-$(CONFIG_MALLOC_DLMALLOC)  += dlmalloc.o
 obj-$(CONFIG_MALLOC_TLSF)  += tlsf_malloc.o tlsf.o
 obj-$(CONFIG_MALLOC_DUMMY) += dummy_malloc.o
diff --git a/common/autoenable.c b/common/autoenable.c
new file mode 100644
index 000..be76942
--- /dev/null
+++ b/common/autoenable.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2017 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 
+
+/**
+ * autoenable_device_by_path() - Autoenable a device by a device tree path
+ * @param path Device tree path up from the root to the device
+ * @return 0 on success, -enodev on failure. If no device found in the device
+ * tree.
+ *
+ * This function will search for a device and will enable it in the kernel
+ * device tree, if it exists and is loaded.
+ */
+int autoenable_device_by_path(char *path)
+{
+   struct device_d *device;
+   struct device_node *node;
+   int ret;
+
+   node = of_find_node_by_name(NULL, path);
+   if (!node)
+   node = of_find_node_by_path(path);
+
+   if (!node)
+   return -ENODEV;
+
+   device = of_find_device_by_node(node);
+   if (!device)
+   return -ENODEV;
+
+   ret = of_register_set_status_fixup(path, 1);
+   if (!ret)
+   printf("autoenabled %s\n", device->name);
+   return ret;
+}
+
+/**
+ * autoenable_i2c_by_path - Autoenable a i2c client by a device tree path
+ * @param path Device tree path up from the root to the i2c client
+ * @return 0 on success, -enodev on failure. If no i2c client found in the i2c
+ * device tree.
+ *
+ * This function will search for a i2c client, tries to write to the client and
+ * will enable it in the kernel device tree, if it exists and is accessible.
+ */
+int autoenable_i2c_by_path(char *path)
+{
+   struct device_node *node;
+   struct i2c_adapter *i2c_adapter;
+   struct i2c_msg msg;
+   char data[1] = {0x0};
+   int addr;
+   const __be32 *ip;
+   int ret;
+
+   node = of_find_node_by_name(NULL, path);
+   if (!node)
+   node = of_find_node_by_path(path);
+   if (!node)
+   return -ENODEV;
+   if (!node->parent)
+   return -ENODEV;
+
+   ip = of_get_property(node, "reg", NULL);
+   if (!ip)
+   return -ENODEV;
+   addr = be32_to_cpup(ip);
+
+   i2c_adapter = of_find_i2c_adapter_by_node(node->parent);
+   if (!i2c_adapter)
+   return -ENODEV;
+
+   msg.buf = data;
+   msg.addr = addr;
+   msg.len = 1;
+
+   /* Try to communicate with the i2c client */
+   ret = i2c_transfer(i2c_adapter, , 1);
+   if (ret == -EREMOTEIO) {
+   return -ENODEV;
+   }
+   if (ret < 1) {
+   printf("failed to autoenable i2c device on address 0x%x with 
%i\n",
+   

[PATCH 3/3] ARM: phytec-som-am335x: Add autoenable

2017-10-27 Thread Daniel Schultz
Add autoenable for components, which can be populated on an AM335x
phyCORE SoM.

Signed-off-by: Daniel Schultz 
---
 arch/arm/boards/phytec-som-am335x/board.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boards/phytec-som-am335x/board.c 
b/arch/arm/boards/phytec-som-am335x/board.c
index 34d4df1..5d13471 100644
--- a/arch/arm/boards/phytec-som-am335x/board.c
+++ b/arch/arm/boards/phytec-som-am335x/board.c
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -136,6 +137,17 @@ static int physom_devices_init(void)
}
}
 
+   /* Enable NAND */
+   autoenable_device_by_path("/ocp/gpmc@5000");
+   /* Enable eMMC */
+   autoenable_device_by_path("/ocp/mmc@481d8000");
+   /* Enable SPI NOR */
+   autoenable_device_by_path("/ocp/spi@4803/m25p80@0");
+
+   autoenable_i2c_by_path("/ocp/i2c@44e0b000/temp@4b");
+   autoenable_i2c_by_path("/ocp/i2c@44e0b000/eeprom@52");
+   autoenable_i2c_by_path("/ocp/i2c@44e0b000/rtc@68");
+
if (IS_ENABLED(CONFIG_SHELL_NONE))
return am33xx_of_register_bootdevice();
 
-- 
2.7.4


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


[PATCH 3/5] ARM: configs: am335x_defconfig: Add state config

2017-10-27 Thread Daniel Schultz
Enable the state framework for all AM335x boards.
---
 arch/arm/configs/am335x_defconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/configs/am335x_defconfig 
b/arch/arm/configs/am335x_defconfig
index dd9c3c5..5a236fb 100644
--- a/arch/arm/configs/am335x_defconfig
+++ b/arch/arm/configs/am335x_defconfig
@@ -88,6 +88,7 @@ CONFIG_CMD_OF_FIXUP_STATUS=y
 CONFIG_CMD_OFTREE=y
 CONFIG_CMD_TIME=y
 CONFIG_CMD_MMC_EXTCSD=y
+CONFIG_CMD_STATE=y
 CONFIG_NET=y
 CONFIG_NET_NFS=y
 CONFIG_NET_NETCONSOLE=y
@@ -142,3 +143,5 @@ CONFIG_FS_FAT_LFN=y
 CONFIG_FS_UBIFS=y
 CONFIG_FS_UBIFS_COMPRESSION_LZO=y
 CONFIG_FS_UBIFS_COMPRESSION_ZLIB=y
+CONFIG_STATE=y
+CONFIG_STATE_DRV=y
-- 
2.7.4


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


[PATCH 5/5] ARM: phytec-som-am335x: Set MAC addresses from state

2017-10-27 Thread Daniel Schultz
If a state with the name 'am335x_phytec_mac_state' is available, valid MAC
addresses from this state get registerd to their ethernet device.

Signed-off-by: Daniel Schultz 
---
 arch/arm/boards/phytec-som-am335x/board.c | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/arch/arm/boards/phytec-som-am335x/board.c 
b/arch/arm/boards/phytec-som-am335x/board.c
index dc3b84a..34d4df1 100644
--- a/arch/arm/boards/phytec-som-am335x/board.c
+++ b/arch/arm/boards/phytec-som-am335x/board.c
@@ -21,10 +21,12 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -67,6 +69,10 @@ static char *nandslots[] = {
 
 static int physom_devices_init(void)
 {
+   struct state *state;
+   struct state_variable *sv;
+   struct state_mac *mac;
+
if (!of_machine_is_compatible("phytec,am335x-som"))
return 0;
 
@@ -114,6 +120,22 @@ static int physom_devices_init(void)
ARRAY_SIZE(nandslots));
am33xx_bbu_emmc_mlo_register_handler("MLO.emmc", "/dev/mmc1");
 
+   if (IS_ENABLED(CONFIG_STATE)) {
+   state = state_by_name("am335x_phytec_mac_state");
+   if (state) {
+   sv = state_find_var(state, "mac0");
+   if (!IS_ERR(sv)) {
+   mac = to_state_mac(sv);
+   eth_register_ethaddr(0, mac->value);
+   }
+   sv = state_find_var(state, "mac1");
+   if (!IS_ERR(sv)) {
+   mac = to_state_mac(sv);
+   eth_register_ethaddr(1, mac->value);
+   }
+   }
+   }
+
if (IS_ENABLED(CONFIG_SHELL_NONE))
return am33xx_of_register_bootdevice();
 
-- 
2.7.4


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


Re: [PATCH 1/2] efi-gui: add USB IO Protocol GUID definition

2017-10-27 Thread Sascha Hauer
On Fri, Oct 27, 2017 at 09:05:47AM +0200, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
> ---
>  common/efi-guid.c | 1 +
>  include/efi.h | 3 +++
>  2 files changed, 4 insertions(+)

Applied, thanks

Sascha

> 
> diff --git a/common/efi-guid.c b/common/efi-guid.c
> index 71aa21ddd..1e45ccf4d 100644
> --- a/common/efi-guid.c
> +++ b/common/efi-guid.c
> @@ -35,6 +35,7 @@ const char *efi_guid_string(efi_guid_t *g)
>   EFI_GUID_STRING(EFI_UGA_PROTOCOL_GUID, "UGA Draw Protocol", "EFI 1.1 
> UGA Draw Protocol");
>   EFI_GUID_STRING(EFI_UGA_IO_PROTOCOL_GUID, "UGA Protocol", "EFI 1.1 UGA 
> Protocol");
>   EFI_GUID_STRING(EFI_PCI_IO_PROTOCOL_GUID, "PCI IO Protocol", "EFI 1.1 
> PCI IO Protocol");
> + EFI_GUID_STRING(EFI_USB_IO_PROTOCOL_GUID, "USB IO Protocol", "EFI 1.0 
> USB IO Protocol");
>   EFI_GUID_STRING(EFI_FILE_INFO_GUID, "File Info", "EFI File Infom");
>   EFI_GUID_STRING(EFI_SIMPLE_FILE_SYSTEM_GUID, "Filesystem", "EFI 1.0 
> Simple FileSystem");
>   EFI_GUID_STRING(EFI_DEVICE_TREE_GUID, "Device Tree", "EFI Device Tree 
> GUID");
> diff --git a/include/efi.h b/include/efi.h
> index e1fc134ee..7cc5fe05f 100644
> --- a/include/efi.h
> +++ b/include/efi.h
> @@ -358,6 +358,9 @@ extern efi_runtime_services_t *RT;
>  #define EFI_PCI_IO_PROTOCOL_GUID \
>  EFI_GUID(  0x4cf5b200, 0x68b8, 0x4ca5, 0x9e, 0xec, 0xb2, 0x3e, 0x3f, 
> 0x50, 0x2, 0x9a )
>  
> +#define EFI_USB_IO_PROTOCOL_GUID \
> +EFI_GUID(0x2B2F68D6, 0x0CD2, 0x44cf, 0x8E, 0x8B, 0xBB, 0xA2, 0x0B, 0x1B, 
> 0x5B, 0x75)
> +
>  #define EFI_FILE_INFO_GUID \
>  EFI_GUID(  0x9576e92, 0x6d3f, 0x11d2, 0x8e, 0x39, 0x00, 0xa0, 0xc9, 
> 0x69, 0x72, 0x3b )
>  
> -- 
> 2.11.0
> 
> 
> ___
> 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] EFI: add poweroff support

2017-10-27 Thread Sascha Hauer
On Thu, Oct 26, 2017 at 12:05:50PM +0200, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
> ---
>  arch/x86/configs/efi_defconfig |  1 +
>  common/efi/efi.c   | 10 ++
>  drivers/efi/Kconfig|  1 +
>  3 files changed, 12 insertions(+)
> 
> diff --git a/arch/x86/configs/efi_defconfig b/arch/x86/configs/efi_defconfig
> index 3e83fd92d..fdf092e9b 100644
> --- a/arch/x86/configs/efi_defconfig
> +++ b/arch/x86/configs/efi_defconfig
> @@ -55,6 +55,7 @@ CONFIG_CMD_CRC_CMP=y
>  CONFIG_CMD_MM=y
>  CONFIG_CMD_DETECT=y
>  CONFIG_CMD_FLASH=y
> +CONFIG_CMD_POWEROFF=y
>  CONFIG_CMD_2048=y
>  CONFIG_CMD_BAREBOX_UPDATE=y
>  CONFIG_CMD_OF_NODE=y
> diff --git a/common/efi/efi.c b/common/efi/efi.c
> index 4b42f5d67..561ce4c08 100644
> --- a/common/efi/efi.c
> +++ b/common/efi/efi.c
> @@ -25,6 +25,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -283,9 +284,18 @@ static void __noreturn efi_restart_system(struct 
> restart_handler *rst)
>   hang();
>  }
>  
> +static void __noreturn efi_poweroff_system(struct poweroff_handler *handler)
> +{
> + shutdown_barebox();
> + RT->reset_system(EFI_RESET_SHUTDOWN, EFI_SUCCESS, 0, NULL);
> +
> + hang();
> +}
> +
>  static int restart_register_feature(void)
>  {
>   restart_handler_register_fn(efi_restart_system);
> + poweroff_handler_register_fn(efi_poweroff_system);
>  
>   return 0;
>  }
> diff --git a/drivers/efi/Kconfig b/drivers/efi/Kconfig
> index 2cd9dd504..5c988d2e1 100644
> --- a/drivers/efi/Kconfig
> +++ b/drivers/efi/Kconfig
> @@ -1,2 +1,3 @@
>  config EFI_BOOTUP
>   bool
> + select HAS_POWEROFF

Dropped this hunk since while applying since HAS_POWEROFF is not used
anywhere in the tree.

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] usb: imx: implement support for "over-current-active-high" property

2017-10-27 Thread Sascha Hauer
On Thu, Oct 26, 2017 at 11:59:17AM +0200, Uwe Kleine-König wrote:
> This property is already documented in the bindings and supported by
> Linux. As on i.MX25 the HW default is active high and up to now barebox
> didn't force this to low (which is the default for e.g. i.MX6), add the
> property to barebox' imx25.dtsi to keep existing behaviour. If on a
> board the OC pin is active low, you need to add
> 
>   /delete-property/ over-current-active-high;
> 
> in the board.dts.
> 
> Signed-off-by: Uwe Kleine-König 
> ---

Applied, thanks

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 2/2] efi-block: detect when the block device is a USB Disk

2017-10-27 Thread Jean-Christophe PLAGNIOL-VILLARD
use usbdisk as a basename

This will be usefull as example when we want to search for a usb disk for
failsafe update or install.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
---
 drivers/block/efi-block-io.c | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/block/efi-block-io.c b/drivers/block/efi-block-io.c
index a4d9d3a95..2bbeb99e6 100644
--- a/drivers/block/efi-block-io.c
+++ b/drivers/block/efi-block-io.c
@@ -130,6 +130,18 @@ static void efi_bio_print_info(struct efi_bio_priv *priv)
media->optimal_transfer_length_granularity);
 }
 
+static int is_bio_usbdev(struct efi_device *efidev)
+{
+   int i;
+
+   for (i = 0; i < efidev->num_guids; i++) {
+   if (!efi_guidcmp(efidev->guids[i], EFI_USB_IO_PROTOCOL_GUID))
+   return 1;
+   }
+
+   return 0;
+}
+
 int efi_bio_probe(struct efi_device *efidev)
 {
int ret;
@@ -147,7 +159,10 @@ int efi_bio_probe(struct efi_device *efidev)
efi_bio_print_info(priv);
priv->dev = >dev;
 
-   priv->blk.cdev.name = xasprintf("disk%d", cdev_find_free_index("disk"));
+   if (is_bio_usbdev(efidev))
+   priv->blk.cdev.name = xasprintf("usbdisk%d", 
cdev_find_free_index("usbdisk"));
+   else
+   priv->blk.cdev.name = xasprintf("disk%d", 
cdev_find_free_index("disk"));
priv->blk.blockbits = ffs(media->block_size) - 1;
priv->blk.num_blocks = media->last_block + 1;
priv->blk.ops = _bio_ops;
-- 
2.11.0


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


[PATCH 1/2] efi-gui: add USB IO Protocol GUID definition

2017-10-27 Thread Jean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
---
 common/efi-guid.c | 1 +
 include/efi.h | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/common/efi-guid.c b/common/efi-guid.c
index 71aa21ddd..1e45ccf4d 100644
--- a/common/efi-guid.c
+++ b/common/efi-guid.c
@@ -35,6 +35,7 @@ const char *efi_guid_string(efi_guid_t *g)
EFI_GUID_STRING(EFI_UGA_PROTOCOL_GUID, "UGA Draw Protocol", "EFI 1.1 
UGA Draw Protocol");
EFI_GUID_STRING(EFI_UGA_IO_PROTOCOL_GUID, "UGA Protocol", "EFI 1.1 UGA 
Protocol");
EFI_GUID_STRING(EFI_PCI_IO_PROTOCOL_GUID, "PCI IO Protocol", "EFI 1.1 
PCI IO Protocol");
+   EFI_GUID_STRING(EFI_USB_IO_PROTOCOL_GUID, "USB IO Protocol", "EFI 1.0 
USB IO Protocol");
EFI_GUID_STRING(EFI_FILE_INFO_GUID, "File Info", "EFI File Infom");
EFI_GUID_STRING(EFI_SIMPLE_FILE_SYSTEM_GUID, "Filesystem", "EFI 1.0 
Simple FileSystem");
EFI_GUID_STRING(EFI_DEVICE_TREE_GUID, "Device Tree", "EFI Device Tree 
GUID");
diff --git a/include/efi.h b/include/efi.h
index e1fc134ee..7cc5fe05f 100644
--- a/include/efi.h
+++ b/include/efi.h
@@ -358,6 +358,9 @@ extern efi_runtime_services_t *RT;
 #define EFI_PCI_IO_PROTOCOL_GUID \
 EFI_GUID(  0x4cf5b200, 0x68b8, 0x4ca5, 0x9e, 0xec, 0xb2, 0x3e, 0x3f, 0x50, 
0x2, 0x9a )
 
+#define EFI_USB_IO_PROTOCOL_GUID \
+EFI_GUID(0x2B2F68D6, 0x0CD2, 0x44cf, 0x8E, 0x8B, 0xBB, 0xA2, 0x0B, 0x1B, 
0x5B, 0x75)
+
 #define EFI_FILE_INFO_GUID \
 EFI_GUID(  0x9576e92, 0x6d3f, 0x11d2, 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 
0x72, 0x3b )
 
-- 
2.11.0


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