All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andreas Werner <wernerandy@gmx.de>
To: kavitha bk <bk.kavitha1@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: eeprom Board Information EEPROM
Date: Sat, 20 Sep 2014 13:23:50 +0200	[thread overview]
Message-ID: <20140920112350.GA1720@awedesk.fritz.box> (raw)
In-Reply-To: <CACx5bVwHo4AUN8UXarX1ygCr9jddYWnM8A-BCOF9W97FcMLJuQ@mail.gmail.com>

On Tue, Sep 16, 2014 at 01:14:36PM +0530, kavitha bk wrote:
> On Mon, Sep 15, 2014 at 10:52 PM, Andreas Werner <wernerandy@gmx.de> wrote:
> 
> > On Thu, Sep 04, 2014 at 09:59:53PM +0530, kavitha bk wrote:
> > > On Wed, Sep 3, 2014 at 8:04 PM, Andreas Werner <wernerandy@gmx.de>
> > wrote:
> > >
> > > > Is there a way to access the eeprom data from within another driver?
> > > >
> > > Yes I had to access mac address from eeprom from smsc [ethernet driver]
> > > so I exported a function from  eeprom driver
> > >
> > >
> > > > I have seen in at24 using the memory_accessor struct to allow access
> > e.g.
> > > > from platform driver,
> > > > but this is not want i want.
> > > >
> > > > Current driver sysfs iface:
> > > >         Predefined sections exported (24byte):
> > > >                 - revision
> > > >                 - serialnr
> > > >                 - prod_date
> > > >                 - rep_date
> > > >                 - hw_name
> > > >
> > > >         User memory (232 byte):
> > > >                 - user_eeprom (binary)
> > > >
> > > > This allows the userland to access the predefined data easily through
> > > > sysfs without
> > > > the need to format the eeprom bytes to get the right data.
> > > >
> > > > I also need an interface to have access within another driver e.g. we
> > have
> > > > an ethernet
> > > > driver which needs to read the serialnumber of the board.
> > > >
> > > > How can I do this?
> > > >
> > >
> > >
> > > Easy way is export a function in at24 driver but very bad it is
> > > Best way using memory_accessor.
> > > Explore  memory_accessor
> > >
> > >
> > >
> > >
> > >         struct memory_accessor *mem_acc =
> > driver->access_eeprom->serial_no
> > >
> > >
> > >         if (!mem_acc->read || !mem_acc->write)
> > >                 return -EIO;
> > >
> > >         ret = mem_acc->read(mem_acc, serial_no, offset, len);
> > >         if (ret != len)
> > >                 return -EIO;
> > >
> > >         return 0;
> > >
> > >
> > > > Regards
> > > > Andy
> > > >
> >
> > Hi,
> > i have checked the memory accessor. If i understand it right it is good if
> > I have some platform code.
> > The problem I have is, if I have some x86 system without platform config
> > (we normally have no BSP for x86)
> > the solution cannot work.
> >
> > Just a description of my problem.
> > I have an Ethernet driver which is a driver for a FPGA IP Core. The eth
> > runs at most on x86 systems.
> > Inside the driver i need a interface to the eeprom were I can access the
> > Serialnumber.
> >
> > For me the solution to export a function in the eeprom driver is the best
> > way to do it, isn´t it?
> >
> 
> 
> Yes may be it is appropriate to it this way in your case
> 

Hi,
i have also tried to export a function, but the problem is that the data of the eeprom is stored
in a structure of the eeprom driver, and i do not know how to get a pointer/reference to
this structure to get access from within another driver.

Does anybody of you have another idea how to access eeprom data from within another driver?

Thanks
Andy


