2018-08-31 00:52:54 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2014-06-03 13:26:02 +08:00
|
|
|
/*
|
2018-08-31 00:52:54 +08:00
|
|
|
* Intel SoC PMIC Driver
|
2014-06-03 13:26:02 +08:00
|
|
|
*
|
|
|
|
* Copyright (C) 2012-2014 Intel Corporation. All rights reserved.
|
|
|
|
*
|
|
|
|
* Author: Yang, Bin <bin.yang@intel.com>
|
|
|
|
* Author: Zhu, Lejun <lejun.zhu@linux.intel.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __INTEL_SOC_PMIC_H__
|
|
|
|
#define __INTEL_SOC_PMIC_H__
|
|
|
|
|
|
|
|
#include <linux/regmap.h>
|
|
|
|
|
mfd: intel_soc_pmic_chtwc: Add cht_wc_model data to struct intel_soc_pmic
Tablet / laptop designs using an Intel Cherry Trail x86 main SoC with
an Intel Whiskey Cove PMIC do not use a single standard setup for
the charger, fuel-gauge and other chips surrounding the PMIC /
charging+data USB port.
Unlike what is normal on x86 this diversity in designs is not handled
by the ACPI tables. On 2 of the 3 known designs there are no standard
(PNP0C0A) ACPI battery devices and on the 3th design the ACPI battery
device does not work under Linux due to it requiring non-standard
and undocumented ACPI behavior.
So to make things work under Linux we use native charger and fuel-gauge
drivers on these devices, re-using the native drivers used on ARM boards
with the same charger / fuel-gauge ICs.
This requires various MFD-cell drivers for the CHT-WC PMIC cells to
know which model they are exactly running on so that they can e.g.
instantiate an I2C-client for the right model charger-IC (the charger
is connected to an I2C-controller which is part of the PMIC).
Rather then duplicating DMI-id matching to check which model we are
running on in each MFD-cell driver, add a check for this to the
shared drivers/mfd/intel_soc_pmic_chtwc.c code by using a
DMI table for all 3 known models:
1. The GPD Win and GPD Pocket mini-laptops, these are really 2 models
but the Pocket re-uses the GPD Win's design in a different housing:
The WC PMIC is connected to a TI BQ24292i charger, paired with
a Maxim MAX17047 fuelgauge + a FUSB302 USB Type-C Controller +
a PI3USB30532 USB switch, for a fully functional Type-C port.
2. The Xiaomi Mi Pad 2:
The WC PMIC is connected to a TI BQ25890 charger, paired with
a TI BQ27520 fuelgauge, using the TI BQ25890 for BC1.2 charger type
detection, for a USB-2 only Type-C port without PD.
3. The Lenovo Yoga Book YB1-X90 / Lenovo Yoga Book YB1-X91 series:
The WC PMIC is connected to a TI BQ25892 charger, paired with
a TI BQ27542 fuelgauge, using the WC PMIC for BC1.2 charger type
detection and using the BQ25892's Mediatek Pump Express+ (1.0)
support to enable charging with up to 12V through a micro-USB port.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2022-02-01 21:07:00 +08:00
|
|
|
enum intel_cht_wc_models {
|
|
|
|
INTEL_CHT_WC_UNKNOWN,
|
|
|
|
INTEL_CHT_WC_GPD_WIN_POCKET,
|
|
|
|
INTEL_CHT_WC_XIAOMI_MIPAD2,
|
|
|
|
INTEL_CHT_WC_LENOVO_YOGABOOK1,
|
|
|
|
};
|
|
|
|
|
2020-04-16 16:15:42 +08:00
|
|
|
/**
|
|
|
|
* struct intel_soc_pmic - Intel SoC PMIC data
|
|
|
|
* @irq: Master interrupt number of the parent PMIC device
|
|
|
|
* @regmap: Pointer to the parent PMIC device regmap structure
|
|
|
|
* @irq_chip_data: IRQ chip data for the PMIC itself
|
|
|
|
* @irq_chip_data_pwrbtn: Chained IRQ chip data for the Power Button
|
|
|
|
* @irq_chip_data_tmu: Chained IRQ chip data for the Time Management Unit
|
|
|
|
* @irq_chip_data_bcu: Chained IRQ chip data for the Burst Control Unit
|
|
|
|
* @irq_chip_data_adc: Chained IRQ chip data for the General Purpose ADC
|
|
|
|
* @irq_chip_data_chgr: Chained IRQ chip data for the External Charger
|
|
|
|
* @irq_chip_data_crit: Chained IRQ chip data for the Critical Event Handler
|
|
|
|
* @dev: Pointer to the parent PMIC device
|
|
|
|
* @scu: Pointer to the SCU IPC device data structure
|
|
|
|
*/
|
2014-06-03 13:26:02 +08:00
|
|
|
struct intel_soc_pmic {
|
|
|
|
int irq;
|
|
|
|
struct regmap *regmap;
|
|
|
|
struct regmap_irq_chip_data *irq_chip_data;
|
2018-08-31 00:52:52 +08:00
|
|
|
struct regmap_irq_chip_data *irq_chip_data_pwrbtn;
|
2016-11-08 04:11:47 +08:00
|
|
|
struct regmap_irq_chip_data *irq_chip_data_tmu;
|
mfd: intel_soc_pmic_bxtwc: Use chained IRQs for second level IRQ chips
Whishkey cove PMIC has support to mask/unmask interrupts at two levels.
At first level we can mask/unmask interrupt domains like TMU, GPIO, ADC,
CHGR, BCU THERMAL and PWRBTN and at second level, it provides facility
to mask/unmask individual interrupts belong each of this domain. For
example, in case of TMU, at first level we have TMU interrupt domain,
and at second level we have two interrupts, wake alarm, system alarm that
belong to the TMU interrupt domain.
Currently, in this driver all first level IRQs are registered as part of
IRQ chip(bxtwc_regmap_irq_chip). By default, after you register the IRQ
chip from your driver, all IRQs in that chip will masked and can only be
enabled if that IRQ is requested using request_irq() call. This is the
default Linux IRQ behavior model. And whenever a dependent device that
belongs to PMIC requests only the second level IRQ and not explicitly
unmask the first level IRQ, then in essence the second level IRQ will
still be disabled. For example, if TMU device driver request wake_alarm
IRQ and not explicitly unmask TMU level 1 IRQ then according to the default
Linux IRQ model, wake_alarm IRQ will still be disabled. So the proper
solution to fix this issue is to use the chained IRQ chip concept. We
should chain all the second level chip IRQs to the corresponding first
level IRQ. To do this, we need to create separate IRQ chips for every
group of second level IRQs.
In case of TMU, when adding second level IRQ chip, instead of using PMIC
IRQ we should use the corresponding first level IRQ. So the following
code will change from
ret = regmap_add_irq_chip(pmic->regmap, pmic->irq, ...)
to,
virq = regmap_irq_get_virq(&pmic->irq_chip_data, BXTWC_TMU_LVL1_IRQ);
ret = regmap_add_irq_chip(pmic->regmap, virq, ...)
In case of Whiskey Cove Type-C driver, Since USBC IRQ is moved under
charger level2 IRQ chip. We should use charger IRQ chip(irq_chip_data_chgr)
to get the USBC virtual IRQ number.
Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Revieved-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2017-06-06 03:08:05 +08:00
|
|
|
struct regmap_irq_chip_data *irq_chip_data_bcu;
|
|
|
|
struct regmap_irq_chip_data *irq_chip_data_adc;
|
|
|
|
struct regmap_irq_chip_data *irq_chip_data_chgr;
|
|
|
|
struct regmap_irq_chip_data *irq_chip_data_crit;
|
2015-09-15 00:39:18 +08:00
|
|
|
struct device *dev;
|
2020-04-16 16:15:42 +08:00
|
|
|
struct intel_scu_ipc_dev *scu;
|
mfd: intel_soc_pmic_chtwc: Add cht_wc_model data to struct intel_soc_pmic
Tablet / laptop designs using an Intel Cherry Trail x86 main SoC with
an Intel Whiskey Cove PMIC do not use a single standard setup for
the charger, fuel-gauge and other chips surrounding the PMIC /
charging+data USB port.
Unlike what is normal on x86 this diversity in designs is not handled
by the ACPI tables. On 2 of the 3 known designs there are no standard
(PNP0C0A) ACPI battery devices and on the 3th design the ACPI battery
device does not work under Linux due to it requiring non-standard
and undocumented ACPI behavior.
So to make things work under Linux we use native charger and fuel-gauge
drivers on these devices, re-using the native drivers used on ARM boards
with the same charger / fuel-gauge ICs.
This requires various MFD-cell drivers for the CHT-WC PMIC cells to
know which model they are exactly running on so that they can e.g.
instantiate an I2C-client for the right model charger-IC (the charger
is connected to an I2C-controller which is part of the PMIC).
Rather then duplicating DMI-id matching to check which model we are
running on in each MFD-cell driver, add a check for this to the
shared drivers/mfd/intel_soc_pmic_chtwc.c code by using a
DMI table for all 3 known models:
1. The GPD Win and GPD Pocket mini-laptops, these are really 2 models
but the Pocket re-uses the GPD Win's design in a different housing:
The WC PMIC is connected to a TI BQ24292i charger, paired with
a Maxim MAX17047 fuelgauge + a FUSB302 USB Type-C Controller +
a PI3USB30532 USB switch, for a fully functional Type-C port.
2. The Xiaomi Mi Pad 2:
The WC PMIC is connected to a TI BQ25890 charger, paired with
a TI BQ27520 fuelgauge, using the TI BQ25890 for BC1.2 charger type
detection, for a USB-2 only Type-C port without PD.
3. The Lenovo Yoga Book YB1-X90 / Lenovo Yoga Book YB1-X91 series:
The WC PMIC is connected to a TI BQ25892 charger, paired with
a TI BQ27542 fuelgauge, using the WC PMIC for BC1.2 charger type
detection and using the BQ25892's Mediatek Pump Express+ (1.0)
support to enable charging with up to 12V through a micro-USB port.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2022-02-01 21:07:00 +08:00
|
|
|
enum intel_cht_wc_models cht_wc_model;
|
2014-06-03 13:26:02 +08:00
|
|
|
};
|
|
|
|
|
2019-01-07 19:15:53 +08:00
|
|
|
int intel_soc_pmic_exec_mipi_pmic_seq_element(u16 i2c_address, u32 reg_address,
|
|
|
|
u32 value, u32 mask);
|
|
|
|
|
2014-06-03 13:26:02 +08:00
|
|
|
#endif /* __INTEL_SOC_PMIC_H__ */
|