Re: [PATCH 1/2] power: reset: add driver for Hardkernel's Odroid boards

2015-01-27 Thread Marek Szyprowski

Hello,

On 2015-01-25 15:32, Sebastian Reichel wrote:

On Fri, Jan 23, 2015 at 12:11:22PM +0100, Marek Szyprowski wrote:

Frankly, I analyzed this case once again and I came to conclusion
that there is no need to make a separate reset driver for Odroid
boards. There is nothing special, specific to whole board about
this gpio. It is rather a property of MMC host controller and eMMC
card that is connected to it. When only gpio toggling code is
moved to reset handler registered from mmc controller, the board
properly performs reboot with a generic exynos4 code.

OK, so I guess this will be fixed independently via mmc subsystem.


I've posted an updated patch.




The poweroff code in above driver is just a generic Exynos4 code,
so again there is no need to duplicate it.

OK. It seems there is a driver for that in arch/arm/mach-exynos.
Otherwise I would have suggest to create something like
syscon-reboot for shutdown.


By moving the code to mmc driver, the same approach can be used for other
Odroid boards (XU/XU3) and maybe even other boards which need manual
resetting of eMMC cards to properly perform reboot procedure.

I suggest to start a new thread for discussing this, which includes
linux-mmc. It might be interesting to provide some more details about
eMMC_nDET, since MMC already contain a reset signal (which seems to
be used according to the odroid schematics I found).


My fault. The documentation for this initial driver was incorrect. The 
reboot
fix has noting to eMMC_nDET signal. It should be eMMC nreset, which is 
routed

directly to SoC GPIO line with external pull-up resistor. I really have no
idea why I wrote eMMC_nDET instead of nreset.

Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] power: reset: add driver for Hardkernel's Odroid boards

2015-01-25 Thread Sebastian Reichel
Hi,

On Fri, Jan 23, 2015 at 12:11:22PM +0100, Marek Szyprowski wrote:
> Frankly, I analyzed this case once again and I came to conclusion
> that there is no need to make a separate reset driver for Odroid
> boards. There is nothing special, specific to whole board about
> this gpio. It is rather a property of MMC host controller and eMMC
> card that is connected to it. When only gpio toggling code is
> moved to reset handler registered from mmc controller, the board
> properly performs reboot with a generic exynos4 code.

OK, so I guess this will be fixed independently via mmc subsystem.

> The poweroff code in above driver is just a generic Exynos4 code,
> so again there is no need to duplicate it.

OK. It seems there is a driver for that in arch/arm/mach-exynos.
Otherwise I would have suggest to create something like
syscon-reboot for shutdown.

> By moving the code to mmc driver, the same approach can be used for other
> Odroid boards (XU/XU3) and maybe even other boards which need manual
> resetting of eMMC cards to properly perform reboot procedure.

I suggest to start a new thread for discussing this, which includes
linux-mmc. It might be interesting to provide some more details about
eMMC_nDET, since MMC already contain a reset signal (which seems to
be used according to the odroid schematics I found).

-- Sebastian


signature.asc
Description: Digital signature


Re: [PATCH 1/2] power: reset: add driver for Hardkernel's Odroid boards

2015-01-23 Thread Marek Szyprowski

Hello,

On 2015-01-22 02:33, Joonyoung Shim wrote:

On 01/22/2015 10:06 AM, Sebastian Reichel wrote:

On Wed, Oct 29, 2014 at 02:13:28PM +0100, Marek Szyprowski wrote:

This patch adds a driver implementing correct reboot and poweroff
procedures for Exynos4412-based Hardkernel's Odroid X/X2/U2/U3/U3+
boards.

Sorry it took so long. I have a couple of small requests before
applying this (comments inline).


Signed-off-by: Marek Szyprowski 
---
  .../bindings/power/reset/odroid-reset.txt  |  18 
  drivers/power/reset/Kconfig|   6 ++
  drivers/power/reset/Makefile   |   1 +
  drivers/power/reset/odroid-reboot.c| 119 +
  4 files changed, 144 insertions(+)
  create mode 100644 
