^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Regulators driver for Marvell 88PM8607
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 2009 Marvell International Ltd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Haojian Zhuang <haojian.zhuang@marvell.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/err.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/of.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/regulator/of_regulator.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/regulator/driver.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/regulator/machine.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/mfd/88pm860x.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) struct pm8607_regulator_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) struct regulator_desc desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) unsigned int *vol_suspend;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) int slope_double;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) static const unsigned int BUCK1_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 725000, 750000, 775000, 800000, 825000, 850000, 875000, 900000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 925000, 950000, 975000, 1000000, 1025000, 1050000, 1075000, 1100000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 1325000, 1350000, 1375000, 1400000, 1425000, 1450000, 1475000, 1500000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 0, 25000, 50000, 75000, 100000, 125000, 150000, 175000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 200000, 225000, 250000, 275000, 300000, 325000, 350000, 375000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 400000, 425000, 450000, 475000, 500000, 525000, 550000, 575000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 600000, 625000, 650000, 675000, 700000, 725000, 750000, 775000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) static const unsigned int BUCK1_suspend_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 0, 25000, 50000, 75000, 100000, 125000, 150000, 175000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 200000, 225000, 250000, 275000, 300000, 325000, 350000, 375000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 400000, 425000, 450000, 475000, 500000, 525000, 550000, 575000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 600000, 625000, 650000, 675000, 700000, 725000, 750000, 775000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 800000, 825000, 850000, 875000, 900000, 925000, 950000, 975000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000, 1375000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 1400000, 1425000, 1450000, 1475000, 1500000, 1500000, 1500000, 1500000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) static const unsigned int BUCK2_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 0, 50000, 100000, 150000, 200000, 250000, 300000, 350000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 400000, 450000, 500000, 550000, 600000, 650000, 700000, 750000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 800000, 850000, 900000, 950000, 1000000, 1050000, 1100000, 1150000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 1200000, 1250000, 1300000, 1350000, 1400000, 1450000, 1500000, 1550000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 1600000, 1650000, 1700000, 1750000, 1800000, 1850000, 1900000, 1950000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 2000000, 2050000, 2100000, 2150000, 2200000, 2250000, 2300000, 2350000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 2400000, 2450000, 2500000, 2550000, 2600000, 2650000, 2700000, 2750000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 2800000, 2850000, 2900000, 2950000, 3000000, 3000000, 3000000, 3000000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) static const unsigned int BUCK2_suspend_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 0, 50000, 100000, 150000, 200000, 250000, 300000, 350000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 400000, 450000, 500000, 550000, 600000, 650000, 700000, 750000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 800000, 850000, 900000, 950000, 1000000, 1050000, 1100000, 1150000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 1200000, 1250000, 1300000, 1350000, 1400000, 1450000, 1500000, 1550000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 1600000, 1650000, 1700000, 1750000, 1800000, 1850000, 1900000, 1950000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 2000000, 2050000, 2100000, 2150000, 2200000, 2250000, 2300000, 2350000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 2400000, 2450000, 2500000, 2550000, 2600000, 2650000, 2700000, 2750000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 2800000, 2850000, 2900000, 2950000, 3000000, 3000000, 3000000, 3000000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) static const unsigned int BUCK3_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 0, 25000, 50000, 75000, 100000, 125000, 150000, 175000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 200000, 225000, 250000, 275000, 300000, 325000, 350000, 375000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 400000, 425000, 450000, 475000, 500000, 525000, 550000, 575000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) 600000, 625000, 650000, 675000, 700000, 725000, 750000, 775000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) 800000, 825000, 850000, 875000, 900000, 925000, 950000, 975000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) 1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000, 1375000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) 1400000, 1425000, 1450000, 1475000, 1500000, 1500000, 1500000, 1500000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) static const unsigned int BUCK3_suspend_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) 0, 25000, 50000, 75000, 100000, 125000, 150000, 175000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) 200000, 225000, 250000, 275000, 300000, 325000, 350000, 375000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) 400000, 425000, 450000, 475000, 500000, 525000, 550000, 575000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) 600000, 625000, 650000, 675000, 700000, 725000, 750000, 775000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) 800000, 825000, 850000, 875000, 900000, 925000, 950000, 975000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) 1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000, 1375000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) 1400000, 1425000, 1450000, 1475000, 1500000, 1500000, 1500000, 1500000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) static const unsigned int LDO1_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) 1800000, 1200000, 2800000, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) static const unsigned int LDO1_suspend_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) 1800000, 1200000, 0, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) static const unsigned int LDO2_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 3300000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) static const unsigned int LDO2_suspend_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 2900000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) static const unsigned int LDO3_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 3300000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) static const unsigned int LDO3_suspend_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 2900000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) static const unsigned int LDO4_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2900000, 3300000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) static const unsigned int LDO4_suspend_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2900000, 2900000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) static const unsigned int LDO5_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 2900000, 3000000, 3100000, 3300000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) static const unsigned int LDO5_suspend_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 2900000, 0, 0, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) static const unsigned int LDO6_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 1800000, 1850000, 2600000, 2650000, 2700000, 2750000, 2800000, 3300000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) static const unsigned int LDO6_suspend_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 1800000, 1850000, 2600000, 2650000, 2700000, 2750000, 2800000, 2900000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) static const unsigned int LDO7_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 2900000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) static const unsigned int LDO7_suspend_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 2900000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) static const unsigned int LDO8_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 2900000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) static const unsigned int LDO8_suspend_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 2900000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) static const unsigned int LDO9_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 3300000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) static const unsigned int LDO9_suspend_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 2900000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) static const unsigned int LDO10_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 3300000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, 1200000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) static const unsigned int LDO10_suspend_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 2900000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, 1200000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) static const unsigned int LDO12_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 1800000, 1900000, 2700000, 2800000, 2900000, 3000000, 3100000, 3300000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, 1200000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) static const unsigned int LDO12_suspend_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 1800000, 1900000, 2700000, 2800000, 2900000, 2900000, 2900000, 2900000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, 1200000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) static const unsigned int LDO13_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 1200000, 1300000, 1800000, 2000000, 2500000, 2800000, 3000000, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) static const unsigned int LDO13_suspend_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) static const unsigned int LDO14_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 1800000, 1850000, 2700000, 2750000, 2800000, 2850000, 2900000, 3300000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) static const unsigned int LDO14_suspend_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 1800000, 1850000, 2700000, 2750000, 2800000, 2850000, 2900000, 2900000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) static int pm8607_list_voltage(struct regulator_dev *rdev, unsigned index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) ret = regulator_list_voltage_table(rdev, index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) if (info->slope_double)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) ret <<= 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) static const struct regulator_ops pm8607_regulator_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) .list_voltage = pm8607_list_voltage,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) .set_voltage_sel = regulator_set_voltage_sel_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) .get_voltage_sel = regulator_get_voltage_sel_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) .enable = regulator_enable_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) .disable = regulator_disable_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) .is_enabled = regulator_is_enabled_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) static const struct regulator_ops pm8606_preg_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) .enable = regulator_enable_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) .disable = regulator_disable_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) .is_enabled = regulator_is_enabled_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) #define PM8606_PREG(ereg, ebit) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) .desc = { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) .name = "PREG", \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) .of_match = of_match_ptr("PREG"), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) .regulators_node = of_match_ptr("regulators"), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) .ops = &pm8606_preg_ops, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) .type = REGULATOR_CURRENT, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) .id = PM8606_ID_PREG, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) .owner = THIS_MODULE, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) .enable_reg = PM8606_##ereg, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) .enable_mask = (ebit), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) .enable_is_inverted = true, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) }, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) #define PM8607_DVC(vreg, ureg, ubit, ereg, ebit) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) .desc = { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) .name = #vreg, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) .of_match = of_match_ptr(#vreg), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) .regulators_node = of_match_ptr("regulators"), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) .ops = &pm8607_regulator_ops, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) .type = REGULATOR_VOLTAGE, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) .id = PM8607_ID_##vreg, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) .owner = THIS_MODULE, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) .volt_table = vreg##_table, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) .n_voltages = ARRAY_SIZE(vreg##_table), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) .vsel_reg = PM8607_##vreg, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) .vsel_mask = ARRAY_SIZE(vreg##_table) - 1, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) .apply_reg = PM8607_##ureg, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) .apply_bit = (ubit), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) .enable_reg = PM8607_##ereg, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) .enable_mask = 1 << (ebit), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) }, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) .slope_double = (0), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) .vol_suspend = (unsigned int *)&vreg##_suspend_table, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) #define PM8607_LDO(_id, vreg, shift, ereg, ebit) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) .desc = { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) .name = "LDO" #_id, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) .of_match = of_match_ptr("LDO" #_id), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) .regulators_node = of_match_ptr("regulators"), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) .ops = &pm8607_regulator_ops, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) .type = REGULATOR_VOLTAGE, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) .id = PM8607_ID_LDO##_id, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) .owner = THIS_MODULE, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) .volt_table = LDO##_id##_table, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) .n_voltages = ARRAY_SIZE(LDO##_id##_table), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) .vsel_reg = PM8607_##vreg, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) .vsel_mask = (ARRAY_SIZE(LDO##_id##_table) - 1) << (shift), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) .enable_reg = PM8607_##ereg, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) .enable_mask = 1 << (ebit), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) }, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) .slope_double = (0), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) .vol_suspend = (unsigned int *)&LDO##_id##_suspend_table, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) static struct pm8607_regulator_info pm8607_regulator_info[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) PM8607_DVC(BUCK1, GO, BIT(0), SUPPLIES_EN11, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) PM8607_DVC(BUCK2, GO, BIT(1), SUPPLIES_EN11, 1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) PM8607_DVC(BUCK3, GO, BIT(2), SUPPLIES_EN11, 2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) PM8607_LDO(1, LDO1, 0, SUPPLIES_EN11, 3),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) PM8607_LDO(2, LDO2, 0, SUPPLIES_EN11, 4),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) PM8607_LDO(3, LDO3, 0, SUPPLIES_EN11, 5),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) PM8607_LDO(4, LDO4, 0, SUPPLIES_EN11, 6),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) PM8607_LDO(5, LDO5, 0, SUPPLIES_EN11, 7),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) PM8607_LDO(6, LDO6, 0, SUPPLIES_EN12, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) PM8607_LDO(7, LDO7, 0, SUPPLIES_EN12, 1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) PM8607_LDO(8, LDO8, 0, SUPPLIES_EN12, 2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) PM8607_LDO(9, LDO9, 0, SUPPLIES_EN12, 3),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) PM8607_LDO(10, LDO10, 0, SUPPLIES_EN12, 4),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) PM8607_LDO(12, LDO12, 0, SUPPLIES_EN12, 5),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) PM8607_LDO(13, VIBRATOR_SET, 1, VIBRATOR_SET, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) PM8607_LDO(14, LDO14, 0, SUPPLIES_EN12, 6),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) static struct pm8607_regulator_info pm8606_regulator_info[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) PM8606_PREG(PREREGULATORB, 5),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) static int pm8607_regulator_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) struct pm8607_regulator_info *info = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) struct regulator_init_data *pdata = dev_get_platdata(&pdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) struct regulator_config config = { };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) struct regulator_dev *rdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) struct resource *res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) res = platform_get_resource(pdev, IORESOURCE_REG, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) if (res) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) /* There're resources in 88PM8607 regulator driver */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) for (i = 0; i < ARRAY_SIZE(pm8607_regulator_info); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) info = &pm8607_regulator_info[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) if (info->desc.vsel_reg == res->start)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) if (i == ARRAY_SIZE(pm8607_regulator_info)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) dev_err(&pdev->dev, "Failed to find regulator %llu\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) (unsigned long long)res->start);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) /* There's no resource in 88PM8606 PREG regulator driver */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) info = &pm8606_regulator_info[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) /* i is used to check regulator ID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) i = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) /* check DVC ramp slope double */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) if ((i == PM8607_ID_BUCK3) && chip->buck3_double)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) info->slope_double = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) config.dev = chip->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) config.driver_data = info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) if (pdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) config.init_data = pdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) if (chip->id == CHIP_PM8607)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) config.regmap = chip->regmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) config.regmap = chip->regmap_companion;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) rdev = devm_regulator_register(&pdev->dev, &info->desc, &config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) if (IS_ERR(rdev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) dev_err(&pdev->dev, "failed to register regulator %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) info->desc.name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) return PTR_ERR(rdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) platform_set_drvdata(pdev, info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) static const struct platform_device_id pm8607_regulator_driver_ids[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) .name = "88pm860x-regulator",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) .driver_data = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) }, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) .name = "88pm860x-preg",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) .driver_data = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) { },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) MODULE_DEVICE_TABLE(platform, pm8607_regulator_driver_ids);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) static struct platform_driver pm8607_regulator_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) .driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) .name = "88pm860x-regulator",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) .probe = pm8607_regulator_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) .id_table = pm8607_regulator_driver_ids,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) static int __init pm8607_regulator_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) return platform_driver_register(&pm8607_regulator_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) subsys_initcall(pm8607_regulator_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) static void __exit pm8607_regulator_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) platform_driver_unregister(&pm8607_regulator_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) module_exit(pm8607_regulator_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) MODULE_AUTHOR("Haojian Zhuang <haojian.zhuang@marvell.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) MODULE_DESCRIPTION("Regulator Driver for Marvell 88PM8607 PMIC");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) MODULE_ALIAS("platform:88pm8607-regulator");