[PATCH V2 4/4] mfd: SPI interface with AIC platform

2013-04-16 Thread Mehar Bajwa
Texas Instruments TLV320AIC family of audio SoC
core functionality controlled via SPI. This driver
provides common support for accessing the device.

Signed-off-by: Mehar Bajwa 
---
 drivers/mfd/Kconfig |   11 +
 drivers/mfd/Makefile|1 +
 drivers/mfd/tlv320aic-spi.c |   97 +++
 3 files changed, 109 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/tlv320aic-spi.c

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 40eb328..b1d6269 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -81,6 +81,17 @@ config MFD_AIC_I2C
  core functionality controlled via I2C. This driver provides common
  support for accessing the device, additional drivers must be enabled
  in order to use the functionality of the device.
+
+config MFD_AIC_SPI
+   bool "AIC SPI Interface"
+   select REGMAP_SPI
+   depends on MFD_AIC
+   depends on SPI_MASTER
+   help
+ Support for the Texas Instruments TLV320AIC family of audio SoC
+ core functionality controlled via SPI.  This driver provides common
+ support for accessing the device, additional drivers must be enabled
+ in order to use the functionality of the device.
 endmenu
 
 config MFD_SM501
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 1e2c96a..dfdcfa2 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_MFD_88PM805)   += 88pm805.o 88pm80x.o
 obj-$(CONFIG_MFD_AIC)  += tlv320aic-core.o
 obj-$(CONFIG_MFD_AIC_IRQ)  += tlv320aic-irq.o
 obj-$(CONFIG_MFD_AIC_I2C)  += tlv320aic-i2c.o
+obj-$(CONFIG_MFD_AIC_SPI)  += tlv320aic-spi.o
 obj-$(CONFIG_MFD_SM501)+= sm501.o
 obj-$(CONFIG_MFD_ASIC3)+= asic3.o tmio_core.o
 
