[RESEND PATCH v2 2/2] watchdog: Port RAVE SP watchdog driver from Linux kernel

2018-05-02 Thread Andrey Smirnov
Port RAVE SP watchdog driver from Linux kernel

Signed-off-by: Andrey Smirnov 
---
 drivers/watchdog/Kconfig   |   5 +
 drivers/watchdog/Makefile  |   1 +
 drivers/watchdog/rave-sp-wdt.c | 426 +
 3 files changed, 432 insertions(+)
 create mode 100644 drivers/watchdog/rave-sp-wdt.c

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 1d6b15617..27e9f6d8b 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -70,4 +70,9 @@ config WATCHDOG_BCM2835
help
  Add support for watchdog on the Broadcom BCM283X SoCs.
 
+config RAVE_SP_WATCHDOG
+   bool "RAVE SP Watchdog timer"
+   depends on RAVE_SP_CORE
+   help
+ Support for the watchdog on RAVE SP device.
 endif
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 237640121..faf06110a 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -8,3 +8,4 @@ obj-$(CONFIG_WATCHDOG_JZ4740) += jz4740.o
 obj-$(CONFIG_WATCHDOG_IMX_RESET_SOURCE) += imxwd.o
 obj-$(CONFIG_WATCHDOG_ORION) += orion_wdt.o
 obj-$(CONFIG_ARCH_BCM283X) += bcm2835_wdt.o
