Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754514AbbG3H1b (ORCPT ); Thu, 30 Jul 2015 03:27:31 -0400 Received: from mail-bn1bbn0104.outbound.protection.outlook.com ([157.56.111.104]:56544 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751301AbbG3H12 (ORCPT ); Thu, 30 Jul 2015 03:27:28 -0400 Authentication-Results: spf=none (sender IP is 192.88.168.50) smtp.mailfrom=nmglablinux22.freescale.com; vger.kernel.org; dkim=none (message not signed) header.d=none; From: Shaveta Leekha To: , CC: , , , Shaveta Leekha Subject: [PATCH 1/3] drivers/gpio: Port gpio driver to ls1021a-qds platform Date: Thu, 30 Jul 2015 12:57:17 +0530 Message-ID: <1438241239-15178-1-git-send-email-shaveta@freescale.com> X-Mailer: git-send-email 1.7.7.4 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BN1BFFO11FD020;1:2jWgRNdVvCgEJZuh+3C1IZG00+xSU6hbykZ5CKnKmgCwEwzXEqOCWf+CX242NJOIPP2oipE5BXrc/+X1JPZrvckUbWjcgJzFn9UvvnQ/ALBg4CHGJ/Il23jGRL2XFQvwq9A7DP9l7nrvopvmc5bUICgUUIpOEyV7agtfjd/zl83yDwx9gXqGfibyaRMu2Bt34td8ZxuIl2savSokHN7uacy4ux4Nkf+int9Glc9Zx/iKxI4YEe0Rq28EjHVmg9wBulKc4R19IuUlMcaJfKFuT1+S5KO2pgsaZWqoLP5SOIo= X-Forefront-Antispam-Report: CIP:192.88.168.50;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(6039001)(2980300002)(199003)(189002)(106466001)(33646002)(47776003)(50226001)(92566002)(50466002)(45336002)(48376002)(19580395003)(42186005)(189998001)(46386002)(6806004)(229853001)(77156002)(16796002)(62966003)(105586002)(46102003)(5001770100001)(86372001)(19580405001)(5001960100002)(107886002)(101416001)(36756003)(52956003)(50986999)(87936001)(4001430100001)(90966001);DIR:OUT;SFP:1102;SCL:1;SRVR:BN3PR0301MB1281;H:tx30smr01.am.freescale.net;FPR:;SPF:None;MLV:sfv;A:0;MX:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;BN3PR0301MB1281;2:3XXIhmzZbyQtO77zelaPPcR4FTA7gS/iFO0dOuAhtvMMpioQSXmSWf7JqUBrCkMAR1BexlAShDOmpsrJjpv9RMCg+Y1pnKPrKDPRb5GY9rn20aZ1Wui8kV+/VBLWo4ECRAAlrX3nw9rdo6SVSc4xYBPR5h4GsaVj7dhSm2V6aBQ=;3:181QWR0BjxKqsgltYVuzTn0LkUILW1MHReKZOjzeYBIQui/AtJ2iLyGdvF4qeT1lE71oQ/2lgvEvJBOifoPLjSqT+OHwkDcdRxZ7wNSpB5J7IaaPlHfr3RSuXTkisqRcOZrTxxKBU+HB1Ub8RL+VVrheWSCiQ2Py3XJffCyDkilzDd+jkyP9jjX9MT4IZz/9iiwQ24IBJlP7tWffK7+6OFJBlwTJaCchOoUzoZzvbwA=;25:VzcTly80RRwj4gI3+Q7PSTj8PDETWIaNnsfr+cIO9yQ6x2Zk0SlwWj+sGTZaTekLNs1gug/XK6kybTXC/Do01C3frhH1LGiJO/zwMy9QI/LIJwAX11CuXtsG5lOsX02fxfLCc+jnySW8WWC2VQlz9s6ao5A+XflJZn9/mhQL0AUipd7rwZzbilwXwAhWDeJyGGTtamu3H8ept44EQAi5BDS+T5Dv9vE0mPcy2MrTYv9AyQ1nC/Y1JKbEMMostCDH X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0301MB1281;UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0301MB1313; X-Microsoft-Exchange-Diagnostics: 1;BN3PR0301MB1281;20:hvVbJta8iESiqyhL0IRqHM+DkCGo0aJbrRFIGrP+oBI93kcLop+A/L3o/PSy7TwP+KnfSC6o4F91d1O4sKR2KSIq7V/iiZ2TbsnkuXUTxIETWMDGSQDOJsAa0ZD8HHNR8Lc7q9mLl02WISo560GsJJtzRqx8KGwUoAuuSOczqFbObRMO8joxOCjte+H1g78b1fFzZ/QiAbvSm0u5vOONcHMyGEiLaooalXY9ezjNwN9466y07nV9BEfLj/s98+643K1iU6XZc3g/4SMzhjwmQcvwCZNF4/XsskcAfOeh6sGqgzFnXbkl+5OMMKHQXgr2a9hJ4m8cU8tcDEW8D8nrWqNqSXH2Rbxi0o1vN2JsSWg=;4:6OQ8C9JWBDuDVXMzA9ksBWT+3vT9YFzqCkK51q4542n7V13v9TyS3lZOsEeV06IcJD1R+2MsUm2grtRtscLbQmaoUP7pT4vyH85JANUFQ9zQmtHdXZOC/+bnCknIBe/wcfGgSXPbbqIFOOv8deVEtBbXhlxOtfpHBGYu09nG3S+9SpOgp10zCQqupmqhiFDmrHBFSZLRQtuyNizse6dLEMuEeMhivKYPxcCPc/avp+XcM3Yy+Ht2/4Y0VGSKzIEY/kfgI8K22HhjOTHBjHVhVIVW0jl5cKNX01oAzyyptPQ= BN3PR0301MB1281: X-MS-Exchange-Organization-RulesExecuted X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:BN3PR0301MB1281;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0301MB1281; X-Forefront-PRVS: 06530126A4 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN3PR0301MB1281;23:+Q3Tw8MXIfeX0uIUe3gIubXSw5jxKWTE4NDbAFg?= =?us-ascii?Q?/92XrGq49jQ52xa2QFxt9tU8e2Wb0jHbSnXW1we+Ds6E+WRw83ILSR/hpI0q?= =?us-ascii?Q?oiteaavYtIoKYkmwJUgutiz4ouBQCl1uoxdTLSgG7fMZrrPyWVJuUoQ2rT7R?= =?us-ascii?Q?buIvvm/sVO9GQYBG5BCyTpA9FTC2zNonXvAWmyJpfA5/iI7J+vaNngxff5rq?= =?us-ascii?Q?59ZFoqJX/GHKuebGLOZg5AI6/6gzYyGuhUIxWGhYRG5HTEg2pBd2V4RxIUMs?= =?us-ascii?Q?WGj3bR/CCMuolmQEh1k7utS8eVoqOOfjOuAEycWIhG0SlyNxQ+m5oLocZ+Me?= =?us-ascii?Q?2/WKE8PmTgQwgksv1cnSNmUsPy11zDNoS75Fnakw7ldjZ61y3POgs9Tq32UZ?= =?us-ascii?Q?zGeNLYGmF2+Evm6ROmycxFcL5PJy8p/SaGEhY+drcCJBOv92slxekD7jmaRA?= =?us-ascii?Q?VQejf6zWZidfVeqGGQp5Cu2CffWmymgbh6865psdp6oLW+OJiehkBGdkseW4?= =?us-ascii?Q?vyfiTzAa8lVlPPEhxqLEJU4a2VCXHbXpDsk0c8qq2wO9I+gRbggIpUAVEnwy?= =?us-ascii?Q?sArk//QG3q/08wHQJZmaf2d00PzJcANWa2zEW7f81z6+3zbXfWVw44uRMWUE?= =?us-ascii?Q?xJZ6lmSeRWfulJMOKMTnXzNXT6A8q3CZogUQil4h0JYQYY+voxuNox9MC4Hj?= =?us-ascii?Q?H7FvjmtfT66PNk+F7Ih720iR3LYHgMmYEBbc+UtctI+/IVnn/3CsC6gXLzIp?= =?us-ascii?Q?vq2JsL0RO5vwp0ADAQx4/7b+9uZLufPkt0qNs1VrdOhGhTW/YLFojXhzLBk5?= =?us-ascii?Q?Idr6k9xzng7HHPd4YeUcjzqhcmsQYDKIJ/jK/FpphzAGgCq9XMz5XMZPKR7x?= =?us-ascii?Q?Xn8y16DS23+ptzn2vxaVMdSUpi9bxXidkX/vIvifemCkn1P0f3fwawphqGkq?= =?us-ascii?Q?uFswOSFjGxkS2GCNyN+IE3CUK4R2yF4gF1rNtqCcimQ=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;BN3PR0301MB1281;5:IXPW1Kr+zdga0DIkIhTXLdWs4Okmcmk1q68l0XmWtIZSH1M0SOn1xjQn1kzY3qfmkuNz2nHYTrGcxxEqkEz+I5c3v7L7jF2GQ/baRTaYO9wDRQhZm1j4t9/LyHI62gv4Pnv+3R/vAP6fxUVu1Kgv4w==;24:dpYJbfLcoePEGS8e2+QQfJ9Zwo0sHti98E3QxIp5qL+LbyWo1Mp9UQwfd438P2ehkn5h0OzQDme/Qms5x423nroy9mHQE7zadyscqEVfCLo=;20:0DOyUlY+VONockBNQ1TfUFvbEhP0t4Os4akb892FuTmmlZPlgLbxqWgcZSrG5MP6xUWX1olKiFsrVxzKNpr4OQ== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2015 07:27:24.2425 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0301MB1281 X-Microsoft-Exchange-Diagnostics: 1;BN3PR0301MB1313;2:KyzzSeRAnAqBovISvo6oBKYTsur4AGnfng6CuQRM/NGG5EDyLDeM/mm4Y177bhHobEMIKjfgIOUzdpzxjcbINiWYU4NNgwJ5RMsPMLulesNW1Ck6r4Aj32bmEvNZJdRet37SlgmKgDHDCLCk3Ff4Jl7XwXCZgUKbn2Sfl+LX48E=;3:5LP9jbX34pVvevE+M+NUaklAv+jlDzBQsYueci/LtRMQ1oos0i9aPCA1C0qut/Wlz0rQu5dfmUPcY0lQo0JpM/KCPWb+Hy3RMBV0F0Y+aTRnF1nCq2PrIqSAZWIOrkjSyUul1LZ1Sz3Hgoy6MqV4YSs8LwT02aMMQ0V/xIi88PaN/4Nok9IEgCftc6lGKMpgpCneYOiSluFgzCSdqSagVGoxfftCAy+TnDoNYYLCJwA=;25:YXEFR6T/PVTWA88UmWkgU5LvJFwJfvUJYMGFwKfUtgGOWbHCP8AfGw0etqcayXM9RkBOuLcYZBlBspLmCBnzrWHWBaAcIMWpEOaztwduZTQ1Gl3Os2NWAzJ4rWpaEm10GmFkwPs8PJv1Msyl838jqViUzNguB3MeKVgQt75eiDpy6eQZqAK6C22547MySNnAZBfA5Xp7f+FDYRyyn/cd/E5axRrjK50DmlzCyQTaSZUoYk/a1E7LfAYnnnkyQYWs;23:WxgeqTy5UTx/Tv4OmveguqgA6MHwMTF4dX0BkMgF8FkLh5Kq/kSxxfIj1HbNuiuKgqrZVGWwz8Jee8XfvJIvKmQVQesLrGD8lE3CgYqmhTlMNMPfhOVkFX7qH/q+Ve/4q/tR0Ztk0UOI4YX45qErICtJXJ58gb7BVz/F4sDJ3cMKeAXt1mzZNGm8yZYjVKUs X-OriginatorOrg: freescale.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 8094 Lines: 220 LS1021a-qds has the same ip block/controller as GPIO on powerpc platform(MPC8XXX). So use portable i/o accessors, as in_be32/out_be32 accessors are Power architecture specific whereas ioread/writebe32 are available in other architectures. GPIO controller's registers are big endian, the accessors ioread32be/iowrite32be matches this one and portable on powerpc as well on ARM. Signed-off-by: Shaveta Leekha --- Tested on Freescale SDK 1.8, as LS1021aQDS support is not yet complete in upstream drivers/gpio/gpio-mpc8xxx.c | 53 ++++++++++++++++++++++++++---------------- 1 files changed, 33 insertions(+), 20 deletions(-) diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c index 8ef7a12..9cd90e8 100644 --- a/drivers/gpio/gpio-mpc8xxx.c +++ b/drivers/gpio/gpio-mpc8xxx.c @@ -1,5 +1,5 @@ /* - * GPIOs on MPC512x/8349/8572/8610 and compatible + * GPIOs on MPC512x/8349/8572/8610/LS1020A and compatible * * Copyright (C) 2008 Peter Korsgaard * @@ -19,6 +19,7 @@ #include #include #include +#include #define MPC8XXX_GPIO_PINS 32 @@ -59,9 +60,17 @@ static void mpc8xxx_gpio_save_regs(struct of_mm_gpio_chip *mm) { struct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm); - mpc8xxx_gc->data = in_be32(mm->regs + GPIO_DAT); + mpc8xxx_gc->data = ioread32be(mm->regs + GPIO_DAT); } +/* Generic set and clear bits accessor ports */ +#define bgpio_setbits32(_addr, _v) \ + iowrite32be(ioread32be(_addr) | (_v), (_addr)) +#define bgpio_clrbits32(_addr, _v) \ + iowrite32be(ioread32be(_addr) & ~(_v), (_addr)) +#define bgpio_clrsetbits32(addr, clear, set) \ + iowrite32be((ioread32be(addr) & ~(clear)) | (set), (addr)) + /* Workaround GPIO 1 errata on MPC8572/MPC8536. The status of GPIOs * defined as output cannot be determined by reading GPDAT register, * so we use shadow data register instead. The status of input pins @@ -74,9 +83,9 @@ static int mpc8572_gpio_get(struct gpio_chip *gc, unsigned int gpio) struct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm); u32 out_mask, out_shadow; - out_mask = in_be32(mm->regs + GPIO_DIR); + out_mask = ioread32be(mm->regs + GPIO_DIR); - val = in_be32(mm->regs + GPIO_DAT) & ~out_mask; + val = ioread32be(mm->regs + GPIO_DAT) & ~out_mask; out_shadow = mpc8xxx_gc->data & out_mask; return (val | out_shadow) & mpc8xxx_gpio2mask(gpio); @@ -86,7 +95,7 @@ static int mpc8xxx_gpio_get(struct gpio_chip *gc, unsigned int gpio) { struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc); - return in_be32(mm->regs + GPIO_DAT) & mpc8xxx_gpio2mask(gpio); + return ioread32be(mm->regs + GPIO_DAT) & mpc8xxx_gpio2mask(gpio); } static void mpc8xxx_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val) @@ -102,7 +111,7 @@ static void mpc8xxx_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val) else mpc8xxx_gc->data &= ~mpc8xxx_gpio2mask(gpio); - out_be32(mm->regs + GPIO_DAT, mpc8xxx_gc->data); + iowrite32be(mpc8xxx_gc->data, mm->regs + GPIO_DAT); raw_spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags); } @@ -128,7 +137,7 @@ static void mpc8xxx_gpio_set_multiple(struct gpio_chip *gc, } } - out_be32(mm->regs + GPIO_DAT, mpc8xxx_gc->data); + iowrite32be(mpc8xxx_gc->data, mm->regs + GPIO_DAT); raw_spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags); } @@ -141,7 +150,7 @@ static int mpc8xxx_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio) raw_spin_lock_irqsave(&mpc8xxx_gc->lock, flags); - clrbits32(mm->regs + GPIO_DIR, mpc8xxx_gpio2mask(gpio)); + bgpio_clrbits32(mm->regs + GPIO_DIR, mpc8xxx_gpio2mask(gpio)); raw_spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags); @@ -158,7 +167,7 @@ static int mpc8xxx_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val raw_spin_lock_irqsave(&mpc8xxx_gc->lock, flags); - setbits32(mm->regs + GPIO_DIR, mpc8xxx_gpio2mask(gpio)); + bgpio_setbits32(mm->regs + GPIO_DIR, mpc8xxx_gpio2mask(gpio)); raw_spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags); @@ -201,7 +210,8 @@ static void mpc8xxx_gpio_irq_cascade(unsigned int irq, struct irq_desc *desc) struct of_mm_gpio_chip *mm = &mpc8xxx_gc->mm_gc; unsigned int mask; - mask = in_be32(mm->regs + GPIO_IER) & in_be32(mm->regs + GPIO_IMR); + mask = ioread32be(mm->regs + GPIO_IER) + & ioread32be(mm->regs + GPIO_IMR); if (mask) generic_handle_irq(irq_linear_revmap(mpc8xxx_gc->irq, 32 - ffs(mask))); @@ -217,7 +227,8 @@ static void mpc8xxx_irq_unmask(struct irq_data *d) raw_spin_lock_irqsave(&mpc8xxx_gc->lock, flags); - setbits32(mm->regs + GPIO_IMR, mpc8xxx_gpio2mask(irqd_to_hwirq(d))); + bgpio_setbits32(mm->regs + GPIO_IMR, + mpc8xxx_gpio2mask(irqd_to_hwirq(d))); raw_spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags); } @@ -230,7 +241,8 @@ static void mpc8xxx_irq_mask(struct irq_data *d) raw_spin_lock_irqsave(&mpc8xxx_gc->lock, flags); - clrbits32(mm->regs + GPIO_IMR, mpc8xxx_gpio2mask(irqd_to_hwirq(d))); + bgpio_clrbits32(mm->regs + GPIO_IMR, + mpc8xxx_gpio2mask(irqd_to_hwirq(d))); raw_spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags); } @@ -240,7 +252,7 @@ static void mpc8xxx_irq_ack(struct irq_data *d) struct mpc8xxx_gpio_chip *mpc8xxx_gc = irq_data_get_irq_chip_data(d); struct of_mm_gpio_chip *mm = &mpc8xxx_gc->mm_gc; - out_be32(mm->regs + GPIO_IER, mpc8xxx_gpio2mask(irqd_to_hwirq(d))); + iowrite32be(mpc8xxx_gpio2mask(irqd_to_hwirq(d)), mm->regs + GPIO_IER); } static int mpc8xxx_irq_set_type(struct irq_data *d, unsigned int flow_type) @@ -252,14 +264,14 @@ static int mpc8xxx_irq_set_type(struct irq_data *d, unsigned int flow_type) switch (flow_type) { case IRQ_TYPE_EDGE_FALLING: raw_spin_lock_irqsave(&mpc8xxx_gc->lock, flags); - setbits32(mm->regs + GPIO_ICR, + bgpio_setbits32(mm->regs + GPIO_ICR, mpc8xxx_gpio2mask(irqd_to_hwirq(d))); raw_spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags); break; case IRQ_TYPE_EDGE_BOTH: raw_spin_lock_irqsave(&mpc8xxx_gc->lock, flags); - clrbits32(mm->regs + GPIO_ICR, + bgpio_clrbits32(mm->regs + GPIO_ICR, mpc8xxx_gpio2mask(irqd_to_hwirq(d))); raw_spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags); break; @@ -292,20 +304,20 @@ static int mpc512x_irq_set_type(struct irq_data *d, unsigned int flow_type) case IRQ_TYPE_EDGE_FALLING: case IRQ_TYPE_LEVEL_LOW: raw_spin_lock_irqsave(&mpc8xxx_gc->lock, flags); - clrsetbits_be32(reg, 3 << shift, 2 << shift); + bgpio_clrsetbits32(reg, 3 << shift, 2 << shift); raw_spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags); break; case IRQ_TYPE_EDGE_RISING: case IRQ_TYPE_LEVEL_HIGH: raw_spin_lock_irqsave(&mpc8xxx_gc->lock, flags); - clrsetbits_be32(reg, 3 << shift, 1 << shift); + bgpio_clrsetbits32(reg, 3 << shift, 1 << shift); raw_spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags); break; case IRQ_TYPE_EDGE_BOTH: raw_spin_lock_irqsave(&mpc8xxx_gc->lock, flags); - clrbits32(reg, 3 << shift); + bgpio_clrbits32(reg, 3 << shift); raw_spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags); break; @@ -373,6 +385,7 @@ static const struct of_device_id mpc8xxx_gpio_ids[] = { { .compatible = "fsl,mpc5125-gpio", .data = &mpc5125_gpio_devtype, }, { .compatible = "fsl,pq3-gpio", }, { .compatible = "fsl,qoriq-gpio", }, + { .compatible = "fsl,ls1021a-gpio", }, {} }; @@ -435,8 +448,8 @@ static int mpc8xxx_probe(struct platform_device *pdev) mpc8xxx_gc->of_dev_id_data = id->data; /* ack and mask all irqs */ - out_be32(mm_gc->regs + GPIO_IER, 0xffffffff); - out_be32(mm_gc->regs + GPIO_IMR, 0); + iowrite32be(0xffffffff, mm_gc->regs + GPIO_IER); + iowrite32be(0, mm_gc->regs + GPIO_IMR); irq_set_chained_handler_and_data(mpc8xxx_gc->irqn, mpc8xxx_gpio_irq_cascade, mpc8xxx_gc); -- 1.7.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/