@@ -575,8 +575,9 @@ static bool _opp_is_supported(struct device *dev, struct opp_table *opp_table,
575575static int opp_parse_supplies (struct dev_pm_opp * opp , struct device * dev ,
576576 struct opp_table * opp_table )
577577{
578- u32 * microvolt , * microamp = NULL ;
579- int supplies = opp_table -> regulator_count , vcount , icount , ret , i , j ;
578+ u32 * microvolt , * microamp = NULL , * microwatt = NULL ;
579+ int supplies = opp_table -> regulator_count ;
580+ int vcount , icount , pcount , ret , i , j ;
580581 struct property * prop = NULL ;
581582 char name [NAME_MAX ];
582583
@@ -688,6 +689,43 @@ static int opp_parse_supplies(struct dev_pm_opp *opp, struct device *dev,
688689 }
689690 }
690691
692+ /* Search for "opp-microwatt" */
693+ sprintf (name , "opp-microwatt" );
694+ prop = of_find_property (opp -> np , name , NULL );
695+
696+ if (prop ) {
697+ pcount = of_property_count_u32_elems (opp -> np , name );
698+ if (pcount < 0 ) {
699+ dev_err (dev , "%s: Invalid %s property (%d)\n" , __func__ ,
700+ name , pcount );
701+ ret = pcount ;
702+ goto free_microamp ;
703+ }
704+
705+ if (pcount != supplies ) {
706+ dev_err (dev , "%s: Invalid number of elements in %s property (%d) with supplies (%d)\n" ,
707+ __func__ , name , pcount , supplies );
708+ ret = - EINVAL ;
709+ goto free_microamp ;
710+ }
711+
712+ microwatt = kmalloc_array (pcount , sizeof (* microwatt ),
713+ GFP_KERNEL );
714+ if (!microwatt ) {
715+ ret = - EINVAL ;
716+ goto free_microamp ;
717+ }
718+
719+ ret = of_property_read_u32_array (opp -> np , name , microwatt ,
720+ pcount );
721+ if (ret ) {
722+ dev_err (dev , "%s: error parsing %s: %d\n" , __func__ ,
723+ name , ret );
724+ ret = - EINVAL ;
725+ goto free_microwatt ;
726+ }
727+ }
728+
691729 for (i = 0 , j = 0 ; i < supplies ; i ++ ) {
692730 opp -> supplies [i ].u_volt = microvolt [j ++ ];
693731
@@ -701,8 +739,13 @@ static int opp_parse_supplies(struct dev_pm_opp *opp, struct device *dev,
701739
702740 if (microamp )
703741 opp -> supplies [i ].u_amp = microamp [i ];
742+
743+ if (microwatt )
744+ opp -> supplies [i ].u_watt = microwatt [i ];
704745 }
705746
747+ free_microwatt :
748+ kfree (microwatt );
706749free_microamp :
707750 kfree (microamp );
708751free_microvolt :
0 commit comments