18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Motorola CPCAP PMIC regulator driver 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Based on cpcap-regulator.c from Motorola Linux kernel tree 58c2ecf20Sopenharmony_ci * Copyright (C) 2009-2011 Motorola, Inc. 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Rewritten for mainline kernel to use device tree and regmap 88c2ecf20Sopenharmony_ci * Copyright (C) 2017 Tony Lindgren <tony@atomide.com> 98c2ecf20Sopenharmony_ci * 108c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or 118c2ecf20Sopenharmony_ci * modify it under the terms of the GNU General Public License as 128c2ecf20Sopenharmony_ci * published by the Free Software Foundation version 2. 138c2ecf20Sopenharmony_ci * 148c2ecf20Sopenharmony_ci * This program is distributed "as is" WITHOUT ANY WARRANTY of any 158c2ecf20Sopenharmony_ci * kind, whether express or implied; without even the implied warranty 168c2ecf20Sopenharmony_ci * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 178c2ecf20Sopenharmony_ci * GNU General Public License for more details. 188c2ecf20Sopenharmony_ci */ 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#include <linux/err.h> 218c2ecf20Sopenharmony_ci#include <linux/module.h> 228c2ecf20Sopenharmony_ci#include <linux/of.h> 238c2ecf20Sopenharmony_ci#include <linux/of_platform.h> 248c2ecf20Sopenharmony_ci#include <linux/regmap.h> 258c2ecf20Sopenharmony_ci#include <linux/regulator/driver.h> 268c2ecf20Sopenharmony_ci#include <linux/regulator/machine.h> 278c2ecf20Sopenharmony_ci#include <linux/regulator/of_regulator.h> 288c2ecf20Sopenharmony_ci#include <linux/mfd/motorola-cpcap.h> 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci/* 318c2ecf20Sopenharmony_ci * Resource assignment register bits. These seem to control the state 328c2ecf20Sopenharmony_ci * idle modes adn are used at least for omap4. 338c2ecf20Sopenharmony_ci */ 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci/* CPCAP_REG_ASSIGN2 bits - Resource Assignment 2 */ 368c2ecf20Sopenharmony_ci#define CPCAP_BIT_VSDIO_SEL BIT(15) 378c2ecf20Sopenharmony_ci#define CPCAP_BIT_VDIG_SEL BIT(14) 388c2ecf20Sopenharmony_ci#define CPCAP_BIT_VCAM_SEL BIT(13) 398c2ecf20Sopenharmony_ci#define CPCAP_BIT_SW6_SEL BIT(12) 408c2ecf20Sopenharmony_ci#define CPCAP_BIT_SW5_SEL BIT(11) 418c2ecf20Sopenharmony_ci#define CPCAP_BIT_SW4_SEL BIT(10) 428c2ecf20Sopenharmony_ci#define CPCAP_BIT_SW3_SEL BIT(9) 438c2ecf20Sopenharmony_ci#define CPCAP_BIT_SW2_SEL BIT(8) 448c2ecf20Sopenharmony_ci#define CPCAP_BIT_SW1_SEL BIT(7) 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci/* CPCAP_REG_ASSIGN3 bits - Resource Assignment 3 */ 478c2ecf20Sopenharmony_ci#define CPCAP_BIT_VUSBINT2_SEL BIT(15) 488c2ecf20Sopenharmony_ci#define CPCAP_BIT_VUSBINT1_SEL BIT(14) 498c2ecf20Sopenharmony_ci#define CPCAP_BIT_VVIB_SEL BIT(13) 508c2ecf20Sopenharmony_ci#define CPCAP_BIT_VWLAN1_SEL BIT(12) 518c2ecf20Sopenharmony_ci#define CPCAP_BIT_VRF1_SEL BIT(11) 528c2ecf20Sopenharmony_ci#define CPCAP_BIT_VHVIO_SEL BIT(10) 538c2ecf20Sopenharmony_ci#define CPCAP_BIT_VDAC_SEL BIT(9) 548c2ecf20Sopenharmony_ci#define CPCAP_BIT_VUSB_SEL BIT(8) 558c2ecf20Sopenharmony_ci#define CPCAP_BIT_VSIM_SEL BIT(7) 568c2ecf20Sopenharmony_ci#define CPCAP_BIT_VRFREF_SEL BIT(6) 578c2ecf20Sopenharmony_ci#define CPCAP_BIT_VPLL_SEL BIT(5) 588c2ecf20Sopenharmony_ci#define CPCAP_BIT_VFUSE_SEL BIT(4) 598c2ecf20Sopenharmony_ci#define CPCAP_BIT_VCSI_SEL BIT(3) 608c2ecf20Sopenharmony_ci#define CPCAP_BIT_SPARE_14_2 BIT(2) 618c2ecf20Sopenharmony_ci#define CPCAP_BIT_VWLAN2_SEL BIT(1) 628c2ecf20Sopenharmony_ci#define CPCAP_BIT_VRF2_SEL BIT(0) 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci/* CPCAP_REG_ASSIGN4 bits - Resource Assignment 4 */ 658c2ecf20Sopenharmony_ci#define CPCAP_BIT_VAUDIO_SEL BIT(0) 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci/* 688c2ecf20Sopenharmony_ci * Enable register bits. At least CPCAP_BIT_AUDIO_LOW_PWR is generic, 698c2ecf20Sopenharmony_ci * and not limited to audio regulator. Let's use the Motorola kernel 708c2ecf20Sopenharmony_ci * naming for now until we have a better understanding of the other 718c2ecf20Sopenharmony_ci * enable register bits. No idea why BIT(3) is not defined. 728c2ecf20Sopenharmony_ci */ 738c2ecf20Sopenharmony_ci#define CPCAP_BIT_AUDIO_LOW_PWR BIT(6) 748c2ecf20Sopenharmony_ci#define CPCAP_BIT_AUD_LOWPWR_SPEED BIT(5) 758c2ecf20Sopenharmony_ci#define CPCAP_BIT_VAUDIOPRISTBY BIT(4) 768c2ecf20Sopenharmony_ci#define CPCAP_BIT_VAUDIO_MODE1 BIT(2) 778c2ecf20Sopenharmony_ci#define CPCAP_BIT_VAUDIO_MODE0 BIT(1) 788c2ecf20Sopenharmony_ci#define CPCAP_BIT_V_AUDIO_EN BIT(0) 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci#define CPCAP_BIT_AUDIO_NORMAL_MODE 0x00 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci/* 838c2ecf20Sopenharmony_ci * Off mode configuration bit. Used currently only by SW5 on omap4. There's 848c2ecf20Sopenharmony_ci * the following comment in Motorola Linux kernel tree for it: 858c2ecf20Sopenharmony_ci * 868c2ecf20Sopenharmony_ci * When set in the regulator mode, the regulator assignment will be changed 878c2ecf20Sopenharmony_ci * to secondary when the regulator is disabled. The mode will be set back to 888c2ecf20Sopenharmony_ci * primary when the regulator is turned on. 898c2ecf20Sopenharmony_ci */ 908c2ecf20Sopenharmony_ci#define CPCAP_REG_OFF_MODE_SEC BIT(15) 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci/* 938c2ecf20Sopenharmony_ci * SoC specific configuration for CPCAP regulator. There are at least three 948c2ecf20Sopenharmony_ci * different SoCs each with their own parameters: omap3, omap4 and tegra2. 958c2ecf20Sopenharmony_ci * 968c2ecf20Sopenharmony_ci * The assign_reg and assign_mask seem to allow toggling between primary 978c2ecf20Sopenharmony_ci * and secondary mode that at least omap4 uses for off mode. 988c2ecf20Sopenharmony_ci */ 998c2ecf20Sopenharmony_cistruct cpcap_regulator { 1008c2ecf20Sopenharmony_ci struct regulator_desc rdesc; 1018c2ecf20Sopenharmony_ci const u16 assign_reg; 1028c2ecf20Sopenharmony_ci const u16 assign_mask; 1038c2ecf20Sopenharmony_ci}; 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ci#define CPCAP_REG(_ID, reg, assignment_reg, assignment_mask, val_tbl, \ 1068c2ecf20Sopenharmony_ci mode_mask, volt_mask, mode_val, off_val, \ 1078c2ecf20Sopenharmony_ci volt_trans_time) { \ 1088c2ecf20Sopenharmony_ci .rdesc = { \ 1098c2ecf20Sopenharmony_ci .name = #_ID, \ 1108c2ecf20Sopenharmony_ci .of_match = of_match_ptr(#_ID), \ 1118c2ecf20Sopenharmony_ci .ops = &cpcap_regulator_ops, \ 1128c2ecf20Sopenharmony_ci .regulators_node = of_match_ptr("regulators"), \ 1138c2ecf20Sopenharmony_ci .type = REGULATOR_VOLTAGE, \ 1148c2ecf20Sopenharmony_ci .id = CPCAP_##_ID, \ 1158c2ecf20Sopenharmony_ci .owner = THIS_MODULE, \ 1168c2ecf20Sopenharmony_ci .n_voltages = ARRAY_SIZE(val_tbl), \ 1178c2ecf20Sopenharmony_ci .volt_table = (val_tbl), \ 1188c2ecf20Sopenharmony_ci .vsel_reg = (reg), \ 1198c2ecf20Sopenharmony_ci .vsel_mask = (volt_mask), \ 1208c2ecf20Sopenharmony_ci .enable_reg = (reg), \ 1218c2ecf20Sopenharmony_ci .enable_mask = (mode_mask), \ 1228c2ecf20Sopenharmony_ci .enable_val = (mode_val), \ 1238c2ecf20Sopenharmony_ci .disable_val = (off_val), \ 1248c2ecf20Sopenharmony_ci .ramp_delay = (volt_trans_time), \ 1258c2ecf20Sopenharmony_ci .of_map_mode = cpcap_map_mode, \ 1268c2ecf20Sopenharmony_ci }, \ 1278c2ecf20Sopenharmony_ci .assign_reg = (assignment_reg), \ 1288c2ecf20Sopenharmony_ci .assign_mask = (assignment_mask), \ 1298c2ecf20Sopenharmony_ci} 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_cistruct cpcap_ddata { 1328c2ecf20Sopenharmony_ci struct regmap *reg; 1338c2ecf20Sopenharmony_ci struct device *dev; 1348c2ecf20Sopenharmony_ci const struct cpcap_regulator *soc; 1358c2ecf20Sopenharmony_ci}; 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_cienum cpcap_regulator_id { 1388c2ecf20Sopenharmony_ci CPCAP_SW1, 1398c2ecf20Sopenharmony_ci CPCAP_SW2, 1408c2ecf20Sopenharmony_ci CPCAP_SW3, 1418c2ecf20Sopenharmony_ci CPCAP_SW4, 1428c2ecf20Sopenharmony_ci CPCAP_SW5, 1438c2ecf20Sopenharmony_ci CPCAP_SW6, 1448c2ecf20Sopenharmony_ci CPCAP_VCAM, 1458c2ecf20Sopenharmony_ci CPCAP_VCSI, 1468c2ecf20Sopenharmony_ci CPCAP_VDAC, 1478c2ecf20Sopenharmony_ci CPCAP_VDIG, 1488c2ecf20Sopenharmony_ci CPCAP_VFUSE, 1498c2ecf20Sopenharmony_ci CPCAP_VHVIO, 1508c2ecf20Sopenharmony_ci CPCAP_VSDIO, 1518c2ecf20Sopenharmony_ci CPCAP_VPLL, 1528c2ecf20Sopenharmony_ci CPCAP_VRF1, 1538c2ecf20Sopenharmony_ci CPCAP_VRF2, 1548c2ecf20Sopenharmony_ci CPCAP_VRFREF, 1558c2ecf20Sopenharmony_ci CPCAP_VWLAN1, 1568c2ecf20Sopenharmony_ci CPCAP_VWLAN2, 1578c2ecf20Sopenharmony_ci CPCAP_VSIM, 1588c2ecf20Sopenharmony_ci CPCAP_VSIMCARD, 1598c2ecf20Sopenharmony_ci CPCAP_VVIB, 1608c2ecf20Sopenharmony_ci CPCAP_VUSB, 1618c2ecf20Sopenharmony_ci CPCAP_VAUDIO, 1628c2ecf20Sopenharmony_ci CPCAP_NR_REGULATORS, 1638c2ecf20Sopenharmony_ci}; 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_ci/* 1668c2ecf20Sopenharmony_ci * We need to also configure regulator idle mode for SoC off mode if 1678c2ecf20Sopenharmony_ci * CPCAP_REG_OFF_MODE_SEC is set. 1688c2ecf20Sopenharmony_ci */ 1698c2ecf20Sopenharmony_cistatic int cpcap_regulator_enable(struct regulator_dev *rdev) 1708c2ecf20Sopenharmony_ci{ 1718c2ecf20Sopenharmony_ci struct cpcap_regulator *regulator = rdev_get_drvdata(rdev); 1728c2ecf20Sopenharmony_ci int error; 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_ci error = regulator_enable_regmap(rdev); 1758c2ecf20Sopenharmony_ci if (error) 1768c2ecf20Sopenharmony_ci return error; 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_ci if (rdev->desc->enable_val & CPCAP_REG_OFF_MODE_SEC) { 1798c2ecf20Sopenharmony_ci error = regmap_update_bits(rdev->regmap, regulator->assign_reg, 1808c2ecf20Sopenharmony_ci regulator->assign_mask, 1818c2ecf20Sopenharmony_ci regulator->assign_mask); 1828c2ecf20Sopenharmony_ci if (error) 1838c2ecf20Sopenharmony_ci regulator_disable_regmap(rdev); 1848c2ecf20Sopenharmony_ci } 1858c2ecf20Sopenharmony_ci 1868c2ecf20Sopenharmony_ci return error; 1878c2ecf20Sopenharmony_ci} 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_ci/* 1908c2ecf20Sopenharmony_ci * We need to also configure regulator idle mode for SoC off mode if 1918c2ecf20Sopenharmony_ci * CPCAP_REG_OFF_MODE_SEC is set. 1928c2ecf20Sopenharmony_ci */ 1938c2ecf20Sopenharmony_cistatic int cpcap_regulator_disable(struct regulator_dev *rdev) 1948c2ecf20Sopenharmony_ci{ 1958c2ecf20Sopenharmony_ci struct cpcap_regulator *regulator = rdev_get_drvdata(rdev); 1968c2ecf20Sopenharmony_ci int error; 1978c2ecf20Sopenharmony_ci 1988c2ecf20Sopenharmony_ci if (rdev->desc->enable_val & CPCAP_REG_OFF_MODE_SEC) { 1998c2ecf20Sopenharmony_ci error = regmap_update_bits(rdev->regmap, regulator->assign_reg, 2008c2ecf20Sopenharmony_ci regulator->assign_mask, 0); 2018c2ecf20Sopenharmony_ci if (error) 2028c2ecf20Sopenharmony_ci return error; 2038c2ecf20Sopenharmony_ci } 2048c2ecf20Sopenharmony_ci 2058c2ecf20Sopenharmony_ci error = regulator_disable_regmap(rdev); 2068c2ecf20Sopenharmony_ci if (error && (rdev->desc->enable_val & CPCAP_REG_OFF_MODE_SEC)) { 2078c2ecf20Sopenharmony_ci regmap_update_bits(rdev->regmap, regulator->assign_reg, 2088c2ecf20Sopenharmony_ci regulator->assign_mask, 2098c2ecf20Sopenharmony_ci regulator->assign_mask); 2108c2ecf20Sopenharmony_ci } 2118c2ecf20Sopenharmony_ci 2128c2ecf20Sopenharmony_ci return error; 2138c2ecf20Sopenharmony_ci} 2148c2ecf20Sopenharmony_ci 2158c2ecf20Sopenharmony_cistatic unsigned int cpcap_map_mode(unsigned int mode) 2168c2ecf20Sopenharmony_ci{ 2178c2ecf20Sopenharmony_ci switch (mode) { 2188c2ecf20Sopenharmony_ci case CPCAP_BIT_AUDIO_NORMAL_MODE: 2198c2ecf20Sopenharmony_ci return REGULATOR_MODE_NORMAL; 2208c2ecf20Sopenharmony_ci case CPCAP_BIT_AUDIO_LOW_PWR: 2218c2ecf20Sopenharmony_ci return REGULATOR_MODE_STANDBY; 2228c2ecf20Sopenharmony_ci default: 2238c2ecf20Sopenharmony_ci return REGULATOR_MODE_INVALID; 2248c2ecf20Sopenharmony_ci } 2258c2ecf20Sopenharmony_ci} 2268c2ecf20Sopenharmony_ci 2278c2ecf20Sopenharmony_cistatic unsigned int cpcap_regulator_get_mode(struct regulator_dev *rdev) 2288c2ecf20Sopenharmony_ci{ 2298c2ecf20Sopenharmony_ci int value; 2308c2ecf20Sopenharmony_ci 2318c2ecf20Sopenharmony_ci regmap_read(rdev->regmap, rdev->desc->enable_reg, &value); 2328c2ecf20Sopenharmony_ci 2338c2ecf20Sopenharmony_ci if (value & CPCAP_BIT_AUDIO_LOW_PWR) 2348c2ecf20Sopenharmony_ci return REGULATOR_MODE_STANDBY; 2358c2ecf20Sopenharmony_ci 2368c2ecf20Sopenharmony_ci return REGULATOR_MODE_NORMAL; 2378c2ecf20Sopenharmony_ci} 2388c2ecf20Sopenharmony_ci 2398c2ecf20Sopenharmony_cistatic int cpcap_regulator_set_mode(struct regulator_dev *rdev, 2408c2ecf20Sopenharmony_ci unsigned int mode) 2418c2ecf20Sopenharmony_ci{ 2428c2ecf20Sopenharmony_ci int value; 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_ci switch (mode) { 2458c2ecf20Sopenharmony_ci case REGULATOR_MODE_NORMAL: 2468c2ecf20Sopenharmony_ci value = CPCAP_BIT_AUDIO_NORMAL_MODE; 2478c2ecf20Sopenharmony_ci break; 2488c2ecf20Sopenharmony_ci case REGULATOR_MODE_STANDBY: 2498c2ecf20Sopenharmony_ci value = CPCAP_BIT_AUDIO_LOW_PWR; 2508c2ecf20Sopenharmony_ci break; 2518c2ecf20Sopenharmony_ci default: 2528c2ecf20Sopenharmony_ci return -EINVAL; 2538c2ecf20Sopenharmony_ci } 2548c2ecf20Sopenharmony_ci 2558c2ecf20Sopenharmony_ci return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, 2568c2ecf20Sopenharmony_ci CPCAP_BIT_AUDIO_LOW_PWR, value); 2578c2ecf20Sopenharmony_ci} 2588c2ecf20Sopenharmony_ci 2598c2ecf20Sopenharmony_cistatic const struct regulator_ops cpcap_regulator_ops = { 2608c2ecf20Sopenharmony_ci .enable = cpcap_regulator_enable, 2618c2ecf20Sopenharmony_ci .disable = cpcap_regulator_disable, 2628c2ecf20Sopenharmony_ci .is_enabled = regulator_is_enabled_regmap, 2638c2ecf20Sopenharmony_ci .list_voltage = regulator_list_voltage_table, 2648c2ecf20Sopenharmony_ci .map_voltage = regulator_map_voltage_iterate, 2658c2ecf20Sopenharmony_ci .get_voltage_sel = regulator_get_voltage_sel_regmap, 2668c2ecf20Sopenharmony_ci .set_voltage_sel = regulator_set_voltage_sel_regmap, 2678c2ecf20Sopenharmony_ci .get_mode = cpcap_regulator_get_mode, 2688c2ecf20Sopenharmony_ci .set_mode = cpcap_regulator_set_mode, 2698c2ecf20Sopenharmony_ci}; 2708c2ecf20Sopenharmony_ci 2718c2ecf20Sopenharmony_cistatic const unsigned int unknown_val_tbl[] = { 0, }; 2728c2ecf20Sopenharmony_cistatic const unsigned int sw2_sw4_val_tbl[] = { 612500, 625000, 637500, 2738c2ecf20Sopenharmony_ci 650000, 662500, 675000, 2748c2ecf20Sopenharmony_ci 687500, 700000, 712500, 2758c2ecf20Sopenharmony_ci 725000, 737500, 750000, 2768c2ecf20Sopenharmony_ci 762500, 775000, 787500, 2778c2ecf20Sopenharmony_ci 800000, 812500, 825000, 2788c2ecf20Sopenharmony_ci 837500, 850000, 862500, 2798c2ecf20Sopenharmony_ci 875000, 887500, 900000, 2808c2ecf20Sopenharmony_ci 912500, 925000, 937500, 2818c2ecf20Sopenharmony_ci 950000, 962500, 975000, 2828c2ecf20Sopenharmony_ci 987500, 1000000, 1012500, 2838c2ecf20Sopenharmony_ci 1025000, 1037500, 1050000, 2848c2ecf20Sopenharmony_ci 1062500, 1075000, 1087500, 2858c2ecf20Sopenharmony_ci 1100000, 1112500, 1125000, 2868c2ecf20Sopenharmony_ci 1137500, 1150000, 1162500, 2878c2ecf20Sopenharmony_ci 1175000, 1187500, 1200000, 2888c2ecf20Sopenharmony_ci 1212500, 1225000, 1237500, 2898c2ecf20Sopenharmony_ci 1250000, 1262500, 1275000, 2908c2ecf20Sopenharmony_ci 1287500, 1300000, 1312500, 2918c2ecf20Sopenharmony_ci 1325000, 1337500, 1350000, 2928c2ecf20Sopenharmony_ci 1362500, 1375000, 1387500, 2938c2ecf20Sopenharmony_ci 1400000, 1412500, 1425000, 2948c2ecf20Sopenharmony_ci 1437500, 1450000, 1462500, }; 2958c2ecf20Sopenharmony_cistatic const unsigned int sw5_val_tbl[] = { 0, 5050000, }; 2968c2ecf20Sopenharmony_cistatic const unsigned int vcam_val_tbl[] = { 2600000, 2700000, 2800000, 2978c2ecf20Sopenharmony_ci 2900000, }; 2988c2ecf20Sopenharmony_cistatic const unsigned int vcsi_val_tbl[] = { 1200000, 1800000, }; 2998c2ecf20Sopenharmony_cistatic const unsigned int vdac_val_tbl[] = { 1200000, 1500000, 1800000, 3008c2ecf20Sopenharmony_ci 2500000,}; 3018c2ecf20Sopenharmony_cistatic const unsigned int vdig_val_tbl[] = { 1200000, 1350000, 1500000, 3028c2ecf20Sopenharmony_ci 1875000, }; 3038c2ecf20Sopenharmony_cistatic const unsigned int vfuse_val_tbl[] = { 1500000, 1600000, 1700000, 3048c2ecf20Sopenharmony_ci 1800000, 1900000, 2000000, 3058c2ecf20Sopenharmony_ci 2100000, 2200000, 2300000, 3068c2ecf20Sopenharmony_ci 2400000, 2500000, 2600000, 3078c2ecf20Sopenharmony_ci 2700000, 3150000, }; 3088c2ecf20Sopenharmony_cistatic const unsigned int vhvio_val_tbl[] = { 2775000, }; 3098c2ecf20Sopenharmony_cistatic const unsigned int vsdio_val_tbl[] = { 1500000, 1600000, 1800000, 3108c2ecf20Sopenharmony_ci 2600000, 2700000, 2800000, 3118c2ecf20Sopenharmony_ci 2900000, 3000000, }; 3128c2ecf20Sopenharmony_cistatic const unsigned int vpll_val_tbl[] = { 1200000, 1300000, 1400000, 3138c2ecf20Sopenharmony_ci 1800000, }; 3148c2ecf20Sopenharmony_ci/* Quirk: 2775000 is before 2500000 for vrf1 regulator */ 3158c2ecf20Sopenharmony_cistatic const unsigned int vrf1_val_tbl[] = { 2775000, 2500000, }; 3168c2ecf20Sopenharmony_cistatic const unsigned int vrf2_val_tbl[] = { 0, 2775000, }; 3178c2ecf20Sopenharmony_cistatic const unsigned int vrfref_val_tbl[] = { 2500000, 2775000, }; 3188c2ecf20Sopenharmony_cistatic const unsigned int vwlan1_val_tbl[] = { 1800000, 1900000, }; 3198c2ecf20Sopenharmony_cistatic const unsigned int vwlan2_val_tbl[] = { 2775000, 3000000, 3300000, 3208c2ecf20Sopenharmony_ci 3300000, }; 3218c2ecf20Sopenharmony_cistatic const unsigned int vsim_val_tbl[] = { 1800000, 2900000, }; 3228c2ecf20Sopenharmony_cistatic const unsigned int vsimcard_val_tbl[] = { 1800000, 2900000, }; 3238c2ecf20Sopenharmony_cistatic const unsigned int vvib_val_tbl[] = { 1300000, 1800000, 2000000, 3248c2ecf20Sopenharmony_ci 3000000, }; 3258c2ecf20Sopenharmony_cistatic const unsigned int vusb_val_tbl[] = { 0, 3300000, }; 3268c2ecf20Sopenharmony_cistatic const unsigned int vaudio_val_tbl[] = { 0, 2775000, }; 3278c2ecf20Sopenharmony_ci 3288c2ecf20Sopenharmony_ci/* 3298c2ecf20Sopenharmony_ci * SoC specific configuration for omap4. The data below is comes from Motorola 3308c2ecf20Sopenharmony_ci * Linux kernel tree. It's basically the values of cpcap_regltr_data, 3318c2ecf20Sopenharmony_ci * cpcap_regulator_mode_values and cpcap_regulator_off_mode_values, see 3328c2ecf20Sopenharmony_ci * CPCAP_REG macro above. 3338c2ecf20Sopenharmony_ci * 3348c2ecf20Sopenharmony_ci * SW1 to SW4 and SW6 seems to be unused for mapphone. Note that VSIM and 3358c2ecf20Sopenharmony_ci * VSIMCARD have a shared resource assignment bit. 3368c2ecf20Sopenharmony_ci */ 3378c2ecf20Sopenharmony_cistatic const struct cpcap_regulator omap4_regulators[] = { 3388c2ecf20Sopenharmony_ci CPCAP_REG(SW1, CPCAP_REG_S1C1, CPCAP_REG_ASSIGN2, 3398c2ecf20Sopenharmony_ci CPCAP_BIT_SW1_SEL, unknown_val_tbl, 3408c2ecf20Sopenharmony_ci 0, 0, 0, 0, 0), 3418c2ecf20Sopenharmony_ci CPCAP_REG(SW2, CPCAP_REG_S2C1, CPCAP_REG_ASSIGN2, 3428c2ecf20Sopenharmony_ci CPCAP_BIT_SW2_SEL, unknown_val_tbl, 3438c2ecf20Sopenharmony_ci 0, 0, 0, 0, 0), 3448c2ecf20Sopenharmony_ci CPCAP_REG(SW3, CPCAP_REG_S3C, CPCAP_REG_ASSIGN2, 3458c2ecf20Sopenharmony_ci CPCAP_BIT_SW3_SEL, unknown_val_tbl, 3468c2ecf20Sopenharmony_ci 0, 0, 0, 0, 0), 3478c2ecf20Sopenharmony_ci CPCAP_REG(SW4, CPCAP_REG_S4C1, CPCAP_REG_ASSIGN2, 3488c2ecf20Sopenharmony_ci CPCAP_BIT_SW4_SEL, unknown_val_tbl, 3498c2ecf20Sopenharmony_ci 0, 0, 0, 0, 0), 3508c2ecf20Sopenharmony_ci CPCAP_REG(SW5, CPCAP_REG_S5C, CPCAP_REG_ASSIGN2, 3518c2ecf20Sopenharmony_ci CPCAP_BIT_SW5_SEL, sw5_val_tbl, 3528c2ecf20Sopenharmony_ci 0x28, 0, 0x20 | CPCAP_REG_OFF_MODE_SEC, 0, 0), 3538c2ecf20Sopenharmony_ci CPCAP_REG(SW6, CPCAP_REG_S6C, CPCAP_REG_ASSIGN2, 3548c2ecf20Sopenharmony_ci CPCAP_BIT_SW6_SEL, unknown_val_tbl, 3558c2ecf20Sopenharmony_ci 0, 0, 0, 0, 0), 3568c2ecf20Sopenharmony_ci CPCAP_REG(VCAM, CPCAP_REG_VCAMC, CPCAP_REG_ASSIGN2, 3578c2ecf20Sopenharmony_ci CPCAP_BIT_VCAM_SEL, vcam_val_tbl, 3588c2ecf20Sopenharmony_ci 0x87, 0x30, 0x3, 0, 420), 3598c2ecf20Sopenharmony_ci CPCAP_REG(VCSI, CPCAP_REG_VCSIC, CPCAP_REG_ASSIGN3, 3608c2ecf20Sopenharmony_ci CPCAP_BIT_VCSI_SEL, vcsi_val_tbl, 3618c2ecf20Sopenharmony_ci 0x47, 0x10, 0x43, 0x41, 350), 3628c2ecf20Sopenharmony_ci CPCAP_REG(VDAC, CPCAP_REG_VDACC, CPCAP_REG_ASSIGN3, 3638c2ecf20Sopenharmony_ci CPCAP_BIT_VDAC_SEL, vdac_val_tbl, 3648c2ecf20Sopenharmony_ci 0x87, 0x30, 0x3, 0, 420), 3658c2ecf20Sopenharmony_ci CPCAP_REG(VDIG, CPCAP_REG_VDIGC, CPCAP_REG_ASSIGN2, 3668c2ecf20Sopenharmony_ci CPCAP_BIT_VDIG_SEL, vdig_val_tbl, 3678c2ecf20Sopenharmony_ci 0x87, 0x30, 0x82, 0, 420), 3688c2ecf20Sopenharmony_ci CPCAP_REG(VFUSE, CPCAP_REG_VFUSEC, CPCAP_REG_ASSIGN3, 3698c2ecf20Sopenharmony_ci CPCAP_BIT_VFUSE_SEL, vfuse_val_tbl, 3708c2ecf20Sopenharmony_ci 0x80, 0xf, 0x80, 0, 420), 3718c2ecf20Sopenharmony_ci CPCAP_REG(VHVIO, CPCAP_REG_VHVIOC, CPCAP_REG_ASSIGN3, 3728c2ecf20Sopenharmony_ci CPCAP_BIT_VHVIO_SEL, vhvio_val_tbl, 3738c2ecf20Sopenharmony_ci 0x17, 0, 0, 0x12, 0), 3748c2ecf20Sopenharmony_ci CPCAP_REG(VSDIO, CPCAP_REG_VSDIOC, CPCAP_REG_ASSIGN2, 3758c2ecf20Sopenharmony_ci CPCAP_BIT_VSDIO_SEL, vsdio_val_tbl, 3768c2ecf20Sopenharmony_ci 0x87, 0x38, 0x82, 0, 420), 3778c2ecf20Sopenharmony_ci CPCAP_REG(VPLL, CPCAP_REG_VPLLC, CPCAP_REG_ASSIGN3, 3788c2ecf20Sopenharmony_ci CPCAP_BIT_VPLL_SEL, vpll_val_tbl, 3798c2ecf20Sopenharmony_ci 0x43, 0x18, 0x2, 0, 420), 3808c2ecf20Sopenharmony_ci CPCAP_REG(VRF1, CPCAP_REG_VRF1C, CPCAP_REG_ASSIGN3, 3818c2ecf20Sopenharmony_ci CPCAP_BIT_VRF1_SEL, vrf1_val_tbl, 3828c2ecf20Sopenharmony_ci 0xac, 0x2, 0x4, 0, 10), 3838c2ecf20Sopenharmony_ci CPCAP_REG(VRF2, CPCAP_REG_VRF2C, CPCAP_REG_ASSIGN3, 3848c2ecf20Sopenharmony_ci CPCAP_BIT_VRF2_SEL, vrf2_val_tbl, 3858c2ecf20Sopenharmony_ci 0x23, 0x8, 0, 0, 10), 3868c2ecf20Sopenharmony_ci CPCAP_REG(VRFREF, CPCAP_REG_VRFREFC, CPCAP_REG_ASSIGN3, 3878c2ecf20Sopenharmony_ci CPCAP_BIT_VRFREF_SEL, vrfref_val_tbl, 3888c2ecf20Sopenharmony_ci 0x23, 0x8, 0, 0, 420), 3898c2ecf20Sopenharmony_ci CPCAP_REG(VWLAN1, CPCAP_REG_VWLAN1C, CPCAP_REG_ASSIGN3, 3908c2ecf20Sopenharmony_ci CPCAP_BIT_VWLAN1_SEL, vwlan1_val_tbl, 3918c2ecf20Sopenharmony_ci 0x47, 0x10, 0, 0, 420), 3928c2ecf20Sopenharmony_ci CPCAP_REG(VWLAN2, CPCAP_REG_VWLAN2C, CPCAP_REG_ASSIGN3, 3938c2ecf20Sopenharmony_ci CPCAP_BIT_VWLAN2_SEL, vwlan2_val_tbl, 3948c2ecf20Sopenharmony_ci 0x20c, 0xc0, 0x20c, 0, 420), 3958c2ecf20Sopenharmony_ci CPCAP_REG(VSIM, CPCAP_REG_VSIMC, CPCAP_REG_ASSIGN3, 3968c2ecf20Sopenharmony_ci 0xffff, vsim_val_tbl, 3978c2ecf20Sopenharmony_ci 0x23, 0x8, 0x3, 0, 420), 3988c2ecf20Sopenharmony_ci CPCAP_REG(VSIMCARD, CPCAP_REG_VSIMC, CPCAP_REG_ASSIGN3, 3998c2ecf20Sopenharmony_ci 0xffff, vsimcard_val_tbl, 4008c2ecf20Sopenharmony_ci 0x1e80, 0x8, 0x1e00, 0, 420), 4018c2ecf20Sopenharmony_ci CPCAP_REG(VVIB, CPCAP_REG_VVIBC, CPCAP_REG_ASSIGN3, 4028c2ecf20Sopenharmony_ci CPCAP_BIT_VVIB_SEL, vvib_val_tbl, 4038c2ecf20Sopenharmony_ci 0x1, 0xc, 0x1, 0, 500), 4048c2ecf20Sopenharmony_ci CPCAP_REG(VUSB, CPCAP_REG_VUSBC, CPCAP_REG_ASSIGN3, 4058c2ecf20Sopenharmony_ci CPCAP_BIT_VUSB_SEL, vusb_val_tbl, 4068c2ecf20Sopenharmony_ci 0x11c, 0x40, 0xc, 0, 0), 4078c2ecf20Sopenharmony_ci CPCAP_REG(VAUDIO, CPCAP_REG_VAUDIOC, CPCAP_REG_ASSIGN4, 4088c2ecf20Sopenharmony_ci CPCAP_BIT_VAUDIO_SEL, vaudio_val_tbl, 4098c2ecf20Sopenharmony_ci 0x16, 0x1, 0x4, 0, 0), 4108c2ecf20Sopenharmony_ci { /* sentinel */ }, 4118c2ecf20Sopenharmony_ci}; 4128c2ecf20Sopenharmony_ci 4138c2ecf20Sopenharmony_cistatic const struct cpcap_regulator xoom_regulators[] = { 4148c2ecf20Sopenharmony_ci CPCAP_REG(SW1, CPCAP_REG_S1C1, CPCAP_REG_ASSIGN2, 4158c2ecf20Sopenharmony_ci CPCAP_BIT_SW1_SEL, unknown_val_tbl, 4168c2ecf20Sopenharmony_ci 0, 0, 0, 0, 0), 4178c2ecf20Sopenharmony_ci CPCAP_REG(SW2, CPCAP_REG_S2C1, CPCAP_REG_ASSIGN2, 4188c2ecf20Sopenharmony_ci CPCAP_BIT_SW2_SEL, sw2_sw4_val_tbl, 4198c2ecf20Sopenharmony_ci 0xf00, 0x7f, 0x800, 0, 120), 4208c2ecf20Sopenharmony_ci CPCAP_REG(SW3, CPCAP_REG_S3C, CPCAP_REG_ASSIGN2, 4218c2ecf20Sopenharmony_ci CPCAP_BIT_SW3_SEL, unknown_val_tbl, 4228c2ecf20Sopenharmony_ci 0, 0, 0, 0, 0), 4238c2ecf20Sopenharmony_ci CPCAP_REG(SW4, CPCAP_REG_S4C1, CPCAP_REG_ASSIGN2, 4248c2ecf20Sopenharmony_ci CPCAP_BIT_SW4_SEL, sw2_sw4_val_tbl, 4258c2ecf20Sopenharmony_ci 0xf00, 0x7f, 0x900, 0, 100), 4268c2ecf20Sopenharmony_ci CPCAP_REG(SW5, CPCAP_REG_S5C, CPCAP_REG_ASSIGN2, 4278c2ecf20Sopenharmony_ci CPCAP_BIT_SW5_SEL, sw5_val_tbl, 4288c2ecf20Sopenharmony_ci 0x2a, 0, 0x22, 0, 0), 4298c2ecf20Sopenharmony_ci CPCAP_REG(SW6, CPCAP_REG_S6C, CPCAP_REG_ASSIGN2, 4308c2ecf20Sopenharmony_ci CPCAP_BIT_SW6_SEL, unknown_val_tbl, 4318c2ecf20Sopenharmony_ci 0, 0, 0, 0, 0), 4328c2ecf20Sopenharmony_ci CPCAP_REG(VCAM, CPCAP_REG_VCAMC, CPCAP_REG_ASSIGN2, 4338c2ecf20Sopenharmony_ci CPCAP_BIT_VCAM_SEL, vcam_val_tbl, 4348c2ecf20Sopenharmony_ci 0x87, 0x30, 0x7, 0, 420), 4358c2ecf20Sopenharmony_ci CPCAP_REG(VCSI, CPCAP_REG_VCSIC, CPCAP_REG_ASSIGN3, 4368c2ecf20Sopenharmony_ci CPCAP_BIT_VCSI_SEL, vcsi_val_tbl, 4378c2ecf20Sopenharmony_ci 0x47, 0x10, 0x7, 0, 350), 4388c2ecf20Sopenharmony_ci CPCAP_REG(VDAC, CPCAP_REG_VDACC, CPCAP_REG_ASSIGN3, 4398c2ecf20Sopenharmony_ci CPCAP_BIT_VDAC_SEL, vdac_val_tbl, 4408c2ecf20Sopenharmony_ci 0x87, 0x30, 0x3, 0, 420), 4418c2ecf20Sopenharmony_ci CPCAP_REG(VDIG, CPCAP_REG_VDIGC, CPCAP_REG_ASSIGN2, 4428c2ecf20Sopenharmony_ci CPCAP_BIT_VDIG_SEL, vdig_val_tbl, 4438c2ecf20Sopenharmony_ci 0x87, 0x30, 0x5, 0, 420), 4448c2ecf20Sopenharmony_ci CPCAP_REG(VFUSE, CPCAP_REG_VFUSEC, CPCAP_REG_ASSIGN3, 4458c2ecf20Sopenharmony_ci CPCAP_BIT_VFUSE_SEL, vfuse_val_tbl, 4468c2ecf20Sopenharmony_ci 0x80, 0xf, 0x80, 0, 420), 4478c2ecf20Sopenharmony_ci CPCAP_REG(VHVIO, CPCAP_REG_VHVIOC, CPCAP_REG_ASSIGN3, 4488c2ecf20Sopenharmony_ci CPCAP_BIT_VHVIO_SEL, vhvio_val_tbl, 4498c2ecf20Sopenharmony_ci 0x17, 0, 0x2, 0, 0), 4508c2ecf20Sopenharmony_ci CPCAP_REG(VSDIO, CPCAP_REG_VSDIOC, CPCAP_REG_ASSIGN2, 4518c2ecf20Sopenharmony_ci CPCAP_BIT_VSDIO_SEL, vsdio_val_tbl, 4528c2ecf20Sopenharmony_ci 0x87, 0x38, 0x2, 0, 420), 4538c2ecf20Sopenharmony_ci CPCAP_REG(VPLL, CPCAP_REG_VPLLC, CPCAP_REG_ASSIGN3, 4548c2ecf20Sopenharmony_ci CPCAP_BIT_VPLL_SEL, vpll_val_tbl, 4558c2ecf20Sopenharmony_ci 0x43, 0x18, 0x1, 0, 420), 4568c2ecf20Sopenharmony_ci CPCAP_REG(VRF1, CPCAP_REG_VRF1C, CPCAP_REG_ASSIGN3, 4578c2ecf20Sopenharmony_ci CPCAP_BIT_VRF1_SEL, vrf1_val_tbl, 4588c2ecf20Sopenharmony_ci 0xac, 0x2, 0xc, 0, 10), 4598c2ecf20Sopenharmony_ci CPCAP_REG(VRF2, CPCAP_REG_VRF2C, CPCAP_REG_ASSIGN3, 4608c2ecf20Sopenharmony_ci CPCAP_BIT_VRF2_SEL, vrf2_val_tbl, 4618c2ecf20Sopenharmony_ci 0x23, 0x8, 0x3, 0, 10), 4628c2ecf20Sopenharmony_ci CPCAP_REG(VRFREF, CPCAP_REG_VRFREFC, CPCAP_REG_ASSIGN3, 4638c2ecf20Sopenharmony_ci CPCAP_BIT_VRFREF_SEL, vrfref_val_tbl, 4648c2ecf20Sopenharmony_ci 0x23, 0x8, 0x3, 0, 420), 4658c2ecf20Sopenharmony_ci CPCAP_REG(VWLAN1, CPCAP_REG_VWLAN1C, CPCAP_REG_ASSIGN3, 4668c2ecf20Sopenharmony_ci CPCAP_BIT_VWLAN1_SEL, vwlan1_val_tbl, 4678c2ecf20Sopenharmony_ci 0x47, 0x10, 0x5, 0, 420), 4688c2ecf20Sopenharmony_ci CPCAP_REG(VWLAN2, CPCAP_REG_VWLAN2C, CPCAP_REG_ASSIGN3, 4698c2ecf20Sopenharmony_ci CPCAP_BIT_VWLAN2_SEL, vwlan2_val_tbl, 4708c2ecf20Sopenharmony_ci 0x20c, 0xc0, 0x8, 0, 420), 4718c2ecf20Sopenharmony_ci CPCAP_REG(VSIM, CPCAP_REG_VSIMC, CPCAP_REG_ASSIGN3, 4728c2ecf20Sopenharmony_ci 0xffff, vsim_val_tbl, 4738c2ecf20Sopenharmony_ci 0x23, 0x8, 0x3, 0, 420), 4748c2ecf20Sopenharmony_ci CPCAP_REG(VSIMCARD, CPCAP_REG_VSIMC, CPCAP_REG_ASSIGN3, 4758c2ecf20Sopenharmony_ci 0xffff, vsimcard_val_tbl, 4768c2ecf20Sopenharmony_ci 0x1e80, 0x8, 0x1e00, 0, 420), 4778c2ecf20Sopenharmony_ci CPCAP_REG(VVIB, CPCAP_REG_VVIBC, CPCAP_REG_ASSIGN3, 4788c2ecf20Sopenharmony_ci CPCAP_BIT_VVIB_SEL, vvib_val_tbl, 4798c2ecf20Sopenharmony_ci 0x1, 0xc, 0, 0x1, 500), 4808c2ecf20Sopenharmony_ci CPCAP_REG(VUSB, CPCAP_REG_VUSBC, CPCAP_REG_ASSIGN3, 4818c2ecf20Sopenharmony_ci CPCAP_BIT_VUSB_SEL, vusb_val_tbl, 4828c2ecf20Sopenharmony_ci 0x11c, 0x40, 0xc, 0, 0), 4838c2ecf20Sopenharmony_ci CPCAP_REG(VAUDIO, CPCAP_REG_VAUDIOC, CPCAP_REG_ASSIGN4, 4848c2ecf20Sopenharmony_ci CPCAP_BIT_VAUDIO_SEL, vaudio_val_tbl, 4858c2ecf20Sopenharmony_ci 0x16, 0x1, 0x4, 0, 0), 4868c2ecf20Sopenharmony_ci { /* sentinel */ }, 4878c2ecf20Sopenharmony_ci}; 4888c2ecf20Sopenharmony_ci 4898c2ecf20Sopenharmony_cistatic const struct of_device_id cpcap_regulator_id_table[] = { 4908c2ecf20Sopenharmony_ci { 4918c2ecf20Sopenharmony_ci .compatible = "motorola,cpcap-regulator", 4928c2ecf20Sopenharmony_ci }, 4938c2ecf20Sopenharmony_ci { 4948c2ecf20Sopenharmony_ci .compatible = "motorola,mapphone-cpcap-regulator", 4958c2ecf20Sopenharmony_ci .data = omap4_regulators, 4968c2ecf20Sopenharmony_ci }, 4978c2ecf20Sopenharmony_ci { 4988c2ecf20Sopenharmony_ci .compatible = "motorola,xoom-cpcap-regulator", 4998c2ecf20Sopenharmony_ci .data = xoom_regulators, 5008c2ecf20Sopenharmony_ci }, 5018c2ecf20Sopenharmony_ci {}, 5028c2ecf20Sopenharmony_ci}; 5038c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(of, cpcap_regulator_id_table); 5048c2ecf20Sopenharmony_ci 5058c2ecf20Sopenharmony_cistatic int cpcap_regulator_probe(struct platform_device *pdev) 5068c2ecf20Sopenharmony_ci{ 5078c2ecf20Sopenharmony_ci struct cpcap_ddata *ddata; 5088c2ecf20Sopenharmony_ci const struct cpcap_regulator *match_data; 5098c2ecf20Sopenharmony_ci struct regulator_config config; 5108c2ecf20Sopenharmony_ci int i; 5118c2ecf20Sopenharmony_ci 5128c2ecf20Sopenharmony_ci match_data = of_device_get_match_data(&pdev->dev); 5138c2ecf20Sopenharmony_ci if (!match_data) { 5148c2ecf20Sopenharmony_ci dev_err(&pdev->dev, "no configuration data found\n"); 5158c2ecf20Sopenharmony_ci 5168c2ecf20Sopenharmony_ci return -ENODEV; 5178c2ecf20Sopenharmony_ci } 5188c2ecf20Sopenharmony_ci 5198c2ecf20Sopenharmony_ci ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL); 5208c2ecf20Sopenharmony_ci if (!ddata) 5218c2ecf20Sopenharmony_ci return -ENOMEM; 5228c2ecf20Sopenharmony_ci 5238c2ecf20Sopenharmony_ci ddata->reg = dev_get_regmap(pdev->dev.parent, NULL); 5248c2ecf20Sopenharmony_ci if (!ddata->reg) 5258c2ecf20Sopenharmony_ci return -ENODEV; 5268c2ecf20Sopenharmony_ci 5278c2ecf20Sopenharmony_ci ddata->dev = &pdev->dev; 5288c2ecf20Sopenharmony_ci ddata->soc = match_data; 5298c2ecf20Sopenharmony_ci platform_set_drvdata(pdev, ddata); 5308c2ecf20Sopenharmony_ci 5318c2ecf20Sopenharmony_ci memset(&config, 0, sizeof(config)); 5328c2ecf20Sopenharmony_ci config.dev = &pdev->dev; 5338c2ecf20Sopenharmony_ci config.regmap = ddata->reg; 5348c2ecf20Sopenharmony_ci 5358c2ecf20Sopenharmony_ci for (i = 0; i < CPCAP_NR_REGULATORS; i++) { 5368c2ecf20Sopenharmony_ci const struct cpcap_regulator *regulator = &ddata->soc[i]; 5378c2ecf20Sopenharmony_ci struct regulator_dev *rdev; 5388c2ecf20Sopenharmony_ci 5398c2ecf20Sopenharmony_ci if (!regulator->rdesc.name) 5408c2ecf20Sopenharmony_ci break; 5418c2ecf20Sopenharmony_ci 5428c2ecf20Sopenharmony_ci if (regulator->rdesc.volt_table == unknown_val_tbl) 5438c2ecf20Sopenharmony_ci continue; 5448c2ecf20Sopenharmony_ci 5458c2ecf20Sopenharmony_ci config.driver_data = (void *)regulator; 5468c2ecf20Sopenharmony_ci rdev = devm_regulator_register(&pdev->dev, 5478c2ecf20Sopenharmony_ci ®ulator->rdesc, 5488c2ecf20Sopenharmony_ci &config); 5498c2ecf20Sopenharmony_ci if (IS_ERR(rdev)) { 5508c2ecf20Sopenharmony_ci dev_err(&pdev->dev, "failed to register regulator %s\n", 5518c2ecf20Sopenharmony_ci regulator->rdesc.name); 5528c2ecf20Sopenharmony_ci 5538c2ecf20Sopenharmony_ci return PTR_ERR(rdev); 5548c2ecf20Sopenharmony_ci } 5558c2ecf20Sopenharmony_ci } 5568c2ecf20Sopenharmony_ci 5578c2ecf20Sopenharmony_ci return 0; 5588c2ecf20Sopenharmony_ci} 5598c2ecf20Sopenharmony_ci 5608c2ecf20Sopenharmony_cistatic struct platform_driver cpcap_regulator_driver = { 5618c2ecf20Sopenharmony_ci .probe = cpcap_regulator_probe, 5628c2ecf20Sopenharmony_ci .driver = { 5638c2ecf20Sopenharmony_ci .name = "cpcap-regulator", 5648c2ecf20Sopenharmony_ci .of_match_table = of_match_ptr(cpcap_regulator_id_table), 5658c2ecf20Sopenharmony_ci }, 5668c2ecf20Sopenharmony_ci}; 5678c2ecf20Sopenharmony_ci 5688c2ecf20Sopenharmony_cimodule_platform_driver(cpcap_regulator_driver); 5698c2ecf20Sopenharmony_ci 5708c2ecf20Sopenharmony_ciMODULE_ALIAS("platform:cpcap-regulator"); 5718c2ecf20Sopenharmony_ciMODULE_AUTHOR("Tony Lindgren <tony@atomide.com>"); 5728c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("CPCAP regulator driver"); 5738c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL v2"); 574