From patchwork Wed Dec 13 07:19:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Six X-Patchwork-Id: 847880 X-Patchwork-Delegate: mario.six@gdsys.cc Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3yxV6g2WFNz9s9Y for ; Wed, 13 Dec 2017 19:22:18 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 85FD4C21E9C; Wed, 13 Dec 2017 07:50:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id B1570C21F0B; Wed, 13 Dec 2017 07:38:56 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 97D4DC21F06; Wed, 13 Dec 2017 07:22:43 +0000 (UTC) Received: from smtprelay08.ispgateway.de (smtprelay08.ispgateway.de [134.119.228.106]) by lists.denx.de (Postfix) with ESMTPS id 4DF31C21EDE for ; Wed, 13 Dec 2017 07:22:36 +0000 (UTC) Received: from [87.191.40.34] (helo=bob3.testumgebung.local) by smtprelay08.ispgateway.de with esmtpa (Exim 4.89) (envelope-from ) id 1eP1ND-00073A-Rs; Wed, 13 Dec 2017 08:22:35 +0100 From: Mario Six To: U-Boot Mailing List , Wolfgang Denk , Dirk Eibach , Simon Glass , Heiko Schocher , Stefan Roese , Jagan Teki , Joe Hershberger Date: Wed, 13 Dec 2017 08:19:32 +0100 Message-Id: <20171213071946.6181-64-mario.six@gdsys.cc> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171213071946.6181-1-mario.six@gdsys.cc> References: <20171213071946.6181-1-mario.six@gdsys.cc> X-Df-Sender: bWFyaW8uc2l4QGdkc3lzLmNj Subject: [U-Boot] [PATCH v2 64/78] gpio: mpc8xxx: Make compatible with more SoCs X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" Finally, make the mpc8xxx driver capable of handling more GPIO devices; this entails adding a special case for the MPC5121 SoC, and adding a set of new compatible strings. Signed-off-by: Mario Six --- v1 -> v2: None --- drivers/gpio/mpc8xxx_gpio.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) -- 2.13.6 diff --git a/drivers/gpio/mpc8xxx_gpio.c b/drivers/gpio/mpc8xxx_gpio.c index e4ebbc117c..0aa72ecd9f 100644 --- a/drivers/gpio/mpc8xxx_gpio.c +++ b/drivers/gpio/mpc8xxx_gpio.c @@ -11,8 +11,8 @@ #include #include -#include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -37,6 +37,12 @@ struct mpc8xxx_gpio_data { * for output pins */ u32 dat_shadow; + ulong type; +}; + +enum { + MPC8XXX_GPIO_TYPE, + MPC5121_GPIO_TYPE, }; inline u32 gpio_mask(uint gpio) @@ -119,6 +125,12 @@ static int mpc8xxx_gpio_set_value(struct udevice *dev, uint gpio, int value) static int mpc8xxx_gpio_direction_output(struct udevice *dev, uint gpio, int value) { + struct mpc8xxx_gpio_data *data = dev_get_priv(dev); + + /* GPIO 28..31 are input only on MPC5121 */ + if (data->type == MPC5121_GPIO_TYPE && gpio >= 28) + return -EINVAL; + return mpc8xxx_gpio_set_value(dev, gpio, value); } @@ -188,6 +200,7 @@ static int mpc8xxx_gpio_platdata_to_priv(struct udevice *dev) struct mpc8xxx_gpio_data *priv = dev_get_priv(dev); struct mpc8xxx_gpio_plat *plat = dev_get_platdata(dev); unsigned long size = plat->size; + ulong driver_data = dev_get_driver_data(dev); if (size == 0) size = 0x100; @@ -237,7 +250,13 @@ static const struct dm_gpio_ops gpio_mpc8xxx_ops = { }; static const struct udevice_id mpc8xxx_gpio_ids[] = { - { .compatible = "fsl,pq3-gpio" }, + { .compatible = "fsl,pq3-gpio", .data = MPC8XXX_GPIO_TYPE }, + { .compatible = "fsl,mpc8308-gpio", .data = MPC8XXX_GPIO_TYPE }, + { .compatible = "fsl,mpc8349-gpio", .data = MPC8XXX_GPIO_TYPE }, + { .compatible = "fsl,mpc8572-gpio", .data = MPC8XXX_GPIO_TYPE}, + { .compatible = "fsl,mpc8610-gpio", .data = MPC8XXX_GPIO_TYPE}, + { .compatible = "fsl,mpc5121-gpio", .data = MPC5121_GPIO_TYPE, }, + { .compatible = "fsl,qoriq-gpio", .data = MPC8XXX_GPIO_TYPE }, { /* sentinel */ } };