Commit d9cd0bc6 authored by AngeloGioacchino Del Regno's avatar AngeloGioacchino Del Regno Committed by Lee Jones
Browse files

mfd: mt6397: Add basic support for MT6331+MT6332 PMIC



Add support for the MT6331 PMIC with MT6332 Companion PMIC, found
in MT6795 Helio X10 smartphone platforms.

This combo has support for multiple devices but, for a start,
only the following have been implemented:
- Regulators (two instances, one in MT6331, one in MT6332)
- RTC (MT6331)
- Keys (MT6331)
- Interrupts (MT6331 also dispatches MT6332's interrupts)

There's more to be implemented, especially for MT6332, which
will come at a later stage.

Signed-off-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: default avatarMatthias Brugger <matthias.bgg@gmail.com>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
Link: https://lore.kernel.org/r/20220627123954.64299-1-angelogioacchino.delregno@collabora.com
parent 371a9fca
Loading
Loading
Loading
Loading
+47 −0
Original line number Diff line number Diff line
@@ -12,11 +12,13 @@
#include <linux/regmap.h>
#include <linux/mfd/core.h>
#include <linux/mfd/mt6323/core.h>
#include <linux/mfd/mt6331/core.h>
#include <linux/mfd/mt6357/core.h>
#include <linux/mfd/mt6358/core.h>
#include <linux/mfd/mt6359/core.h>
#include <linux/mfd/mt6397/core.h>
#include <linux/mfd/mt6323/registers.h>
#include <linux/mfd/mt6331/registers.h>
#include <linux/mfd/mt6357/registers.h>
#include <linux/mfd/mt6358/registers.h>
#include <linux/mfd/mt6359/registers.h>
@@ -28,6 +30,9 @@
#define MT6357_RTC_BASE		0x0588
#define MT6357_RTC_SIZE		0x3c

#define MT6331_RTC_BASE		0x4000
#define MT6331_RTC_SIZE		0x40

#define MT6358_RTC_BASE		0x0588
#define MT6358_RTC_SIZE		0x3c

@@ -47,6 +52,11 @@ static const struct resource mt6357_rtc_resources[] = {
	DEFINE_RES_IRQ(MT6357_IRQ_RTC),
};

static const struct resource mt6331_rtc_resources[] = {
	DEFINE_RES_MEM(MT6331_RTC_BASE, MT6331_RTC_SIZE),
	DEFINE_RES_IRQ(MT6331_IRQ_STATUS_RTC),
};

static const struct resource mt6358_rtc_resources[] = {
	DEFINE_RES_MEM(MT6358_RTC_BASE, MT6358_RTC_SIZE),
	DEFINE_RES_IRQ(MT6358_IRQ_RTC),
@@ -83,6 +93,11 @@ static const struct resource mt6357_keys_resources[] = {
	DEFINE_RES_IRQ_NAMED(MT6357_IRQ_HOMEKEY_R, "homekey_r"),
};

static const struct resource mt6331_keys_resources[] = {
	DEFINE_RES_IRQ_NAMED(MT6331_IRQ_STATUS_PWRKEY, "powerkey"),
	DEFINE_RES_IRQ_NAMED(MT6331_IRQ_STATUS_HOMEKEY, "homekey"),
};

static const struct resource mt6397_keys_resources[] = {
	DEFINE_RES_IRQ_NAMED(MT6397_IRQ_PWRKEY, "powerkey"),
	DEFINE_RES_IRQ_NAMED(MT6397_IRQ_HOMEKEY, "homekey"),
@@ -133,6 +148,27 @@ static const struct mfd_cell mt6357_devs[] = {
	},
};

/* MT6331 is always used in combination with MT6332 */
static const struct mfd_cell mt6331_mt6332_devs[] = {
	{
		.name = "mt6331-rtc",
		.num_resources = ARRAY_SIZE(mt6331_rtc_resources),
		.resources = mt6331_rtc_resources,
		.of_compatible = "mediatek,mt6331-rtc",
	}, {
		.name = "mt6331-regulator",
		.of_compatible = "mediatek,mt6331-regulator"
	}, {
		.name = "mt6332-regulator",
		.of_compatible = "mediatek,mt6332-regulator"
	}, {
		.name = "mtk-pmic-keys",
		.num_resources = ARRAY_SIZE(mt6331_keys_resources),
		.resources = mt6331_keys_resources,
		.of_compatible = "mediatek,mt6331-keys"
	},
};

static const struct mfd_cell mt6358_devs[] = {
	{
		.name = "mt6358-regulator",
@@ -220,6 +256,14 @@ static const struct chip_data mt6357_core = {
	.irq_init = mt6358_irq_init,
};

static const struct chip_data mt6331_mt6332_core = {
	.cid_addr = MT6331_HWCID,
	.cid_shift = 0,
	.cells = mt6331_mt6332_devs,
	.cell_size = ARRAY_SIZE(mt6331_mt6332_devs),
	.irq_init = mt6397_irq_init,
};

static const struct chip_data mt6358_core = {
	.cid_addr = MT6358_SWCID,
	.cid_shift = 8,
@@ -302,6 +346,9 @@ static const struct of_device_id mt6397_of_match[] = {
	{
		.compatible = "mediatek,mt6323",
		.data = &mt6323_core,
	}, {
		.compatible = "mediatek,mt6331",
		.data = &mt6331_mt6332_core,
	}, {
		.compatible = "mediatek,mt6357",
		.data = &mt6357_core,
+8 −1
Original line number Diff line number Diff line
@@ -12,6 +12,8 @@
#include <linux/suspend.h>
#include <linux/mfd/mt6323/core.h>
#include <linux/mfd/mt6323/registers.h>
#include <linux/mfd/mt6331/core.h>
#include <linux/mfd/mt6331/registers.h>
#include <linux/mfd/mt6397/core.h>
#include <linux/mfd/mt6397/registers.h>

@@ -172,7 +174,12 @@ int mt6397_irq_init(struct mt6397_chip *chip)
		chip->int_status[0] = MT6323_INT_STATUS0;
		chip->int_status[1] = MT6323_INT_STATUS1;
		break;

	case MT6331_CHIP_ID:
		chip->int_con[0] = MT6331_INT_CON0;
		chip->int_con[1] = MT6331_INT_CON1;
		chip->int_status[0] = MT6331_INT_STATUS_CON0;
		chip->int_status[1] = MT6331_INT_STATUS_CON1;
		break;
	case MT6391_CHIP_ID:
	case MT6397_CHIP_ID:
		chip->int_con[0] = MT6397_INT_CON0;
+40 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (c) 2022 AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
 */

#ifndef __MFD_MT6331_CORE_H__
#define __MFD_MT6331_CORE_H__

enum mt6331_irq_status_numbers {
	MT6331_IRQ_STATUS_PWRKEY = 0,
	MT6331_IRQ_STATUS_HOMEKEY,
	MT6331_IRQ_STATUS_CHRDET,
	MT6331_IRQ_STATUS_THR_H,
	MT6331_IRQ_STATUS_THR_L,
	MT6331_IRQ_STATUS_BAT_H,
	MT6331_IRQ_STATUS_BAT_L,
	MT6331_IRQ_STATUS_RTC,
	MT6331_IRQ_STATUS_AUDIO,
	MT6331_IRQ_STATUS_MAD,
	MT6331_IRQ_STATUS_ACCDET,
	MT6331_IRQ_STATUS_ACCDET_EINT,
	MT6331_IRQ_STATUS_ACCDET_NEGV = 12,
	MT6331_IRQ_STATUS_VDVFS11_OC = 16,
	MT6331_IRQ_STATUS_VDVFS12_OC,
	MT6331_IRQ_STATUS_VDVFS13_OC,
	MT6331_IRQ_STATUS_VDVFS14_OC,
	MT6331_IRQ_STATUS_GPU_OC,
	MT6331_IRQ_STATUS_VCORE1_OC,
	MT6331_IRQ_STATUS_VCORE2_OC,
	MT6331_IRQ_STATUS_VIO18_OC,
	MT6331_IRQ_STATUS_LDO_OC,
	MT6331_IRQ_STATUS_NR,
};

#define MT6331_IRQ_CON0_BASE	MT6331_IRQ_STATUS_PWRKEY
#define MT6331_IRQ_CON0_BITS	(MT6331_IRQ_STATUS_ACCDET_NEGV + 1)
#define MT6331_IRQ_CON1_BASE	MT6331_IRQ_STATUS_VDVFS11_OC
#define MT6331_IRQ_CON1_BITS	(MT6331_IRQ_STATUS_LDO_OC - MT6331_IRQ_STATUS_VDFS11_OC + 1)

#endif /* __MFD_MT6331_CORE_H__ */
+584 −0

File added.

Preview size limit exceeded, changes collapsed.

+65 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading