Add support for Maxim 77663 MFD
Subsystems (4)
cover Add support for Maxim 77663 MFD
Hello,
This series adds support for the Maxim 77663 chip that provides PMIC, RTC, GPIO and watchdog timer functionality. The hardware is very similar to the Maxim 77620/20024 hardware units that are already supported by the kernel, hence we will reuse the existing drivers for 77663. The GPIO, regulator, RTC and watchdog timer functionality was tested on a Nexus 7 tablet that has the Max77663 chip, everything is working perfectly fine. I'm looking at upstreaming support for that tablet device and Max77663 is one of the core components that are currently missing in the upstream kernel.
Dmitry Osipenko (5):
mfd: max77620: Fix swapped FPS_PERIOD_MAX_US values
mfd: max77620: Support Maxim 77663
regulator: max77620: Support Maxim 77663
dt-bindings: mfd: max77620: Add compatible for Maxim 77663
mfd: max77620: Support device-tree properly
.../devicetree/bindings/mfd/max77620.txt | 4 +- drivers/mfd/max77620.c | 99 +++++++++++++++++-- drivers/regulator/max77620-regulator.c | 26 ++++- include/linux/mfd/max77620.h | 5 +- 4 files changed, 123 insertions(+), 11 deletions(-)
Signature · 1 line
2.21.0
PATCH 1/5 mfd: max77620: Fix swapped FPS_PERIOD_MAX_US values
The FPS_PERIOD_MAX_US definitions are swapped for MAX20024 and MAX77620, fix it.
--- include/linux/mfd/max77620.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/mfd/max77620.h +2 -2
@@ -136,8 +136,8 @@#define MAX77620_FPS_PERIOD_MIN_US 40#define MAX20024_FPS_PERIOD_MIN_US 20 -#define MAX77620_FPS_PERIOD_MAX_US 2560 -#define MAX20024_FPS_PERIOD_MAX_US 5120 +#define MAX20024_FPS_PERIOD_MAX_US 2560 +#define MAX77620_FPS_PERIOD_MAX_US 5120#define MAX77620_REG_FPS_GPIO1 0x54#define MAX77620_REG_FPS_GPIO2 0x55
Signature · 1 line
2.21.0
Re: [PATCH v1 1/5] mfd: max77620: Fix swapped FPS_PERIOD_MAX_US values
Hi,
[This is an automated email]
This commit has been processed because it contains a -stable tag. The stable tag indicates that it's relevant for the following trees: all
The bot has tested the following trees: v5.0.9, v4.19.36, v4.14.113, v4.9.170, v4.4.178, v3.18.138,
v5.0.9: Build OK!
v4.19.36: Build OK!
v4.14.113: Build OK!
v4.9.170: Build OK!
v4.4.178: Failed to apply! Possible dependencies:
327156c59360 ("mfd: max77620: Add core driver for MAX77620/MAX20024")v3.18.138: Failed to apply! Possible dependencies:
327156c59360 ("mfd: max77620: Add core driver for MAX77620/MAX20024")How should we proceed with this patch?
--
Thanks,
Sasha
PATCH 2/5 mfd: max77620: Support Maxim 77663
In reply to Dmitry OsipenkoAdd support for Maxim 77663 using the Max77620 driver. The hardware is very similar to Max77663/20024, although there are couple minor differences.
--- drivers/mfd/max77620.c | 68 +++++++++++++++++++++++++++++++++++- include/linux/mfd/max77620.h | 1 + 2 files changed, 68 insertions(+), 1 deletion(-)
drivers/mfd/max77620.c +67 -1
@@ -111,6 +111,25 @@ static const struct mfd_cell max20024_children[] = { }, }; +static const struct mfd_cell max77663_children[] = { + { .name ="max77620-clock" , }, + { .name ="max77663-pmic" , }, + { .name ="max77620-watchdog" , }, + { + .name ="max77620-gpio" , + .resources = gpio_resources, + .num_resources =ARRAY_SIZE (gpio_resources), + }, { + .name ="max77620-rtc" , + .resources = rtc_resources, + .num_resources =ARRAY_SIZE (rtc_resources), + }, { + .name ="max77663-power" , + .resources = power_resources, + .num_resources =ARRAY_SIZE (power_resources), + }, +}; +static const struct regmap_range max77620_readable_ranges[] = {regmap_reg_range (MAX77620_REG_CNFGGLBL1 ,MAX77620_REG_DVSSD4 ), };
@@ -171,6 +190,35 @@ static const struct regmap_config max20024_regmap_config = { .volatile_table = &max77620_volatile_table, }; +static const struct regmap_range max77663_readable_ranges[] = { +regmap_reg_range (MAX77620_REG_CNFGGLBL1 ,MAX77620_REG_CID5 ), +}; + +static const struct regmap_access_table max77663_readable_table = { + .yes_ranges = max77663_readable_ranges, + .n_yes_ranges =ARRAY_SIZE (max77663_readable_ranges), +}; + +static const struct regmap_range max77663_writable_ranges[] = { +regmap_reg_range (MAX77620_REG_CNFGGLBL1 ,MAX77620_REG_CID5 ), +}; + +static const struct regmap_access_table max77663_writable_table = { + .yes_ranges = max77663_writable_ranges, + .n_yes_ranges =ARRAY_SIZE (max77663_writable_ranges), +}; + +static const struct regmap_config max77663_regmap_config = { + .name ="power-slave" , + .reg_bits =8 , + .val_bits =8 , + .max_register =MAX77620_REG_CID5 +1 , + .cache_type =REGCACHE_RBTREE , + .rd_table = &max77663_readable_table, + .wr_table = &max77663_writable_table, + .volatile_table = &max77620_volatile_table, +}; +/* * MAX77620 and MAX20024 has the following steps of the interrupt handling * for TOP interrupts:
@@ -237,6 +285,9 @@ static int max77620_get_fps_period_reg_value(struct max77620_chip *chip,case MAX20024 : fps_min_period =MAX20024_FPS_PERIOD_MIN_US ;break ; +case MAX77663 : + fps_min_period =MAX20024_FPS_PERIOD_MIN_US ; +break ;case MAX77620 : fps_min_period =MAX77620_FPS_PERIOD_MIN_US ;break ;
@@ -274,6 +325,9 @@ static int max77620_config_fps(struct max77620_chip *chip,case MAX77620 : fps_max_period =MAX77620_FPS_PERIOD_MAX_US ;break ; +case MAX77663 : + fps_max_period =MAX20024_FPS_PERIOD_MAX_US ; +break ;default :return -EINVAL ; }
@@ -375,6 +429,9 @@ static int max77620_initialise_fps(struct max77620_chip *chip) } skip_fps: +if (chip->chip_id ==MAX77663 ) +return 0 ; +/* Enable wake on EN0 pin */ ret = regmap_update_bits(chip->rmap, MAX77620_REG_ONOFFCNFG2, MAX77620_ONOFFCNFG2_WK_EN0,
@@ -453,6 +510,11 @@ static int max77620_probe(struct i2c_client *client, n_mfd_cells =ARRAY_SIZE (max20024_children); rmap_config = &max20024_regmap_config;break ; +case MAX77663 : + mfd_cells = max77663_children; + n_mfd_cells =ARRAY_SIZE (max77663_children); + rmap_config = &max77663_regmap_config; +break ;default :dev_err (chip->dev,"ChipID is invalid %d\n" , chip->chip_id);return -EINVAL ;
@@ -546,6 +608,9 @@ static int max77620_i2c_suspend(struct device *dev)return ret; } +if (chip->chip_id ==MAX77663 ) + goto out; +/* Disable WK_EN0 */ ret =regmap_update_bits (chip->rmap,MAX77620_REG_ONOFFCNFG2 ,MAX77620_ONOFFCNFG2_WK_EN0 ,0 );
@@ -581,7 +646,7 @@ static int max77620_i2c_resume(struct device *dev)* For MAX20024: No need to configure WKEN0 on resume as * it is configured on Init. */ -if (chip->chip_id ==MAX20024 ) +if (chip->chip_id ==MAX20024 || chip->chip_id ==MAX77663 ) goto out;/* Enable WK_EN0 */
@@ -603,6 +668,7 @@ static int max77620_i2c_resume(struct device *dev)static const struct i2c_device_id max77620_id[] = { {"max77620" ,MAX77620 }, {"max20024" ,MAX20024 }, + {"max77663" ,MAX77663 }, {}, };
include/linux/mfd/max77620.h +1 -0
@@ -324,6 +324,7 @@ enum max77620_fps_src {enum max77620_chip_id {MAX77620 ,MAX20024 , +MAX77663 , };struct max77620_chip {
Signature · 1 line
2.21.0
PATCH 3/5 regulator: max77620: Support Maxim 77663
In reply to Dmitry OsipenkoAdd support for Maxim 77663.
--- drivers/regulator/max77620-regulator.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-)
drivers/regulator/max77620-regulator.c +25 -1
@@ -761,6 +761,24 @@ static struct max77620_regulator_info max20024_regs_info[MAX77620_NUM_REGS] = { RAIL_LDO(LDO8, ldo8, "in-ldo7-8", N, 800000, 3950000, 50000), }; +static struct max77620_regulator_info max77663_regs_info[MAX77620_NUM_REGS ] = { +RAIL_SD (SD0 , sd0,"in-sd0" ,SD0 ,600000 ,3387500 ,12500 ,0xFF ,NONE ), +RAIL_SD (SD1 , sd1,"in-sd1" ,SD1 ,800000 ,1587500 ,12500 ,0xFF ,NONE ), +RAIL_SD (SD2 , sd2,"in-sd2" ,SDX ,600000 ,3787500 ,12500 ,0xFF ,NONE ), +RAIL_SD (SD3 , sd3,"in-sd3" ,SDX ,600000 ,3787500 ,12500 ,0xFF ,NONE ), +RAIL_SD (SD4 , sd4,"in-sd4" ,SDX ,600000 ,3787500 ,12500 ,0xFF ,NONE ), + +RAIL_LDO (LDO0 , ldo0,"in-ldo0-1" ,N ,800000 ,2375000 ,25000 ), +RAIL_LDO (LDO1 , ldo1,"in-ldo0-1" ,N ,800000 ,2375000 ,25000 ), +RAIL_LDO (LDO2 , ldo2,"in-ldo2" ,P ,800000 ,3950000 ,50000 ), +RAIL_LDO (LDO3 , ldo3,"in-ldo3-5" ,P ,800000 ,3950000 ,50000 ), +RAIL_LDO (LDO4 , ldo4,"in-ldo4-6" ,P ,800000 ,1587500 ,12500 ), +RAIL_LDO (LDO5 , ldo5,"in-ldo3-5" ,P ,800000 ,3950000 ,50000 ), +RAIL_LDO (LDO6 , ldo6,"in-ldo4-6" ,P ,800000 ,3950000 ,50000 ), +RAIL_LDO (LDO7 , ldo7,"in-ldo7-8" ,N ,800000 ,3950000 ,50000 ), +RAIL_LDO (LDO8 , ldo8,"in-ldo7-8" ,N ,800000 ,3950000 ,50000 ), +}; +static int max77620_regulator_probe (struct platform_device *pdev) {struct max77620_chip *max77620_chip =dev_get_drvdata (pdev->dev.parent);
@@ -785,9 +803,14 @@ static int max77620_regulator_probe(struct platform_device *pdev)case MAX77620 : rinfo = max77620_regs_info;break ; -default : +case MAX20024 : rinfo = max20024_regs_info;break ; +case MAX77663 : + rinfo = max77663_regs_info; +break ; +default : +return -EINVAL ; } config.regmap = pmic->rmap;
@@ -881,6 +904,7 @@ static const struct dev_pm_ops max77620_regulator_pm_ops = {static const struct platform_device_id max77620_regulator_devtype[] = { { .name ="max77620-pmic" , }, { .name ="max20024-pmic" , }, + { .name ="max77663-pmic" , }, {}, };MODULE_DEVICE_TABLE (platform, max77620_regulator_devtype);
Signature · 1 line
2.21.0
PATCH 4/5 dt-bindings: mfd: max77620: Add compatible for Maxim 77663
In reply to Dmitry OsipenkoMaxim 77663 has a few minor differences in regards to hardware interface and available capabilities by comparing it with 77620 and 20024 models, hence re-use 77620 device-tree binding for the 77663.
--- Documentation/devicetree/bindings/mfd/max77620.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/mfd/max77620.txt +3 -1
@@ -4,7 +4,8 @@ Required properties: ------------------- - compatible: Must be one of "maxim,max77620" - "maxim,max20024". + "maxim,max20024" + "maxim,max77663". - reg: I2C device address. Optional properties:
@@ -105,6 +106,7 @@ Optional properties: Here supported time periods by device in microseconds are as follows: MAX77620 supports 40, 80, 160, 320, 640, 1280, 2560 and 5120 microseconds. MAX20024 supports 20, 40, 80, 160, 320, 640, 1280 and 2540 microseconds. +MAX77663 supports 20, 40, 80, 160, 320, 640, 1280 and 2540 microseconds. -maxim,power-ok-control: configure map power ok bit 1: Enables POK(Power OK) to control nRST_IO and GPIO1
Signature · 1 line
2.21.0
PATCH 5/5 mfd: max77620: Support device-tree properly
In reply to Dmitry OsipenkoFor some unknown reason the driver for Max77620 doesn't wire up the device-tree support properly and nothing in kernel creates I2C device for the driver (and never did), moreover device-tree files for NVIDIA Tegra210/186/194 boards already have nodes for Max77620. Hence add the missing of_match_table to make driver actually usable.
--- drivers/mfd/max77620.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-)
drivers/mfd/max77620.c +26 -7
@@ -37,6 +37,10 @@#include <linux/regmap.h> #include <linux/slab.h> +struct max77620_desc { +enum max77620_chip_id chip_id; +}; +static const struct resource gpio_resources[] = {DEFINE_RES_IRQ (MAX77620_IRQ_TOP_GPIO ), };
@@ -486,6 +490,7 @@ static int max77620_probe(struct i2c_client *client,const struct regmap_config *rmap_config;struct max77620_chip *chip;const struct mfd_cell *mfd_cells; +const struct max77620_desc *desc;int n_mfd_cells;int ret;
@@ -493,11 +498,13 @@ static int max77620_probe(struct i2c_client *client,if (!chip)return -ENOMEM ; + desc =of_device_get_match_data (&client->dev); +i2c_set_clientdata (client, chip); chip->dev = &client->dev; chip->irq_base =-1 ; chip->chip_irq = client->irq; - chip->chip_id = (enum max77620_chip_id )id->driver_data; + chip->chip_id = desc->chip_id;switch (chip->chip_id) {case MAX77620 :
@@ -665,11 +672,23 @@ static int max77620_i2c_resume(struct device *dev) }#endif -static const struct i2c_device_id max77620_id[] = { - {"max77620" ,MAX77620 }, - {"max20024" ,MAX20024 }, - {"max77663" ,MAX77663 }, - {}, +static const struct max77620_desc max77620_desc = { + .chip_id =MAX77620 , +}; + +static const struct max77620_desc max20024_desc = { + .chip_id =MAX20024 , +}; + +static const struct max77620_desc max77663_desc = { + .chip_id =MAX77663 , +}; + +static const struct of_device_id max77620_of_match[] = { + { .compatible ="maxim,max77620" , .data = &max77620_desc }, + { .compatible ="maxim,max20024" , .data = &max20024_desc }, + { .compatible ="maxim,max77663" , .data = &max77663_desc }, + { }, };static const struct dev_pm_ops max77620_pm_ops = {
@@ -680,8 +699,8 @@ static struct i2c_driver max77620_driver = { .driver = { .name = "max77620", .pm = &max77620_pm_ops, + .of_match_table = of_match_ptr(max77620_of_match), }, .probe = max77620_probe, - .id_table = max77620_id, };builtin_i2c_driver (max77620_driver);
Signature · 1 line
2.21.0