Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7189046imu; Tue, 22 Jan 2019 01:45:22 -0800 (PST) X-Google-Smtp-Source: ALg8bN4o33VHFqtMmLzFn04dCrhQTh66lZ7XlcoHJqB1FZtReQa4XF+ClkA3Qzd7Njq/I4n7xnnG X-Received: by 2002:a65:6392:: with SMTP id h18mr31675529pgv.107.1548150322697; Tue, 22 Jan 2019 01:45:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548150322; cv=none; d=google.com; s=arc-20160816; b=oxvQFtLXHft+P/mFcqisxcai2kHYj7GbfZfNHiNB/qtLAwSBS0DYh+J6Dn9B6c6PVv wlcTubsJ3CoJHP9IUEBzzFRJaMKbRLWkATWVhkhfVa3PP+LfDcJCVahorGWVu6Kgk+Sd my+P776XeJ6zQkyzfyjBPQ66luZwuEyBfLHhcdhcKBYiWMQmWzMiRC6PF3iHzCmnIitf iaVr7ssHDDXZkHzPzNNALk/t+gLfCWSmFjPeyUyRxnV2k2qeXeCruCFqqPd4J31Ww9Rb gwyghTtegXNHwLltK2hqjW2+UObH+GzhNqFOXMq94E8H4tGNVLsWX2X8bFx+kLv9vlGh RXIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=XQMhsXdYeQEoqa9kUduf2WYgIBHM1c2g/MMxJfDQVWU=; b=iVeI+jeKI7X2RRg3OU0R27kh4N1CU8YjWDPFMorbeB1bD4EFpOCNvrNtRYYtCvVN4I shtebDSkwDQ45mMEWZmzG4Q5tbR5pzZ64/hjVcsMa6dIKRGqDImJ5UoO/nMXwIoq6tV4 HkiR2ExaAJ3pVtxwJpQR0FL89YEFuqYgbj8crGwRF3BjoRhFvFBaeWuVuPlAcORQ2CHH aoUVoppKQfQNYvCrYBGBkyIIGuwzenOXgr85BF2FWcpQdXeeP2jsSIgpIfwhVEq9xAKe 7HDDCeTCj/2UXMJgX8oZQQGOnGUkcFC71h33S1jB49K6hOp0GcQQvO73iAVrNKuhXtEN W2Zw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v21si14768389plo.417.2019.01.22.01.45.07; Tue, 22 Jan 2019 01:45:22 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727984AbfAVJnQ (ORCPT + 99 others); Tue, 22 Jan 2019 04:43:16 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:33769 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726872AbfAVJnP (ORCPT ); Tue, 22 Jan 2019 04:43:15 -0500 Received: by mail-lj1-f195.google.com with SMTP id v1-v6so20031184ljd.0; Tue, 22 Jan 2019 01:43:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=XQMhsXdYeQEoqa9kUduf2WYgIBHM1c2g/MMxJfDQVWU=; b=Q5ADtDNQ0XT3DLOHjId7CaLMBkiiVdoyylAE06cDXu+fBz93qxi/TIqQfcWnA74F13 67pg6vYCyEFBu/zMTzqiRLSlNkSXlxqo5cb7ymqxXR39fyyPzEwWl8X0/qz2jmXIRnX+ scBmNVGwNmvKcgoKn8vQE+2qD17gSSoOokRg1U5EAczzFFkDRT+Cf35S5vfR1dGwgRNV oTQIBiaDKetrzLVlbDlQkmcAZrNCohYnyASxZTPaBHQMnkho+SUv0W0Sy2jD0dC5rP9D I2NkqA4MU+hpugxn+KTur1cphFZC9TSHA9T9fcmvpMXZYe3XeyogmuH8KPmy2TUmiIj9 Kn6Q== X-Gm-Message-State: AJcUukcoNzMj3EoE8FJB+RTKxhrnum/1c1ybXmROov+8ZpOCfquewm4i VgzS9HreNw6BvfovUDj2kzo= X-Received: by 2002:a2e:851a:: with SMTP id j26-v6mr20059474lji.163.1548150191955; Tue, 22 Jan 2019 01:43:11 -0800 (PST) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id y131sm2681769lfc.43.2019.01.22.01.43.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 22 Jan 2019 01:43:11 -0800 (PST) Date: Tue, 22 Jan 2019 11:42:58 +0200 From: Matti Vaittinen To: matti.vaittinen@fi.rohmeurope.com, mazziesaccount@gmail.com Cc: lee.jones@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, lgirdwood@gmail.com, broonie@kernel.org, gregkh@linuxfoundation.org, rafael@kernel.org, mturquette@baylibre.com, sboyd@kernel.org, linus.walleij@linaro.org, bgolaszewski@baylibre.com, sre@kernel.org, a.zummo@towertech.it, alexandre.belloni@bootlin.com, wim@linux-watchdog.org, linux@roeck-us.net, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-gpio@vger.kernel.org, linux-pm@vger.kernel.org, linux-rtc@vger.kernel.org, linux-watchdog@vger.kernel.org, mikko.mutanen@fi.rohmeurope.com, heikki.haikola@fi.rohmeurope.com Subject: [RFC PATCH v1 02/13] mfd: bd718x7.h split to ROHM common and bd718x7 specific parts Message-ID: <572e0507f1cf24365f50a6fb81929f0141f5c7d6.1548149337.git.matti.vaittinen@fi.rohmeurope.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Split the bd718x7.h to ROHM common and bd718x7 specific parts so that we do not need to add same things in every new ROHM PMIC header. Please note that this change requires changes also in bd718x7 sub-device drivers for regulators and clk. Signed-off-by: Matti Vaittinen --- drivers/mfd/rohm-bd718x7.c | 23 ++++++++++++----------- include/linux/mfd/rohm-bd718x7.h | 22 ++++++++-------------- include/linux/mfd/rohm-generic.h | 20 ++++++++++++++++++++ 3 files changed, 40 insertions(+), 25 deletions(-) create mode 100644 include/linux/mfd/rohm-generic.h diff --git a/drivers/mfd/rohm-bd718x7.c b/drivers/mfd/rohm-bd718x7.c index a29d529a96f4..7beb444a57cb 100644 --- a/drivers/mfd/rohm-bd718x7.c +++ b/drivers/mfd/rohm-bd718x7.c @@ -98,18 +98,19 @@ static int bd718xx_i2c_probe(struct i2c_client *i2c, return -ENOMEM; bd718xx->chip_irq = i2c->irq; - bd718xx->chip_type = (unsigned int)(uintptr_t) + bd718xx->chip.chip_type = (unsigned int)(uintptr_t) of_device_get_match_data(&i2c->dev); - bd718xx->dev = &i2c->dev; + bd718xx->chip.dev = &i2c->dev; dev_set_drvdata(&i2c->dev, bd718xx); - bd718xx->regmap = devm_regmap_init_i2c(i2c, &bd718xx_regmap_config); - if (IS_ERR(bd718xx->regmap)) { + bd718xx->chip.regmap = devm_regmap_init_i2c(i2c, + &bd718xx_regmap_config); + if (IS_ERR(bd718xx->chip.regmap)) { dev_err(&i2c->dev, "regmap initialization failed\n"); - return PTR_ERR(bd718xx->regmap); + return PTR_ERR(bd718xx->chip.regmap); } - ret = devm_regmap_add_irq_chip(&i2c->dev, bd718xx->regmap, + ret = devm_regmap_add_irq_chip(&i2c->dev, bd718xx->chip.regmap, bd718xx->chip_irq, IRQF_ONESHOT, 0, &bd718xx_irq_chip, &bd718xx->irq_data); if (ret) { @@ -118,7 +119,7 @@ static int bd718xx_i2c_probe(struct i2c_client *i2c, } /* Configure short press to 10 milliseconds */ - ret = regmap_update_bits(bd718xx->regmap, + ret = regmap_update_bits(bd718xx->chip.regmap, BD718XX_REG_PWRONCONFIG0, BD718XX_PWRBTN_PRESS_DURATION_MASK, BD718XX_PWRBTN_SHORT_PRESS_10MS); @@ -129,7 +130,7 @@ static int bd718xx_i2c_probe(struct i2c_client *i2c, } /* Configure long press to 10 seconds */ - ret = regmap_update_bits(bd718xx->regmap, + ret = regmap_update_bits(bd718xx->chip.regmap, BD718XX_REG_PWRONCONFIG1, BD718XX_PWRBTN_PRESS_DURATION_MASK, BD718XX_PWRBTN_LONG_PRESS_10S); @@ -149,7 +150,7 @@ static int bd718xx_i2c_probe(struct i2c_client *i2c, button.irq = ret; - ret = devm_mfd_add_devices(bd718xx->dev, PLATFORM_DEVID_AUTO, + ret = devm_mfd_add_devices(bd718xx->chip.dev, PLATFORM_DEVID_AUTO, bd718xx_mfd_cells, ARRAY_SIZE(bd718xx_mfd_cells), NULL, 0, regmap_irq_get_domain(bd718xx->irq_data)); @@ -162,11 +163,11 @@ static int bd718xx_i2c_probe(struct i2c_client *i2c, static const struct of_device_id bd718xx_of_match[] = { { .compatible = "rohm,bd71837", - .data = (void *)BD718XX_TYPE_BD71837, + .data = (void *)ROHM_CHIP_TYPE_BD71837, }, { .compatible = "rohm,bd71847", - .data = (void *)BD718XX_TYPE_BD71847, + .data = (void *)ROHM_CHIP_TYPE_BD71847, }, { } }; diff --git a/include/linux/mfd/rohm-bd718x7.h b/include/linux/mfd/rohm-bd718x7.h index fd194bfc836f..7f2dbde402a1 100644 --- a/include/linux/mfd/rohm-bd718x7.h +++ b/include/linux/mfd/rohm-bd718x7.h @@ -4,14 +4,9 @@ #ifndef __LINUX_MFD_BD718XX_H__ #define __LINUX_MFD_BD718XX_H__ +#include #include -enum { - BD718XX_TYPE_BD71837 = 0, - BD718XX_TYPE_BD71847, - BD718XX_TYPE_AMOUNT -}; - enum { BD718XX_BUCK1 = 0, BD718XX_BUCK2, @@ -321,18 +316,17 @@ enum { BD718XX_PWRBTN_LONG_PRESS_15S }; -struct bd718xx_clk; - struct bd718xx { - unsigned int chip_type; - struct device *dev; - struct regmap *regmap; - unsigned long int id; + /* + * Please keep this as the first member here as some + * drivers (clk) supporting more than one chip may only know this + * generic struct 'struct rohm_regmap_dev' and assume it is + * the first chunk of parent device's private data. + */ + struct rohm_regmap_dev chip; int chip_irq; struct regmap_irq_chip_data *irq_data; - - struct bd718xx_clk *clk; }; #endif /* __LINUX_MFD_BD718XX_H__ */ diff --git a/include/linux/mfd/rohm-generic.h b/include/linux/mfd/rohm-generic.h new file mode 100644 index 000000000000..bff15ac26f2c --- /dev/null +++ b/include/linux/mfd/rohm-generic.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* Copyright (C) 2018 ROHM Semiconductors */ + +#ifndef __LINUX_MFD_ROHM_H__ +#define __LINUX_MFD_ROHM_H__ + +enum { + ROHM_CHIP_TYPE_BD71837 = 0, + ROHM_CHIP_TYPE_BD71847, + ROHM_CHIP_TYPE_BD70528, + ROHM_CHIP_TYPE_AMOUNT +}; + +struct rohm_regmap_dev { + unsigned int chip_type; + struct device *dev; + struct regmap *regmap; +}; + +#endif -- 2.14.3 -- Matti Vaittinen ROHM Semiconductors ~~~ "I don't think so," said Rene Descartes. Just then, he vanished ~~~