From patchwork Fri Apr 1 14:16:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 8725071 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B77709F38C for ; Fri, 1 Apr 2016 14:18:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B4A9720396 for ; Fri, 1 Apr 2016 14:18:48 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 65B8B203B8 for ; Fri, 1 Apr 2016 14:18:47 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1alzsu-00009U-G0; Fri, 01 Apr 2016 14:17:12 +0000 Received: from mail-wm0-x236.google.com ([2a00:1450:400c:c09::236]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1alzsh-0008Ia-Hw for linux-arm-kernel@lists.infradead.org; Fri, 01 Apr 2016 14:17:01 +0000 Received: by mail-wm0-x236.google.com with SMTP id f198so27959989wme.0 for ; Fri, 01 Apr 2016 07:16:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ViG+IpttJDDpdFsvHFT0lDjP5PpCTN0z4enIuahFCwg=; b=pT/l2W3i7aXHYkU6S/aJYSwlpUqzaLj88qETHf/7ClaPXbc1HrvrOaurJZ5wp8qpSS gGlJBee7FrJDeMRqDMDGUXkKc0AJTP5rmstQi7GZHD70ouP0/TX1ItUcUMlOjtPewDxC Nlt4h8jfNrUg5yPGioOLlQW0+W0KxxXQxXszvHKDeoPDROjFtpZFNKVLQsCubYaLeh5d N3DoPmWVA363mOanJtoJZ+9ggo6OdNOeCtHPkeydjDyKnP9lcaCWpFyopNanDk7TDhnB o/Ut5k0464HKJF46gP0zgXcGLxBx/owFqmA2fXsTdQo6jsYrY2gaTx6HcIDoujZMvIAM 7bJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ViG+IpttJDDpdFsvHFT0lDjP5PpCTN0z4enIuahFCwg=; b=ld6B95hl6+7JMDHabqkGeHq1spCmXTdxAA30TizN5acYTSKrhXjVGPlIOOH7Qswv0S 9bdFYzVtxbNQ/c58bxxNVn0YmbUSjbeJ3g0C2Err+w7j8nl5/4SOUwzoPzg/as8xOj1k 4IpIeEdKpxV0kr4P2gv2R0sNrWfZdLSkLiJCzjYZiO3mA+PGdCCticmYNeKJfrr8KNFV +CH/xOpkjLurr6ELxkwimHxrlE2jIVoD5u2pY36WudBGUuZwyHnkbDZOVIyYoKGZmKtt /tkLfW9lGhy3qhNQedIpNieugR2HLRq7d9DZjbSCwymFN/p5ExWjlv+8BkUHXXVCXU6F Ou3Q== X-Gm-Message-State: AD7BkJJelWwymQiQbRVYN6UenvcQl93MKBLHeKnLuiauR3k4189sWvP7ztHEpR9sfNqDXPqr X-Received: by 10.194.188.20 with SMTP id fw20mr5618310wjc.80.1459520197960; Fri, 01 Apr 2016 07:16:37 -0700 (PDT) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id uq10sm14231795wjc.38.2016.04.01.07.16.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 01 Apr 2016 07:16:37 -0700 (PDT) From: Neil Armstrong To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, p.zabel@pengutronix.de Subject: [PATCH 1/2] reset: Add Oxford Semiconductor Reset Controller driver Date: Fri, 1 Apr 2016 16:16:13 +0200 Message-Id: <1459520174-12897-2-git-send-email-narmstrong@baylibre.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1459520174-12897-1-git-send-email-narmstrong@baylibre.com> References: <1459520174-12897-1-git-send-email-narmstrong@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160401_071659_775586_B0CE9CE4 X-CRM114-Status: GOOD ( 19.60 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ma Haijun , Neil Armstrong MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add System reset controller driver for Oxford Semiconductor OXNAS SoC Family. CC: Ma Haijun Signed-off-by: Neil Armstrong --- drivers/reset/Kconfig | 3 + drivers/reset/Makefile | 1 + drivers/reset/reset-oxnas.c | 136 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 140 insertions(+) create mode 100644 drivers/reset/reset-oxnas.c diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig index df37212..0b2733d 100644 --- a/drivers/reset/Kconfig +++ b/drivers/reset/Kconfig @@ -12,5 +12,8 @@ menuconfig RESET_CONTROLLER If unsure, say no. +config RESET_OXNAS + bool + source "drivers/reset/sti/Kconfig" source "drivers/reset/hisilicon/Kconfig" diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile index a1fc8ed..f173fc3 100644 --- a/drivers/reset/Makefile +++ b/drivers/reset/Makefile @@ -8,3 +8,4 @@ obj-$(CONFIG_ARCH_STI) += sti/ obj-$(CONFIG_ARCH_HISI) += hisilicon/ obj-$(CONFIG_ARCH_ZYNQ) += reset-zynq.o obj-$(CONFIG_ATH79) += reset-ath79.o +obj-$(CONFIG_RESET_OXNAS) += reset-oxnas.o diff --git a/drivers/reset/reset-oxnas.c b/drivers/reset/reset-oxnas.c new file mode 100644 index 0000000..c60fb2d --- /dev/null +++ b/drivers/reset/reset-oxnas.c @@ -0,0 +1,136 @@ +/* + * drivers/reset/reset-oxnas.c + * + * Copyright (C) 2016 Neil Armstrong + * Copyright (C) 2014 Ma Haijun + * Copyright (C) 2009 Oxford Semiconductor Ltd + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Regmap offsets */ +#define RST_SET_REGOFFSET 0x34 +#define RST_CLR_REGOFFSET 0x38 + +struct oxnas_reset { + struct regmap *regmap; + struct reset_controller_dev rcdev; +}; + +static int oxnas_reset_reset(struct reset_controller_dev *rcdev, + unsigned long id) +{ + struct oxnas_reset *data = + container_of(rcdev, struct oxnas_reset, rcdev); + + regmap_write(data->regmap, RST_SET_REGOFFSET, BIT(id)); + msleep(50); + regmap_write(data->regmap, RST_CLR_REGOFFSET, BIT(id)); + + return 0; +} + +static int oxnas_reset_assert(struct reset_controller_dev *rcdev, + unsigned long id) +{ + struct oxnas_reset *data = + container_of(rcdev, struct oxnas_reset, rcdev); + + regmap_write(data->regmap, RST_SET_REGOFFSET, BIT(id)); + + return 0; +} + +static int oxnas_reset_deassert(struct reset_controller_dev *rcdev, + unsigned long id) +{ + struct oxnas_reset *data = + container_of(rcdev, struct oxnas_reset, rcdev); + + regmap_write(data->regmap, RST_CLR_REGOFFSET, BIT(id)); + + return 0; +} + +static const struct reset_control_ops oxnas_reset_ops = { + .reset = oxnas_reset_reset, + .assert = oxnas_reset_assert, + .deassert = oxnas_reset_deassert, +}; + +static const struct of_device_id oxnas_reset_dt_ids[] = { + { .compatible = "oxsemi,ox810se-reset", }, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, oxnas_reset_dt_ids); + +static int oxnas_reset_probe(struct platform_device *pdev) +{ + struct oxnas_reset *data; + struct device *parent; + + parent = pdev->dev.parent; + if (!parent) { + dev_err(&pdev->dev, "no parent\n"); + return -ENODEV; + } + + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + data->regmap = syscon_node_to_regmap(parent->of_node); + if (IS_ERR(data->regmap)) { + dev_err(&pdev->dev, "failed to get parent regmap\n"); + return PTR_ERR(data->regmap); + } + + platform_set_drvdata(pdev, data); + + data->rcdev.owner = THIS_MODULE; + data->rcdev.nr_resets = 32; + data->rcdev.ops = &oxnas_reset_ops; + data->rcdev.of_node = pdev->dev.of_node; + + return reset_controller_register(&data->rcdev); +} + +static int oxnas_reset_remove(struct platform_device *pdev) +{ + struct oxnas_reset *data = platform_get_drvdata(pdev); + + reset_controller_unregister(&data->rcdev); + + return 0; +} + +static struct platform_driver oxnas_reset_driver = { + .probe = oxnas_reset_probe, + .remove = oxnas_reset_remove, + .driver = { + .name = "oxnas-reset", + .of_match_table = oxnas_reset_dt_ids, + }, +}; + +module_platform_driver(oxnas_reset_driver);