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

mfd: axp20x: Add support for dts property "xpowers,master-mode"

commit b101829a029a ("mfd: axp20x: Fix AXP806 access errors on cold boot")
was intended to fix the case where a board uses an AXP806 in slave mode,
but the boot loader leaves it in master mode for lack of AXP806 support.
But now the driver breaks on boards where the PMIC is operating in master
mode. This patch lets the driver use the new device tree property
"xpowers,master-mode" to set the correct operating mode for the board.

Fixes: 8824ee857348 ("mfd: axp20x: Add support for AXP806 PMIC")
Signed-off-by: Rask Ingemann Lambertsen <rask@formelder.dk>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Rask Ingemann Lambertsen and committed by
Lee Jones
c0369698 8461cf20

+13 -8
+13 -8
drivers/mfd/axp20x.c
··· 31 31 32 32 #define AXP20X_OFF 0x80 33 33 34 + #define AXP806_REG_ADDR_EXT_ADDR_MASTER_MODE 0 34 35 #define AXP806_REG_ADDR_EXT_ADDR_SLAVE_MODE BIT(4) 35 36 36 37 static const char * const axp20x_model_names[] = { ··· 878 877 * the these device addressing bits (in the upper 4 bits of the 879 878 * registers) match. 880 879 * 881 - * Since we only support an AXP806 chained to an AXP809 in slave 882 - * mode, and there isn't any existing hardware which uses AXP806 883 - * in master mode, or has 2 AXP806s in the same system, we can 884 - * just program the register address extension to the slave mode 885 - * address. 880 + * By default we support an AXP806 chained to an AXP809 in slave 881 + * mode. Boards which use an AXP806 in master mode can set the 882 + * property "x-powers,master-mode" to override the default. 886 883 */ 887 - if (axp20x->variant == AXP806_ID) 888 - regmap_write(axp20x->regmap, AXP806_REG_ADDR_EXT, 889 - AXP806_REG_ADDR_EXT_ADDR_SLAVE_MODE); 884 + if (axp20x->variant == AXP806_ID) { 885 + if (of_property_read_bool(axp20x->dev->of_node, 886 + "x-powers,master-mode")) 887 + regmap_write(axp20x->regmap, AXP806_REG_ADDR_EXT, 888 + AXP806_REG_ADDR_EXT_ADDR_MASTER_MODE); 889 + else 890 + regmap_write(axp20x->regmap, AXP806_REG_ADDR_EXT, 891 + AXP806_REG_ADDR_EXT_ADDR_SLAVE_MODE); 892 + } 890 893 891 894 ret = regmap_add_irq_chip(axp20x->regmap, axp20x->irq, 892 895 IRQF_ONESHOT | IRQF_SHARED | axp20x->irq_flags,