Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422826AbWLUPDq (ORCPT ); Thu, 21 Dec 2006 10:03:46 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1422832AbWLUPDq (ORCPT ); Thu, 21 Dec 2006 10:03:46 -0500 Received: from an-out-0708.google.com ([209.85.132.242]:31754 "EHLO an-out-0708.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422826AbWLUPDp (ORCPT ); Thu, 21 Dec 2006 10:03:45 -0500 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=L8oMDR0rEjeDN4jegj/dK/ep+6oTX21N1iQml0u2Fso09ahCJAzbxDXfXCY4lMWlAB9PsQ+Pv7UPf9Th5mp4YzICGR1TWU3fCR9d36AiOpyMD8f/3zLrHevaIMzaesAAHS75paEZS+X/atyAh0maJsReUBwDcA6kd0l8hxNTeGQ= Message-ID: <74d0deb30612210703y735e53kf14e7c800dae7140@mail.gmail.com> Date: Thu, 21 Dec 2006 16:03:42 +0100 From: "pHilipp Zabel" To: "Nicolas Pitre" Subject: Re: [patch 2.6.20-rc1 4/6] PXA GPIO wrappers Cc: "David Brownell" , "Andrew Morton" , "Linux Kernel list" , "Andrew Victor" , "Bill Gatliff" , "Haavard Skinnemoen" , jamey.hicks@hp.com, "Kevin Hilman" , "Russell King" , "Tony Lindgren" In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_33797_20942520.1166713422990" References: <200611111541.34699.david-b@pacbell.net> <200612201312.36616.david-b@pacbell.net> <20061220221252.732f4e97.akpm@osdl.org> <200612202244.03351.david-b@pacbell.net> Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 10804 Lines: 265 ------=_Part_33797_20942520.1166713422990 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 12/21/06, Nicolas Pitre wrote: > On Wed, 20 Dec 2006, David Brownell wrote: > > > On Wednesday 20 December 2006 10:12 pm, Andrew Morton wrote: > > > Why not implement them as inline functions? > > > > I just collected and forwarded the code from Philip... > > the better not to lose such stuff! :) > > > > > > > Or non-inline functions, come to that. > > > > In this case I think that'd be preferable; see what those macros > > expand to on pxa27x CPUs. > > Only if the gpio argument is not constant please. When it is constant > this expands to a single word store. > > > Nicolas David suggested to have both inline and non-inline functions depending on whether gpio is constant. How is this patch? regards Philipp Index: linux-2.6/include/asm-arm/arch-pxa/gpio.h =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ linux-2.6/include/asm-arm/arch-pxa/gpio.h 2006-12-21 07:57:12.000000000 +0100 @@ -0,0 +1,86 @@ +/* + * linux/include/asm-arm/arch-pxa/gpio.h + * + * PXA GPIO wrappers for arch-neutral GPIO calls + * + * Written by Philipp Zabel + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef __ASM_ARCH_PXA_GPIO_H +#define __ASM_ARCH_PXA_GPIO_H + +#include +#include +#include + +#include + +static inline int gpio_request(unsigned gpio, const char *label) +{ + return 0; +} + +static inline void gpio_free(unsigned gpio) +{ + return; +} + +static inline int gpio_direction_input(unsigned gpio) +{ + if (gpio > PXA_LAST_GPIO) + return -EINVAL; + pxa_gpio_mode(gpio | GPIO_IN); +} + +static inline int gpio_direction_output(unsigned gpio) +{ + if (gpio > PXA_LAST_GPIO) + return -EINVAL; + pxa_gpio_mode(gpio | GPIO_OUT); +} + +static inline int __gpio_get_value(unsigned gpio) +{ + return GPLR(gpio) & GPIO_bit(gpio); +} + +#define gpio_get_value(gpio) \ + (__builtin_constant_p(gpio) ? \ + __gpioe_get_value(gpio) : \ + pxa_gpio_get_value(gpio)) + +static inline void __gpio_set_value(unsigned gpio, int value) +{ + if (value) + GPSR(gpio) = GPIO_bit(gpio); + else + GPCR(gpio) = GPIO_bit(gpio); +} + +#define gpio_set_value(gpio,value) \ + (__builtin_constant_p(gpio) ? \ + __gpio_set_value(gpio, value) : \ + pxa_gpio_set_value(gpio, value)) + +#include /* cansleep wrappers */ + +#define gpio_to_irq(gpio) IRQ_GPIO(gpio) +#define irq_to_gpio(irq) IRQ_TO_GPIO(irq) + + +#endif Index: linux-2.6/arch/arm/mach-pxa/generic.c =================================================================== --- linux-2.6.orig/arch/arm/mach-pxa/generic.c 2006-12-16 16:47:42.000000000 +0100 +++ linux-2.6/arch/arm/mach-pxa/generic.c 2006-12-16 16:47:45.000000000 +0100 @@ -129,6 +129,29 @@ EXPORT_SYMBOL(pxa_gpio_mode); /* + * Return GPIO level, nonzero means high, zero is low + */ +int pxa_gpio_get_value(unsigned gpio) +{ + return GPLR(gpio) & GPIO_bit(gpio); +} + +EXPORT_SYMBOL(pxa_gpio_get_value); + +/* + * Set output GPIO level + */ +void pxa_gpio_set_value(unsigned gpio, int value) +{ + if (value) + GPSR(gpio) = GPIO_bit(gpio); + else + GPCR(gpio) = GPIO_bit(gpio); +} + +EXPORT_SYMBOL(pxa_gpio_set_value); + +/* * Routine to safely enable or disable a clock in the CKEN */ void pxa_set_cken(int clock, int enable) Index: linux-2.6/include/asm-arm/arch-pxa/hardware.h =================================================================== --- linux-2.6.orig/include/asm-arm/arch-pxa/hardware.h 2006-12-17 15:42:36.000000000 +0100 +++ linux-2.6/include/asm-arm/arch-pxa/hardware.h 2006-12-17 15:43:26.000000000 +0100 @@ -68,6 +68,16 @@ extern void pxa_gpio_mode( int gpio_mode ); /* + * Return GPIO level, nonzero means high, zero is low + */ +extern int pxa_gpio_get_value(unsigned gpio); + +/* + * Set output GPIO level + */ +extern void pxa_gpio_set_value(unsigned gpio, int value); + +/* * Routine to enable or disable CKEN */ extern void pxa_set_cken(int clock, int enable); ------=_Part_33797_20942520.1166713422990 Content-Type: text/x-patch; name=gpio-api-pxa.patch; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: base64 X-Attachment-Id: f_evzaxbyc Content-Disposition: attachment; filename="gpio-api-pxa.patch" SW5kZXg6IGxpbnV4LTIuNi9pbmNsdWRlL2FzbS1hcm0vYXJjaC1weGEvZ3Bpby5oCj09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT0KLS0tIC9kZXYvbnVsbAkxOTcwLTAxLTAxIDAwOjAwOjAwLjAwMDAwMDAwMCArMDAwMAorKysg bGludXgtMi42L2luY2x1ZGUvYXNtLWFybS9hcmNoLXB4YS9ncGlvLmgJMjAwNi0xMi0yMSAwNzo1 NzoxMi4wMDAwMDAwMDAgKzAxMDAKQEAgLTAsMCArMSw4NiBAQAorLyoKKyAqIGxpbnV4L2luY2x1 ZGUvYXNtLWFybS9hcmNoLXB4YS9ncGlvLmgKKyAqCisgKiBQWEEgR1BJTyB3cmFwcGVycyBmb3Ig YXJjaC1uZXV0cmFsIEdQSU8gY2FsbHMKKyAqCisgKiBXcml0dGVuIGJ5IFBoaWxpcHAgWmFiZWwg PHBoaWxpcHAuemFiZWxAZ21haWwuY29tPgorICoKKyAqIFRoaXMgcHJvZ3JhbSBpcyBmcmVlIHNv ZnR3YXJlOyB5b3UgY2FuIHJlZGlzdHJpYnV0ZSBpdCBhbmQvb3IgbW9kaWZ5CisgKiBpdCB1bmRl ciB0aGUgdGVybXMgb2YgdGhlIEdOVSBHZW5lcmFsIFB1YmxpYyBMaWNlbnNlIGFzIHB1Ymxpc2hl ZCBieQorICogdGhlIEZyZWUgU29mdHdhcmUgRm91bmRhdG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VkIGdwaW8sIGlu dCB2YWx1ZSk7CisKKy8qCiAgKiBSb3V0aW5lIHRvIGVuYWJsZSBvciBkaXNhYmxlIENLRU4KICAq LwogZXh0ZXJuIHZvaWQgcHhhX3NldF9ja2VuKGludCBjbG9jaywgaW50IGVuYWJsZSk7Cg== ------=_Part_33797_20942520.1166713422990-- - 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/