From patchwork Thu Apr 12 15:39:41 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Liu X-Patchwork-Id: 7764 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 294B823E29 for ; Thu, 12 Apr 2012 15:40:06 +0000 (UTC) Received: from mail-gx0-f180.google.com (mail-gx0-f180.google.com [209.85.161.180]) by fiordland.canonical.com (Postfix) with ESMTP id 690B9A18021 for ; Thu, 12 Apr 2012 15:40:05 +0000 (UTC) Received: by gglu1 with SMTP id u1so1434183ggl.11 for ; Thu, 12 Apr 2012 08:40:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:x-gm-message-state; bh=tGJOSL4HpFCOX/i0KRwZArFhwQqv9mVo+C7tIwVwlKM=; b=LmF6ZpfHqh9vjswlI1k9owBgOpo/4lYt4pB2GV1GueWKWfXzgVFMb4O6yg7cPOjV0y pOpCKomakhsRYibp1sNdUtlzEKKJUMT2AAZFrrTKEy3meZ+jCq3IUHas0LsObtu8Pk9R FPP9Izo/YOjT0CH6+niqLCTOof2AcL9RUm3XPl11ad4E0+96f06p5aJ/YOdKTZi6lNjy xQ9Ukd7NT4Qi8rPSQFnAJUFUQ5EEo0Nb3mv9CnB2HSobXjJRYqRGY5BxVDXZsCU7wWd/ yl5RrrAU8V4Tlc0BnLTpfPVFj4DZahpzoBPi45RqUurAKLU+GIvE7WHyP+ugzyhpr54Y /YFg== Received: by 10.50.242.5 with SMTP id wm5mr3083883igc.40.1334245203384; Thu, 12 Apr 2012 08:40:03 -0700 (PDT) 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.231.70.69 with SMTP id c5csp272004ibj; Thu, 12 Apr 2012 08:40:02 -0700 (PDT) Received: by 10.182.72.5 with SMTP id z5mr3575589obu.61.1334245201908; Thu, 12 Apr 2012 08:40:01 -0700 (PDT) Received: from mail-ob0-f178.google.com (mail-ob0-f178.google.com [209.85.214.178]) by mx.google.com with ESMTPS id 8si1869400obi.52.2012.04.12.08.40.01 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 12 Apr 2012 08:40:01 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.214.178 is neither permitted nor denied by best guess record for domain of paul.liu@linaro.org) client-ip=209.85.214.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.214.178 is neither permitted nor denied by best guess record for domain of paul.liu@linaro.org) smtp.mail=paul.liu@linaro.org Received: by obfk16 with SMTP id k16so3799083obf.37 for ; Thu, 12 Apr 2012 08:40:01 -0700 (PDT) Received: by 10.182.0.48 with SMTP id 16mr3799217obb.23.1334245201650; Thu, 12 Apr 2012 08:40:01 -0700 (PDT) Received: from freya.lan (host-216.138-185-111.static.totalbb.net.tw. [111.185.138.216]) by mx.google.com with ESMTPS id by5sm7056183obb.19.2012.04.12.08.39.57 (version=SSLv3 cipher=OTHER); Thu, 12 Apr 2012 08:40:00 -0700 (PDT) From: "Ying-Chun Liu (PaulLiu)" To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, linaro-dev@lists.linaro.org, patches@linaro.org, broonie@opensource.wolfsonmicro.com, "Ying-Chun Liu (PaulLiu)" , Samuel Ortiz , Shawn Guo , Ashish Jangam Subject: [PATCH 1/2] mfd: da9052: add device-tree support for i2c driver Date: Thu, 12 Apr 2012 23:39:41 +0800 Message-Id: <1334245182-31725-1-git-send-email-paul.liu@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQlkmPB4k75cb4S6VgGYpuLSvL+N9ap5dSfl1gG4iYAXC8MOuIu7FycF7oeqnuSGu6h5NZC5 From: "Ying-Chun Liu (PaulLiu)" This patch adds device-tree support for dialog MFD and the binding documentations. Signed-off-by: Ying-Chun Liu (PaulLiu) Cc: Samuel Ortiz Cc: Shawn Guo Cc: Ashish Jangam --- .../devicetree/bindings/mfd/da9052-i2c.txt | 58 ++++++++++++++++++++ drivers/mfd/da9052-i2c.c | 54 +++++++++++++++--- 2 files changed, 104 insertions(+), 8 deletions(-) create mode 100644 Documentation/devicetree/bindings/mfd/da9052-i2c.txt diff --git a/Documentation/devicetree/bindings/mfd/da9052-i2c.txt b/Documentation/devicetree/bindings/mfd/da9052-i2c.txt new file mode 100644 index 0000000..042d042 --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/da9052-i2c.txt @@ -0,0 +1,58 @@ +* Dialog DA9052/53 Power Management Integrated Circuit (PMIC) + +Required properties: +- compatible : Should be "dialog,da9052", "dialog,da9053-aa", + "dialog,da9053-ab", or "dialog,da9053-bb" + +Sub-nodes: +- regulators : Contain the regulator nodes. The DA9052 regulators are + sorted as following: + + buck_core : regulator BUCK_CORE (id: 0 ) + buck_pro : regulator BUCK_PRO (id: 1 ) + buck_mem : regulator BUCK_MEM (id: 2 ) + buck_peri : regulator BUCK_PERI (id: 3 ) + ldo1 : regulator LDO1 (id: 4 ) + ldo2 : regulator LDO2 (id: 5 ) + ldo3 : regulator LDO3 (id: 6 ) + ldo4 : regulator LDO4 (id: 7 ) + ldo5 : regulator LDO5 (id: 8 ) + ldo6 : regulator LDO6 (id: 9 ) + ldo7 : regulator LDO7 (id: 10) + ldo8 : regulator LDO8 (id: 11) + ldo9 : regulator LDO9 (id: 12) + ldo10 : regulator LDO10 (id: 13) + + The bindings details of individual regulator device can be found in: + Documentation/devicetree/bindings/regulator/regulator.txt + +Examples: + +i2c@63fc8000 { /* I2C1 */ + status = "okay"; + + pmic: dialog@48 { + compatible = "dialog,da9053-aa"; + reg = <0x48>; + + regulators { + regulator-buck0 { + regulator-name = "DA9052_BUCK_CORE"; + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <2075000>; + }; + + regulator-buck1 { + regulator-name = "DA9052_BUCK_PRO"; + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <2075000>; + }; + + regulator-buck2 { + regulator-name = "DA9052_BUCK_MEM"; + regulator-min-microvolt = <925000>; + regulator-max-microvolt = <2500000>; + }; + }; + }; +}; diff --git a/drivers/mfd/da9052-i2c.c b/drivers/mfd/da9052-i2c.c index 36b88e3..e07bcfa 100644 --- a/drivers/mfd/da9052-i2c.c +++ b/drivers/mfd/da9052-i2c.c @@ -22,6 +22,11 @@ #include #include +#ifdef CONFIG_OF +#include +#include +#endif + static int da9052_i2c_enable_multiwrite(struct da9052 *da9052) { int reg_val, ret; @@ -41,6 +46,24 @@ static int da9052_i2c_enable_multiwrite(struct da9052 *da9052) return 0; } +static struct i2c_device_id da9052_i2c_id[] = { + {"da9052", DA9052}, + {"da9053-aa", DA9053_AA}, + {"da9053-ba", DA9053_BA}, + {"da9053-bb", DA9053_BB}, + {} +}; + +#ifdef CONFIG_OF +static const struct of_device_id dialog_dt_ids[] = { + { .compatible = "dialog,da9052" }, + { .compatible = "dialog,da9053-aa" }, + { .compatible = "dialog,da9053-ab" }, + { .compatible = "dialog,da9053-bb" }, + { /* sentinel */ } +}; +#endif + static int __devinit da9052_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -76,6 +99,26 @@ static int __devinit da9052_i2c_probe(struct i2c_client *client, if (ret < 0) goto err_regmap; +#ifdef CONFIG_OF + if (!id) { + int i; + struct device_node *np = client->dev.of_node; + + for (i = 0; + i < sizeof(dialog_dt_ids)/sizeof(dialog_dt_ids[0]); + i++) + if (of_device_is_compatible(np, + dialog_dt_ids[i].compatible)) + id = &da9052_i2c_id[i]; + } +#endif + + if (!id) { + ret = -ENODEV; + dev_err(&client->dev, "id is null.\n"); + goto err_regmap; + } + ret = da9052_device_init(da9052, id->driver_data); if (ret != 0) goto err_regmap; @@ -100,14 +143,6 @@ static int __devexit da9052_i2c_remove(struct i2c_client *client) return 0; } -static struct i2c_device_id da9052_i2c_id[] = { - {"da9052", DA9052}, - {"da9053-aa", DA9053_AA}, - {"da9053-ba", DA9053_BA}, - {"da9053-bb", DA9053_BB}, - {} -}; - static struct i2c_driver da9052_i2c_driver = { .probe = da9052_i2c_probe, .remove = __devexit_p(da9052_i2c_remove), @@ -115,6 +150,9 @@ static struct i2c_driver da9052_i2c_driver = { .driver = { .name = "da9052", .owner = THIS_MODULE, +#ifdef CONFIG_OF + .of_match_table = dialog_dt_ids, +#endif }, };