+obj-$(CONFIG_RAVE_SP_WATCHDOG) += rave-sp-wdt.o
diff --git a/drivers/watchdog/rave-sp-wdt.c b/drivers/watchdog/rave-sp-wdt.c
new file mode 100644
index 0..164316785
--- /dev/null
+++ b/drivers/watchdog/rave-sp-wdt.c
@@ -0,0 +1,426 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/*
+ * Driver for watchdog aspect of for Zodiac Inflight Innovations RAVE
+ * Supervisory Processor(SP) MCU
+ *
+ * Copyright (C) 2018 Zodiac Inflight Innovation
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+enum {
+   RAVE_SP_RESET_BYTE = 1,
+   RAVE_SP_RESET_REASON_NORMAL = 0,
+   RAVE_SP_RESET_REASON_HW_WATCHDOG= 1,
+   RAVE_SP_RESET_REASON_SW_WATCHDOG= 2,
+   RAVE_SP_RESET_REASON_VOLTAGE= 3,
+   RAVE_SP_RESET_REASON_HOST_REQUEST   = 4,
+   RAVE_SP_RESET_REASON_TEMPERATURE= 5,
+   RAVE_SP_RESET_REASON_BUTTON_PRESS   = 6,
+   RAVE_SP_RESET_REASON_PIC_CM = 7,
+   RAVE_SP_RESET_REASON_PIC_ILL_INST   = 8,
+   RAVE_SP_RESET_REASON_PIC_TRAP   = 9,
+   RAVE_SP_RESET_REASON_UKNOWN_REASON  = 10,
+   RAVE_SP_RESET_REASON_THERMAL_SENSOR = 11,
+   RAVE_SP_RESET_REASON_SW_VOLTAGE = 12,
+   RAVE_SP_RESET_REASON_CP_REQUEST = 13,
+
+   RAVE_SP_RESET_DELAY_MS = 500,
+
+   RAVE_SP_BOOT_SOURCE_GET = 0,
+   RAVE_SP_BOOT_SOURCE_SET = 1,
+};
+
+/**
+ * struct rave_sp_wdt_variant - RAVE SP watchdog variant
+ *
+ * @max_timeout:   Largest possible watchdog timeout setting
+ * @min_timeout:   Smallest possible watchdog timeout setting
+ *
+ * @configure: Function to send configuration command
+ * @restart:   Function to send "restart" command
+ */
+struct rave_sp_wdt_variant {
+   unsigned int max_timeout;
+   unsigned int min_timeout;
+
+   int (*configure)(struct watchdog *, bool);
+   int (*restart)(struct watchdog *);
+   int (*reset_reason)(struct watchdog *);
+};
+
+/**
+ * struct rave_sp_wdt - RAVE SP watchdog
+ *
+ * @wdd:   Underlying watchdog device
+ * @sp:Pointer to parent RAVE SP device
+ * @variant:   Device specific variant information
+ * @reboot_notifier:   Reboot notifier implementing machine reset
+ */
+struct rave_sp_wdt {
+   struct watchdog wdd;
+   struct rave_sp *sp;
+   const struct rave_sp_wdt_variant *variant;
+   struct restart_handler restart;
+   unsigned int timeout;
+   unsigned int boot_source;
+   struct device_d dev;
+};
+
+static struct rave_sp_wdt *to_rave_sp_wdt(struct watchdog *wdd)
+{
+   return container_of(wdd, struct rave_sp_wdt, wdd);
+}
+
+static int rave_sp_wdt_exec(struct watchdog *wdd, void *data,
+   size_t data_size)
+{
+   return rave_sp_exec(to_rave_sp_wdt(wdd)->sp,
+   data, data_size, NULL, 0);
+}
+
+
+static int rave_sp_wdt_access_boot_source(struct rave_sp_wdt *sp_wd, u8 
set_get)
+{
+   u8 cmd[] = {
+   [0] = RAVE_SP_CMD_BOOT_SOURCE,
+   [1] = 0,
+   [2] = set_get,
+   [3] = sp_wd->boot_source,
+   };
+   u8 response;
+   int ret;
+
+   ret = rave_sp_exec(sp_wd->sp, cmd, sizeof(cmd), ,
+  sizeof(response));
+   if (ret)
+   return ret;
+
+   return response;
+}
+
+static int __rave_sp_wdt_rdu_reset_reason(struct watchdog *wdd,
+ uint8_t response[],
+ size_t response_len)
+{
+   u8 cmd[] = {
+   [0] = RAVE_SP_CMD_RESET_REASON,
+   [1] = 0,
+   };
+   int ret;
+
+   ret = rave_sp_exec(to_rave_sp_wdt(wdd)->sp, cmd, sizeof(cmd),
+  response, 

[RESEND PATCH v2 1/2] mfd: Port RAVE SP driver from Linux kernel

2018-05-02 Thread Andrey Smirnov
Port MFD driver for RAVE SP from Linux kernel.

Signed-off-by: Andrey Smirnov 
---
 drivers/mfd/Kconfig |   8 +
 drivers/mfd/Makefile|   1 +
 drivers/mfd/rave-sp.c   | 758 
 include/linux/mfd/rave-sp.h |  78 +
 4 files changed, 845 insertions(+)
 create mode 100644 drivers/mfd/rave-sp.c
 create mode 100644 include/linux/mfd/rave-sp.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 521cf042a..d04431fbc 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -53,4 +53,12 @@ config MFD_TWL6030
select MFD_TWLCORE
bool "TWL6030 driver"
 
+config RAVE_SP_CORE
+   tristate "RAVE SP MCU core driver"
+   depends on SERIAL_DEV_BUS
+   select CRC_CCITT
+   help
+ Select this to get support for the Supervisory Processor
+ device found on several devices in RAVE line of hardware.
+
 endmenu
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 041915a7c..8b23a1023 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -10,3 +10,4 @@ obj-$(CONFIG_MFD_SYSCON)  += syscon.o
 obj-$(CONFIG_MFD_TWLCORE)  += twl-core.o
 obj-$(CONFIG_MFD_TWL4030)  += twl4030.o
 obj-$(CONFIG_MFD_TWL6030)  += twl6030.o
+obj-$(CONFIG_RAVE_SP_CORE) += rave-sp.o
diff --git a/drivers/mfd/rave-sp.c b/drivers/mfd/rave-sp.c
new file mode 100644
index 0..d55e913ff
--- /dev/null
+++ b/drivers/mfd/rave-sp.c
@@ -0,0 +1,758 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/*
+ * Multifunction core driver for Zodiac Inflight Innovations RAVE
+ * Supervisory Processor(SP) MCU that is connected via dedicated UART
+ * port
+ *
+ * Copyright (C) 2017 Zodiac Inflight Innovations
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+#define DUMP_PREFIX_NONE 0
+
+/*
+ * UART protocol using following entities:
+ *  - message to MCU => ACK response
+ *  - event from MCU => event ACK
+ *
+ * Frame structure:
+ *
+ * Where:
+ * - STX - is start of transmission character
+ * - ETX - end of transmission
+ * - DATA - payload
+ * - CHECKSUM - checksum calculated on 
+ *
+ * If  or  contain one of control characters, then it is
+ * escaped using  control code. Added  does not participate in
+ * checksum calculation.
+ */
+#define RAVE_SP_STX0x02
+#define RAVE_SP_ETX0x03
+#define RAVE_SP_DLE0x10
+
+#define RAVE_SP_MAX_DATA_SIZE  64
+#define RAVE_SP_CHECKSUM_SIZE  2  /* Worst case scenario on RDU2 */
+/*
+ * We don't store STX, ETX and unescaped bytes, so Rx is only
+ * DATA + CSUM
+ */
+#define RAVE_SP_RX_BUFFER_SIZE \
+   (RAVE_SP_MAX_DATA_SIZE + RAVE_SP_CHECKSUM_SIZE)
+
+#define RAVE_SP_STX_ETX_SIZE   2
+/*
+ * For Tx we have to have space for everything, STX, EXT and
+ * potentially stuffed DATA + CSUM data + csum
+ */
+#define RAVE_SP_TX_BUFFER_SIZE \
+   (RAVE_SP_STX_ETX_SIZE + 2 * RAVE_SP_RX_BUFFER_SIZE)
+
+#define RAVE_SP_BOOT_SOURCE_GET0
+#define RAVE_SP_BOOT_SOURCE_SET1
+
+#define RAVE_SP_RDU2_BOARD_TYPE_RMB0
+#define RAVE_SP_RDU2_BOARD_TYPE_DEB1
+
+#define RAVE_SP_BOOT_SOURCE_SD 0
+#define RAVE_SP_BOOT_SOURCE_EMMC   1
+#define RAVE_SP_BOOT_SOURCE_NOR2
+
+/**
+ * enum rave_sp_deframer_state - Possible state for de-framer
+ *
+ * @RAVE_SP_EXPECT_SOF: Scanning input for start-of-frame 
marker
+ * @RAVE_SP_EXPECT_DATA:Got start of frame marker, collecting frame
+ * @RAVE_SP_EXPECT_ESCAPED_DATA: Got escape character, collecting escaped byte
+ */
+enum rave_sp_deframer_state {
+   RAVE_SP_EXPECT_SOF,
+   RAVE_SP_EXPECT_DATA,
+   RAVE_SP_EXPECT_ESCAPED_DATA,
+};
+
+/**
+ * struct rave_sp_deframer - Device protocol deframer
+ *
+ * @state:  Current state of the deframer
+ * @data:   Buffer used to collect deframed data
+ * @length: Number of bytes de-framed so far
+ */
+struct rave_sp_deframer {
+   enum rave_sp_deframer_state state;
+   unsigned char data[RAVE_SP_RX_BUFFER_SIZE];
+   size_t length;
+};
+
+/**
+ * struct rave_sp_reply - Reply as per RAVE device protocol
+ *
+ * @length:Expected reply length
+ * @data:  Buffer to store reply payload in
+ * @code:  Expected reply code
+ * @ackid: Expected reply ACK ID
+ * @completion: Successful reply reception completion
+ */
+struct rave_sp_reply {
+   size_t length;
+   void  *data;
+   u8 code;
+   u8 ackid;
+
+   bool   received;
+};
+
+/**
+ * struct rave_sp_checksum - Variant specific checksum implementation details
+ *
+ * @length:Caculated checksum length
+ * @subroutine:Utilized checksum algorithm implementation
+ */
+struct rave_sp_checksum {
+   size_t length;
+   void (*subroutine)(const u8 *, size_t, u8 *);
+};
+
+/**
+ * struct rave_sp_variant_cmds - Variant specific 

[RESEND PATCH v2 0/2] Initial RAVE SP Linux driver port

2018-05-02 Thread Andrey Smirnov
Everyone:

These two patches are first results of an effort to port RAVE SP
(Supervisory Processor) MFD and it's children drivers from Linux
kernel to Barebox. Patch 1/2 brings MFD driver with its core API and
patch 2/2 adds support for watchdog "cell" of the RAVE SP device.

With a very few exceptions, the code of the drivers is identical to
the code of their Linux counterparts.

These drivers are also first users of "serdev" API work that was
recently merged and should server as a reasonable example of its
usage.

Feedback is wellcome!

Changes since [v1]:

 - rave_sp_wdt_set_timeout fixed to correctly handle timeout of zero
   (as pointed out by Sascha)

Thanks,
Andrey Smirnov

[v1] http://lists.infradead.org/pipermail/barebox/2018-April/032725.html

Andrey Smirnov (2):
  mfd: Port RAVE SP driver from Linux kernel
  watchdog: Port RAVE SP watchdog driver from Linux kernel

 drivers/mfd/Kconfig|   8 +
 drivers/mfd/Makefile   |   1 +
 drivers/mfd/rave-sp.c  | 758 +
 drivers/watchdog/Kconfig   |   5 +
 drivers/watchdog/Makefile  |   1 +
 drivers/watchdog/rave-sp-wdt.c | 426 +++
 include/linux/mfd/rave-sp.h|  78 +
 7 files changed, 1277 insertions(+)
 create mode 100644 drivers/mfd/rave-sp.c
 create mode 100644 drivers/watchdog/rave-sp-wdt.c
 create mode 100644 include/linux/mfd/rave-sp.h

-- 
2.14.3


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


Re: [PATCH v2 0/2] Initial RAVE SP Linux driver port

2018-05-02 Thread Andrey Smirnov
On Wed, May 2, 2018 at 12:28 PM, Andrey Smirnov
 wrote:
> Everyone:
>
> These two patches are first results of an effort to port RAVE SP
> (Supervisory Processor) MFD and it's children drivers from Linux
> kernel to Barebox. Patch 1/2 brings MFD driver with its core API and
> patch 2/2 adds support for watchdog "cell" of the RAVE SP device.
>
> With a very few exceptions, the code of the drivers is identical to
> the code of their Linux counterparts.
>
> These drivers are also first users of "serdev" API work that was
> recently merged and should server as a reasonable example of its
> usage.
>
> Feedback is wellcome!
>
> Changes since [v1]:
>
>  - rave_sp_wdt_set_timeout fixed to correctly handle timeout of zero
>(as pointed out by Sascha)
>
> Thanks,
> Andrey Smirnov
>
> [v1] http://lists.infradead.org/pipermail/barebox/2018-April/032725.html
>
> Andrey Smirnov (2):
>   watchdog: Port RAVE SP watchdog driver from Linux kernel
>   mfd: rave-sp: Add temporary workaround for missing GET_STATUS

Ugh. Accidentaly sent out the wrong patch. Will send out the correct
one shortly. Disregard this submission and sorry for the noise.

Thanks,
Andrey Smirnov

>
>  drivers/mfd/rave-sp.c  |  18 +-
>  drivers/watchdog/Kconfig   |   5 +
>  drivers/watchdog/Makefile  |   1 +
>  drivers/watchdog/rave-sp-wdt.c | 426 
> +
>  4 files changed, 448 insertions(+), 2 deletions(-)
>  create mode 100644 drivers/watchdog/rave-sp-wdt.c
>
> --
> 2.14.3
>

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


[PATCH v2 1/2] watchdog: Port RAVE SP watchdog driver from Linux kernel

2018-05-02 Thread Andrey Smirnov
Port RAVE SP watchdog driver from Linux kernel

Signed-off-by: Andrey Smirnov 
---
 drivers/watchdog/Kconfig   |   5 +
 drivers/watchdog/Makefile  |   1 +
 drivers/watchdog/rave-sp-wdt.c | 426 +
 3 files changed, 432 insertions(+)
 create mode 100644 drivers/watchdog/rave-sp-wdt.c

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 1d6b15617..27e9f6d8b 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -70,4 +70,9 @@ config WATCHDOG_BCM2835
help
  Add support for watchdog on the Broadcom BCM283X SoCs.
 
+config RAVE_SP_WATCHDOG
+   bool "RAVE SP Watchdog timer"
+   depends on RAVE_SP_CORE
+   help
+ Support for the watchdog on RAVE SP device.
 endif
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 237640121..faf06110a 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -8,3 +8,4 @@ obj-$(CONFIG_WATCHDOG_JZ4740) += jz4740.o
 obj-$(CONFIG_WATCHDOG_IMX_RESET_SOURCE) += imxwd.o
 obj-$(CONFIG_WATCHDOG_ORION) += orion_wdt.o
 obj-$(CONFIG_ARCH_BCM283X) += bcm2835_wdt.o
+obj-$(CONFIG_RAVE_SP_WATCHDOG) += rave-sp-wdt.o
diff --git a/drivers/watchdog/rave-sp-wdt.c b/drivers/watchdog/rave-sp-wdt.c
new file mode 100644
index 0..164316785
--- /dev/null
+++ b/drivers/watchdog/rave-sp-wdt.c
@@ -0,0 +1,426 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/*
+ * Driver for watchdog aspect of for Zodiac Inflight Innovations RAVE
+ * Supervisory Processor(SP) MCU
+ *
+ * Copyright (C) 2018 Zodiac Inflight Innovation
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+enum {
+   RAVE_SP_RESET_BYTE = 1,
+   RAVE_SP_RESET_REASON_NORMAL = 0,
+   RAVE_SP_RESET_REASON_HW_WATCHDOG= 1,
+   RAVE_SP_RESET_REASON_SW_WATCHDOG= 2,
+   RAVE_SP_RESET_REASON_VOLTAGE= 3,
+   RAVE_SP_RESET_REASON_HOST_REQUEST   = 4,
+   RAVE_SP_RESET_REASON_TEMPERATURE= 5,
+   RAVE_SP_RESET_REASON_BUTTON_PRESS   = 6,
+   RAVE_SP_RESET_REASON_PIC_CM = 7,
+   RAVE_SP_RESET_REASON_PIC_ILL_INST   = 8,
+   RAVE_SP_RESET_REASON_PIC_TRAP   = 9,
+   RAVE_SP_RESET_REASON_UKNOWN_REASON  = 10,
+   RAVE_SP_RESET_REASON_THERMAL_SENSOR = 11,
+   RAVE_SP_RESET_REASON_SW_VOLTAGE = 12,
+   RAVE_SP_RESET_REASON_CP_REQUEST = 13,
+
+   RAVE_SP_RESET_DELAY_MS = 500,
+
+   RAVE_SP_BOOT_SOURCE_GET = 0,
+   RAVE_SP_BOOT_SOURCE_SET = 1,
+};
+
+/**
+ * struct rave_sp_wdt_variant - RAVE SP watchdog variant
+ *
+ * @max_timeout:   Largest possible watchdog timeout setting
+ * @min_timeout:   Smallest possible watchdog timeout setting
+ *
+ * @configure: Function to send configuration command
+ * @restart:   Function to send "restart" command
+ */
+struct rave_sp_wdt_variant {
+   unsigned int max_timeout;
+   unsigned int min_timeout;
+
+   int (*configure)(struct watchdog *, bool);
+   int (*restart)(struct watchdog *);
+   int (*reset_reason)(struct watchdog *);
+};
+
+/**
+ * struct rave_sp_wdt - RAVE SP watchdog
+ *
+ * @wdd:   Underlying watchdog device
+ * @sp:Pointer to parent RAVE SP device
+ * @variant:   Device specific variant information
+ * @reboot_notifier:   Reboot notifier implementing machine reset
+ */
+struct rave_sp_wdt {
+   struct watchdog wdd;
+   struct rave_sp *sp;
+   const struct rave_sp_wdt_variant *variant;
+   struct restart_handler restart;
+   unsigned int timeout;
+   unsigned int boot_source;
+   struct device_d dev;
+};
+
+static struct rave_sp_wdt *to_rave_sp_wdt(struct watchdog *wdd)
+{
+   return container_of(wdd, struct rave_sp_wdt, wdd);
+}
+
+static int rave_sp_wdt_exec(struct watchdog *wdd, void *data,
+   size_t data_size)
+{
+   return rave_sp_exec(to_rave_sp_wdt(wdd)->sp,
+   data, data_size, NULL, 0);
+}
+
+
+static int rave_sp_wdt_access_boot_source(struct rave_sp_wdt *sp_wd, u8 
set_get)
+{
+   u8 cmd[] = {
+   [0] = RAVE_SP_CMD_BOOT_SOURCE,
+   [1] = 0,
+   [2] = set_get,
+   [3] = sp_wd->boot_source,
+   };
+   u8 response;
+   int ret;
+
+   ret = rave_sp_exec(sp_wd->sp, cmd, sizeof(cmd), ,
+  sizeof(response));
+   if (ret)
+   return ret;
+
+   return response;
+}
+
+static int __rave_sp_wdt_rdu_reset_reason(struct watchdog *wdd,
+ uint8_t response[],
+ size_t response_len)
+{
+   u8 cmd[] = {
+   [0] = RAVE_SP_CMD_RESET_REASON,
+   [1] = 0,
+   };
+   int ret;
+
+   ret = rave_sp_exec(to_rave_sp_wdt(wdd)->sp, cmd, sizeof(cmd),
+  response, 

[PATCH v2 0/2] Initial RAVE SP Linux driver port

2018-05-02 Thread Andrey Smirnov
Everyone:

These two patches are first results of an effort to port RAVE SP
(Supervisory Processor) MFD and it's children drivers from Linux
kernel to Barebox. Patch 1/2 brings MFD driver with its core API and
patch 2/2 adds support for watchdog "cell" of the RAVE SP device.

With a very few exceptions, the code of the drivers is identical to
the code of their Linux counterparts.

These drivers are also first users of "serdev" API work that was
recently merged and should server as a reasonable example of its
usage.

Feedback is wellcome!

Changes since [v1]:

 - rave_sp_wdt_set_timeout fixed to correctly handle timeout of zero
   (as pointed out by Sascha)

Thanks,
Andrey Smirnov

[v1] http://lists.infradead.org/pipermail/barebox/2018-April/032725.html

Andrey Smirnov (2):
  watchdog: Port RAVE SP watchdog driver from Linux kernel
  mfd: rave-sp: Add temporary workaround for missing GET_STATUS

 drivers/mfd/rave-sp.c  |  18 +-
 drivers/watchdog/Kconfig   |   5 +
 drivers/watchdog/Makefile  |   1 +
 drivers/watchdog/rave-sp-wdt.c | 426 +
 4 files changed, 448 insertions(+), 2 deletions(-)
 create mode 100644 drivers/watchdog/rave-sp-wdt.c

-- 
2.14.3


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


[PATCH v2 2/2] mfd: rave-sp: Add temporary workaround for missing GET_STATUS

2018-05-02 Thread Andrey Smirnov
---
 drivers/mfd/rave-sp.c | 18 --
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/rave-sp.c b/drivers/mfd/rave-sp.c
index d55e913ff..6c24c28fc 100644
--- a/drivers/mfd/rave-sp.c
+++ b/drivers/mfd/rave-sp.c
@@ -635,8 +635,21 @@ static int rave_sp_get_status(struct rave_sp *sp)
int ret;
 
ret = rave_sp_exec(sp, cmd, sizeof(cmd), , sizeof(status));
-   if (ret)
-   return ret;
+   if (ret) {
+   cmd[0] = RAVE_SP_CMD_GET_FIRMWARE_VERSION;
+   ret = rave_sp_exec(sp, cmd, sizeof(cmd), 
_version,
+  sizeof(status.firmware_version));
+   if (ret)
+   return ret;
+
+   cmd[0] = RAVE_SP_CMD_GET_BOOTLOADER_VERSION;
+   ret = rave_sp_exec(sp, cmd, sizeof(cmd), 
_version,
+  sizeof(status.bootloader_version));
+   if (ret)
+   return ret;
+
+   goto populate_version;
+   }
 
if (status.general_status & RAVE_SP_STATUS_GS_FIRMWARE_MODE)
mode = "Application";
@@ -645,6 +658,7 @@ static int rave_sp_get_status(struct rave_sp *sp)
 
dev_info(dev, "Device is in %s mode\n", mode);
 
+populate_version:
sp->part_number_firmware   = devm_rave_sp_version(dev,
   _version);
sp->part_number_bootloader = devm_rave_sp_version(dev,
-- 
2.14.3


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


Re: [PATCH 2/2] watchdog: Port RAVE SP watchdog driver from Linux kernel

2018-05-02 Thread Andrey Smirnov
On Wed, May 2, 2018 at 3:24 AM, Sascha Hauer  wrote:
> On Fri, Apr 20, 2018 at 06:33:38PM -0700, Andrey Smirnov wrote:
>> +static int rave_sp_wdt_set_timeout(struct watchdog *wdd,
>> +unsigned int timeout)
>> +{
>> + struct rave_sp_wdt *sp_wd = to_rave_sp_wdt(wdd);
>> +
>> + if (timeout < sp_wd->variant->min_timeout ||
>> + timeout > sp_wd->variant->max_timeout)
>> + return -EINVAL;
>> +
>> + if (!timeout)
>> + return rave_sp_wdt_stop(wdd);
>
> Since min_timeout is > 0 this is never reached. You should move this up.
>

Good catch! Will do in v2.

Thanks,
Andrey Smirnov

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


Re: [PATCH v2 03/10] ARM: i.MX6: Record reset reason as a part of startup

2018-05-02 Thread Andrey Smirnov
On Wed, May 2, 2018 at 7:42 AM, Jan Lübbe  wrote:
> There is already code in drivers/watchdog/imxwd.c to handle this. Is
> that obsolete now?
>

AFAIK, watchdog IP block doesn't have as precise information about
reset source as SRSR register on i.MX SoCs that have the latter.
There, this code supersedes imxwd.c. OTHO  SoCs that don't have SRSR
(i.MX21, i.MX31, etc) still rely on code imxwd.c  for reset source
detection.

Hope this answers your question.

Thanks,
Andrey Smirnov

> On Fri, 2018-04-20 at 18:05 -0700, Andrey Smirnov wrote:
>> Signed-off-by: Andrey Smirnov 
>> ---
>>  arch/arm/mach-imx/imx6.c  | 13 -
>>  arch/arm/mach-imx/include/mach/reset-reason.h |  2 ++
>>  2 files changed, 14 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/arm/mach-imx/imx6.c b/arch/arm/mach-imx/imx6.c
>> index 88165adee..49610bf08 100644
>> --- a/arch/arm/mach-imx/imx6.c
>> +++ b/arch/arm/mach-imx/imx6.c
>> @@ -19,6 +19,7 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>  #include 
>>  #include 
>>  #include 
>> @@ -173,10 +174,20 @@ int imx6_cpu_revision(void)
>>   return soc_revision;
>>  }
>>
>> +static const struct imx_reset_reason imx6_reset_reasons[] = {
>> + { IMX_SRC_SRSR_IPP_RESET, RESET_POR,  0 },
>> + { IMX_SRC_SRSR_WDOG1_RESET,   RESET_WDG,  0 },
>> + { IMX_SRC_SRSR_JTAG_RESET,RESET_JTAG, 0 },
>> + { IMX_SRC_SRSR_JTAG_SW_RESET, RESET_JTAG, 0 },
>> + { IMX_SRC_SRSR_WARM_BOOT, RESET_RST,  0 },
>> + { /* sentinel */ }
>> +};
>> +
>>  int imx6_init(void)
>>  {
>>   const char *cputypestr;
>>   u32 mx6_silicon_revision;
>> + void __iomem *src = IOMEM(MX6_SRC_BASE_ADDR);
>>
>>   imx6_init_lowlevel();
>>
>> @@ -221,7 +232,7 @@ int imx6_init(void)
>>   }
>>
>>   imx_set_silicon_revision(cputypestr, mx6_silicon_revision);
>> -
>> + imx_set_reset_reason(src + IMX6_SRC_SRSR,
>> imx6_reset_reasons);
>>   imx6_setup_ipu_qos();
>>   imx6ul_enet_clk_init();
>>
>> diff --git a/arch/arm/mach-imx/include/mach/reset-reason.h
>> b/arch/arm/mach-imx/include/mach/reset-reason.h
>> index 39afc4b28..f2544a303 100644
>> --- a/arch/arm/mach-imx/include/mach/reset-reason.h
>> +++ b/arch/arm/mach-imx/include/mach/reset-reason.h
>> @@ -14,6 +14,8 @@
>>  #define IMX_SRC_SRSR_TEMPSENSE_RESET BIT(9)
>>  #define IMX_SRC_SRSR_WARM_BOOT   BIT(16)
>>
>> +#define IMX6_SRC_SRSR0x008
>> +
>>  struct imx_reset_reason {
>>   uint32_t mask;
>>   enum reset_src_type type;
> --
> 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 v2 03/10] ARM: i.MX6: Record reset reason as a part of startup

2018-05-02 Thread Jan Lübbe
There is already code in drivers/watchdog/imxwd.c to handle this. Is
that obsolete now?

On Fri, 2018-04-20 at 18:05 -0700, Andrey Smirnov wrote:
> Signed-off-by: Andrey Smirnov 
> ---
>  arch/arm/mach-imx/imx6.c  | 13 -
>  arch/arm/mach-imx/include/mach/reset-reason.h |  2 ++
>  2 files changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/mach-imx/imx6.c b/arch/arm/mach-imx/imx6.c
> index 88165adee..49610bf08 100644
> --- a/arch/arm/mach-imx/imx6.c
> +++ b/arch/arm/mach-imx/imx6.c
> @@ -19,6 +19,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -173,10 +174,20 @@ int imx6_cpu_revision(void)
>   return soc_revision;
>  }
>  
> +static const struct imx_reset_reason imx6_reset_reasons[] = {
> + { IMX_SRC_SRSR_IPP_RESET, RESET_POR,  0 },
> + { IMX_SRC_SRSR_WDOG1_RESET,   RESET_WDG,  0 },
> + { IMX_SRC_SRSR_JTAG_RESET,RESET_JTAG, 0 },
> + { IMX_SRC_SRSR_JTAG_SW_RESET, RESET_JTAG, 0 },
> + { IMX_SRC_SRSR_WARM_BOOT, RESET_RST,  0 },
> + { /* sentinel */ }
> +};
> +
>  int imx6_init(void)
>  {
>   const char *cputypestr;
>   u32 mx6_silicon_revision;
> + void __iomem *src = IOMEM(MX6_SRC_BASE_ADDR);
>  
>   imx6_init_lowlevel();
>  
> @@ -221,7 +232,7 @@ int imx6_init(void)
>   }
>  
>   imx_set_silicon_revision(cputypestr, mx6_silicon_revision);
> -
> + imx_set_reset_reason(src + IMX6_SRC_SRSR,
> imx6_reset_reasons);
>   imx6_setup_ipu_qos();
>   imx6ul_enet_clk_init();
>  
> diff --git a/arch/arm/mach-imx/include/mach/reset-reason.h
> b/arch/arm/mach-imx/include/mach/reset-reason.h
> index 39afc4b28..f2544a303 100644
> --- a/arch/arm/mach-imx/include/mach/reset-reason.h
> +++ b/arch/arm/mach-imx/include/mach/reset-reason.h
> @@ -14,6 +14,8 @@
>  #define IMX_SRC_SRSR_TEMPSENSE_RESET BIT(9)
>  #define IMX_SRC_SRSR_WARM_BOOT   BIT(16)
>  
> +#define IMX6_SRC_SRSR0x008
> +
>  struct imx_reset_reason {
>   uint32_t mask;
>   enum reset_src_type type;
-- 
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] blspec: add checking of optional key machine-id

2018-05-02 Thread Jan Lübbe
On Sun, 2018-04-29 at 18:01 +0200, Andreas Schmidt wrote:
> I guess, for such an use case Bootloader Spec specify "machine-id"
> key. This patch implement the support for machine-id key.

The way I read https://www.freedesktop.org/wiki/Specifications/BootLoad
erSpec/ is that the "machine-id" field should contain the ID from
/etc/machine-id, which is basically a UUID:
"machine-id shall contain the machine ID of the OS /etc/machine-id.
This is useful for boot loaders and applications to filter out boot
entries, for example to show only a single newest kernel per OS, or to
group items by OS, or to maybe filter out the currently booted OS in
UIs that want to show only other installed operating systems."

Your use-case sound like you'd need a way to add a more specific DT
board compatible at runtime. Then the existing selection logic would
handle your case as well.

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] blspec: add checking of optional key machine-id

2018-05-02 Thread Sascha Hauer
Hi Andreas,

On Sun, Apr 29, 2018 at 06:01:25PM +0200, Andreas Schmidt wrote:
> For filtering of Bootloader Spec entries, Bootloader Spec
> specify an optional key machine-id. By set the
> global.boot.machine-id variable the checking of machine-id
> key in Bootloader Spec entries will be activate. If the
> variable and key match, appropriate boot entry will be
> booting. If it not match boot entry will be ignore and
> barebox check the next boot entry.
> 
> Signed-off-by: Andreas Schmidt 
> ---
> Hi,
> we use the same barebox for all our devices. The devices have
> same CPU-module but different interface boards. So the bootloader
> has to choose the right boot entry. To determine the right boot entry we
> decide to use Bootloader Spec. But we have a issue: Currently, only oftree 
> compatibility is checking by barebox for Bootloader Spec entries. But all 
> our ofstrees are compatible with our barebox, because we use only one. So
> we need a additional possibility to check witch Bootloader Spec entry
> is the right one for appropriate device. I guess, for such an use case
> Bootloader Spec specify "machine-id" key. This patch implement the support
> for machine-id key.
> The machine-id key is optional. I decide to activate the checking of this
> key only if "global.boot.machine_id" variable is set to non-empty value.
> If "global.boot.machine_id" not set machine-id key will be ignored, 
> independent if it exists in Bootloader Spec entry or not.

I like the idea and the patch looks mosty fine.

> +static bool entry_is_match_machine_id(struct blspec_entry *entry)
> +{
> + int ret = true;
> + const char *env_machineid = getenv_nonempty("global.boot.machine_id");
> +
> + if (env_machineid) {
> + const char *machineid = blspec_entry_var_get(entry, 
> "machine-id");
> + if (!machineid || strcmp(machineid, env_machineid)) {
> + pr_info("ignoring entry with missmatched machine-id 
> \"%s\"\n",
> + env_machineid);

Don't you want to print the machine id of the current entry rather than
the desired machine id?

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] commands: of_display_timings: Add simple-panel support

2018-05-02 Thread Sascha Hauer
Hi Stefan,

On Fri, Apr 20, 2018 at 01:01:01PM +0200, Stefan Riedmueller wrote:
> Display timings can now be set with simple-panel method which selects
> the required timings by the compatible of the simple panel devicetree
> node.
> 
> This patch adds an option to set simple panel timings with the
> of_display_timings command by setting the compatible of the display node.
> The options -P and -c were implemented. The -P option requires the display
> node path as argument and the -c option requires the compatible to set.
> 
> This has one downside. The available simple panel timings cannot be
> listed since the timings are defined in the kernel. Account for this in the
> help text.
> 
> Signed-off-by: Stefan Riedmueller 
> ---
>  commands/of_display_timings.c | 65 
> ---
>  1 file changed, 61 insertions(+), 4 deletions(-)

This patch seems to be a way to manipulate a device tree property in the
Linux device tree. How about adding a new option to the of_property
command which would register a of_fixup instead of doing the operation
now?

Like this:

of_property -f -s /path/to/node compatible vendor,foo-display

> + case 'c':
> + compatible = optarg;
> + break;
>   case 'S':
>   timingpath = xzalloc(strlen(optarg) + 1);
>   strcpy(timingpath, optarg);

xstrdup() is what you want here.

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 0/6] i.MX51, 53 reset reason detection support

2018-05-02 Thread Sascha Hauer
On Thu, Apr 26, 2018 at 10:49:40PM -0700, Andrey Smirnov wrote:
> Everyone:
> 
> This patchset is a followup to "i.MX reset reason detection support"
> series I submited a couple of days ago. Mostly bits and pieces needed
> for i.MX51 and i.MX53 integration with the rest of reset reason code.
> 
> Feedback is wellcome!
> 
> Sascha:
> 
> Let me know if you want me to squash these patches back into original
> "i.MX reset reason detection support" series and re-submit it.

Applied, thanks. No need to squash the patches.

Sascha

> 
> Thanks,
> Andrey Smirnov
> 
> Andrey Smirnov (6):
>   ARM: i.MX51: Replace expicit casts with IOMEM
>   ARM: i.MX: Fix incorrect IMX_SRC_SRSR_CSU_RESET
>   ARM: i.MX: Make imx6_reset_reasons global
>   ARM: i.MX: Introduce IMX_SRC_SRSR
>   ARM: i.MX53: Record reset reason as a part of startup
>   ARM: i.MX51: Record reset reason as a part of startup
> 
>  arch/arm/mach-imx/imx.c   |  9 +
>  arch/arm/mach-imx/imx51.c | 20 
>  arch/arm/mach-imx/imx53.c |  4 
>  arch/arm/mach-imx/imx6.c  | 11 +--
>  arch/arm/mach-imx/include/mach/reset-reason.h |  8 
>  arch/arm/mach-imx/vf610.c |  2 +-
>  6 files changed, 31 insertions(+), 23 deletions(-)
> 
> -- 
> 2.14.3
> 
> 
> ___
> 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 1/2] ARM omap beagle xload_defconfig: do not load drivers from DT

2018-05-02 Thread Sascha Hauer
On Thu, Apr 26, 2018 at 05:56:44PM +, Alexander Kurz wrote:
> The first stage loader must run in SRAM and is limited in size.
> Remove unused support to load drivers from DT at this stage and
> save precious 9kB of code size.
> Regenerating the defconfig removes CONFIG_TEXT_BASE.
> 
> Signed-off-by: Alexander Kurz 
> ---
>  arch/arm/configs/omap3530_beagle_xload_defconfig | 3 ---
>  1 file changed, 3 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/arch/arm/configs/omap3530_beagle_xload_defconfig 
> b/arch/arm/configs/omap3530_beagle_xload_defconfig
> index d36aaf319..2105c0b9d 100644
> --- a/arch/arm/configs/omap3530_beagle_xload_defconfig
> +++ b/arch/arm/configs/omap3530_beagle_xload_defconfig
> @@ -8,7 +8,6 @@ CONFIG_THUMB2_BAREBOX=y
>  CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
>  CONFIG_ARM_UNWIND=y
>  CONFIG_MMU=y
> -CONFIG_TEXT_BASE=0x0
>  CONFIG_STACK_SIZE=0xc00
>  CONFIG_MALLOC_SIZE=0x0
>  CONFIG_MALLOC_DUMMY=y
> @@ -18,7 +17,6 @@ CONFIG_SHELL_NONE=y
>  # CONFIG_ERRNO_MESSAGES is not set
>  # CONFIG_TIMESTAMP is not set
>  CONFIG_CONSOLE_SIMPLE=y
> -CONFIG_OFDEVICE=y
>  CONFIG_DRIVER_SERIAL_NS16550=y
>  CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS=y
>  # CONFIG_SPI is not set
> @@ -36,7 +34,6 @@ CONFIG_MCI=y
>  CONFIG_MCI_STARTUP=y
>  # CONFIG_MCI_WRITE is not set
>  CONFIG_MCI_OMAP_HSMMC=y
> -# CONFIG_PINCTRL is not set
>  # CONFIG_FS_RAMFS is not set
>  # CONFIG_FS_DEVFS is not set
>  CONFIG_FS_FAT=y
> -- 
> 2.11.0
> 
> 

-- 
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] ARM: i.MX7: Remove unnecessary local variable

2018-05-02 Thread Sascha Hauer
On Thu, Apr 26, 2018 at 10:32:16PM -0700, Andrey Smirnov wrote:
> It looks this code was based on analogous code for i.MX6, but there
> that variable was being used as a part of following switch
> statement. Since this is not the case for i.MX7, just replace the
> variable with direct function call.
> 
> Signed-off-by: Andrey Smirnov 
> ---
>  arch/arm/mach-imx/imx7.c | 5 +
>  1 file changed, 1 insertion(+), 4 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/arch/arm/mach-imx/imx7.c b/arch/arm/mach-imx/imx7.c
> index 5ad91c2d7..e49baf6f7 100644
> --- a/arch/arm/mach-imx/imx7.c
> +++ b/arch/arm/mach-imx/imx7.c
> @@ -182,7 +182,6 @@ static const struct imx_reset_reason imx7_reset_reasons[] 
> = {
>  int imx7_init(void)
>  {
>   const char *cputypestr;
> - u32 imx7_silicon_revision;
>   void __iomem *src = IOMEM(MX7_SRC_BASE_ADDR);
>  
>   imx7_init_lowlevel();
> @@ -193,8 +192,6 @@ int imx7_init(void)
>  
>   imx7_boot_save_loc();
>  
> - imx7_silicon_revision = imx7_cpu_revision();
> -
>   psci_set_ops(_psci_ops);
>  
>   switch (imx7_cpu_type()) {
> @@ -209,7 +206,7 @@ int imx7_init(void)
>   break;
>   }
>  
> - imx_set_silicon_revision(cputypestr, imx7_silicon_revision);
> + imx_set_silicon_revision(cputypestr, imx7_cpu_revision());
>   imx_set_reset_reason(src + IMX7_SRC_SRSR, imx7_reset_reasons);
>  
>   return 0;
> -- 
> 2.14.3
> 
> 
> ___
> 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 v2] ARM: VFxxx: Record cpu boot source as a part of startup

2018-05-02 Thread Sascha Hauer
On Mon, Apr 30, 2018 at 11:47:14PM -0700, Andrey Smirnov wrote:
> Signed-off-by: Andrey Smirnov 
> ---
> 
> Same as original patch, but with fixed subject line.
> 
>  arch/arm/mach-imx/vf610.c | 2 ++
>  1 file changed, 2 insertions(+)

Applied, thanks

Sascha

> 
> diff --git a/arch/arm/mach-imx/vf610.c b/arch/arm/mach-imx/vf610.c
> index df8cfcd6b..3ac7c356f 100644
> --- a/arch/arm/mach-imx/vf610.c
> +++ b/arch/arm/mach-imx/vf610.c
> @@ -35,6 +35,8 @@ int vf610_init(void)
>   const char *cputypestr;
>   void __iomem *src = IOMEM(VF610_SRC_BASE_ADDR);
>  
> + vf610_boot_save_loc();
> +
>   switch (vf610_cpu_type()) {
>   case VF610_CPUTYPE_VF610:
>   cputypestr = "VF610";
> -- 
> 2.14.3
> 
> 
> ___
> 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/2] watchdog: Port RAVE SP watchdog driver from Linux kernel

2018-05-02 Thread Sascha Hauer
On Fri, Apr 20, 2018 at 06:33:38PM -0700, Andrey Smirnov wrote:
> +static int rave_sp_wdt_set_timeout(struct watchdog *wdd,
> +unsigned int timeout)
> +{
> + struct rave_sp_wdt *sp_wd = to_rave_sp_wdt(wdd);
> +
> + if (timeout < sp_wd->variant->min_timeout ||
> + timeout > sp_wd->variant->max_timeout)
> + return -EINVAL;
> +
> + if (!timeout)
> + return rave_sp_wdt_stop(wdd);

Since min_timeout is > 0 this is never reached. You should move this up.

Otherwise the patches look fine.

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] usbnet: increase bulk message timeout

2018-05-02 Thread Sascha Hauer
On Thu, Apr 26, 2018 at 04:02:48PM +0300, Nikita Yushchenko wrote:
> Timeout of 1ms is too low for case when device operates in Full Speed
> mode. This causes most incoming frames to be lost.
> 
> Since timeout is only used to get out of polling loop in case of no
> response from hardware, increasing it should be safe for all platforms.
> 
> Signed-off-by: Nikita Yushchenko 
> Tested-By: Andrew Lunn 
> ---

Applied, thanks.

The patch is whitespace damaged, I fixed this up manually this time.

Sascha

>  drivers/net/usb/usbnet.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
> index 33d900b70..60e67ff1a 100644
> --- a/drivers/net/usb/usbnet.c
> +++ b/drivers/net/usb/usbnet.c
> @@ -125,7 +125,7 @@ static int usbnet_recv(struct eth_device *edev)
>   len = dev->rx_urb_size;
>  -ret = usb_bulk_msg(dev->udev, dev->in, rx_buf, len, , 1);
> + ret = usb_bulk_msg(dev->udev, dev->in, rx_buf, len, , 100);
>   if (ret)
>   return ret;
>  -- 2.11.0
> 
> 

-- 
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] arm: imx6: don't reset PFDs that are used by periph_clk

2018-05-02 Thread Sascha Hauer
On Wed, Apr 25, 2018 at 11:45:06AM +0200, Marc Ohlf wrote:
> Check if PLL2 PFD0 or PLL2 PFD2 is selected as clock source in
> register CCM CBCMR->pre_periph_clk_sel or CCM CBCMR->pre_periph2_clk.
> Don't reset the used PFDs to avoid system hang.
> 
> ported from https://github.com/Freescale/u-boot-fslc/
> commit/9293d7fd502ce29302fadb8b4ccb9231ec0bcc66
> 
> Signed-off-by: Marc Ohlf 
> ---
>  arch/arm/mach-imx/imx6.c | 58 
> +---
>  1 file changed, 35 insertions(+), 23 deletions(-)

Appplied, thanks

Sascha

> 
> diff --git a/arch/arm/mach-imx/imx6.c b/arch/arm/mach-imx/imx6.c
> index 14a1cba..2b55a3c 100644
> --- a/arch/arm/mach-imx/imx6.c
> +++ b/arch/arm/mach-imx/imx6.c
> @@ -16,6 +16,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -44,6 +45,11 @@ static void imx6_init_lowlevel(void)
>   void __iomem *aips2 = (void *)MX6_AIPS2_ON_BASE_ADDR;
>   bool is_imx6q = __imx6_cpu_type() == IMX6_CPUTYPE_IMX6Q;
>   bool is_imx6d = __imx6_cpu_type() == IMX6_CPUTYPE_IMX6D;
> + uint32_t val_480;
> + uint32_t val_528;
> + uint32_t periph_sel_1;
> + uint32_t periph_sel_2;
> + uint32_t reg;
>  
>   /*
>* Set all MPROTx to be non-bufferable, trusted for R/W,
> @@ -68,32 +74,38 @@ static void imx6_init_lowlevel(void)
>   /* Due to hardware limitation, on MX6Q we need to gate/ungate all PFDs
>* to make sure PFD is working right, otherwise, PFDs may
>* not output clock after reset, MX6DL and MX6SL have added 396M pfd
> -  * workaround in ROM code, as bus clock need it
> +  * workaround in ROM code, as bus clock need it.
> +  * Don't reset PLL2 PFD0 / PLL2 PFD2 if is's used by periph_clk.
>*/
>   if (is_imx6q || is_imx6d) {
> - writel(BM_ANADIG_PFD_480_PFD3_CLKGATE |
> -BM_ANADIG_PFD_480_PFD2_CLKGATE |
> -BM_ANADIG_PFD_480_PFD1_CLKGATE |
> -BM_ANADIG_PFD_480_PFD0_CLKGATE,
> -MX6_ANATOP_BASE_ADDR + HW_ANADIG_PFD_480_SET);
> - writel(BM_ANADIG_PFD_528_PFD3_CLKGATE |
> -BM_ANADIG_PFD_528_PFD2_CLKGATE |
> -BM_ANADIG_PFD_528_PFD1_CLKGATE |
> -BM_ANADIG_PFD_528_PFD0_CLKGATE,
> -MX6_ANATOP_BASE_ADDR + HW_ANADIG_PFD_528_SET);
> -
> - writel(BM_ANADIG_PFD_480_PFD3_CLKGATE |
> -BM_ANADIG_PFD_480_PFD2_CLKGATE |
> -BM_ANADIG_PFD_480_PFD1_CLKGATE |
> -BM_ANADIG_PFD_480_PFD0_CLKGATE,
> -MX6_ANATOP_BASE_ADDR + HW_ANADIG_PFD_480_CLR);
> - writel(BM_ANADIG_PFD_528_PFD3_CLKGATE |
> -BM_ANADIG_PFD_528_PFD2_CLKGATE |
> -BM_ANADIG_PFD_528_PFD1_CLKGATE |
> -BM_ANADIG_PFD_528_PFD0_CLKGATE,
> -MX6_ANATOP_BASE_ADDR + HW_ANADIG_PFD_528_CLR);
> - }
> + val_480 = BM_ANADIG_PFD_480_PFD3_CLKGATE |
> +BM_ANADIG_PFD_480_PFD2_CLKGATE |
> +BM_ANADIG_PFD_480_PFD1_CLKGATE |
> +BM_ANADIG_PFD_480_PFD0_CLKGATE;
> +
> + val_528 = BM_ANADIG_PFD_528_PFD3_CLKGATE |
> +BM_ANADIG_PFD_528_PFD1_CLKGATE;
> +
> + reg = readl(MXC_CCM_CBCMR);
> + periph_sel_1 = (reg & MXC_CCM_CBCMR_PRE_PERIPH_CLK_SEL_MASK)
> + >> MXC_CCM_CBCMR_PRE_PERIPH_CLK_SEL_OFFSET;
> +
> + periph_sel_2 = (reg & MXC_CCM_CBCMR_PRE_PERIPH2_CLK_SEL_MASK)
> + >> MXC_CCM_CBCMR_PRE_PERIPH2_CLK_SEL_OFFSET;
>  
> + if ((periph_sel_1 != 0x2) && (periph_sel_2 != 0x2))
> + val_528 |= BM_ANADIG_PFD_528_PFD0_CLKGATE;
> +
> + if ((periph_sel_1 != 0x1) && (periph_sel_2 != 0x1)
> + && (periph_sel_1 != 0x3) && (periph_sel_2 != 0x3))
> + val_528 |= BM_ANADIG_PFD_528_PFD2_CLKGATE;
> +
> + writel(val_480, MX6_ANATOP_BASE_ADDR + HW_ANADIG_PFD_480_SET);
> + writel(val_528, MX6_ANATOP_BASE_ADDR + HW_ANADIG_PFD_528_SET);
> +
> + writel(val_480, MX6_ANATOP_BASE_ADDR + HW_ANADIG_PFD_480_CLR);
> + writel(val_528, MX6_ANATOP_BASE_ADDR + HW_ANADIG_PFD_528_CLR);
> + }
>  }
>  
>  static void imx6_setup_ipu_qos(void)
> -- 
> 2.7.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