From patchwork Fri Jan 4 05:38:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajeshwari Shinde X-Patchwork-Id: 13786 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 DF15723F74 for ; Fri, 4 Jan 2013 05:32:26 +0000 (UTC) Received: from mail-vb0-f45.google.com (mail-vb0-f45.google.com [209.85.212.45]) by fiordland.canonical.com (Postfix) with ESMTP id 852B0A18196 for ; Fri, 4 Jan 2013 05:32:26 +0000 (UTC) Received: by mail-vb0-f45.google.com with SMTP id p1so16344755vbi.32 for ; Thu, 03 Jan 2013 21:32:26 -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=VKaPT5wI4nZb55H5Y8SGqeBj596+i1t2tCMLQ+vfbUk=; b=Khfw24Q4Pfg2AA6A4WCP6D9xbLmFWdPos1osTvsV++RvsemeRK4ZLJ327Woc1318VM N2uR8G9FV8KfkpaOqoijv5AzUFI/dzN7w5km1Wu2xAGKYqTnsPsgNDGBtehtOStg1+8F ttc0IwWzulNpi0z0q1h0dn9QY9xpcxPwQoUVw4U8LJiSSWSwY/E9I8sE95EJjCb4eddh g010zmFaR93IhLnWyACAIq5tlAHtXdsktNEatCF+aCZJDkkNdFW6vbHkG93JL6WfuE6E EPYOJLVg10B0iz52n+KzdEQO9TpdaxhfJ/WPLNIwGfXFgjCAPx9Wn6eVMQ9axAKl9XKR SNVg== X-Received: by 10.52.18.147 with SMTP id w19mr66496832vdd.94.1357277546027; Thu, 03 Jan 2013 21:32:26 -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 st5csp123054veb; Thu, 3 Jan 2013 21:32:25 -0800 (PST) X-Received: by 10.66.79.195 with SMTP id l3mr150851836pax.82.1357277544156; Thu, 03 Jan 2013 21:32:24 -0800 (PST) Received: from mailout2.samsung.com (mailout2.samsung.com. [203.254.224.25]) by mx.google.com with ESMTP id w3si49481149pbz.288.2013.01.03.21.32.23; Thu, 03 Jan 2013 21:32:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of rajeshwari.s@samsung.com designates 203.254.224.25 as permitted sender) client-ip=203.254.224.25; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of rajeshwari.s@samsung.com designates 203.254.224.25 as permitted sender) smtp.mail=rajeshwari.s@samsung.com Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MG3008V561GTZD0@mailout2.samsung.com>; Fri, 04 Jan 2013 14:32:17 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.125]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id F9.21.12699.16966E05; Fri, 04 Jan 2013 14:32:17 +0900 (KST) X-AuditID: cbfee61b-b7f616d00000319b-1a-50e669612581 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 89.21.12699.16966E05; Fri, 04 Jan 2013 14:32:17 +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 <0MG300LZU61EH870@mmp1.samsung.com>; Fri, 04 Jan 2013 14:32:17 +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 V4] PMIC: MAX77686: Add FDT Support Date: Fri, 04 Jan 2013 11:08:59 +0530 Message-id: <1357277939-3033-4-git-send-email-rajeshwari.s@samsung.com> X-Mailer: git-send-email 1.7.4.4 In-reply-to: <1357277939-3033-1-git-send-email-rajeshwari.s@samsung.com> References: <1357277939-3033-1-git-send-email-rajeshwari.s@samsung.com> DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrILMWRmVeSWpSXmKPExsWyRsSkVjcx81mAwaX9WhYP199ksZhy+AuL A5PHnWt72AIYo7hsUlJzMstSi/TtErgy9v2/xlywib/i5ccrLA2M63m6GDk5JARMJA5+X8QE YYtJXLi3nq2LkYtDSGApo8TjfUcYuxg5wIr2rxWGiC9ilFj0cSkThDORSaL7/H02kG42ASOJ rSenMYLYIgISEr/6r4LZzAIlEt++dbOC2MIC5hIb1vwCi7MIqEr0dd8E6+UVcJf4cu0RG8QV ChLHpn4Fq+cU8JA4urwX7DohoJqL/XdYIHoFJL5NPsQCcZysxKYDzCD3SAjcZ5M49OUwM8Qc SYmDK26wTGAUXsDIsIpRNLUguaA4KT3XSK84Mbe4NC9dLzk/dxMjMBxP/3smvYNxVYPFIUYB DkYlHl7LO08DhFgTy4orcw8xSnAwK4nwftZ+FiDEm5JYWZValB9fVJqTWnyI0QfokonMUqLJ +cBYySuJNzQ2MTc1NrU0MjIzNcUhrCTOy3jqSYCQQHpiSWp2ampBahHMOCYOTqkGRs3g1OuW n94Yh9vU+a5duLNompxVS/f5E2HHr9g83/a1xvxhwwnG2gBNq0pDjrUTXT1Xhabee/1YoNCN xS0znP29ZpP8YbZ6e/7AEDNNCRafjoM/t1vGpX+sesxnlZg/KW+tuaWB8rGH+15yRk4oys8/ pS/96v+0lB//TzwTvrGhzUu91sZRiaU4I9FQi7moOBEA41O/xnQCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprAIsWRmVeSWpSXmKPExsVy+t9jAd3EzGcBBvsOKlk8XH+TxWLK4S8s Dkwed67tYQtgjGpgtMlITUxJLVJIzUvOT8nMS7dV8g6Od443NTMw1DW0tDBXUshLzE21VXLx CdB1y8wBmq2kUJaYUwoUCkgsLlbSt8M0ITTETdcCpjFC1zckCK7HyAANJKxhzNj3/xpzwSb+ ipcfr7A0MK7n6WLk4JAQMJHYv1a4i5ETyBSTuHBvPVsXIxeHkMAiRolFH5cyQTgTmSS6z99n A6liEzCS2HpyGiOILSIgIfGr/yqYzSxQIvHtWzcriC0sYC6xYc0vsDiLgKpEX/dNsF5eAXeJ L9cesUFsU5A4NvUrWD2ngIfE0eW9TCC2EFDNxf47LBMYeRcwMqxiFE0tSC4oTkrPNdIrTswt Ls1L10vOz93ECA72Z9I7GFc1WBxiFOBgVOLhtbzzNECINbGsuDL3EKMEB7OSCO9n7WcBQrwp iZVVqUX58UWlOanFhxh9gK6ayCwlmpwPjMS8knhDYxNzU2NTSxMLEzNLHMJK4ryMp54ECAmk J5akZqemFqQWwYxj4uCUamC0PjfPvEoq+s+T68fnunDUezaX7O7t835VruL9hXujpb6C+cn1 rgea+Pdfy9vm/UQ9m1N+Zky2858te5aLcr258WneujNpd6//1Q3f+9oiO7KjyjFFiXn1KhWG U54MiVX+y2Zum3itXOX5jNU/SiPXM4mf0173eRHLN32No2fmxmk9N1Zd2rBNiaU4I9FQi7mo OBEAKIFP4KMCAAA= X-CFilter-Loop: Reflected X-Gm-Message-State: ALoCoQm9pzjLxDD9cURJ1Q9AXUxwG9Bq44lQ5PZ8dW3FE1z+K+icR5i66JNXDqxwXGgm8upfpRJF This patch adds fdt support to MAX77686. Signed-off-by: Rajeshwari Shinde Acked-by: Simon Glass --- Changes in V2: - Corrected indentation errors. Changes in V3: - Rebased on top of the latest implementation of PMIC Changes in V4: - Corrected PMIC register address 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", 9); +#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; }