From patchwork Wed Jul 8 12:26:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Hiremath X-Patchwork-Id: 6746651 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AE675C05AC for ; Wed, 8 Jul 2015 12:32:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BB48820665 for ; Wed, 8 Jul 2015 12:32:25 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CA84020639 for ; Wed, 8 Jul 2015 12:32:24 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZCoUG-0007tF-JE; Wed, 08 Jul 2015 12:30:04 +0000 Received: from mail-pd0-f176.google.com ([209.85.192.176]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZCoU8-0007hk-Db for linux-arm-kernel@lists.infradead.org; Wed, 08 Jul 2015 12:29:56 +0000 Received: by pdbep18 with SMTP id ep18so145071733pdb.1 for ; Wed, 08 Jul 2015 05:29:35 -0700 (PDT) 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=CLIElusXG8FwqlHPeWRKk/74NvUnsa4jvv2BKekDuCQ=; b=Ehb+jG1lWhnj5dziMYGmkkf7razen5N/gCFJEKQK/6ZufNbpntM1WcpUAYDDluN9G0 yyhNVzf1uk03NmnEyCntU17Dx9Fe1D6p+sJZQH3YSjz4qvp5d5NnT4Nn89bxvhJjJaI5 iz8rCLwfHN/+P6RogZfFCnG4st4ThYselY3+sFm6i9CaLHy56rV5Rlu2sW68/t3h6K3j AFCr2ISej9TUH/UiRBZPLhwIlOefgqEWwqFSH+dZNrd9lZ33edYfbPeTy2I1RYjaZWVG abQEAjPWwCmc0BIJNWzL1QFd65z7Yw0VV6pCr+8nWsrOtvwE1ow/i0paqpZypL7QjpAA dktQ== X-Gm-Message-State: ALoCoQkIvR6aXiEfMO4AUPESYCfYbHiinFtShZP17Tfu+3pLqjr2NlJy6DgfXb76B7uAEuUqpaXX X-Received: by 10.70.37.43 with SMTP id v11mr20161301pdj.89.1436358575791; Wed, 08 Jul 2015 05:29:35 -0700 (PDT) Received: from localhost.localdomain ([202.62.93.138]) by smtp.gmail.com with ESMTPSA id db1sm2415741pdb.50.2015.07.08.05.29.31 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Jul 2015 05:29:34 -0700 (PDT) From: Vaibhav Hiremath To: linux-arm-kernel@lists.infradead.org Subject: [PATCH-v6 2/6] mfd: 88pm800: Add device tree support Date: Wed, 8 Jul 2015 17:56:28 +0530 Message-Id: <1436358392-15449-3-git-send-email-vaibhav.hiremath@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1436358392-15449-1-git-send-email-vaibhav.hiremath@linaro.org> References: <1436358392-15449-1-git-send-email-vaibhav.hiremath@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150708_052956_490467_C08A0842 X-CRM114-Status: GOOD ( 16.06 ) X-Spam-Score: 0.7 (/) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Samuel Ortiz , Lee Jones , Vaibhav Hiremath , open list , Chao Xie 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=-1.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_SBL_CSS, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=no 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 DT support to the 88pm800 driver, along with compatible field for it's sub-devices (rtc, onkey and regulator) Signed-off-by: Chao Xie Signed-off-by: Vaibhav Hiremath Reviewed-by: Krzysztof Kozlowski Acked-by: Lee Jones --- drivers/mfd/88pm800.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/mfd/88pm800.c b/drivers/mfd/88pm800.c index 0c5470e..95c418c 100644 --- a/drivers/mfd/88pm800.c +++ b/drivers/mfd/88pm800.c @@ -27,6 +27,7 @@ #include #include #include +#include /* Interrupt Registers */ #define PM800_INT_STATUS1 (0x05) @@ -121,6 +122,11 @@ static const struct i2c_device_id pm80x_id_table[] = { }; MODULE_DEVICE_TABLE(i2c, pm80x_id_table); +static const struct of_device_id pm80x_of_match_table[] = { + { .compatible = "marvell,88pm800", }, + {}, +}; + static struct resource rtc_resources[] = { { .name = "88pm80x-rtc", @@ -133,6 +139,7 @@ static struct resource rtc_resources[] = { static struct mfd_cell rtc_devs[] = { { .name = "88pm80x-rtc", + .of_compatible = "marvell,88pm80x-rtc", .num_resources = ARRAY_SIZE(rtc_resources), .resources = &rtc_resources[0], .id = -1, @@ -151,6 +158,7 @@ static struct resource onkey_resources[] = { static const struct mfd_cell onkey_devs[] = { { .name = "88pm80x-onkey", + .of_compatible = "marvell,88pm80x-onkey", .num_resources = 1, .resources = &onkey_resources[0], .id = -1, @@ -160,6 +168,7 @@ static const struct mfd_cell onkey_devs[] = { static const struct mfd_cell regulator_devs[] = { { .name = "88pm80x-regulator", + .of_compatible = "marvell,88pm80x-regulator", .id = -1, }, }; @@ -520,8 +529,24 @@ static int pm800_probe(struct i2c_client *client, int ret = 0; struct pm80x_chip *chip; struct pm80x_platform_data *pdata = dev_get_platdata(&client->dev); + struct device_node *np = client->dev.of_node; struct pm80x_subchip *subchip; + if (!pdata && !np) { + dev_err(&client->dev, + "pm80x requires platform data or of_node\n"); + return -EINVAL; + } + + if (!pdata) { + pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return -ENOMEM; + + /* Ensure we only alloc platform data once */ + client->dev.platform_data = pdata; + } + ret = pm80x_init(client); if (ret) { dev_err(&client->dev, "pm800_init fail\n"); @@ -587,6 +612,7 @@ static struct i2c_driver pm800_driver = { .name = "88PM800", .owner = THIS_MODULE, .pm = &pm80x_pm_ops, + .of_match_table = pm80x_of_match_table, }, .probe = pm800_probe, .remove = pm800_remove,