1 From c6fab1574939f968257029dd75da51ab266081c9 Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Fri, 8 Jan 2016 08:41:52 +0100
4 Subject: [PATCH 44/66] mfd: mt6397: add support for different Slave types
6 Signed-off-by: John Crispin <blogic@openwrt.org>
8 drivers/mfd/mt6397-core.c | 58 ++++++++++++++++++++++++++++++++-------------
9 1 file changed, 41 insertions(+), 17 deletions(-)
11 diff --git a/drivers/mfd/mt6397-core.c b/drivers/mfd/mt6397-core.c
12 index 75ad0fe..aa91606 100644
13 --- a/drivers/mfd/mt6397-core.c
14 +++ b/drivers/mfd/mt6397-core.c
16 #define MT6397_RTC_BASE 0xe000
17 #define MT6397_RTC_SIZE 0x3e
19 +#define MT6391_CID_CODE 0x91
20 +#define MT6397_CID_CODE 0x97
22 static const struct resource mt6397_rtc_resources[] = {
24 .start = MT6397_RTC_BASE,
25 @@ -232,39 +235,60 @@ static SIMPLE_DEV_PM_OPS(mt6397_pm_ops, mt6397_irq_suspend,
26 static int mt6397_probe(struct platform_device *pdev)
29 - struct mt6397_chip *mt6397;
31 + struct mt6397_chip *pmic;
33 - mt6397 = devm_kzalloc(&pdev->dev, sizeof(*mt6397), GFP_KERNEL);
35 + pmic = devm_kzalloc(&pdev->dev, sizeof(*pmic), GFP_KERNEL);
39 - mt6397->dev = &pdev->dev;
40 - mt6397->int_con[0] = MT6397_INT_CON0;
41 - mt6397->int_con[1] = MT6397_INT_CON1;
42 - mt6397->int_status[0] = MT6397_INT_STATUS0;
43 - mt6397->int_status[1] = MT6397_INT_STATUS1;
44 + pmic->dev = &pdev->dev;
47 * mt6397 MFD is child device of soc pmic wrapper.
48 * Regmap is set from its parent.
50 - mt6397->regmap = dev_get_regmap(pdev->dev.parent, NULL);
51 - if (!mt6397->regmap)
52 + pmic->regmap = dev_get_regmap(pdev->dev.parent, NULL);
56 - platform_set_drvdata(pdev, mt6397);
57 + platform_set_drvdata(pdev, pmic);
59 + ret = regmap_read(pmic->regmap, MT6397_CID, &id);
61 + dev_err(pmic->dev, "Failed to read chip id: %d\n", ret);
65 + switch (id & 0xff) {
66 + case MT6397_CID_CODE:
67 + case MT6391_CID_CODE:
68 + pmic->int_con[0] = MT6397_INT_CON0;
69 + pmic->int_con[1] = MT6397_INT_CON1;
70 + pmic->int_status[0] = MT6397_INT_STATUS0;
71 + pmic->int_status[1] = MT6397_INT_STATUS1;
72 + ret = mfd_add_devices(&pdev->dev, -1, mt6397_devs,
73 + ARRAY_SIZE(mt6397_devs), NULL, 0, NULL);
77 + dev_err(&pdev->dev, "unsupported chip: %d\n", id);
82 - mt6397->irq = platform_get_irq(pdev, 0);
83 - if (mt6397->irq > 0) {
84 - ret = mt6397_irq_init(mt6397);
85 + pmic->irq = platform_get_irq(pdev, 0);
86 + if (pmic->irq > 0) {
87 + ret = mt6397_irq_init(pmic);
92 - ret = mfd_add_devices(&pdev->dev, -1, mt6397_devs,
93 - ARRAY_SIZE(mt6397_devs), NULL, 0, NULL);
97 + irq_domain_remove(pmic->irq_domain);
98 dev_err(&pdev->dev, "failed to add child devices: %d\n", ret);