Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mfd: bd9571mwv: Add support for BD9574MWF

The new PMIC BD9574MWF inherits features from BD9571MWV.
Add the support of new PMIC to existing bd9571mwv driver.

Signed-off-by: Khiem Nguyen <khiem.nguyen.xt@renesas.com>
Co-developed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Khiem Nguyen and committed by
Lee Jones
b2548da6 f16e1fd1

+89 -4
+75 -1
drivers/mfd/bd9571mwv.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-only 2 2 /* 3 - * ROHM BD9571MWV-M MFD driver 3 + * ROHM BD9571MWV-M and BD9574MVF-M core driver 4 4 * 5 5 * Copyright (C) 2017 Marek Vasut <marek.vasut+renesas@gmail.com> 6 6 * Copyright (C) 2020 Renesas Electronics Corporation ··· 11 11 #include <linux/i2c.h> 12 12 #include <linux/interrupt.h> 13 13 #include <linux/mfd/core.h> 14 + #include <linux/mfd/rohm-generic.h> 14 15 #include <linux/module.h> 15 16 16 17 #include <linux/mfd/bd9571mwv.h> ··· 104 103 .num_irqs = ARRAY_SIZE(bd9571mwv_irqs), 105 104 }; 106 105 106 + static const struct mfd_cell bd9574mwf_cells[] = { 107 + { .name = "bd9574mwf-regulator", }, 108 + { .name = "bd9574mwf-gpio", }, 109 + }; 110 + 111 + static const struct regmap_range bd9574mwf_readable_yes_ranges[] = { 112 + regmap_reg_range(BD9571MWV_VENDOR_CODE, BD9571MWV_PRODUCT_REVISION), 113 + regmap_reg_range(BD9571MWV_BKUP_MODE_CNT, BD9571MWV_BKUP_MODE_CNT), 114 + regmap_reg_range(BD9571MWV_DVFS_VINIT, BD9571MWV_DVFS_SETVMAX), 115 + regmap_reg_range(BD9571MWV_DVFS_SETVID, BD9571MWV_DVFS_MONIVDAC), 116 + regmap_reg_range(BD9571MWV_GPIO_IN, BD9571MWV_GPIO_IN), 117 + regmap_reg_range(BD9571MWV_GPIO_INT, BD9571MWV_GPIO_INTMASK), 118 + regmap_reg_range(BD9571MWV_INT_INTREQ, BD9571MWV_INT_INTMASK), 119 + }; 120 + 121 + static const struct regmap_access_table bd9574mwf_readable_table = { 122 + .yes_ranges = bd9574mwf_readable_yes_ranges, 123 + .n_yes_ranges = ARRAY_SIZE(bd9574mwf_readable_yes_ranges), 124 + }; 125 + 126 + static const struct regmap_range bd9574mwf_writable_yes_ranges[] = { 127 + regmap_reg_range(BD9571MWV_BKUP_MODE_CNT, BD9571MWV_BKUP_MODE_CNT), 128 + regmap_reg_range(BD9571MWV_DVFS_SETVID, BD9571MWV_DVFS_SETVID), 129 + regmap_reg_range(BD9571MWV_GPIO_DIR, BD9571MWV_GPIO_OUT), 130 + regmap_reg_range(BD9571MWV_GPIO_INT_SET, BD9571MWV_GPIO_INTMASK), 131 + regmap_reg_range(BD9571MWV_INT_INTREQ, BD9571MWV_INT_INTMASK), 132 + }; 133 + 134 + static const struct regmap_access_table bd9574mwf_writable_table = { 135 + .yes_ranges = bd9574mwf_writable_yes_ranges, 136 + .n_yes_ranges = ARRAY_SIZE(bd9574mwf_writable_yes_ranges), 137 + }; 138 + 139 + static const struct regmap_range bd9574mwf_volatile_yes_ranges[] = { 140 + regmap_reg_range(BD9571MWV_DVFS_MONIVDAC, BD9571MWV_DVFS_MONIVDAC), 141 + regmap_reg_range(BD9571MWV_GPIO_IN, BD9571MWV_GPIO_IN), 142 + regmap_reg_range(BD9571MWV_GPIO_INT, BD9571MWV_GPIO_INT), 143 + regmap_reg_range(BD9571MWV_INT_INTREQ, BD9571MWV_INT_INTREQ), 144 + }; 145 + 146 + static const struct regmap_access_table bd9574mwf_volatile_table = { 147 + .yes_ranges = bd9574mwf_volatile_yes_ranges, 148 + .n_yes_ranges = ARRAY_SIZE(bd9574mwf_volatile_yes_ranges), 149 + }; 150 + 151 + static const struct regmap_config bd9574mwf_regmap_config = { 152 + .reg_bits = 8, 153 + .val_bits = 8, 154 + .cache_type = REGCACHE_RBTREE, 155 + .rd_table = &bd9574mwf_readable_table, 156 + .wr_table = &bd9574mwf_writable_table, 157 + .volatile_table = &bd9574mwf_volatile_table, 158 + .max_register = 0xff, 159 + }; 160 + 161 + static struct regmap_irq_chip bd9574mwf_irq_chip = { 162 + .name = "bd9574mwf", 163 + .status_base = BD9571MWV_INT_INTREQ, 164 + .mask_base = BD9571MWV_INT_INTMASK, 165 + .ack_base = BD9571MWV_INT_INTREQ, 166 + .init_ack_masked = true, 167 + .num_regs = 1, 168 + .irqs = bd9571mwv_irqs, 169 + .num_irqs = ARRAY_SIZE(bd9571mwv_irqs), 170 + }; 171 + 107 172 static int bd957x_identify(struct device *dev, struct regmap *regmap) 108 173 { 109 174 unsigned int value; ··· 229 162 cells = bd9571mwv_cells; 230 163 num_cells = ARRAY_SIZE(bd9571mwv_cells); 231 164 break; 165 + case BD9571MWV_PRODUCT_CODE_BD9574MWF: 166 + regmap_config = &bd9574mwf_regmap_config; 167 + irq_chip = &bd9574mwf_irq_chip; 168 + cells = bd9574mwf_cells; 169 + num_cells = ARRAY_SIZE(bd9574mwf_cells); 170 + break; 232 171 default: 233 172 dev_err(dev, "Unsupported device 0x%x\n", ret); 234 173 return -ENODEV; ··· 263 190 264 191 static const struct of_device_id bd9571mwv_of_match_table[] = { 265 192 { .compatible = "rohm,bd9571mwv", }, 193 + { .compatible = "rohm,bd9574mwf", }, 266 194 { /* sentinel */ } 267 195 }; 268 196 MODULE_DEVICE_TABLE(of, bd9571mwv_of_match_table);
+14 -3
include/linux/mfd/bd9571mwv.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 2 /* 3 - * ROHM BD9571MWV-M driver 3 + * ROHM BD9571MWV-M and BD9574MWF-M driver 4 4 * 5 5 * Copyright (C) 2017 Marek Vasut <marek.vasut+renesas@gmail.com> 6 6 * Copyright (C) 2020 Renesas Electronics Corporation ··· 14 14 #include <linux/device.h> 15 15 #include <linux/regmap.h> 16 16 17 - /* List of registers for BD9571MWV */ 17 + /* List of registers for BD9571MWV and BD9574MWF */ 18 18 #define BD9571MWV_VENDOR_CODE 0x00 19 19 #define BD9571MWV_VENDOR_CODE_VAL 0xdb 20 20 #define BD9571MWV_PRODUCT_CODE 0x01 21 21 #define BD9571MWV_PRODUCT_CODE_BD9571MWV 0x60 22 + #define BD9571MWV_PRODUCT_CODE_BD9574MWF 0x74 22 23 #define BD9571MWV_PRODUCT_REVISION 0x02 23 24 24 25 #define BD9571MWV_I2C_FUSA_MODE 0x10 ··· 49 48 #define BD9571MWV_VD33_VID 0x44 50 49 51 50 #define BD9571MWV_DVFS_VINIT 0x50 51 + #define BD9574MWF_VD09_VINIT 0x51 52 52 #define BD9571MWV_DVFS_SETVMAX 0x52 53 53 #define BD9571MWV_DVFS_BOOSTVID 0x53 54 54 #define BD9571MWV_DVFS_SETVID 0x54 ··· 63 61 #define BD9571MWV_GPIO_INT_SET 0x64 64 62 #define BD9571MWV_GPIO_INT 0x65 65 63 #define BD9571MWV_GPIO_INTMASK 0x66 64 + #define BD9574MWF_GPIO_MUX 0x67 66 65 67 66 #define BD9571MWV_REG_KEEP(n) (0x70 + (n)) 68 67 ··· 73 70 #define BD9571MWV_PROT_ERROR_STATUS2 0x83 74 71 #define BD9571MWV_PROT_ERROR_STATUS3 0x84 75 72 #define BD9571MWV_PROT_ERROR_STATUS4 0x85 73 + #define BD9574MWF_PROT_ERROR_STATUS5 0x86 74 + #define BD9574MWF_SYSTEM_ERROR_STATUS 0x87 76 75 77 76 #define BD9571MWV_INT_INTREQ 0x90 78 77 #define BD9571MWV_INT_INTREQ_MD1_INT BIT(0) ··· 87 82 #define BD9571MWV_INT_INTREQ_BKUP_TRG_INT BIT(7) 88 83 #define BD9571MWV_INT_INTMASK 0x91 89 84 85 + #define BD9574MWF_SSCG_CNT 0xA0 86 + #define BD9574MWF_POFFB_MRB 0xA1 87 + #define BD9574MWF_SMRB_WR_PROT 0xA2 88 + #define BD9574MWF_SMRB_ASSERT 0xA3 89 + #define BD9574MWF_SMRB_STATUS 0xA4 90 + 90 91 #define BD9571MWV_ACCESS_KEY 0xff 91 92 92 93 /* Define the BD9571MWV IRQ numbers */ ··· 102 91 BD9571MWV_IRQ_MD2_E2, 103 92 BD9571MWV_IRQ_PROT_ERR, 104 93 BD9571MWV_IRQ_GP, 105 - BD9571MWV_IRQ_128H_OF, 94 + BD9571MWV_IRQ_128H_OF, /* BKUP_HOLD on BD9574MWF */ 106 95 BD9571MWV_IRQ_WDT_OF, 107 96 BD9571MWV_IRQ_BKUP_TRG, 108 97 };