.. | .. |
---|
8 | 8 | #include <common.h> |
---|
9 | 9 | #include <errno.h> |
---|
10 | 10 | #include <dm.h> |
---|
11 | | -#include <dm/device-internal.h> |
---|
12 | 11 | #include <dm/uclass-internal.h> |
---|
13 | 12 | #include <power/pmic.h> |
---|
14 | 13 | #include <power/regulator.h> |
---|
.. | .. |
---|
413 | 412 | if (regulator_name_is_unique(dev, uc_pdata->name)) |
---|
414 | 413 | return 0; |
---|
415 | 414 | |
---|
416 | | -#ifdef CONFIG_USING_KERNEL_DTB |
---|
417 | | - printf("Pre-reloc: %s\n", uc_pdata->name); |
---|
418 | | - |
---|
419 | | - return 0; |
---|
420 | | -#else |
---|
421 | 415 | debug("'%s' of dev: '%s', has nonunique value: '%s\n", |
---|
422 | 416 | property, dev->name, uc_pdata->name); |
---|
423 | 417 | |
---|
424 | 418 | return -EINVAL; |
---|
425 | | -#endif |
---|
426 | 419 | } |
---|
427 | 420 | |
---|
428 | 421 | static int regulator_pre_probe(struct udevice *dev) |
---|
.. | .. |
---|
505 | 498 | return ret; |
---|
506 | 499 | } |
---|
507 | 500 | |
---|
508 | | -#ifdef CONFIG_USING_KERNEL_DTB |
---|
509 | | -/* |
---|
510 | | - * Skip probed pre-reloc regulators. |
---|
511 | | - * |
---|
512 | | - * Some regulator like fixed/gpio regultor applies a default output state |
---|
513 | | - * when probed. It maybe reverse the state which was set by the pre-reloc |
---|
514 | | - * regulator. Example: vcc3v3_pcie. |
---|
515 | | - */ |
---|
516 | | -int regulators_enable_boot_on(bool verbose) |
---|
517 | | -{ |
---|
518 | | - struct dm_regulator_uclass_platdata *uc_pdata; |
---|
519 | | - struct udevice *dev; |
---|
520 | | - struct uclass *uc; |
---|
521 | | - char **pre_probed = NULL; |
---|
522 | | - int i = 0, num = 0; |
---|
523 | | - int ret; |
---|
524 | | - bool skip; |
---|
525 | | - |
---|
526 | | - ret = uclass_get(UCLASS_REGULATOR, &uc); |
---|
527 | | - if (ret) |
---|
528 | | - return ret; |
---|
529 | | - |
---|
530 | | - /* find probed pre-reloc regulators */ |
---|
531 | | - for (uclass_find_first_device(UCLASS_REGULATOR, &dev); |
---|
532 | | - dev; |
---|
533 | | - uclass_find_next_device(&dev)) { |
---|
534 | | - if (!(dev->flags & DM_FLAG_KNRL_DTB) && |
---|
535 | | - (dev->flags & DM_FLAG_ACTIVATED)) |
---|
536 | | - num++; |
---|
537 | | - } |
---|
538 | | - if (num) { |
---|
539 | | - pre_probed = calloc(num, sizeof(char *)); |
---|
540 | | - if (!pre_probed) |
---|
541 | | - return -ENOMEM; |
---|
542 | | - |
---|
543 | | - for (uclass_find_first_device(UCLASS_REGULATOR, &dev); |
---|
544 | | - dev; |
---|
545 | | - uclass_find_next_device(&dev)) { |
---|
546 | | - if (!(dev->flags & DM_FLAG_KNRL_DTB) && |
---|
547 | | - (dev->flags & DM_FLAG_ACTIVATED)) { |
---|
548 | | - uc_pdata = dev_get_uclass_platdata(dev); |
---|
549 | | - pre_probed[i++] = (char *)uc_pdata->name; |
---|
550 | | - } |
---|
551 | | - } |
---|
552 | | - } |
---|
553 | | - |
---|
554 | | - /* Skip kernel regulators whose name matches probed pre-reloc regulators */ |
---|
555 | | - for (uclass_find_first_device(UCLASS_REGULATOR, &dev); |
---|
556 | | - dev; |
---|
557 | | - uclass_find_next_device(&dev)) { |
---|
558 | | - uc_pdata = dev_get_uclass_platdata(dev); |
---|
559 | | - debug("%s: %s%s\n", __func__, uc_pdata->name, |
---|
560 | | - dev->flags & DM_FLAG_KNRL_DTB ? "" : "*"); |
---|
561 | | - if (dev->flags & DM_FLAG_KNRL_DTB) { |
---|
562 | | - for (i = 0, skip = false; i < num; i++) { |
---|
563 | | - if (!strcmp(pre_probed[i], uc_pdata->name)) { |
---|
564 | | - skip = true; |
---|
565 | | - break; |
---|
566 | | - } |
---|
567 | | - } |
---|
568 | | - if (skip) |
---|
569 | | - continue; |
---|
570 | | - } |
---|
571 | | - |
---|
572 | | - /* Probe and init */ |
---|
573 | | - ret = device_probe(dev); |
---|
574 | | - if (ret) |
---|
575 | | - continue; |
---|
576 | | - ret = regulator_autoset(dev); |
---|
577 | | - if (ret == -EMEDIUMTYPE) |
---|
578 | | - ret = 0; |
---|
579 | | - if (verbose) |
---|
580 | | - regulator_show(dev, ret); |
---|
581 | | - if (ret == -ENOSYS) |
---|
582 | | - ret = 0; |
---|
583 | | - } |
---|
584 | | - |
---|
585 | | - if (pre_probed) |
---|
586 | | - free(pre_probed); |
---|
587 | | - |
---|
588 | | - return ret; |
---|
589 | | -} |
---|
590 | | - |
---|
591 | | -#else |
---|
592 | 501 | int regulators_enable_boot_on(bool verbose) |
---|
593 | 502 | { |
---|
594 | 503 | struct udevice *dev; |
---|
.. | .. |
---|
613 | 522 | |
---|
614 | 523 | return ret; |
---|
615 | 524 | } |
---|
616 | | -#endif |
---|
617 | 525 | |
---|
618 | 526 | UCLASS_DRIVER(regulator) = { |
---|
619 | 527 | .id = UCLASS_REGULATOR, |
---|