Input: wm97xx: add new AC97 bus support
authorRobert Jarzmik <robert.jarzmik@free.fr>
Wed, 13 Sep 2017 19:37:18 +0000 (21:37 +0200)
committerMark Brown <broonie@kernel.org>
Tue, 19 Sep 2017 16:07:28 +0000 (17:07 +0100)
This adds support for the new AC97 bus code, which discovers the devices
rather than uses platform data.

As part of this discovery, it enables a multi-function device wm97xx,
which supports touchscreen, battery, ADC and an audio codec. This patch
adds the code to bind the touchscreen "cell" as the touchscreen driver.

This was tested on the pxa architecture with a pxa270 + wm9713 + the
mioa701 touchscreen.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/input/touchscreen/Kconfig
drivers/input/touchscreen/wm97xx-core.c

index 64b30fe273fd7ba17312402c0efc9e81b77e94bb..176b1a74b2b727acf39fd89963a0be070688d75c 100644 (file)
@@ -727,7 +727,7 @@ config TOUCHSCREEN_WM831X
 
 config TOUCHSCREEN_WM97XX
        tristate "Support for WM97xx AC97 touchscreen controllers"
-       depends on AC97_BUS
+       depends on AC97_BUS || AC97_BUS_NEW
        help
          Say Y here if you have a Wolfson Microelectronics WM97xx
          touchscreen connected to your system. Note that this option
index 39869ffdc4fa11a0ab37fea386d55feb5289777e..fd714ee881f73d897b6d9150697f355bc4dd7f6a 100644 (file)
@@ -44,6 +44,7 @@
 #include <linux/pm.h>
 #include <linux/interrupt.h>
 #include <linux/bitops.h>
+#include <linux/mfd/wm97xx.h>
 #include <linux/workqueue.h>
 #include <linux/wm97xx.h>
 #include <linux/uaccess.h>
@@ -766,6 +767,39 @@ static int wm97xx_remove(struct device *dev)
        return 0;
 }
 
+static int wm97xx_mfd_probe(struct platform_device *pdev)
+{
+       struct wm97xx *wm;
+       struct wm97xx_platform_data *mfd_pdata = dev_get_platdata(&pdev->dev);
+       int ret;
+
+       wm = devm_kzalloc(&pdev->dev, sizeof(struct wm97xx), GFP_KERNEL);
+       if (!wm)
+               return -ENOMEM;
+
+       wm->dev = &pdev->dev;
+       wm->ac97 = mfd_pdata->ac97;
+
+       ret =  _wm97xx_probe(wm);
+       if (ret)
+               return ret;
+
+       ret = wm97xx_add_battery(wm, mfd_pdata->batt_pdata);
+       if (ret < 0)
+               goto batt_err;
+
+       return ret;
+
+batt_err:
+       wm97xx_unregister_touch(wm);
+       return ret;
+}
+
+static int wm97xx_mfd_remove(struct platform_device *pdev)
+{
+       return wm97xx_remove(&pdev->dev);
+}
+
 static int __maybe_unused wm97xx_suspend(struct device *dev)
 {
        struct wm97xx *wm = dev_get_drvdata(dev);
@@ -862,21 +896,41 @@ EXPORT_SYMBOL_GPL(wm97xx_unregister_mach_ops);
 
 static struct device_driver wm97xx_driver = {
        .name =         "wm97xx-ts",
+#ifdef CONFIG_AC97_BUS
        .bus =          &ac97_bus_type,
+#endif
        .owner =        THIS_MODULE,
        .probe =        wm97xx_probe,
        .remove =       wm97xx_remove,
        .pm =           &wm97xx_pm_ops,
 };
 
+static struct platform_driver wm97xx_mfd_driver = {
+       .driver = {
+               .name =         "wm97xx-ts",
+               .pm =           &wm97xx_pm_ops,
+       },
+       .probe =        wm97xx_mfd_probe,
+       .remove =       wm97xx_mfd_remove,
+};
+
 static int __init wm97xx_init(void)
 {
-       return driver_register(&wm97xx_driver);
+       int ret;
+
+       ret = platform_driver_register(&wm97xx_mfd_driver);
+       if (ret)
+               return ret;
+
+       if (IS_BUILTIN(CONFIG_AC97_BUS))
+               ret =  driver_register(&wm97xx_driver);
+       return ret;
 }
 
 static void __exit wm97xx_exit(void)
 {
        driver_unregister(&wm97xx_driver);
+       platform_driver_unregister(&wm97xx_mfd_driver);
 }
 
 module_init(wm97xx_init);