From patchwork Wed Oct 29 13:13:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 39771 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BB95224046 for ; Wed, 29 Oct 2014 13:13:59 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id h11sf1916207wiw.11 for ; Wed, 29 Oct 2014 06:13:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=KAqGH6OLb3Wc+Ok1i72eg3WLFC2LxoE4Xk2joAJZitA=; b=cuGrYy22tlkXMsvY87IYuITY72lyUzCjtOF5SgT0CRrSs0OAxsQQezwTKWSjynIX7K BqnRc5ydQ0T6Dc011EBZvp4GywH9Gi5dnFdGLI5tq5lodKLdOP69fdc2fV/B/If+mxOX 0OaWnJI/hVRkgzxWzsNfvHAgRjRnr+87kFlVOv1OXIkXup9csMtFpQkYWyRADrxvrJ0R Nhf96eWCFcllHcluo8HgFzDUwm1BJyBvNDbAJufXPzpygnriCPMx0G8CHiEw6IwFckMp MisHA5AM9M3a44MIABPmMWaHLMLGUZK02218z6sR8cTHF8QZVmjPyxE9DHgcrnROYOFi JN9Q== X-Gm-Message-State: ALoCoQkUmitAxeymmPKAtedHPpyogG7W1+KzOukyBpknsCAxotl/6mtW5yER1oQVGTey2HEq00qZ X-Received: by 10.112.32.163 with SMTP id k3mr163792lbi.17.1414588438935; Wed, 29 Oct 2014 06:13:58 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.206.8 with SMTP id lk8ls168930lac.17.gmail; Wed, 29 Oct 2014 06:13:58 -0700 (PDT) X-Received: by 10.152.7.7 with SMTP id f7mr11162755laa.57.1414588438589; Wed, 29 Oct 2014 06:13:58 -0700 (PDT) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com. [209.85.215.45]) by mx.google.com with ESMTPS id d5si7128545laf.110.2014.10.29.06.13.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 Oct 2014 06:13:58 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by mail-la0-f45.google.com with SMTP id gm9so2473113lab.4 for ; Wed, 29 Oct 2014 06:13:58 -0700 (PDT) X-Received: by 10.112.12.35 with SMTP id v3mr11301229lbb.80.1414588438431; Wed, 29 Oct 2014 06:13:58 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp654379lbz; Wed, 29 Oct 2014 06:13:57 -0700 (PDT) X-Received: by 10.70.20.66 with SMTP id l2mr10445862pde.106.1414588436430; Wed, 29 Oct 2014 06:13:56 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ss6si4072142pab.26.2014.10.29.06.13.55 for ; Wed, 29 Oct 2014 06:13:56 -0700 (PDT) Received-SPF: none (google.com: devicetree-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932768AbaJ2NNy (ORCPT + 4 others); Wed, 29 Oct 2014 09:13:54 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:24174 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932746AbaJ2NNx (ORCPT ); Wed, 29 Oct 2014 09:13:53 -0400 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NE700L4KJJXTX00@mailout1.w1.samsung.com>; Wed, 29 Oct 2014 13:16:45 +0000 (GMT) X-AuditID: cbfec7f4-b7f6c6d00000120b-eb-5450e80e821d Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id BF.90.04619.E08E0545; Wed, 29 Oct 2014 13:13:50 +0000 (GMT) Received: from amdc1339.digital.local ([106.116.147.30]) by eusync3.samsung.com (Oracle Communications Messaging Server 7u4-23.01 (7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0NE70089XJEZ5DA0@eusync3.samsung.com>; Wed, 29 Oct 2014 13:13:50 +0000 (GMT) From: Marek Szyprowski To: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , Kukjin Kim , Tobias Jakobi , Daniel Drake , Dmitry Eremin-Solenikov , David Woodhouse , Sebastian Reichel Subject: [PATCH 1/2] power: reset: add driver for Hardkernel's Odroid boards Date: Wed, 29 Oct 2014 14:13:28 +0100 Message-id: <1414588409-8065-1-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.2 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrEJMWRmVeSWpSXmKPExsVy+t/xq7p8LwJCDG7st7SY9OQ9s8X8I+dY LR7Nf8xsMXHlZGaL3gVX2Sw+9x5htJhxfh+TRdfPn2wWa4/cZbc4vbvEgctj0fcsj52z7rJ7 LN60n81j8wotj02rOtk8+rasYvT4vEkugD2KyyYlNSezLLVI3y6BK2PemjfsBScMKt6+uM/U wHhTo4uRk0NCwETix5nzTBC2mMSFe+vZuhi5OIQEljJKnNt7ixEkISTQxyTx45IDiM0mYCjR 9baLDcQWEYiVmLj1B5jNLDCPSeLgjnwQW1jAR+L6u2/MIDaLgKrEo4dvgOZwcPAKuEv8WO8N sUtO4v/LFUwTGLkXMDKsYhRNLU0uKE5KzzXUK07MLS7NS9dLzs/dxAgJpy87GBcfszrEKMDB qMTD67AxIESINbGsuDL3EKMEB7OSCO+7vUAh3pTEyqrUovz4otKc1OJDjEwcnFINjAsOWsXz SgtvnfWvsW/tA+Yq2dB38u3WU0ScFvQd835VHHP8i0qY0G19l9bHrmG6TB7eVy5c9fWaMlP1 lyGXR3nL3atR0zSCbizfejRCvU9Jgc1/085/P9K61uSeVYtLT+pV4y57skXuxvbIp2UHl157 6ZN2IUjSxER/7uNS6Zq/y13rZgZNVmIpzkg01GIuKk4EAC3B/H4FAgAA Sender: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: m.szyprowski@samsung.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 000000000000..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 000000000000..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, 0xffffffff, 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 reset gpio pin\n"); + return NULL; + } + devm_gpio_request(dev, data->power_gpio, "reset"); + + data->reg_pmu = syscon_regmap_lookup_by_phandle(np, + "samsung,pmureg-phandle"); + if (IS_ERR(data->reg_pmu)) { + dev_err(dev, "failed to map PMU registers\n"); + return NULL; + } + + return data; +} + +static int odroid_reboot_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + + if (pdev->dev.of_node) + reboot_data = odroid_reboot_parse_dt(dev); + + if (!reboot_data) + return -EINVAL; + + reboot_data->dev = &pdev->dev; + reboot_data->reboot_func = arm_pm_restart; + + /* grab reboot arm specific hook */ + arm_pm_restart = odroid_reboot; + + /* register power off function */ + pm_power_off = odroid_power_off; + + return 0; +} + +static struct of_device_id odroid_reboot_of_match[] = { + { .compatible = "hardkernel,odroid-reboot", }, + { }, +}; + +static struct platform_driver odroid_reboot_driver = { + .probe = odroid_reboot_probe, + .driver = { + .name = "odroid-reboot", + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(odroid_reboot_of_match), + } +}; +module_platform_driver(odroid_reboot_driver);