Documentation/devicetree/bindings/power/reset/odroid-reset.txt
  create mode 100644 drivers/power/reset/odroid-reboot.c

diff --git a/Documentation/devicetree/bindings/power/reset/odroid-reset.txt 
b/Documentation/devicetree/bindings/power/reset/odroid-reset.txt
new file mode 100644
index ..86471a463518
--- /dev/null
+++ b/Documentation/devicetree/bindings/power/reset/odroid-reset.txt
@@ -0,0 +1,18 @@
+* Device tree bindings for Hardkernel's Exynos4412 based Odroid boards
+
+This node is intended to allow proper system reboot and power off of
+Odroid X/X2/U2/U3/U3+ boards with eMMC storage. Without this node, board
+hangs during standard reset procedure.
+
+Required properties:
+- compatible:  hardkernel,odroid-reboot
+- samsung,pmureg-phandle:  phandle to Exynos PMU node
+- reset-gpios: phandle and gpio-specifier to the GPIO pin
+   connected to the eMMC_nDET
+
+Example:
+odroid_reboot {
+   compatible = "hardkernel,odroid-reboot";
+   samsung,pmureg-phandle = <&pmu_system_controller>;
+   reset-gpio = <&gpk1 2 0>;
+};
diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig
index f65ff49bb275..f02b13d5344f 100644
--- a/drivers/power/reset/Kconfig
+++ b/drivers/power/reset/Kconfig
@@ -84,6 +84,12 @@ config POWER_RESET_LTC2952
  This driver supports an external powerdown trigger and board power
  down via the LTC2952. Bindings are made in the device tree.
  
+config POWER_RESET_ODROID

+   bool "Hardkernel's Exynos4412 based Odroid reboot driver"
+   depends on POWER_RESET && ARCH_EXYNOS

once the arm specific restart handler is gone you can add ||
COMPILE_TEST


+   help
+ Power off and restart support for Odroid boards.
+
  config POWER_RESET_QNAP
bool "QNAP power-off driver"
depends on OF_GPIO && PLAT_ORION
diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile
index 76ce1c59469b..178ee86eb813 100644
--- a/drivers/power/reset/Makefile
+++ b/drivers/power/reset/Makefile
@@ -8,6 +8,7 @@ obj-$(CONFIG_POWER_RESET_GPIO_RESTART) += gpio-restart.o
  obj-$(CONFIG_POWER_RESET_HISI) += hisi-reboot.o
  obj-$(CONFIG_POWER_RESET_MSM) += msm-poweroff.o
  obj-$(CONFIG_POWER_RESET_LTC2952) += ltc2952-poweroff.o
+obj-$(CONFIG_POWER_RESET_ODROID) += odroid-reboot.o
  obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o
  obj-$(CONFIG_POWER_RESET_RESTART) += restart-poweroff.o
  obj-$(CONFIG_POWER_RESET_SUN6I) += sun6i-reboot.o
