Skip to contentSkip to conversation

mfd: Add support for Merrifield Basin Cove PMIC

PATCH Superseded Andy Shevchenko 2 participants 7 messages Jun 12, 2019 – Jul 4, 2019

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 mfd: Add support for Merrifield Basin Cove PMIC

Add an MFD driver for Intel Merrifield Basin Cove PMIC.

---
- updated copyright year to be 2019
- rebased on top of latest vanilla rc

 drivers/mfd/Kconfig                      |  11 ++
 drivers/mfd/Makefile                     |   1 +
 drivers/mfd/intel_soc_pmic_mrfld.c       | 157 +++++++++++++++++++++++
 include/linux/mfd/intel_soc_pmic_mrfld.h |  81 ++++++++++++
 4 files changed, 250 insertions(+)
 create mode 100644 drivers/mfd/intel_soc_pmic_mrfld.c
 create mode 100644 include/linux/mfd/intel_soc_pmic_mrfld.h
drivers/mfd/Kconfig +11 -0
index a17d275bf1d4..466dfede2e63 100644
@@ -583,6 +583,17 @@ config INTEL_SOC_PMIC_CHTDC_TI
 	  Select this option for supporting Dollar Cove (TI version) PMIC
 	  device that is found on some Intel Cherry Trail systems.
 
+config INTEL_SOC_PMIC_MRFLD
+	tristate "Support for Intel Merrifield Basin Cove PMIC"
+	depends on GPIOLIB
+	depends on ACPI
+	depends on INTEL_SCU_IPC
+	select MFD_CORE
+	select REGMAP_IRQ
+	help
+	  Select this option for supporting Basin Cove PMIC device
+	  that is found on Intel Merrifield systems.
+
 config MFD_INTEL_LPSS
 	tristate
 	select COMMON_CLK
drivers/mfd/Makefile +1 -0
index 52b1a90ff515..2f4927819a14 100644
@@ -235,6 +235,7 @@ obj-$(CONFIG_INTEL_SOC_PMIC)	+= intel-soc-pmic.o
 obj-$(CONFIG_INTEL_SOC_PMIC_BXTWC)	+= intel_soc_pmic_bxtwc.o
 obj-$(CONFIG_INTEL_SOC_PMIC_CHTWC)	+= intel_soc_pmic_chtwc.o
 obj-$(CONFIG_INTEL_SOC_PMIC_CHTDC_TI)	+= intel_soc_pmic_chtdc_ti.o
+obj-$(CONFIG_INTEL_SOC_PMIC_MRFLD)	+= intel_soc_pmic_mrfld.o
 obj-$(CONFIG_MFD_MT6397)	+= mt6397-core.o
 
 obj-$(CONFIG_MFD_ALTERA_A10SR)	+= altera-a10sr.o
drivers/mfd/intel_soc_pmic_mrfld.c new file +157 -0

157 lines not on this page · raw message

include/linux/mfd/intel_soc_pmic_mrfld.h new file +81 -0

81 lines not on this page · raw message

Signature · 1 line
2.20.1
#1 lore raw
Quoted 14 lines · Andy Shevchenko

Add an MFD driver for Intel Merrifield Basin Cove PMIC.

---
- updated copyright year to be 2019
- rebased on top of latest vanilla rc

 drivers/mfd/Kconfig                      |  11 ++
 drivers/mfd/Makefile                     |   1 +
 drivers/mfd/intel_soc_pmic_mrfld.c       | 157 +++++++++++++++++++++++
 include/linux/mfd/intel_soc_pmic_mrfld.h |  81 ++++++++++++
 4 files changed, 250 insertions(+)
 create mode 100644 drivers/mfd/intel_soc_pmic_mrfld.c
 create mode 100644 include/linux/mfd/intel_soc_pmic_mrfld.h

[...]

Quoted 10 lines
drivers/mfd/intel_soc_pmic_mrfld.c new file +10 -0
+static int bcove_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct intel_soc_pmic *pmic;
+	unsigned int i;
+	int ret;
+
+	pmic = devm_kzalloc(dev, sizeof(*pmic), GFP_KERNEL);
+	if (!pmic)
+		return -ENOMEM;

drivers/mfd/intel_soc_pmic_mrfld.c line 128

