All of lore.kernel.org
 help / color / mirror / Atom feed
From: Przemyslaw Marczak <p.marczak@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 08/10] dm: Add a simple EEPROM driver
Date: Wed, 03 Dec 2014 17:16:52 +0100	[thread overview]
Message-ID: <547F3774.9020909@samsung.com> (raw)
In-Reply-To: <CAPnjgZ39-gJ=uF8gMQU32fu+zRLQ7O0eTYjL2wjGd3w0sxkQeg@mail.gmail.com>

Hello,
On 12/03/2014 04:18 PM, Simon Glass wrote:
> Hi Masahiro,
>
> On 1 December 2014 at 04:48, Masahiro Yamada <yamada.m@jp.panasonic.com> wrote:
>> Hi Simon,
>>
>>
>>
>>
>>
>> On Mon, 24 Nov 2014 11:57:22 -0700
>> Simon Glass <sjg@chromium.org> wrote:
>>
>>> --- /dev/null
>>> +++ b/drivers/misc/i2c_eeprom.c
>>> @@ -0,0 +1,51 @@
>>> +/*
>>> + * Copyright (c) 2014 Google, Inc
>>> + *
>>> + * SPDX-License-Identifier:  GPL-2.0+
>>> + */
>>> +
>>> +#include <common.h>
>>> +#include <dm.h>
>>> +#include <i2c.h>
>>> +#include <i2c_eeprom.h>
>>> +
>>> +static int i2c_eeprom_read(struct udevice *dev, int offset, uint8_t *buf,
>>> +                        int size)
>>> +{
>>> +     return -ENODEV;
>>> +}
>>> +
>>> +static int i2c_eeprom_write(struct udevice *dev, int offset,
>>> +                         const uint8_t *buf, int size)
>>> +{
>>> +     return -ENODEV;
>>> +}
>>
>>
>> Isn't there any possibility to reach i2c_eeprom_read/i2c_eeprom_write
>> handler?
>
> No it's just a stub for now.
>
>>
>> Maybe, is it better to fallback to i2c_read()/i2c_write() like this?
>>
>>
>> static int i2c_eeprom_read(struct udevice *dev, int offset, uint8_t *buf,
>>                             int size)
>> {
>>          return i2c_read(dev, offset, buf, size);
>> }
>>
>> static int i2c_eeprom_write(struct udevice *dev, int offset, const uint8_t *buf,
>>                             int size)
>> {
>>          return i2c_write(dev, offset, buf, size);
>> }
>>
>>
>
> Sure we can - I haven't implemented this yet, but if we could have a
> generic EEPROM driver like this it would be nice.
>
>>
>> Moreover, can we read data from EEPROM
>> without knowing if its parent is I2C bus or SPI bus ?
>>
>>
>> My rough image is like this:
>>
>> int eeprom_read(struct udevice *dev, int offset, uint8_t buf, int size)
>> {
>>          struct udevice *bus = dev->parent;
>>          struct generic_bus_operation *ops = bus->uclass->uc_drv->ops;
>>
>>          return ops->read(dev, bus, offset, buf, size);
>> }
>>
>> I am not sure, but if this approach is possible,
>> we do not need to have both of "i2c_eeprom uclass" and "spi_eeprom uclass".
>>
>> struct generic_bus_operation is the operaton some uclasses have.
>>
>> We can move i2c_read() and i2c_write()
>> to struct generic_bus_operation of i2c uclass.
>>
>> Likewise, we can move spi_read() and spi_write()
>> to struct generic_bus_operation of spi uclass.
>
> Yes we should do join up I2C and SPI. In order to do it we need SPI
> uclass to support reading and writing a particular offset (rather than
> just the current generic xfer()).
>
> Perhaps we should have a generic register access uclass. Drivers that
> want to support it could add themselves to the I2C and REGISTER
> uclass. But it would be better to handle this entirely in the I2C/SPI
> uclasses if we can.
>
> I added Przemyslaw as he needs something like this for the PMIC uclass.
>
> Regards,
> Simon
>

