From patchwork Thu Jan 3 13:47:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajeshwari Shinde X-Patchwork-Id: 13774 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 0E8AA23E21 for ; Thu, 3 Jan 2013 13:42:51 +0000 (UTC) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by fiordland.canonical.com (Postfix) with ESMTP id AA9F6A18E8E for ; Thu, 3 Jan 2013 13:42:50 +0000 (UTC) Received: by mail-vc0-f171.google.com with SMTP id n11so15633241vch.30 for ; Thu, 03 Jan 2013 05:42:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-auditid:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:dlp-filter:x-mtr:x-brightmail-tracker :x-brightmail-tracker:x-cfilter-loop:x-gm-message-state; bh=uPgbil9dPM32n51f4oxhcuZP9J0/EDEM79byj2MzdGw=; b=I3OrPpVYbPFz/YrgTsXfP9DO0AwOjzgbtPSVubIbAKZBqBk4lAlroVOvoc+rPwxT0/ iIY4fxblJZulLLclc2F0ntMDln9UrtaKGhH1z/W1xuHcnVxibU9/ZAdVwrmZu9XGPYvG RZ2PNjfZtjiWRvprXy7S2RyZWYOouDXY0JvCTIPyiEXRr9nx/JKiDN1n1UkdFeUhPJY1 U+M4AILQPihRDCe+FZJl5Oi2nriyEY9pI7kxgLeGqu/kq2JCwapNVQ+4VZ2ry/ZwaGit YtsdYJ/hmFsCccVZTWwMxBUrHJJZDQ2OUn9XLVlB0jehAUZI7V+8z1TCgAqbwXrUcrit 3Juw== X-Received: by 10.58.196.196 with SMTP id io4mr75901635vec.22.1357220570206; Thu, 03 Jan 2013 05:42:50 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.145.101 with SMTP id st5csp91810veb; Thu, 3 Jan 2013 05:42:49 -0800 (PST) X-Received: by 10.66.84.3 with SMTP id u3mr145179503pay.51.1357220568893; Thu, 03 Jan 2013 05:42:48 -0800 (PST) Received: from mailout4.samsung.com (mailout4.samsung.com. [203.254.224.34]) by mx.google.com with ESMTP id rr6si47554321pbc.11.2013.01.03.05.42.48; Thu, 03 Jan 2013 05:42:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of rajeshwari.s@samsung.com designates 203.254.224.34 as permitted sender) client-ip=203.254.224.34; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of rajeshwari.s@samsung.com designates 203.254.224.34 as permitted sender) smtp.mail=rajeshwari.s@samsung.com Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MG100A5NY3BIN10@mailout4.samsung.com>; Thu, 03 Jan 2013 22:42:47 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.126]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 11.9D.01231.7DA85E05; Thu, 03 Jan 2013 22:42:47 +0900 (KST) X-AuditID: cbfee61a-b7fa66d0000004cf-1c-50e58ad7f688 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id A0.9D.01231.7DA85E05; Thu, 03 Jan 2013 22:42:47 +0900 (KST) Received: from rajeshwari-linux.sisodomain.com ([107.108.215.115]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MG1001GEY058Y20@mmp1.samsung.com>; Thu, 03 Jan 2013 22:42:47 +0900 (KST) From: Rajeshwari Shinde To: u-boot@lists.denx.de Cc: patches@linaro.org, sjg@chromium.org, mk7.kang@samsung.com, chander.kashyap@linaro.org, l.majewski@samsung.com Subject: [PATCH 3/3 V3] PMIC: MAX77686: Add FDT Support Date: Thu, 03 Jan 2013 19:17:49 +0530 Message-id: <1357220869-13819-4-git-send-email-rajeshwari.s@samsung.com> X-Mailer: git-send-email 1.7.4.4 In-reply-to: <1357220869-13819-1-git-send-email-rajeshwari.s@samsung.com> References: <1357220869-13819-1-git-send-email-rajeshwari.s@samsung.com> DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrILMWRmVeSWpSXmKPExsWyRsSkTvd619MAg52XFC0err/JYjHl8BcW ByaPO9f2sAUwRnHZpKTmZJalFunbJXBl/Nn/ga3gH1/FpV0rmBoY23i6GDk4JARMJB7fMepi 5AQyxSQu3FvP1sXIxSEksJRRYtLpeywQCROJV9P3MEMkFjFKfLzznwnCmcgk0bpyAxNIFZuA kcTWk9MYQWwRAQmJX/1XwWxmgRKJb9+6WUFsYQFzif7tS8HiLAKqEvP/bGEHsXkFPCReLZ/K CrFNQeLY1K9gNqeAp8Td89fZQGwhoJrW5w1QvQIS3yYfYoH4QFZi0wGw4yQEbrNJ3FrQBnW1 pMTBFTdYJjAKL2BkWMUomlqQXFCclJ5rqFecmFtcmpeul5yfu4kRGI6n/z2T2sG4ssHiEKMA B6MSDy9j/ZMAIdbEsuLK3EOMEhzMSiK8s/OfBgjxpiRWVqUW5ccXleakFh9i9AG6ZCKzlGhy PjBW8kriDY1NzE2NTS2NjMxMTXEIK4nzMp4CGi+QnliSmp2aWpBaBDOOiYNTqoGR/fUdbZ6Q vGfZ7Roph268PHBo3t6LE9432zn8iOw5HLAwQC7+G6MNs0yT+6ucY0esAjrkZOtt7zxc+m2T S3rE1q5Q3tVb73H0RUlMSY14NS0vfGdB3bbHJ4oFmTUdgkvqco/MmrimQOzid6k4C26vhJmz fXwOpt806YozcOha9a+tzEbf6o8SS3FGoqEWc1FxIgBPGDzEdAIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprIIsWRmVeSWpSXmKPExsVy+t9jAd3rXU8DDB70i1o8XH+TxWLK4S8s Dkwed67tYQtgjGpgtMlITUxJLVJIzUvOT8nMS7dV8g6Od443NTMw1DW0tDBXUshLzE21VXLx CdB1y8wBmq2kUJaYUwoUCkgsLlbSt8M0ITTETdcCpjFC1zckCK7HyAANJKxhzPiz/wNbwT++ iku7VjA1MLbxdDFyckgImEi8mr6HGcIWk7hwbz1bFyMXh5DAIkaJj3f+M0E4E5kkWlduYAKp YhMwkth6chojiC0iICHxq/8qmM0sUCLx7Vs3K4gtLGAu0b99KVicRUBVYv6fLewgNq+Ah8Sr 5VNZIbYpSByb+hXM5hTwlLh7/jobiC0EVNP6vIFxAiPvAkaGVYyiqQXJBcVJ6bmGesWJucWl eel6yfm5mxjB4f5MagfjygaLQ4wCHIxKPLyM9U8ChFgTy4orcw8xSnAwK4nwzs5/GiDEm5JY WZValB9fVJqTWnyI0QfoqonMUqLJ+cBYzCuJNzQ2MTc1NrU0sTAxs8QhrCTOy3gKaLxAemJJ anZqakFqEcw4Jg5OqQZGU3Nn7SU70hpnqCpENaedXJAfrPZd+ZFyQ9LVtJZSPpHCQM2GhoMa G+bo7zHTuPlg+7zoeJ6406XM+6d9bkj6m2FddfR4zqbzX2U35Txw+vl0hXzof57knKl1ddO1 1nIHbJrh9PEl/wazD2X31CRmf90zt9OlMFvpzsp170Mehrx9My3syYTHSizFGYmGWsxFxYkA l8B02KQCAAA= X-CFilter-Loop: Reflected X-Gm-Message-State: ALoCoQkg98sATzhSeIPCTpZMWDP5P20j8Wpm0cNguxb7zxlHBTL3QovzVqqtLDkD5t/ERzvMKAF1 This patch adds fdt support to MAX77686. Signed-off-by: Rajeshwari Shinde --- Changes in V2: - Corrected indentation errors. Changes in V3: - Rebased on top of the latest implementation of PMIC drivers/power/pmic/pmic_max77686.c | 37 +++++++++++++++++++++++++++++++++-- 1 files changed, 34 insertions(+), 3 deletions(-) diff --git a/drivers/power/pmic/pmic_max77686.c b/drivers/power/pmic/pmic_max77686.c index fce0183..a1ee04e 100644 --- a/drivers/power/pmic/pmic_max77686.c +++ b/drivers/power/pmic/pmic_max77686.c @@ -22,10 +22,14 @@ */ #include +#include +#include #include #include #include +DECLARE_GLOBAL_DATA_PTR; + int pmic_init(unsigned char bus) { static const char name[] = "MAX77686_PMIC"; @@ -36,13 +40,40 @@ int pmic_init(unsigned char bus) return -ENOMEM; } - puts("Board PMIC init\n"); +#ifdef CONFIG_OF_CONTROL + const void *blob = gd->fdt_blob; + int node, parent; + + node = fdtdec_next_compatible(blob, 0, COMPAT_MAXIM_MAX77686_PMIC); + if (node < 0) { + debug("PMIC: No node for PMIC Chip in device tree\n"); + debug("node = %d\n", node); + return -1; + } + + parent = fdt_parent_offset(blob, node); + if (parent < 0) { + debug("%s: Cannot find node parent\n", __func__); + return -1; + } + + p->bus = i2c_get_bus_num_fdt(parent); + if (p->bus < 0) { + debug("%s: Cannot find I2C bus\n", __func__); + return -1; + } + p->hw.i2c.addr = fdtdec_get_int(blob, node, "reg", 6); +#else + p->bus = bus; + p->hw.i2c.addr = MAX77686_I2C_ADDR; +#endif + p->name = name; p->interface = PMIC_I2C; p->number_of_regs = PMIC_NUM_OF_REGS; - p->hw.i2c.addr = MAX77686_I2C_ADDR; p->hw.i2c.tx_num = 1; - p->bus = bus; + + puts("Board PMIC init\n"); return 0; }