Loading Documentation/devicetree/bindings/mfd/mt6397.txt +1 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ Required properties: compatible: "mediatek,mt6323" for PMIC MT6323 "mediatek,mt6358" for PMIC MT6358 "mediatek,mt6359" for PMIC MT6359 "mediatek,mt6397" for PMIC MT6397 Optional subnodes: Loading Documentation/devicetree/bindings/regulator/mt6359-regulator.yaml 0 → 100644 +385 −0 Original line number Diff line number Diff line # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) %YAML 1.2 --- $id: http://devicetree.org/schemas/regulator/mt6359-regulator.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# title: MT6359 Regulator from MediaTek Integrated maintainers: - Hsin-Hsiung Wang <hsin-hsiung.wang@mediatek.com> description: | List of regulators provided by this controller. It is named according to its regulator type, buck_<name> and ldo_<name>. MT6359 regulators node should be sub node of the MT6397 MFD node. patternProperties: "^buck_v(s1|gpu11|modem|pu|core|s2|pa|proc2|proc1|core_sshub)$": type: object $ref: "regulator.yaml#" properties: regulator-name: pattern: "^v(s1|gpu11|modem|pu|core|s2|pa|proc2|proc1|core_sshub)$" unevaluatedProperties: false "^ldo_v(ibr|rf12|usb|camio|efuse|xo22)$": type: object $ref: "regulator.yaml#" properties: regulator-name: pattern: "^v(ibr|rf12|usb|camio|efuse|xo22)$" unevaluatedProperties: false "^ldo_v(rfck|emc|a12|a09|ufs|bbck)$": type: object $ref: "regulator.yaml#" properties: regulator-name: pattern: "^v(rfck|emc|a12|a09|ufs|bbck)$" unevaluatedProperties: false "^ldo_vcn(18|13|33_1_bt|13_1_wifi|33_2_bt|33_2_wifi)$": type: object $ref: "regulator.yaml#" properties: regulator-name: pattern: "^vcn(18|13|33_1_bt|13_1_wifi|33_2_bt|33_2_wifi)$" unevaluatedProperties: false "^ldo_vsram_(proc2|others|md|proc1|others_sshub)$": type: object $ref: "regulator.yaml#" properties: regulator-name: pattern: "^vsram_(proc2|others|md|proc1|others_sshub)$" unevaluatedProperties: false "^ldo_v(fe|bif|io)28$": type: object $ref: "regulator.yaml#" properties: regulator-name: pattern: "^v(fe|bif|io)28$" unevaluatedProperties: false "^ldo_v(aud|io|aux|rf|m)18$": type: object $ref: "regulator.yaml#" properties: regulator-name: pattern: "^v(aud|io|aux|rf|m)18$" unevaluatedProperties: false "^ldo_vsim[12]$": type: object $ref: "regulator.yaml#" properties: regulator-name: pattern: "^vsim[12]$" required: - regulator-name unevaluatedProperties: false additionalProperties: false examples: - | pmic { regulators { mt6359_vs1_buck_reg: buck_vs1 { regulator-name = "vs1"; regulator-min-microvolt = <800000>; regulator-max-microvolt = <2200000>; regulator-enable-ramp-delay = <0>; regulator-always-on; }; mt6359_vgpu11_buck_reg: buck_vgpu11 { regulator-name = "vgpu11"; regulator-min-microvolt = <400000>; regulator-max-microvolt = <1193750>; regulator-ramp-delay = <5000>; regulator-enable-ramp-delay = <200>; regulator-allowed-modes = <0 1 2>; }; mt6359_vmodem_buck_reg: buck_vmodem { regulator-name = "vmodem"; regulator-min-microvolt = <400000>; regulator-max-microvolt = <1100000>; regulator-ramp-delay = <10760>; regulator-enable-ramp-delay = <200>; }; mt6359_vpu_buck_reg: buck_vpu { regulator-name = "vpu"; regulator-min-microvolt = <400000>; regulator-max-microvolt = <1193750>; regulator-ramp-delay = <5000>; regulator-enable-ramp-delay = <200>; regulator-allowed-modes = <0 1 2>; }; mt6359_vcore_buck_reg: buck_vcore { regulator-name = "vcore"; regulator-min-microvolt = <400000>; regulator-max-microvolt = <1300000>; regulator-ramp-delay = <5000>; regulator-enable-ramp-delay = <200>; regulator-allowed-modes = <0 1 2>; }; mt6359_vs2_buck_reg: buck_vs2 { regulator-name = "vs2"; regulator-min-microvolt = <800000>; regulator-max-microvolt = <1600000>; regulator-enable-ramp-delay = <0>; regulator-always-on; }; mt6359_vpa_buck_reg: buck_vpa { regulator-name = "vpa"; regulator-min-microvolt = <500000>; regulator-max-microvolt = <3650000>; regulator-enable-ramp-delay = <300>; }; mt6359_vproc2_buck_reg: buck_vproc2 { regulator-name = "vproc2"; regulator-min-microvolt = <400000>; regulator-max-microvolt = <1193750>; regulator-ramp-delay = <7500>; regulator-enable-ramp-delay = <200>; regulator-allowed-modes = <0 1 2>; }; mt6359_vproc1_buck_reg: buck_vproc1 { regulator-name = "vproc1"; regulator-min-microvolt = <400000>; regulator-max-microvolt = <1193750>; regulator-ramp-delay = <7500>; regulator-enable-ramp-delay = <200>; regulator-allowed-modes = <0 1 2>; }; mt6359_vcore_sshub_buck_reg: buck_vcore_sshub { regulator-name = "vcore_sshub"; regulator-min-microvolt = <400000>; regulator-max-microvolt = <1193750>; }; mt6359_vgpu11_sshub_buck_reg: buck_vgpu11_sshub { regulator-name = "vgpu11_sshub"; regulator-min-microvolt = <400000>; regulator-max-microvolt = <1193750>; }; mt6359_vaud18_ldo_reg: ldo_vaud18 { regulator-name = "vaud18"; regulator-min-microvolt = <1800000>; regulator-max-microvolt = <1800000>; regulator-enable-ramp-delay = <240>; }; mt6359_vsim1_ldo_reg: ldo_vsim1 { regulator-name = "vsim1"; regulator-min-microvolt = <1700000>; regulator-max-microvolt = <3100000>; }; mt6359_vibr_ldo_reg: ldo_vibr { regulator-name = "vibr"; regulator-min-microvolt = <1200000>; regulator-max-microvolt = <3300000>; }; mt6359_vrf12_ldo_reg: ldo_vrf12 { regulator-name = "vrf12"; regulator-min-microvolt = <1100000>; regulator-max-microvolt = <1300000>; }; mt6359_vusb_ldo_reg: ldo_vusb { regulator-name = "vusb"; regulator-min-microvolt = <3000000>; regulator-max-microvolt = <3000000>; regulator-enable-ramp-delay = <960>; regulator-always-on; }; mt6359_vsram_proc2_ldo_reg: ldo_vsram_proc2 { regulator-name = "vsram_proc2"; regulator-min-microvolt = <500000>; regulator-max-microvolt = <1293750>; regulator-ramp-delay = <7500>; regulator-enable-ramp-delay = <240>; regulator-always-on; }; mt6359_vio18_ldo_reg: ldo_vio18 { regulator-name = "vio18"; regulator-min-microvolt = <1700000>; regulator-max-microvolt = <1900000>; regulator-enable-ramp-delay = <960>; regulator-always-on; }; mt6359_vcamio_ldo_reg: ldo_vcamio { regulator-name = "vcamio"; regulator-min-microvolt = <1700000>; regulator-max-microvolt = <1900000>; }; mt6359_vcn18_ldo_reg: ldo_vcn18 { regulator-name = "vcn18"; regulator-min-microvolt = <1800000>; regulator-max-microvolt = <1800000>; regulator-enable-ramp-delay = <240>; }; mt6359_vfe28_ldo_reg: ldo_vfe28 { regulator-name = "vfe28"; regulator-min-microvolt = <2800000>; regulator-max-microvolt = <2800000>; regulator-enable-ramp-delay = <120>; }; mt6359_vcn13_ldo_reg: ldo_vcn13 { regulator-name = "vcn13"; regulator-min-microvolt = <900000>; regulator-max-microvolt = <1300000>; }; mt6359_vcn33_1_bt_ldo_reg: ldo_vcn33_1_bt { regulator-name = "vcn33_1_bt"; regulator-min-microvolt = <2800000>; regulator-max-microvolt = <3500000>; }; mt6359_vcn33_1_wifi_ldo_reg: ldo_vcn33_1_wifi { regulator-name = "vcn33_1_wifi"; regulator-min-microvolt = <2800000>; regulator-max-microvolt = <3500000>; }; mt6359_vaux18_ldo_reg: ldo_vaux18 { regulator-name = "vaux18"; regulator-min-microvolt = <1800000>; regulator-max-microvolt = <1800000>; regulator-enable-ramp-delay = <240>; regulator-always-on; }; mt6359_vsram_others_ldo_reg: ldo_vsram_others { regulator-name = "vsram_others"; regulator-min-microvolt = <500000>; regulator-max-microvolt = <1293750>; regulator-ramp-delay = <5000>; regulator-enable-ramp-delay = <240>; }; mt6359_vefuse_ldo_reg: ldo_vefuse { regulator-name = "vefuse"; regulator-min-microvolt = <1700000>; regulator-max-microvolt = <2000000>; }; mt6359_vxo22_ldo_reg: ldo_vxo22 { regulator-name = "vxo22"; regulator-min-microvolt = <1800000>; regulator-max-microvolt = <2200000>; regulator-always-on; }; mt6359_vrfck_ldo_reg: ldo_vrfck { regulator-name = "vrfck"; regulator-min-microvolt = <1500000>; regulator-max-microvolt = <1700000>; }; mt6359_vrfck_1_ldo_reg: ldo_vrfck_1 { regulator-name = "vrfck"; regulator-min-microvolt = <1240000>; regulator-max-microvolt = <1600000>; }; mt6359_vbif28_ldo_reg: ldo_vbif28 { regulator-name = "vbif28"; regulator-min-microvolt = <2800000>; regulator-max-microvolt = <2800000>; regulator-enable-ramp-delay = <240>; }; mt6359_vio28_ldo_reg: ldo_vio28 { regulator-name = "vio28"; regulator-min-microvolt = <2800000>; regulator-max-microvolt = <3300000>; regulator-always-on; }; mt6359_vemc_ldo_reg: ldo_vemc { regulator-name = "vemc"; regulator-min-microvolt = <2900000>; regulator-max-microvolt = <3300000>; }; mt6359_vemc_1_ldo_reg: ldo_vemc_1 { regulator-name = "vemc"; regulator-min-microvolt = <2500000>; regulator-max-microvolt = <3300000>; }; mt6359_vcn33_2_bt_ldo_reg: ldo_vcn33_2_bt { regulator-name = "vcn33_2_bt"; regulator-min-microvolt = <2800000>; regulator-max-microvolt = <3500000>; }; mt6359_vcn33_2_wifi_ldo_reg: ldo_vcn33_2_wifi { regulator-name = "vcn33_2_wifi"; regulator-min-microvolt = <2800000>; regulator-max-microvolt = <3500000>; }; mt6359_va12_ldo_reg: ldo_va12 { regulator-name = "va12"; regulator-min-microvolt = <1200000>; regulator-max-microvolt = <1300000>; regulator-always-on; }; mt6359_va09_ldo_reg: ldo_va09 { regulator-name = "va09"; regulator-min-microvolt = <800000>; regulator-max-microvolt = <1200000>; }; mt6359_vrf18_ldo_reg: ldo_vrf18 { regulator-name = "vrf18"; regulator-min-microvolt = <1700000>; regulator-max-microvolt = <1810000>; }; mt6359_vsram_md_ldo_reg: ldo_vsram_md { regulator-name = "vsram_md"; regulator-min-microvolt = <500000>; regulator-max-microvolt = <1293750>; regulator-ramp-delay = <10760>; regulator-enable-ramp-delay = <240>; }; mt6359_vufs_ldo_reg: ldo_vufs { regulator-name = "vufs"; regulator-min-microvolt = <1700000>; regulator-max-microvolt = <1900000>; }; mt6359_vm18_ldo_reg: ldo_vm18 { regulator-name = "vm18"; regulator-min-microvolt = <1700000>; regulator-max-microvolt = <1900000>; regulator-always-on; }; mt6359_vbbck_ldo_reg: ldo_vbbck { regulator-name = "vbbck"; regulator-min-microvolt = <1100000>; regulator-max-microvolt = <1200000>; }; mt6359_vsram_proc1_ldo_reg: ldo_vsram_proc1 { regulator-name = "vsram_proc1"; regulator-min-microvolt = <500000>; regulator-max-microvolt = <1293750>; regulator-ramp-delay = <7500>; regulator-enable-ramp-delay = <240>; regulator-always-on; }; mt6359_vsim2_ldo_reg: ldo_vsim2 { regulator-name = "vsim2"; regulator-min-microvolt = <1700000>; regulator-max-microvolt = <3100000>; }; mt6359_vsram_others_sshub_ldo: ldo_vsram_others_sshub { regulator-name = "vsram_others_sshub"; regulator-min-microvolt = <500000>; regulator-max-microvolt = <1293750>; }; }; }; ... drivers/mfd/mt6358-irq.c +62 −27 Original line number Diff line number Diff line Loading @@ -5,6 +5,8 @@ #include <linux/interrupt.h> #include <linux/mfd/mt6358/core.h> #include <linux/mfd/mt6358/registers.h> #include <linux/mfd/mt6359/core.h> #include <linux/mfd/mt6359/registers.h> #include <linux/mfd/mt6397/core.h> #include <linux/module.h> #include <linux/of.h> Loading @@ -13,7 +15,9 @@ #include <linux/platform_device.h> #include <linux/regmap.h> static struct irq_top_t mt6358_ints[] = { #define MTK_PMIC_REG_WIDTH 16 static const struct irq_top_t mt6358_ints[] = { MT6358_TOP_GEN(BUCK), MT6358_TOP_GEN(LDO), MT6358_TOP_GEN(PSC), Loading @@ -24,6 +28,31 @@ static struct irq_top_t mt6358_ints[] = { MT6358_TOP_GEN(MISC), }; static const struct irq_top_t mt6359_ints[] = { MT6359_TOP_GEN(BUCK), MT6359_TOP_GEN(LDO), MT6359_TOP_GEN(PSC), MT6359_TOP_GEN(SCK), MT6359_TOP_GEN(BM), MT6359_TOP_GEN(HK), MT6359_TOP_GEN(AUD), MT6359_TOP_GEN(MISC), }; static struct pmic_irq_data mt6358_irqd = { .num_top = ARRAY_SIZE(mt6358_ints), .num_pmic_irqs = MT6358_IRQ_NR, .top_int_status_reg = MT6358_TOP_INT_STATUS0, .pmic_ints = mt6358_ints, }; static struct pmic_irq_data mt6359_irqd = { .num_top = ARRAY_SIZE(mt6359_ints), .num_pmic_irqs = MT6359_IRQ_NR, .top_int_status_reg = MT6359_TOP_INT_STATUS0, .pmic_ints = mt6359_ints, }; static void pmic_irq_enable(struct irq_data *data) { unsigned int hwirq = irqd_to_hwirq(data); Loading Loading @@ -62,15 +91,15 @@ static void pmic_irq_sync_unlock(struct irq_data *data) /* Find out the IRQ group */ top_gp = 0; while ((top_gp + 1) < irqd->num_top && i >= mt6358_ints[top_gp + 1].hwirq_base) i >= irqd->pmic_ints[top_gp + 1].hwirq_base) top_gp++; /* Find the IRQ registers */ gp_offset = i - mt6358_ints[top_gp].hwirq_base; int_regs = gp_offset / MT6358_REG_WIDTH; shift = gp_offset % MT6358_REG_WIDTH; en_reg = mt6358_ints[top_gp].en_reg + (mt6358_ints[top_gp].en_reg_shift * int_regs); gp_offset = i - irqd->pmic_ints[top_gp].hwirq_base; int_regs = gp_offset / MTK_PMIC_REG_WIDTH; shift = gp_offset % MTK_PMIC_REG_WIDTH; en_reg = irqd->pmic_ints[top_gp].en_reg + (irqd->pmic_ints[top_gp].en_reg_shift * int_regs); regmap_update_bits(chip->regmap, en_reg, BIT(shift), irqd->enable_hwirq[i] << shift); Loading @@ -95,10 +124,11 @@ static void mt6358_irq_sp_handler(struct mt6397_chip *chip, unsigned int irq_status, sta_reg, status; unsigned int hwirq, virq; int i, j, ret; struct pmic_irq_data *irqd = chip->irq_data; for (i = 0; i < mt6358_ints[top_gp].num_int_regs; i++) { sta_reg = mt6358_ints[top_gp].sta_reg + mt6358_ints[top_gp].sta_reg_shift * i; for (i = 0; i < irqd->pmic_ints[top_gp].num_int_regs; i++) { sta_reg = irqd->pmic_ints[top_gp].sta_reg + irqd->pmic_ints[top_gp].sta_reg_shift * i; ret = regmap_read(chip->regmap, sta_reg, &irq_status); if (ret) { Loading @@ -114,8 +144,8 @@ static void mt6358_irq_sp_handler(struct mt6397_chip *chip, do { j = __ffs(status); hwirq = mt6358_ints[top_gp].hwirq_base + MT6358_REG_WIDTH * i + j; hwirq = irqd->pmic_ints[top_gp].hwirq_base + MTK_PMIC_REG_WIDTH * i + j; virq = irq_find_mapping(chip->irq_domain, hwirq); if (virq) Loading @@ -131,12 +161,12 @@ static void mt6358_irq_sp_handler(struct mt6397_chip *chip, static irqreturn_t mt6358_irq_handler(int irq, void *data) { struct mt6397_chip *chip = data; struct pmic_irq_data *mt6358_irq_data = chip->irq_data; struct pmic_irq_data *irqd = chip->irq_data; unsigned int bit, i, top_irq_status = 0; int ret; ret = regmap_read(chip->regmap, mt6358_irq_data->top_int_status_reg, irqd->top_int_status_reg, &top_irq_status); if (ret) { dev_err(chip->dev, Loading @@ -144,8 +174,8 @@ static irqreturn_t mt6358_irq_handler(int irq, void *data) return IRQ_NONE; } for (i = 0; i < mt6358_irq_data->num_top; i++) { bit = BIT(mt6358_ints[i].top_offset); for (i = 0; i < irqd->num_top; i++) { bit = BIT(irqd->pmic_ints[i].top_offset); if (top_irq_status & bit) { mt6358_irq_sp_handler(chip, i); top_irq_status &= ~bit; Loading Loading @@ -180,17 +210,22 @@ int mt6358_irq_init(struct mt6397_chip *chip) int i, j, ret; struct pmic_irq_data *irqd; irqd = devm_kzalloc(chip->dev, sizeof(*irqd), GFP_KERNEL); if (!irqd) return -ENOMEM; switch (chip->chip_id) { case MT6358_CHIP_ID: chip->irq_data = &mt6358_irqd; break; case MT6359_CHIP_ID: chip->irq_data = &mt6359_irqd; break; chip->irq_data = irqd; default: dev_err(chip->dev, "unsupported chip: 0x%x\n", chip->chip_id); return -ENODEV; } mutex_init(&chip->irqlock); irqd->top_int_status_reg = MT6358_TOP_INT_STATUS0; irqd->num_pmic_irqs = MT6358_IRQ_NR; irqd->num_top = ARRAY_SIZE(mt6358_ints); irqd = chip->irq_data; irqd->enable_hwirq = devm_kcalloc(chip->dev, irqd->num_pmic_irqs, sizeof(*irqd->enable_hwirq), Loading @@ -207,10 +242,10 @@ int mt6358_irq_init(struct mt6397_chip *chip) /* Disable all interrupts for initializing */ for (i = 0; i < irqd->num_top; i++) { for (j = 0; j < mt6358_ints[i].num_int_regs; j++) for (j = 0; j < irqd->pmic_ints[i].num_int_regs; j++) regmap_write(chip->regmap, mt6358_ints[i].en_reg + mt6358_ints[i].en_reg_shift * j, 0); irqd->pmic_ints[i].en_reg + irqd->pmic_ints[i].en_reg_shift * j, 0); } chip->irq_domain = irq_domain_add_linear(chip->dev->of_node, Loading drivers/mfd/mt6397-core.c +24 −0 Original line number Diff line number Diff line Loading @@ -13,9 +13,11 @@ #include <linux/mfd/core.h> #include <linux/mfd/mt6323/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/mt6358/registers.h> #include <linux/mfd/mt6359/registers.h> #include <linux/mfd/mt6397/registers.h> #define MT6323_RTC_BASE 0x8000 Loading Loading @@ -99,6 +101,17 @@ static const struct mfd_cell mt6358_devs[] = { }, }; static const struct mfd_cell mt6359_devs[] = { { .name = "mt6359-regulator", }, { .name = "mt6359-rtc", .num_resources = ARRAY_SIZE(mt6358_rtc_resources), .resources = mt6358_rtc_resources, .of_compatible = "mediatek,mt6358-rtc", }, { .name = "mt6359-sound", }, }; static const struct mfd_cell mt6397_devs[] = { { .name = "mt6397-rtc", Loading Loading @@ -149,6 +162,14 @@ static const struct chip_data mt6358_core = { .irq_init = mt6358_irq_init, }; static const struct chip_data mt6359_core = { .cid_addr = MT6359_SWCID, .cid_shift = 8, .cells = mt6359_devs, .cell_size = ARRAY_SIZE(mt6359_devs), .irq_init = mt6358_irq_init, }; static const struct chip_data mt6397_core = { .cid_addr = MT6397_CID, .cid_shift = 0, Loading Loading @@ -218,6 +239,9 @@ static const struct of_device_id mt6397_of_match[] = { }, { .compatible = "mediatek,mt6358", .data = &mt6358_core, }, { .compatible = "mediatek,mt6359", .data = &mt6359_core, }, { .compatible = "mediatek,mt6397", .data = &mt6397_core, Loading drivers/regulator/Kconfig +9 −0 Original line number Diff line number Diff line Loading @@ -769,6 +769,15 @@ config REGULATOR_MT6358 This driver supports the control of different power rails of device through regulator interface. config REGULATOR_MT6359 tristate "MediaTek MT6359 PMIC" depends on MFD_MT6397 help Say y here to select this option to enable the power regulator of MediaTek MT6359 PMIC. This driver supports the control of different power rails of device through regulator interface. config REGULATOR_MT6360 tristate "MT6360 SubPMIC Regulator" depends on MFD_MT6360 Loading Loading
Documentation/devicetree/bindings/mfd/mt6397.txt +1 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ Required properties: compatible: "mediatek,mt6323" for PMIC MT6323 "mediatek,mt6358" for PMIC MT6358 "mediatek,mt6359" for PMIC MT6359 "mediatek,mt6397" for PMIC MT6397 Optional subnodes: Loading
Documentation/devicetree/bindings/regulator/mt6359-regulator.yaml 0 → 100644 +385 −0 Original line number Diff line number Diff line # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) %YAML 1.2 --- $id: http://devicetree.org/schemas/regulator/mt6359-regulator.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# title: MT6359 Regulator from MediaTek Integrated maintainers: - Hsin-Hsiung Wang <hsin-hsiung.wang@mediatek.com> description: | List of regulators provided by this controller. It is named according to its regulator type, buck_<name> and ldo_<name>. MT6359 regulators node should be sub node of the MT6397 MFD node. patternProperties: "^buck_v(s1|gpu11|modem|pu|core|s2|pa|proc2|proc1|core_sshub)$": type: object $ref: "regulator.yaml#" properties: regulator-name: pattern: "^v(s1|gpu11|modem|pu|core|s2|pa|proc2|proc1|core_sshub)$" unevaluatedProperties: false "^ldo_v(ibr|rf12|usb|camio|efuse|xo22)$": type: object $ref: "regulator.yaml#" properties: regulator-name: pattern: "^v(ibr|rf12|usb|camio|efuse|xo22)$" unevaluatedProperties: false "^ldo_v(rfck|emc|a12|a09|ufs|bbck)$": type: object $ref: "regulator.yaml#" properties: regulator-name: pattern: "^v(rfck|emc|a12|a09|ufs|bbck)$" unevaluatedProperties: false "^ldo_vcn(18|13|33_1_bt|13_1_wifi|33_2_bt|33_2_wifi)$": type: object $ref: "regulator.yaml#" properties: regulator-name: pattern: "^vcn(18|13|33_1_bt|13_1_wifi|33_2_bt|33_2_wifi)$" unevaluatedProperties: false "^ldo_vsram_(proc2|others|md|proc1|others_sshub)$": type: object $ref: "regulator.yaml#" properties: regulator-name: pattern: "^vsram_(proc2|others|md|proc1|others_sshub)$" unevaluatedProperties: false "^ldo_v(fe|bif|io)28$": type: object $ref: "regulator.yaml#" properties: regulator-name: pattern: "^v(fe|bif|io)28$" unevaluatedProperties: false "^ldo_v(aud|io|aux|rf|m)18$": type: object $ref: "regulator.yaml#" properties: regulator-name: pattern: "^v(aud|io|aux|rf|m)18$" unevaluatedProperties: false "^ldo_vsim[12]$": type: object $ref: "regulator.yaml#" properties: regulator-name: pattern: "^vsim[12]$" required: - regulator-name unevaluatedProperties: false additionalProperties: false examples: - | pmic { regulators { mt6359_vs1_buck_reg: buck_vs1 { regulator-name = "vs1"; regulator-min-microvolt = <800000>; regulator-max-microvolt = <2200000>; regulator-enable-ramp-delay = <0>; regulator-always-on; }; mt6359_vgpu11_buck_reg: buck_vgpu11 { regulator-name = "vgpu11"; regulator-min-microvolt = <400000>; regulator-max-microvolt = <1193750>; regulator-ramp-delay = <5000>; regulator-enable-ramp-delay = <200>; regulator-allowed-modes = <0 1 2>; }; mt6359_vmodem_buck_reg: buck_vmodem { regulator-name = "vmodem"; regulator-min-microvolt = <400000>; regulator-max-microvolt = <1100000>; regulator-ramp-delay = <10760>; regulator-enable-ramp-delay = <200>; }; mt6359_vpu_buck_reg: buck_vpu { regulator-name = "vpu"; regulator-min-microvolt = <400000>; regulator-max-microvolt = <1193750>; regulator-ramp-delay = <5000>; regulator-enable-ramp-delay = <200>; regulator-allowed-modes = <0 1 2>; }; mt6359_vcore_buck_reg: buck_vcore { regulator-name = "vcore"; regulator-min-microvolt = <400000>; regulator-max-microvolt = <1300000>; regulator-ramp-delay = <5000>; regulator-enable-ramp-delay = <200>; regulator-allowed-modes = <0 1 2>; }; mt6359_vs2_buck_reg: buck_vs2 { regulator-name = "vs2"; regulator-min-microvolt = <800000>; regulator-max-microvolt = <1600000>; regulator-enable-ramp-delay = <0>; regulator-always-on; }; mt6359_vpa_buck_reg: buck_vpa { regulator-name = "vpa"; regulator-min-microvolt = <500000>; regulator-max-microvolt = <3650000>; regulator-enable-ramp-delay = <300>; }; mt6359_vproc2_buck_reg: buck_vproc2 { regulator-name = "vproc2"; regulator-min-microvolt = <400000>; regulator-max-microvolt = <1193750>; regulator-ramp-delay = <7500>; regulator-enable-ramp-delay = <200>; regulator-allowed-modes = <0 1 2>; }; mt6359_vproc1_buck_reg: buck_vproc1 { regulator-name = "vproc1"; regulator-min-microvolt = <400000>; regulator-max-microvolt = <1193750>; regulator-ramp-delay = <7500>; regulator-enable-ramp-delay = <200>; regulator-allowed-modes = <0 1 2>; }; mt6359_vcore_sshub_buck_reg: buck_vcore_sshub { regulator-name = "vcore_sshub"; regulator-min-microvolt = <400000>; regulator-max-microvolt = <1193750>; }; mt6359_vgpu11_sshub_buck_reg: buck_vgpu11_sshub { regulator-name = "vgpu11_sshub"; regulator-min-microvolt = <400000>; regulator-max-microvolt = <1193750>; }; mt6359_vaud18_ldo_reg: ldo_vaud18 { regulator-name = "vaud18"; regulator-min-microvolt = <1800000>; regulator-max-microvolt = <1800000>; regulator-enable-ramp-delay = <240>; }; mt6359_vsim1_ldo_reg: ldo_vsim1 { regulator-name = "vsim1"; regulator-min-microvolt = <1700000>; regulator-max-microvolt = <3100000>; }; mt6359_vibr_ldo_reg: ldo_vibr { regulator-name = "vibr"; regulator-min-microvolt = <1200000>; regulator-max-microvolt = <3300000>; }; mt6359_vrf12_ldo_reg: ldo_vrf12 { regulator-name = "vrf12"; regulator-min-microvolt = <1100000>; regulator-max-microvolt = <1300000>; }; mt6359_vusb_ldo_reg: ldo_vusb { regulator-name = "vusb"; regulator-min-microvolt = <3000000>; regulator-max-microvolt = <3000000>; regulator-enable-ramp-delay = <960>; regulator-always-on; }; mt6359_vsram_proc2_ldo_reg: ldo_vsram_proc2 { regulator-name = "vsram_proc2"; regulator-min-microvolt = <500000>; regulator-max-microvolt = <1293750>; regulator-ramp-delay = <7500>; regulator-enable-ramp-delay = <240>; regulator-always-on; }; mt6359_vio18_ldo_reg: ldo_vio18 { regulator-name = "vio18"; regulator-min-microvolt = <1700000>; regulator-max-microvolt = <1900000>; regulator-enable-ramp-delay = <960>; regulator-always-on; }; mt6359_vcamio_ldo_reg: ldo_vcamio { regulator-name = "vcamio"; regulator-min-microvolt = <1700000>; regulator-max-microvolt = <1900000>; }; mt6359_vcn18_ldo_reg: ldo_vcn18 { regulator-name = "vcn18"; regulator-min-microvolt = <1800000>; regulator-max-microvolt = <1800000>; regulator-enable-ramp-delay = <240>; }; mt6359_vfe28_ldo_reg: ldo_vfe28 { regulator-name = "vfe28"; regulator-min-microvolt = <2800000>; regulator-max-microvolt = <2800000>; regulator-enable-ramp-delay = <120>; }; mt6359_vcn13_ldo_reg: ldo_vcn13 { regulator-name = "vcn13"; regulator-min-microvolt = <900000>; regulator-max-microvolt = <1300000>; }; mt6359_vcn33_1_bt_ldo_reg: ldo_vcn33_1_bt { regulator-name = "vcn33_1_bt"; regulator-min-microvolt = <2800000>; regulator-max-microvolt = <3500000>; }; mt6359_vcn33_1_wifi_ldo_reg: ldo_vcn33_1_wifi { regulator-name = "vcn33_1_wifi"; regulator-min-microvolt = <2800000>; regulator-max-microvolt = <3500000>; }; mt6359_vaux18_ldo_reg: ldo_vaux18 { regulator-name = "vaux18"; regulator-min-microvolt = <1800000>; regulator-max-microvolt = <1800000>; regulator-enable-ramp-delay = <240>; regulator-always-on; }; mt6359_vsram_others_ldo_reg: ldo_vsram_others { regulator-name = "vsram_others"; regulator-min-microvolt = <500000>; regulator-max-microvolt = <1293750>; regulator-ramp-delay = <5000>; regulator-enable-ramp-delay = <240>; }; mt6359_vefuse_ldo_reg: ldo_vefuse { regulator-name = "vefuse"; regulator-min-microvolt = <1700000>; regulator-max-microvolt = <2000000>; }; mt6359_vxo22_ldo_reg: ldo_vxo22 { regulator-name = "vxo22"; regulator-min-microvolt = <1800000>; regulator-max-microvolt = <2200000>; regulator-always-on; }; mt6359_vrfck_ldo_reg: ldo_vrfck { regulator-name = "vrfck"; regulator-min-microvolt = <1500000>; regulator-max-microvolt = <1700000>; }; mt6359_vrfck_1_ldo_reg: ldo_vrfck_1 { regulator-name = "vrfck"; regulator-min-microvolt = <1240000>; regulator-max-microvolt = <1600000>; }; mt6359_vbif28_ldo_reg: ldo_vbif28 { regulator-name = "vbif28"; regulator-min-microvolt = <2800000>; regulator-max-microvolt = <2800000>; regulator-enable-ramp-delay = <240>; }; mt6359_vio28_ldo_reg: ldo_vio28 { regulator-name = "vio28"; regulator-min-microvolt = <2800000>; regulator-max-microvolt = <3300000>; regulator-always-on; }; mt6359_vemc_ldo_reg: ldo_vemc { regulator-name = "vemc"; regulator-min-microvolt = <2900000>; regulator-max-microvolt = <3300000>; }; mt6359_vemc_1_ldo_reg: ldo_vemc_1 { regulator-name = "vemc"; regulator-min-microvolt = <2500000>; regulator-max-microvolt = <3300000>; }; mt6359_vcn33_2_bt_ldo_reg: ldo_vcn33_2_bt { regulator-name = "vcn33_2_bt"; regulator-min-microvolt = <2800000>; regulator-max-microvolt = <3500000>; }; mt6359_vcn33_2_wifi_ldo_reg: ldo_vcn33_2_wifi { regulator-name = "vcn33_2_wifi"; regulator-min-microvolt = <2800000>; regulator-max-microvolt = <3500000>; }; mt6359_va12_ldo_reg: ldo_va12 { regulator-name = "va12"; regulator-min-microvolt = <1200000>; regulator-max-microvolt = <1300000>; regulator-always-on; }; mt6359_va09_ldo_reg: ldo_va09 { regulator-name = "va09"; regulator-min-microvolt = <800000>; regulator-max-microvolt = <1200000>; }; mt6359_vrf18_ldo_reg: ldo_vrf18 { regulator-name = "vrf18"; regulator-min-microvolt = <1700000>; regulator-max-microvolt = <1810000>; }; mt6359_vsram_md_ldo_reg: ldo_vsram_md { regulator-name = "vsram_md"; regulator-min-microvolt = <500000>; regulator-max-microvolt = <1293750>; regulator-ramp-delay = <10760>; regulator-enable-ramp-delay = <240>; }; mt6359_vufs_ldo_reg: ldo_vufs { regulator-name = "vufs"; regulator-min-microvolt = <1700000>; regulator-max-microvolt = <1900000>; }; mt6359_vm18_ldo_reg: ldo_vm18 { regulator-name = "vm18"; regulator-min-microvolt = <1700000>; regulator-max-microvolt = <1900000>; regulator-always-on; }; mt6359_vbbck_ldo_reg: ldo_vbbck { regulator-name = "vbbck"; regulator-min-microvolt = <1100000>; regulator-max-microvolt = <1200000>; }; mt6359_vsram_proc1_ldo_reg: ldo_vsram_proc1 { regulator-name = "vsram_proc1"; regulator-min-microvolt = <500000>; regulator-max-microvolt = <1293750>; regulator-ramp-delay = <7500>; regulator-enable-ramp-delay = <240>; regulator-always-on; }; mt6359_vsim2_ldo_reg: ldo_vsim2 { regulator-name = "vsim2"; regulator-min-microvolt = <1700000>; regulator-max-microvolt = <3100000>; }; mt6359_vsram_others_sshub_ldo: ldo_vsram_others_sshub { regulator-name = "vsram_others_sshub"; regulator-min-microvolt = <500000>; regulator-max-microvolt = <1293750>; }; }; }; ...
drivers/mfd/mt6358-irq.c +62 −27 Original line number Diff line number Diff line Loading @@ -5,6 +5,8 @@ #include <linux/interrupt.h> #include <linux/mfd/mt6358/core.h> #include <linux/mfd/mt6358/registers.h> #include <linux/mfd/mt6359/core.h> #include <linux/mfd/mt6359/registers.h> #include <linux/mfd/mt6397/core.h> #include <linux/module.h> #include <linux/of.h> Loading @@ -13,7 +15,9 @@ #include <linux/platform_device.h> #include <linux/regmap.h> static struct irq_top_t mt6358_ints[] = { #define MTK_PMIC_REG_WIDTH 16 static const struct irq_top_t mt6358_ints[] = { MT6358_TOP_GEN(BUCK), MT6358_TOP_GEN(LDO), MT6358_TOP_GEN(PSC), Loading @@ -24,6 +28,31 @@ static struct irq_top_t mt6358_ints[] = { MT6358_TOP_GEN(MISC), }; static const struct irq_top_t mt6359_ints[] = { MT6359_TOP_GEN(BUCK), MT6359_TOP_GEN(LDO), MT6359_TOP_GEN(PSC), MT6359_TOP_GEN(SCK), MT6359_TOP_GEN(BM), MT6359_TOP_GEN(HK), MT6359_TOP_GEN(AUD), MT6359_TOP_GEN(MISC), }; static struct pmic_irq_data mt6358_irqd = { .num_top = ARRAY_SIZE(mt6358_ints), .num_pmic_irqs = MT6358_IRQ_NR, .top_int_status_reg = MT6358_TOP_INT_STATUS0, .pmic_ints = mt6358_ints, }; static struct pmic_irq_data mt6359_irqd = { .num_top = ARRAY_SIZE(mt6359_ints), .num_pmic_irqs = MT6359_IRQ_NR, .top_int_status_reg = MT6359_TOP_INT_STATUS0, .pmic_ints = mt6359_ints, }; static void pmic_irq_enable(struct irq_data *data) { unsigned int hwirq = irqd_to_hwirq(data); Loading Loading @@ -62,15 +91,15 @@ static void pmic_irq_sync_unlock(struct irq_data *data) /* Find out the IRQ group */ top_gp = 0; while ((top_gp + 1) < irqd->num_top && i >= mt6358_ints[top_gp + 1].hwirq_base) i >= irqd->pmic_ints[top_gp + 1].hwirq_base) top_gp++; /* Find the IRQ registers */ gp_offset = i - mt6358_ints[top_gp].hwirq_base; int_regs = gp_offset / MT6358_REG_WIDTH; shift = gp_offset % MT6358_REG_WIDTH; en_reg = mt6358_ints[top_gp].en_reg + (mt6358_ints[top_gp].en_reg_shift * int_regs); gp_offset = i - irqd->pmic_ints[top_gp].hwirq_base; int_regs = gp_offset / MTK_PMIC_REG_WIDTH; shift = gp_offset % MTK_PMIC_REG_WIDTH; en_reg = irqd->pmic_ints[top_gp].en_reg + (irqd->pmic_ints[top_gp].en_reg_shift * int_regs); regmap_update_bits(chip->regmap, en_reg, BIT(shift), irqd->enable_hwirq[i] << shift); Loading @@ -95,10 +124,11 @@ static void mt6358_irq_sp_handler(struct mt6397_chip *chip, unsigned int irq_status, sta_reg, status; unsigned int hwirq, virq; int i, j, ret; struct pmic_irq_data *irqd = chip->irq_data; for (i = 0; i < mt6358_ints[top_gp].num_int_regs; i++) { sta_reg = mt6358_ints[top_gp].sta_reg + mt6358_ints[top_gp].sta_reg_shift * i; for (i = 0; i < irqd->pmic_ints[top_gp].num_int_regs; i++) { sta_reg = irqd->pmic_ints[top_gp].sta_reg + irqd->pmic_ints[top_gp].sta_reg_shift * i; ret = regmap_read(chip->regmap, sta_reg, &irq_status); if (ret) { Loading @@ -114,8 +144,8 @@ static void mt6358_irq_sp_handler(struct mt6397_chip *chip, do { j = __ffs(status); hwirq = mt6358_ints[top_gp].hwirq_base + MT6358_REG_WIDTH * i + j; hwirq = irqd->pmic_ints[top_gp].hwirq_base + MTK_PMIC_REG_WIDTH * i + j; virq = irq_find_mapping(chip->irq_domain, hwirq); if (virq) Loading @@ -131,12 +161,12 @@ static void mt6358_irq_sp_handler(struct mt6397_chip *chip, static irqreturn_t mt6358_irq_handler(int irq, void *data) { struct mt6397_chip *chip = data; struct pmic_irq_data *mt6358_irq_data = chip->irq_data; struct pmic_irq_data *irqd = chip->irq_data; unsigned int bit, i, top_irq_status = 0; int ret; ret = regmap_read(chip->regmap, mt6358_irq_data->top_int_status_reg, irqd->top_int_status_reg, &top_irq_status); if (ret) { dev_err(chip->dev, Loading @@ -144,8 +174,8 @@ static irqreturn_t mt6358_irq_handler(int irq, void *data) return IRQ_NONE; } for (i = 0; i < mt6358_irq_data->num_top; i++) { bit = BIT(mt6358_ints[i].top_offset); for (i = 0; i < irqd->num_top; i++) { bit = BIT(irqd->pmic_ints[i].top_offset); if (top_irq_status & bit) { mt6358_irq_sp_handler(chip, i); top_irq_status &= ~bit; Loading Loading @@ -180,17 +210,22 @@ int mt6358_irq_init(struct mt6397_chip *chip) int i, j, ret; struct pmic_irq_data *irqd; irqd = devm_kzalloc(chip->dev, sizeof(*irqd), GFP_KERNEL); if (!irqd) return -ENOMEM; switch (chip->chip_id) { case MT6358_CHIP_ID: chip->irq_data = &mt6358_irqd; break; case MT6359_CHIP_ID: chip->irq_data = &mt6359_irqd; break; chip->irq_data = irqd; default: dev_err(chip->dev, "unsupported chip: 0x%x\n", chip->chip_id); return -ENODEV; } mutex_init(&chip->irqlock); irqd->top_int_status_reg = MT6358_TOP_INT_STATUS0; irqd->num_pmic_irqs = MT6358_IRQ_NR; irqd->num_top = ARRAY_SIZE(mt6358_ints); irqd = chip->irq_data; irqd->enable_hwirq = devm_kcalloc(chip->dev, irqd->num_pmic_irqs, sizeof(*irqd->enable_hwirq), Loading @@ -207,10 +242,10 @@ int mt6358_irq_init(struct mt6397_chip *chip) /* Disable all interrupts for initializing */ for (i = 0; i < irqd->num_top; i++) { for (j = 0; j < mt6358_ints[i].num_int_regs; j++) for (j = 0; j < irqd->pmic_ints[i].num_int_regs; j++) regmap_write(chip->regmap, mt6358_ints[i].en_reg + mt6358_ints[i].en_reg_shift * j, 0); irqd->pmic_ints[i].en_reg + irqd->pmic_ints[i].en_reg_shift * j, 0); } chip->irq_domain = irq_domain_add_linear(chip->dev->of_node, Loading
drivers/mfd/mt6397-core.c +24 −0 Original line number Diff line number Diff line Loading @@ -13,9 +13,11 @@ #include <linux/mfd/core.h> #include <linux/mfd/mt6323/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/mt6358/registers.h> #include <linux/mfd/mt6359/registers.h> #include <linux/mfd/mt6397/registers.h> #define MT6323_RTC_BASE 0x8000 Loading Loading @@ -99,6 +101,17 @@ static const struct mfd_cell mt6358_devs[] = { }, }; static const struct mfd_cell mt6359_devs[] = { { .name = "mt6359-regulator", }, { .name = "mt6359-rtc", .num_resources = ARRAY_SIZE(mt6358_rtc_resources), .resources = mt6358_rtc_resources, .of_compatible = "mediatek,mt6358-rtc", }, { .name = "mt6359-sound", }, }; static const struct mfd_cell mt6397_devs[] = { { .name = "mt6397-rtc", Loading Loading @@ -149,6 +162,14 @@ static const struct chip_data mt6358_core = { .irq_init = mt6358_irq_init, }; static const struct chip_data mt6359_core = { .cid_addr = MT6359_SWCID, .cid_shift = 8, .cells = mt6359_devs, .cell_size = ARRAY_SIZE(mt6359_devs), .irq_init = mt6358_irq_init, }; static const struct chip_data mt6397_core = { .cid_addr = MT6397_CID, .cid_shift = 0, Loading Loading @@ -218,6 +239,9 @@ static const struct of_device_id mt6397_of_match[] = { }, { .compatible = "mediatek,mt6358", .data = &mt6358_core, }, { .compatible = "mediatek,mt6359", .data = &mt6359_core, }, { .compatible = "mediatek,mt6397", .data = &mt6397_core, Loading
drivers/regulator/Kconfig +9 −0 Original line number Diff line number Diff line Loading @@ -769,6 +769,15 @@ config REGULATOR_MT6358 This driver supports the control of different power rails of device through regulator interface. config REGULATOR_MT6359 tristate "MediaTek MT6359 PMIC" depends on MFD_MT6397 help Say y here to select this option to enable the power regulator of MediaTek MT6359 PMIC. This driver supports the control of different power rails of device through regulator interface. config REGULATOR_MT6360 tristate "MT6360 SubPMIC Regulator" depends on MFD_MT6360 Loading