Quoted 10 lines
drivers/mfd/intel_soc_pmic_mrfld.c new file +10 -0
+
+	platform_set_drvdata(pdev, pmic);
+	pmic->dev = &pdev->dev;
+
+	pmic->regmap = devm_regmap_init(dev, NULL, pmic, &bcove_regmap_config);
+	if (IS_ERR(pmic->regmap))
+		return PTR_ERR(pmic->regmap);
+
+	for (i = 0; i < ARRAY_SIZE(irq_level2_resources); i++) {
+		ret = platform_get_irq(pdev, i);

If you already know the order, define the children's device IDs in the parent's shared header ('intel_soc_pmic_mrfld.h'?) and retreive them like:

  platform_get_irq(pdev->parent, <SUITABLE_DEFINED_ID>);

Then you can skip all of this platform device -> platform device hoop jumping.

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#2 lore raw
Quoted 44 lines · Lee Jones
Quoted 14 lines · Andy Shevchenko

Add an MFD driver for Intel Merrifield Basin Cove PMIC.

---
- updated copyright year to be 2019
- rebased on top of latest vanilla rc

 drivers/mfd/Kconfig                      |  11 ++
 drivers/mfd/Makefile                     |   1 +
 drivers/mfd/intel_soc_pmic_mrfld.c       | 157 +++++++++++++++++++++++
 include/linux/mfd/intel_soc_pmic_mrfld.h |  81 ++++++++++++
 4 files changed, 250 insertions(+)
 create mode 100644 drivers/mfd/intel_soc_pmic_mrfld.c
 create mode 100644 include/linux/mfd/intel_soc_pmic_mrfld.h

[...]

Quoted 10 lines
drivers/mfd/intel_soc_pmic_mrfld.c new file +10 -0
+static int bcove_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct intel_soc_pmic *pmic;
+	unsigned int i;
+	int ret;
+
+	pmic = devm_kzalloc(dev, sizeof(*pmic), GFP_KERNEL);
+	if (!pmic)
+		return -ENOMEM;

drivers/mfd/intel_soc_pmic_mrfld.c line 128

Quoted 10 lines
drivers/mfd/intel_soc_pmic_mrfld.c new file +10 -0
+
+	platform_set_drvdata(pdev, pmic);
+	pmic->dev = &pdev->dev;
+
+	pmic->regmap = devm_regmap_init(dev, NULL, pmic, &bcove_regmap_config);
+	if (IS_ERR(pmic->regmap))
+		return PTR_ERR(pmic->regmap);
+
+	for (i = 0; i < ARRAY_SIZE(irq_level2_resources); i++) {
+		ret = platform_get_irq(pdev, i);

If you already know the order, define the children's device IDs in the parent's shared header ('intel_soc_pmic_mrfld.h'?) and retreive them like:

Quoted 4 lines
  platform_get_irq(pdev->parent, <SUITABLE_DEFINED_ID>);

Then you can skip all of this platform device -> platform device hoop jumping.

The idea of MFD is to get children to be parent agnostic (at least to some extent). What you are proposing here seems like disadvantage from MFD philosophy. No?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw
Quoted 45 lines · Andy Shevchenko
Quoted 44 lines · Lee Jones
Quoted 14 lines · Andy Shevchenko

Add an MFD driver for Intel Merrifield Basin Cove PMIC.

---
- updated copyright year to be 2019
- rebased on top of latest vanilla rc

 drivers/mfd/Kconfig                      |  11 ++
 drivers/mfd/Makefile                     |   1 +
 drivers/mfd/intel_soc_pmic_mrfld.c       | 157 +++++++++++++++++++++++
 include/linux/mfd/intel_soc_pmic_mrfld.h |  81 ++++++++++++
 4 files changed, 250 insertions(+)
 create mode 100644 drivers/mfd/intel_soc_pmic_mrfld.c
 create mode 100644 include/linux/mfd/intel_soc_pmic_mrfld.h

[...]

Quoted 10 lines
drivers/mfd/intel_soc_pmic_mrfld.c new file +10 -0
+static int bcove_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct intel_soc_pmic *pmic;
+	unsigned int i;
+	int ret;
+
+	pmic = devm_kzalloc(dev, sizeof(*pmic), GFP_KERNEL);
+	if (!pmic)
+		return -ENOMEM;

drivers/mfd/intel_soc_pmic_mrfld.c line 128

Quoted 10 lines
drivers/mfd/intel_soc_pmic_mrfld.c new file +10 -0
+
+	platform_set_drvdata(pdev, pmic);
+	pmic->dev = &pdev->dev;
+
+	pmic->regmap = devm_regmap_init(dev, NULL, pmic, &bcove_regmap_config);
+	if (IS_ERR(pmic->regmap))
+		return PTR_ERR(pmic->regmap);
+
+	for (i = 0; i < ARRAY_SIZE(irq_level2_resources); i++) {
+		ret = platform_get_irq(pdev, i);

If you already know the order, define the children's device IDs in the parent's shared header ('intel_soc_pmic_mrfld.h'?) and retreive them like:

Quoted 8 lines
Quoted 4 lines
  platform_get_irq(pdev->parent, <SUITABLE_DEFINED_ID>);

Then you can skip all of this platform device -> platform device hoop jumping.

The idea of MFD is to get children to be parent agnostic (at least to some extent). What you are proposing here seems like disadvantage from MFD philosophy. No?

Not at all. The idea of MFD is to split up support for monolithic h/w such that they can be handled properly by their appropriate subsystems, and by extension, maintained by the associated subject matter experts.

Children are often aware of their parents (some siblings are even aware of each other!), and many expect and depend on the data-sets provided by their parents.

For instance (this example may come to bite me in the behind, but), taken from this very patch, where is this consumed?

platform_set_drvdata(pdev, pmic);

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#4 lore raw
Quoted 22 lines · Lee Jones
Quoted 12 lines · Andy Shevchenko
Quoted 11 lines · Lee Jones

drivers/mfd/intel_soc_pmic_mrfld.c line 128

Quoted 4 lines · Andy Shevchenko

Add an MFD driver for Intel Merrifield Basin Cove PMIC.

drivers/mfd/intel_soc_pmic_mrfld.c new file +2 -0
+	for (i = 0; i < ARRAY_SIZE(irq_level2_resources); i++) {
+		ret = platform_get_irq(pdev, i);

If you already know the order, define the children's device IDs in the parent's shared header ('intel_soc_pmic_mrfld.h'?) and retreive them like:

Quoted 8 lines
Quoted 4 lines
  platform_get_irq(pdev->parent, <SUITABLE_DEFINED_ID>);

Then you can skip all of this platform device -> platform device hoop jumping.

The idea of MFD is to get children to be parent agnostic (at least to some extent). What you are proposing here seems like disadvantage from MFD philosophy. No?

Quoted 8 lines

Not at all. The idea of MFD is to split up support for monolithic h/w such that they can be handled properly by their appropriate subsystems, and by extension, maintained by the associated subject matter experts.

Children are often aware of their parents (some siblings are even aware of each other!), and many expect and depend on the data-sets provided by their parents.

Yes, that's true and that's why I put wording "to some extent" above.

Quoted 4 lines

For instance (this example may come to bite me in the behind, but), taken from this very patch, where is this consumed?

platform_set_drvdata(pdev, pmic);

Yes. It's used in children. BUT. This structure covers several PMIC chips and the children driver doesn't know which generation / version of PMIC is serving.

What you are proposing with the change is to strictly link the children driver to PMIC gen X ver Y, while above example doesn't do that.

So, I'm not convinced it's a good change to have.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#5 lore raw
Quoted 37 lines · Andy Shevchenko
Quoted 22 lines · Lee Jones
Quoted 12 lines · Andy Shevchenko
Quoted 11 lines · Lee Jones

drivers/mfd/intel_soc_pmic_mrfld.c line 128

Quoted 4 lines · Andy Shevchenko

Add an MFD driver for Intel Merrifield Basin Cove PMIC.

drivers/mfd/intel_soc_pmic_mrfld.c new file +2 -0
+	for (i = 0; i < ARRAY_SIZE(irq_level2_resources); i++) {
+		ret = platform_get_irq(pdev, i);

If you already know the order, define the children's device IDs in the parent's shared header ('intel_soc_pmic_mrfld.h'?) and retreive them like:

Quoted 8 lines
Quoted 4 lines
  platform_get_irq(pdev->parent, <SUITABLE_DEFINED_ID>);

Then you can skip all of this platform device -> platform device hoop jumping.

The idea of MFD is to get children to be parent agnostic (at least to some extent). What you are proposing here seems like disadvantage from MFD philosophy. No?

Quoted 8 lines

Not at all. The idea of MFD is to split up support for monolithic h/w such that they can be handled properly by their appropriate subsystems, and by extension, maintained by the associated subject matter experts.

Children are often aware of their parents (some siblings are even aware of each other!), and many expect and depend on the data-sets provided by their parents.

Yes, that's true and that's why I put wording "to some extent" above.

Quoted 3 lines

For instance (this example may come to bite me in the behind, but), taken from this very patch, where is this consumed?

Quoted 7 lines
Quoted 1 line

platform_set_drvdata(pdev, pmic);

Yes. It's used in children. BUT. This structure covers several PMIC chips and the children driver doesn't know which generation / version of PMIC is serving.

What you are proposing with the change is to strictly link the children driver to PMIC gen X ver Y, while above example doesn't do that.

Well that is a different argument. :)

I still don't really like the idea of sucking one set of platform data just to place in another. The implementation even looks hacky.

What if you were to provide the child driver with its IRQ index? Perhaps via platform data?

Quoted 1 line

So, I'm not convinced it's a good change to have.

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#6 lore raw
Quoted 44 lines · Lee Jones
Quoted 42 lines · Andy Shevchenko
Quoted 22 lines · Lee Jones
Quoted 12 lines · Andy Shevchenko
Quoted 11 lines · Lee Jones

drivers/mfd/intel_soc_pmic_mrfld.c line 128

Quoted 4 lines · Andy Shevchenko

Add an MFD driver for Intel Merrifield Basin Cove PMIC.

drivers/mfd/intel_soc_pmic_mrfld.c new file +2 -0
+	for (i = 0; i < ARRAY_SIZE(irq_level2_resources); i++) {
+		ret = platform_get_irq(pdev, i);

If you already know the order, define the children's device IDs in the parent's shared header ('intel_soc_pmic_mrfld.h'?) and retreive them like:

Quoted 8 lines
Quoted 4 lines
  platform_get_irq(pdev->parent, <SUITABLE_DEFINED_ID>);

Then you can skip all of this platform device -> platform device hoop jumping.

The idea of MFD is to get children to be parent agnostic (at least to some extent). What you are proposing here seems like disadvantage from MFD philosophy. No?

Quoted 8 lines

Not at all. The idea of MFD is to split up support for monolithic h/w such that they can be handled properly by their appropriate subsystems, and by extension, maintained by the associated subject matter experts.

Children are often aware of their parents (some siblings are even aware of each other!), and many expect and depend on the data-sets provided by their parents.

Yes, that's true and that's why I put wording "to some extent" above.

Quoted 4 lines

For instance (this example may come to bite me in the behind, but), taken from this very patch, where is this consumed?

platform_set_drvdata(pdev, pmic);

Yes. It's used in children. BUT. This structure covers several PMIC chips and the children driver doesn't know which generation / version of PMIC is serving.

Quoted 7 lines
Quoted 2 lines

What you are proposing with the change is to strictly link the children driver to PMIC gen X ver Y, while above example doesn't do that.

Well that is a different argument. :)

I still don't really like the idea of sucking one set of platform data just to place in another. The implementation even looks hacky.

To me it looks straight forward. We get a description of MFD and split it accordingly. Look at the rest of Intel PMIC drivers, they are built on the same principles.

"Thanks" to firmware here, that does more, than on other PMICs, that's why we have several IRQ resources, but from hardware point of view it's still an MFD.

Quoted 2 lines

What if you were to provide the child driver with its IRQ index? Perhaps via platform data?

It seems some people would like to bring up Shady Cove PMIC support in the future, which seems to behave in a similar way, while the (most of the) drivers can be re-used.

So, for me it will look like a hack in each of PMIC driver to have additional platform data for whatever can be passed using well-established facilities, like device resources.

Quoted 1 line
Quoted 1 line

So, I'm not convinced it's a good change to have.

Signature · 2 lines
With Best Regards,
Andy Shevchenko