From patchwork Wed Oct 8 20:48:43 2014
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Przemyslaw Marczak
X-Patchwork-Id: 397736
X-Patchwork-Delegate: sjg@chromium.org
Return-Path:
X-Original-To: incoming@patchwork.ozlabs.org
Delivered-To: patchwork-incoming@bilbo.ozlabs.org
Received: from theia.denx.de (theia.denx.de [85.214.87.163])
by ozlabs.org (Postfix) with ESMTP id 019FA1400BE
for ;
Thu, 9 Oct 2014 07:50:59 +1100 (EST)
Received: from localhost (localhost [127.0.0.1])
by theia.denx.de (Postfix) with ESMTP id DC0E64B5F5;
Wed, 8 Oct 2014 22:50:31 +0200 (CEST)
Received: from theia.denx.de ([127.0.0.1])
by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id nZjSNMgSWXuk; Wed, 8 Oct 2014 22:50:31 +0200 (CEST)
Received: from theia.denx.de (localhost [127.0.0.1])
by theia.denx.de (Postfix) with ESMTP id 5340EA7408;
Wed, 8 Oct 2014 22:50:11 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
by theia.denx.de (Postfix) with ESMTP id 59C62A73ED
for ; Wed, 8 Oct 2014 22:49:52 +0200 (CEST)
Received: from theia.denx.de ([127.0.0.1])
by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id flRi7KraReOK for ;
Wed, 8 Oct 2014 22:49:52 +0200 (CEST)
X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5
NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested)
Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com
[210.118.77.11]) by theia.denx.de (Postfix) with ESMTPS id 1B9514B5EC
for ; Wed, 8 Oct 2014 22:49:52 +0200 (CEST)
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 <0ND500F7O8NTRW20@mailout1.w1.samsung.com>
for u-boot@lists.denx.de; Wed, 08 Oct 2014 21:52:41 +0100 (BST)
X-AuditID: cbfec7f4-b7f156d0000063c7-cd-5435a36a907d
Received: from eusync4.samsung.com ( [203.254.199.214])
by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 6C.B4.25543.A63A5345;
Wed, 08 Oct 2014 21:49:46 +0100 (BST)
Received: from AMDC1186.digital.local ([106.116.147.185])
by eusync4.samsung.com
(Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit
(built Nov
17 2011)) with ESMTPA id <0ND5008458IPTV30@eusync4.samsung.com>; Wed,
08 Oct 2014 21:49:46 +0100 (BST)
From: Przemyslaw Marczak
To: u-boot@lists.denx.de
Date: Wed, 08 Oct 2014 22:48:43 +0200
Message-id: <1412801335-1591-8-git-send-email-p.marczak@samsung.com>
X-Mailer: git-send-email 1.9.1
In-reply-to: <1412801335-1591-1-git-send-email-p.marczak@samsung.com>
References: <1412801335-1591-1-git-send-email-p.marczak@samsung.com>
X-Brightmail-Tracker:
H4sIAAAAAAAAA+NgFmplluLIzCtJLcpLzFFi42I5/e/4Nd2sxaYhBvt/WFm8OT6dyeLNw82M
Fh1HWhgtdly+wWLx4PBOdotvW7YxWkxePJ/Z4u3eTnaLo1+usTlwesxuuMjiMW3iR2aPs3d2
MHq833eVzaNvyypGj+M3tjMFsEVx2aSk5mSWpRbp2yVwZfz+uZatYJ5MxberAQ2MN8W7GDk5
JARMJB5+WsoEYYtJXLi3nq2LkYtDSGApo8TSq69YIZw+Jok7C+8wg1SxCRhI7Ll0BswWEZCQ
+NV/lRGkiFlgO5PEqVstYKOEBSwlLn1qYQGxWQRUJZ5u2wPWwCvgIvF4xik2iHVyEiePTQba
wMHBKeAqMfVyCEhYCKhkydsJ7BMYeRcwMqxiFE0tTS4oTkrPNdQrTswtLs1L10vOz93ECAm6
LzsYFx+zOsQowMGoxMNr0GwSIsSaWFZcmXuIUYKDWUmE91CgaYgQb0piZVVqUX58UWlOavEh
RiYOTqkGxtQ+K4fER42rzD/N0o1Z6pnrlhKdI+p/Q/Dc9ti88MLCtpYAmUNZpVLsh2WLIoNj
fhe0bpo/9wDn6l9ab6yc3kzyjGZRd5DOPpN+5+clDclg48aMl4yNGeKnZLOqp51VLZ48YfL/
l4YG3EnVq3+oL0uNCQoT4N205efc5oIn7R5m7MWfq3YosRRnJBpqMRcVJwIABNChAhgCAAA=
Cc: Przemyslaw Marczak , Tom Rini
Subject: [U-Boot] [PATCH 07/19] dm: pmic: add max77686 pmic driver
X-BeenThere: u-boot@lists.denx.de
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: U-Boot discussion
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
MIME-Version: 1.0
Sender: u-boot-bounces@lists.denx.de
Errors-To: u-boot-bounces@lists.denx.de
This adds a simple implementation of driver model uclass pmic driver.
This implementation includes two funcitons:
- max77686_ofdata_to_platdada(...) - init I/O data from fdt
- max77686_probe(...) - looks for max77686 regulator driver and bind it
If there is no regulator driver, then pmic can still provide read/write
operations, and can be accessed by 'pmic' commands.
Signed-off-by: Przemyslaw Marczak
Reviewed-by: Tom Rini
---
drivers/power/pmic/Makefile | 1 +
drivers/power/pmic/max77686.c | 89 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 90 insertions(+)
create mode 100644 drivers/power/pmic/max77686.c
diff --git a/drivers/power/pmic/Makefile b/drivers/power/pmic/Makefile
index e7b07eb..49beffb 100644
--- a/drivers/power/pmic/Makefile
+++ b/drivers/power/pmic/Makefile
@@ -10,6 +10,7 @@ obj-$(CONFIG_POWER_MAX8998) += pmic_max8998.o
obj-$(CONFIG_POWER_MAX8997) += pmic_max8997.o
obj-$(CONFIG_POWER_MUIC_MAX8997) += muic_max8997.o
obj-$(CONFIG_POWER_MAX77686) += pmic_max77686.o
+obj-$(CONFIG_DM_PMIC_MAX77686) += max77686.o
obj-$(CONFIG_POWER_PFUZE100) += pmic_pfuze100.o
obj-$(CONFIG_POWER_TPS65090_I2C) += pmic_tps65090.o
obj-$(CONFIG_POWER_TPS65090_EC) += pmic_tps65090_ec.o
diff --git a/drivers/power/pmic/max77686.c b/drivers/power/pmic/max77686.c
new file mode 100644
index 0000000..74b10da
--- /dev/null
+++ b/drivers/power/pmic/max77686.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics
+ * Rajeshwari Shinde
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static int max77686_ofdata_to_platdata(struct udevice *dev)
+{
+ struct pmic_platdata *pl = dev->platdata;
+ const void *blob = gd->fdt_blob;
+ int node = dev->of_offset;
+ int parent;
+
+ pl->interface = PMIC_I2C;
+ pl->regs_num = PMIC_NUM_OF_REGS;
+
+ parent = fdt_parent_offset(blob, node);
+
+ if (parent < 0) {
+ error("%s: Cannot find node parent", __func__);
+ return -EINVAL;
+ }
+
+ pl->bus = i2c_get_bus_num_fdt(parent);
+ if (pl->bus < 0) {
+ debug("%s: Cannot find bus num\n", __func__);
+ return -EINVAL;
+ }
+
+ pl->hw.i2c.addr = fdtdec_get_int(blob, node, "reg", MAX77686_I2C_ADDR);
+ pl->hw.i2c.tx_num = 1;
+
+ return 0;
+}
+
+static int max77686_probe(struct udevice *parent)
+{
+ struct udevice *reg_dev;
+ struct driver *reg_drv;
+ int ret;
+
+ reg_drv = lists_driver_lookup_name("max77686 regulator");
+ if (!reg_drv) {
+ error("%s regulator driver not found!\n", parent->name);
+ return 0;
+ }
+
+ if (!parent->platdata) {
+ error("%s platdata not found!\n", parent->name);
+ return -EINVAL;
+ }
+
+ ret = device_bind(parent, reg_drv, parent->name, parent->platdata,
+ parent->of_offset, ®_dev);
+ if (ret)
+ error("%s regulator bind failed", parent->name);
+
+ /* Return error only if no parent platdata set */
+ return 0;
+}
+
+static const struct udevice_id max77686_ids[] = {
+ { .compatible = "maxim,max77686_pmic"},
+ { }
+};
+
+U_BOOT_DRIVER(pmic_max77686) = {
+ .name = "max77686 pmic",
+ .id = UCLASS_PMIC,
+ .of_match = max77686_ids,
+ .probe = max77686_probe,
+ .ofdata_to_platdata = max77686_ofdata_to_platdata,
+ .platdata_auto_alloc_size = sizeof(struct pmic_platdata),
+};