2424#define DEBUG 0
2525
2626#include <common.h>
27+ #include <linux/delay.h>
2728#include <errno.h>
2829#include <dm.h>
2930#include <i2c.h>
@@ -379,12 +380,11 @@ static void nvec_init_i2c_slave(struct nvec_t *nvec)
379380/**
380381 * Decode the nvec information from the fdt.
381382 *
382- * @param blob fdt blob
383- * @param config structure to store fdt config into
383+ * @param dev nvec device
384+ * @param config structure to store fdt config into
384385 * @return 0 if ok, -ve on error
385386 */
386- static int nvec_decode_fdt (const void * blob , int node ,
387- struct nvec_t * nvec )
387+ static int nvec_decode_fdt (struct udevice * dev , struct nvec_t * nvec )
388388{
389389// int ret;
390390
@@ -395,22 +395,19 @@ static int nvec_decode_fdt(const void *blob, int node,
395395// return -ENOENT;
396396// }
397397
398- nvec -> base = (void __iomem * )fdtdec_get_addr (blob , node , "reg" );
399- if (nvec -> base == (void __iomem * )FDT_ADDR_T_NONE ) {
400- error ("No NVEC controller address" );
401- return - ENOENT ;
402- }
403- nvec -> i2c_addr = fdtdec_get_int (blob , node , "slave-addr" , -1 );
404- nvec -> i2c_clk = fdtdec_get_int (blob , node , "clock-frequency" , -1 );
398+ nvec -> base = dev_read_addr_ptr (dev );
399+ if (!nvec -> base )
400+ return - ENOMEM ;
401+
402+ nvec -> i2c_addr = dev_read_u32_default (dev , "slave-addr" , -1 );
403+ nvec -> i2c_clk = dev_read_u32_default (dev , "clock-frequency" , -1 );
405404
406405 return 0 ;
407406}
408407
409408static int nvec_probe (struct udevice * dev )
410409{
411410 struct nvec_t * nvec = dev_get_priv (dev );
412- const void * blob = gd -> fdt_blob ;
413- int node = dev -> node .of_offset ;
414411 int res ;
415412
416413 TRACE ();
@@ -424,7 +421,7 @@ static int nvec_probe(struct udevice *dev)
424421
425422 debug ("NVEC initialization...\n" );
426423
427- if (nvec_decode_fdt (blob , node , nvec_data )) {
424+ if (nvec_decode_fdt (dev , nvec_data )) {
428425 error ("Failed to decode fdt" );
429426 return - EBUSY ;
430427 }
@@ -519,6 +516,6 @@ U_BOOT_DRIVER(i2c_nvec) = {
519516 .id = UCLASS_I2C ,
520517 .of_match = i2c_nvec_ids ,
521518 .probe = nvec_probe ,
522- .priv_auto_alloc_size = sizeof (struct nvec_t ),
519+ .priv_auto = sizeof (struct nvec_t ),
523520 .ops = & i2c_nvec_ops ,
524521};
0 commit comments