[PATCH 4/5] ARM: novena: Read Ethernet MAC address from EEPROM

John Watts contact at jookia.org
Tue Jan 24 10:35:53 PST 2023


On Mon, Jan 23, 2023 at 10:33:05AM +0100, Sascha Hauer wrote:
> And here is the point where you have to request that the EEPROM is
> actually availabe to support the deep probe mechanism. Before reading
> the EEPROM add a call to:
> 
> 	of_device_ensure_probed_by_alias("eeprom0");
> 
> Nowadays the read-MAC-address-from-EEPROM thingy would likely be done
> using nvmem cells which would boil this code down to device tree changes
> only. If you're feeling brave you could change this, I won't insist on
> it though.
> 
> Sascha

Hey Sascha,

I did some refactoring today based on your suggestions and now have this code:

        rc = of_device_ensure_probed_by_alias("eeprom0");

        if (rc < 0) {
                pr_err("Unable to probe Novena EEPROM: %s\n", strerror(-rc));
                return NULL;
        }

        rc = read_file_2("/dev/eeprom0", &read, &eeprom, max);

This gets me this bootup sequence:

  of_platform_device_create: register device 21a8000.i2c at 21a8000.of, io=0x021a8000
  register_device: 21a8000.i2c at 21a8000.of
          probe-> 21a8000.i2c at 21a8000.of
  imx-iomuxv3 20e0000.pinctrl at 20e0000.of: set state: /soc/bus at 2000000/pinctrl at 20e0000/i2c3grp-novena
  __request_region ok: 0x021a8000:0x021abfff flags=0x0
  of_get_named_gpio_flags: cannot parse sda-gpios property: -2
  of_get_named_gpio_flags: cannot parse scl-gpios property: -2
  <NULL>: <i2c_fsl_set_clk> I2C_CLK=66000000, REQ DIV=660
  <NULL>: <i2c_fsl_set_clk> IFDR[IC]=0x39, REAL DIV=768
  register_device: i2c0
  register_device: es83280
  es83280: registered on bus 0, chip->addr 0x11
  register_device: 24c5120
              probe-> 24c5120
  of_get_named_gpio_flags: cannot parse wp-gpios property: -2
  at24 24c5120: Registering nvmem device eeprom0
  register_device: eeprom00
  at24 24c5120: registered on bus 0, chip->addr 0x56
  eeprom00: read ofs: 0x00000000 count: 0x00000014
  i2c0: master_xfer[0] W, addr=0x56, len=2
  i2c0: master_xfer[1] R, addr=0x56, len=20
  i2c0: timeout waiting for status set 0x20, cur status: 0x93
  at24 24c5120: read 20 at 0 --> -95 (1046280961)
  Unable to read Novena EEPROM: Connection timed out

After the shell boots I'm able to read /dev/eeprom0 just fine.

John.



More information about the barebox mailing list