1 From 1ef53a11f0c282008aa572eb7c97fa1e79621ea3 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/81] 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 --- a/drivers/mfd/mt6397-core.c
12 +++ b/drivers/mfd/mt6397-core.c
14 #define MT6397_RTC_BASE 0xe000
15 #define MT6397_RTC_SIZE 0x3e
17 +#define MT6391_CID_CODE 0x91
18 +#define MT6397_CID_CODE 0x97
20 static const struct resource mt6397_rtc_resources[] = {
22 .start = MT6397_RTC_BASE,
23 @@ -232,39 +235,60 @@ static SIMPLE_DEV_PM_OPS(mt6397_pm_ops,
24 static int mt6397_probe(struct platform_device *pdev)
27 - struct mt6397_chip *mt6397;
29 + struct mt6397_chip *pmic;
31 - mt6397 = devm_kzalloc(&pdev->dev, sizeof(*mt6397), GFP_KERNEL);
33 + pmic = devm_kzalloc(&pdev->dev, sizeof(*pmic), GFP_KERNEL);
37 - mt6397->dev = &pdev->dev;
38 - mt6397->int_con[0] = MT6397_INT_CON0;
39 - mt6397->int_con[1] = MT6397_INT_CON1;
40 - mt6397->int_status[0] = MT6397_INT_STATUS0;
41 - mt6397->int_status[1] = MT6397_INT_STATUS1;
42 + pmic->dev = &pdev->dev;
45 * mt6397 MFD is child device of soc pmic wrapper.
46 * Regmap is set from its parent.
48 - mt6397->regmap = dev_get_regmap(pdev->dev.parent, NULL);
49 - if (!mt6397->regmap)
50 + pmic->regmap = dev_get_regmap(pdev->dev.parent, NULL);
54 - platform_set_drvdata(pdev, mt6397);
55 + platform_set_drvdata(pdev, pmic);
57 + ret = regmap_read(pmic->regmap, MT6397_CID, &id);
59 + dev_err(pmic->dev, "Failed to read chip id: %d\n", ret);
63 + switch (id & 0xff) {
64 + case MT6397_CID_CODE:
65 + case MT6391_CID_CODE:
66 + pmic->int_con[0] = MT6397_INT_CON0;
67 + pmic->int_con[1] = MT6397_INT_CON1;
68 + pmic->int_status[0] = MT6397_INT_STATUS0;
69 + pmic->int_status[1] = MT6397_INT_STATUS1;
70 + ret = mfd_add_devices(&pdev->dev, -1, mt6397_devs,
71 + ARRAY_SIZE(mt6397_devs), NULL, 0, NULL);
75 + dev_err(&pdev->dev, "unsupported chip: %d\n", id);
80 - mt6397->irq = platform_get_irq(pdev, 0);
81 - if (mt6397->irq > 0) {
82 - ret = mt6397_irq_init(mt6397);
83 + pmic->irq = platform_get_irq(pdev, 0);
84 + if (pmic->irq > 0) {
85 + ret = mt6397_irq_init(pmic);
90 - ret = mfd_add_devices(&pdev->dev, -1, mt6397_devs,
91 - ARRAY_SIZE(mt6397_devs), NULL, 0, NULL);
95 + irq_domain_remove(pmic->irq_domain);
96 dev_err(&pdev->dev, "failed to add child devices: %d\n", ret);