0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include <linux/acpi.h>
0011 #include <linux/init.h>
0012 #include <linux/mfd/intel_soc_pmic.h>
0013 #include <linux/platform_device.h>
0014 #include "intel_pmic.h"
0015
0016
0017 #define CHTDC_TI_VBAT 0x54
0018 #define CHTDC_TI_DIETEMP 0x56
0019 #define CHTDC_TI_BPTHERM 0x58
0020 #define CHTDC_TI_GPADC 0x5a
0021
0022 static struct pmic_table chtdc_ti_power_table[] = {
0023 { .address = 0x00, .reg = 0x41 },
0024 { .address = 0x04, .reg = 0x42 },
0025 { .address = 0x08, .reg = 0x43 },
0026 { .address = 0x0c, .reg = 0x45 },
0027 { .address = 0x10, .reg = 0x46 },
0028 { .address = 0x14, .reg = 0x47 },
0029 { .address = 0x18, .reg = 0x48 },
0030 { .address = 0x1c, .reg = 0x49 },
0031 { .address = 0x20, .reg = 0x4a },
0032 { .address = 0x24, .reg = 0x4b },
0033 { .address = 0x28, .reg = 0x4c },
0034 { .address = 0x2c, .reg = 0x4d },
0035 { .address = 0x30, .reg = 0x4e },
0036 };
0037
0038 static struct pmic_table chtdc_ti_thermal_table[] = {
0039 {
0040 .address = 0x00,
0041 .reg = CHTDC_TI_GPADC
0042 },
0043 {
0044 .address = 0x0c,
0045 .reg = CHTDC_TI_GPADC
0046 },
0047
0048 {
0049 .address = 0x18,
0050 .reg = CHTDC_TI_GPADC
0051 },
0052
0053 {
0054 .address = 0x24,
0055 .reg = CHTDC_TI_BPTHERM
0056 },
0057 {
0058 .address = 0x30,
0059 .reg = CHTDC_TI_GPADC
0060 },
0061
0062 {
0063 .address = 0x3c,
0064 .reg = CHTDC_TI_DIETEMP
0065 },
0066 };
0067
0068 static int chtdc_ti_pmic_get_power(struct regmap *regmap, int reg, int bit,
0069 u64 *value)
0070 {
0071 int data;
0072
0073 if (regmap_read(regmap, reg, &data))
0074 return -EIO;
0075
0076 *value = data & 1;
0077 return 0;
0078 }
0079
0080 static int chtdc_ti_pmic_update_power(struct regmap *regmap, int reg, int bit,
0081 bool on)
0082 {
0083 return regmap_update_bits(regmap, reg, 1, on);
0084 }
0085
0086 static int chtdc_ti_pmic_get_raw_temp(struct regmap *regmap, int reg)
0087 {
0088 u8 buf[2];
0089
0090 if (regmap_bulk_read(regmap, reg, buf, 2))
0091 return -EIO;
0092
0093
0094 return ((buf[0] & 0x03) << 8) | buf[1];
0095 }
0096
0097 static const struct intel_pmic_opregion_data chtdc_ti_pmic_opregion_data = {
0098 .get_power = chtdc_ti_pmic_get_power,
0099 .update_power = chtdc_ti_pmic_update_power,
0100 .get_raw_temp = chtdc_ti_pmic_get_raw_temp,
0101 .lpat_raw_to_temp = acpi_lpat_raw_to_temp,
0102 .power_table = chtdc_ti_power_table,
0103 .power_table_count = ARRAY_SIZE(chtdc_ti_power_table),
0104 .thermal_table = chtdc_ti_thermal_table,
0105 .thermal_table_count = ARRAY_SIZE(chtdc_ti_thermal_table),
0106 .pmic_i2c_address = 0x5e,
0107 };
0108
0109 static int chtdc_ti_pmic_opregion_probe(struct platform_device *pdev)
0110 {
0111 struct intel_soc_pmic *pmic = dev_get_drvdata(pdev->dev.parent);
0112 int err;
0113
0114 err = intel_pmic_install_opregion_handler(&pdev->dev,
0115 ACPI_HANDLE(pdev->dev.parent), pmic->regmap,
0116 &chtdc_ti_pmic_opregion_data);
0117 if (err < 0)
0118 return err;
0119
0120
0121 acpi_dev_clear_dependencies(ACPI_COMPANION(pdev->dev.parent));
0122 return 0;
0123 }
0124
0125 static const struct platform_device_id chtdc_ti_pmic_opregion_id_table[] = {
0126 { .name = "chtdc_ti_region" },
0127 {},
0128 };
0129
0130 static struct platform_driver chtdc_ti_pmic_opregion_driver = {
0131 .probe = chtdc_ti_pmic_opregion_probe,
0132 .driver = {
0133 .name = "cht_dollar_cove_ti_pmic",
0134 },
0135 .id_table = chtdc_ti_pmic_opregion_id_table,
0136 };
0137 builtin_platform_driver(chtdc_ti_pmic_opregion_driver);