forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/acpi/pmic/intel_pmic_xpower.c
....@@ -1,23 +1,16 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
2
- * intel_pmic_xpower.c - XPower AXP288 PMIC operation region driver
3
+ * XPower AXP288 PMIC operation region driver
34 *
45 * Copyright (C) 2014 Intel Corporation. All rights reserved.
5
- *
6
- * This program is free software; you can redistribute it and/or
7
- * modify it under the terms of the GNU General Public License version
8
- * 2 as published by the Free Software Foundation.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
146 */
157
16
-#include <linux/init.h>
178 #include <linux/acpi.h>
9
+#include <linux/init.h>
1810 #include <linux/mfd/axp20x.h>
1911 #include <linux/regmap.h>
2012 #include <linux/platform_device.h>
13
+#include <asm/iosf_mbi.h>
2114 #include "intel_pmic.h"
2215
2316 #define XPOWER_GPADC_LOW 0x5b
....@@ -183,15 +176,21 @@
183176 static int intel_xpower_pmic_update_power(struct regmap *regmap, int reg,
184177 int bit, bool on)
185178 {
186
- int data;
179
+ int data, ret;
187180
188181 /* GPIO1 LDO regulator needs special handling */
189182 if (reg == XPOWER_GPI1_CTRL)
190183 return regmap_update_bits(regmap, reg, GPI1_LDO_MASK,
191184 on ? GPI1_LDO_ON : GPI1_LDO_OFF);
192185
193
- if (regmap_read(regmap, reg, &data))
194
- return -EIO;
186
+ ret = iosf_mbi_block_punit_i2c_access();
187
+ if (ret)
188
+ return ret;
189
+
190
+ if (regmap_read(regmap, reg, &data)) {
191
+ ret = -EIO;
192
+ goto out;
193
+ }
195194
196195 if (on)
197196 data |= BIT(bit);
....@@ -199,9 +198,11 @@
199198 data &= ~BIT(bit);
200199
201200 if (regmap_write(regmap, reg, data))
202
- return -EIO;
201
+ ret = -EIO;
202
+out:
203
+ iosf_mbi_unblock_punit_i2c_access();
203204
204
- return 0;
205
+ return ret;
205206 }
206207
207208 /**
....@@ -264,6 +265,7 @@
264265 .power_table_count = ARRAY_SIZE(power_table),
265266 .thermal_table = thermal_table,
266267 .thermal_table_count = ARRAY_SIZE(thermal_table),
268
+ .pmic_i2c_address = 0x34,
267269 };
268270
269271 static acpi_status intel_xpower_pmic_gpio_handler(u32 function,