From: Wolfram Sang <w.sang@pengutronix.de>
To: Rabin VINCENT <rabin.vincent@stericsson.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Linus WALLEIJ <linus.walleij@stericsson.com>,
Samuel Ortiz <sameo@linux.intel.com>
Subject: Re: [RFC] gpio/stmpe: add bitmask to block requests to unavailable GPIOs
Date: Wed, 18 Aug 2010 12:31:37 +0200 [thread overview]
Message-ID: <20100818103137.GB3528@pengutronix.de> (raw)
In-Reply-To: <20100818100950.GA19706@bnru01.bnr.st.com>
[-- Attachment #1: Type: text/plain, Size: 3605 bytes --]
On Wed, Aug 18, 2010 at 03:39:50PM +0530, Rabin VINCENT wrote:
> On Mon, Aug 16, 2010 at 17:14:44 +0200, Wolfram Sang wrote:
> > GPIOs on these controller are multi-functional. If you decided to use
> > some of them e.g. as input channels for the ADC, you surely don't want
> > those pins to be reassigned as simple GPIOs (which may be triggered even
> > from userspace via 'export'). Same for the touchscreen controller pins.
> > Since knowledge about the hardware is needed to decide which GPIOs to
> > reserve, let this bitmask be inside platform_data and provide some
> > defines to assist potential users.
>
> Could this be done without the platform data, say something like the
> below? (Though this does assume that nobody tries to request GPIOs
> before the STMPE subdrivers reserve their pins.)
>
While I'd also like to skip the additional platform_data entry, your
last comment is in deed a drawback. Also, when thinking of a generic
solution (ADC comes to my mind), you can't make an assumption which pins
will have the alternate function as you can do with the touchscreen
driver. If a pin is an ADC-input channel or a GPIO, that is board
design.
Regards,
Wolfram
> diff --git a/drivers/input/touchscreen/stmpe-ts.c b/drivers/input/touchscreen/stmpe-ts.c
> index 656148e..d1595f9 100644
> --- a/drivers/input/touchscreen/stmpe-ts.c
> +++ b/drivers/input/touchscreen/stmpe-ts.c
> @@ -179,6 +179,12 @@ static int __devinit stmpe_init_hw(struct stmpe_touch *ts)
> return ret;
> }
>
> + ret = stmpe_set_altfunc(stmpe, 0xf0, STMPE_BLOCK_TOUCHSCREEN);
> + if (ret) {
> + dev_err(dev, "Could not enable alternate function for pins\n");
> + return ret;
> + }
> +
> adc_ctrl1 = SAMPLE_TIME(ts->sample_time) | MOD_12B(ts->mod_12b) |
> REF_SEL(ts->ref_sel);
> adc_ctrl1_mask = SAMPLE_TIME(0xff) | MOD_12B(0xff) | REF_SEL(0xff);
> diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c
> index 0754c5e9..4f748fa 100644
> --- a/drivers/mfd/stmpe.c
> +++ b/drivers/mfd/stmpe.c
> @@ -253,6 +253,12 @@ int stmpe_set_altfunc(struct stmpe *stmpe, u32 pins, enum stmpe_block block)
>
> mutex_lock(&stmpe->lock);
>
> + if (block == STMPE_BLOCK_GPIO && (pins & stmpe->af_pins)) {
> + dev_dbg(stmpe->dev, "not allowing change of AF pins to GPIO\n");
> + ret = -EBUSY;
> + goto out;
> + }
> +
> ret = __stmpe_enable(stmpe, STMPE_BLOCK_GPIO);
> if (ret < 0)
> goto out;
> @@ -274,6 +280,11 @@ int stmpe_set_altfunc(struct stmpe *stmpe, u32 pins, enum stmpe_block block)
> pins &= ~(1 << pin);
> }
>
> + if (block == STMPE_BLOCK_GPIO)
> + stmpe->af_pins &= ~pins;
> + else
> + stmpe->af_pins |= pins;
> +
> ret = __stmpe_block_write(stmpe, regaddr, numregs, regs);
>
> out:
> diff --git a/include/linux/mfd/stmpe.h b/include/linux/mfd/stmpe.h
> index 39ca758..ba5a847 100644
> --- a/include/linux/mfd/stmpe.h
> +++ b/include/linux/mfd/stmpe.h
> @@ -64,6 +64,7 @@ struct stmpe_variant_info;
> * @num_gpios: number of gpios, differs for variants
> * @ier: cache of IER registers for bus_lock
> * @oldier: cache of IER registers for bus_lock
> + * @af_pins: mask of pins set in alternate function mode
> * @pdata: platform data
> */
> struct stmpe {
> @@ -79,6 +80,7 @@ struct stmpe {
> int num_gpios;
> u8 ier[2];
> u8 oldier[2];
> + u32 af_pins;
> struct stmpe_platform_data *pdata;
> };
>
--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
next prev parent reply other threads:[~2010-08-18 10:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-16 15:14 [RFC] gpio/stmpe: add bitmask to block requests to unavailable GPIOs Wolfram Sang
2010-08-18 10:09 ` Rabin VINCENT
2010-08-18 10:31 ` Wolfram Sang [this message]
2010-08-19 13:06 ` Rabin Vincent
2010-08-19 13:26 ` Wolfram Sang
2010-08-20 22:25 ` Samuel Ortiz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100818103137.GB3528@pengutronix.de \
--to=w.sang@pengutronix.de \
--cc=linus.walleij@stericsson.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rabin.vincent@stericsson.com \
--cc=sameo@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).