I send some general comments as a reply for patch number 0 and it also 
touches the bus accessing problem.

Best regards,
-- 
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com

  parent reply	other threads:[~2014-12-03 16:16 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-24 18:57 [U-Boot] [PATCH v3 0/10] dm: Add I2C support and convert sandbox, tegra Simon Glass
2014-11-24 18:57 ` [U-Boot] [PATCH v3 01/10] dm: i2c: Add a uclass for I2C Simon Glass
2014-11-28  4:47   ` Simon Glass
2014-12-01  9:02     ` Masahiro Yamada
2014-12-01 11:47   ` Masahiro Yamada
2014-12-02  4:31     ` Simon Glass
2014-12-02  4:35       ` Masahiro Yamada
2014-12-02  6:29       ` Heiko Schocher
2014-12-02 17:42         ` Simon Glass
2014-12-03 15:12     ` Simon Glass
2014-12-03 13:24   ` Masahiro Yamada
2014-12-03 15:13     ` Simon Glass
2014-12-03 16:02       ` Masahiro YAMADA
2014-12-04  2:01   ` Masahiro Yamada
2014-12-04  2:32     ` Simon Glass
2014-12-04  7:24       ` Masahiro Yamada
2014-12-04 12:23         ` Simon Glass
2014-12-04  2:36     ` Simon Glass
2014-12-04  7:27       ` Masahiro Yamada
2014-12-04 12:27         ` Simon Glass
2014-12-04  4:36   ` Masahiro Yamada
2014-12-04  5:07     ` Simon Glass
2014-11-24 18:57 ` [U-Boot] [PATCH v3 02/10] dm: i2c: Implement driver model support in the i2c command Simon Glass
2014-11-24 18:57 ` [U-Boot] [PATCH v3 03/10] dm: i2c: Add I2C emulation driver for sandbox Simon Glass
2014-11-24 18:57 ` [U-Boot] [PATCH v3 04/10] dm: i2c: Add a sandbox I2C driver Simon Glass
2014-11-24 18:57 ` [U-Boot] [PATCH v3 05/10] dm: i2c: Add an I2C EEPROM simulator Simon Glass
2014-11-24 18:57 ` [U-Boot] [PATCH v3 06/10] dm: i2c: config: Enable I2C for sandbox using driver model Simon Glass
2014-11-24 18:57 ` [U-Boot] [PATCH v3 07/10] dm: i2c: dts: Add an I2C bus for sandbox Simon Glass
2014-11-24 18:57 ` [U-Boot] [PATCH v3 08/10] dm: Add a simple EEPROM driver Simon Glass
2014-12-01 11:48   ` Masahiro Yamada
2014-12-03 15:18     ` Simon Glass
2014-12-03 16:03       ` Masahiro YAMADA
2014-12-03 16:16       ` Przemyslaw Marczak [this message]
2014-11-24 18:57 ` [U-Boot] [PATCH v3 09/10] dm: i2c: Add tests for I2C Simon Glass
2014-11-24 18:57 ` [U-Boot] [PATCH v3 10/10] dm: i2c: tegra: Convert to driver model Simon Glass
2014-12-01 11:53   ` Masahiro Yamada
2014-12-03 13:30   ` Masahiro Yamada
2014-12-03 15:23     ` Simon Glass
2014-12-03 15:52       ` Masahiro YAMADA
2014-12-03 16:37         ` Simon Glass
2014-12-03 16:13 ` [U-Boot] [PATCH v3 0/10] dm: Add I2C support and convert sandbox, tegra Przemyslaw Marczak
2014-12-04  2:00   ` Simon Glass
2014-12-05 13:09     ` Przemyslaw Marczak
2014-12-05 17:47       ` Simon Glass

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=547F3774.9020909@samsung.com \
    --to=p.marczak@samsung.com \
    --cc=u-boot@lists.denx.de \
    /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.