> >
> > I hope it is clear what i want.
> >
> > Regards
> > Andy
> >
> >
> >
> >
> >
> > > > On Tue, Sep 02, 2014 at 01:30:52PM +0530, kavitha bk wrote:
> > > > > static ssize_t eeprom_read(struct device *dev,
> > > > >                         struct device_attribute *attr,
> > > > >                         char *buf) {
> > > > >         struct i2c_client *client = to_i2c_client(dev);
> > > > >         int ret = -1,i = 0;
> > > > >         unsigned char sn[256];
> > > > >
> > > > >         sn[0] = 0x00;
> > > > >         sn[1] = 0x00;
> > > > >
> > > > >         ret = i2c_master_send(client, sn, 2);
> > > > >
> > > > >         if(ret == -1)
> > > > >                 pr_info("ERROR: I2C send error\n");
> > > > >
> > > > >         ret = i2c_master_recv(client, sn, 256);
> > > > >         if(ret == -1)
> > > > >                 pr_info("I2C read error\n");
> > > > >
> > > > >
> > > > >         return sprintf(buf, "%s\n", sn);
> > > > > }
> > > > > static DEVICE_ATTR(eeprom, 0644, eeprom_read, NULL);
> > > > >
> > > > >
> > > > >
> > > > > In probe
> > > > >
> > > > >   err = device_create_file(&client->dev,&dev_attr_eeprom);
> > > > >                 if(err < 0) {
> > > > >                         pr_err("%s : failed to device create file\n",
> > > > > __func__);
> > > > >                         goto err_device_create_file_failed;
> > > > >                 }
> > > > >
> > > > >
> > > > >
> > > > > Sample code for reference
> > > > >
> > > > >
> > > > > Kavitha
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > On Tue, Sep 2, 2014 at 3:22 PM, Andreas Werner <wernerandy@gmx.de>
> > > > wrote:
> > > > >
> > > > > > On Mon, Sep 01, 2014 at 01:52:10PM +0530, kavitha bk wrote:
> > > > > > > On Sat, Aug 30, 2014 at 2:26 AM, Andreas Werner <
> > wernerandy@gmx.de>
> > > > > > wrote:
> > > > > > >
> > > > > > > > I have a question regarding a driver for a Board Information
> > > > EEPROM.
> > > > > > > >
> > > > > > > > I want to give our customer easy access to our Board
> > Information
> > > > EEPROM
> > > > > > > > which is an 256byte I2C eeprom.
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > >
> > > > > > > > There is a defined structure of information at the beginning
> > of the
> > > > > > eeprom
> > > > > > > > which includes board name, serialnumber, production date,
> > repair
> > > > date
> > > > > > and
> > > > > > > > a eeprom structure ident number.
> > > > > > > >
> > > > > > > > The rest of the eeprom is for user defined settings where
> > customer
> > > > can
> > > > > > > > write
> > > > > > > > any data to.
> > > > > > > >
> > > > > > > > I want to have access to the eeprom without any special to and
> > > > without
> > > > > > > > installing
> > > > > > > > anything just running linux and to a cat/echo to sysfs entries
> > to
> > > > > > > > read/write
> > > > > > > > data to the eeprom.
> > > > > > > >
> > > > > > > > What i want to do is to create sysfs entries for the pre
> > defined
> > > > > > settings
> > > > > > > > and
> > > > > > > > on entrie where customer can access the rest of the eeprom
> > bytes.
> > > > > > > >
> > > > > > > > Is drivers/misc/eeprom the right place to put those kind of
> > driver
> > > > in?
> > > > > > >
> > > > > > >
> > > > > > > Yes You can add here
> > > > > > >
> > > > > > > > Or are
> > > > > > > > there any other options to write those kind of driver?
> > > > > > > >
> > > > > > >
> > > > > > > Which eeprom are you using? You can explore CONFIG_EEPROM_AT24
> > > > driver for
> > > > > > > writing a sys interface
> > > > > > >
> > > > > >
> > > > > > Ok i will check it out.
> > > > > >
> > > > > > Thanks.
> > > > > >
> > > > > > Regards
> > > > > > Andy
> > > > > >
> > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > Regards
> > > > > > > > Andy
> > > > > > > > --
> > > > > > > > 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/
> > > > > > > >
> > > > > >
> > > >
> >

      parent reply	other threads:[~2014-09-20 11:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-29 20:56 eeprom Board Information EEPROM Andreas Werner
     [not found] ` <CACx5bVzvJ-x7EdnGX+AraNBwKaxKNwRVvBwN1-0DNY3O155U5Q@mail.gmail.com>
2014-09-02  9:52   ` Andreas Werner
     [not found]     ` <CACx5bVwUaHXOD0NxOiGzEMVQ0HYF2eLXVBL3nu1s=xAemYP9LQ@mail.gmail.com>
     [not found]       ` <20140903143415.GA3684@awedesk.fritz.box>
     [not found]         ` <CACx5bVxpGW=vb8zXLLJ9ewUOfw3ib0g=YBHUcTAS=vMhZ7NnHg@mail.gmail.com>
     [not found]           ` <20140915172255.GA798@awedesk.fritz.box>
     [not found]             ` <CACx5bVwHo4AUN8UXarX1ygCr9jddYWnM8A-BCOF9W97FcMLJuQ@mail.gmail.com>
2014-09-20 11:23               ` Andreas Werner [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=20140920112350.GA1720@awedesk.fritz.box \
    --to=wernerandy@gmx.de \
    --cc=bk.kavitha1@gmail.com \
    --cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.