Re: [dwi2c PATCH v1] dwi2c add offsets to reads

2020-12-14 Thread Heiko Schocher
Hello Duffin,

Am 14.12.20 um 18:12 schrieb Duffin, CooperX:
> Hello Heiko,
> 
> I hope you are doing well, just curious if you have had a chance to look into 
> my latest response?

Yep, thanks all fine, just to much workload ... and seems
I forgot to response

> 
> Regards,
> 
> -Cooper Duffin
> 
> Hello Heiko,
> 
> I hope you are doing well, just curious if you have had a chance to look into 
> my latest response?
> 
> Regards,
> 
> -Cooper Duffin
> 
> -Original Message-
> From: Duffin, CooperX 
> Sent: Wednesday, December 2, 2020 1:53 PM
> To: h...@denx.de
> Cc: Simon Glass ; U-Boot Mailing List 
> ; uboot-snps-...@synopsys.com; Tom Rini 
> ; Robert Beckett ; Wolgang 
> Denk ; Ian Ray 
> Subject: RE: [dwi2c PATCH v1] dwi2c add offsets to reads
> 
> -Original Message-
> From: Heiko Schocher 
> Sent: Tuesday, November 17, 2020 11:42 PM
> To: Duffin, CooperX 
> Cc: Simon Glass ; U-Boot Mailing List 
> ; uboot-snps-...@synopsys.com; Tom Rini 
> ; Robert Beckett ; Wolgang 
> Denk ; Ian Ray 
> Subject: Re: [dwi2c PATCH v1] dwi2c add offsets to reads
> 
> Hello Simon,
> 
> Am 17.11.2020 um 00:20 schrieb Simon Glass:
>> +Heiko Schocher who might know more about this I2C question
> 
> Sorry for late response ...
> 
>> On Mon, 9 Nov 2020 at 15:09, Duffin, CooperX  
>> wrote:
>>>
>>> -Original Message-
>>> From: Simon Glass 
>>> Sent: Saturday, November 7, 2020 1:33 PM
>>> To: Duffin, CooperX 
>>> Cc: U-Boot Mailing List ; 
>>> uboot-snps-...@synopsys.com; Tom Rini ; Robert 
>>> Beckett ; Heiko Schocher ; 
>>> Wolgang Denk ; Ian Ray 
>>> Subject: Re: [dwi2c PATCH v1] dwi2c add offsets to reads
>>>
>>> Hi CooperX,
>>>
>>> On Fri, 6 Nov 2020 at 16:08, Duffin, CooperX  
>>> wrote:
>>>>
>>>> Hello Simon,
>>>>
>>>> I wasn’t using the test/dm/i2c I this was tested using hardware where I 
>>>> was using the dm_i2c_read() function. I just tried to use the test/dm/i2c 
>>>> where I am following the README but I keep getting  "sdl2-config: Command 
>>>> not found". I suspect it would also fail where it is trying to read but I 
>>>> will have to get test/dm/i2c working before I know for sure.
>>>>
>>>> Essentially my test was
>>>>
>>>> int uboot_app (int argc, char * const argv[]) {
>>>> uint8_t buf[10];
>>>> uint8_t read_buf[5];
>>>> uint8_t dev_addr;
>>>> uint32_t bus_speed;
>>>> //i2c_bus device pointer
>>>> struct udevice *i2c_led;
>>>> struct udevice *bus;
>>>> app_startup(argv);
>>>> /* Print the ABI version */
>>>> printf ("Example expects ABI version %d\n", XF_VERSION);
>>>> printf ("Actual U-Boot ABI version %d\n", 
>>>> (int)get_version());
>>>>
>>>> dev_addr = 0x60;
>>>> bus_speed = 10; //100KHz
>>>> printf("starting test i2c\n");
>>>> buf[0] = 'b';
>>>> buf[1] = 'o';
>>>> buf[2] = 'o';
>>>> buf[3] = 't';
>>>> //Get i2c chip, init the code
>>>> printf("init starting\n");
>>>> if(i2c_get_chip_for_busnum(0 , 0x60, 1, _led)!=0){
>>>> printf("ERROR: no device found at %x \n",dev_addr);
>>>> return (0);
>>>> }
>>>> uclass_get_device_by_seq(UCLASS_I2C, 0, );
>>>> printf("Setting bus speed to %d\n", bus_speed);
>>>> if(dm_i2c_set_bus_speed(bus,bus_speed)!=0){
>>>> printf("ERROR: Cannot set buspeed\n");
>>>> return (0);
>>>> }
>>>> printf("i2c_led name is %s\n",i2c_led->name);
>>>> if(i2c_led == NULL){
>>>> printf("ERROR i2c_led 0 is null\n");
>>>> return (0);
>>>> }
>>>> printf("Writing\n");
>>>> for(unsigned int a =0; a< 4; a++){
>>>> if(dm_i2c_write(i2c_led,a,[a],1)!=0){
>>>> printf("ERROR writing\n");
>>>> return (0);
>>>>

RE: [dwi2c PATCH v1] dwi2c add offsets to reads

2020-12-14 Thread Duffin, CooperX
Hello Heiko,

I hope you are doing well, just curious if you have had a chance to look into 
my latest response?

Regards,

-Cooper Duffin

Hello Heiko,

I hope you are doing well, just curious if you have had a chance to look into 
my latest response?

Regards,

-Cooper Duffin

-Original Message-
From: Duffin, CooperX 
Sent: Wednesday, December 2, 2020 1:53 PM
To: h...@denx.de
Cc: Simon Glass ; U-Boot Mailing List 
; uboot-snps-...@synopsys.com; Tom Rini 
; Robert Beckett ; Wolgang Denk 
; Ian Ray 
Subject: RE: [dwi2c PATCH v1] dwi2c add offsets to reads

-Original Message-
From: Heiko Schocher 
Sent: Tuesday, November 17, 2020 11:42 PM
To: Duffin, CooperX 
Cc: Simon Glass ; U-Boot Mailing List 
; uboot-snps-...@synopsys.com; Tom Rini 
; Robert Beckett ; Wolgang Denk 
; Ian Ray 
Subject: Re: [dwi2c PATCH v1] dwi2c add offsets to reads

Hello Simon,

Am 17.11.2020 um 00:20 schrieb Simon Glass:
> +Heiko Schocher who might know more about this I2C question

Sorry for late response ...

> On Mon, 9 Nov 2020 at 15:09, Duffin, CooperX  wrote:
>>
>> -Original Message-
>> From: Simon Glass 
>> Sent: Saturday, November 7, 2020 1:33 PM
>> To: Duffin, CooperX 
>> Cc: U-Boot Mailing List ; 
>> uboot-snps-...@synopsys.com; Tom Rini ; Robert 
>> Beckett ; Heiko Schocher ; 
>> Wolgang Denk ; Ian Ray 
>> Subject: Re: [dwi2c PATCH v1] dwi2c add offsets to reads
>>
>> Hi CooperX,
>>
>> On Fri, 6 Nov 2020 at 16:08, Duffin, CooperX  
>> wrote:
>>>
>>> Hello Simon,
>>>
>>> I wasn’t using the test/dm/i2c I this was tested using hardware where I was 
>>> using the dm_i2c_read() function. I just tried to use the test/dm/i2c where 
>>> I am following the README but I keep getting  "sdl2-config: Command not 
>>> found". I suspect it would also fail where it is trying to read but I will 
>>> have to get test/dm/i2c working before I know for sure.
>>>
>>> Essentially my test was
>>>
>>> int uboot_app (int argc, char * const argv[]) {
>>> uint8_t buf[10];
>>> uint8_t read_buf[5];
>>> uint8_t dev_addr;
>>> uint32_t bus_speed;
>>> //i2c_bus device pointer
>>> struct udevice *i2c_led;
>>> struct udevice *bus;
>>> app_startup(argv);
>>> /* Print the ABI version */
>>> printf ("Example expects ABI version %d\n", XF_VERSION);
>>> printf ("Actual U-Boot ABI version %d\n", 
>>> (int)get_version());
>>>
>>> dev_addr = 0x60;
>>> bus_speed = 10; //100KHz
>>> printf("starting test i2c\n");
>>> buf[0] = 'b';
>>> buf[1] = 'o';
>>> buf[2] = 'o';
>>> buf[3] = 't';
>>> //Get i2c chip, init the code
>>> printf("init starting\n");
>>> if(i2c_get_chip_for_busnum(0 , 0x60, 1, _led)!=0){
>>> printf("ERROR: no device found at %x \n",dev_addr);
>>> return (0);
>>> }
>>> uclass_get_device_by_seq(UCLASS_I2C, 0, );
>>> printf("Setting bus speed to %d\n", bus_speed);
>>> if(dm_i2c_set_bus_speed(bus,bus_speed)!=0){
>>> printf("ERROR: Cannot set buspeed\n");
>>> return (0);
>>> }
>>> printf("i2c_led name is %s\n",i2c_led->name);
>>> if(i2c_led == NULL){
>>> printf("ERROR i2c_led 0 is null\n");
>>> return (0);
>>> }
>>> printf("Writing\n");
>>> for(unsigned int a =0; a< 4; a++){
>>> if(dm_i2c_write(i2c_led,a,[a],1)!=0){
>>> printf("ERROR writing\n");
>>> return (0);
>>> }
>>> }
>>>
>>> printf("Reading\n");
>>> for(unsigned int a =0; a< 4; a++){
>>> if(dm_i2c_read(i2c_led,a,_buf[a],1)!=0){
>>> printf("ERROR writing\n");
>>> return (0);
>>> }
>>> }
>>> printf("read buffer is %c, %c, %c, %c \n",read_buf[0],read_buf[1], 
>>> read_buf[2],read_buf[3]);
>>> printf ("\n\n");
>>> return (0);
>>> }
>>>
>>> ## 

RE: [dwi2c PATCH v1] dwi2c add offsets to reads

2020-12-02 Thread Duffin, CooperX
-Original Message-
From: Heiko Schocher  
Sent: Tuesday, November 17, 2020 11:42 PM
To: Duffin, CooperX 
Cc: Simon Glass ; U-Boot Mailing List 
; uboot-snps-...@synopsys.com; Tom Rini 
; Robert Beckett ; Wolgang Denk 
; Ian Ray 
Subject: Re: [dwi2c PATCH v1] dwi2c add offsets to reads

Hello Simon,

Am 17.11.2020 um 00:20 schrieb Simon Glass:
> +Heiko Schocher who might know more about this I2C question

Sorry for late response ...

> On Mon, 9 Nov 2020 at 15:09, Duffin, CooperX  wrote:
>>
>> -Original Message-
>> From: Simon Glass 
>> Sent: Saturday, November 7, 2020 1:33 PM
>> To: Duffin, CooperX 
>> Cc: U-Boot Mailing List ; 
>> uboot-snps-...@synopsys.com; Tom Rini ; Robert 
>> Beckett ; Heiko Schocher ; 
>> Wolgang Denk ; Ian Ray 
>> Subject: Re: [dwi2c PATCH v1] dwi2c add offsets to reads
>>
>> Hi CooperX,
>>
>> On Fri, 6 Nov 2020 at 16:08, Duffin, CooperX  
>> wrote:
>>>
>>> Hello Simon,
>>>
>>> I wasn’t using the test/dm/i2c I this was tested using hardware where I was 
>>> using the dm_i2c_read() function. I just tried to use the test/dm/i2c where 
>>> I am following the README but I keep getting  "sdl2-config: Command not 
>>> found". I suspect it would also fail where it is trying to read but I will 
>>> have to get test/dm/i2c working before I know for sure.
>>>
>>> Essentially my test was
>>>
>>> int uboot_app (int argc, char * const argv[]) {
>>> uint8_t buf[10];
>>> uint8_t read_buf[5];
>>> uint8_t dev_addr;
>>> uint32_t bus_speed;
>>> //i2c_bus device pointer
>>> struct udevice *i2c_led;
>>> struct udevice *bus;
>>> app_startup(argv);
>>> /* Print the ABI version */
>>> printf ("Example expects ABI version %d\n", XF_VERSION);
>>> printf ("Actual U-Boot ABI version %d\n", 
>>> (int)get_version());
>>>
>>> dev_addr = 0x60;
>>> bus_speed = 10; //100KHz
>>> printf("starting test i2c\n");
>>> buf[0] = 'b';
>>> buf[1] = 'o';
>>> buf[2] = 'o';
>>> buf[3] = 't';
>>> //Get i2c chip, init the code
>>> printf("init starting\n");
>>> if(i2c_get_chip_for_busnum(0 , 0x60, 1, _led)!=0){
>>> printf("ERROR: no device found at %x \n",dev_addr);
>>> return (0);
>>> }
>>> uclass_get_device_by_seq(UCLASS_I2C, 0, );
>>> printf("Setting bus speed to %d\n", bus_speed);
>>> if(dm_i2c_set_bus_speed(bus,bus_speed)!=0){
>>> printf("ERROR: Cannot set buspeed\n");
>>> return (0);
>>> }
>>> printf("i2c_led name is %s\n",i2c_led->name);
>>> if(i2c_led == NULL){
>>> printf("ERROR i2c_led 0 is null\n");
>>> return (0);
>>> }
>>> printf("Writing\n");
>>> for(unsigned int a =0; a< 4; a++){
>>> if(dm_i2c_write(i2c_led,a,[a],1)!=0){
>>> printf("ERROR writing\n");
>>> return (0);
>>> }
>>> }
>>>
>>> printf("Reading\n");
>>> for(unsigned int a =0; a< 4; a++){
>>> if(dm_i2c_read(i2c_led,a,_buf[a],1)!=0){
>>> printf("ERROR writing\n");
>>> return (0);
>>> }
>>> }
>>> printf("read buffer is %c, %c, %c, %c \n",read_buf[0],read_buf[1], 
>>> read_buf[2],read_buf[3]);
>>> printf ("\n\n");
>>> return (0);
>>> }
>>>
>>> ## Starting application at 0x0C10 ...
>>> Example expects ABI version 10
>>> Actual U-Boot ABI version 10
>>> starting test i2c
>>> init starting
>>> Setting bus speed to 10
>>> i2c_led name is generic_60
>>> Writing
>>> Reading
>>> read buffer is o, o, o, o
>>>
>>> with the fix I get:
>>>
>>> ## Starting application at 0x0C10 ...
>>> Example expects ABI version 10
>>> Actual U-Boot ABI version 10
>>> starting tes

Re: [dwi2c PATCH v1] dwi2c add offsets to reads

2020-11-17 Thread Heiko Schocher
Hello Simon,

Am 17.11.2020 um 00:20 schrieb Simon Glass:
> +Heiko Schocher who might know more about this I2C question

Sorry for late response ...

> On Mon, 9 Nov 2020 at 15:09, Duffin, CooperX  wrote:
>>
>> -Original Message-
>> From: Simon Glass 
>> Sent: Saturday, November 7, 2020 1:33 PM
>> To: Duffin, CooperX 
>> Cc: U-Boot Mailing List ; uboot-snps-...@synopsys.com; 
>> Tom Rini ; Robert Beckett ; 
>> Heiko Schocher ; Wolgang Denk ; Ian Ray 
>> 
>> Subject: Re: [dwi2c PATCH v1] dwi2c add offsets to reads
>>
>> Hi CooperX,
>>
>> On Fri, 6 Nov 2020 at 16:08, Duffin, CooperX  
>> wrote:
>>>
>>> Hello Simon,
>>>
>>> I wasn’t using the test/dm/i2c I this was tested using hardware where I was 
>>> using the dm_i2c_read() function. I just tried to use the test/dm/i2c where 
>>> I am following the README but I keep getting  "sdl2-config: Command not 
>>> found". I suspect it would also fail where it is trying to read but I will 
>>> have to get test/dm/i2c working before I know for sure.
>>>
>>> Essentially my test was
>>>
>>> int uboot_app (int argc, char * const argv[]) {
>>> uint8_t buf[10];
>>> uint8_t read_buf[5];
>>> uint8_t dev_addr;
>>> uint32_t bus_speed;
>>> //i2c_bus device pointer
>>> struct udevice *i2c_led;
>>> struct udevice *bus;
>>> app_startup(argv);
>>> /* Print the ABI version */
>>> printf ("Example expects ABI version %d\n", XF_VERSION);
>>> printf ("Actual U-Boot ABI version %d\n", (int)get_version());
>>>
>>> dev_addr = 0x60;
>>> bus_speed = 10; //100KHz
>>> printf("starting test i2c\n");
>>> buf[0] = 'b';
>>> buf[1] = 'o';
>>> buf[2] = 'o';
>>> buf[3] = 't';
>>> //Get i2c chip, init the code
>>> printf("init starting\n");
>>> if(i2c_get_chip_for_busnum(0 , 0x60, 1, _led)!=0){
>>> printf("ERROR: no device found at %x \n",dev_addr);
>>> return (0);
>>> }
>>> uclass_get_device_by_seq(UCLASS_I2C, 0, );
>>> printf("Setting bus speed to %d\n", bus_speed);
>>> if(dm_i2c_set_bus_speed(bus,bus_speed)!=0){
>>> printf("ERROR: Cannot set buspeed\n");
>>> return (0);
>>> }
>>> printf("i2c_led name is %s\n",i2c_led->name);
>>> if(i2c_led == NULL){
>>> printf("ERROR i2c_led 0 is null\n");
>>> return (0);
>>> }
>>> printf("Writing\n");
>>> for(unsigned int a =0; a< 4; a++){
>>> if(dm_i2c_write(i2c_led,a,[a],1)!=0){
>>> printf("ERROR writing\n");
>>> return (0);
>>> }
>>> }
>>>
>>> printf("Reading\n");
>>> for(unsigned int a =0; a< 4; a++){
>>> if(dm_i2c_read(i2c_led,a,_buf[a],1)!=0){
>>> printf("ERROR writing\n");
>>> return (0);
>>> }
>>> }
>>> printf("read buffer is %c, %c, %c, %c \n",read_buf[0],read_buf[1], 
>>> read_buf[2],read_buf[3]);
>>> printf ("\n\n");
>>> return (0);
>>> }
>>>
>>> ## Starting application at 0x0C10 ...
>>> Example expects ABI version 10
>>> Actual U-Boot ABI version 10
>>> starting test i2c
>>> init starting
>>> Setting bus speed to 10
>>> i2c_led name is generic_60
>>> Writing
>>> Reading
>>> read buffer is o, o, o, o
>>>
>>> with the fix I get:
>>>
>>> ## Starting application at 0x0C10 ...
>>> Example expects ABI version 10
>>> Actual U-Boot ABI version 10
>>> starting test i2c
>>> init starting
>>> Setting bus speed to 10
>>> i2c_led name is generic_60
>>> Writing
>>> Reading
>>> read buffer is b, o, o, t
>>>
>>> which is correct. Similarly if I stop auto boot I get a simi

Re: [dwi2c PATCH v1] dwi2c add offsets to reads

2020-11-16 Thread Simon Glass
+Heiko Schocher who might know more about this I2C question

On Mon, 9 Nov 2020 at 15:09, Duffin, CooperX  wrote:
>
> -Original Message-
> From: Simon Glass 
> Sent: Saturday, November 7, 2020 1:33 PM
> To: Duffin, CooperX 
> Cc: U-Boot Mailing List ; uboot-snps-...@synopsys.com; 
> Tom Rini ; Robert Beckett ; 
> Heiko Schocher ; Wolgang Denk ; Ian Ray 
> 
> Subject: Re: [dwi2c PATCH v1] dwi2c add offsets to reads
>
> Hi CooperX,
>
> On Fri, 6 Nov 2020 at 16:08, Duffin, CooperX  wrote:
> >
> > Hello Simon,
> >
> > I wasn’t using the test/dm/i2c I this was tested using hardware where I was 
> > using the dm_i2c_read() function. I just tried to use the test/dm/i2c where 
> > I am following the README but I keep getting  "sdl2-config: Command not 
> > found". I suspect it would also fail where it is trying to read but I will 
> > have to get test/dm/i2c working before I know for sure.
> >
> > Essentially my test was
> >
> > int uboot_app (int argc, char * const argv[]) {
> > uint8_t buf[10];
> > uint8_t read_buf[5];
> > uint8_t dev_addr;
> > uint32_t bus_speed;
> > //i2c_bus device pointer
> > struct udevice *i2c_led;
> > struct udevice *bus;
> > app_startup(argv);
> > /* Print the ABI version */
> > printf ("Example expects ABI version %d\n", XF_VERSION);
> > printf ("Actual U-Boot ABI version %d\n", (int)get_version());
> >
> > dev_addr = 0x60;
> > bus_speed = 10; //100KHz
> > printf("starting test i2c\n");
> > buf[0] = 'b';
> > buf[1] = 'o';
> > buf[2] = 'o';
> > buf[3] = 't';
> > //Get i2c chip, init the code
> > printf("init starting\n");
> > if(i2c_get_chip_for_busnum(0 , 0x60, 1, _led)!=0){
> > printf("ERROR: no device found at %x \n",dev_addr);
> > return (0);
> > }
> > uclass_get_device_by_seq(UCLASS_I2C, 0, );
> > printf("Setting bus speed to %d\n", bus_speed);
> > if(dm_i2c_set_bus_speed(bus,bus_speed)!=0){
> > printf("ERROR: Cannot set buspeed\n");
> > return (0);
> > }
> > printf("i2c_led name is %s\n",i2c_led->name);
> > if(i2c_led == NULL){
> > printf("ERROR i2c_led 0 is null\n");
> > return (0);
> > }
> > printf("Writing\n");
> > for(unsigned int a =0; a< 4; a++){
> > if(dm_i2c_write(i2c_led,a,[a],1)!=0){
> > printf("ERROR writing\n");
> > return (0);
> > }
> > }
> >
> > printf("Reading\n");
> > for(unsigned int a =0; a< 4; a++){
> > if(dm_i2c_read(i2c_led,a,_buf[a],1)!=0){
> > printf("ERROR writing\n");
> > return (0);
> > }
> > }
> > printf("read buffer is %c, %c, %c, %c \n",read_buf[0],read_buf[1], 
> > read_buf[2],read_buf[3]);
> > printf ("\n\n");
> > return (0);
> > }
> >
> > ## Starting application at 0x0C10 ...
> > Example expects ABI version 10
> > Actual U-Boot ABI version 10
> > starting test i2c
> > init starting
> > Setting bus speed to 10
> > i2c_led name is generic_60
> > Writing
> > Reading
> > read buffer is o, o, o, o
> >
> > with the fix I get:
> >
> > ## Starting application at 0x0C10 ...
> > Example expects ABI version 10
> > Actual U-Boot ABI version 10
> > starting test i2c
> > init starting
> > Setting bus speed to 10
> > i2c_led name is generic_60
> > Writing
> > Reading
> > read buffer is b, o, o, t
> >
> > which is correct. Similarly if I stop auto boot I get a similar result:
> >
> > Hit any key to stop autoboot:  0
> > device # i2c
> > i2c - I2C sub-system
> >
> > Assuming I write "boot" to the device
> > device # i2c dev 0
> > Setting bus to 0
> > device # i2c md 0x60 0 4
> > : 6f 6f 6f 6f
> >
> > With the fix/patch I get:
> >
> > device# i2c md 0x60 0 4
> > : 62 6f 6f 74boot
> >
> &g

RE: [dwi2c PATCH v1] dwi2c add offsets to reads

2020-11-09 Thread Duffin, CooperX
-Original Message-
From: Simon Glass  
Sent: Saturday, November 7, 2020 1:33 PM
To: Duffin, CooperX 
Cc: U-Boot Mailing List ; uboot-snps-...@synopsys.com; 
Tom Rini ; Robert Beckett ; 
Heiko Schocher ; Wolgang Denk ; Ian Ray 

Subject: Re: [dwi2c PATCH v1] dwi2c add offsets to reads

Hi CooperX,

On Fri, 6 Nov 2020 at 16:08, Duffin, CooperX  wrote:
>
> Hello Simon,
>
> I wasn’t using the test/dm/i2c I this was tested using hardware where I was 
> using the dm_i2c_read() function. I just tried to use the test/dm/i2c where I 
> am following the README but I keep getting  "sdl2-config: Command not found". 
> I suspect it would also fail where it is trying to read but I will have to 
> get test/dm/i2c working before I know for sure.
>
> Essentially my test was
>
> int uboot_app (int argc, char * const argv[]) {
> uint8_t buf[10];
> uint8_t read_buf[5];
> uint8_t dev_addr;
> uint32_t bus_speed;
> //i2c_bus device pointer
> struct udevice *i2c_led;
> struct udevice *bus;
> app_startup(argv);
> /* Print the ABI version */
> printf ("Example expects ABI version %d\n", XF_VERSION);
> printf ("Actual U-Boot ABI version %d\n", (int)get_version());
>
> dev_addr = 0x60;
> bus_speed = 10; //100KHz
> printf("starting test i2c\n");
> buf[0] = 'b';
> buf[1] = 'o';
> buf[2] = 'o';
> buf[3] = 't';
> //Get i2c chip, init the code
> printf("init starting\n");
> if(i2c_get_chip_for_busnum(0 , 0x60, 1, _led)!=0){
> printf("ERROR: no device found at %x \n",dev_addr);
> return (0);
> }
> uclass_get_device_by_seq(UCLASS_I2C, 0, );
> printf("Setting bus speed to %d\n", bus_speed);
> if(dm_i2c_set_bus_speed(bus,bus_speed)!=0){
> printf("ERROR: Cannot set buspeed\n");
> return (0);
> }
> printf("i2c_led name is %s\n",i2c_led->name);
> if(i2c_led == NULL){
> printf("ERROR i2c_led 0 is null\n");
> return (0);
> }
> printf("Writing\n");
> for(unsigned int a =0; a< 4; a++){
> if(dm_i2c_write(i2c_led,a,[a],1)!=0){
> printf("ERROR writing\n");
> return (0);
> }
> }
>
> printf("Reading\n");
> for(unsigned int a =0; a< 4; a++){
> if(dm_i2c_read(i2c_led,a,_buf[a],1)!=0){
> printf("ERROR writing\n");
> return (0);
> }
> }
> printf("read buffer is %c, %c, %c, %c \n",read_buf[0],read_buf[1], 
> read_buf[2],read_buf[3]);
> printf ("\n\n");
> return (0);
> }
>
> ## Starting application at 0x0C10 ...
> Example expects ABI version 10
> Actual U-Boot ABI version 10
> starting test i2c
> init starting
> Setting bus speed to 10
> i2c_led name is generic_60
> Writing
> Reading
> read buffer is o, o, o, o
>
> with the fix I get:
>
> ## Starting application at 0x0C10 ...
> Example expects ABI version 10
> Actual U-Boot ABI version 10
> starting test i2c
> init starting
> Setting bus speed to 10
> i2c_led name is generic_60
> Writing
> Reading
> read buffer is b, o, o, t
>
> which is correct. Similarly if I stop auto boot I get a similar result:
>
> Hit any key to stop autoboot:  0
> device # i2c
> i2c - I2C sub-system
>
> Assuming I write "boot" to the device
> device # i2c dev 0
> Setting bus to 0
> device # i2c md 0x60 0 4
> : 6f 6f 6f 6f
>
> With the fix/patch I get:
>
> device# i2c md 0x60 0 4
> : 62 6f 6f 74boot
>
> Which is correct. Also the reads were working in linux leading to my original 
> suspicion that there might be something going on in the driver. Hopefully 
> that answers your question let me know if you have anymore.

I had a bit of a look at this. If you look at dm_i2c_read() it actually builds 
the address into the buffer it sends. So when it gets to __dw_i2c_write() the 
alen parameter is always 0. That function is actually a holdover from before 
driver model, so one day the alen and addr parameters will go away.

I wonder if your device does not support multiple-byte reads or writes? Can you 
try the i2c md with a single byte? There is a DM_I2C_CHIP_WR_ADDRESS option to 
handle this - see the 'i2c flags'
command.

Re: [dwi2c PATCH v1] dwi2c add offsets to reads

2020-11-07 Thread Simon Glass
Hi CooperX,

On Fri, 6 Nov 2020 at 16:08, Duffin, CooperX  wrote:
>
> Hello Simon,
>
> I wasn’t using the test/dm/i2c I this was tested using hardware where I was 
> using the dm_i2c_read() function. I just tried to use the test/dm/i2c where I 
> am following the README but I keep getting  "sdl2-config: Command not found". 
> I suspect it would also fail where it is trying to read but I will have to 
> get test/dm/i2c working before I know for sure.
>
> Essentially my test was
>
> int uboot_app (int argc, char * const argv[])
> {
> uint8_t buf[10];
> uint8_t read_buf[5];
> uint8_t dev_addr;
> uint32_t bus_speed;
> //i2c_bus device pointer
> struct udevice *i2c_led;
> struct udevice *bus;
> app_startup(argv);
> /* Print the ABI version */
> printf ("Example expects ABI version %d\n", XF_VERSION);
> printf ("Actual U-Boot ABI version %d\n", (int)get_version());
>
> dev_addr = 0x60;
> bus_speed = 10; //100KHz
> printf("starting test i2c\n");
> buf[0] = 'b';
> buf[1] = 'o';
> buf[2] = 'o';
> buf[3] = 't';
> //Get i2c chip, init the code
> printf("init starting\n");
> if(i2c_get_chip_for_busnum(0 , 0x60, 1, _led)!=0){
> printf("ERROR: no device found at %x \n",dev_addr);
> return (0);
> }
> uclass_get_device_by_seq(UCLASS_I2C, 0, );
> printf("Setting bus speed to %d\n", bus_speed);
> if(dm_i2c_set_bus_speed(bus,bus_speed)!=0){
> printf("ERROR: Cannot set buspeed\n");
> return (0);
> }
> printf("i2c_led name is %s\n",i2c_led->name);
> if(i2c_led == NULL){
> printf("ERROR i2c_led 0 is null\n");
> return (0);
> }
> printf("Writing\n");
> for(unsigned int a =0; a< 4; a++){
> if(dm_i2c_write(i2c_led,a,[a],1)!=0){
> printf("ERROR writing\n");
> return (0);
> }
> }
>
> printf("Reading\n");
> for(unsigned int a =0; a< 4; a++){
> if(dm_i2c_read(i2c_led,a,_buf[a],1)!=0){
> printf("ERROR writing\n");
> return (0);
> }
> }
> printf("read buffer is %c, %c, %c, %c \n",read_buf[0],read_buf[1], 
> read_buf[2],read_buf[3]);
> printf ("\n\n");
> return (0);
> }
>
> ## Starting application at 0x0C10 ...
> Example expects ABI version 10
> Actual U-Boot ABI version 10
> starting test i2c
> init starting
> Setting bus speed to 10
> i2c_led name is generic_60
> Writing
> Reading
> read buffer is o, o, o, o
>
> with the fix I get:
>
> ## Starting application at 0x0C10 ...
> Example expects ABI version 10
> Actual U-Boot ABI version 10
> starting test i2c
> init starting
> Setting bus speed to 10
> i2c_led name is generic_60
> Writing
> Reading
> read buffer is b, o, o, t
>
> which is correct. Similarly if I stop auto boot I get a similar result:
>
> Hit any key to stop autoboot:  0
> device # i2c
> i2c - I2C sub-system
>
> Assuming I write "boot" to the device
> device # i2c dev 0
> Setting bus to 0
> device # i2c md 0x60 0 4
> : 6f 6f 6f 6f
>
> With the fix/patch I get:
>
> device# i2c md 0x60 0 4
> : 62 6f 6f 74boot
>
> Which is correct. Also the reads were working in linux leading to my original 
> suspicion that there might be something going on in the driver. Hopefully 
> that answers your question let me know if you have anymore.

I had a bit of a look at this. If you look at dm_i2c_read() it
actually builds the address into the buffer it sends. So when it gets
to __dw_i2c_write() the alen parameter is always 0. That function is
actually a holdover from before driver model, so one day the alen and
addr parameters will go away.

I wonder if your device does not support multiple-byte reads or
writes? Can you try the i2c md with a single byte? There is a
DM_I2C_CHIP_WR_ADDRESS option to handle this - see the 'i2c flags'
command.

In the designware_i2c_xfer(), try printing out the bytes that it gets
in each message using i2c_dump_msgs().

Also check the i2c_get_chip() function which you are using. See if
chip->offset_len is set to 1 as it should be, for your device. If not,
perhaps something is missing.

In short I am not re

RE: [dwi2c PATCH v1] dwi2c add offsets to reads

2020-11-06 Thread Duffin, CooperX
Hello Simon, 

I wasn’t using the test/dm/i2c I this was tested using hardware where I was 
using the dm_i2c_read() function. I just tried to use the test/dm/i2c where I 
am following the README but I keep getting  "sdl2-config: Command not found". I 
suspect it would also fail where it is trying to read but I will have to get 
test/dm/i2c working before I know for sure.

Essentially my test was  

int uboot_app (int argc, char * const argv[])
{
uint8_t buf[10];
uint8_t read_buf[5];
uint8_t dev_addr;
uint32_t bus_speed;
//i2c_bus device pointer
struct udevice *i2c_led;
struct udevice *bus;
app_startup(argv);
/* Print the ABI version */
printf ("Example expects ABI version %d\n", XF_VERSION);
printf ("Actual U-Boot ABI version %d\n", (int)get_version());

dev_addr = 0x60;
bus_speed = 10; //100KHz
printf("starting test i2c\n");
buf[0] = 'b';
buf[1] = 'o';
buf[2] = 'o';
buf[3] = 't';
//Get i2c chip, init the code
printf("init starting\n");
if(i2c_get_chip_for_busnum(0 , 0x60, 1, _led)!=0){
printf("ERROR: no device found at %x \n",dev_addr);
return (0);
}
uclass_get_device_by_seq(UCLASS_I2C, 0, );
printf("Setting bus speed to %d\n", bus_speed);
if(dm_i2c_set_bus_speed(bus,bus_speed)!=0){
printf("ERROR: Cannot set buspeed\n");
return (0);
}
printf("i2c_led name is %s\n",i2c_led->name);
if(i2c_led == NULL){
printf("ERROR i2c_led 0 is null\n");
return (0); 
}
printf("Writing\n");
for(unsigned int a =0; a< 4; a++){
if(dm_i2c_write(i2c_led,a,[a],1)!=0){
printf("ERROR writing\n");
return (0);
}
}

printf("Reading\n");
for(unsigned int a =0; a< 4; a++){
if(dm_i2c_read(i2c_led,a,_buf[a],1)!=0){
printf("ERROR writing\n");
return (0);
}
}
printf("read buffer is %c, %c, %c, %c \n",read_buf[0],read_buf[1], 
read_buf[2],read_buf[3]);
printf ("\n\n");
return (0);
}

## Starting application at 0x0C10 ...
Example expects ABI version 10
Actual U-Boot ABI version 10
starting test i2c
init starting
Setting bus speed to 10
i2c_led name is generic_60
Writing
Reading
read buffer is o, o, o, o
 
with the fix I get:

## Starting application at 0x0C10 ...
Example expects ABI version 10
Actual U-Boot ABI version 10
starting test i2c
init starting
Setting bus speed to 10
i2c_led name is generic_60
Writing
Reading
read buffer is b, o, o, t

which is correct. Similarly if I stop auto boot I get a similar result:

Hit any key to stop autoboot:  0 
device # i2c 
i2c - I2C sub-system

Assuming I write "boot" to the device
device # i2c dev 0
Setting bus to 0
device # i2c md 0x60 0 4
: 6f 6f 6f 6f

With the fix/patch I get:
 
device# i2c md 0x60 0 4
: 62 6f 6f 74boot

Which is correct. Also the reads were working in linux leading to my original 
suspicion that there might be something going on in the driver. Hopefully that 
answers your question let me know if you have anymore. 

Best regards,

-Cooper Duffin
-Original Message-
From: Simon Glass  
Sent: Friday, November 6, 2020 10:51 AM
To: Duffin, CooperX 
Cc: U-Boot Mailing List ; uboot-snps-...@synopsys.com; 
Tom Rini ; Robert Beckett ; 
Heiko Schocher ; Wolgang Denk ; Ian Ray 

Subject: Re: [dwi2c PATCH v1] dwi2c add offsets to reads

Hi Cduffinx,

On Thu, 5 Nov 2020 at 14:26, cduffinx  wrote:
>
> modify the designware_i2c_xfer function to use 1 byte per address, it 
> was set to 0 before which makes it think its reading a register type. 
> Added offset of where it is supposed to read from. Before it was 
> always reading from offset 0 despite specifying the offset in the 
> higher level function.
>
> Signed-off-by: Cooper Duffin 
> Signed-off-by: cduffinx 
> ---
>
>  drivers/i2c/designware_i2c.c | 5 +++--
>  drivers/i2c/i2c-uclass.c | 1 +
>  include/i2c.h| 1 +
>  3 files changed, 5 insertions(+), 2 deletions(-)
>

Thanks for the patch!

Is there a test that was failing before (test/dm/i2c.c) or should we add a new 
one to catch this?

Regards,
Simon


Re: [dwi2c PATCH v1] dwi2c add offsets to reads

2020-11-06 Thread Simon Glass
Hi Cduffinx,

On Thu, 5 Nov 2020 at 14:26, cduffinx  wrote:
>
> modify the designware_i2c_xfer function to use 1 byte per
> address, it was set to 0 before which makes it think its
> reading a register type. Added offset of where it is
> supposed to read from. Before it was always reading from
> offset 0 despite specifying the offset in the higher level
> function.
>
> Signed-off-by: Cooper Duffin 
> Signed-off-by: cduffinx 
> ---
>
>  drivers/i2c/designware_i2c.c | 5 +++--
>  drivers/i2c/i2c-uclass.c | 1 +
>  include/i2c.h| 1 +
>  3 files changed, 5 insertions(+), 2 deletions(-)
>

Thanks for the patch!

Is there a test that was failing before (test/dm/i2c.c) or should we
add a new one to catch this?

Regards,
Simon