From patchwork Tue Feb 4 12:19:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Porter X-Patchwork-Id: 3575731 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B5225C02DC for ; Tue, 4 Feb 2014 12:21:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C580520163 for ; Tue, 4 Feb 2014 12:21:54 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A522B200E8 for ; Tue, 4 Feb 2014 12:21:53 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WAezK-00030t-J2; Tue, 04 Feb 2014 12:20:27 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WAez7-0006LH-Gp; Tue, 04 Feb 2014 12:20:13 +0000 Received: from mail-ig0-f174.google.com ([209.85.213.174]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WAeye-0006Fn-9e for linux-arm-kernel@lists.infradead.org; Tue, 04 Feb 2014 12:19:49 +0000 Received: by mail-ig0-f174.google.com with SMTP id hl1so7413419igb.1 for ; Tue, 04 Feb 2014 04:19:23 -0800 (PST) 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=i4zFbF9KcrjGSis07Syt63aAhMo9gqPcSsEOOdFk/yc=; b=HByCO6bsgK4y1p3THU58W+YP5luoTObS4lgaEoTAZJV6YDTr+ZHDN8ttb8N48ww0Uh y16oSFZgkBhPsIn7s7yLsAboQ4WtOFRTxu7lpFpt6eIOfEysxLLFOMLq+i5WvOWflfbA kKbnpwDrNuMGQmXkvC95sVJNl3sUQUk8ZrZgKVzBj8qOndm7w4/1OHLjKiu+0mS3MjJM Y4Eq5P/Q1wpc5oxAO5GLOPtZxY1nqFYBr9YvVuWk8EQ6aTpnGGowcSeuCf+hvO5Q9RO5 uTp4AFqXlKHWp0TAs4QOIw37fmdzE5KM/B6zoQD/8MVIo72EanDldDw7tTAHOH+BZ+6j xyQQ== X-Gm-Message-State: ALoCoQkO/aOEpDVajf4eLOqNDfWGlMU/x+Qo0mFqQw51RfFcgozRA7JSOGnNkkThgzJ3RQZSRmRq X-Received: by 10.50.50.170 with SMTP id d10mr16990213igo.28.1391516363243; Tue, 04 Feb 2014 04:19:23 -0800 (PST) Received: from beef.ohporter.com (cpe-98-27-254-98.neo.res.rr.com. [98.27.254.98]) by mx.google.com with ESMTPSA id ni8sm39720180igb.7.2014.02.04.04.19.21 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 04 Feb 2014 04:19:22 -0800 (PST) From: Matt Porter To: Wolfram Sang , Tim Kryger , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , Samuel Ortiz , Lee Jones , Liam Girdwood , Mark Brown , Christian Daudt Subject: [PATCH 3/6] mfd: add bcm59056 pmu driver Date: Tue, 4 Feb 2014 07:19:09 -0500 Message-Id: <1391516352-32359-4-git-send-email-mporter@linaro.org> X-Mailer: git-send-email 1.8.4 In-Reply-To: <1391516352-32359-1-git-send-email-mporter@linaro.org> References: <1391516352-32359-1-git-send-email-mporter@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140204_071944_471990_A0CA8100 X-CRM114-Status: GOOD ( 21.18 ) X-Spam-Score: -2.6 (--) Cc: Devicetree List , Linux I2C List , Linux ARM Kernel List , Linux Kernel Mailing List X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, 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 a driver for the BCM59056 PMU multi-function device. The driver initially supports regmap initialization and instantiation of the voltage regulator device function of the PMU. Signed-off-by: Matt Porter Reviewed-by: Tim Kryger Reviewed-by: Markus Mayer --- drivers/mfd/Kconfig | 8 +++ drivers/mfd/Makefile | 1 + drivers/mfd/bcm59056.c | 119 +++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/bcm59056.h | 35 +++++++++++++ 4 files changed, 163 insertions(+) create mode 100644 drivers/mfd/bcm59056.c create mode 100644 include/linux/mfd/bcm59056.h diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 49bb445..36e96c2 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -59,6 +59,14 @@ config MFD_AAT2870_CORE additional drivers must be enabled in order to use the functionality of the device. +config MFD_BCM59056 + bool "Broadcom BCM59056 PMU" + select MFD_CORE + select REGMAP_I2C + depends on I2C=y + help + Support for the BCM59056 PMU from Broadcom + config MFD_CROS_EC tristate "ChromeOS Embedded Controller" select MFD_CORE diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 5aea5ef..8d7e110 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -8,6 +8,7 @@ obj-$(CONFIG_MFD_88PM800) += 88pm800.o 88pm80x.o obj-$(CONFIG_MFD_88PM805) += 88pm805.o 88pm80x.o obj-$(CONFIG_MFD_SM501) += sm501.o obj-$(CONFIG_MFD_ASIC3) += asic3.o tmio_core.o +obj-$(CONFIG_MFD_BCM59056) += bcm59056.o obj-$(CONFIG_MFD_CROS_EC) += cros_ec.o obj-$(CONFIG_MFD_CROS_EC_I2C) += cros_ec_i2c.o obj-$(CONFIG_MFD_CROS_EC_SPI) += cros_ec_spi.o diff --git a/drivers/mfd/bcm59056.c b/drivers/mfd/bcm59056.c new file mode 100644 index 0000000..f193bfb --- /dev/null +++ b/drivers/mfd/bcm59056.c @@ -0,0 +1,119 @@ +/* + * Broadcom BCM59056 PMU + * + * Copyright 2014 Linaro Limited + * Author: Matt Porter + * + * 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 +#include +#include +#include +#include + +static struct mfd_cell bcm59056s[] = { + { + .name = "bcm59056-pmu", + }, +}; + +static const struct regmap_config bcm59056_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + .max_register = BCM59056_MAX_REGISTER - 1, + .cache_type = REGCACHE_RBTREE, +}; + +static int bcm59056_i2c_probe(struct i2c_client *i2c, + const struct i2c_device_id *id) +{ + struct bcm59056 *bcm59056; + int chip_id = id->driver_data; + int ret = 0; + + bcm59056 = devm_kzalloc(&i2c->dev, sizeof(*bcm59056), GFP_KERNEL); + if (!bcm59056) + return -ENOMEM; + + i2c_set_clientdata(i2c, bcm59056); + bcm59056->dev = &i2c->dev; + bcm59056->i2c_client = i2c; + bcm59056->id = chip_id; + + bcm59056->regmap = devm_regmap_init_i2c(i2c, &bcm59056_regmap_config); + if (IS_ERR(bcm59056->regmap)) { + ret = PTR_ERR(bcm59056->regmap); + dev_err(&i2c->dev, "regmap initialization failed: %d\n", ret); + return ret; + } + + ret = mfd_add_devices(bcm59056->dev, -1, + bcm59056s, ARRAY_SIZE(bcm59056s), + NULL, 0, NULL); + if (ret < 0) + dev_err(&i2c->dev, "mfd_add_devices failed: %d\n", ret); + + return ret; +} + +static int bcm59056_i2c_remove(struct i2c_client *i2c) +{ + struct bcm59056 *bcm59056 = i2c_get_clientdata(i2c); + + mfd_remove_devices(bcm59056->dev); + + return 0; +} + +static const struct of_device_id bcm59056_of_match[] = { + { .compatible = "brcm,bcm59056", .data = (void *)BCM59056 }, + { } +}; + +static const struct i2c_device_id bcm59056_i2c_id[] = { + { "bcm59056", BCM59056 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, bcm59056_i2c_id); + +static struct i2c_driver bcm59056_i2c_driver = { + .driver = { + .name = "bcm59056", + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(bcm59056_of_match), + }, + .probe = bcm59056_i2c_probe, + .remove = bcm59056_i2c_remove, + .id_table = bcm59056_i2c_id, +}; + +static int __init bcm59056_init(void) +{ + return i2c_add_driver(&bcm59056_i2c_driver); +} +subsys_initcall(bcm59056_init); + +static void __exit bcm59056_exit(void) +{ + i2c_del_driver(&bcm59056_i2c_driver); +} +module_exit(bcm59056_exit); + +MODULE_AUTHOR("Matt Porter "); +MODULE_DESCRIPTION("BCM59056 multi-function driver"); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:bcm59056"); diff --git a/include/linux/mfd/bcm59056.h b/include/linux/mfd/bcm59056.h new file mode 100644 index 0000000..967395d --- /dev/null +++ b/include/linux/mfd/bcm59056.h @@ -0,0 +1,35 @@ +/* + * Broadcom BCM59056 PMU + * + * Copyright 2014 Linaro Limited + * Author: Matt Porter + * + * 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. + * + */ + +#ifndef __LINUX_MFD_BCM59056_H +#define __LINUX_MFD_BCM59056_H + +#include +#include +#include + +/* chip id */ +#define BCM59056 0 + +/* max register address */ +#define BCM59056_MAX_REGISTER 0xe8 + +/* bcm59056 chip access */ +struct bcm59056 { + struct device *dev; + struct i2c_client *i2c_client; + struct regmap *regmap; + unsigned int id; +}; + +#endif /* __LINUX_MFD_BCM59056_H */