public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
To: "Rogério de Souza Moraes"
	<rogerio.souza-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: I2C driver modification for BH1710FVC Ambient Light Sensor
Date: Mon, 30 Aug 2010 17:58:36 +0200	[thread overview]
Message-ID: <20100830175836.65260450@hyperion.delvare> (raw)
In-Reply-To: <AANLkTinzBkHsLO3TqwoPFb3AjVQ5xziSg_F7wFtB0c0R-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

Hi Rogério,

On Mon, 30 Aug 2010 12:33:26 -0300, Rogério de Souza Moraes wrote:
> Hi folks,
> 
> I am developing a driver for the Ambient Light Sensor BH1710FVC that
> communicates by i2c bus. My problem is that the type of message that
> this chip accept is this:
> 
> S Addr Rd [A] [DataHigh] A [DataLow] NA P
> 
> I searched in the file "Documentation/i2c/smbus-protocol" for one
> function that communicate like this, but I did not find. I tried to
> use the function i2c_smbus_read_byte twice (reading data high first
> and so the data low), but the chip do not accept communicate this way.
> 
> So I've based in the function i2c_smbus_read_byte to build the
> function that implements the protocol like I need.
> 
> I modified the file i2c-core.c in the function i2c_smbus_xfer_emulated
> creating an I2C_SMBUS_WORD.
> In first switch I add:
> 
>         case I2C_SMBUS_WORD:
>                 if (read_write == I2C_SMBUS_READ) {
>                         msg[0].len = 2;
>                         msg[0].flags = I2C_M_RD | flags;
>                         num = 1;
>                 }
>                 break;
> 
> and for the second switch I added the following case:
> 
>                         case I2C_SMBUS_WORD:
>                                 data->word = msgbuf0[0] | (msgbuf0[1] << 8);
>                                 break;
> 
> After this modification my Ambient Light Sensor driver is working just fine.
> 
> So I want to know if there is a better way to implement this without
> need to modify the i2c driver.

As the transaction format you need isn't part of SMBus, I assume that
your controller is an I2C master and you should simply use
i2c_master_recv() in your device driver.

-- 
Jean Delvare

      parent reply	other threads:[~2010-08-30 15:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-30 15:33 I2C driver modification for BH1710FVC Ambient Light Sensor Rogério de Souza Moraes
     [not found] ` <AANLkTinzBkHsLO3TqwoPFb3AjVQ5xziSg_F7wFtB0c0R-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-08-30 15:58   ` Jean Delvare [this message]

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=20100830175836.65260450@hyperion.delvare \
    --to=khali-puyad+kwke1g9huczpvpmw@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=rogerio.souza-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /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