mfd: axp20x: Add support for PMIC axp202 and axp209
Subsystems (3)
cover mfd: axp20x: Add support for PMIC axp202 and axp209
This set of patches add prelinary support for PMIC X-Powers axp202 and axp209. Only two subsystem are supported at the moment: power enable key (PEK) and regulators. Drivers for these two sub-system will be submitted in later patch-sets.
Carlo Caione (3):
mfd: axp20x: Add mfd driver for axp20x PMIC
mfd: axp20x: Add dtsi for axp20x
mfd: axp20x: Add bindings documentation
Documentation/devicetree/bindings/mfd/axp20x.txt | 87 ++++++++ arch/arm/boot/dts/axp20x.dtsi | 9 + drivers/mfd/Kconfig | 12 ++ drivers/mfd/Makefile | 1 + drivers/mfd/axp20x.c | 251 +++++++++++++++++++++++ include/linux/mfd/axp20x.h | 178 ++++++++++++++++ 6 files changed, 538 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/axp20x.txt create mode 100644 arch/arm/boot/dts/axp20x.dtsi create mode 100644 drivers/mfd/axp20x.c create mode 100644 include/linux/mfd/axp20x.h
Signature · 1 line
1.8.5.3
PATCH 1/3 mfd: axp20x: Add mfd driver for axp20x PMIC
This patch introduces the preliminary support for PMICs X-Powers AXP202 and AXP209. The core contains support only for two sub-modules (PEK and regulators) that will be added with two different patch-sets.
--- drivers/mfd/Kconfig | 12 +++ drivers/mfd/Makefile | 1 + drivers/mfd/axp20x.c | 251 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/axp20x.h | 178 ++++++++++++++++++++++++++++++++ 4 files changed, 442 insertions(+) create mode 100644 drivers/mfd/axp20x.c create mode 100644 include/linux/mfd/axp20x.h
drivers/mfd/Kconfig +12 -0
@@ -59,6 +59,18 @@ config MFD_AAT2870_CORE additional drivers must be enabled in order to use the functionality of the device. +config MFD_AXP20X + bool "X-Powers AXP20X" + select MFD_CORE + select REGMAP_I2C + select REGMAP_IRQ + depends on I2C=y + help + If you say Y here you get support for the AXP20X. + This driver provides common support for accessing the device, + additional drivers must be enabled in order to use the + functionality of the device. + config MFD_CROS_EC tristate "ChromeOS Embedded Controller" select MFD_CORE
drivers/mfd/Makefile +1 -0
@@ -101,6 +101,7 @@ obj-$(CONFIG_PMIC_DA9052) += da9052-irq.o obj-$(CONFIG_PMIC_DA9052) += da9052-core.o obj-$(CONFIG_MFD_DA9052_SPI) += da9052-spi.o obj-$(CONFIG_MFD_DA9052_I2C) += da9052-i2c.o +obj-$(CONFIG_MFD_AXP20X) += axp20x.o obj-$(CONFIG_MFD_LP8788) += lp8788.o lp8788-irq.o
drivers/mfd/axp20x.c new file +251 -0
251 lines not on this page · raw message
include/linux/mfd/axp20x.h new file +178 -0
178 lines not on this page · raw message
Signature · 1 line
1.8.5.3
PATCH 1/3 mfd: axp20x: Add mfd driver for axp20x PMIC
Quoted 120 lines · Carlo Caione
This patch introduces the preliminary support for PMICs X-Powers AXP202 and AXP209. The core contains support only for two sub-modules (PEK and regulators) that will be added with two different patch-sets.
Signed-off-by Carlo Caione <[email protected]>--- drivers/mfd/Kconfig | 12 +++ drivers/mfd/Makefile | 1 + drivers/mfd/axp20x.c | 251 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/axp20x.h | 178 ++++++++++++++++++++++++++++++++ 4 files changed, 442 insertions(+) create mode 100644 drivers/mfd/axp20x.c create mode 100644 include/linux/mfd/axp20x.hdrivers/mfd/Kconfig +12
-0@@ -59,6 +59,18 @@ config MFD_AAT2870_CORE additional drivers must be enabled in order to use the functionality of the device. +config MFD_AXP20X + bool "X-Powers AXP20X" + select MFD_CORE + select REGMAP_I2C + select REGMAP_IRQ + depends on I2C=y + help + If you say Y here you get support for the AXP20X. + This driver provides common support for accessing the device, + additional drivers must be enabled in order to use the + functionality of the device. + config MFD_CROS_EC tristate "ChromeOS Embedded Controller" select MFD_COREdrivers/mfd/Makefile +1
-0@@ -101,6 +101,7 @@ obj-$(CONFIG_PMIC_DA9052) += da9052-irq.o obj-$(CONFIG_PMIC_DA9052) += da9052-core.o obj-$(CONFIG_MFD_DA9052_SPI) += da9052-spi.o obj-$(CONFIG_MFD_DA9052_I2C) += da9052-i2c.o +obj-$(CONFIG_MFD_AXP20X) += axp20x.o obj-$(CONFIG_MFD_LP8788) += lp8788.o lp8788-irq.odrivers/mfd/axp20x.c new file +64
-0@@ -0,0 +1,251 @@ +/* +* Author: Carlo Caione <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#include <linux/err.h> +#include <linux/i2c.h> +#include <linux/interrupt.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/pm_runtime.h> +#include <linux/regmap.h> +#include <linux/slab.h> +#include <linux/regulator/consumer.h> +#include <linux/mfd/axp20x.h> +#include <linux/mfd/core.h> +#include <linux/of_device.h> +#include <linux/of_irq.h> + +static const struct regmap_range axp20x_writeable_ranges[] = { + { + .range_min =AXP20X_DATA (0 ), + .range_max =AXP20X_IRQ5_STATE , + }, { + .range_min =AXP20X_DCDC_MODE , + .range_max =AXP20X_FG_RES , + }, +}; + +static const struct regmap_range axp20x_volatile_ranges[] = { + { + .range_min =AXP20X_IRQ1_EN , + .range_max =AXP20X_IRQ5_STATE , + }, +}; + +static const struct regmap_access_table axp20x_writeable_table = { + .yes_ranges = axp20x_writeable_ranges, + .n_yes_ranges =ARRAY_SIZE (axp20x_writeable_ranges), +}; + +static const struct regmap_access_table axp20x_volatile_table = { + .yes_ranges = axp20x_volatile_ranges, + .n_yes_ranges =ARRAY_SIZE (axp20x_volatile_ranges), +}; + +static struct resource axp20x_pek_resources[] = { + { + .name ="PEK_DBR" , + .start =AXP20X_IRQ_PEK_RIS_EDGE , + .end =AXP20X_IRQ_PEK_RIS_EDGE , + .flags =IORESOURCE_IRQ , + }, + { + .name ="PEK_DBF" , + .start =AXP20X_IRQ_PEK_FAL_EDGE , + .end =AXP20X_IRQ_PEK_FAL_EDGE , + .flags =IORESOURCE_IRQ , + }, + +};
Quoted 1 line
From your documentation, it seems like you want to declare them in the
DT too. Why do you need to declare the resources in both locations?
Quoted 374 lines
drivers/mfd/axp20x.c new file +187
-0+ +static const struct regmap_config axp20x_regmap_config = { + .reg_bits =8 , + .val_bits =8 , + .wr_table = &axp20x_writeable_table, + .volatile_table = &axp20x_volatile_table, + .max_register =AXP20X_FG_RES , + .cache_type =REGCACHE_RBTREE , +}; + +#define AXP20X_IRQ (_irq, _off, _mask) \ + [AXP20X_IRQ_##_irq] = { .reg_offset = (_off), .mask = BIT(_mask) } + +static const struct regmap_irq axp20x_regmap_irqs[] = { +AXP20X_IRQ (ACIN_OVER_V ,0 ,7 ), +AXP20X_IRQ (ACIN_PLUGIN ,0 ,6 ), +AXP20X_IRQ (ACIN_REMOVAL ,0 ,5 ), +AXP20X_IRQ (VBUS_OVER_V ,0 ,4 ), +AXP20X_IRQ (VBUS_PLUGIN ,0 ,3 ), +AXP20X_IRQ (VBUS_REMOVAL ,0 ,2 ), +AXP20X_IRQ (VBUS_V_LOW ,0 ,1 ), +AXP20X_IRQ (BATT_PLUGIN ,1 ,7 ), +AXP20X_IRQ (BATT_REMOVAL ,1 ,6 ), +AXP20X_IRQ (BATT_ENT_ACT_MODE ,1 ,5 ), +AXP20X_IRQ (BATT_EXIT_ACT_MODE ,1 ,4 ), +AXP20X_IRQ (CHARG ,1 ,3 ), +AXP20X_IRQ (CHARG_DONE ,1 ,2 ), +AXP20X_IRQ (BATT_TEMP_HIGH ,1 ,1 ), +AXP20X_IRQ (BATT_TEMP_LOW ,1 ,0 ), +AXP20X_IRQ (DIE_TEMP_HIGH ,2 ,7 ), +AXP20X_IRQ (CHARG_I_LOW ,2 ,6 ), +AXP20X_IRQ (DCDC1_V_LONG ,2 ,5 ), +AXP20X_IRQ (DCDC2_V_LONG ,2 ,4 ), +AXP20X_IRQ (DCDC3_V_LONG ,2 ,3 ), +AXP20X_IRQ (PEK_SHORT ,2 ,1 ), +AXP20X_IRQ (PEK_LONG ,2 ,0 ), +AXP20X_IRQ (N_OE_PWR_ON ,3 ,7 ), +AXP20X_IRQ (N_OE_PWR_OFF ,3 ,6 ), +AXP20X_IRQ (VBUS_VALID ,3 ,5 ), +AXP20X_IRQ (VBUS_NOT_VALID ,3 ,4 ), +AXP20X_IRQ (VBUS_SESS_VALID ,3 ,3 ), +AXP20X_IRQ (VBUS_SESS_END ,3 ,2 ), +AXP20X_IRQ (LOW_PWR_LVL1 ,3 ,1 ), +AXP20X_IRQ (LOW_PWR_LVL2 ,3 ,0 ), +AXP20X_IRQ (TIMER ,4 ,7 ), +AXP20X_IRQ (PEK_RIS_EDGE ,4 ,6 ), +AXP20X_IRQ (PEK_FAL_EDGE ,4 ,5 ), +AXP20X_IRQ (GPIO3_INPUT ,4 ,3 ), +AXP20X_IRQ (GPIO2_INPUT ,4 ,2 ), +AXP20X_IRQ (GPIO1_INPUT ,4 ,1 ), +AXP20X_IRQ (GPIO0_INPUT ,4 ,0 ), +}; + +static const struct regmap_irq_chip axp20x_regmap_irq_chip = { + .name ="axp20x_irq_chip" , + .status_base =AXP20X_IRQ1_STATE , + .ack_base =AXP20X_IRQ1_STATE , + .mask_base =AXP20X_IRQ1_EN , + .num_regs =5 , + .irqs = axp20x_regmap_irqs, + .num_irqs =ARRAY_SIZE (axp20x_regmap_irqs), + .mask_invert =1 , + .init_ack_masked =1 , +}; + +static struct mfd_cell axp20x_cells[] = { + { + .name ="axp20x-pek" , + .of_compatible ="x-powers,axp20x-pek" , + .num_resources =ARRAY_SIZE (axp20x_pek_resources), + .resources = axp20x_pek_resources, + }, { + .name ="axp20x-regulator" , + }, +}; + +const struct of_device_id axp20x_of_match[] = { + { .compatible ="x-powers,axp20x" , .data = (void *)AXP20X }, + { }, +}; + +static struct axp20x_dev *axp20x_pm_power_off; +static void axp20x_power_off (void ) +{ +regmap_write (axp20x_pm_power_off->regmap,AXP20X_OFF_CTRL ,0x80 ); +} + +static int axp20x_i2c_probe (struct i2c_client *i2c, +const struct i2c_device_id *id) +{ +struct axp20x_dev *axp20x; +const struct of_device_id *of_id; +int ret; + + axp20x =devm_kzalloc (&i2c->dev,sizeof (*axp20x),GFP_KERNEL ); +if (!axp20x) +return -ENOMEM ; + + of_id =of_match_device (axp20x_of_match, &i2c->dev); +if (!of_id) { +dev_err (&i2c->dev,"Unable to setup AXP20X data\n" ); +return -ENODEV ; + } + axp20x->variant = (int ) of_id->data; + + axp20x->i2c_client = i2c; +i2c_set_clientdata (i2c, axp20x); + + axp20x->dev = &i2c->dev; +dev_set_drvdata (axp20x->dev, axp20x); + + axp20x->regmap =devm_regmap_init_i2c (i2c, &axp20x_regmap_config); +if (IS_ERR (axp20x->regmap)) { + ret =PTR_ERR (axp20x->regmap); +dev_err (&i2c->dev,"regmap init failed: %d\n" , ret); +return ret; + } + + axp20x->irq = i2c->irq; + ret =regmap_add_irq_chip (axp20x->regmap, axp20x->irq, +IRQF_ONESHOT |IRQF_SHARED ,-1 , + &axp20x_regmap_irq_chip, + &axp20x->regmap_irqc); +if (ret !=0 ) { +dev_err (&i2c->dev,"failed to add irq chip: %d\n" , ret); +return ret; + } + + ret =mfd_add_devices (axp20x->dev,-1 , axp20x_cells, +ARRAY_SIZE (axp20x_cells),NULL ,0 ,NULL ); +if (ret !=0 ) { +dev_err (&i2c->dev,"failed to add MFD devices: %d\n" , ret); + goto mfd_err; + } + +if (!pm_power_off) { + axp20x_pm_power_off = axp20x; + pm_power_off = axp20x_power_off; + } + +dev_info (&i2c->dev,"AXP20X driver loaded\n" ); + +return 0 ; + +mfd_err: +regmap_del_irq_chip (axp20x->irq, axp20x->regmap_irqc); + +return ret; +} + +static int axp20x_i2c_remove (struct i2c_client *i2c) +{ +struct axp20x_dev *axp20x =i2c_get_clientdata (i2c); + +if (axp20x == axp20x_pm_power_off) { + axp20x_pm_power_off =NULL ; + pm_power_off =NULL ; + } + +mfd_remove_devices (axp20x->dev); +regmap_del_irq_chip (axp20x->i2c_client->irq, axp20x->regmap_irqc); + +return 0 ; +} + +static const struct i2c_device_id axp20x_i2c_id[] = { + {"axp20x" ,AXP20X }, + { } +}; +MODULE_DEVICE_TABLE (i2c, axp20x_i2c_id); + +static struct i2c_driver axp20x_i2c_driver = { + .driver = { + .name ="axp20x" , + .owner =THIS_MODULE , + .of_match_table =of_match_ptr (axp20x_of_match), + }, + .probe = axp20x_i2c_probe, + .remove = axp20x_i2c_remove, + .id_table = axp20x_i2c_id, +}; + +module_i2c_driver (axp20x_i2c_driver); + +MODULE_DESCRIPTION ("PMIC MFD core driver for AXP20X" ); +MODULE_AUTHOR ("Carlo Caione <[email protected]>" ); +MODULE_LICENSE ("GPL" );include/linux/mfd/axp20x.h new file +178
-0@@ -0,0 +1,178 @@ +/* +* Functions to access AXP20X power management chip. +* +* Copyright (C) 2013, Carlo Caione <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#ifndef __LINUX_MFD_AXP20X_H +#define __LINUX_MFD_AXP20X_H + +#define AXP20X 0 + +#define AXP20X_DATA (m) (0x04 + (m)) + +/* Power supply */ +#define AXP20X_PWR_INPUT_STATUS 0x00 +#define AXP20X_PWR_OP_MODE 0x01 +#define AXP20X_USB_OTG_STATUS 0x02 +#define AXP20X_PWR_OUT_CTRL 0x12 +#define AXP20X_DCDC2_V_OUT 0x23 +#define AXP20X_DCDC2_LDO3_V_SCAL 0x25 +#define AXP20X_DCDC3_V_OUT 0x27 +#define AXP20X_LDO24_V_OUT 0x28 +#define AXP20X_LDO3_V_OUT 0x29 +#define AXP20X_VBUS_IPSOUT_MGMT 0x30 +#define AXP20X_V_OFF 0x31 +#define AXP20X_OFF_CTRL 0x32 +#define AXP20X_CHRG_CTRL1 0x33 +#define AXP20X_CHRG_CTRL2 0x34 +#define AXP20X_CHRG_BAK_CTRL 0x35 +#define AXP20X_PEK_KEY 0x36 +#define AXP20X_DCDC_FREQ 0x37 +#define AXP20X_V_LTF_CHRG 0x38 +#define AXP20X_V_HTF_CHRG 0x39 +#define AXP20X_APS_WARN_L1 0x3a +#define AXP20X_APS_WARN_L2 0x3b +#define AXP20X_V_LTF_DISCHRG 0x3c +#define AXP20X_V_HTF_DISCHRG 0x3d + +/* Interrupt */ +#define AXP20X_IRQ1_EN 0x40 +#define AXP20X_IRQ2_EN 0x41 +#define AXP20X_IRQ3_EN 0x42 +#define AXP20X_IRQ4_EN 0x43 +#define AXP20X_IRQ5_EN 0x44 +#define AXP20X_IRQ1_STATE 0x48 +#define AXP20X_IRQ2_STATE 0x49 +#define AXP20X_IRQ3_STATE 0x4a +#define AXP20X_IRQ4_STATE 0x4b +#define AXP20X_IRQ5_STATE 0x4c + +/* ADC */ +#define AXP20X_ACIN_V_ADC_H 0x56 +#define AXP20X_ACIN_V_ADC_L 0x57 +#define AXP20X_ACIN_I_ADC_H 0x58 +#define AXP20X_ACIN_I_ADC_L 0x59 +#define AXP20X_VBUS_V_ADC_H 0x5a +#define AXP20X_VBUS_V_ADC_L 0x5b +#define AXP20X_VBUS_I_ADC_H 0x5c +#define AXP20X_VBUS_I_ADC_L 0x5d +#define AXP20X_TEMP_ADC_H 0x5e +#define AXP20X_TEMP_ADC_L 0x5f +#define AXP20X_TS_IN_H 0x62 +#define AXP20X_TS_IN_L 0x63 +#define AXP20X_GPIO0_V_ADC_H 0x64 +#define AXP20X_GPIO0_V_ADC_L 0x65 +#define AXP20X_GPIO1_V_ADC_H 0x66 +#define AXP20X_GPIO1_V_ADC_L 0x67 +#define AXP20X_PWR_BATT_H 0x70 +#define AXP20X_PWR_BATT_M 0x71 +#define AXP20X_PWR_BATT_L 0x72 +#define AXP20X_BATT_V_H 0x78 +#define AXP20X_BATT_V_L 0x79 +#define AXP20X_BATT_CHRG_I_H 0x7a +#define AXP20X_BATT_CHRG_I_L 0x7b +#define AXP20X_BATT_DISCHRG_I_H 0x7c +#define AXP20X_BATT_DISCHRG_I_L 0x7d +#define AXP20X_IPSOUT_V_HIGH_H 0x7e +#define AXP20X_IPSOUT_V_HIGH_L 0x7f + +/* Power supply */ +#define AXP20X_DCDC_MODE 0x80 +#define AXP20X_ADC_EN1 0x82 +#define AXP20X_ADC_EN2 0x83 +#define AXP20X_ADC_RATE 0x84 +#define AXP20X_GPIO10_IN_RANGE 0x85 +#define AXP20X_GPIO1_ADC_IRQ_RIS 0x86 +#define AXP20X_GPIO1_ADC_IRQ_FAL 0x87 +#define AXP20X_TIMER_CTRL 0x8a +#define AXP20X_VBUS_MON 0x8b +#define AXP20X_OVER_TMP 0x8f + +/* GPIO */ +#define AXP20X_GPIO0_CTRL 0x90 +#define AXP20X_LDO5_V_OUT 0x91 +#define AXP20X_GPIO1_CTRL 0x92 +#define AXP20X_GPIO2_CTRL 0x93 +#define AXP20X_GPIO20_SS 0x94 +#define AXP20X_GPIO3_CTRL 0x95 + +/* Battery */ +#define AXP20X_CHRG_CC_31_24 0xb0 +#define AXP20X_CHRG_CC_23_16 0xb1 +#define AXP20X_CHRG_CC_15_8 0xb2 +#define AXP20X_CHRG_CC_7_0 0xb3 +#define AXP20X_DISCHRG_CC_31_24 0xb4 +#define AXP20X_DISCHRG_CC_23_16 0xb5 +#define AXP20X_DISCHRG_CC_15_8 0xb6 +#define AXP20X_DISCHRG_CC_7_0 0xb7 +#define AXP20X_CC_CTRL 0xb8 +#define AXP20X_FG_RES 0xb9 + +/* Regulators IDs */ +enum { +AXP20X_LDO1 =0 , +AXP20X_LDO2 , +AXP20X_LDO3 , +AXP20X_LDO4 , +AXP20X_LDO5 , +AXP20X_DCDC2 , +AXP20X_DCDC3 , +AXP20X_REG_ID_MAX , +}; + +/* IRQs */ +enum { +AXP20X_IRQ_ACIN_OVER_V =1 , +AXP20X_IRQ_ACIN_PLUGIN , +AXP20X_IRQ_ACIN_REMOVAL , +AXP20X_IRQ_VBUS_OVER_V , +AXP20X_IRQ_VBUS_PLUGIN , +AXP20X_IRQ_VBUS_REMOVAL , +AXP20X_IRQ_VBUS_V_LOW , +AXP20X_IRQ_BATT_PLUGIN , +AXP20X_IRQ_BATT_REMOVAL , +AXP20X_IRQ_BATT_ENT_ACT_MODE , +AXP20X_IRQ_BATT_EXIT_ACT_MODE , +AXP20X_IRQ_CHARG , +AXP20X_IRQ_CHARG_DONE , +AXP20X_IRQ_BATT_TEMP_HIGH , +AXP20X_IRQ_BATT_TEMP_LOW , +AXP20X_IRQ_DIE_TEMP_HIGH , +AXP20X_IRQ_CHARG_I_LOW , +AXP20X_IRQ_DCDC1_V_LONG , +AXP20X_IRQ_DCDC2_V_LONG , +AXP20X_IRQ_DCDC3_V_LONG , +AXP20X_IRQ_PEK_SHORT =22 , +AXP20X_IRQ_PEK_LONG , +AXP20X_IRQ_N_OE_PWR_ON , +AXP20X_IRQ_N_OE_PWR_OFF , +AXP20X_IRQ_VBUS_VALID , +AXP20X_IRQ_VBUS_NOT_VALID , +AXP20X_IRQ_VBUS_SESS_VALID , +AXP20X_IRQ_VBUS_SESS_END , +AXP20X_IRQ_LOW_PWR_LVL1 , +AXP20X_IRQ_LOW_PWR_LVL2 , +AXP20X_IRQ_TIMER , +AXP20X_IRQ_PEK_RIS_EDGE , +AXP20X_IRQ_PEK_FAL_EDGE , +AXP20X_IRQ_GPIO3_INPUT , +AXP20X_IRQ_GPIO2_INPUT , +AXP20X_IRQ_GPIO1_INPUT , +AXP20X_IRQ_GPIO0_INPUT , +}; + +struct axp20x_dev { +struct device *dev; +struct i2c_client *i2c_client; +struct regmap *regmap; +struct regmap_irq_chip_data *regmap_irqc; +int variant; +int irq; +}; + +#endif /* __LINUX_MFD_AXP20X_H */ Signature · 1 line
1.8.5.3
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140210/29cdfb48/attachment-0001.sig>
[linux-sunxi] Re: [PATCH 1/3] mfd: axp20x: Add mfd driver for axp20x PMIC
Quoted 10 lines · Maxime Ripard
Quoted 10 lines
drivers/mfd/axp20x.c new file +10
-0+static struct resource axp20x_pek_resources[] = { + { + .name ="PEK_DBR" , + .start =AXP20X_IRQ_PEK_RIS_EDGE , + .end =AXP20X_IRQ_PEK_RIS_EDGE , + .flags =IORESOURCE_IRQ , + }, + { + .name ="PEK_DBF" , + .start =AXP20X_IRQ_PEK_FAL_EDGE ,
Quoted 8 lines
drivers/mfd/axp20x.c line 64
Quoted 5 lines
drivers/mfd/axp20x.c new file +5
-0+ .end = AXP20X_IRQ_PEK_FAL_EDGE, + .flags = IORESOURCE_IRQ, + }, + +};From your documentation, it seems like you want to declare them in the DT too. Why do you need to declare the resources in both locations?
It's not really a need, I thought it was a bit "clearer" also to have them in DT.
But I agree it is redundant. I'll fix in v2.
Thank you,
Signature · 1 line
Carlo Caione
PATCH 1/3 mfd: axp20x: Add mfd driver for axp20x PMIC
In reply to Carlo CaioneQuoted 21 lines
This patch introduces the preliminary support for PMICs X-Powers AXP202 and AXP209. The core contains support only for two sub-modules (PEK and regulators) that will be added with two different patch-sets.
Signed-off-by Carlo Caione <[email protected]>--- drivers/mfd/Kconfig | 12 +++ drivers/mfd/Makefile | 1 + drivers/mfd/axp20x.c | 251 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/axp20x.h | 178 ++++++++++++++++++++++++++++++++ 4 files changed, 442 insertions(+) create mode 100644 drivers/mfd/axp20x.c create mode 100644 include/linux/mfd/axp20x.hdrivers/mfd/Kconfig +0
-0@@ -59,6 +59,18 @@ config MFD_AAT2870_CORE additional drivers must be enabled in order to use the functionality of the device.
<snip>
drivers/mfd/axp20x.c line 1
Quoted 7 lines
drivers/mfd/axp20x.c new file +1
-0@@ -0,0 +1,251 @@ +/*
A nice descriptive title here would be good.
Quoted 52 lines
drivers/mfd/axp20x.c new file +52
-0+* Author: Carlo Caione <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#include <linux/err.h> +#include <linux/i2c.h> +#include <linux/interrupt.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/pm_runtime.h> +#include <linux/regmap.h> +#include <linux/slab.h> +#include <linux/regulator/consumer.h> +#include <linux/mfd/axp20x.h> +#include <linux/mfd/core.h> +#include <linux/of_device.h> +#include <linux/of_irq.h> + +static const struct regmap_range axp20x_writeable_ranges[] = { + { + .range_min =AXP20X_DATA (0 ), + .range_max =AXP20X_IRQ5_STATE , + }, { + .range_min =AXP20X_DCDC_MODE , + .range_max =AXP20X_FG_RES , + }, +}; + +static const struct regmap_range axp20x_volatile_ranges[] = { + { + .range_min =AXP20X_IRQ1_EN , + .range_max =AXP20X_IRQ5_STATE , + }, +}; + +static const struct regmap_access_table axp20x_writeable_table = { + .yes_ranges = axp20x_writeable_ranges, + .n_yes_ranges =ARRAY_SIZE (axp20x_writeable_ranges), +}; + +static const struct regmap_access_table axp20x_volatile_table = { + .yes_ranges = axp20x_volatile_ranges, + .n_yes_ranges =ARRAY_SIZE (axp20x_volatile_ranges), +}; + +static struct resource axp20x_pek_resources[] = { + { + .name ="PEK_DBR" , + .start =AXP20X_IRQ_PEK_RIS_EDGE ,
drivers/mfd/axp20x.c line 63
Quoted 10 lines
drivers/mfd/axp20x.c new file +10
-0+ .end = AXP20X_IRQ_PEK_RIS_EDGE, + .flags = IORESOURCE_IRQ, + }, + { + .name = "PEK_DBF", + .start = AXP20X_IRQ_PEK_FAL_EDGE, + .end = AXP20X_IRQ_PEK_FAL_EDGE, + .flags = IORESOURCE_IRQ, + }, +
Superfluous new line.
Quoted 43 lines
drivers/mfd/axp20x.c new file +43
-0+}; + +static const struct regmap_config axp20x_regmap_config = { + .reg_bits =8 , + .val_bits =8 , + .wr_table = &axp20x_writeable_table, + .volatile_table = &axp20x_volatile_table, + .max_register =AXP20X_FG_RES , + .cache_type =REGCACHE_RBTREE , +}; + +#define AXP20X_IRQ (_irq, _off, _mask) \ + [AXP20X_IRQ_##_irq] = { .reg_offset = (_off), .mask = BIT(_mask) } + +static const struct regmap_irq axp20x_regmap_irqs[] = { +AXP20X_IRQ (ACIN_OVER_V ,0 ,7 ), +AXP20X_IRQ (ACIN_PLUGIN ,0 ,6 ), +AXP20X_IRQ (ACIN_REMOVAL ,0 ,5 ), +AXP20X_IRQ (VBUS_OVER_V ,0 ,4 ), +AXP20X_IRQ (VBUS_PLUGIN ,0 ,3 ), +AXP20X_IRQ (VBUS_REMOVAL ,0 ,2 ), +AXP20X_IRQ (VBUS_V_LOW ,0 ,1 ), +AXP20X_IRQ (BATT_PLUGIN ,1 ,7 ), +AXP20X_IRQ (BATT_REMOVAL ,1 ,6 ), +AXP20X_IRQ (BATT_ENT_ACT_MODE ,1 ,5 ), +AXP20X_IRQ (BATT_EXIT_ACT_MODE ,1 ,4 ), +AXP20X_IRQ (CHARG ,1 ,3 ), +AXP20X_IRQ (CHARG_DONE ,1 ,2 ), +AXP20X_IRQ (BATT_TEMP_HIGH ,1 ,1 ), +AXP20X_IRQ (BATT_TEMP_LOW ,1 ,0 ), +AXP20X_IRQ (DIE_TEMP_HIGH ,2 ,7 ), +AXP20X_IRQ (CHARG_I_LOW ,2 ,6 ), +AXP20X_IRQ (DCDC1_V_LONG ,2 ,5 ), +AXP20X_IRQ (DCDC2_V_LONG ,2 ,4 ), +AXP20X_IRQ (DCDC3_V_LONG ,2 ,3 ), +AXP20X_IRQ (PEK_SHORT ,2 ,1 ), +AXP20X_IRQ (PEK_LONG ,2 ,0 ), +AXP20X_IRQ (N_OE_PWR_ON ,3 ,7 ), +AXP20X_IRQ (N_OE_PWR_OFF ,3 ,6 ), +AXP20X_IRQ (VBUS_VALID ,3 ,5 ), +AXP20X_IRQ (VBUS_NOT_VALID ,3 ,4 ), +AXP20X_IRQ (VBUS_SESS_VALID ,3 ,3 ), +AXP20X_IRQ (VBUS_SESS_END ,3 ,2 ),
drivers/mfd/axp20x.c line 116
Quoted 10 lines
drivers/mfd/axp20x.c new file +10
-0+AXP20X_IRQ (LOW_PWR_LVL1 ,3 ,1 ), +AXP20X_IRQ (LOW_PWR_LVL2 ,3 ,0 ), +AXP20X_IRQ (TIMER ,4 ,7 ), +AXP20X_IRQ (PEK_RIS_EDGE ,4 ,6 ), +AXP20X_IRQ (PEK_FAL_EDGE ,4 ,5 ), +AXP20X_IRQ (GPIO3_INPUT ,4 ,3 ), +AXP20X_IRQ (GPIO2_INPUT ,4 ,2 ), +AXP20X_IRQ (GPIO1_INPUT ,4 ,1 ), + AXP20X_IRQ(GPIO0_INPUT, 4, 0), +};
Where are these handled i.e. where is the irq_handler located?
drivers/mfd/axp20x.c line 126
Quoted 9 lines
drivers/mfd/axp20x.c new file +9
-0+static const struct regmap_irq_chip axp20x_regmap_irq_chip = { + .name ="axp20x_irq_chip" , + .status_base =AXP20X_IRQ1_STATE , + .ack_base =AXP20X_IRQ1_STATE , + .mask_base =AXP20X_IRQ1_EN , + .num_regs =5 , + .irqs = axp20x_regmap_irqs, + .num_irqs =ARRAY_SIZE (axp20x_regmap_irqs), + .mask_invert =1 ,
This is a bool; true or false please.
drivers/mfd/axp20x.c line 127
Quoted 1 line
drivers/mfd/axp20x.c new file +1
-0+ .init_ack_masked = 1,
Same here.
drivers/mfd/axp20x.c line 135
Quoted 8 lines
drivers/mfd/axp20x.c new file +8
-0+}; + +static struct mfd_cell axp20x_cells[] = { + { + .name ="axp20x-pek" , + .of_compatible ="x-powers,axp20x-pek" , + .num_resources =ARRAY_SIZE (axp20x_pek_resources), + .resources = axp20x_pek_resources,
I already saw the comments about these.
drivers/mfd/axp20x.c line 142
Quoted 7 lines
drivers/mfd/axp20x.c new file +7
-0+ }, { + .name = "axp20x-regulator", + }, +}; + +const struct of_device_id axp20x_of_match[] = { + { .compatible ="x-powers,axp20x" , .data = (void *)AXP20X },
There's no need to add device IDs if you only support one device.
drivers/mfd/axp20x.c line 146
Quoted 4 lines
drivers/mfd/axp20x.c new file +4
-0+ { }, +}; + +static struct axp20x_dev *axp20x_pm_power_off;
This looks pretty unconventional. What's the point of it?
drivers/mfd/axp20x.c line 149
Quoted 3 lines
drivers/mfd/axp20x.c new file +3
-0+static void axp20x_power_off (void ) +{ +regmap_write (axp20x_pm_power_off->regmap,AXP20X_OFF_CTRL ,0x80 );
What does the 0x80 do exactly? Think about #defining.
Quoted 9 lines
drivers/mfd/axp20x.c new file +9
-0+} + +static int axp20x_i2c_probe (struct i2c_client *i2c, +const struct i2c_device_id *id) +{ +struct axp20x_dev *axp20x; +const struct of_device_id *of_id; +int ret; +
drivers/mfd/axp20x.c line 168
Quoted 10 lines
drivers/mfd/axp20x.c new file +10
-0+ axp20x =devm_kzalloc (&i2c->dev,sizeof (*axp20x),GFP_KERNEL ); +if (!axp20x) +return -ENOMEM ; + + of_id =of_match_device (axp20x_of_match, &i2c->dev); +if (!of_id) { +dev_err (&i2c->dev,"Unable to setup AXP20X data\n" ); +return -ENODEV ; + } + axp20x->variant = (int ) of_id->data;
Lots of code here surrounding added device support, but only one device is supported. Why so?
drivers/mfd/axp20x.c line 174
Quoted 5 lines
drivers/mfd/axp20x.c new file +5
-0+ axp20x->i2c_client = i2c; +i2c_set_clientdata (i2c, axp20x); + + axp20x->dev = &i2c->dev; +dev_set_drvdata (axp20x->dev, axp20x);
Do you make use of all this saving of the device container?
If so, where?
Also:
i2c_set_clientdata(i2c)
and:
dev_set_drvdata(i2c->dev);
... do exactly the same thing i.e. set i2c->dev->p->device_data.
drivers/mfd/axp20x.c line 188
Quoted 13 lines
drivers/mfd/axp20x.c new file +13
-0+ axp20x->regmap =devm_regmap_init_i2c (i2c, &axp20x_regmap_config); +if (IS_ERR (axp20x->regmap)) { + ret =PTR_ERR (axp20x->regmap); +dev_err (&i2c->dev,"regmap init failed: %d\n" , ret); +return ret; + } + + axp20x->irq = i2c->irq; + ret =regmap_add_irq_chip (axp20x->regmap, axp20x->irq, +IRQF_ONESHOT |IRQF_SHARED ,-1 , + &axp20x_regmap_irq_chip, + &axp20x->regmap_irqc); +if (ret !=0 ) {
It's more succinct to say:
if (!ret)
Quoted 5 lines
drivers/mfd/axp20x.c new file +5
-0+dev_err (&i2c->dev,"failed to add irq chip: %d\n" , ret); +return ret; + } + + ret = mfd_add_devices(axp20x->dev, -1, axp20x_cells,
drivers/mfd/axp20x.c line 203
Quoted 10 lines
drivers/mfd/axp20x.c new file +10
-0+ ARRAY_SIZE(axp20x_cells), NULL, 0, NULL); +if (ret !=0 ) { +dev_err (&i2c->dev,"failed to add MFD devices: %d\n" , ret); + goto mfd_err; + } + +if (!pm_power_off) { + axp20x_pm_power_off = axp20x; + pm_power_off = axp20x_power_off; + }
Can you describe to me what you're using the pm_power_off call-back for please?
Quoted 17 lines
drivers/mfd/axp20x.c new file +17
-0+dev_info (&i2c->dev,"AXP20X driver loaded\n" ); + +return 0 ; + +mfd_err: +regmap_del_irq_chip (axp20x->irq, axp20x->regmap_irqc); + +return ret; +} + +static int axp20x_i2c_remove (struct i2c_client *i2c) +{ +struct axp20x_dev *axp20x =i2c_get_clientdata (i2c); + +if (axp20x == axp20x_pm_power_off) { + axp20x_pm_power_off =NULL ; + pm_power_off =NULL ;
drivers/mfd/axp20x.c line 231
Quoted 10 lines
drivers/mfd/axp20x.c new file +10
-0+ } + +mfd_remove_devices (axp20x->dev); +regmap_del_irq_chip (axp20x->i2c_client->irq, axp20x->regmap_irqc); + +return 0 ; +} + +static const struct i2c_device_id axp20x_i2c_id[] = { + {"axp20x" ,AXP20X },
It doesn't look like you're using this ID either?
Quoted 32 lines
drivers/mfd/axp20x.c new file +20
-0+ { } +}; +MODULE_DEVICE_TABLE (i2c, axp20x_i2c_id); + +static struct i2c_driver axp20x_i2c_driver = { + .driver = { + .name ="axp20x" , + .owner =THIS_MODULE , + .of_match_table =of_match_ptr (axp20x_of_match), + }, + .probe = axp20x_i2c_probe, + .remove = axp20x_i2c_remove, + .id_table = axp20x_i2c_id, +}; + +module_i2c_driver (axp20x_i2c_driver); + +MODULE_DESCRIPTION ("PMIC MFD core driver for AXP20X" ); +MODULE_AUTHOR ("Carlo Caione <[email protected]>" ); +MODULE_LICENSE ("GPL" );include/linux/mfd/axp20x.h new file +6
-0@@ -0,0 +1,178 @@ +/* +* Functions to access AXP20X power management chip. +* +* Copyright (C) 2013, Carlo Caione <[email protected]> +* +* This program is free software; you can redistribute it and/or modify
include/linux/mfd/axp20x.h line 16
Quoted 10 lines
include/linux/mfd/axp20x.h new file +10
-0+* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#ifndef __LINUX_MFD_AXP20X_H +#define __LINUX_MFD_AXP20X_H + +#define AXP20X 0 + +#define AXP20X_DATA (m) (0x04 + (m))
This is not a great name for a macro. 'data' and 'value' seldom make for good names for variables/macros. Please replace it with something more descriptive.
In fact, on closer inspection it appears as though you only use this once while defining writable registers. What happened to registers 0x00 to 0x03, and why have the top registers below been omitted from the range(s)?
Quoted 150 lines
include/linux/mfd/axp20x.h new file +150
-0+ +/* Power supply */ +#define AXP20X_PWR_INPUT_STATUS 0x00 +#define AXP20X_PWR_OP_MODE 0x01 +#define AXP20X_USB_OTG_STATUS 0x02 +#define AXP20X_PWR_OUT_CTRL 0x12 +#define AXP20X_DCDC2_V_OUT 0x23 +#define AXP20X_DCDC2_LDO3_V_SCAL 0x25 +#define AXP20X_DCDC3_V_OUT 0x27 +#define AXP20X_LDO24_V_OUT 0x28 +#define AXP20X_LDO3_V_OUT 0x29 +#define AXP20X_VBUS_IPSOUT_MGMT 0x30 +#define AXP20X_V_OFF 0x31 +#define AXP20X_OFF_CTRL 0x32 +#define AXP20X_CHRG_CTRL1 0x33 +#define AXP20X_CHRG_CTRL2 0x34 +#define AXP20X_CHRG_BAK_CTRL 0x35 +#define AXP20X_PEK_KEY 0x36 +#define AXP20X_DCDC_FREQ 0x37 +#define AXP20X_V_LTF_CHRG 0x38 +#define AXP20X_V_HTF_CHRG 0x39 +#define AXP20X_APS_WARN_L1 0x3a +#define AXP20X_APS_WARN_L2 0x3b +#define AXP20X_V_LTF_DISCHRG 0x3c +#define AXP20X_V_HTF_DISCHRG 0x3d + +/* Interrupt */ +#define AXP20X_IRQ1_EN 0x40 +#define AXP20X_IRQ2_EN 0x41 +#define AXP20X_IRQ3_EN 0x42 +#define AXP20X_IRQ4_EN 0x43 +#define AXP20X_IRQ5_EN 0x44 +#define AXP20X_IRQ1_STATE 0x48 +#define AXP20X_IRQ2_STATE 0x49 +#define AXP20X_IRQ3_STATE 0x4a +#define AXP20X_IRQ4_STATE 0x4b +#define AXP20X_IRQ5_STATE 0x4c + +/* ADC */ +#define AXP20X_ACIN_V_ADC_H 0x56 +#define AXP20X_ACIN_V_ADC_L 0x57 +#define AXP20X_ACIN_I_ADC_H 0x58 +#define AXP20X_ACIN_I_ADC_L 0x59 +#define AXP20X_VBUS_V_ADC_H 0x5a +#define AXP20X_VBUS_V_ADC_L 0x5b +#define AXP20X_VBUS_I_ADC_H 0x5c +#define AXP20X_VBUS_I_ADC_L 0x5d +#define AXP20X_TEMP_ADC_H 0x5e +#define AXP20X_TEMP_ADC_L 0x5f +#define AXP20X_TS_IN_H 0x62 +#define AXP20X_TS_IN_L 0x63 +#define AXP20X_GPIO0_V_ADC_H 0x64 +#define AXP20X_GPIO0_V_ADC_L 0x65 +#define AXP20X_GPIO1_V_ADC_H 0x66 +#define AXP20X_GPIO1_V_ADC_L 0x67 +#define AXP20X_PWR_BATT_H 0x70 +#define AXP20X_PWR_BATT_M 0x71 +#define AXP20X_PWR_BATT_L 0x72 +#define AXP20X_BATT_V_H 0x78 +#define AXP20X_BATT_V_L 0x79 +#define AXP20X_BATT_CHRG_I_H 0x7a +#define AXP20X_BATT_CHRG_I_L 0x7b +#define AXP20X_BATT_DISCHRG_I_H 0x7c +#define AXP20X_BATT_DISCHRG_I_L 0x7d +#define AXP20X_IPSOUT_V_HIGH_H 0x7e +#define AXP20X_IPSOUT_V_HIGH_L 0x7f + +/* Power supply */ +#define AXP20X_DCDC_MODE 0x80 +#define AXP20X_ADC_EN1 0x82 +#define AXP20X_ADC_EN2 0x83 +#define AXP20X_ADC_RATE 0x84 +#define AXP20X_GPIO10_IN_RANGE 0x85 +#define AXP20X_GPIO1_ADC_IRQ_RIS 0x86 +#define AXP20X_GPIO1_ADC_IRQ_FAL 0x87 +#define AXP20X_TIMER_CTRL 0x8a +#define AXP20X_VBUS_MON 0x8b +#define AXP20X_OVER_TMP 0x8f + +/* GPIO */ +#define AXP20X_GPIO0_CTRL 0x90 +#define AXP20X_LDO5_V_OUT 0x91 +#define AXP20X_GPIO1_CTRL 0x92 +#define AXP20X_GPIO2_CTRL 0x93 +#define AXP20X_GPIO20_SS 0x94 +#define AXP20X_GPIO3_CTRL 0x95 + +/* Battery */ +#define AXP20X_CHRG_CC_31_24 0xb0 +#define AXP20X_CHRG_CC_23_16 0xb1 +#define AXP20X_CHRG_CC_15_8 0xb2 +#define AXP20X_CHRG_CC_7_0 0xb3 +#define AXP20X_DISCHRG_CC_31_24 0xb4 +#define AXP20X_DISCHRG_CC_23_16 0xb5 +#define AXP20X_DISCHRG_CC_15_8 0xb6 +#define AXP20X_DISCHRG_CC_7_0 0xb7 +#define AXP20X_CC_CTRL 0xb8 +#define AXP20X_FG_RES 0xb9 + +/* Regulators IDs */ +enum { +AXP20X_LDO1 =0 , +AXP20X_LDO2 , +AXP20X_LDO3 , +AXP20X_LDO4 , +AXP20X_LDO5 , +AXP20X_DCDC2 , +AXP20X_DCDC3 , +AXP20X_REG_ID_MAX , +}; + +/* IRQs */ +enum { +AXP20X_IRQ_ACIN_OVER_V =1 , +AXP20X_IRQ_ACIN_PLUGIN , +AXP20X_IRQ_ACIN_REMOVAL , +AXP20X_IRQ_VBUS_OVER_V , +AXP20X_IRQ_VBUS_PLUGIN , +AXP20X_IRQ_VBUS_REMOVAL , +AXP20X_IRQ_VBUS_V_LOW , +AXP20X_IRQ_BATT_PLUGIN , +AXP20X_IRQ_BATT_REMOVAL , +AXP20X_IRQ_BATT_ENT_ACT_MODE , +AXP20X_IRQ_BATT_EXIT_ACT_MODE , +AXP20X_IRQ_CHARG , +AXP20X_IRQ_CHARG_DONE , +AXP20X_IRQ_BATT_TEMP_HIGH , +AXP20X_IRQ_BATT_TEMP_LOW , +AXP20X_IRQ_DIE_TEMP_HIGH , +AXP20X_IRQ_CHARG_I_LOW , +AXP20X_IRQ_DCDC1_V_LONG , +AXP20X_IRQ_DCDC2_V_LONG , +AXP20X_IRQ_DCDC3_V_LONG , +AXP20X_IRQ_PEK_SHORT =22 , +AXP20X_IRQ_PEK_LONG , +AXP20X_IRQ_N_OE_PWR_ON , +AXP20X_IRQ_N_OE_PWR_OFF , +AXP20X_IRQ_VBUS_VALID , +AXP20X_IRQ_VBUS_NOT_VALID , +AXP20X_IRQ_VBUS_SESS_VALID , +AXP20X_IRQ_VBUS_SESS_END , +AXP20X_IRQ_LOW_PWR_LVL1 , +AXP20X_IRQ_LOW_PWR_LVL2 , +AXP20X_IRQ_TIMER , +AXP20X_IRQ_PEK_RIS_EDGE , +AXP20X_IRQ_PEK_FAL_EDGE , +AXP20X_IRQ_GPIO3_INPUT , +AXP20X_IRQ_GPIO2_INPUT , +AXP20X_IRQ_GPIO1_INPUT , +AXP20X_IRQ_GPIO0_INPUT ,
include/linux/mfd/axp20x.h line 176
Quoted 10 lines
include/linux/mfd/axp20x.h new file +10
-0+}; + +struct axp20x_dev { +struct device *dev; +struct i2c_client *i2c_client; +struct regmap *regmap; +struct regmap_irq_chip_data *regmap_irqc; +int variant; +int irq; +};
Is this used anywhere else except in the MFD driver?
If not, consider moving it into the *.c file.
Quoted 1 line
include/linux/mfd/axp20x.h new file +1
-0+#endif /* __LINUX_MFD_AXP20X_H */
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
[linux-sunxi] Re: [PATCH 1/3] mfd: axp20x: Add mfd driver for axp20x PMIC
Quoted 24 lines · Lee Jones
Quoted 21 lines
This patch introduces the preliminary support for PMICs X-Powers AXP202 and AXP209. The core contains support only for two sub-modules (PEK and regulators) that will be added with two different patch-sets.
Signed-off-by Carlo Caione <[email protected]>--- drivers/mfd/Kconfig | 12 +++ drivers/mfd/Makefile | 1 + drivers/mfd/axp20x.c | 251 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/axp20x.h | 178 ++++++++++++++++++++++++++++++++ 4 files changed, 442 insertions(+) create mode 100644 drivers/mfd/axp20x.c create mode 100644 include/linux/mfd/axp20x.hdrivers/mfd/Kconfig +0
-0@@ -59,6 +59,18 @@ config MFD_AAT2870_CORE additional drivers must be enabled in order to use the functionality of the device.<snip>
Quoted 9 lines
drivers/mfd/axp20x.c line 1
Quoted 7 lines
drivers/mfd/axp20x.c new file +1
-0@@ -0,0 +1,251 @@ +/* A nice descriptive title here would be good.
Agree.
Quoted 112 lines
Quoted 52 lines
drivers/mfd/axp20x.c new file +52
-0+* Author: Carlo Caione <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#include <linux/err.h> +#include <linux/i2c.h> +#include <linux/interrupt.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/pm_runtime.h> +#include <linux/regmap.h> +#include <linux/slab.h> +#include <linux/regulator/consumer.h> +#include <linux/mfd/axp20x.h> +#include <linux/mfd/core.h> +#include <linux/of_device.h> +#include <linux/of_irq.h> + +static const struct regmap_range axp20x_writeable_ranges[] = { + { + .range_min =AXP20X_DATA (0 ), + .range_max =AXP20X_IRQ5_STATE , + }, { + .range_min =AXP20X_DCDC_MODE , + .range_max =AXP20X_FG_RES , + }, +}; + +static const struct regmap_range axp20x_volatile_ranges[] = { + { + .range_min =AXP20X_IRQ1_EN , + .range_max =AXP20X_IRQ5_STATE , + }, +}; + +static const struct regmap_access_table axp20x_writeable_table = { + .yes_ranges = axp20x_writeable_ranges, + .n_yes_ranges =ARRAY_SIZE (axp20x_writeable_ranges), +}; + +static const struct regmap_access_table axp20x_volatile_table = { + .yes_ranges = axp20x_volatile_ranges, + .n_yes_ranges =ARRAY_SIZE (axp20x_volatile_ranges), +}; + +static struct resource axp20x_pek_resources[] = { + { + .name ="PEK_DBR" , + .start =AXP20X_IRQ_PEK_RIS_EDGE ,drivers/mfd/axp20x.c line 63
Quoted 10 lines
drivers/mfd/axp20x.c new file +10
-0+ .end = AXP20X_IRQ_PEK_RIS_EDGE, + .flags = IORESOURCE_IRQ, + }, + { + .name = "PEK_DBF", + .start = AXP20X_IRQ_PEK_FAL_EDGE, + .end = AXP20X_IRQ_PEK_FAL_EDGE, + .flags = IORESOURCE_IRQ, + }, +Superfluous new line.
Quoted 47 lines
drivers/mfd/axp20x.c new file +47
-0+}; + +static const struct regmap_config axp20x_regmap_config = { + .reg_bits =8 , + .val_bits =8 , + .wr_table = &axp20x_writeable_table, + .volatile_table = &axp20x_volatile_table, + .max_register =AXP20X_FG_RES , + .cache_type =REGCACHE_RBTREE , +}; + +#define AXP20X_IRQ (_irq, _off, _mask) \ + [AXP20X_IRQ_##_irq] = { .reg_offset = (_off), .mask = BIT(_mask) } + +static const struct regmap_irq axp20x_regmap_irqs[] = { +AXP20X_IRQ (ACIN_OVER_V ,0 ,7 ), +AXP20X_IRQ (ACIN_PLUGIN ,0 ,6 ), +AXP20X_IRQ (ACIN_REMOVAL ,0 ,5 ), +AXP20X_IRQ (VBUS_OVER_V ,0 ,4 ), +AXP20X_IRQ (VBUS_PLUGIN ,0 ,3 ), +AXP20X_IRQ (VBUS_REMOVAL ,0 ,2 ), +AXP20X_IRQ (VBUS_V_LOW ,0 ,1 ), +AXP20X_IRQ (BATT_PLUGIN ,1 ,7 ), +AXP20X_IRQ (BATT_REMOVAL ,1 ,6 ), +AXP20X_IRQ (BATT_ENT_ACT_MODE ,1 ,5 ), +AXP20X_IRQ (BATT_EXIT_ACT_MODE ,1 ,4 ), +AXP20X_IRQ (CHARG ,1 ,3 ), +AXP20X_IRQ (CHARG_DONE ,1 ,2 ), +AXP20X_IRQ (BATT_TEMP_HIGH ,1 ,1 ), +AXP20X_IRQ (BATT_TEMP_LOW ,1 ,0 ), +AXP20X_IRQ (DIE_TEMP_HIGH ,2 ,7 ), +AXP20X_IRQ (CHARG_I_LOW ,2 ,6 ), +AXP20X_IRQ (DCDC1_V_LONG ,2 ,5 ), +AXP20X_IRQ (DCDC2_V_LONG ,2 ,4 ), +AXP20X_IRQ (DCDC3_V_LONG ,2 ,3 ), +AXP20X_IRQ (PEK_SHORT ,2 ,1 ), +AXP20X_IRQ (PEK_LONG ,2 ,0 ), +AXP20X_IRQ (N_OE_PWR_ON ,3 ,7 ), +AXP20X_IRQ (N_OE_PWR_OFF ,3 ,6 ), +AXP20X_IRQ (VBUS_VALID ,3 ,5 ), +AXP20X_IRQ (VBUS_NOT_VALID ,3 ,4 ), +AXP20X_IRQ (VBUS_SESS_VALID ,3 ,3 ), +AXP20X_IRQ (VBUS_SESS_END ,3 ,2 ), +AXP20X_IRQ (LOW_PWR_LVL1 ,3 ,1 ), +AXP20X_IRQ (LOW_PWR_LVL2 ,3 ,0 ), +AXP20X_IRQ (TIMER ,4 ,7 ), +AXP20X_IRQ (PEK_RIS_EDGE ,4 ,6 ),
Quoted 8 lines
drivers/mfd/axp20x.c line 116
Quoted 6 lines
drivers/mfd/axp20x.c new file +6
-0+AXP20X_IRQ (PEK_FAL_EDGE ,4 ,5 ), +AXP20X_IRQ (GPIO3_INPUT ,4 ,3 ), +AXP20X_IRQ (GPIO2_INPUT ,4 ,2 ), +AXP20X_IRQ (GPIO1_INPUT ,4 ,1 ), + AXP20X_IRQ(GPIO0_INPUT, 4, 0), +};Where are these handled i.e. where is the
irq_handlerlocated?
Each one is used by a different driver for each subsystem of the MFD, so each driver will have a specific irq_handler. I need the full list here to register with regmap_add_irq_chip() the generic regmap_irq_thread.
Quoted 10 lines
drivers/mfd/axp20x.c line 126
Quoted 9 lines
drivers/mfd/axp20x.c new file +9
-0+static const struct regmap_irq_chip axp20x_regmap_irq_chip = { + .name ="axp20x_irq_chip" , + .status_base =AXP20X_IRQ1_STATE , + .ack_base =AXP20X_IRQ1_STATE , + .mask_base =AXP20X_IRQ1_EN , + .num_regs =5 , + .irqs = axp20x_regmap_irqs, + .num_irqs =ARRAY_SIZE (axp20x_regmap_irqs), + .mask_invert =1 ,
Quoted 5 lines
This is a bool; true or false please.
drivers/mfd/axp20x.c line 127
Quoted 1 line
drivers/mfd/axp20x.c new file +1
-0+ .init_ack_masked = 1,Same here.
I'll fix both in v2.
Quoted 11 lines
drivers/mfd/axp20x.c line 135
Quoted 8 lines
drivers/mfd/axp20x.c new file +8
-0+}; + +static struct mfd_cell axp20x_cells[] = { + { + .name ="axp20x-pek" , + .of_compatible ="x-powers,axp20x-pek" , + .num_resources =ARRAY_SIZE (axp20x_pek_resources), + .resources = axp20x_pek_resources,I already saw the comments about these.
Quoted 9 lines
drivers/mfd/axp20x.c line 142
Quoted 7 lines
drivers/mfd/axp20x.c new file +7
-0+ }, { + .name = "axp20x-regulator", + }, +}; + +const struct of_device_id axp20x_of_match[] = { + { .compatible ="x-powers,axp20x" , .data = (void *)AXP20X },There's no need to add device IDs if you only support one device.
Ok. But what if in the future we want to add a new device?
Quoted 6 lines
drivers/mfd/axp20x.c line 146
Quoted 4 lines
drivers/mfd/axp20x.c new file +4
-0+ { }, +}; + +static struct axp20x_dev *axp20x_pm_power_off;This looks pretty unconventional. What's the point of it?
On a single board we can have multiple AXPs so I track which one is in charge of powering off the board (and to get the correct device in the axp20x_power_off())
Quoted 5 lines
drivers/mfd/axp20x.c line 149
Quoted 3 lines
drivers/mfd/axp20x.c new file +3
-0+static void axp20x_power_off (void ) +{ +regmap_write (axp20x_pm_power_off->regmap,AXP20X_OFF_CTRL ,0x80 );What does the
0x80do exactly? Think about #defining.
It's only used here, but I'll #define it.
Quoted 14 lines
Quoted 14 lines
drivers/mfd/axp20x.c new file +14
-0+} + +static int axp20x_i2c_probe (struct i2c_client *i2c, +const struct i2c_device_id *id) +{ +struct axp20x_dev *axp20x; +const struct of_device_id *of_id; +int ret; + + axp20x =devm_kzalloc (&i2c->dev,sizeof (*axp20x),GFP_KERNEL ); +if (!axp20x) +return -ENOMEM ; + + of_id =of_match_device (axp20x_of_match, &i2c->dev);
Quoted 8 lines
drivers/mfd/axp20x.c line 168
Quoted 5 lines
drivers/mfd/axp20x.c new file +5
-0+if (!of_id) { +dev_err (&i2c->dev,"Unable to setup AXP20X data\n" ); +return -ENODEV ; + } + axp20x->variant = (int ) of_id->data;Lots of code here surrounding added device support, but only one device is supported. Why so?
Because at the moment I support only axp202 and axp209 but I wanted something future-proof
Quoted 9 lines
drivers/mfd/axp20x.c line 174
Quoted 5 lines
drivers/mfd/axp20x.c new file +5
-0+ axp20x->i2c_client = i2c; +i2c_set_clientdata (i2c, axp20x); + + axp20x->dev = &i2c->dev; +dev_set_drvdata (axp20x->dev, axp20x);Do you make use of all this saving of the device container?
If so, where?
In the drivers for subsystems (input, regulators, gpio, etc..)
Quoted 7 lines
Also:
i2c_set_clientdata(i2c)and:
dev_set_drvdata(i2c->dev);... do exactly the same thing i.e. set
i2c->dev->p->device_data.
Right.
Quoted 14 lines
drivers/mfd/axp20x.c line 188
Quoted 13 lines
drivers/mfd/axp20x.c new file +13
-0+ axp20x->regmap =devm_regmap_init_i2c (i2c, &axp20x_regmap_config); +if (IS_ERR (axp20x->regmap)) { + ret =PTR_ERR (axp20x->regmap); +dev_err (&i2c->dev,"regmap init failed: %d\n" , ret); +return ret; + } + + axp20x->irq = i2c->irq; + ret =regmap_add_irq_chip (axp20x->regmap, axp20x->irq, +IRQF_ONESHOT |IRQF_SHARED ,-1 , + &axp20x_regmap_irq_chip, + &axp20x->regmap_irqc); +if (ret !=0 ) {
Quoted 2 lines
It's more succinct to say:
if (!ret)
Agree
Quoted 10 lines
Quoted 10 lines
drivers/mfd/axp20x.c new file +10
-0+dev_err (&i2c->dev,"failed to add irq chip: %d\n" , ret); +return ret; + } + + ret =mfd_add_devices (axp20x->dev,-1 , axp20x_cells, +ARRAY_SIZE (axp20x_cells),NULL ,0 ,NULL ); +if (ret !=0 ) { +dev_err (&i2c->dev,"failed to add MFD devices: %d\n" , ret); + goto mfd_err; + }
Quoted 8 lines
drivers/mfd/axp20x.c line 203
Quoted 5 lines
drivers/mfd/axp20x.c new file +5
-0+ +if (!pm_power_off) { + axp20x_pm_power_off = axp20x; + pm_power_off = axp20x_power_off; + }Can you describe to me what you're using the
pm_power_offcall-back for please?
It's meant to poweroff the board
Quoted 21 lines
Quoted 21 lines
drivers/mfd/axp20x.c new file +21
-0+dev_info (&i2c->dev,"AXP20X driver loaded\n" ); + +return 0 ; + +mfd_err: +regmap_del_irq_chip (axp20x->irq, axp20x->regmap_irqc); + +return ret; +} + +static int axp20x_i2c_remove (struct i2c_client *i2c) +{ +struct axp20x_dev *axp20x =i2c_get_clientdata (i2c); + +if (axp20x == axp20x_pm_power_off) { + axp20x_pm_power_off =NULL ; + pm_power_off =NULL ; + } + +mfd_remove_devices (axp20x->dev); +regmap_del_irq_chip (axp20x->i2c_client->irq, axp20x->regmap_irqc);
Quoted 8 lines
drivers/mfd/axp20x.c line 231
Quoted 6 lines
drivers/mfd/axp20x.c new file +6
-0+ +return 0 ; +} + +static const struct i2c_device_id axp20x_i2c_id[] = { + {"axp20x" ,AXP20X },It doesn't look like you're using this ID either?
No, I am not. I'll fix it in v2.
Quoted 38 lines
Quoted 38 lines
drivers/mfd/axp20x.c new file +20
-0+ { } +}; +MODULE_DEVICE_TABLE (i2c, axp20x_i2c_id); + +static struct i2c_driver axp20x_i2c_driver = { + .driver = { + .name ="axp20x" , + .owner =THIS_MODULE , + .of_match_table =of_match_ptr (axp20x_of_match), + }, + .probe = axp20x_i2c_probe, + .remove = axp20x_i2c_remove, + .id_table = axp20x_i2c_id, +}; + +module_i2c_driver (axp20x_i2c_driver); + +MODULE_DESCRIPTION ("PMIC MFD core driver for AXP20X" ); +MODULE_AUTHOR ("Carlo Caione <[email protected]>" ); +MODULE_LICENSE ("GPL" );include/linux/mfd/axp20x.h new file +12
-0@@ -0,0 +1,178 @@ +/* +* Functions to access AXP20X power management chip. +* +* Copyright (C) 2013, Carlo Caione <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#ifndef __LINUX_MFD_AXP20X_H +#define __LINUX_MFD_AXP20X_H
Quoted 8 lines
include/linux/mfd/axp20x.h line 16
Quoted 4 lines
include/linux/mfd/axp20x.h new file +4
-0+ +#define AXP20X 0 + +#define AXP20X_DATA (m) (0x04 + (m))This is not a great name for a macro. 'data' and 'value' seldom make for good names for variables/macros. Please replace it with something more descriptive.
Agree. I'll change it.
Quoted 4 lines
In fact, on closer inspection it appears as though you only use this once while defining writable registers. What happened to registers
0x00to0x03, and why have the top registers below been omitted from the range(s)?
All the registers defined here can be used by the drivers of the different subsystems including this header file, thus all the registers are reported here though they are not directly used by the core driver.
About the range you are right, I'll fix it in v2. Thanks for noticing.
Quoted 163 lines
Quoted 150 lines
include/linux/mfd/axp20x.h new file +150
-0+ +/* Power supply */ +#define AXP20X_PWR_INPUT_STATUS 0x00 +#define AXP20X_PWR_OP_MODE 0x01 +#define AXP20X_USB_OTG_STATUS 0x02 +#define AXP20X_PWR_OUT_CTRL 0x12 +#define AXP20X_DCDC2_V_OUT 0x23 +#define AXP20X_DCDC2_LDO3_V_SCAL 0x25 +#define AXP20X_DCDC3_V_OUT 0x27 +#define AXP20X_LDO24_V_OUT 0x28 +#define AXP20X_LDO3_V_OUT 0x29 +#define AXP20X_VBUS_IPSOUT_MGMT 0x30 +#define AXP20X_V_OFF 0x31 +#define AXP20X_OFF_CTRL 0x32 +#define AXP20X_CHRG_CTRL1 0x33 +#define AXP20X_CHRG_CTRL2 0x34 +#define AXP20X_CHRG_BAK_CTRL 0x35 +#define AXP20X_PEK_KEY 0x36 +#define AXP20X_DCDC_FREQ 0x37 +#define AXP20X_V_LTF_CHRG 0x38 +#define AXP20X_V_HTF_CHRG 0x39 +#define AXP20X_APS_WARN_L1 0x3a +#define AXP20X_APS_WARN_L2 0x3b +#define AXP20X_V_LTF_DISCHRG 0x3c +#define AXP20X_V_HTF_DISCHRG 0x3d + +/* Interrupt */ +#define AXP20X_IRQ1_EN 0x40 +#define AXP20X_IRQ2_EN 0x41 +#define AXP20X_IRQ3_EN 0x42 +#define AXP20X_IRQ4_EN 0x43 +#define AXP20X_IRQ5_EN 0x44 +#define AXP20X_IRQ1_STATE 0x48 +#define AXP20X_IRQ2_STATE 0x49 +#define AXP20X_IRQ3_STATE 0x4a +#define AXP20X_IRQ4_STATE 0x4b +#define AXP20X_IRQ5_STATE 0x4c + +/* ADC */ +#define AXP20X_ACIN_V_ADC_H 0x56 +#define AXP20X_ACIN_V_ADC_L 0x57 +#define AXP20X_ACIN_I_ADC_H 0x58 +#define AXP20X_ACIN_I_ADC_L 0x59 +#define AXP20X_VBUS_V_ADC_H 0x5a +#define AXP20X_VBUS_V_ADC_L 0x5b +#define AXP20X_VBUS_I_ADC_H 0x5c +#define AXP20X_VBUS_I_ADC_L 0x5d +#define AXP20X_TEMP_ADC_H 0x5e +#define AXP20X_TEMP_ADC_L 0x5f +#define AXP20X_TS_IN_H 0x62 +#define AXP20X_TS_IN_L 0x63 +#define AXP20X_GPIO0_V_ADC_H 0x64 +#define AXP20X_GPIO0_V_ADC_L 0x65 +#define AXP20X_GPIO1_V_ADC_H 0x66 +#define AXP20X_GPIO1_V_ADC_L 0x67 +#define AXP20X_PWR_BATT_H 0x70 +#define AXP20X_PWR_BATT_M 0x71 +#define AXP20X_PWR_BATT_L 0x72 +#define AXP20X_BATT_V_H 0x78 +#define AXP20X_BATT_V_L 0x79 +#define AXP20X_BATT_CHRG_I_H 0x7a +#define AXP20X_BATT_CHRG_I_L 0x7b +#define AXP20X_BATT_DISCHRG_I_H 0x7c +#define AXP20X_BATT_DISCHRG_I_L 0x7d +#define AXP20X_IPSOUT_V_HIGH_H 0x7e +#define AXP20X_IPSOUT_V_HIGH_L 0x7f + +/* Power supply */ +#define AXP20X_DCDC_MODE 0x80 +#define AXP20X_ADC_EN1 0x82 +#define AXP20X_ADC_EN2 0x83 +#define AXP20X_ADC_RATE 0x84 +#define AXP20X_GPIO10_IN_RANGE 0x85 +#define AXP20X_GPIO1_ADC_IRQ_RIS 0x86 +#define AXP20X_GPIO1_ADC_IRQ_FAL 0x87 +#define AXP20X_TIMER_CTRL 0x8a +#define AXP20X_VBUS_MON 0x8b +#define AXP20X_OVER_TMP 0x8f + +/* GPIO */ +#define AXP20X_GPIO0_CTRL 0x90 +#define AXP20X_LDO5_V_OUT 0x91 +#define AXP20X_GPIO1_CTRL 0x92 +#define AXP20X_GPIO2_CTRL 0x93 +#define AXP20X_GPIO20_SS 0x94 +#define AXP20X_GPIO3_CTRL 0x95 + +/* Battery */ +#define AXP20X_CHRG_CC_31_24 0xb0 +#define AXP20X_CHRG_CC_23_16 0xb1 +#define AXP20X_CHRG_CC_15_8 0xb2 +#define AXP20X_CHRG_CC_7_0 0xb3 +#define AXP20X_DISCHRG_CC_31_24 0xb4 +#define AXP20X_DISCHRG_CC_23_16 0xb5 +#define AXP20X_DISCHRG_CC_15_8 0xb6 +#define AXP20X_DISCHRG_CC_7_0 0xb7 +#define AXP20X_CC_CTRL 0xb8 +#define AXP20X_FG_RES 0xb9 + +/* Regulators IDs */ +enum { +AXP20X_LDO1 =0 , +AXP20X_LDO2 , +AXP20X_LDO3 , +AXP20X_LDO4 , +AXP20X_LDO5 , +AXP20X_DCDC2 , +AXP20X_DCDC3 , +AXP20X_REG_ID_MAX , +}; + +/* IRQs */ +enum { +AXP20X_IRQ_ACIN_OVER_V =1 , +AXP20X_IRQ_ACIN_PLUGIN , +AXP20X_IRQ_ACIN_REMOVAL , +AXP20X_IRQ_VBUS_OVER_V , +AXP20X_IRQ_VBUS_PLUGIN , +AXP20X_IRQ_VBUS_REMOVAL , +AXP20X_IRQ_VBUS_V_LOW , +AXP20X_IRQ_BATT_PLUGIN , +AXP20X_IRQ_BATT_REMOVAL , +AXP20X_IRQ_BATT_ENT_ACT_MODE , +AXP20X_IRQ_BATT_EXIT_ACT_MODE , +AXP20X_IRQ_CHARG , +AXP20X_IRQ_CHARG_DONE , +AXP20X_IRQ_BATT_TEMP_HIGH , +AXP20X_IRQ_BATT_TEMP_LOW , +AXP20X_IRQ_DIE_TEMP_HIGH , +AXP20X_IRQ_CHARG_I_LOW , +AXP20X_IRQ_DCDC1_V_LONG , +AXP20X_IRQ_DCDC2_V_LONG , +AXP20X_IRQ_DCDC3_V_LONG , +AXP20X_IRQ_PEK_SHORT =22 , +AXP20X_IRQ_PEK_LONG , +AXP20X_IRQ_N_OE_PWR_ON , +AXP20X_IRQ_N_OE_PWR_OFF , +AXP20X_IRQ_VBUS_VALID , +AXP20X_IRQ_VBUS_NOT_VALID , +AXP20X_IRQ_VBUS_SESS_VALID , +AXP20X_IRQ_VBUS_SESS_END , +AXP20X_IRQ_LOW_PWR_LVL1 , +AXP20X_IRQ_LOW_PWR_LVL2 , +AXP20X_IRQ_TIMER , +AXP20X_IRQ_PEK_RIS_EDGE , +AXP20X_IRQ_PEK_FAL_EDGE , +AXP20X_IRQ_GPIO3_INPUT , +AXP20X_IRQ_GPIO2_INPUT , +AXP20X_IRQ_GPIO1_INPUT , +AXP20X_IRQ_GPIO0_INPUT ,include/linux/mfd/axp20x.h line 176
Quoted 10 lines
include/linux/mfd/axp20x.h new file +10
-0+}; + +struct axp20x_dev { +struct device *dev; +struct i2c_client *i2c_client; +struct regmap *regmap; +struct regmap_irq_chip_data *regmap_irqc; +int variant; +int irq; +};Is this used anywhere else except in the MFD driver?
Quoted 1 line
If not, consider moving it into the *.c file.
Yes, it is used by drivers of subsystems.
Thank you,
Signature · 1 line
Carlo Caione
[linux-sunxi] Re: [PATCH 1/3] mfd: axp20x: Add mfd driver for axp20x PMIC
Quoted 7 lines · Carlo Caione
Quoted 3 lines
Quoted 1 line
+static struct
axp20x_dev*axp20x_pm_power_off;This looks pretty unconventional. What's the point of it?
On a single board we can have multiple AXPs so I track which one is in charge of powering off the board (and to get the correct device in the
axp20x_power_off())
<snip>
Quoted 10 lines
Quoted 8 lines
drivers/mfd/axp20x.c line 203
Quoted 5 lines
drivers/mfd/axp20x.c new file +5
-0+ +if (!pm_power_off) { + axp20x_pm_power_off = axp20x; + pm_power_off = axp20x_power_off; + }Can you describe to me what you're using the
pm_power_offcall-back for please?It's meant to poweroff the board
Actually what is missing here is also a way to determine which device is in charge of powering off when multiple AXPs are registered. I'll fix it in v2.
Thanks,
Signature · 1 line
Carlo Caione
[linux-sunxi] Re: [PATCH 1/3] mfd: axp20x: Add mfd driver for axp20x PMIC
In reply to Carlo CaioneQuoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/mfd/axp20x.c new file +3
-0+static const struct regmap_irq axp20x_regmap_irqs[] = { +AXP20X_IRQ (ACIN_OVER_V ,0 ,7 ), +AXP20X_IRQ (ACIN_PLUGIN ,0 ,6 ),
[...]
Quoted 11 lines
Quoted 5 lines
drivers/mfd/axp20x.c line 116
Quoted 3 lines
drivers/mfd/axp20x.c new file +3
-0+AXP20X_IRQ (GPIO1_INPUT ,4 ,1 ), + AXP20X_IRQ(GPIO0_INPUT, 4, 0), +};Where are these handled i.e. where is the
irq_handlerlocated?Each one is used by a different driver for each subsystem of the MFD, so each driver will have a specific
irq_handler. I need the full list here to register withregmap_add_irq_chip()the generic
regmap_irq_thread.
Okay, this is all I needed. I must confess that I haven't _used_ regmap_add_irq_chip() before and was a little confused as to how it worked exactly. We used to handle hierarchical IRQs ourselves, but this is better I think.
<snip>
Quoted 6 lines
Quoted 4 lines
drivers/mfd/axp20x.c line 142
Quoted 2 lines
drivers/mfd/axp20x.c new file +2
-0+const struct of_device_id axp20x_of_match[] = { + { .compatible ="x-powers,axp20x" , .data = (void *)AXP20X },There's no need to add device IDs if you only support one device.
Ok. But what if in the future we want to add a new device?
Then we add support for device identification. Until then, it's just meaningless cruft.
Quoted 10 lines
Quoted 6 lines
drivers/mfd/axp20x.c line 146
Quoted 4 lines
drivers/mfd/axp20x.c new file +4
-0+ { }, +}; + +static struct axp20x_dev *axp20x_pm_power_off;This looks pretty unconventional. What's the point of it?
On a single board we can have multiple AXPs so I track which one is in charge of powering off the board (and to get the correct device in the
axp20x_power_off())
Is it this device's responsibility to shut down the _entire_ board? Or does the call below only turn off _this_ device?
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/mfd/axp20x.c new file +3
-0+static void axp20x_power_off (void ) +{ +regmap_write (axp20x_pm_power_off->regmap,AXP20X_OFF_CTRL ,0x80 );
<snip>
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
drivers/mfd/axp20x.c new file +6
-0+ of_id =of_match_device (axp20x_of_match, &i2c->dev); +if (!of_id) { +dev_err (&i2c->dev,"Unable to setup AXP20X data\n" ); +return -ENODEV ; + } + axp20x->variant = (int ) of_id->data;
Quoted 5 lines
Quoted 2 lines
Lots of code here surrounding added device support, but only one device is supported. Why so?
Because at the moment I support only axp202 and axp209 but I wanted something future-proof
Nothing is future-proof. :)
You only need to add this functionality when it's going to be utilised.
Quoted 11 lines
Quoted 9 lines
drivers/mfd/axp20x.c line 174
Quoted 5 lines
drivers/mfd/axp20x.c new file +5
-0+ axp20x->i2c_client = i2c; +i2c_set_clientdata (i2c, axp20x); + + axp20x->dev = &i2c->dev; +dev_set_drvdata (axp20x->dev, axp20x);Do you make use of all this saving of the device container?
If so, where?
In the drivers for subsystems (input, regulators, gpio, etc..)
Can you link me to the patches please? Any reason why they're not in this set? By submitting them together you give the Maintainers a good over-view on how the system works together.
Quoted 9 lines
Quoted 7 lines
Also:
i2c_set_clientdata(i2c)and:
dev_set_drvdata(i2c->dev);... do exactly the same thing i.e. set
i2c->dev->p->device_data.Right.
Right. So why are you doing them both?
<snip>
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
[linux-sunxi] Re: [PATCH 1/3] mfd: axp20x: Add mfd driver for axp20x PMIC
Quoted 9 lines · Lee Jones
Quoted 6 lines
Quoted 4 lines
drivers/mfd/axp20x.c line 142
Quoted 2 lines
drivers/mfd/axp20x.c new file +2
-0+const struct of_device_id axp20x_of_match[] = { + { .compatible ="x-powers,axp20x" , .data = (void *)AXP20X },There's no need to add device IDs if you only support one device.
Ok. But what if in the future we want to add a new device?
Then we add support for device identification. Until then, it's just meaningless cruft.
Ok, I'll get rid of it in v2.
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
drivers/mfd/axp20x.c line 146
Quoted 4 lines
drivers/mfd/axp20x.c new file +4
-0+ { }, +}; + +static struct axp20x_dev *axp20x_pm_power_off;This looks pretty unconventional. What's the point of it?
Quoted 6 lines
Quoted 3 lines
On a single board we can have multiple AXPs so I track which one is in charge of powering off the board (and to get the correct device in the
axp20x_power_off())Is it this device's responsibility to shut down the _entire_ board? Or does the call below only turn off _this_ device?
AXP shutdowns the entire board
Quoted 16 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/mfd/axp20x.c new file +3
-0+static void axp20x_power_off (void ) +{ +regmap_write (axp20x_pm_power_off->regmap,AXP20X_OFF_CTRL ,0x80 );<snip>
Quoted 10 lines
Quoted 9 lines
drivers/mfd/axp20x.c line 168
Quoted 6 lines
drivers/mfd/axp20x.c new file +6
-0+ of_id =of_match_device (axp20x_of_match, &i2c->dev); +if (!of_id) { +dev_err (&i2c->dev,"Unable to setup AXP20X data\n" ); +return -ENODEV ; + } + axp20x->variant = (int ) of_id->data;Lots of code here surrounding added device support, but only one device is supported. Why so?
Quoted 7 lines
Quoted 2 lines
Because at the moment I support only axp202 and axp209 but I wanted something future-proof
Nothing is future-proof. :)
You only need to add this functionality when it's going to be utilised.
I agree. Fix in v2.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/mfd/axp20x.c line 174
Quoted 5 lines
drivers/mfd/axp20x.c new file +5
-0+ axp20x->i2c_client = i2c; +i2c_set_clientdata (i2c, axp20x); + + axp20x->dev = &i2c->dev; +dev_set_drvdata (axp20x->dev, axp20x);Do you make use of all this saving of the device container?
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
If so, where?
In the drivers for subsystems (input, regulators, gpio, etc..)
Can you link me to the patches please? Any reason why they're not in this set? By submitting them together you give the Maintainers a good over-view on how the system works together.
I wasn't sure it was a good idea to submit all the drivers altogether, so my idea was to submit one driver at a time.
Do you think is it better to submit all the subsystems in one patch-set?
Quoted 11 lines
Quoted 9 lines
Quoted 7 lines
Also:
i2c_set_clientdata(i2c)and:
dev_set_drvdata(i2c->dev);... do exactly the same thing i.e. set
i2c->dev->p->device_data.Right.
Right. So why are you doing them both?
Right == I'll fix it :)
Thank you,
Signature · 1 line
Carlo Caione
[linux-sunxi] Re: [PATCH 1/3] mfd: axp20x: Add mfd driver for axp20x PMIC
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 9 lines
drivers/mfd/axp20x.c line 174
Quoted 5 lines
drivers/mfd/axp20x.c new file +5
-0+ axp20x->i2c_client = i2c; +i2c_set_clientdata (i2c, axp20x); + + axp20x->dev = &i2c->dev; +dev_set_drvdata (axp20x->dev, axp20x);Do you make use of all this saving of the device container?
If so, where?
In the drivers for subsystems (input, regulators, gpio, etc..)
Quoted 7 lines
Quoted 3 lines
Can you link me to the patches please? Any reason why they're not in this set? By submitting them together you give the Maintainers a good over-view on how the system works together.
I wasn't sure it was a good idea to submit all the drivers altogether, so my idea was to submit one driver at a time.
Do you think is it better to submit all the subsystems in one patch-set?
Normally.
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH 2/3 mfd: axp20x: Add dtsi for axp20x
In reply to Carlo CaioneThis patch adds a new dtsi for supporting axp20x.
--- arch/arm/boot/dts/axp20x.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 arch/arm/boot/dts/axp20x.dtsi
arch/arm/boot/dts/axp20x.dtsi new file +9 -0
@@ -0,0 +1,9 @@ +/* +* Integrated Power Management Chip AXP209 +*/ + +&axp { + compatible = "x-powers,axp20x"; + interrupt-controller; + #interrupt-cells = <1>; +};
Signature · 1 line
1.8.5.3
PATCH 2/3 mfd: axp20x: Add dtsi for axp20x
Hi Carlo,
Quoted 14 lines · Carlo Caione
This patch adds a new dtsi for supporting axp20x.
Signed-off-by Carlo Caione <[email protected]>--- arch/arm/boot/dts/axp20x.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 arch/arm/boot/dts/axp20x.dtsiarch/arm/boot/dts/axp20x.dtsi new file +0
-0
arch/arm/boot/dts/axp20x.dtsi line 9
Quoted 9 lines
arch/arm/boot/dts/axp20x.dtsi new file +9
-0@@ -0,0 +1,9 @@ +/* +* Integrated Power Management Chip AXP209 +*/ + +&axp { + compatible = "x-powers,axp20x"; + interrupt-controller; + #interrupt-cells = <1>; +};
Hmmm, this refers to an undefined node, I can't see this DTSI used anywhere, and why do you need a DTSI of its own in the first place?
Thanks,
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140210/b62a7ee4/attachment.sig>
[linux-sunxi] Re: [PATCH 2/3] mfd: axp20x: Add dtsi for axp20x
Quoted 21 lines · Maxime Ripard
Hi Carlo,
Quoted 18 lines · Carlo Caione
This patch adds a new dtsi for supporting axp20x.
Signed-off-by Carlo Caione <[email protected]>--- arch/arm/boot/dts/axp20x.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 arch/arm/boot/dts/axp20x.dtsiarch/arm/boot/dts/axp20x.dtsi new file +4
-0@@ -0,0 +1,9 @@ +/* +* Integrated Power Management Chip AXP209 +*/ +
Quoted 8 lines
arch/arm/boot/dts/axp20x.dtsi line 9
Quoted 5 lines
arch/arm/boot/dts/axp20x.dtsi new file +5
-0+&axp { + compatible = "x-powers,axp20x"; + interrupt-controller; + #interrupt-cells = <1>; +};Hmmm, this refers to an undefined node, I can't see this DTSI used anywhere, and why do you need a DTSI of its own in the first place?
Since axp is an independent MFD this could be integrated in the DTS of the SoC using it (multiple SoC could be using the same axp), that's why I left it in a DTSI.
i.e. it will be integrated in sun7i-a20-cubieboard2.dts once the problem with the NMI controller has been solved (and we have a NMI controller to link the axp to).
Thanks,
Signature · 1 line
Carlo Caione
PATCH 2/3 mfd: axp20x: Add dtsi for axp20x
In reply to Carlo CaioneQuoted 14 lines · Carlo Caione
This patch adds a new dtsi for supporting axp20x.
Signed-off-by Carlo Caione <[email protected]>--- arch/arm/boot/dts/axp20x.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 arch/arm/boot/dts/axp20x.dtsiarch/arm/boot/dts/axp20x.dtsi new file +0
-0
arch/arm/boot/dts/axp20x.dtsi line 9
Quoted 9 lines
arch/arm/boot/dts/axp20x.dtsi new file +9
-0@@ -0,0 +1,9 @@ +/* +* Integrated Power Management Chip AXP209 +*/ + +&axp { + compatible = "x-powers,axp20x"; + interrupt-controller; + #interrupt-cells = <1>; +};
I's suggest not doing it this way. Having a .dtsi file for every device is not the way Device Tree has been designed. This snippet should be copied directly into device's .dts(i) files.
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH 2/3 mfd: axp20x: Add dtsi for axp20x
Quoted 21 lines · Lee Jones
Quoted 19 lines · Carlo Caione
This patch adds a new dtsi for supporting axp20x.
Signed-off-by Carlo Caione <[email protected]>--- arch/arm/boot/dts/axp20x.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 arch/arm/boot/dts/axp20x.dtsiarch/arm/boot/dts/axp20x.dtsi new file +5
-0@@ -0,0 +1,9 @@ +/* +* Integrated Power Management Chip AXP209 +*/ + +&axp {
Quoted 8 lines
arch/arm/boot/dts/axp20x.dtsi line 9
Quoted 4 lines
arch/arm/boot/dts/axp20x.dtsi new file +4
-0+ compatible = "x-powers,axp20x"; + interrupt-controller; + #interrupt-cells = <1>; +};I's suggest not doing it this way. Having a .dtsi file for every device is not the way Device Tree has been designed. This snippet should be copied directly into device's .dts(i) files.
Well, ok then :) I'll fix it in v2.
Thanks,
Signature · 1 line
Carlo Caione
PATCH 3/3 mfd: axp20x: Add bindings documentation
In reply to Carlo CaioneBindings documentation for the axp20x driver. In this file also two sub-nodes (PEK and regulators) are documented.
--- Documentation/devicetree/bindings/mfd/axp20x.txt | 87 ++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/axp20x.txt
Documentation/devicetree/bindings/mfd/axp20x.txt new file +87 -0
@@ -0,0 +1,87 @@ +* axp20x device tree bindings + +The axp20x family current members :- +axp202 (x-powers) +axp209 (x-powers) + +Required properties: +- compatible : Should be "x-powers,axp20x" (for axp202 and axp209) +- interrupt-controller : axp20x has its own internal IRQs +- #interrupt-cells : should be set to 1 +- interrupt-parent : The parent interrupt controller +- interrupts : Specifies the list of interrupt lines which are handled by + the device in the parent controller's notation +- reg : Specifies base physical address and size of the registers + +Sub-nodes +* regulators : Contain the regulator nodes. The regulators are bound using + their name as listed here: dcdc2, dcdc3, ldo1, ldo2, ldo3, + ldo4, ldo5. + The bindings details of individual regulator device can be found in: + Documentation/devicetree/bindings/regulator/regulator.txt with the + exception of: + + - dcdc-freq : defines the work frequency of DC-DC where + F=(1+dcdc-freq*5%)*1.5MHz + +* axp20x-pek : Power Enable Key + - compatible : should be "x-powers,axp20x-pek" + - interrupts : two interrupt numbers with order defined by interrupt-names + (one irq number for rising transition of the power key, the + other one for falling transition) + - interrupt-names : should be "PEK_DBR" and "PEK_DBF" + +Example: + +axp { + compatible = "x-powers,axp20x"; + interrupt-controller; + #interrupt-cells = <1>; + + axp20x-pek { + compatible = "x-powers,axp20x-pek"; + interrupts = <33>, <34>; + interrupt-names = "PEK_DBR", "PEK_DBF"; + }; + + regulators { + dcdc-freq = "8"; + + axp_dcdc2: dcdc2 { + regulator-min-microvolt = <700000>; + regulator-max-microvolt = <2275000>; + dcdc-workmode = <0>; + }; + + axp_dcdc3: dcdc3 { + regulator-min-microvolt = <700000>; + regulator-max-microvolt = <3500000>; + dcdc-workmode = <0>; + }; + + axp_ldo1: ldo1 { + regulator-min-microvolt = <1300000>; + regulator-max-microvolt = <1300000>; + }; + + axp_ldo2: ldo2 { + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3300000>; + }; + + axp_ldo3: ldo3 { + regulator-min-microvolt = <700000>; + regulator-max-microvolt = <3500000>; + }; + + axp_ldo4: ldo4 { + regulator-min-microvolt = <1250000>; + regulator-max-microvolt = <3300000>; + }; + + axp_ldo5: ldo5 { + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3300000>; + }; + }; +};
Signature · 1 line
1.8.5.3
PATCH 3/3 mfd: axp20x: Add bindings documentation
Quoted 6 lines
Bindings documentation for the axp20x driver. In this file also two sub-nodes (PEK and regulators) are documented.
Signed-off-by Carlo Caione <[email protected]>--- Documentation/devicetree/bindings/mfd/axp20x.txt | 87 ++++++++++++++++++++++++
You need to CC the Device Tree guys.
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH 3/3 mfd: axp20x: Add bindings documentation
In reply to Carlo CaioneHi Carlo,
Quoted 15 lines · Carlo Caione
Bindings documentation for the axp20x driver. In this file also two sub-nodes (PEK and regulators) are documented.
Signed-off-by Carlo Caione <[email protected]>--- Documentation/devicetree/bindings/mfd/axp20x.txt | 87 ++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/axp20x.txtDocumentation/devicetree/bindings/mfd/axp20x.txt new file +0
-0
Documentation/devicetree/bindings/mfd/axp20x.txt line 8
Quoted 8 lines
Documentation/devicetree/bindings/mfd/axp20x.txt new file +8
-0@@ -0,0 +1,87 @@ +* axp20x device tree bindings + +The axp20x family current members :- +axp202 (x-powers) +axp209 (x-powers) + +Required properties: +- compatible : Should be "x-powers,axp20x" (for axp202 and axp209)
"Generic" compatibles are usually a bad thing, for several reasons, mostly because there's no way to actually differentiate the two without keeping adding DT properties (and hence, being unable to actually fix something or add a quirk for one single of these devices without having to modify the DT too.)
Please use the "real" compatibles.
Documentation/devicetree/bindings/mfd/axp20x.txt line 11
Quoted 3 lines
Documentation/devicetree/bindings/mfd/axp20x.txt new file +3
-0+- interrupt-controller : axp20x has its own internal IRQs +- #interrupt-cells : should be set to 1 +- interrupt-parent : The parent interrupt controller
Is this really required? It was not in your DTSI.
Documentation/devicetree/bindings/mfd/axp20x.txt line 13
Quoted 2 lines
Documentation/devicetree/bindings/mfd/axp20x.txt new file +2
-0+- interrupts : Specifies the list of interrupt lines which are handled by + the device in the parent controller's notation
Hmmm, I'm not sure what you mean here.
Documentation/devicetree/bindings/mfd/axp20x.txt line 14
Quoted 1 line
Documentation/devicetree/bindings/mfd/axp20x.txt new file +1
-0+- reg : Specifies base physical address and size of the registers
Base physical address? Isn't it a I2C device?
Documentation/devicetree/bindings/mfd/axp20x.txt line 22
Quoted 8 lines
Documentation/devicetree/bindings/mfd/axp20x.txt new file +8
-0+ +Sub-nodes +* regulators : Contain the regulator nodes. The regulators are bound using + their name as listed here: dcdc2, dcdc3, ldo1, ldo2, ldo3, + ldo4, ldo5. + The bindings details of individual regulator device can be found in: + Documentation/devicetree/bindings/regulator/regulator.txt with the + exception of:
I'm guessing this is where you differentiate between AXP202 and AXP209?
Documentation/devicetree/bindings/mfd/axp20x.txt line 25
Quoted 3 lines
Documentation/devicetree/bindings/mfd/axp20x.txt new file +3
-0+ + - dcdc-freq : defines the work frequency of DC-DC where + F=(1+dcdc-freq*5%)*1.5MHz
I'd very much prefer this DCDC frequency to be in Hz, or a similar unit, and let the driver do the conversion.
Documentation/devicetree/bindings/mfd/axp20x.txt line 32
Quoted 7 lines
Documentation/devicetree/bindings/mfd/axp20x.txt new file +7
-0+ +* axp20x-pek : Power Enable Key + - compatible : should be "x-powers,axp20x-pek" + - interrupts : two interrupt numbers with order defined by interrupt-names + (one irq number for rising transition of the power key, the + other one for falling transition) + - interrupt-names : should be "PEK_DBR" and "PEK_DBF"
Is this actually needed since you declare the resources in your driver?
Documentation/devicetree/bindings/mfd/axp20x.txt line 39
Quoted 7 lines
Documentation/devicetree/bindings/mfd/axp20x.txt new file +7
-0+ +Example: + +axp { + compatible = "x-powers,axp20x"; + interrupt-controller; + #interrupt-cells = <1>;
No reg property ?
Quoted 4 lines
Documentation/devicetree/bindings/mfd/axp20x.txt new file +4
-0+ + axp20x-pek { + compatible = "x-powers,axp20x-pek"; + interrupts = <33>, <34>;
Documentation/devicetree/bindings/mfd/axp20x.txt line 53
Quoted 10 lines
Documentation/devicetree/bindings/mfd/axp20x.txt new file +10
-0+ interrupt-names = "PEK_DBR", "PEK_DBF"; + }; + + regulators { + dcdc-freq = "8"; + + axp_dcdc2: dcdc2 { + regulator-min-microvolt = <700000>; + regulator-max-microvolt = <2275000>; + dcdc-workmode = <0>;
And what is this dcdc-workmode property about?
Quoted 37 lines
Documentation/devicetree/bindings/mfd/axp20x.txt new file +34
-0+ }; + + axp_dcdc3: dcdc3 { + regulator-min-microvolt = <700000>; + regulator-max-microvolt = <3500000>; + dcdc-workmode = <0>; + }; + + axp_ldo1: ldo1 { + regulator-min-microvolt = <1300000>; + regulator-max-microvolt = <1300000>; + }; + + axp_ldo2: ldo2 { + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3300000>; + }; + + axp_ldo3: ldo3 { + regulator-min-microvolt = <700000>; + regulator-max-microvolt = <3500000>; + }; + + axp_ldo4: ldo4 { + regulator-min-microvolt = <1250000>; + regulator-max-microvolt = <3300000>; + }; + + axp_ldo5: ldo5 { + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3300000>; + }; + }; +};Signature · 1 line
1.8.5.3
Thanks for working on this!
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140210/03fc1689/attachment.sig>
[linux-sunxi] Re: [PATCH 3/3] mfd: axp20x: Add bindings documentation
Quoted 33 lines · Maxime Ripard
Hi Carlo,
Quoted 15 lines · Carlo Caione
Bindings documentation for the axp20x driver. In this file also two sub-nodes (PEK and regulators) are documented.
Signed-off-by Carlo Caione <[email protected]>--- Documentation/devicetree/bindings/mfd/axp20x.txt | 87 ++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/axp20x.txtDocumentation/devicetree/bindings/mfd/axp20x.txt new file +0
-0Documentation/devicetree/bindings/mfd/axp20x.txt line 8
Quoted 8 lines
Documentation/devicetree/bindings/mfd/axp20x.txt new file +8
-0@@ -0,0 +1,87 @@ +* axp20x device tree bindings + +The axp20x family current members :- +axp202 (x-powers) +axp209 (x-powers) + +Required properties: +- compatible : Should be "x-powers,axp20x" (for axp202 and axp209)"Generic" compatibles are usually a bad thing, for several reasons, mostly because there's no way to actually differentiate the two without keeping adding DT properties (and hence, being unable to actually fix something or add a quirk for one single of these devices without having to modify the DT too.)
Quoted 1 line
Please use the "real" compatibles.
Ok
Quoted 5 lines
Documentation/devicetree/bindings/mfd/axp20x.txt line 11
Quoted 3 lines
Documentation/devicetree/bindings/mfd/axp20x.txt new file +3
-0+- interrupt-controller : axp20x has its own internal IRQs +- #interrupt-cells : should be set to 1 +- interrupt-parent : The parent interrupt controllerIs this really required? It was not in your DTSI.
It wasn't in my DTSI since it was supposed to be used by DTS importing this DTSI.
I'll fix it in v2.
Quoted 4 lines
Documentation/devicetree/bindings/mfd/axp20x.txt line 13
Quoted 2 lines
Documentation/devicetree/bindings/mfd/axp20x.txt new file +2
-0+- interrupts : Specifies the list of interrupt lines which are handled by + the device in the parent controller's notationHmmm, I'm not sure what you mean here.
It means that the notation used to indicate the interrupt for this device has to follow the notation of the parent controller (i.e. in terms of number of interrupt cells).
I'll rewrite the statement in v2.
Quoted 3 lines
Documentation/devicetree/bindings/mfd/axp20x.txt line 14
Quoted 1 line
Documentation/devicetree/bindings/mfd/axp20x.txt new file +1
-0+- reg : Specifies base physical address and size of the registersBase physical address? Isn't it a I2C device?
Right. cut&paste error.
Quoted 11 lines
Documentation/devicetree/bindings/mfd/axp20x.txt line 22
Quoted 8 lines
Documentation/devicetree/bindings/mfd/axp20x.txt new file +8
-0+ +Sub-nodes +* regulators : Contain the regulator nodes. The regulators are bound using + their name as listed here: dcdc2, dcdc3, ldo1, ldo2, ldo3, + ldo4, ldo5. + The bindings details of individual regulator device can be found in: + Documentation/devicetree/bindings/regulator/regulator.txt with the + exception of:I'm guessing this is where you differentiate between AXP202 and AXP209?
Not really. AXP202 and AXP209 have the same regulators (with the same constrains)
Quoted 6 lines
Documentation/devicetree/bindings/mfd/axp20x.txt line 25
Quoted 3 lines
Documentation/devicetree/bindings/mfd/axp20x.txt new file +3
-0+ + - dcdc-freq : defines the work frequency of DC-DC where + F=(1+dcdc-freq*5%)*1.5MHzI'd very much prefer this DCDC frequency to be in Hz, or a similar unit, and let the driver do the conversion.
Ok. Fix in v2.
Quoted 9 lines
Documentation/devicetree/bindings/mfd/axp20x.txt line 32
Quoted 7 lines
Documentation/devicetree/bindings/mfd/axp20x.txt new file +7
-0+ +* axp20x-pek : Power Enable Key + - compatible : should be "x-powers,axp20x-pek" + - interrupts : two interrupt numbers with order defined by interrupt-names + (one irq number for rising transition of the power key, the + other one for falling transition) + - interrupt-names : should be "PEK_DBR" and "PEK_DBF"Is this actually needed since you declare the resources in your driver?
Not needed.
Quoted 9 lines
Documentation/devicetree/bindings/mfd/axp20x.txt line 39
Quoted 7 lines
Documentation/devicetree/bindings/mfd/axp20x.txt new file +7
-0+ +Example: + +axp { + compatible = "x-powers,axp20x"; + interrupt-controller; + #interrupt-cells = <1>;No reg property ?
Also the reg property was supposed to be used in the DTS. I'll fix it.
Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/mfd/axp20x.txt new file +8
-0+ + axp20x-pek { + compatible = "x-powers,axp20x-pek"; + interrupts = <33>, <34>; + interrupt-names = "PEK_DBR", "PEK_DBF"; + }; + + regulators {
Quoted 8 lines
Documentation/devicetree/bindings/mfd/axp20x.txt line 53
Quoted 6 lines
Documentation/devicetree/bindings/mfd/axp20x.txt new file +6
-0+ dcdc-freq = "8"; + + axp_dcdc2: dcdc2 { + regulator-min-microvolt = <700000>; + regulator-max-microvolt = <2275000>; + dcdc-workmode = <0>;And what is this dcdc-workmode property about?
Oh. I missed that, sorry.
Quoted 31 lines
Quoted 31 lines
Documentation/devicetree/bindings/mfd/axp20x.txt new file +31
-0+ }; + + axp_dcdc3: dcdc3 { + regulator-min-microvolt = <700000>; + regulator-max-microvolt = <3500000>; + dcdc-workmode = <0>; + }; + + axp_ldo1: ldo1 { + regulator-min-microvolt = <1300000>; + regulator-max-microvolt = <1300000>; + }; + + axp_ldo2: ldo2 { + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3300000>; + }; + + axp_ldo3: ldo3 { + regulator-min-microvolt = <700000>; + regulator-max-microvolt = <3500000>; + }; + + axp_ldo4: ldo4 { + regulator-min-microvolt = <1250000>; + regulator-max-microvolt = <3300000>; + }; + + axp_ldo5: ldo5 { + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3300000>;
Quoted 8 lines
Quoted 6 lines
Documentation/devicetree/bindings/mfd/axp20x.txt new file +3
-1+ }; + }; +}; --1.8.5.3
Thanks for working on this!
Thank you,
Signature · 1 line
Carlo Caione
[linux-sunxi] Re: [PATCH 3/3] mfd: axp20x: Add bindings documentation
Quoted 11 lines · Carlo Caione
Quoted 10 lines
Documentation/devicetree/bindings/mfd/axp20x.txt line 22
Quoted 7 lines
Documentation/devicetree/bindings/mfd/axp20x.txt new file +7
-0+Sub-nodes +* regulators : Contain the regulator nodes. The regulators are bound using + their name as listed here: dcdc2, dcdc3, ldo1, ldo2, ldo3, + ldo4, ldo5. + The bindings details of individual regulator device can be found in: + Documentation/devicetree/bindings/regulator/regulator.txt with the + exception of:I'm guessing this is where you differentiate between AXP202 and AXP209?
Quoted 2 lines
Not really. AXP202 and AXP209 have the same regulators (with the same constrains)
Ok. What's the difference between the two then?
Thanks,
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140210/7fcfc338/attachment.sig>
[linux-sunxi] Re: [PATCH 3/3] mfd: axp20x: Add bindings documentation
Quoted 12 lines · Maxime Ripard
Quoted 11 lines · Carlo Caione
Quoted 10 lines
Documentation/devicetree/bindings/mfd/axp20x.txt line 22
Quoted 7 lines
Documentation/devicetree/bindings/mfd/axp20x.txt new file +7
-0+Sub-nodes +* regulators : Contain the regulator nodes. The regulators are bound using + their name as listed here: dcdc2, dcdc3, ldo1, ldo2, ldo3, + ldo4, ldo5. + The bindings details of individual regulator device can be found in: + Documentation/devicetree/bindings/regulator/regulator.txt with the + exception of:I'm guessing this is where you differentiate between AXP202 and AXP209?
Quoted 4 lines
Quoted 2 lines
Not really. AXP202 and AXP209 have the same regulators (with the same constrains)
Ok. What's the difference between the two then?
Honestly I have no idea. For what I have seen (core, PEK and regulators) AXP202 and AXP209 are identical.
Signature · 1 line
Carlo Caione
[linux-sunxi] Re: [PATCH 3/3] mfd: axp20x: Add bindings documentation
Quoted 6 lines · Carlo Caione
On Mon, Feb 10, 2014 at 11:01 PM, Maxime Ripard
Quoted 1 line
Ok. What's the difference between the two then?
Honestly I have no idea. For what I have seen (core, PEK and regulators) AXP202 and AXP209 are identical.
I'd guess something in the electrical or mechanical specs (eg, maximum
current draws or packaging which are often related anyway), it's quite
common to get multiple PMICs that are silicon identical but differently
packaged or binned.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140212/95bb7c52/attachment.sig>
PATCH 3/3 mfd: axp20x: Add bindings documentation
In reply to Carlo CaioneQuoted 2 lines · Carlo Caione
Bindings documentation for the axp20x driver. In this file also two sub-nodes (PEK and regulators) are documented.
You probably want to CC bindings to the maintianers for the relevant subsystes too.
Documentation/devicetree/bindings/mfd/axp20x.txt line 25
Quoted 2 lines
Documentation/devicetree/bindings/mfd/axp20x.txt new file +2
-0+ - dcdc-freq : defines the work frequency of DC-DC where + F=(1+dcdc-freq*5%)*1.5MHz
It sees a bit nicer to either have this be the frequency and work back
to the register setting or name it after the register field that gets
updated as a result. I'm also not sure what *5% means - I'm guessing
it's *0.05 but it'd be clearer to just write that.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140212/a4448312/attachment.sig>