diff --git a/drivers/power/reset/odroid-reboot.c 
b/drivers/power/reset/odroid-reboot.c
new file mode 100644
index ..823e93539220
--- /dev/null
+++ b/drivers/power/reset/odroid-reboot.c
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#define PS_HOLD_CONTROL0x330C
+
+struct odroid_reboot_data {
+   struct device *dev;
+   int power_gpio;
+   struct regmap *reg_pmu;
+   void (*reboot_func)(enum reboot_mode mode, const char *cmd);
+};
+
+static struct odroid_reboot_data *reboot_data;
+
+static void odroid_reboot(enum reboot_mode mode, const char *cmd)
+{
+   local_irq_disable();
+
+   gpio_set_value(reboot_data->power_gpio, 0);
+   mdelay(150);
+   gpio_set_value(reboot_data->power_gpio, 1);
+
+   reboot_data->reboot_func(mode, cmd);
+

It is called do_kernel_restart() if arm_pm_restart is NULL from
machine_restart of arch/arm/kernel/process.c

How about this?

if (reboot_data->reboot_func)
reboot_data->reboot_func(mode, cmd);
else
do_kernel_restart(cmd);


Frankly, I analyzed this case once again and I came to conclusion that there
is no need to make a separate reset driver for Odroid boards. There is 
nothing

special, specific to whole board about this gpio. It i

Re: [PATCH 1/2] power: reset: add driver for Hardkernel's Odroid boards

2015-01-21 Thread Joonyoung Shim
Hi,

On 01/22/2015 10:06 AM, Sebastian Reichel wrote:
> Hi,
> 
> On Wed, Oct 29, 2014 at 02:13:28PM +0100, Marek Szyprowski wrote:
>> This patch adds a driver implementing correct reboot and poweroff
>> procedures for Exynos4412-based Hardkernel's Odroid X/X2/U2/U3/U3+
>> boards.
> 
> Sorry it took so long. I have a couple of small requests before
> applying this (comments inline).
> 
>> Signed-off-by: Marek Szyprowski 
>> ---
>>  .../bindings/power/reset/odroid-reset.txt  |  18 
>>  drivers/power/reset/Kconfig|   6 ++
>>  drivers/power/reset/Makefile   |   1 +
>>  drivers/power/reset/odroid-reboot.c| 119 
>> +
>>  4 files changed, 144 insertions(+)
>>  create mode 100644 
>> Documentation/devicetree/bindings/power/reset/odroid-reset.txt
>>  create mode 100644 drivers/power/reset/odroid-reboot.c
>>
>> diff --git a/Documentation/devicetree/bindings/power/reset/odroid-reset.txt 
>> b/Documentation/devicetree/bindings/power/reset/odroid-reset.txt
>> new file mode 100644
>> index ..86471a463518
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/power/reset/odroid-reset.txt
>> @@ -0,0 +1,18 @@
>> +* Device tree bindings for Hardkernel's Exynos4412 based Odroid boards
>> +
>> +This node is intended to allow proper system reboot and power off of
>> +Odroid X/X2/U2/U3/U3+ boards with eMMC storage. Without this node, board
>> +hangs during standard reset procedure.
>> +
>> +Required properties:
>> +- compatible:   hardkernel,odroid-reboot
>> +- samsung,pmureg-phandle:   phandle to Exynos PMU node
>> +- reset-gpios:  phandle and gpio-specifier to the GPIO 
>> pin
>> +connected to the eMMC_nDET
>> +
>> +Example:
>> +odroid_reboot {
>> +compatible = "hardkernel,odroid-reboot";
>> +samsung,pmureg-phandle = <&pmu_system_controller>;
>> +reset-gpio = <&gpk1 2 0>;
>> +};
>> diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig
>> index f65ff49bb275..f02b13d5344f 100644
>> --- a/drivers/power/reset/Kconfig
>> +++ b/drivers/power/reset/Kconfig
>> @@ -84,6 +84,12 @@ config POWER_RESET_LTC2952
>>This driver supports an external powerdown trigger and board power
>>down via the LTC2952. Bindings are made in the device tree.
>>  
>> +config POWER_RESET_ODROID
>> +bool "Hardkernel's Exynos4412 based Odroid reboot driver"
>> +depends on POWER_RESET && ARCH_EXYNOS
> 
> once the arm specific restart handler is gone you can add ||
> COMPILE_TEST
> 
>> +help
>> +  Power off and restart support for Odroid boards.
>> +
>>  config POWER_RESET_QNAP
>>  bool "QNAP power-off driver"
>>  depends on OF_GPIO && PLAT_ORION
>> diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile
>> index 76ce1c59469b..178ee86eb813 100644
>> --- a/drivers/power/reset/Makefile
>> +++ b/drivers/power/reset/Makefile
>> @@ -8,6 +8,7 @@ obj-$(CONFIG_POWER_RESET_GPIO_RESTART) += gpio-restart.o
>>  obj-$(CONFIG_POWER_RESET_HISI) += hisi-reboot.o
>>  obj-$(CONFIG_POWER_RESET_MSM) += msm-poweroff.o
>>  obj-$(CONFIG_POWER_RESET_LTC2952) += ltc2952-poweroff.o
>> +obj-$(CONFIG_POWER_RESET_ODROID) += odroid-reboot.o
>>  obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o
>>  obj-$(CONFIG_POWER_RESET_RESTART) += restart-poweroff.o
>>  obj-$(CONFIG_POWER_RESET_SUN6I) += sun6i-reboot.o
>> diff --git a/drivers/power/reset/odroid-reboot.c 
>> b/drivers/power/reset/odroid-reboot.c
>> new file mode 100644
>> index ..823e93539220
>> --- /dev/null
>> +++ b/drivers/power/reset/odroid-reboot.c
>> @@ -0,0 +1,119 @@
>> +/*
>> + * Copyright (c) 2014 Samsung Electronics Co., Ltd.
>> + *  http://www.samsung.com
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License as published by
>> + * the Free Software Foundation; either version 2 of the License, or
>> + * (at your option) any later version.
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include 
>> +
>> +#define PS_HOLD_CONTROL 0x330C
>> +
>> +struct odroid_reboot_data {
>> +struct device *dev;
>> +int power_gpio;
>> +struct regmap *reg_pmu;
>> +void (*reboot_func)(enum reboot_mode mode, const char *cmd);
>> +};
>> +
>> +static struct odroid_reboot_data *reboot_data;
>> +
>> +static void odroid_reboot(enum reboot_mode mode, const char *cmd)
>> +{
>> +local_irq_disable();
>> +
>> +gpio_set_value(reboot_data->power_gpio, 0);
>> +mdelay(150);
>> +gpio_set_value(reboot_data->power_gpio, 1);
>> +
>> +reboot_data->reboot_func(mode, cmd);
>> +

It is called do_kernel_restart() if arm_pm_restart is NULL from
machine_restart of arch/arm/kernel/process.c

How about this?

if (reboot_data->reboot_func)
reboot_data->reboot_func(mode,

Re: [PATCH 1/2] power: reset: add driver for Hardkernel's Odroid boards

2015-01-21 Thread Sebastian Reichel
Hi,

On Wed, Oct 29, 2014 at 02:13:28PM +0100, Marek Szyprowski wrote:
> This patch adds a driver implementing correct reboot and poweroff
> procedures for Exynos4412-based Hardkernel's Odroid X/X2/U2/U3/U3+
> boards.

Sorry it took so long. I have a couple of small requests before
applying this (comments inline).

> Signed-off-by: Marek Szyprowski 
> ---
>  .../bindings/power/reset/odroid-reset.txt  |  18 
>  drivers/power/reset/Kconfig|   6 ++
>  drivers/power/reset/Makefile   |   1 +
>  drivers/power/reset/odroid-reboot.c| 119 
> +
>  4 files changed, 144 insertions(+)
>  create mode 100644 
> Documentation/devicetree/bindings/power/reset/odroid-reset.txt
>  create mode 100644 drivers/power/reset/odroid-reboot.c
> 
> diff --git a/Documentation/devicetree/bindings/power/reset/odroid-reset.txt 
> b/Documentation/devicetree/bindings/power/reset/odroid-reset.txt
> new file mode 100644
> index ..86471a463518
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/power/reset/odroid-reset.txt
> @@ -0,0 +1,18 @@
> +* Device tree bindings for Hardkernel's Exynos4412 based Odroid boards
> +
> +This node is intended to allow proper system reboot and power off of
> +Odroid X/X2/U2/U3/U3+ boards with eMMC storage. Without this node, board
> +hangs during standard reset procedure.
> +
> +Required properties:
> +- compatible:hardkernel,odroid-reboot
> +- samsung,pmureg-phandle:phandle to Exynos PMU node
> +- reset-gpios:   phandle and gpio-specifier to the GPIO 
> pin
> + connected to the eMMC_nDET
> +
> +Example:
> +odroid_reboot {
> + compatible = "hardkernel,odroid-reboot";
> + samsung,pmureg-phandle = <&pmu_system_controller>;
> + reset-gpio = <&gpk1 2 0>;
> +};
> diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig
> index f65ff49bb275..f02b13d5344f 100644
> --- a/drivers/power/reset/Kconfig
> +++ b/drivers/power/reset/Kconfig
> @@ -84,6 +84,12 @@ config POWER_RESET_LTC2952
> This driver supports an external powerdown trigger and board power
> down via the LTC2952. Bindings are made in the device tree.
>  
> +config POWER_RESET_ODROID
> + bool "Hardkernel's Exynos4412 based Odroid reboot driver"
> + depends on POWER_RESET && ARCH_EXYNOS

once the arm specific restart handler is gone you can add ||
COMPILE_TEST

> + help
> +   Power off and restart support for Odroid boards.
> +
>  config POWER_RESET_QNAP
>   bool "QNAP power-off driver"
>   depends on OF_GPIO && PLAT_ORION
> diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile
> index 76ce1c59469b..178ee86eb813 100644
> --- a/drivers/power/reset/Makefile
> +++ b/drivers/power/reset/Makefile
> @@ -8,6 +8,7 @@ obj-$(CONFIG_POWER_RESET_GPIO_RESTART) += gpio-restart.o
>  obj-$(CONFIG_POWER_RESET_HISI) += hisi-reboot.o
>  obj-$(CONFIG_POWER_RESET_MSM) += msm-poweroff.o
>  obj-$(CONFIG_POWER_RESET_LTC2952) += ltc2952-poweroff.o
> +obj-$(CONFIG_POWER_RESET_ODROID) += odroid-reboot.o
>  obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o
>  obj-$(CONFIG_POWER_RESET_RESTART) += restart-poweroff.o
>  obj-$(CONFIG_POWER_RESET_SUN6I) += sun6i-reboot.o
> diff --git a/drivers/power/reset/odroid-reboot.c 
> b/drivers/power/reset/odroid-reboot.c
> new file mode 100644
> index ..823e93539220
> --- /dev/null
> +++ b/drivers/power/reset/odroid-reboot.c
> @@ -0,0 +1,119 @@
> +/*
> + * Copyright (c) 2014 Samsung Electronics Co., Ltd.
> + *   http://www.samsung.com
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +
> +#define PS_HOLD_CONTROL  0x330C
> +
> +struct odroid_reboot_data {
> + struct device *dev;
> + int power_gpio;
> + struct regmap *reg_pmu;
> + void (*reboot_func)(enum reboot_mode mode, const char *cmd);
> +};
> +
> +static struct odroid_reboot_data *reboot_data;
> +
> +static void odroid_reboot(enum reboot_mode mode, const char *cmd)
> +{
> + local_irq_disable();
> +
> + gpio_set_value(reboot_data->power_gpio, 0);
> + mdelay(150);
> + gpio_set_value(reboot_data->power_gpio, 1);
> +
> + reboot_data->reboot_func(mode, cmd);
> +
> + pr_emerg("%s: waiting for reboot\n", __func__);
> + while (1)
> + ;
> +}
> +
> +static void odroid_power_off(void)
> +{
> + regmap_update_bits(reboot_data->reg_pmu, PS_HOLD_CONTROL, 0x, 
> 0x5200);
> + while (1) {
> + pr_emerg("%s: should not reach here!\n", __func__);
> + msleep(1000);
> + }
> +

[PATCH 1/2] power: reset: add driver for Hardkernel's Odroid boards

2014-10-29 Thread Marek Szyprowski
This patch adds a driver implementing correct reboot and poweroff
procedures for Exynos4412-based Hardkernel's Odroid X/X2/U2/U3/U3+
boards.

Signed-off-by: Marek Szyprowski 
---
 .../bindings/power/reset/odroid-reset.txt  |  18 
 drivers/power/reset/Kconfig|   6 ++
 drivers/power/reset/Makefile   |   1 +
 drivers/power/reset/odroid-reboot.c| 119 +
 4 files changed, 144 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/power/reset/odroid-reset.txt
 create mode 100644 drivers/power/reset/odroid-reboot.c

diff --git a/Documentation/devicetree/bindings/power/reset/odroid-reset.txt 
b/Documentation/devicetree/bindings/power/reset/odroid-reset.txt
new file mode 100644
index ..86471a463518
--- /dev/null
+++ b/Documentation/devicetree/bindings/power/reset/odroid-reset.txt
@@ -0,0 +1,18 @@
+* Device tree bindings for Hardkernel's Exynos4412 based Odroid boards
+
+This node is intended to allow proper system reboot and power off of
+Odroid X/X2/U2/U3/U3+ boards with eMMC storage. Without this node, board
+hangs during standard reset procedure.
+
+Required properties:
+- compatible:  hardkernel,odroid-reboot
+- samsung,pmureg-phandle:  phandle to Exynos PMU node
+- reset-gpios: phandle and gpio-specifier to the GPIO pin
+   connected to the eMMC_nDET
+
+Example:
+odroid_reboot {
+   compatible = "hardkernel,odroid-reboot";
+   samsung,pmureg-phandle = <&pmu_system_controller>;
+   reset-gpio = <&gpk1 2 0>;
+};
diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig
index f65ff49bb275..f02b13d5344f 100644
--- a/drivers/power/reset/Kconfig
+++ b/drivers/power/reset/Kconfig
@@ -84,6 +84,12 @@ config POWER_RESET_LTC2952
  This driver supports an external powerdown trigger and board power
  down via the LTC2952. Bindings are made in the device tree.
 
+config POWER_RESET_ODROID
+   bool "Hardkernel's Exynos4412 based Odroid reboot driver"
+   depends on POWER_RESET && ARCH_EXYNOS
+   help
+ Power off and restart support for Odroid boards.
+
 config POWER_RESET_QNAP
bool "QNAP power-off driver"
depends on OF_GPIO && PLAT_ORION
diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile
index 76ce1c59469b..178ee86eb813 100644
--- a/drivers/power/reset/Makefile
+++ b/drivers/power/reset/Makefile
@@ -8,6 +8,7 @@ obj-$(CONFIG_POWER_RESET_GPIO_RESTART) += gpio-restart.o
 obj-$(CONFIG_POWER_RESET_HISI) += hisi-reboot.o
 obj-$(CONFIG_POWER_RESET_MSM) += msm-poweroff.o
 obj-$(CONFIG_POWER_RESET_LTC2952) += ltc2952-poweroff.o
+obj-$(CONFIG_POWER_RESET_ODROID) += odroid-reboot.o
 obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o
 obj-$(CONFIG_POWER_RESET_RESTART) += restart-poweroff.o
 obj-$(CONFIG_POWER_RESET_SUN6I) += sun6i-reboot.o
diff --git a/drivers/power/reset/odroid-reboot.c 
b/drivers/power/reset/odroid-reboot.c
new file mode 100644
index ..823e93539220
--- /dev/null
+++ b/drivers/power/reset/odroid-reboot.c
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#define PS_HOLD_CONTROL0x330C
+
+struct odroid_reboot_data {
+   struct device *dev;
+   int power_gpio;
+   struct regmap *reg_pmu;
+   void (*reboot_func)(enum reboot_mode mode, const char *cmd);
+};
+
+static struct odroid_reboot_data *reboot_data;
+
+static void odroid_reboot(enum reboot_mode mode, const char *cmd)
+{
+   local_irq_disable();
+
+   gpio_set_value(reboot_data->power_gpio, 0);
+   mdelay(150);
+   gpio_set_value(reboot_data->power_gpio, 1);
+
+   reboot_data->reboot_func(mode, cmd);
+
+   pr_emerg("%s: waiting for reboot\n", __func__);
+   while (1)
+   ;
+}
+
+static void odroid_power_off(void)
+{
+   regmap_update_bits(reboot_data->reg_pmu, PS_HOLD_CONTROL, 0x, 
0x5200);
+   while (1) {
+   pr_emerg("%s: should not reach here!\n", __func__);
+   msleep(1000);
+   }
+}
+
+static struct odroid_reboot_data *odroid_reboot_parse_dt(struct device *dev)
+{
+   struct device_node *np = dev->of_node;
+   struct odroid_reboot_data *data;
+
+   data = devm_kzalloc(dev, sizeof(struct odroid_reboot_data), GFP_KERNEL);
+   if (!data)
+   return NULL;
+
+   data->power_gpio = of_get_named_gpio(np, "reset-gpios", 0);
+   if (!gpio_is_valid(data->power_gpio)) {
+   dev_err(dev, "invalid res