From patchwork Tue Mar 15 05:48:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 597363 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3qPP6r4Drgz9s8g for ; Tue, 15 Mar 2016 16:58:12 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=UjojRGLS; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9374FA7629; Tue, 15 Mar 2016 06:58:08 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3oQyPXqdZXmq; Tue, 15 Mar 2016 06:58:08 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5F4ADA768C; Tue, 15 Mar 2016 06:58:06 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 923F9A765D for ; Tue, 15 Mar 2016 06:58:02 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TX31cJqCOGlI for ; Tue, 15 Mar 2016 06:58:02 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-pf0-f193.google.com (mail-pf0-f193.google.com [209.85.192.193]) by theia.denx.de (Postfix) with ESMTPS id 7A2E3A745C for ; Tue, 15 Mar 2016 06:57:57 +0100 (CET) Received: by mail-pf0-f193.google.com with SMTP id u190so1266940pfb.2 for ; Mon, 14 Mar 2016 22:57:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jJLf8sh2aTp5xJKN0B4u4KNIG4S7lWcAfXaW3KtbLz4=; b=UjojRGLSLYtCYN/fUGX0BfMKhZgC/T0cZJUbJZVeK9Tw1pDZsHfwZkWziML24qYs9d w054qd7uEMJffP2qbTQFE3AHYInP0dXK+zf1k+U8nF3iSZVX4I1nccGrzqI5K58/lrUt ERb7hM6vdIUvCbMt9e4boc8Pgxb4ya4Ivkw3tXsVgCbXqset91y3qELixUWN0LfPwSo8 /SuaglwP4pNOsTqxe4EuWTbezII4Vrd9rCCzW2VS8KsQKmUsh4U01mEbNdG/hKtZ1wB9 rGBZ+g15T/rSSKQt5DH86C+OFAx0nZpi9arkWmWMbUdq6Pts3hWy/v14vf2Ukuyf0+ce 3KhQ== 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=jJLf8sh2aTp5xJKN0B4u4KNIG4S7lWcAfXaW3KtbLz4=; b=HmN6xCIBZwid0I87JKauhKEzU6wUMwLFsQsfMGypxVtPdZ6XeUaGU28IvvHrQB6FxF 5mOZkpWITRjPRh2vFM89KMKJZEYRxi4ec9K4GHBqA/mIyzGkdi3L/5kz3LyP+VBs02AV ++/f2ywPTsmbl/CTzIJYQN6pommbR6WOVLPuJM7pKTlSHMLYOZ1qSPwoFjJQrIK67GnK aiFAoBSffTuLU0N0cjdM9dVcWRRdAZKzaUh3LAwYEDdEFs7g50TgNeBl2dSHWQQDE9n+ xwRh0OBK7kdAnsakEhnUd8ac3UmjpDw1uAnr9EZiJ8/LWRU9i/n5QQI/bcflS/EXXcmB KhIA== X-Gm-Message-State: AD7BkJI4i1AZvT0q6l/FcFHMqmuykp7FXFZ6YqmbCZXMU8hDhpPQl6kd8cMtl74rPYXWXw== X-Received: by 10.66.55.73 with SMTP id q9mr43910865pap.50.1458021475912; Mon, 14 Mar 2016 22:57:55 -0700 (PDT) Received: from linux-7smt.suse (gate-zmy3.freescale.com. [192.88.167.1]) by smtp.gmail.com with ESMTPSA id dg1sm36335953pad.18.2016.03.14.22.57.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 14 Mar 2016 22:57:55 -0700 (PDT) From: Peng Fan To: sbabic@denx.de, sjg@chromium.org Date: Tue, 15 Mar 2016 13:48:57 +0800 Message-Id: <1458020937-994-2-git-send-email-van.freenix@gmail.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1458020937-994-1-git-send-email-van.freenix@gmail.com> References: <1458020937-994-1-git-send-email-van.freenix@gmail.com> Cc: u-boot@lists.denx.de, Fabio Estevam Subject: [U-Boot] [PATCH 2/2] dm: gpio: mxc: implement xlate function X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" To i.MX controller, we use such as "<&gpio1 3 GPIO_ACTIVE_LOW>" for a device to refer a gpio pin in device tree. So need to implement xlate function, to correctly handle gpio flags and offset. Signed-off-by: Peng Fan Cc: Simon Glass Cc: Stefano Babic Cc: Fabio Estevam Reviewed-by: Simon Glass --- drivers/gpio/mxc_gpio.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/gpio/mxc_gpio.c b/drivers/gpio/mxc_gpio.c index b6ae3fc..15449d7 100644 --- a/drivers/gpio/mxc_gpio.c +++ b/drivers/gpio/mxc_gpio.c @@ -10,10 +10,12 @@ #include #include #include +#include #include #include #include #include +#include enum mxc_gpio_direction { MXC_GPIO_DIRECTION_IN, @@ -263,12 +265,22 @@ static int mxc_gpio_get_function(struct udevice *dev, unsigned offset) return GPIOF_INPUT; } +static int mxc_gpio_xlate(struct udevice *dev, struct gpio_desc *desc, + struct fdtdec_phandle_args *args) +{ + desc->offset = args->args[0]; + desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0; + + return 0; +} + static const struct dm_gpio_ops gpio_mxc_ops = { .direction_input = mxc_gpio_direction_input, .direction_output = mxc_gpio_direction_output, .get_value = mxc_gpio_get_value, .set_value = mxc_gpio_set_value, .get_function = mxc_gpio_get_function, + .xlate = mxc_gpio_xlate, }; static int mxc_gpio_probe(struct udevice *dev)