pfuze100-regulator.c (49ab19a4a51a31cb06992386cec4be82ebca5a2d) | pfuze100-regulator.c (6a6939d5f588b40db32b82ebcec20ee5189c8376) |
---|---|
1// SPDX-License-Identifier: GPL-2.0+ 2// 3// Copyright (C) 2011-2013 Freescale Semiconductor, Inc. All Rights Reserved. 4 5#include <linux/kernel.h> 6#include <linux/module.h> 7#include <linux/init.h> 8#include <linux/err.h> --- 91 unchanged lines hidden (view full) --- 100static const int pfuze3000_sw2lo[] = { 101 1500000, 1550000, 1600000, 1650000, 1700000, 1750000, 1800000, 1850000, 102}; 103 104static const int pfuze3000_sw2hi[] = { 105 2500000, 2800000, 2850000, 3000000, 3100000, 3150000, 3200000, 3300000, 106}; 107 | 1// SPDX-License-Identifier: GPL-2.0+ 2// 3// Copyright (C) 2011-2013 Freescale Semiconductor, Inc. All Rights Reserved. 4 5#include <linux/kernel.h> 6#include <linux/module.h> 7#include <linux/init.h> 8#include <linux/err.h> --- 91 unchanged lines hidden (view full) --- 100static const int pfuze3000_sw2lo[] = { 101 1500000, 1550000, 1600000, 1650000, 1700000, 1750000, 1800000, 1850000, 102}; 103 104static const int pfuze3000_sw2hi[] = { 105 2500000, 2800000, 2850000, 3000000, 3100000, 3150000, 3200000, 3300000, 106}; 107 |
108static const struct i2c_device_id pfuze_device_id[] = { 109 {.name = "pfuze100", .driver_data = PFUZE100}, 110 {.name = "pfuze200", .driver_data = PFUZE200}, 111 {.name = "pfuze3000", .driver_data = PFUZE3000}, 112 {.name = "pfuze3001", .driver_data = PFUZE3001}, 113 { } 114}; 115MODULE_DEVICE_TABLE(i2c, pfuze_device_id); 116 | |
117static const struct of_device_id pfuze_dt_ids[] = { 118 { .compatible = "fsl,pfuze100", .data = (void *)PFUZE100}, 119 { .compatible = "fsl,pfuze200", .data = (void *)PFUZE200}, 120 { .compatible = "fsl,pfuze3000", .data = (void *)PFUZE3000}, 121 { .compatible = "fsl,pfuze3001", .data = (void *)PFUZE3001}, 122 { } 123}; 124MODULE_DEVICE_TABLE(of, pfuze_dt_ids); --- 310 unchanged lines hidden (view full) --- 435 PFUZE100_VGEN_REG(PFUZE3001, VLDO1, PFUZE100_VGEN1VOL, 1800000, 3300000, 100000), 436 PFUZE100_VGEN_REG(PFUZE3001, VLDO2, PFUZE100_VGEN2VOL, 800000, 1550000, 50000), 437 PFUZE3000_VCC_REG(PFUZE3001, VCCSD, PFUZE100_VGEN3VOL, 2850000, 3300000, 150000), 438 PFUZE3000_VCC_REG(PFUZE3001, V33, PFUZE100_VGEN4VOL, 2850000, 3300000, 150000), 439 PFUZE100_VGEN_REG(PFUZE3001, VLDO3, PFUZE100_VGEN5VOL, 1800000, 3300000, 100000), 440 PFUZE100_VGEN_REG(PFUZE3001, VLDO4, PFUZE100_VGEN6VOL, 1800000, 3300000, 100000), 441}; 442 | 108static const struct of_device_id pfuze_dt_ids[] = { 109 { .compatible = "fsl,pfuze100", .data = (void *)PFUZE100}, 110 { .compatible = "fsl,pfuze200", .data = (void *)PFUZE200}, 111 { .compatible = "fsl,pfuze3000", .data = (void *)PFUZE3000}, 112 { .compatible = "fsl,pfuze3001", .data = (void *)PFUZE3001}, 113 { } 114}; 115MODULE_DEVICE_TABLE(of, pfuze_dt_ids); --- 310 unchanged lines hidden (view full) --- 426 PFUZE100_VGEN_REG(PFUZE3001, VLDO1, PFUZE100_VGEN1VOL, 1800000, 3300000, 100000), 427 PFUZE100_VGEN_REG(PFUZE3001, VLDO2, PFUZE100_VGEN2VOL, 800000, 1550000, 50000), 428 PFUZE3000_VCC_REG(PFUZE3001, VCCSD, PFUZE100_VGEN3VOL, 2850000, 3300000, 150000), 429 PFUZE3000_VCC_REG(PFUZE3001, V33, PFUZE100_VGEN4VOL, 2850000, 3300000, 150000), 430 PFUZE100_VGEN_REG(PFUZE3001, VLDO3, PFUZE100_VGEN5VOL, 1800000, 3300000, 100000), 431 PFUZE100_VGEN_REG(PFUZE3001, VLDO4, PFUZE100_VGEN6VOL, 1800000, 3300000, 100000), 432}; 433 |
443#ifdef CONFIG_OF | |
444/* PFUZE100 */ 445static struct of_regulator_match pfuze100_matches[] = { 446 { .name = "sw1ab", }, 447 { .name = "sw1c", }, 448 { .name = "sw2", }, 449 { .name = "sw3a", }, 450 { .name = "sw3b", }, 451 { .name = "sw4", }, --- 121 unchanged lines hidden (view full) --- 573{ 574 return pfuze_matches[index].init_data; 575} 576 577static inline struct device_node *match_of_node(int index) 578{ 579 return pfuze_matches[index].of_node; 580} | 434/* PFUZE100 */ 435static struct of_regulator_match pfuze100_matches[] = { 436 { .name = "sw1ab", }, 437 { .name = "sw1c", }, 438 { .name = "sw2", }, 439 { .name = "sw3a", }, 440 { .name = "sw3b", }, 441 { .name = "sw4", }, --- 121 unchanged lines hidden (view full) --- 563{ 564 return pfuze_matches[index].init_data; 565} 566 567static inline struct device_node *match_of_node(int index) 568{ 569 return pfuze_matches[index].of_node; 570} |
581#else 582static int pfuze_parse_regulators_dt(struct pfuze_chip *chip) 583{ 584 return 0; 585} | |
586 | 571 |
587static inline struct regulator_init_data *match_init_data(int index) 588{ 589 return NULL; 590} 591 592static inline struct device_node *match_of_node(int index) 593{ 594 return NULL; 595} 596#endif 597 | |
598static struct pfuze_chip *syspm_pfuze_chip; 599 600static void pfuze_power_off_prepare(void) 601{ 602 dev_info(syspm_pfuze_chip->dev, "Configure standby mode for power off"); 603 604 /* Switch from default mode: APS/APS to APS/Off */ 605 regmap_update_bits(syspm_pfuze_chip->regmap, PFUZE100_SW1ABMODE, --- 97 unchanged lines hidden (view full) --- 703 .max_register = PFUZE_NUMREGS - 1, 704 .cache_type = REGCACHE_RBTREE, 705}; 706 707static int pfuze100_regulator_probe(struct i2c_client *client, 708 const struct i2c_device_id *id) 709{ 710 struct pfuze_chip *pfuze_chip; | 572static struct pfuze_chip *syspm_pfuze_chip; 573 574static void pfuze_power_off_prepare(void) 575{ 576 dev_info(syspm_pfuze_chip->dev, "Configure standby mode for power off"); 577 578 /* Switch from default mode: APS/APS to APS/Off */ 579 regmap_update_bits(syspm_pfuze_chip->regmap, PFUZE100_SW1ABMODE, --- 97 unchanged lines hidden (view full) --- 677 .max_register = PFUZE_NUMREGS - 1, 678 .cache_type = REGCACHE_RBTREE, 679}; 680 681static int pfuze100_regulator_probe(struct i2c_client *client, 682 const struct i2c_device_id *id) 683{ 684 struct pfuze_chip *pfuze_chip; |
711 struct pfuze_regulator_platform_data *pdata = 712 dev_get_platdata(&client->dev); | |
713 struct regulator_config config = { }; 714 int i, ret; 715 const struct of_device_id *match; 716 u32 regulator_num; 717 u32 sw_check_start, sw_check_end, sw_hi = 0x40; 718 719 pfuze_chip = devm_kzalloc(&client->dev, sizeof(*pfuze_chip), 720 GFP_KERNEL); --- 76 unchanged lines hidden (view full) --- 797 798 for (i = 0; i < regulator_num; i++) { 799 struct regulator_init_data *init_data; 800 struct regulator_desc *desc; 801 int val; 802 803 desc = &pfuze_chip->regulator_descs[i].desc; 804 | 685 struct regulator_config config = { }; 686 int i, ret; 687 const struct of_device_id *match; 688 u32 regulator_num; 689 u32 sw_check_start, sw_check_end, sw_hi = 0x40; 690 691 pfuze_chip = devm_kzalloc(&client->dev, sizeof(*pfuze_chip), 692 GFP_KERNEL); --- 76 unchanged lines hidden (view full) --- 769 770 for (i = 0; i < regulator_num; i++) { 771 struct regulator_init_data *init_data; 772 struct regulator_desc *desc; 773 int val; 774 775 desc = &pfuze_chip->regulator_descs[i].desc; 776 |
805 if (pdata) 806 init_data = pdata->init_data[i]; 807 else 808 init_data = match_init_data(i); | 777 init_data = match_init_data(i); |
809 810 /* SW2~SW4 high bit check and modify the voltage value table */ 811 if (i >= sw_check_start && i <= sw_check_end) { 812 ret = regmap_read(pfuze_chip->regmap, 813 desc->vsel_reg, &val); 814 if (ret) { 815 dev_err(&client->dev, "Fails to read from the register.\n"); 816 return ret; --- 14 unchanged lines hidden (view full) --- 831 832 /* 833 * Allow SW regulators to turn off. Checking it trough a flag is 834 * a workaround to keep the backward compatibility with existing 835 * old dtb's which may relay on the fact that we didn't disable 836 * the switched regulator till yet. 837 */ 838 if (pfuze_chip->flags & PFUZE_FLAG_DISABLE_SW) { | 778 779 /* SW2~SW4 high bit check and modify the voltage value table */ 780 if (i >= sw_check_start && i <= sw_check_end) { 781 ret = regmap_read(pfuze_chip->regmap, 782 desc->vsel_reg, &val); 783 if (ret) { 784 dev_err(&client->dev, "Fails to read from the register.\n"); 785 return ret; --- 14 unchanged lines hidden (view full) --- 800 801 /* 802 * Allow SW regulators to turn off. Checking it trough a flag is 803 * a workaround to keep the backward compatibility with existing 804 * old dtb's which may relay on the fact that we didn't disable 805 * the switched regulator till yet. 806 */ 807 if (pfuze_chip->flags & PFUZE_FLAG_DISABLE_SW) { |
839 if (pfuze_chip->chip_id == PFUZE100 || 840 pfuze_chip->chip_id == PFUZE200) { 841 if (pfuze_chip->regulator_descs[i].sw_reg) { 842 desc->ops = &pfuze100_sw_disable_regulator_ops; 843 desc->enable_val = 0x8; 844 desc->disable_val = 0x0; 845 desc->enable_time = 500; 846 } | 808 if (pfuze_chip->regulator_descs[i].sw_reg) { 809 desc->ops = &pfuze100_sw_disable_regulator_ops; 810 desc->enable_val = 0x8; 811 desc->disable_val = 0x0; 812 desc->enable_time = 500; |
847 } 848 } 849 850 config.dev = &client->dev; 851 config.init_data = init_data; 852 config.driver_data = pfuze_chip; 853 config.of_node = match_of_node(i); 854 --- 19 unchanged lines hidden (view full) --- 874 syspm_pfuze_chip = NULL; 875 pm_power_off_prepare = NULL; 876 } 877 878 return 0; 879} 880 881static struct i2c_driver pfuze_driver = { | 813 } 814 } 815 816 config.dev = &client->dev; 817 config.init_data = init_data; 818 config.driver_data = pfuze_chip; 819 config.of_node = match_of_node(i); 820 --- 19 unchanged lines hidden (view full) --- 840 syspm_pfuze_chip = NULL; 841 pm_power_off_prepare = NULL; 842 } 843 844 return 0; 845} 846 847static struct i2c_driver pfuze_driver = { |
882 .id_table = pfuze_device_id, | |
883 .driver = { 884 .name = "pfuze100-regulator", 885 .of_match_table = pfuze_dt_ids, 886 }, 887 .probe = pfuze100_regulator_probe, 888 .remove = pfuze100_regulator_remove, 889}; 890module_i2c_driver(pfuze_driver); 891 892MODULE_AUTHOR("Robin Gong <b38343@freescale.com>"); 893MODULE_DESCRIPTION("Regulator Driver for Freescale PFUZE100/200/3000/3001 PMIC"); 894MODULE_LICENSE("GPL v2"); | 848 .driver = { 849 .name = "pfuze100-regulator", 850 .of_match_table = pfuze_dt_ids, 851 }, 852 .probe = pfuze100_regulator_probe, 853 .remove = pfuze100_regulator_remove, 854}; 855module_i2c_driver(pfuze_driver); 856 857MODULE_AUTHOR("Robin Gong <b38343@freescale.com>"); 858MODULE_DESCRIPTION("Regulator Driver for Freescale PFUZE100/200/3000/3001 PMIC"); 859MODULE_LICENSE("GPL v2"); |