Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1509754

[PATCH 9/9] Input: wm97xx: add new AC97 bus support

From Robert Jarzmik <robert.jarzmik@free.fr>
Newsgroups linux.kernel
Subject [PATCH 9/9] Input: wm97xx: add new AC97 bus support
Date 2016-10-26 21:50 +0200
Message-ID <swCmZ-8eE-13@gated-at.bofh.it> (permalink)
References <swCmZ-8eE-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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>
---
 drivers/input/touchscreen/Kconfig       |  2 +-
 drivers/input/touchscreen/wm97xx-core.c | 56 ++++++++++++++++++++++++++++++++-
 2 files changed, 56 insertions(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index efca0133e266..7af06015e704 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -737,7 +737,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
diff --git a/drivers/input/touchscreen/wm97xx-core.c b/drivers/input/touchscreen/wm97xx-core.c
index 50a110e2988b..4d5c96a5ab04 100644
--- a/drivers/input/touchscreen/wm97xx-core.c
+++ b/drivers/input/touchscreen/wm97xx-core.c
@@ -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>
@@ -763,6 +764,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);
@@ -859,21 +893,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);
-- 
2.1.4

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/9] AC97 device/driver model revamp Robert Jarzmik <robert.jarzmik@free.fr> - 2016-10-26 21:50 +0200
  [PATCH 9/9] Input: wm97xx: add new AC97 bus support Robert Jarzmik <robert.jarzmik@free.fr> - 2016-10-26 21:50 +0200
    Re: [PATCH 9/9] Input: wm97xx: add new AC97 bus support Charles Keepax <ckeepax@opensource.wolfsonmicro.com> - 2016-10-27 11:20 +0200
  [PATCH 5/9] ASoC: pxa: switch to new ac97 bus support Robert Jarzmik <robert.jarzmik@free.fr> - 2016-10-26 21:50 +0200
    Re: [PATCH 5/9] ASoC: pxa: switch to new ac97 bus support Robert Jarzmik <robert.jarzmik@free.fr> - 2016-10-31 09:40 +0100
      Re: [PATCH 5/9] ASoC: pxa: switch to new ac97 bus support Robert Jarzmik <robert.jarzmik@free.fr> - 2016-11-01 21:00 +0100
  [PATCH 1/9] ALSA: ac97: split out the generic ac97 registers Robert Jarzmik <robert.jarzmik@free.fr> - 2016-10-26 21:50 +0200
  [PATCH 2/9] ALSA: ac97: add an ac97 bus Robert Jarzmik <robert.jarzmik@free.fr> - 2016-10-26 21:50 +0200
    Re: [alsa-devel] [PATCH 2/9] ALSA: ac97: add an ac97 bus Lars-Peter Clausen <lars@metafoo.de> - 2016-11-08 14:40 +0100
      Re: [alsa-devel] [PATCH 2/9] ALSA: ac97: add an ac97 bus Robert Jarzmik <robert.jarzmik@free.fr> - 2016-11-08 22:30 +0100
        Re: [alsa-devel] [PATCH 2/9] ALSA: ac97: add an ac97 bus Lars-Peter Clausen <lars@metafoo.de> - 2016-11-09 14:20 +0100
          Re: [alsa-devel] [PATCH 2/9] ALSA: ac97: add an ac97 bus Robert Jarzmik <robert.jarzmik@free.fr> - 2016-11-09 22:30 +0100
            Re: [alsa-devel] [PATCH 2/9] ALSA: ac97: add an ac97 bus Lars-Peter Clausen <lars@metafoo.de> - 2016-11-10 12:40 +0100
  [PATCH 3/9] ASoC: add new ac97 bus support Robert Jarzmik <robert.jarzmik@free.fr> - 2016-10-26 21:50 +0200
  [PATCH 4/9] ASoC: wm9713: add ac97 new bus support Robert Jarzmik <robert.jarzmik@free.fr> - 2016-10-26 22:00 +0200
    Re: [PATCH 4/9] ASoC: wm9713: add ac97 new bus support Charles Keepax <ckeepax@opensource.wolfsonmicro.com> - 2016-10-27 16:00 +0200
  [PATCH 7/9] Input: wm97xx: split out touchscreen registering Robert Jarzmik <robert.jarzmik@free.fr> - 2016-10-26 22:20 +0200
    Re: [PATCH 7/9] Input: wm97xx: split out touchscreen registering Charles Keepax <ckeepax@opensource.wolfsonmicro.com> - 2016-10-27 16:10 +0200
      Re: [PATCH 7/9] Input: wm97xx: split out touchscreen registering Robert Jarzmik <robert.jarzmik@free.fr> - 2016-10-27 21:30 +0200
  [PATCH 8/9] mfd: wm97xx-core: core support for wm97xx Codec Robert Jarzmik <robert.jarzmik@free.fr> - 2016-10-26 22:20 +0200
    Re: [PATCH 8/9] mfd: wm97xx-core: core support for wm97xx Codec Charles Keepax <ckeepax@opensource.wolfsonmicro.com> - 2016-10-27 11:20 +0200

csiph-web