Commit 1d2c25ed authored by John Crispin's avatar John Crispin Committed by Lee Jones

mfd: mt6397: Add support for different Slave types

Signed-off-by: default avatarJohn Crispin <blogic@openwrt.org>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
parent feec4799
...@@ -24,6 +24,9 @@ ...@@ -24,6 +24,9 @@
#define MT6397_RTC_BASE 0xe000 #define MT6397_RTC_BASE 0xe000
#define MT6397_RTC_SIZE 0x3e #define MT6397_RTC_SIZE 0x3e
#define MT6391_CID_CODE 0x91
#define MT6397_CID_CODE 0x97
static const struct resource mt6397_rtc_resources[] = { static const struct resource mt6397_rtc_resources[] = {
{ {
.start = MT6397_RTC_BASE, .start = MT6397_RTC_BASE,
...@@ -232,39 +235,60 @@ static SIMPLE_DEV_PM_OPS(mt6397_pm_ops, mt6397_irq_suspend, ...@@ -232,39 +235,60 @@ static SIMPLE_DEV_PM_OPS(mt6397_pm_ops, mt6397_irq_suspend,
static int mt6397_probe(struct platform_device *pdev) static int mt6397_probe(struct platform_device *pdev)
{ {
int ret; int ret;
struct mt6397_chip *mt6397; unsigned int id;
struct mt6397_chip *pmic;
mt6397 = devm_kzalloc(&pdev->dev, sizeof(*mt6397), GFP_KERNEL); pmic = devm_kzalloc(&pdev->dev, sizeof(*pmic), GFP_KERNEL);
if (!mt6397) if (!pmic)
return -ENOMEM; return -ENOMEM;
mt6397->dev = &pdev->dev; pmic->dev = &pdev->dev;
mt6397->int_con[0] = MT6397_INT_CON0;
mt6397->int_con[1] = MT6397_INT_CON1;
mt6397->int_status[0] = MT6397_INT_STATUS0;
mt6397->int_status[1] = MT6397_INT_STATUS1;
/* /*
* mt6397 MFD is child device of soc pmic wrapper. * mt6397 MFD is child device of soc pmic wrapper.
* Regmap is set from its parent. * Regmap is set from its parent.
*/ */
mt6397->regmap = dev_get_regmap(pdev->dev.parent, NULL); pmic->regmap = dev_get_regmap(pdev->dev.parent, NULL);
if (!mt6397->regmap) if (!pmic->regmap)
return -ENODEV; return -ENODEV;
platform_set_drvdata(pdev, mt6397); platform_set_drvdata(pdev, pmic);
ret = regmap_read(pmic->regmap, MT6397_CID, &id);
if (ret) {
dev_err(pmic->dev, "Failed to read chip id: %d\n", ret);
goto fail_irq;
}
switch (id & 0xff) {
case MT6397_CID_CODE:
case MT6391_CID_CODE:
pmic->int_con[0] = MT6397_INT_CON0;
pmic->int_con[1] = MT6397_INT_CON1;
pmic->int_status[0] = MT6397_INT_STATUS0;
pmic->int_status[1] = MT6397_INT_STATUS1;
ret = mfd_add_devices(&pdev->dev, -1, mt6397_devs,
ARRAY_SIZE(mt6397_devs), NULL, 0, NULL);
break;
default:
dev_err(&pdev->dev, "unsupported chip: %d\n", id);
ret = -ENODEV;
break;
}
mt6397->irq = platform_get_irq(pdev, 0); pmic->irq = platform_get_irq(pdev, 0);
if (mt6397->irq > 0) { if (pmic->irq > 0) {
ret = mt6397_irq_init(mt6397); ret = mt6397_irq_init(pmic);
if (ret) if (ret)
return ret; return ret;
} }
ret = mfd_add_devices(&pdev->dev, -1, mt6397_devs, fail_irq:
ARRAY_SIZE(mt6397_devs), NULL, 0, NULL); if (ret) {
if (ret) irq_domain_remove(pmic->irq_domain);
dev_err(&pdev->dev, "failed to add child devices: %d\n", ret); dev_err(&pdev->dev, "failed to add child devices: %d\n", ret);
}
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment