Re: eeprom Board Information EEPROM
From: Andreas Werner
Date: Sat Sep 20 2014 - 07:24:32 EST
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@xxxxxx> 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@xxxxxx>
> > 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@xxxxxx>
> > > > 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@xxxxxx>
> > > > > > 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@xxxxxxxxxxxxxxx
> > > > > > > > More majordomo info at
> > http://vger.kernel.org/majordomo-info.html
> > > > > > > > Please read the FAQ at http://www.tux.org/lkml/
> > > > > > > >
> > > > > >
> > > >
> >
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/