diff --git a/drivers/mfd/tlv320aic-spi.c b/drivers/mfd/tlv320aic-spi.c
new file mode 100644
index 000..2faeb40
--- /dev/null
+++ b/drivers/mfd/tlv320aic-spi.c
@@ -0,0 +1,97 @@
+/*
+ * tlv320aic-spi.c  -- driver for TLV320AIC
+ *
+ * Author:  Mukund Navada 
+ *     Mehar Bajwa 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+struct regmap_config aic_spi_regmap = {
+   .reg_bits = 7,
+   .val_bits = 8,
+   .cache_type = REGCACHE_NONE,
+   .read_flag_mask = 0x1,
+   .pad_bits = 1,
+};
+
+static int tlv320aic_spi_probe(struct spi_device *spi)
+{
+   const struct spi_device_id *id = spi_get_device_id(spi);
+   struct aic *aic;
+   const struct regmap_config *regmap_config;
+   int ret;
+
+   regmap_config = _spi_regmap;
+
+   aic = devm_kzalloc(>dev, sizeof(struct aic), GFP_KERNEL);
+   if (aic == NULL)
+   return -ENOMEM;
+
+   aic->regmap = devm_regmap_init_spi(spi, regmap_config);
+   if (IS_ERR(aic->regmap)) {
+   ret = PTR_ERR(aic->regmap);
+   dev_err(>dev, "Failed to allocate register map: %d\n",
+   ret);
+   return ret;
+   }
+
+   aic->type = id->driver_data;
+   aic->dev = >dev;
+   aic->irq = spi->irq;
+
+   return aic_device_init(aic);
+}
+
+static int tlv320aic_spi_remove(struct spi_device *spi)
+{
+   struct aic *aic = dev_get_drvdata(>dev);
+   aic_device_exit(aic);
+   return 0;
+}
+
+static const struct spi_device_id aic_spi_ids[] = {
+   {"tlv320aic3262", TLV320AIC3262},
+   { }
+};
+MODULE_DEVICE_TABLE(spi, aic_spi_ids);
+
+static struct spi_driver tlv320aic_spi_driver = {
+   .driver = {
+   .name   = "tlv320aic",
+   .owner  = THIS_MODULE,
+   },
+   .probe  = tlv320aic_spi_probe,
+   .remove = tlv320aic_spi_remove,
+   .id_table   = aic_spi_ids,
+};
+
+module_spi_driver(tlv320aic_spi_driver);
+
+MODULE_DESCRIPTION("TLV320AIC SPI bus interface");
+MODULE_AUTHOR("Mukund Navada ");
+MODULE_AUTHOR("Mehar Bajwa ");
+MODULE_LICENSE("GPL");
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2 3/4] mfd: I2C interface with AIC platform

2013-04-16 Thread Mehar Bajwa
Texas Instruments TLV320AIC family of audio SoC
core functionality controlled via I2C. This driver
provides common support for accessing the device.

Signed-off-by: Mehar Bajwa 
---
 drivers/mfd/Kconfig |   12 +
 drivers/mfd/Makefile|1 +
 drivers/mfd/tlv320aic-i2c.c |   98 +++
 3 files changed, 111 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/tlv320aic-i2c.c

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 3019897..40eb328 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -64,11 +64,23 @@ menu "AIC Interface Drivers"
 config MFD_AIC_IRQ
bool "Support of IRQ for AIC"
depends on MFD_AIC
+   default y
help
  Say yes here if you want support of IRQ for Texas Instruments
  AIC codec family.
  You have to select individual components like codec device
  under the corresponding menus.
+
+config MFD_AIC_I2C
+   bool "AIC I2C Interface"
+   select REGMAP_I2C
+   depends on MFD_AIC
+   depends on I2C
+   help
+ Support for the Texas Instruments TLV320AIC family of audio SoC
+ core functionality controlled via I2C. This driver provides common
+ support for accessing the device, additional drivers must be enabled
+ in order to use the functionality of the device.
 endmenu
 
 config MFD_SM501
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 3b39454..1e2c96a 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -8,6 +8,7 @@ obj-$(CONFIG_MFD_88PM800)   += 88pm800.o 88pm80x.o
 obj-$(CONFIG_MFD_88PM805)  += 88pm805.o 88pm80x.o
 obj-$(CONFIG_MFD_AIC)  += tlv320aic-core.o
 obj-$(CONFIG_MFD_AIC_IRQ)  += tlv320aic-irq.o
+obj-$(CONFIG_MFD_AIC_I2C)  += tlv320aic-i2c.o
 obj-$(CONFIG_MFD_SM501)+= sm501.o
 obj-$(CONFIG_MFD_ASIC3)+= asic3.o tmio_core.o
 
diff --git a/drivers/mfd/tlv320aic-i2c.c b/drivers/mfd/tlv320aic-i2c.c
new file mode 100644
index 000..18987b1
--- /dev/null
+++ b/drivers/mfd/tlv320aic-i2c.c
@@ -0,0 +1,98 @@
+/*
+ * tlv320aic-i2c.c  -- driver for TLV320AIC Codecs Family
+ *
+ * Author: Mukund Navada 
+ * Mehar Bajwa 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+struct regmap_config aic_i2c_regmap = {
+   .reg_bits = 8,
+   .val_bits = 8,
+   .cache_type = REGCACHE_NONE,
+};
+
+static int aic_i2c_probe(struct i2c_client *i2c,
+ const struct i2c_device_id *id)
+{
+   struct aic *aic;
+   const struct regmap_config *regmap_config;
+   int ret;
+
+   regmap_config = _i2c_regmap;
+
+   aic = devm_kzalloc(>dev, sizeof(*aic), GFP_KERNEL);
+   if (aic == NULL)
+   return -ENOMEM;
+
+   aic->regmap = devm_regmap_init_i2c(i2c, regmap_config);
+
+   if (IS_ERR(aic->regmap)) {
+   ret = PTR_ERR(aic->regmap);
+   dev_err(>dev, "Failed to allocate register map: %d\n",
+   ret);
+   return ret;
+   }
+
+   aic->type = id->driver_data;
+   aic->dev = >dev;
+   aic->irq = i2c->irq;
+
+   return aic_device_init(aic);
+}
+
+static int aic_i2c_remove(struct i2c_client *i2c)
+{
+   struct aic *aic = dev_get_drvdata(>dev);
+
+   aic_device_exit(aic);
+   return 0;
+}
+
+static const struct i2c_device_id aic_i2c_id[] = {
+   {"tlv320aic3262", TLV320AIC3262},
+   { }
+};
+MODULE_DEVICE_TABLE(i2c, aic_i2c_id);
+
+static struct i2c_driver aic_i2c_driver = {
+   .driver = {
+   .name   = "tlv320aic",
+   .owner  = THIS_MODULE,
+   },
+   .probe  = aic_i2c_probe,
+   .remove = aic_i2c_remove,
+   .id_table   = aic_i2c_id,
+};
+
+module_i2c_driver(aic_i2c_driver);
+
+MODULE_DESCRIPTION("TLV320AIC I2C bus interface");
+MODULE_AUTHOR("Mukund Navada ");
+MODULE_AUTHOR("Mehar Bajwa ");
+MODULE_LICENSE("GPL");
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a 

[PATCH V2 2/4] mfd: Interrupt handling support for AIC family

2013-04-16 Thread Mehar Bajwa
This provides Interrupt handling features for common interface
to series of low power AIC audio CODECS.

Signed-off-by: Mehar Bajwa 
---
 drivers/mfd/Kconfig |   13 ++
 drivers/mfd/Makefile|1 +
 drivers/mfd/tlv320aic-irq.c |  234 +++
 include/linux/mfd/tlv320aic-core.h  |   49 ++-
 include/linux/mfd/tlv320aic-registers.h |   57 
 5 files changed, 348 insertions(+), 6 deletions(-)
 create mode 100644 drivers/mfd/tlv320aic-irq.c

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 629d374..3019897 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -58,6 +58,19 @@ config MFD_AIC
  you have to select individual components like codec device
  to use AIC features.
 
+menu "AIC Interface Drivers"
+   depends on MFD_AIC
+
+config MFD_AIC_IRQ
+   bool "Support of IRQ for AIC"
+   depends on MFD_AIC
+   help
+ Say yes here if you want support of IRQ for Texas Instruments
+ AIC codec family.
+ You have to select individual components like codec device
+ under the corresponding menus.
+endmenu
+
 config MFD_SM501
tristate "Support for Silicon Motion SM501"
 ---help---
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index b975c94..3b39454 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -7,6 +7,7 @@ obj-$(CONFIG_MFD_88PM860X)  += 88pm860x.o
 obj-$(CONFIG_MFD_88PM800)  += 88pm800.o 88pm80x.o
 obj-$(CONFIG_MFD_88PM805)  += 88pm805.o 88pm80x.o
 obj-$(CONFIG_MFD_AIC)  += tlv320aic-core.o
+obj-$(CONFIG_MFD_AIC_IRQ)  += tlv320aic-irq.o
 obj-$(CONFIG_MFD_SM501)+= sm501.o
 obj-$(CONFIG_MFD_ASIC3)+= asic3.o tmio_core.o
 
diff --git a/drivers/mfd/tlv320aic-irq.c b/drivers/mfd/tlv320aic-irq.c
new file mode 100644
index 000..e299495
--- /dev/null
+++ b/drivers/mfd/tlv320aic-irq.c
@@ -0,0 +1,234 @@
+/*
+ * tlv320aic-irq.c  --  Interrupt controller support for
+ *  TI TLV320AIC family
+ *
+ * Author:  Mukund Navada 
+ *  Mehar Bajwa 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+
+struct aic_irq_data {
+   int mask;
+   int status;
+};
+
+static struct aic_irq_data aic_irqs[] = {
+   {
+.mask = AIC_HEADSET_IN_M,
+.status = AIC_HEADSET_PLUG_UNPLUG_INT,
+},
+   {
+.mask = AIC_BUTTON_PRESS_M,
+.status = AIC_BUTTON_PRESS_INT,
+},
+   {
+.mask = AIC_DAC_DRC_THRES_M,
+.status = AIC_LEFT_DRC_THRES_INT | AIC_RIGHT_DRC_THRES_INT,
+},
+   {
+.mask = AIC_AGC_NOISE_M,
+.status = AIC_LEFT_AGC_NOISE_INT | AIC_RIGHT_AGC_NOISE_INT,
+},
+   {
+.mask = AIC_OVER_CURRENT_M,
+.status = AIC_LEFT_OUTPUT_DRIVER_OVERCURRENT_INT
+| AIC_RIGHT_OUTPUT_DRIVER_OVERCURRENT_INT,
+},
+   {
+.mask = AIC_OVERFLOW_M,
+.status =
+AIC_LEFT_DAC_OVERFLOW_INT | AIC_RIGHT_DAC_OVERFLOW_INT |
+AIC_MINIDSP_D_BARREL_SHIFT_OVERFLOW_INT |
+AIC_LEFT_ADC_OVERFLOW_INT | AIC_RIGHT_ADC_OVERFLOW_INT |
+AIC_MINIDSP_D_BARREL_SHIFT_OVERFLOW_INT,
+},
+   {
+.mask = AIC_SPK_OVERCURRENT_M,
+.status = AIC_SPK_OVER_CURRENT_INT,
+},
+
+};
+
+static void aic_irq_lock(struct irq_data *data)
+{
+   struct aic *aic = irq_data_get_irq_chip_data(data);
+
+   mutex_lock(>irq_lock);
+}
+
+static void aic_irq_sync_unlock(struct irq_data *data)
+{
+   struct aic *aic = irq_data_get_irq_chip_data(data);
+
+   /* write back to hardware any change in irq mask */
+   if (aic->irq_masks_cur != aic->irq_masks_cache) {
+   aic->irq_masks_cache = aic->irq_masks_cur;
+   aic_reg_write(aic, AIC_INT1_CNTL,
+ aic->irq_masks_cur);
+   }
+
+   mutex_unlock(>irq_lock);
+}
+
+
+static void aic_irq_enable(struct irq_data *data)
+{
+   struct aic *aic = irq_data_get_irq_chip_data(data);
+   struct aic_irq_data *irq_data = _irqs[data->hwirq];
+   aic->irq_masks_cur |= irq_data->m

[PATCH V2 1/4] mfd: Initial support for Texas Instruments AIC family of CODECs

2013-04-16 Thread Mehar Bajwa
Initial support for Texas Instruments's AIC CODEC device.

The AIC platform provides common interface to series of low power audio CODECS.
This MFD core driver instantiates subdevices that help in supporting range
of features provided by AIC family of devices

Signed-off-by: Mehar Bajwa 
---
 drivers/mfd/Kconfig |   13 +
 drivers/mfd/Makefile|1 +
 drivers/mfd/tlv320aic-core.c|  462 +++
 include/linux/mfd/tlv320aic-core.h  |  112 
 include/linux/mfd/tlv320aic-registers.h |   32 +++
 5 files changed, 620 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/tlv320aic-core.c
 create mode 100644 include/linux/mfd/tlv320aic-core.h
 create mode 100644 include/linux/mfd/tlv320aic-registers.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 671f5b1..629d374 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -45,6 +45,19 @@ config MFD_88PM805
  components like codec device, headset/Mic device under the
  corresponding menus.
 
+config MFD_AIC
+   bool "Support for Texas Instruments TLV320AIC platform"
+   select REGMAP
+   select MFD_CORE
+   help
+ Say yes here if you want support for Texas Instruments AIC audio
+ codec.
+ You have to select individual I2C or SPI depending on
+ AIC interfacing with platform. To enable IRQ handling
+ facilities select IRQ component under corresponding menus.
+ you have to select individual components like codec device
+ to use AIC features.
+
 config MFD_SM501
tristate "Support for Silicon Motion SM501"
 ---help---
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index b90409c..b975c94 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -6,6 +6,7 @@
 obj-$(CONFIG_MFD_88PM860X) += 88pm860x.o
 obj-$(CONFIG_MFD_88PM800)  += 88pm800.o 88pm80x.o
 obj-$(CONFIG_MFD_88PM805)  += 88pm805.o 88pm80x.o
+obj-$(CONFIG_MFD_AIC)  += tlv320aic-core.o
 obj-$(CONFIG_MFD_SM501)+= sm501.o
 obj-$(CONFIG_MFD_ASIC3)+= asic3.o tmio_core.o
 
diff --git a/drivers/mfd/tlv320aic-core.c b/drivers/mfd/tlv320aic-core.c
new file mode 100644
index 000..4b8a424
--- /dev/null
+++ b/drivers/mfd/tlv320aic-core.c
@@ -0,0 +1,462 @@
+/*
+ * tlv320aic-core.c  -- driver for TLV320AIC
+ *
+ * Author:  Mukund Navada 
+ *  Mehar Bajwa 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+/**
+ * set_aic_book: change book which we have to write/read to.
+ *
+ * @aic: Device to write/read to.
+ * @book: Book to write/read to.
+ */
+int set_aic_book(struct aic *aic, int book)
+{
+   int ret = 0;
+   u8 page_buf[] = { 0x0, 0x0 };
+   u8 book_buf[] = { 0x7f, 0x0 };
+
+   ret = regmap_write(aic->regmap, page_buf[0], page_buf[1]);
+
+   if (ret < 0)
+   return ret;
+   book_buf[1] = book;
+   ret = regmap_write(aic->regmap, book_buf[0], book_buf[1]);
+
+   if (ret < 0)
+   return ret;
+   aic->book_no = book;
+   aic->page_no = 0;
+
+   return ret;
+}
+
+/**
+ * set_aic_page: change page which we have to write/read to.
+ *
+ * @aic: Device to write/read to.
+ * @page: Book to write/read to.
+ */
+int set_aic_page(struct aic *aic, int page)
+{
+   int ret = 0;
+   u8 page_buf[] = { 0x0, 0x0 };
+
+   page_buf[1] = page;
+   ret = regmap_write(aic->regmap, page_buf[0], page_buf[1]);
+
+   if (ret < 0)
+   return ret;
+   aic->page_no = page;
+   return ret;
+}
+/**
+ * aic_reg_read: Read a single TLV320AIC register.
+ *
+ * @aic: Device to read from.
+ * @reg: Register to read.
+ */
+int aic_reg_read(struct aic *aic, unsigned int reg)
+{
+   unsigned int val;
+   int ret;
+   union aic_reg_union *aic_reg = (union aic_reg_union *) 
+   u8 book, page, offset;
+
+   page = aic_reg->aic_register.page;
+   book = aic_reg->aic_register.book;
+   offset = aic_reg->aic_register.offset;
+
+   mutex_lock(>io_lock);
+   if (aic->book_no != book) {
+   

[PATCH V2 1/4] mfd: Initial support for Texas Instruments AIC family of CODECs

2013-04-16 Thread Mehar Bajwa
Initial support for Texas Instruments's AIC CODEC device.

The AIC platform provides common interface to series of low power audio CODECS.
This MFD core driver instantiates subdevices that help in supporting range
of features provided by AIC family of devices

Signed-off-by: Mehar Bajwa mehar.ba...@ti.com
---
 drivers/mfd/Kconfig |   13 +
 drivers/mfd/Makefile|1 +
 drivers/mfd/tlv320aic-core.c|  462 +++
 include/linux/mfd/tlv320aic-core.h  |  112 
 include/linux/mfd/tlv320aic-registers.h |   32 +++
 5 files changed, 620 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/tlv320aic-core.c
 create mode 100644 include/linux/mfd/tlv320aic-core.h
 create mode 100644 include/linux/mfd/tlv320aic-registers.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 671f5b1..629d374 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -45,6 +45,19 @@ config MFD_88PM805
  components like codec device, headset/Mic device under the
  corresponding menus.
 
+config MFD_AIC
+   bool Support for Texas Instruments TLV320AIC platform
+   select REGMAP
+   select MFD_CORE
+   help
+ Say yes here if you want support for Texas Instruments AIC audio
+ codec.
+ You have to select individual I2C or SPI depending on
+ AIC interfacing with platform. To enable IRQ handling
+ facilities select IRQ component under corresponding menus.
+ you have to select individual components like codec device
+ to use AIC features.
+
 config MFD_SM501
tristate Support for Silicon Motion SM501
 ---help---
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index b90409c..b975c94 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -6,6 +6,7 @@
 obj-$(CONFIG_MFD_88PM860X) += 88pm860x.o
 obj-$(CONFIG_MFD_88PM800)  += 88pm800.o 88pm80x.o
 obj-$(CONFIG_MFD_88PM805)  += 88pm805.o 88pm80x.o
+obj-$(CONFIG_MFD_AIC)  += tlv320aic-core.o
 obj-$(CONFIG_MFD_SM501)+= sm501.o
 obj-$(CONFIG_MFD_ASIC3)+= asic3.o tmio_core.o
 
diff --git a/drivers/mfd/tlv320aic-core.c b/drivers/mfd/tlv320aic-core.c
new file mode 100644
index 000..4b8a424
--- /dev/null
+++ b/drivers/mfd/tlv320aic-core.c
@@ -0,0 +1,462 @@
+/*
+ * tlv320aic-core.c  -- driver for TLV320AIC
+ *
+ * Author:  Mukund Navada nav...@ti.com
+ *  Mehar Bajwa mehar.ba...@ti.com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+#include linux/kernel.h
+#include linux/module.h
+#include linux/slab.h
+#include linux/i2c.h
+#include linux/err.h
+#include linux/delay.h
+#include linux/regmap.h
+#include linux/mfd/core.h
+#include linux/pm_runtime.h
+#include linux/regulator/consumer.h
+#include linux/regulator/machine.h
+#include linux/gpio.h
+
+#include linux/mfd/tlv320aic-core.h
+#include linux/mfd/tlv320aic-registers.h
+/**
+ * set_aic_book: change book which we have to write/read to.
+ *
+ * @aic: Device to write/read to.
+ * @book: Book to write/read to.
+ */
+int set_aic_book(struct aic *aic, int book)
+{
+   int ret = 0;
+   u8 page_buf[] = { 0x0, 0x0 };
+   u8 book_buf[] = { 0x7f, 0x0 };
+
+   ret = regmap_write(aic-regmap, page_buf[0], page_buf[1]);
+
+   if (ret  0)
+   return ret;
+   book_buf[1] = book;
+   ret = regmap_write(aic-regmap, book_buf[0], book_buf[1]);
+
+   if (ret  0)
+   return ret;
+   aic-book_no = book;
+   aic-page_no = 0;
+
+   return ret;
+}
+
+/**
+ * set_aic_page: change page which we have to write/read to.
+ *
+ * @aic: Device to write/read to.
+ * @page: Book to write/read to.
+ */
+int set_aic_page(struct aic *aic, int page)
+{
+   int ret = 0;
+   u8 page_buf[] = { 0x0, 0x0 };
+
+   page_buf[1] = page;
+   ret = regmap_write(aic-regmap, page_buf[0], page_buf[1]);
+
+   if (ret  0)
+   return ret;
+   aic-page_no = page;
+   return ret;
+}
+/**
+ * aic_reg_read: Read a single TLV320AIC register.
+ *
+ * @aic: Device to read from.
+ * @reg: Register to read.
+ */
+int aic_reg_read(struct aic *aic, unsigned int reg)
+{
+   unsigned int val;
+   int ret;
+   union aic_reg_union *aic_reg = (union aic_reg_union *) reg;
+   u8 book, page

[PATCH V2 2/4] mfd: Interrupt handling support for AIC family

2013-04-16 Thread Mehar Bajwa
This provides Interrupt handling features for common interface
to series of low power AIC audio CODECS.

Signed-off-by: Mehar Bajwa mehar.ba...@ti.com
---
 drivers/mfd/Kconfig |   13 ++
 drivers/mfd/Makefile|1 +
 drivers/mfd/tlv320aic-irq.c |  234 +++
 include/linux/mfd/tlv320aic-core.h  |   49 ++-
 include/linux/mfd/tlv320aic-registers.h |   57 
 5 files changed, 348 insertions(+), 6 deletions(-)
 create mode 100644 drivers/mfd/tlv320aic-irq.c

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 629d374..3019897 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -58,6 +58,19 @@ config MFD_AIC
  you have to select individual components like codec device
  to use AIC features.
 
+menu AIC Interface Drivers
+   depends on MFD_AIC
+
+config MFD_AIC_IRQ
+   bool Support of IRQ for AIC
+   depends on MFD_AIC
+   help
+ Say yes here if you want support of IRQ for Texas Instruments
+ AIC codec family.
+ You have to select individual components like codec device
+ under the corresponding menus.
+endmenu
+
 config MFD_SM501
tristate Support for Silicon Motion SM501
 ---help---
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index b975c94..3b39454 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -7,6 +7,7 @@ obj-$(CONFIG_MFD_88PM860X)  += 88pm860x.o
 obj-$(CONFIG_MFD_88PM800)  += 88pm800.o 88pm80x.o
 obj-$(CONFIG_MFD_88PM805)  += 88pm805.o 88pm80x.o
 obj-$(CONFIG_MFD_AIC)  += tlv320aic-core.o
+obj-$(CONFIG_MFD_AIC_IRQ)  += tlv320aic-irq.o
 obj-$(CONFIG_MFD_SM501)+= sm501.o
 obj-$(CONFIG_MFD_ASIC3)+= asic3.o tmio_core.o
 
diff --git a/drivers/mfd/tlv320aic-irq.c b/drivers/mfd/tlv320aic-irq.c
new file mode 100644
index 000..e299495
--- /dev/null
+++ b/drivers/mfd/tlv320aic-irq.c
@@ -0,0 +1,234 @@
+/*
+ * tlv320aic-irq.c  --  Interrupt controller support for
+ *  TI TLV320AIC family
+ *
+ * Author:  Mukund Navada nav...@ti.com
+ *  Mehar Bajwa mehar.ba...@ti.com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include linux/kernel.h
+#include linux/module.h
+#include linux/i2c.h
+#include linux/irq.h
+#include linux/mfd/core.h
+#include linux/interrupt.h
+#include linux/irqdomain.h
+
+#include linux/mfd/tlv320aic-core.h
+#include linux/mfd/tlv320aic-registers.h
+
+#include linux/delay.h
+
+struct aic_irq_data {
+   int mask;
+   int status;
+};
+
+static struct aic_irq_data aic_irqs[] = {
+   {
+.mask = AIC_HEADSET_IN_M,
+.status = AIC_HEADSET_PLUG_UNPLUG_INT,
+},
+   {
+.mask = AIC_BUTTON_PRESS_M,
+.status = AIC_BUTTON_PRESS_INT,
+},
+   {
+.mask = AIC_DAC_DRC_THRES_M,
+.status = AIC_LEFT_DRC_THRES_INT | AIC_RIGHT_DRC_THRES_INT,
+},
+   {
+.mask = AIC_AGC_NOISE_M,
+.status = AIC_LEFT_AGC_NOISE_INT | AIC_RIGHT_AGC_NOISE_INT,
+},
+   {
+.mask = AIC_OVER_CURRENT_M,
+.status = AIC_LEFT_OUTPUT_DRIVER_OVERCURRENT_INT
+| AIC_RIGHT_OUTPUT_DRIVER_OVERCURRENT_INT,
+},
+   {
+.mask = AIC_OVERFLOW_M,
+.status =
+AIC_LEFT_DAC_OVERFLOW_INT | AIC_RIGHT_DAC_OVERFLOW_INT |
+AIC_MINIDSP_D_BARREL_SHIFT_OVERFLOW_INT |
+AIC_LEFT_ADC_OVERFLOW_INT | AIC_RIGHT_ADC_OVERFLOW_INT |
+AIC_MINIDSP_D_BARREL_SHIFT_OVERFLOW_INT,
+},
+   {
+.mask = AIC_SPK_OVERCURRENT_M,
+.status = AIC_SPK_OVER_CURRENT_INT,
+},
+
+};
+
+static void aic_irq_lock(struct irq_data *data)
+{
+   struct aic *aic = irq_data_get_irq_chip_data(data);
+
+   mutex_lock(aic-irq_lock);
+}
+
+static void aic_irq_sync_unlock(struct irq_data *data)
+{
+   struct aic *aic = irq_data_get_irq_chip_data(data);
+
+   /* write back to hardware any change in irq mask */
+   if (aic-irq_masks_cur != aic-irq_masks_cache) {
+   aic-irq_masks_cache = aic-irq_masks_cur;
+   aic_reg_write(aic, AIC_INT1_CNTL,
+ aic-irq_masks_cur);
+   }
+
+   mutex_unlock(aic-irq_lock);
+}
+
+
+static void aic_irq_enable(struct irq_data *data

[PATCH V2 3/4] mfd: I2C interface with AIC platform

2013-04-16 Thread Mehar Bajwa
Texas Instruments TLV320AIC family of audio SoC
core functionality controlled via I2C. This driver
provides common support for accessing the device.

Signed-off-by: Mehar Bajwa mehar.ba...@ti.com
---
 drivers/mfd/Kconfig |   12 +
 drivers/mfd/Makefile|1 +
 drivers/mfd/tlv320aic-i2c.c |   98 +++
 3 files changed, 111 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/tlv320aic-i2c.c

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 3019897..40eb328 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -64,11 +64,23 @@ menu AIC Interface Drivers
 config MFD_AIC_IRQ
bool Support of IRQ for AIC
depends on MFD_AIC
+   default y
help
  Say yes here if you want support of IRQ for Texas Instruments
  AIC codec family.
  You have to select individual components like codec device
  under the corresponding menus.
+
+config MFD_AIC_I2C
+   bool AIC I2C Interface
+   select REGMAP_I2C
+   depends on MFD_AIC
+   depends on I2C
+   help
+ Support for the Texas Instruments TLV320AIC family of audio SoC
+ core functionality controlled via I2C. This driver provides common
+ support for accessing the device, additional drivers must be enabled
+ in order to use the functionality of the device.
 endmenu
 
 config MFD_SM501
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 3b39454..1e2c96a 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -8,6 +8,7 @@ obj-$(CONFIG_MFD_88PM800)   += 88pm800.o 88pm80x.o
 obj-$(CONFIG_MFD_88PM805)  += 88pm805.o 88pm80x.o
 obj-$(CONFIG_MFD_AIC)  += tlv320aic-core.o
 obj-$(CONFIG_MFD_AIC_IRQ)  += tlv320aic-irq.o
+obj-$(CONFIG_MFD_AIC_I2C)  += tlv320aic-i2c.o
 obj-$(CONFIG_MFD_SM501)+= sm501.o
 obj-$(CONFIG_MFD_ASIC3)+= asic3.o tmio_core.o
 
diff --git a/drivers/mfd/tlv320aic-i2c.c b/drivers/mfd/tlv320aic-i2c.c
new file mode 100644
index 000..18987b1
--- /dev/null
+++ b/drivers/mfd/tlv320aic-i2c.c
@@ -0,0 +1,98 @@
+/*
+ * tlv320aic-i2c.c  -- driver for TLV320AIC Codecs Family
+ *
+ * Author: Mukund Navada nav...@ti.com
+ * Mehar Bajwa mehar.ba...@ti.com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include linux/kernel.h
+#include linux/err.h
+#include linux/i2c.h
+#include linux/module.h
+#include linux/pm_runtime.h
+#include linux/regmap.h
+#include linux/regulator/consumer.h
+#include linux/slab.h
+
+#include linux/mfd/tlv320aic-core.h
+
+struct regmap_config aic_i2c_regmap = {
+   .reg_bits = 8,
+   .val_bits = 8,
+   .cache_type = REGCACHE_NONE,
+};
+
+static int aic_i2c_probe(struct i2c_client *i2c,
+ const struct i2c_device_id *id)
+{
+   struct aic *aic;
+   const struct regmap_config *regmap_config;
+   int ret;
+
+   regmap_config = aic_i2c_regmap;
+
+   aic = devm_kzalloc(i2c-dev, sizeof(*aic), GFP_KERNEL);
+   if (aic == NULL)
+   return -ENOMEM;
+
+   aic-regmap = devm_regmap_init_i2c(i2c, regmap_config);
+
+   if (IS_ERR(aic-regmap)) {
+   ret = PTR_ERR(aic-regmap);
+   dev_err(i2c-dev, Failed to allocate register map: %d\n,
+   ret);
+   return ret;
+   }
+
+   aic-type = id-driver_data;
+   aic-dev = i2c-dev;
+   aic-irq = i2c-irq;
+
+   return aic_device_init(aic);
+}
+
+static int aic_i2c_remove(struct i2c_client *i2c)
+{
+   struct aic *aic = dev_get_drvdata(i2c-dev);
+
+   aic_device_exit(aic);
+   return 0;
+}
+
+static const struct i2c_device_id aic_i2c_id[] = {
+   {tlv320aic3262, TLV320AIC3262},
+   { }
+};
+MODULE_DEVICE_TABLE(i2c, aic_i2c_id);
+
+static struct i2c_driver aic_i2c_driver = {
+   .driver = {
+   .name   = tlv320aic,
+   .owner  = THIS_MODULE,
+   },
+   .probe  = aic_i2c_probe,
+   .remove = aic_i2c_remove,
+   .id_table   = aic_i2c_id,
+};
+
+module_i2c_driver(aic_i2c_driver);
+
+MODULE_DESCRIPTION(TLV320AIC I2C bus interface);
+MODULE_AUTHOR(Mukund Navada nav...@ti.com);
+MODULE_AUTHOR(Mehar Bajwa mehar.ba...@ti.com);
+MODULE_LICENSE(GPL);
-- 
1.7.0.4

--
To unsubscribe from

[PATCH V2 4/4] mfd: SPI interface with AIC platform

2013-04-16 Thread Mehar Bajwa
Texas Instruments TLV320AIC family of audio SoC
core functionality controlled via SPI. This driver
provides common support for accessing the device.

Signed-off-by: Mehar Bajwa mehar.ba...@ti.com
---
 drivers/mfd/Kconfig |   11 +
 drivers/mfd/Makefile|1 +
 drivers/mfd/tlv320aic-spi.c |   97 +++
 3 files changed, 109 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/tlv320aic-spi.c

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 40eb328..b1d6269 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -81,6 +81,17 @@ config MFD_AIC_I2C
  core functionality controlled via I2C. This driver provides common
  support for accessing the device, additional drivers must be enabled
  in order to use the functionality of the device.
+
+config MFD_AIC_SPI
+   bool AIC SPI Interface
+   select REGMAP_SPI
+   depends on MFD_AIC
+   depends on SPI_MASTER
+   help
+ Support for the Texas Instruments TLV320AIC family of audio SoC
+ core functionality controlled via SPI.  This driver provides common
+ support for accessing the device, additional drivers must be enabled
+ in order to use the functionality of the device.
 endmenu
 
 config MFD_SM501
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 1e2c96a..dfdcfa2 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_MFD_88PM805)   += 88pm805.o 88pm80x.o
 obj-$(CONFIG_MFD_AIC)  += tlv320aic-core.o
 obj-$(CONFIG_MFD_AIC_IRQ)  += tlv320aic-irq.o
 obj-$(CONFIG_MFD_AIC_I2C)  += tlv320aic-i2c.o
+obj-$(CONFIG_MFD_AIC_SPI)  += tlv320aic-spi.o
 obj-$(CONFIG_MFD_SM501)+= sm501.o
 obj-$(CONFIG_MFD_ASIC3)+= asic3.o tmio_core.o
 
diff --git a/drivers/mfd/tlv320aic-spi.c b/drivers/mfd/tlv320aic-spi.c
new file mode 100644
index 000..2faeb40
--- /dev/null
+++ b/drivers/mfd/tlv320aic-spi.c
@@ -0,0 +1,97 @@
+/*
+ * tlv320aic-spi.c  -- driver for TLV320AIC
+ *
+ * Author:  Mukund Navada nav...@ti.com
+ * Mehar Bajwa mehar.ba...@ti.com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include linux/err.h
+#include linux/module.h
+#include linux/pm_runtime.h
+#include linux/regmap.h
+#include linux/regulator/consumer.h
+#include linux/slab.h
+#include linux/spi/spi.h
+
+#include linux/mfd/tlv320aic-core.h
+
+struct regmap_config aic_spi_regmap = {
+   .reg_bits = 7,
+   .val_bits = 8,
+   .cache_type = REGCACHE_NONE,
+   .read_flag_mask = 0x1,
+   .pad_bits = 1,
+};
+
+static int tlv320aic_spi_probe(struct spi_device *spi)
+{
+   const struct spi_device_id *id = spi_get_device_id(spi);
+   struct aic *aic;
+   const struct regmap_config *regmap_config;
+   int ret;
+
+   regmap_config = aic_spi_regmap;
+
+   aic = devm_kzalloc(spi-dev, sizeof(struct aic), GFP_KERNEL);
+   if (aic == NULL)
+   return -ENOMEM;
+
+   aic-regmap = devm_regmap_init_spi(spi, regmap_config);
+   if (IS_ERR(aic-regmap)) {
+   ret = PTR_ERR(aic-regmap);
+   dev_err(spi-dev, Failed to allocate register map: %d\n,
+   ret);
+   return ret;
+   }
+
+   aic-type = id-driver_data;
+   aic-dev = spi-dev;
+   aic-irq = spi-irq;
+
+   return aic_device_init(aic);
+}
+
+static int tlv320aic_spi_remove(struct spi_device *spi)
+{
+   struct aic *aic = dev_get_drvdata(spi-dev);
+   aic_device_exit(aic);
+   return 0;
+}
+
+static const struct spi_device_id aic_spi_ids[] = {
+   {tlv320aic3262, TLV320AIC3262},
+   { }
+};
+MODULE_DEVICE_TABLE(spi, aic_spi_ids);
+
+static struct spi_driver tlv320aic_spi_driver = {
+   .driver = {
+   .name   = tlv320aic,
+   .owner  = THIS_MODULE,
+   },
+   .probe  = tlv320aic_spi_probe,
+   .remove = tlv320aic_spi_remove,
+   .id_table   = aic_spi_ids,
+};
+
+module_spi_driver(tlv320aic_spi_driver);
+
+MODULE_DESCRIPTION(TLV320AIC SPI bus interface);
+MODULE_AUTHOR(Mukund Navada nav...@ti.com);
+MODULE_AUTHOR(Mehar Bajwa mehar.ba...@ti.com);
+MODULE_LICENSE(GPL);
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body

[PATCH] Mfd: Initial support for Texas Instruments AIC family of CODECs

2012-12-12 Thread Mehar Bajwa
Initial support for TI's AIC platform and TLV320AIC3262 CODEC device.

The AIC platform provides common interface to series of low power audio CODECS.
This MFD core driver instantiates subdevices that help in supporting range of 
features
provided by AIC family of devices.

Signed-off-by: Mehar Bajwa 
---
 drivers/mfd/Kconfig |   41 +++
 drivers/mfd/Makefile|3 +
 drivers/mfd/tlv320aic3xxx-core.c|  462 +++
 drivers/mfd/tlv320aic3xxx-i2c.c |   97 ++
 drivers/mfd/tlv320aic3xxx-irq.c |  234 ++
 drivers/mfd/tlv320aic3xxx-spi.c |   96 ++
 include/linux/mfd/tlv320aic3262-registers.h |  312 ++
 include/linux/mfd/tlv320aic3xxx-core.h  |  153 +
 include/linux/mfd/tlv320aic3xxx-registers.h |   75 +
 9 files changed, 1473 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/tlv320aic3xxx-core.c
 create mode 100644 drivers/mfd/tlv320aic3xxx-i2c.c
 create mode 100644 drivers/mfd/tlv320aic3xxx-irq.c
 create mode 100644 drivers/mfd/tlv320aic3xxx-spi.c
 create mode 100644 include/linux/mfd/tlv320aic3262-registers.h
 create mode 100644 include/linux/mfd/tlv320aic3xxx-core.h
 create mode 100644 include/linux/mfd/tlv320aic3xxx-registers.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 50bbe88..2ecfbad 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -45,6 +45,47 @@ config MFD_88PM805
  components like codec device, headset/Mic device under the
  corresponding menus.
 
+config MFD_AIC3XXX
+   bool "Support for AIC3XXX"
+   select REGMAP
+   select MFD_CORE
+   help
+ Say yes here if you want support for Texas Instruments AIC audio
+ codec.
+ You have to select individual I2C or SPI depending on
+ AIC3XXX interfacing with platform.
+
+config MFD_AIC3XXX_I2C
+   bool "Support Texas Instruments AIC3XXX platform with I2C"
+   select MFD_AIC3XXX
+   select REGMAP_I2C
+   depends on I2C
+   help
+ Support for the Texas Instruments TLV320AIC3XXX family of audio SoC
+ core functionality controlled via I2C.  This driver provides common
+ support for accessing the device, additional drivers must be enabled
+ in order to use the functionality of the device.
+
+config MFD_AIC3XXX_SPI
+   bool "Support Texas Instruments AIC3XXX  platform with SPI"
+   select MFD_AIC3XXX
+   select REGMAP_SPI
+   depends on SPI_MASTER
+   help
+ Support for the Texas Instruments TLV320AIC3XXX family of audio SoC
+ core functionality controlled via SPI.  This driver provides common
+ support for accessing the device, additional drivers must be enabled
+ in order to use the functionality of the device.
+
+config MFD_AIC3262
+   bool "Support Texas Instruments AIC3262"
+   depends on MFD_AIC3XXX
+   help
+ If you say yes here you will get support for Texas Instrument
+ TLV320AIC3262 low power audio SoC.
+ Addition driver must be enabled to use this in order to use
+ functionality on device.
+
 config MFD_SM501
tristate "Support for Silicon Motion SM501"
 ---help---
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index f2216df..8c97872 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -6,6 +6,9 @@
 obj-$(CONFIG_MFD_88PM860X) += 88pm860x.o
 obj-$(CONFIG_MFD_88PM800)  += 88pm800.o 88pm80x.o
 obj-$(CONFIG_MFD_88PM805)  += 88pm805.o 88pm80x.o
+obj-$(CONFIG_MFD_AIC3XXX)  += tlv320aic3xxx-core.o tlv320aic3xxx-irq.o
+obj-$(CONFIG_MFD_AIC3XXX_I2C)  += tlv320aic3xxx-i2c.o
+obj-$(CONFIG_MFD_AIC3XXX_SPI)  += tlv320aic3xxx-spi.o
 obj-$(CONFIG_MFD_SM501)+= sm501.o
 obj-$(CONFIG_MFD_ASIC3)+= asic3.o tmio_core.o
 
diff --git a/drivers/mfd/tlv320aic3xxx-core.c b/drivers/mfd/tlv320aic3xxx-core.c
new file mode 100644
index 000..6fd151b
--- /dev/null
+++ b/drivers/mfd/tlv320aic3xxx-core.c
@@ -0,0 +1,462 @@
+/*
+ * tlv320aic3xxx-core.c  -- driver for TLV320AIC3XXX
+ *
+ * Author:  Mukund Navada 
+ *  Mehar Bajwa 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+#include 
+#include 
+#i

[PATCH] Mfd: Initial support for Texas Instruments AIC family of CODECs

2012-12-12 Thread Mehar Bajwa
Initial support for TI's AIC platform and TLV320AIC3262 CODEC device.

The AIC platform provides common interface to series of low power audio CODECS.
This MFD core driver instantiates subdevices that help in supporting range of 
features
provided by AIC family of devices.

Signed-off-by: Mehar Bajwa mehar.ba...@ti.com
---
 drivers/mfd/Kconfig |   41 +++
 drivers/mfd/Makefile|3 +
 drivers/mfd/tlv320aic3xxx-core.c|  462 +++
 drivers/mfd/tlv320aic3xxx-i2c.c |   97 ++
 drivers/mfd/tlv320aic3xxx-irq.c |  234 ++
 drivers/mfd/tlv320aic3xxx-spi.c |   96 ++
 include/linux/mfd/tlv320aic3262-registers.h |  312 ++
 include/linux/mfd/tlv320aic3xxx-core.h  |  153 +
 include/linux/mfd/tlv320aic3xxx-registers.h |   75 +
 9 files changed, 1473 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/tlv320aic3xxx-core.c
 create mode 100644 drivers/mfd/tlv320aic3xxx-i2c.c
 create mode 100644 drivers/mfd/tlv320aic3xxx-irq.c
 create mode 100644 drivers/mfd/tlv320aic3xxx-spi.c
 create mode 100644 include/linux/mfd/tlv320aic3262-registers.h
 create mode 100644 include/linux/mfd/tlv320aic3xxx-core.h
 create mode 100644 include/linux/mfd/tlv320aic3xxx-registers.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 50bbe88..2ecfbad 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -45,6 +45,47 @@ config MFD_88PM805
  components like codec device, headset/Mic device under the
  corresponding menus.
 
+config MFD_AIC3XXX
+   bool Support for AIC3XXX
+   select REGMAP
+   select MFD_CORE
+   help
+ Say yes here if you want support for Texas Instruments AIC audio
+ codec.
+ You have to select individual I2C or SPI depending on
+ AIC3XXX interfacing with platform.
+
+config MFD_AIC3XXX_I2C
+   bool Support Texas Instruments AIC3XXX platform with I2C
+   select MFD_AIC3XXX
+   select REGMAP_I2C
+   depends on I2C
+   help
+ Support for the Texas Instruments TLV320AIC3XXX family of audio SoC
+ core functionality controlled via I2C.  This driver provides common
+ support for accessing the device, additional drivers must be enabled
+ in order to use the functionality of the device.
+
+config MFD_AIC3XXX_SPI
+   bool Support Texas Instruments AIC3XXX  platform with SPI
+   select MFD_AIC3XXX
+   select REGMAP_SPI
+   depends on SPI_MASTER
+   help
+ Support for the Texas Instruments TLV320AIC3XXX family of audio SoC
+ core functionality controlled via SPI.  This driver provides common
+ support for accessing the device, additional drivers must be enabled
+ in order to use the functionality of the device.
+
+config MFD_AIC3262
+   bool Support Texas Instruments AIC3262
+   depends on MFD_AIC3XXX
+   help
+ If you say yes here you will get support for Texas Instrument
+ TLV320AIC3262 low power audio SoC.
+ Addition driver must be enabled to use this in order to use
+ functionality on device.
+
 config MFD_SM501
tristate Support for Silicon Motion SM501
 ---help---
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index f2216df..8c97872 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -6,6 +6,9 @@
 obj-$(CONFIG_MFD_88PM860X) += 88pm860x.o
 obj-$(CONFIG_MFD_88PM800)  += 88pm800.o 88pm80x.o
 obj-$(CONFIG_MFD_88PM805)  += 88pm805.o 88pm80x.o
+obj-$(CONFIG_MFD_AIC3XXX)  += tlv320aic3xxx-core.o tlv320aic3xxx-irq.o
+obj-$(CONFIG_MFD_AIC3XXX_I2C)  += tlv320aic3xxx-i2c.o
+obj-$(CONFIG_MFD_AIC3XXX_SPI)  += tlv320aic3xxx-spi.o
 obj-$(CONFIG_MFD_SM501)+= sm501.o
 obj-$(CONFIG_MFD_ASIC3)+= asic3.o tmio_core.o
 
diff --git a/drivers/mfd/tlv320aic3xxx-core.c b/drivers/mfd/tlv320aic3xxx-core.c
new file mode 100644
index 000..6fd151b
--- /dev/null
+++ b/drivers/mfd/tlv320aic3xxx-core.c
@@ -0,0 +1,462 @@
+/*
+ * tlv320aic3xxx-core.c  -- driver for TLV320AIC3XXX
+ *
+ * Author:  Mukund Navada nav...@ti.com
+ *  Mehar Bajwa mehar.ba...@ti.com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+#include linux/kernel.h
+#include linux

[PATCH 2/2] ASoC: aic: Support for AIC family DSPs

2012-12-11 Thread Mehar Bajwa
AIC family of audio CODECs from TI features a programmable miniDSP for
performing signal processing operations. Due to commonality of functions
across the CODECs a common library will be used to provide support for them.

Signed-off-by: Mehar Bajwa 
---
 sound/soc/codecs/Kconfig   |5 +
 sound/soc/codecs/Makefile  |2 +
 sound/soc/codecs/aic3xxx_cfw.h |  529 +++
 sound/soc/codecs/aic3xxx_cfw_ops.c |  989 
 sound/soc/codecs/aic3xxx_cfw_ops.h |   98 
 5 files changed, 1623 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/codecs/aic3xxx_cfw.h
 create mode 100644 sound/soc/codecs/aic3xxx_cfw_ops.c
 create mode 100644 sound/soc/codecs/aic3xxx_cfw_ops.h

diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 73d8cea..52b3601 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -188,6 +188,11 @@ config SND_SOC_ADAV80X
 config SND_SOC_ADS117X
tristate
 
+config SND_SOC_AIC_CFW
+   tristate
+   default y if SND_SOC_TLV320AIC3262=y
+   default m if SND_SOC_TLV320AIC3262=m
+
 config SND_SOC_AK4104
tristate
 
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index a3f8f4f..ffda11b 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -9,6 +9,7 @@ snd-soc-adau1701-objs := adau1701.o
 snd-soc-adau1373-objs := adau1373.o
 snd-soc-adav80x-objs := adav80x.o
 snd-soc-ads117x-objs := ads117x.o
+snd-soc-aic3xxx-cfw-ops-objs := aic3xxx_cfw_ops.o
 snd-soc-ak4104-objs := ak4104.o
 snd-soc-ak4535-objs := ak4535.o
 snd-soc-ak4641-objs := ak4641.o
@@ -132,6 +133,7 @@ obj-$(CONFIG_SND_SOC_ADAU1373)  += snd-soc-adau1373.o
 obj-$(CONFIG_SND_SOC_ADAU1701)  += snd-soc-adau1701.o
 obj-$(CONFIG_SND_SOC_ADAV80X)  += snd-soc-adav80x.o
 obj-$(CONFIG_SND_SOC_ADS117X)  += snd-soc-ads117x.o
+obj-$(CONFIG_SND_SOC_AIC_CFW)  += snd-soc-aic3xxx-cfw-ops.o
 obj-$(CONFIG_SND_SOC_AK4104)   += snd-soc-ak4104.o
 obj-$(CONFIG_SND_SOC_AK4535)   += snd-soc-ak4535.o
 obj-$(CONFIG_SND_SOC_AK4641)   += snd-soc-ak4641.o
diff --git a/sound/soc/codecs/aic3xxx_cfw.h b/sound/soc/codecs/aic3xxx_cfw.h
new file mode 100644
index 000..b88485d
--- /dev/null
+++ b/sound/soc/codecs/aic3xxx_cfw.h
@@ -0,0 +1,529 @@
+/*
+ *  aic3xxx_cfw.h  --  SoC audio for TI OMAP44XX SDP
+ *  Codec Firmware Declarations
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef AIC_FIRMWARE_H_
+#define AIC_FIRMWARE_H_
+
+
+#define AIC_FW_MAGIC 0xC0D1F1ED
+
+
+/** \defgroup pd Arbitrary Limitations */
+/* @{ */
+#ifndef AIC_MAX_ID
+#define AIC_MAX_ID  (64)   /**= AIC_CMD_DELAY)
+
+/**
+ * AIC Block Type
+ *
+ * Block identifier
+ *
+ */
+enum __attribute__ ((__packed__)) aic_block_t {
+   AIC_BLOCK_SYSTEM_PRE,
+   AIC_BLOCK_A_INST,
+   AIC_BLOCK_A_A_COEF,
+   AIC_BLOCK_A_B_COEF,
+   AIC_BLOCK_A_F_COEF,
+   AIC_BLOCK_D_INST,
+   AIC_BLOCK_D_A1_COEF,
+   AIC_BLOCK_D_B1_COEF,
+   AIC_BLOCK_D_A2_COEF,
+   AIC_BLOCK_D_B2_COEF,
+   AIC_BLOCK_D_F_COEF,
+   AIC_BLOCK_SYSTEM_POST,
+   AIC_BLOCK_N,
+   AIC_BLOCK_INVALID,
+};
+#define AIC_BLOCK_D_A_COEF AIC_BLOCK_D_A1_COEF
+#define AIC_BLOCK_D_B_COEF AIC_BLOCK_D_B1_COEF
+
+/**
+ * AIC Block
+ *
+ * A block of logically grouped sequences/commands/cmd-commands
+ *
+ */
+struct aic_block {
+   enum aic_block_t type;
+   int ncmds;
+   union aic_cmd cmd[];
+};
+#define AIC_BLOCK_SIZE(ncmds) (sizeof(struct aic_block) + \
+   ((ncmds)*sizeof(union aic_cmd)))
+
+/**
+ * AIC Image
+ *
+ * A downloadable image
+ */
+struct aic_image {
+   char name[AIC_MAX_ID];  /**< Name of the pfw/overlay/configuration*/
+   char *desc; /**< User string*/
+   int mute_flags;
+   struct aic_block *block[AIC_BLOCK_N];
+};
+
+
+
+/**
+ * AIC PLL
+ *
+ * PLL configuration sequence and match critirea
+ */
+struct aic_pll {
+   char name[AIC_MAX_ID];  /**< Name of the PLL sequence*/
+   char *desc; /**< User string*/
+   struct aic_block *seq;
+};
+
+/**
+ * AIC Control
+ *
+ * Run-time control for a process flow
+ */
+struct aic_control {
+   char name[AIC_MAX_ID];  /**< Control identifier*/
+   char *desc; /**< User string*/
+   int mute_flags;

[PATCH 2/2] ASoC: aic: Support for AIC family DSPs

2012-12-11 Thread Mehar Bajwa
AIC family of audio CODECs from TI features a programmable miniDSP for
performing signal processing operations. Due to commonality of functions
across the CODECs a common library will be used to provide support for them.

Signed-off-by: Mehar Bajwa mehar.ba...@ti.com
---
 sound/soc/codecs/Kconfig   |5 +
 sound/soc/codecs/Makefile  |2 +
 sound/soc/codecs/aic3xxx_cfw.h |  529 +++
 sound/soc/codecs/aic3xxx_cfw_ops.c |  989 
 sound/soc/codecs/aic3xxx_cfw_ops.h |   98 
 5 files changed, 1623 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/codecs/aic3xxx_cfw.h
 create mode 100644 sound/soc/codecs/aic3xxx_cfw_ops.c
 create mode 100644 sound/soc/codecs/aic3xxx_cfw_ops.h

diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 73d8cea..52b3601 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -188,6 +188,11 @@ config SND_SOC_ADAV80X
 config SND_SOC_ADS117X
tristate
 
+config SND_SOC_AIC_CFW
+   tristate
+   default y if SND_SOC_TLV320AIC3262=y
+   default m if SND_SOC_TLV320AIC3262=m
+
 config SND_SOC_AK4104
tristate
 
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index a3f8f4f..ffda11b 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -9,6 +9,7 @@ snd-soc-adau1701-objs := adau1701.o
 snd-soc-adau1373-objs := adau1373.o
 snd-soc-adav80x-objs := adav80x.o
 snd-soc-ads117x-objs := ads117x.o
+snd-soc-aic3xxx-cfw-ops-objs := aic3xxx_cfw_ops.o
 snd-soc-ak4104-objs := ak4104.o
 snd-soc-ak4535-objs := ak4535.o
 snd-soc-ak4641-objs := ak4641.o
@@ -132,6 +133,7 @@ obj-$(CONFIG_SND_SOC_ADAU1373)  += snd-soc-adau1373.o
 obj-$(CONFIG_SND_SOC_ADAU1701)  += snd-soc-adau1701.o
 obj-$(CONFIG_SND_SOC_ADAV80X)  += snd-soc-adav80x.o
 obj-$(CONFIG_SND_SOC_ADS117X)  += snd-soc-ads117x.o
+obj-$(CONFIG_SND_SOC_AIC_CFW)  += snd-soc-aic3xxx-cfw-ops.o
 obj-$(CONFIG_SND_SOC_AK4104)   += snd-soc-ak4104.o
 obj-$(CONFIG_SND_SOC_AK4535)   += snd-soc-ak4535.o
 obj-$(CONFIG_SND_SOC_AK4641)   += snd-soc-ak4641.o
diff --git a/sound/soc/codecs/aic3xxx_cfw.h b/sound/soc/codecs/aic3xxx_cfw.h
new file mode 100644
index 000..b88485d
--- /dev/null
+++ b/sound/soc/codecs/aic3xxx_cfw.h
@@ -0,0 +1,529 @@
+/*
+ *  aic3xxx_cfw.h  --  SoC audio for TI OMAP44XX SDP
+ *  Codec Firmware Declarations
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef AIC_FIRMWARE_H_
+#define AIC_FIRMWARE_H_
+
+
+#define AIC_FW_MAGIC 0xC0D1F1ED
+
+
+/** \defgroup pd Arbitrary Limitations */
+/* @{ */
+#ifndef AIC_MAX_ID
+#define AIC_MAX_ID  (64)   /**Max length of string identifies*/
+#define AIC_MAX_VARS   (256)   /**Number of variables alive at the*/
+   /**same time in an acx file*/
+#endif
+
+/* @} */
+
+
+
+/** \defgroup st Enums, Flags, Macros and Supporting Types */
+/* @{ */
+
+
+/**
+ * Device Family Identifier
+ *
+ */
+enum __attribute__ ((__packed__)) aic_dfamily {
+   AIC_DFM_TYPE_A,
+   AIC_DFM_TYPE_B,
+   AIC_DFM_TYPE_C
+};
+
+/**
+ * Device Identifier
+ *
+ */
+enum __attribute__ ((__packed__)) aic_device {
+   AIC_DEV_DAC3120,
+   AIC_DEV_DAC3100,
+   AIC_DEV_AIC3120,
+   AIC_DEV_AIC3100,
+   AIC_DEV_AIC3110,
+   AIC_DEV_AIC3111,
+   AIC_DEV_AIC36,
+   AIC_DEV_AIC3206,
+   AIC_DEV_AIC3204,
+   AIC_DEV_AIC3254,
+   AIC_DEV_AIC3256,
+   AIC_DEV_AIC3253,
+   AIC_DEV_AIC3212,
+   AIC_DEV_AIC3262,
+   AIC_DEV_AIC3017,
+   AIC_DEV_AIC3008,
+
+   AIC_DEV_AIC3266,
+   AIC_DEV_AIC3285,
+};
+
+/**
+ * Transition Sequence Identifier
+ *
+ */
+enum aic_transition_t {
+   AIC_TRN_INIT,
+   AIC_TRN_RESUME,
+   AIC_TRN_NEUTRAL,
+   AIC_TRN_A_MUTE,
+   AIC_TRN_D_MUTE,
+   AIC_TRN_AD_MUTE,
+   AIC_TRN_A_UNMUTE,
+   AIC_TRN_D_UNMUTE,
+   AIC_TRN_AD_UNMUTE,
+   AIC_TRN_SUSPEND,
+   AIC_TRN_EXIT,
+   AIC_TRN_N
+};
+
+#ifndef __cplusplus
+static const char *const aic_transition_id[] = {
+   [AIC_TRN_INIT] INIT,
+   [AIC_TRN_RESUME]   RESUME,
+   [AIC_TRN_NEUTRAL]  NEUTRAL,
+   [AIC_TRN_A_MUTE]   A_MUTE,
+   [AIC_TRN_D_MUTE]   D_MUTE,
+   [AIC_TRN_AD_MUTE]  AD_MUTE,
+   [AIC_TRN_A_UNMUTE] A_UNMUTE