Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3305982imm; Tue, 4 Sep 2018 20:23:27 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaEoz/Ike0wbX7GidZ/Z60VCbxu9vWOw7PLvpiMs3oIR9q6r6HuP1pxGntRmWFdkZEthgcR X-Received: by 2002:a65:6104:: with SMTP id z4-v6mr32825206pgu.361.1536117807833; Tue, 04 Sep 2018 20:23:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536117807; cv=none; d=google.com; s=arc-20160816; b=PMwXcU+Dg0AOMtnp73ZzuwWvThiGbJJTt/CH4LlW7OWulIohDs+FrmFgu7irrqb8oU dHIkRw1DAuq6jbZ6Jtwu+YAqebbfc+v8uewYntwXIZAsNV4si5JhgP5K3trlBGO1aYMj /gjIFqH1zuFY6rkb/ygTzx+fTNYpdeqU4nOxhQGgvXKh3dC0yjiZIG1oSF0uHgYkhXUY SWyvgMUBd9Rhfq0w9KL9T2cbTF2xery8qf5pzZ+hGs0Tkehp3Vstdg7Lg6OXEJjGRITz 3X7Qb0o7qB4u4vwsl+07AQKDkQ3vj7cgtacjQHe75B7ntWQm13xr8yWYMtpV3rnfhPhe o2kQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=sfOmFLdl1Qpq8RmUUZlkhkxl2m9MHPREuv9igXgXFH4=; b=sNqXqBgB1WFJQqIAAPkxI42/l7u/l2QYX9IAYMWCO3YrpPOfSptfjQrfU03GKKnhAb 7KCG4ynmlRtueYGdo1fBc7IR/hOCbamVtXVj1SKtRHX4wnJdjfTe4zSR0rsT0VAbqOHQ 98SaDfBXD0NpMiCE85ekX6AnOul5+E0pps/Aoaye6G03H99MJ8jwBY+wPJDySyyFHio6 5BuOjvsYnU9zbIt3Z4OoTjnjhfKajiNPxC8fncKz/F33mCD8v4L02PlMOQJm6W9L2Iyn eGlNgoYQQGGxcUo2bIMJE9RIu09Sf950HLRJWToZLqvlXLk10hznZbBmb+E8iPv1XWQc 1fkw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f24-v6si743457pgh.287.2018.09.04.20.23.12; Tue, 04 Sep 2018 20:23:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727240AbeIEHuI convert rfc822-to-8bit (ORCPT + 99 others); Wed, 5 Sep 2018 03:50:08 -0400 Received: from mail-oi0-f66.google.com ([209.85.218.66]:43738 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725939AbeIEHuI (ORCPT ); Wed, 5 Sep 2018 03:50:08 -0400 Received: by mail-oi0-f66.google.com with SMTP id b15-v6so10898342oib.10; Tue, 04 Sep 2018 20:22:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=9fgVoKoxTbTBiACKz0/xMs2QuyKTvwQBMxGnvdzug7U=; b=lSEuxfL0QZlvwcKKmeNJLJdEFNrs4EC1nF4oSWnuOr8pXC08uYJzkWJ6DP33xw5K1A Tk/iaTT2bzFsJtl459cBvDiv4NlzxIVC4qZfwjGSnfm6uREofyRYyx231vJf2ntuvViY vjEFNJ4w5uIr3RNHu74cPVefmQBtvwP58IxONovGuKDMUMYHqsL12cAau3YB9T9YEqWx vLfSMfMyuDk/uengULgGsSoFHHI0siz0CqRYZ24wc//IZyK5S6n7++cfixKD6OrAfDw/ i4bVQknqsgfki4VeHD0OLXqwJXJII+/haEnKLgYnXiOdiBQ4wJAsIYAqlD1B+mxYfUCy n9jw== X-Gm-Message-State: APzg51CcmPLCwu5HDkEm152RohfukG0FKXxaYRMh7ragohvnh8+X8CsY f3VFQoyVWCW1pRoapRx6JH9GMdi0COM= X-Received: by 2002:aca:5e42:: with SMTP id s63-v6mr26011332oib.134.1536117725294; Tue, 04 Sep 2018 20:22:05 -0700 (PDT) Received: from mail-oi0-f50.google.com (mail-oi0-f50.google.com. [209.85.218.50]) by smtp.gmail.com with ESMTPSA id b125-v6sm1718352oia.38.2018.09.04.20.22.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Sep 2018 20:22:04 -0700 (PDT) Received: by mail-oi0-f50.google.com with SMTP id k81-v6so10926416oib.9; Tue, 04 Sep 2018 20:22:04 -0700 (PDT) X-Received: by 2002:aca:1119:: with SMTP id 25-v6mr26404716oir.297.1536117724506; Tue, 04 Sep 2018 20:22:04 -0700 (PDT) MIME-Version: 1.0 References: <20180831035219.31619-1-ran.wang_1@nxp.com> <20180831035219.31619-3-ran.wang_1@nxp.com> In-Reply-To: From: Li Yang Date: Tue, 4 Sep 2018 22:21:53 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 3/3] soc: fsl: add RCPM driver To: dongsheng.wang@hxt-semitech.com Cc: Ran Wang , Rob Herring , Mark Rutland , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , linuxppc-dev , lkml , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 4, 2018 at 9:58 PM Wang, Dongsheng wrote: > > Please change your comments style. Although this doesn't get into the Linux kernel coding style documentation yet, Linus seems changed his mind to prefer // than /* */ comment style now. https://lkml.org/lkml/2017/11/25/133 So the // style should be acceptable for now. > > On 2018/8/31 11:56, Ran Wang wrote: > > The NXP's QorIQ Processors based on ARM Core have RCPM module (Run > > Control and Power Management), which performs all device-level > > tasks associated with power management such as wakeup source control. > > > > This driver depends on FSL platform PM driver framework which help to > > isolate user and PM service provider (such as RCPM driver). > > > > Signed-off-by: Chenhui Zhao > > Signed-off-by: Ying Zhang > > Signed-off-by: Ran Wang > > --- > > drivers/soc/fsl/Kconfig | 6 ++ > > drivers/soc/fsl/Makefile | 1 + > > drivers/soc/fsl/ls-rcpm.c | 153 +++++++++++++++++++++++++++++++++++++++++++++ > > 3 files changed, 160 insertions(+), 0 deletions(-) > > create mode 100644 drivers/soc/fsl/ls-rcpm.c > > > > diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig > > index 6517412..882330d 100644 > > --- a/drivers/soc/fsl/Kconfig > > +++ b/drivers/soc/fsl/Kconfig > > @@ -30,3 +30,9 @@ config FSL_PLAT_PM > > have to know the implement details of wakeup function it require. > > Besides, it is also easy for service side to upgrade its logic when > > design changed and remain user side unchanged. > > + > > +config LS_RCPM > > + bool "Freescale RCPM support" > > + depends on (FSL_PLAT_PM) > > + help > > + This feature is to enable specified wakeup source for system sleep. > > diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile > > index 8f9db23..43ff71a 100644 > > --- a/drivers/soc/fsl/Makefile > > +++ b/drivers/soc/fsl/Makefile > > @@ -7,3 +7,4 @@ obj-$(CONFIG_QUICC_ENGINE) += qe/ > > obj-$(CONFIG_CPM) += qe/ > > obj-$(CONFIG_FSL_GUTS) += guts.o > > obj-$(CONFIG_FSL_PLAT_PM) += plat_pm.o > > +obj-$(CONFIG_LS_RCPM) += ls-rcpm.o Probably use "_" instead of "-" for alignment. > > diff --git a/drivers/soc/fsl/ls-rcpm.c b/drivers/soc/fsl/ls-rcpm.c > > new file mode 100644 > > index 0000000..b0feb88 > > --- /dev/null > > +++ b/drivers/soc/fsl/ls-rcpm.c > > @@ -0,0 +1,153 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +// > > +// plat_pm.c - Freescale Layerscape RCPM driver The file name here is not the same as the real file name. > > +// > > +// Copyright 2018 NXP > > +// > > +// Author: Ran Wang , Where do you need the comma in the end? > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#define MAX_COMPATIBLE_NUM 10 > > + > > +struct rcpm_t { > > + struct device *dev; > > + void __iomem *ippdexpcr_addr; > > + bool big_endian; /* Big/Little endian of RCPM module */ > > +}; > > + > > +// rcpm_handle - Configure RCPM reg according to wake up source request > > +// @user_dev: pointer to user's device struct > > +// @flag: to enable(true) or disable(false) wakeup source > > +// @handle_priv: pointer to struct rcpm_t instance > > +// > > +// Return 0 on success other negative errno Although Linus preferred this // comment style. I'm not sure if this will be handled correctly by the kernel-doc compiler. https://www.kernel.org/doc/html/v4.18/doc-guide/kernel-doc.html > > +static int rcpm_handle(struct device *user_dev, bool flag, void *handle_priv) > > +{ > > + struct rcpm_t *rcpm; > > + bool big_endian; > > + const char *dev_compatible_array[MAX_COMPATIBLE_NUM]; > > + void __iomem *ippdexpcr_addr; > > + u32 ippdexpcr; > > + u32 set_bit; > > + int ret, num, i; > > + > > + rcpm = handle_priv; > > + big_endian = rcpm->big_endian; > > + ippdexpcr_addr = rcpm->ippdexpcr_addr; > > + > > + num = device_property_read_string_array(user_dev, "compatible", > > + dev_compatible_array, MAX_COMPATIBLE_NUM); > > + if (num < 0) > > + return num; > > + > > + for (i = 0; i < num; i++) { > > + if (!device_property_present(rcpm->dev, > > + dev_compatible_array[i])) > > + continue; > > + else { > Remove this else. > > + ret = device_property_read_u32(rcpm->dev, > > + dev_compatible_array[i], &set_bit); > > + if (ret) > > + return ret; > > + > > + if (!device_property_present(rcpm->dev, > > + dev_compatible_array[i])) > This has been checked. Continue ? or return ENODEV? > > + return -ENODEV; > > + else { > Remove this else. > > + ret = device_property_read_u32(rcpm->dev, > > + dev_compatible_array[i], &set_bit); > > + if (ret) > > + return ret; > > + > > + if (big_endian) > > + ippdexpcr = ioread32be(ippdexpcr_addr); > > + else > > + ippdexpcr = ioread32(ippdexpcr_addr); > > + > > + if (flag) > > + ippdexpcr |= set_bit; > > + else > > + ippdexpcr &= ~set_bit; > > + > > + if (big_endian) { > > + iowrite32be(ippdexpcr, ippdexpcr_addr); > > + ippdexpcr = ioread32be(ippdexpcr_addr); > > + } else > if (x) { > .... > .... > } else { > > } > > + iowrite32(ippdexpcr, ippdexpcr_addr); > > + > > + return 0; > > + } > > + } > > + } > > + > > + return -ENODEV; > > +} > > + > > +static int ls_rcpm_probe(struct platform_device *pdev) > > +{ > > + struct resource *r; > > + struct rcpm_t *rcpm; > > + > > + r = platform_get_resource(pdev, IORESOURCE_MEM, 0); > > + if (!r) > > + return -ENODEV; > > + > > + rcpm = kmalloc(sizeof(*rcpm), GFP_KERNEL); > kzalloc is better. > > + if (!rcpm) > > + return -ENOMEM; > > + > > + rcpm->big_endian = device_property_read_bool(&pdev->dev, "big-endian"); > > + > > + rcpm->ippdexpcr_addr = devm_ioremap_resource(&pdev->dev, r); > > + if (IS_ERR(rcpm->ippdexpcr_addr)) > > + return PTR_ERR(rcpm->ippdexpcr_addr); > > + > > + rcpm->dev = &pdev->dev; > > + platform_set_drvdata(pdev, rcpm); > > + > > + return register_fsl_platform_wakeup_source(rcpm_handle, rcpm); > > +} > > + > > +static int ls_rcpm_remove(struct platform_device *pdev) > > +{ > > + struct rcpm_t *rcpm; > Not need a table. > > Cheers, > -Dongsheng > > > + > > + rcpm = platform_get_drvdata(pdev); > > + deregister_fsl_platform_wakeup_source(rcpm); > > + kfree(rcpm); > > + > > + return 0; > > +} > > + > > +static const struct of_device_id ls_rcpm_of_match[] = { > > + { .compatible = "fsl,qoriq-rcpm-2.1", }, > > + {} > > +}; > > +MODULE_DEVICE_TABLE(of, ls_rcpm_of_match); > > + > > +static struct platform_driver ls_rcpm_driver = { > > + .driver = { > > + .name = "ls-rcpm", > > + .of_match_table = ls_rcpm_of_match, > > + }, > > + .probe = ls_rcpm_probe, > > + .remove = ls_rcpm_remove, > > +}; > > + > > +static int __init ls_rcpm_init(void) > > +{ > > + return platform_driver_register(&ls_rcpm_driver); > > +} > > +subsys_initcall(ls_rcpm_init); > > + > > +static void __exit ls_rcpm_exit(void) > > +{ > > + platform_driver_unregister(&ls_rcpm_driver); > > +} > > +module_exit(ls_rcpm_exit); > >