From patchwork Mon Feb 4 15:40:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 14541 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 CEC3423F8B for ; Mon, 4 Feb 2013 15:42:21 +0000 (UTC) Received: from mail-ve0-f169.google.com (mail-ve0-f169.google.com [209.85.128.169]) by fiordland.canonical.com (Postfix) with ESMTP id 8A3B6A18088 for ; Mon, 4 Feb 2013 15:42:21 +0000 (UTC) Received: by mail-ve0-f169.google.com with SMTP id 15so3119841vea.0 for ; Mon, 04 Feb 2013 07:42:21 -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-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=TDQTboMdaRUzjWcxwQmwPADyfkwf4HK+q2gkojGRY7c=; b=o7kBrzJIoeln8Ky6T8RVsP+5+Yp77kSz67vz5mSSByrXB8JRXGgFUlU7UbrhQvo0RJ p8I2T2EjDF/uudNrMAyTcpTSL+k9coNIyyF8ZfC9bvDuFy3Qg+RwWrVElKrufRpc3tmZ RoIgYaYPa0NJPaFl1fUyNsHypVYWsFflMoqRd6LoB3KXJ/E05PBj7drM29IEQLLj5qna jb4L3y63FK+k72Vzr0v56bFDui/qxuq4rGGvyoayWZg7hJ/hettbIyX1SwZvrAPwRJL5 whUxZJUJ0QXFoJ2eGWkOOE6UEvF8+ptaBylWtL1K2AS2GMuqaYp+ACAAFxjeGOYQ1sAA gI6A== X-Received: by 10.52.21.146 with SMTP id v18mr19848342vde.79.1359992541056; Mon, 04 Feb 2013 07:42:21 -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.252.8 with SMTP id zo8csp92954vec; Mon, 4 Feb 2013 07:42:20 -0800 (PST) X-Received: by 10.66.90.98 with SMTP id bv2mr37361397pab.19.1359992540188; Mon, 04 Feb 2013 07:42:20 -0800 (PST) Received: from mail-pa0-f53.google.com (mail-pa0-f53.google.com [209.85.220.53]) by mx.google.com with ESMTPS id a5si15919053pax.269.2013.02.04.07.42.19 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 04 Feb 2013 07:42:20 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.53 is neither permitted nor denied by best guess record for domain of haojian.zhuang@linaro.org) client-ip=209.85.220.53; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.53 is neither permitted nor denied by best guess record for domain of haojian.zhuang@linaro.org) smtp.mail=haojian.zhuang@linaro.org Received: by mail-pa0-f53.google.com with SMTP id bg4so3378175pad.40 for ; Mon, 04 Feb 2013 07:42:19 -0800 (PST) X-Received: by 10.66.83.134 with SMTP id q6mr54125651pay.34.1359992539621; Mon, 04 Feb 2013 07:42:19 -0800 (PST) Received: from localhost.localdomain ([67.198.145.34]) by mx.google.com with ESMTPS id d1sm22254330pav.6.2013.02.04.07.42.13 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 04 Feb 2013 07:42:18 -0800 (PST) From: Haojian Zhuang To: sameo@linux.intel.com, qingx@marvell.com, grant.likely@secretlab.ca, rob.herring@calxeda.com, cxie4@marvell.com, linux-kernel@vger.kernel.org, devicetree-discuss@lists.ozlabs.org Cc: patches@linaro.org, Haojian Zhuang Subject: [PATCH 4/6] mfd: max8925: support dt for backlight Date: Mon, 4 Feb 2013 23:40:45 +0800 Message-Id: <1359992448-22229-4-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1359992448-22229-1-git-send-email-haojian.zhuang@linaro.org> References: <1359992448-22229-1-git-send-email-haojian.zhuang@linaro.org> X-Gm-Message-State: ALoCoQlu5EspkIVf3BeMj+W7lHbXXt5Qr4pJS0bECDm6QIu7xqStwPjcWedw+yYE1NhCPV1Pp9F1 From: Qing Xu Add device tree support in max8925 backlight. Signed-off-by: Qing Xu Signed-off-by: Haojian Zhuang --- drivers/video/backlight/max8925_bl.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/drivers/video/backlight/max8925_bl.c b/drivers/video/backlight/max8925_bl.c index 2c9bce0..5ca11b0 100644 --- a/drivers/video/backlight/max8925_bl.c +++ b/drivers/video/backlight/max8925_bl.c @@ -101,6 +101,29 @@ static const struct backlight_ops max8925_backlight_ops = { .get_brightness = max8925_backlight_get_brightness, }; +#ifdef CONFIG_OF +static int max8925_backlight_dt_init(struct platform_device *pdev, + struct max8925_backlight_pdata *pdata) +{ + struct device_node *nproot = pdev->dev.parent->of_node, *np; + int dual_string; + + if (!nproot) + return -ENODEV; + np = of_find_node_by_name(nproot, "backlight"); + if (!np) { + dev_err(&pdev->dev, "failed to find backlight node\n"); + return -ENODEV; + } + + of_property_read_u32(np, "maxim,max8925-dual-string", &dual_string); + pdata->dual_string = dual_string; + return 0; +} +#else +#define max8925_backlight_dt_init(x, y) (-1) +#endif + static int max8925_backlight_probe(struct platform_device *pdev) { struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent); @@ -147,6 +170,13 @@ static int max8925_backlight_probe(struct platform_device *pdev) platform_set_drvdata(pdev, bl); value = 0; + if (pdev->dev.parent->of_node && !pdata) { + pdata = devm_kzalloc(&pdev->dev, + sizeof(struct max8925_backlight_pdata), + GFP_KERNEL); + max8925_backlight_dt_init(pdev, pdata); + } + if (pdata) { if (pdata->lxw_scl) value |= (1 << 7); @@ -158,7 +188,6 @@ static int max8925_backlight_probe(struct platform_device *pdev) ret = max8925_set_bits(chip->i2c, data->reg_mode_cntl, 0xfe, value); if (ret < 0) goto out_brt; - backlight_update_status(bl); return 0; out_brt: