Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934238Ab3FSIkJ (ORCPT ); Wed, 19 Jun 2013 04:40:09 -0400 Received: from mail-oa0-f49.google.com ([209.85.219.49]:35052 "EHLO mail-oa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933755Ab3FSIkG (ORCPT ); Wed, 19 Jun 2013 04:40:06 -0400 MIME-Version: 1.0 In-Reply-To: <1371589469-32700-2-git-send-email-kevin.strasser@linux.intel.com> References: <1365441321-21952-1-git-send-email-kevin.strasser@linux.intel.com> <1371589469-32700-1-git-send-email-kevin.strasser@linux.intel.com> <1371589469-32700-2-git-send-email-kevin.strasser@linux.intel.com> Date: Wed, 19 Jun 2013 10:40:04 +0200 Message-ID: Subject: Re: [PATCH v2 1/4] mfd: Kontron PLD mfd driver From: Linus Walleij To: Kevin Strasser Cc: "linux-kernel@vger.kernel.org" , Darren Hart , Samuel Ortiz , Guenter Roeck , Michael Brunner , Michael Brunner , Chris Healy , Thomas Gleixner , Dirk Hohndel , Wolfram Sang , Ben Dooks , Grant Likely , Wim Van Sebroeck , Mark Brown Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4407 Lines: 125 On Tue, Jun 18, 2013 at 11:04 PM, Kevin Strasser wrote: > Add core MFD driver for the on-board PLD found on some Kontron embedded > modules. The PLD device may provide functions like watchdog, GPIO, UART > and I2C bus. > > The following modules are supported: > * COMe-bIP# > * COMe-bPC2 (ETXexpress-PC) > * COMe-bSC# (ETXexpress-SC T#) > * COMe-cCT6 > * COMe-cDC2 (microETXexpress-DC) > * COMe-cPC2 (microETXexpress-PC) > * COMe-mCT10 > * ETX-OH > > Signed-off-by: Kevin Strasser > Signed-off-by: Michael Brunner > Acked-by: Guenter Roeck > Acked-by: Darren Hart (...) > +/** > + * kempld_read8 - read 8 bit register > + * @pld: kempld_device_data structure describing the PLD > + * @index: register index on the chip > + * > + * kempld_get_mutex must be called prior to calling this function. > + */ > +u8 kempld_read8(struct kempld_device_data *pld, u8 index) > +{ > + iowrite8(index, pld->io_index); > + return ioread8(pld->io_data); > +} > +EXPORT_SYMBOL_GPL(kempld_read8); > + > +/** > + * kempld_write8 - write 8 bit register > + * @pld: kempld_device_data structure describing the PLD > + * @index: register index on the chip > + * @data: new register value > + * > + * kempld_get_mutex must be called prior to calling this function. > + */ > +void kempld_write8(struct kempld_device_data *pld, u8 index, u8 data) > +{ > + iowrite8(index, pld->io_index); > + iowrite8(data, pld->io_data); > +} > +EXPORT_SYMBOL_GPL(kempld_write8); > + > +/** > + * kempld_read16 - read 16 bit register > + * @pld: kempld_device_data structure describing the PLD > + * @index: register index on the chip > + * > + * kempld_get_mutex must be called prior to calling this function. > + */ > +u16 kempld_read16(struct kempld_device_data *pld, u8 index) > +{ > + return kempld_read8(pld, index) | kempld_read8(pld, index + 1) << 8; > +} > +EXPORT_SYMBOL_GPL(kempld_read16); > + > +/** > + * kempld_write16 - write 16 bit register > + * @pld: kempld_device_data structure describing the PLD > + * @index: register index on the chip > + * @data: new register value > + * > + * kempld_get_mutex must be called prior to calling this function. > + */ > +void kempld_write16(struct kempld_device_data *pld, u8 index, u16 data) > +{ > + kempld_write8(pld, index, (u8)data); > + kempld_write8(pld, index + 1, (u8)(data >> 8)); > +} > +EXPORT_SYMBOL_GPL(kempld_write16); > + > +/** > + * kempld_read32 - read 32 bit register > + * @pld: kempld_device_data structure describing the PLD > + * @index: register index on the chip > + * > + * kempld_get_mutex must be called prior to calling this function. > + */ > +u32 kempld_read32(struct kempld_device_data *pld, u8 index) > +{ > + return kempld_read16(pld, index) | kempld_read16(pld, index + 2) << 16; > +} > +EXPORT_SYMBOL_GPL(kempld_read32); > + > +/** > + * kempld_write32 - write 32 bit register > + * @pld: kempld_device_data structure describing the PLD > + * @index: register index on the chip > + * @data: new register value > + * > + * kempld_get_mutex must be called prior to calling this function. > + */ > +void kempld_write32(struct kempld_device_data *pld, u8 index, u32 data) > +{ > + kempld_write16(pld, index, (u16)data); > + kempld_write16(pld, index + 2, (u16)(data >> 16)); > +} > +EXPORT_SYMBOL_GPL(kempld_write32); (...) > +extern u8 kempld_read8(struct kempld_device_data *pld, u8 index); > +extern void kempld_write8(struct kempld_device_data *pld, u8 index, u8 data); > +extern u16 kempld_read16(struct kempld_device_data *pld, u8 index); > +extern void kempld_write16(struct kempld_device_data *pld, u8 index, u16 data); > +extern u32 kempld_read32(struct kempld_device_data *pld, u8 index); > +extern void kempld_write32(struct kempld_device_data *pld, u8 index, u32 data); Not really my business, but I think if I was to implement this inter-module API I would use regmap for this read/write marshalling right here. Yours, Linus Walleij -- 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/