4444#define PFUZE100_VGEN5VOL 0x70
4545#define PFUZE100_VGEN6VOL 0x71
4646
47- enum chips { PFUZE100 , PFUZE200 , PFUZE3000 = 3 };
47+ enum chips { PFUZE100 , PFUZE200 , PFUZE3000 = 3 , PFUZE3001 = 0x31 , };
4848
4949struct pfuze_regulator {
5050 struct regulator_desc desc ;
@@ -92,6 +92,7 @@ static const struct i2c_device_id pfuze_device_id[] = {
9292 {.name = "pfuze100" , .driver_data = PFUZE100 },
9393 {.name = "pfuze200" , .driver_data = PFUZE200 },
9494 {.name = "pfuze3000" , .driver_data = PFUZE3000 },
95+ {.name = "pfuze3001" , .driver_data = PFUZE3001 },
9596 { }
9697};
9798MODULE_DEVICE_TABLE (i2c , pfuze_device_id );
@@ -100,6 +101,7 @@ static const struct of_device_id pfuze_dt_ids[] = {
100101 { .compatible = "fsl,pfuze100" , .data = (void * )PFUZE100 },
101102 { .compatible = "fsl,pfuze200" , .data = (void * )PFUZE200 },
102103 { .compatible = "fsl,pfuze3000" , .data = (void * )PFUZE3000 },
104+ { .compatible = "fsl,pfuze3001" , .data = (void * )PFUZE3001 },
103105 { }
104106};
105107MODULE_DEVICE_TABLE (of , pfuze_dt_ids );
@@ -108,19 +110,38 @@ static int pfuze100_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay)
108110{
109111 struct pfuze_chip * pfuze100 = rdev_get_drvdata (rdev );
110112 int id = rdev_get_id (rdev );
113+ bool reg_has_ramp_delay ;
111114 unsigned int ramp_bits ;
112115 int ret ;
113116
114- if (id < PFUZE100_SWBST ) {
117+ switch (pfuze100 -> chip_id ) {
118+ case PFUZE3001 :
119+ /* no dynamic voltage scaling for PF3001 */
120+ reg_has_ramp_delay = false;
121+ break ;
122+ case PFUZE3000 :
123+ reg_has_ramp_delay = (id < PFUZE3000_SWBST );
124+ break ;
125+ case PFUZE200 :
126+ reg_has_ramp_delay = (id < PFUZE200_SWBST );
127+ break ;
128+ case PFUZE100 :
129+ default :
130+ reg_has_ramp_delay = (id < PFUZE100_SWBST );
131+ break ;
132+ }
133+
134+ if (reg_has_ramp_delay ) {
115135 ramp_delay = 12500 / ramp_delay ;
116136 ramp_bits = (ramp_delay >> 1 ) - (ramp_delay >> 3 );
117137 ret = regmap_update_bits (pfuze100 -> regmap ,
118138 rdev -> desc -> vsel_reg + 4 ,
119139 0xc0 , ramp_bits << 6 );
120140 if (ret < 0 )
121141 dev_err (pfuze100 -> dev , "ramp failed, err %d\n" , ret );
122- } else
142+ } else {
123143 ret = - EACCES ;
144+ }
124145
125146 return ret ;
126147}
@@ -361,6 +382,19 @@ static struct pfuze_regulator pfuze3000_regulators[] = {
361382 PFUZE100_VGEN_REG (PFUZE3000 , VLDO4 , PFUZE100_VGEN6VOL , 1800000 , 3300000 , 100000 ),
362383};
363384
385+ static struct pfuze_regulator pfuze3001_regulators [] = {
386+ PFUZE100_SWB_REG (PFUZE3001 , SW1 , PFUZE100_SW1ABVOL , 0x1f , pfuze3000_sw1a ),
387+ PFUZE100_SWB_REG (PFUZE3001 , SW2 , PFUZE100_SW2VOL , 0x7 , pfuze3000_sw2lo ),
388+ PFUZE3000_SW3_REG (PFUZE3001 , SW3 , PFUZE100_SW3AVOL , 900000 , 1650000 , 50000 ),
389+ PFUZE100_SWB_REG (PFUZE3001 , VSNVS , PFUZE100_VSNVSVOL , 0x7 , pfuze100_vsnvs ),
390+ PFUZE100_VGEN_REG (PFUZE3001 , VLDO1 , PFUZE100_VGEN1VOL , 1800000 , 3300000 , 100000 ),
391+ PFUZE100_VGEN_REG (PFUZE3001 , VLDO2 , PFUZE100_VGEN2VOL , 800000 , 1550000 , 50000 ),
392+ PFUZE3000_VCC_REG (PFUZE3001 , VCCSD , PFUZE100_VGEN3VOL , 2850000 , 3300000 , 150000 ),
393+ PFUZE3000_VCC_REG (PFUZE3001 , V33 , PFUZE100_VGEN4VOL , 2850000 , 3300000 , 150000 ),
394+ PFUZE100_VGEN_REG (PFUZE3001 , VLDO3 , PFUZE100_VGEN5VOL , 1800000 , 3300000 , 100000 ),
395+ PFUZE100_VGEN_REG (PFUZE3001 , VLDO4 , PFUZE100_VGEN6VOL , 1800000 , 3300000 , 100000 ),
396+ };
397+
364398#ifdef CONFIG_OF
365399/* PFUZE100 */
366400static struct of_regulator_match pfuze100_matches [] = {
@@ -418,6 +452,21 @@ static struct of_regulator_match pfuze3000_matches[] = {
418452 { .name = "vldo4" , },
419453};
420454
455+ /* PFUZE3001 */
456+ static struct of_regulator_match pfuze3001_matches [] = {
457+
458+ { .name = "sw1" , },
459+ { .name = "sw2" , },
460+ { .name = "sw3" , },
461+ { .name = "vsnvs" , },
462+ { .name = "vldo1" , },
463+ { .name = "vldo2" , },
464+ { .name = "vccsd" , },
465+ { .name = "v33" , },
466+ { .name = "vldo3" , },
467+ { .name = "vldo4" , },
468+ };
469+
421470static struct of_regulator_match * pfuze_matches ;
422471
423472static int pfuze_parse_regulators_dt (struct pfuze_chip * chip )
@@ -437,6 +486,11 @@ static int pfuze_parse_regulators_dt(struct pfuze_chip *chip)
437486 }
438487
439488 switch (chip -> chip_id ) {
489+ case PFUZE3001 :
490+ pfuze_matches = pfuze3001_matches ;
491+ ret = of_regulator_match (dev , parent , pfuze3001_matches ,
492+ ARRAY_SIZE (pfuze3001_matches ));
493+ break ;
440494 case PFUZE3000 :
441495 pfuze_matches = pfuze3000_matches ;
442496 ret = of_regulator_match (dev , parent , pfuze3000_matches ,
@@ -508,7 +562,8 @@ static int pfuze_identify(struct pfuze_chip *pfuze_chip)
508562 */
509563 dev_info (pfuze_chip -> dev , "Assuming misprogrammed ID=0x8" );
510564 } else if ((value & 0x0f ) != pfuze_chip -> chip_id &&
511- (value & 0xf0 ) >> 4 != pfuze_chip -> chip_id ) {
565+ (value & 0xf0 ) >> 4 != pfuze_chip -> chip_id &&
566+ (value != pfuze_chip -> chip_id )) {
512567 /* device id NOT match with your setting */
513568 dev_warn (pfuze_chip -> dev , "Illegal ID: %x\n" , value );
514569 return - ENODEV ;
@@ -588,6 +643,13 @@ static int pfuze100_regulator_probe(struct i2c_client *client,
588643
589644 /* use the right regulators after identify the right device */
590645 switch (pfuze_chip -> chip_id ) {
646+ case PFUZE3001 :
647+ pfuze_chip -> pfuze_regulators = pfuze3001_regulators ;
648+ regulator_num = ARRAY_SIZE (pfuze3001_regulators );
649+ sw_check_start = PFUZE3001_SW2 ;
650+ sw_check_end = PFUZE3001_SW2 ;
651+ sw_hi = 1 << 3 ;
652+ break ;
591653 case PFUZE3000 :
592654 pfuze_chip -> pfuze_regulators = pfuze3000_regulators ;
593655 regulator_num = ARRAY_SIZE (pfuze3000_regulators );
@@ -611,7 +673,8 @@ static int pfuze100_regulator_probe(struct i2c_client *client,
611673 }
612674 dev_info (& client -> dev , "pfuze%s found.\n" ,
613675 (pfuze_chip -> chip_id == PFUZE100 ) ? "100" :
614- ((pfuze_chip -> chip_id == PFUZE200 ) ? "200" : "3000" ));
676+ (((pfuze_chip -> chip_id == PFUZE200 ) ? "200" :
677+ ((pfuze_chip -> chip_id == PFUZE3000 ) ? "3000" : "3001" ))));
615678
616679 memcpy (pfuze_chip -> regulator_descs , pfuze_chip -> pfuze_regulators ,
617680 sizeof (pfuze_chip -> regulator_descs ));
@@ -636,7 +699,8 @@ static int pfuze100_regulator_probe(struct i2c_client *client,
636699 if (i >= sw_check_start && i <= sw_check_end ) {
637700 regmap_read (pfuze_chip -> regmap , desc -> vsel_reg , & val );
638701 if (val & sw_hi ) {
639- if (pfuze_chip -> chip_id == PFUZE3000 ) {
702+ if (pfuze_chip -> chip_id == PFUZE3000 ||
703+ pfuze_chip -> chip_id == PFUZE3001 ) {
640704 desc -> volt_table = pfuze3000_sw2hi ;
641705 desc -> n_voltages = ARRAY_SIZE (pfuze3000_sw2hi );
642706 } else {
@@ -675,5 +739,5 @@ static struct i2c_driver pfuze_driver = {
675739module_i2c_driver (pfuze_driver );
676740
677741MODULE_AUTHOR ("Robin Gong <b38343@freescale.com>" );
678- MODULE_DESCRIPTION ("Regulator Driver for Freescale PFUZE100/200/3000 PMIC" );
742+ MODULE_DESCRIPTION ("Regulator Driver for Freescale PFUZE100/200/3000/3001 PMIC" );
679743MODULE_LICENSE ("GPL v2" );
0 commit comments