diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index f9d7cd3be6a83fed5a8484c14be15db1c1056d15..f045f39447bccbbac8edd405a1c545febfe32362 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig @@ -827,7 +827,7 @@ config TOUCHSCREEN_TI_AM335X_TSC config TOUCHSCREEN_UCB1400 tristate "Philips UCB1400 touchscreen" - depends on AC97_BUS + depends on ( AC97_BUS || AC97_BUS_NEW ) depends on UCB1400_CORE help This enables support for the Philips UCB1400 touchscreen interface. diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index b2e53547522db0ea054b5793f75bcf82c82d4206..79875302973c9a9417a6458be12c2896cded2344 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -1065,7 +1065,7 @@ config PCF50633_GPIO config UCB1400_CORE tristate "Philips UCB1400 Core driver" - depends on AC97_BUS + depends on ( AC97_BUS || AC97_BUS_NEW ) depends on GPIOLIB help This enables support for the Philips UCB1400 core functions. diff --git a/drivers/mfd/ucb1400_core.c b/drivers/mfd/ucb1400_core.c index 8c3832a58ef674a2e30b214735112e4cb3ab3d87..8e9e65a43d70376786bb7f61678e4ba9b90e391c 100644 --- a/drivers/mfd/ucb1400_core.c +++ b/drivers/mfd/ucb1400_core.c @@ -21,6 +21,15 @@ #include <linux/sched.h> #include <linux/slab.h> #include <linux/ucb1400.h> +#include <linux/of_irq.h> + +#ifdef CONFIG_AC97_BUS_NEW +#include <sound/ac97/codec.h> +#include <sound/ac97/compat.h> +#endif + +#define UCB1400_VENDOR_ID 0x50534304 +#define UCB1400_VENDOR_ID_MASK 0xffffffff unsigned int ucb1400_adc_read(struct snd_ac97 *ac97, u16 adc_channel, int adcsync) @@ -42,19 +51,26 @@ unsigned int ucb1400_adc_read(struct snd_ac97 *ac97, u16 adc_channel, } EXPORT_SYMBOL_GPL(ucb1400_adc_read); +#ifdef CONFIG_AC97_BUS_NEW +static int ucb1400_core_probe(struct ac97_codec_device *adev) +{ + struct device * dev = ac97_codec_dev2dev(adev); + struct ucb1400_pdata *pdata = snd_ac97_codec_get_platdata(adev); +#else static int ucb1400_core_probe(struct device *dev) { + struct ucb1400_pdata *pdata = dev_get_platdata(dev); +#endif int err; struct ucb1400 *ucb; struct ucb1400_ts ucb_ts; struct ucb1400_gpio ucb_gpio; struct snd_ac97 *ac97; - struct ucb1400_pdata *pdata = dev_get_platdata(dev); memset(&ucb_ts, 0, sizeof(ucb_ts)); memset(&ucb_gpio, 0, sizeof(ucb_gpio)); - ucb = kzalloc(sizeof(struct ucb1400), GFP_KERNEL); + ucb = devm_kzalloc(dev, sizeof(struct ucb1400), GFP_KERNEL); if (!ucb) { err = -ENOMEM; goto err; @@ -62,7 +78,15 @@ static int ucb1400_core_probe(struct device *dev) dev_set_drvdata(dev, ucb); +#ifdef CONFIG_AC97_BUS_NEW + ac97 = snd_ac97_compat_alloc(adev); +#else ac97 = to_ac97_t(dev); +#endif + if (IS_ERR(ac97)){ + err = PTR_ERR(ac97); + goto err; + } ucb_ts.id = ucb1400_reg_read(ac97, UCB_ID); if (ucb_ts.id != UCB_ID_1400) { @@ -93,10 +117,13 @@ static int ucb1400_core_probe(struct device *dev) /* TOUCHSCREEN */ ucb_ts.ac97 = ac97; - if (pdata != NULL && pdata->irq >= 0) + ucb_ts.irq = of_irq_get(dev->of_node, 0); + + if( ucb_ts.irq < 0 && pdata != NULL && pdata->irq >= 0) ucb_ts.irq = pdata->irq; - else - ucb_ts.irq = -1; + + if( ucb_ts.irq < 0 ) + dev_warn(dev, "Failed to get irq: %d", ucb_ts.irq); ucb->ucb1400_ts = platform_device_alloc("ucb1400_ts", -1); if (!ucb->ucb1400_ts) { @@ -125,6 +152,25 @@ static int ucb1400_core_probe(struct device *dev) return err; } +#ifdef CONFIG_AC97_BUS_NEW +static int ucb1400_core_remove(struct ac97_codec_device *adev) +{ + struct ucb1400_ts *ucb_ts; + struct snd_ac97 *ac97; + struct ucb1400 *ucb = ac97_get_drvdata(adev);; + + ucb_ts = dev_get_platdata(&ucb->ucb1400_ts->dev); + ac97 = ucb_ts->ac97; + + platform_device_unregister(ucb->ucb1400_ts); + platform_device_unregister(ucb->ucb1400_gpio); + + snd_ac97_compat_release(ac97); + + kfree(ucb); + return 0; +} +#else static int ucb1400_core_remove(struct device *dev) { struct ucb1400 *ucb = dev_get_drvdata(dev); @@ -135,6 +181,32 @@ static int ucb1400_core_remove(struct device *dev) kfree(ucb); return 0; } +#endif + +#ifdef CONFIG_AC97_BUS_NEW +static const struct ac97_id ucb1400_ac97_ids[] = { + { .id = UCB1400_VENDOR_ID, .mask = UCB1400_VENDOR_ID_MASK }, + { } +}; +static struct ac97_codec_driver ucb1400_core_driver = { + .driver = { + .name = "ucb1400-core", + }, + .probe = ucb1400_core_probe, + .remove = ucb1400_core_remove, + .id_table = ucb1400_ac97_ids, +}; + +static int __init ucb1400_core_init(void) +{ + return snd_ac97_codec_driver_register(&ucb1400_core_driver); +} + +static void __exit ucb1400_core_exit(void) +{ + snd_ac97_codec_driver_unregister(&ucb1400_core_driver); +} +#else static struct device_driver ucb1400_core_driver = { .name = "ucb1400_core", @@ -152,6 +224,7 @@ static void __exit ucb1400_core_exit(void) { driver_unregister(&ucb1400_core_driver); } +#endif module_init(ucb1400_core_init); module_exit(ucb1400_core_exit);