summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorYeleswarapu Nagaradhesh <nagaradh@codeaurora.org>2016-06-15 11:30:19 +0530
committerKyle Yan <kyan@codeaurora.org>2016-06-17 15:18:27 -0700
commit5eaa7f688fac14a9aefb9ae4db75f94309a37537 (patch)
tree756b927ff94314f0b76f982b340b8646a7a661eb /include
parent000c189cb63da500580c24b05e6b5559aade5e42 (diff)
wcd9xxx: refactor wcd9xxx audio codec drivers
Refactor wcd9xxx audio codec driver for better handling of codec specific functionalities. CRs-fixed: 1028800 Change-Id: I229ee4a741c5a606e2eb045940f5ee3c4eabf512 Signed-off-by: Phani Kumar Uppalapati <phaniu@codeaurora.org> Signed-off-by: Yeleswarapu Nagaradhesh <nagaradh@codeaurora.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/mfd/msm-cdc-supply.h48
-rwxr-xr-xinclude/linux/mfd/wcd9xxx/core-resource.h153
-rw-r--r--[-rwxr-xr-x]include/linux/mfd/wcd9xxx/core.h170
-rwxr-xr-xinclude/linux/mfd/wcd9xxx/pdata.h9
-rw-r--r--include/linux/mfd/wcd9xxx/wcd-gpio-ctrl.h34
-rw-r--r--include/linux/mfd/wcd9xxx/wcd9xxx-irq.h32
-rw-r--r--include/linux/mfd/wcd9xxx/wcd9xxx-utils.h119
7 files changed, 315 insertions, 250 deletions
diff --git a/include/linux/mfd/msm-cdc-supply.h b/include/linux/mfd/msm-cdc-supply.h
new file mode 100644
index 000000000000..b40f44b1f12f
--- /dev/null
+++ b/include/linux/mfd/msm-cdc-supply.h
@@ -0,0 +1,48 @@
+/* Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+#ifndef __CODEC_POWER_SUPPLY_H__
+#define __CODEC_POWER_SUPPLY_H__
+
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/regulator/consumer.h>
+
+struct cdc_regulator {
+ const char *name;
+ int min_uV;
+ int max_uV;
+ int optimum_uA;
+ bool ondemand;
+ struct regulator *regulator;
+};
+
+extern int msm_cdc_get_power_supplies(struct device *dev,
+ struct cdc_regulator **cdc_vreg,
+ int *total_num_supplies);
+extern int msm_cdc_disable_static_supplies(struct device *dev,
+ struct regulator_bulk_data *supplies,
+ struct cdc_regulator *cdc_vreg,
+ int num_supplies);
+extern int msm_cdc_release_supplies(struct device *dev,
+ struct regulator_bulk_data *supplies,
+ struct cdc_regulator *cdc_vreg,
+ int num_supplies);
+extern int msm_cdc_enable_static_supplies(struct device *dev,
+ struct regulator_bulk_data *supplies,
+ struct cdc_regulator *cdc_vreg,
+ int num_supplies);
+extern int msm_cdc_init_supplies(struct device *dev,
+ struct regulator_bulk_data **supplies,
+ struct cdc_regulator *cdc_vreg,
+ int num_supplies);
+#endif
diff --git a/include/linux/mfd/wcd9xxx/core-resource.h b/include/linux/mfd/wcd9xxx/core-resource.h
deleted file mode 100755
index fa32fd4b13ee..000000000000
--- a/include/linux/mfd/wcd9xxx/core-resource.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#ifndef __MFD_CORE_RESOURCE_H__
-#define __MFD_CORE_RESOURCE_H__
-
-#include <linux/types.h>
-#include <linux/interrupt.h>
-#include <linux/pm_qos.h>
-
-#define WCD9XXX_MAX_IRQ_REGS 4
-#define WCD9XXX_MAX_NUM_IRQS (WCD9XXX_MAX_IRQ_REGS * 8)
-
-struct intr_data {
- int intr_num;
- bool clear_first;
-};
-
-enum wcd9xxx_pm_state {
- WCD9XXX_PM_SLEEPABLE,
- WCD9XXX_PM_AWAKE,
- WCD9XXX_PM_ASLEEP,
-};
-
-enum {
- WCD9XXX_INTR_STATUS_BASE = 0,
- WCD9XXX_INTR_CLEAR_BASE,
- WCD9XXX_INTR_MASK_BASE,
- WCD9XXX_INTR_LEVEL_BASE,
- WCD9XXX_INTR_CLR_COMMIT,
- WCD9XXX_INTR_REG_MAX,
-};
-
-enum wcd9xxx_intf_status {
- WCD9XXX_INTERFACE_TYPE_PROBING,
- WCD9XXX_INTERFACE_TYPE_SLIMBUS,
- WCD9XXX_INTERFACE_TYPE_I2C,
-};
-
-struct wcd9xxx_core_resource {
- struct mutex irq_lock;
- struct mutex nested_irq_lock;
-
- enum wcd9xxx_pm_state pm_state;
- struct mutex pm_lock;
- /* pm_wq notifies change of pm_state */
- wait_queue_head_t pm_wq;
- struct pm_qos_request pm_qos_req;
- int wlock_holders;
-
-
- /* holds the table of interrupts per codec */
- const struct intr_data *intr_table;
- int intr_table_size;
- unsigned int irq_base;
- unsigned int irq;
- u8 irq_masks_cur[WCD9XXX_MAX_IRQ_REGS];
- u8 irq_masks_cache[WCD9XXX_MAX_IRQ_REGS];
- bool irq_level_high[WCD9XXX_MAX_NUM_IRQS];
- int num_irqs;
- int num_irq_regs;
- u16 intr_reg[WCD9XXX_INTR_REG_MAX];
-
- /* Callback functions to read/write codec registers */
- int (*codec_reg_read) (struct wcd9xxx_core_resource *,
- unsigned short);
- int (*codec_reg_write) (struct wcd9xxx_core_resource *,
- unsigned short, u8);
- int (*codec_bulk_read) (struct wcd9xxx_core_resource *,
- unsigned short, int, u8 *);
- int (*codec_bulk_write) (struct wcd9xxx_core_resource *,
- unsigned short, int, u8 *);
-
- /* Pointer to parent container data structure */
- void *parent;
-
- struct device *dev;
-};
-
-extern int wcd9xxx_core_res_init(
- struct wcd9xxx_core_resource*,
- int, int,
- int (*codec_read)(struct wcd9xxx_core_resource *, unsigned short),
- int (*codec_write)(struct wcd9xxx_core_resource *, unsigned short, u8),
- int (*codec_bulk_read) (struct wcd9xxx_core_resource *, unsigned short,
- int, u8 *),
- int (*codec_bulk_write) (struct wcd9xxx_core_resource *, unsigned short,
- int, u8 *));
-
-extern void wcd9xxx_core_res_deinit(
- struct wcd9xxx_core_resource *);
-
-extern int wcd9xxx_core_res_suspend(
- struct wcd9xxx_core_resource *,
- pm_message_t);
-
-extern int wcd9xxx_core_res_resume(
- struct wcd9xxx_core_resource *);
-
-extern int wcd9xxx_core_irq_init(
- struct wcd9xxx_core_resource*);
-
-extern int wcd9xxx_initialize_irq(
- struct wcd9xxx_core_resource*,
- unsigned int,
- unsigned int);
-
-enum wcd9xxx_intf_status wcd9xxx_get_intf_type(void);
-void wcd9xxx_set_intf_type(enum wcd9xxx_intf_status);
-
-bool wcd9xxx_lock_sleep(struct wcd9xxx_core_resource *);
-void wcd9xxx_unlock_sleep(struct wcd9xxx_core_resource *);
-void wcd9xxx_nested_irq_lock(struct wcd9xxx_core_resource *);
-void wcd9xxx_nested_irq_unlock(struct wcd9xxx_core_resource *);
-enum wcd9xxx_pm_state wcd9xxx_pm_cmpxchg(
- struct wcd9xxx_core_resource *,
- enum wcd9xxx_pm_state,
- enum wcd9xxx_pm_state);
-
-int wcd9xxx_request_irq(struct wcd9xxx_core_resource *, int,
- irq_handler_t, const char *, void *);
-
-void wcd9xxx_free_irq(struct wcd9xxx_core_resource *, int, void*);
-void wcd9xxx_enable_irq(struct wcd9xxx_core_resource *, int);
-void wcd9xxx_disable_irq(struct wcd9xxx_core_resource *, int);
-void wcd9xxx_disable_irq_sync(struct wcd9xxx_core_resource *, int);
-int wcd9xxx_reg_read(struct wcd9xxx_core_resource *,
- unsigned short);
-int wcd9xxx_reg_write(struct wcd9xxx_core_resource *,
- unsigned short, u8);
-int wcd9xxx_bulk_read(struct wcd9xxx_core_resource *,
- unsigned short, int, u8 *);
-int wcd9xxx_bulk_write(struct wcd9xxx_core_resource*,
- unsigned short, int, u8*);
-int wcd9xxx_reg_update_bits(struct wcd9xxx_core_resource *core_res,
- unsigned short reg, u8 mask, u8 val);
-int wcd9xxx_irq_init(struct wcd9xxx_core_resource *);
-void wcd9xxx_irq_exit(struct wcd9xxx_core_resource *);
-int wcd9xxx_core_res_resume(
- struct wcd9xxx_core_resource *);
-int wcd9xxx_core_res_suspend(
- struct wcd9xxx_core_resource *,
- pm_message_t);
-#endif
diff --git a/include/linux/mfd/wcd9xxx/core.h b/include/linux/mfd/wcd9xxx/core.h
index e0abd4285753..96937a4338a8 100755..100644
--- a/include/linux/mfd/wcd9xxx/core.h
+++ b/include/linux/mfd/wcd9xxx/core.h
@@ -16,9 +16,11 @@
#include <linux/types.h>
#include <linux/platform_device.h>
#include <linux/of_irq.h>
-#include <linux/mfd/wcd9xxx/core-resource.h>
-
+#include <linux/interrupt.h>
+#include <linux/pm_qos.h>
+#define WCD9XXX_MAX_IRQ_REGS 4
+#define WCD9XXX_MAX_NUM_IRQS (WCD9XXX_MAX_IRQ_REGS * 8)
#define WCD9XXX_SLIM_NUM_PORT_REG 3
#define TABLA_VERSION_1_0 0
#define TABLA_VERSION_1_1 1
@@ -58,9 +60,15 @@
#define TASHA_IS_2_0(ver) \
((ver == TASHA_VERSION_2_0) ? 1 : 0)
-enum wcd9xxx_slim_slave_addr_type {
- WCD9XXX_SLIM_SLAVE_ADDR_TYPE_TABLA,
- WCD9XXX_SLIM_SLAVE_ADDR_TYPE_TAIKO,
+#define IS_CODEC_TYPE(wcd, wcdtype) \
+ ((wcd->type == wcdtype) ? true : false)
+#define IS_CODEC_VERSION(wcd, wcdversion) \
+ ((wcd->version == wcdversion) ? true : false)
+
+enum {
+ CDC_V_1_0,
+ CDC_V_1_1,
+ CDC_V_2_0,
};
enum codec_variant {
@@ -70,6 +78,32 @@ enum codec_variant {
WCD9326,
};
+enum wcd9xxx_slim_slave_addr_type {
+ WCD9XXX_SLIM_SLAVE_ADDR_TYPE_0,
+ WCD9XXX_SLIM_SLAVE_ADDR_TYPE_1,
+};
+
+enum wcd9xxx_pm_state {
+ WCD9XXX_PM_SLEEPABLE,
+ WCD9XXX_PM_AWAKE,
+ WCD9XXX_PM_ASLEEP,
+};
+
+enum {
+ WCD9XXX_INTR_STATUS_BASE = 0,
+ WCD9XXX_INTR_CLEAR_BASE,
+ WCD9XXX_INTR_MASK_BASE,
+ WCD9XXX_INTR_LEVEL_BASE,
+ WCD9XXX_INTR_CLR_COMMIT,
+ WCD9XXX_INTR_REG_MAX,
+};
+
+enum wcd9xxx_intf_status {
+ WCD9XXX_INTERFACE_TYPE_PROBING,
+ WCD9XXX_INTERFACE_TYPE_SLIMBUS,
+ WCD9XXX_INTERFACE_TYPE_I2C,
+};
+
enum {
/* INTR_REG 0 */
WCD9XXX_IRQ_SLIMBUS = 0,
@@ -128,50 +162,47 @@ enum {
};
enum {
- /* INTR_REG 0 */
- WCD9335_IRQ_FLL_LOCK_LOSS = 1,
- WCD9335_IRQ_HPH_PA_OCPL_FAULT,
- WCD9335_IRQ_HPH_PA_OCPR_FAULT,
- WCD9335_IRQ_EAR_PA_OCP_FAULT,
- WCD9335_IRQ_HPH_PA_CNPL_COMPLETE,
- WCD9335_IRQ_HPH_PA_CNPR_COMPLETE,
- WCD9335_IRQ_EAR_PA_CNP_COMPLETE,
- /* INTR_REG 1 */
- WCD9335_IRQ_MBHC_SW_DET,
- WCD9335_IRQ_MBHC_ELECT_INS_REM_DET,
- WCD9335_IRQ_MBHC_BUTTON_PRESS_DET,
- WCD9335_IRQ_MBHC_BUTTON_RELEASE_DET,
- WCD9335_IRQ_MBHC_ELECT_INS_REM_LEG_DET,
- WCD9335_IRQ_RESERVED_0,
- WCD9335_IRQ_RESERVED_1,
- WCD9335_IRQ_RESERVED_2,
- /* INTR_REG 2 */
- WCD9335_IRQ_LINE_PA1_CNP_COMPLETE,
- WCD9335_IRQ_LINE_PA2_CNP_COMPLETE,
- WCD9335_IRQ_LINE_PA3_CNP_COMPLETE,
- WCD9335_IRQ_LINE_PA4_CNP_COMPLETE,
- WCD9335_IRQ_SOUNDWIRE,
- WCD9335_IRQ_VDD_DIG_RAMP_COMPLETE,
- WCD9335_IRQ_RCO_ERROR,
- WCD9335_IRQ_SVA_ERROR,
- /* INTR_REG 3 */
- WCD9335_IRQ_MAD_AUDIO,
- WCD9335_IRQ_MAD_BEACON,
- WCD9335_IRQ_MAD_ULTRASOUND,
- WCD9335_IRQ_VBAT_ATTACK,
- WCD9335_IRQ_VBAT_RESTORE,
- WCD9335_IRQ_SVA_OUTBOX1,
- WCD9335_IRQ_SVA_OUTBOX2,
- WCD9335_NUM_IRQS,
-};
-
-enum {
TABLA_NUM_IRQS = WCD9310_NUM_IRQS,
SITAR_NUM_IRQS = WCD9310_NUM_IRQS,
TAIKO_NUM_IRQS = WCD9XXX_NUM_IRQS,
TAPAN_NUM_IRQS = WCD9306_NUM_IRQS,
TOMTOM_NUM_IRQS = WCD9330_NUM_IRQS,
- TASHA_NUM_IRQS = WCD9335_NUM_IRQS,
+};
+
+struct intr_data {
+ int intr_num;
+ bool clear_first;
+};
+
+struct wcd9xxx_core_resource {
+ struct mutex irq_lock;
+ struct mutex nested_irq_lock;
+
+ enum wcd9xxx_pm_state pm_state;
+ struct mutex pm_lock;
+ /* pm_wq notifies change of pm_state */
+ wait_queue_head_t pm_wq;
+ struct pm_qos_request pm_qos_req;
+ int wlock_holders;
+
+
+ /* holds the table of interrupts per codec */
+ const struct intr_data *intr_table;
+ int intr_table_size;
+ unsigned int irq_base;
+ unsigned int irq;
+ u8 irq_masks_cur[WCD9XXX_MAX_IRQ_REGS];
+ u8 irq_masks_cache[WCD9XXX_MAX_IRQ_REGS];
+ bool irq_level_high[WCD9XXX_MAX_NUM_IRQS];
+ int num_irqs;
+ int num_irq_regs;
+ u16 intr_reg[WCD9XXX_INTR_REG_MAX];
+ struct regmap *wcd_core_regmap;
+
+ /* Pointer to parent container data structure */
+ void *parent;
+
+ struct device *dev;
};
/*
@@ -243,6 +274,9 @@ struct wcd9xxx_codec_type {
int version; /* -1 to retrive version from chip version register */
enum wcd9xxx_slim_slave_addr_type slim_slave_type;
u16 i2c_chip_status;
+ const struct intr_data *intr_tbl;
+ int intr_tbl_size;
+ u16 intr_reg[WCD9XXX_INTR_REG_MAX];
};
struct wcd9xxx_power_region {
@@ -266,6 +300,8 @@ struct wcd9xxx {
int bytes, void *dest, bool interface_reg);
int (*write_dev)(struct wcd9xxx *wcd9xxx, unsigned short reg,
int bytes, void *src, bool interface_reg);
+ int (*multi_reg_write)(struct wcd9xxx *wcd9xxx, const void *data,
+ size_t count);
int (*dev_down)(struct wcd9xxx *wcd9xxx);
int (*post_reset)(struct wcd9xxx *wcd9xxx);
@@ -287,10 +323,9 @@ struct wcd9xxx {
struct wcd9xxx_ch *tx_chs;
u32 mclk_rate;
enum codec_variant type;
- bool using_regmap;
struct regmap *regmap;
- const struct wcd9xxx_codec_type *codec_type;
+ struct wcd9xxx_codec_type *codec_type;
bool prev_pg_valid;
u8 prev_pg;
struct wcd9xxx_power_region *wcd9xxx_pwr[WCD9XXX_MAX_PWR_REGIONS];
@@ -315,26 +350,43 @@ int wcd9xxx_set_power_state(struct wcd9xxx *, enum codec_power_states,
int wcd9xxx_get_current_power_state(struct wcd9xxx *,
enum wcd_power_regions);
+int wcd9xxx_page_write(struct wcd9xxx *wcd9xxx, unsigned short *reg);
+
int wcd9xxx_slim_bulk_write(struct wcd9xxx *wcd9xxx,
struct wcd9xxx_reg_val *bulk_reg,
unsigned int size, bool interface);
+extern int wcd9xxx_core_res_init(
+ struct wcd9xxx_core_resource*,
+ int, int, struct regmap *);
+
+extern void wcd9xxx_core_res_deinit(
+ struct wcd9xxx_core_resource *);
+
+extern int wcd9xxx_core_res_suspend(
+ struct wcd9xxx_core_resource *,
+ pm_message_t);
+
+extern int wcd9xxx_core_res_resume(
+ struct wcd9xxx_core_resource *);
+
+extern int wcd9xxx_core_irq_init(
+ struct wcd9xxx_core_resource*);
+
+extern int wcd9xxx_assign_irq(struct wcd9xxx_core_resource*,
+ unsigned int,
+ unsigned int);
+
+extern enum wcd9xxx_intf_status wcd9xxx_get_intf_type(void);
+extern void wcd9xxx_set_intf_type(enum wcd9xxx_intf_status);
+
+extern enum wcd9xxx_pm_state wcd9xxx_pm_cmpxchg(
+ struct wcd9xxx_core_resource *,
+ enum wcd9xxx_pm_state,
+ enum wcd9xxx_pm_state);
static inline int __init wcd9xxx_irq_of_init(struct device_node *node,
struct device_node *parent)
{
return 0;
}
-
-static inline void wcd9xxx_reg_update(struct wcd9xxx *core,
- unsigned short reg,
- u8 mask, u8 val)
-{
- u8 reg_val;
-
- if (core) {
- reg_val = wcd9xxx_reg_read(&core->core_res, reg);
- reg_val = (reg_val & ~mask) | (val & mask);
- wcd9xxx_reg_write(&core->core_res, reg, reg_val);
- }
-}
#endif
diff --git a/include/linux/mfd/wcd9xxx/pdata.h b/include/linux/mfd/wcd9xxx/pdata.h
index 791cb7f1654a..52277f26b5a4 100755
--- a/include/linux/mfd/wcd9xxx/pdata.h
+++ b/include/linux/mfd/wcd9xxx/pdata.h
@@ -10,11 +10,12 @@
* GNU General Public License for more details.
*/
-#ifndef __MFD_TABLA_PDATA_H__
+#ifndef __MFD_WCD9XXX_PDATA_H__
-#define __MFD_TABLA_PDATA_H__
+#define __MFD_WCD9XXX_PDATA_H__
#include <linux/slimbus/slimbus.h>
+#include <linux/mfd/msm-cdc-supply.h>
#define MICBIAS_EXT_BYP_CAP 0x00
#define MICBIAS_NO_EXT_BYP_CAP 0x01
@@ -183,12 +184,12 @@ struct wcd9xxx_pdata {
struct slim_device slimbus_slave_device;
struct wcd9xxx_micbias_setting micbias;
struct wcd9xxx_ocp_setting ocp;
- struct wcd9xxx_regulator regulator[WCD9XXX_MAX_REGULATOR];
+ struct cdc_regulator *regulator;
+ int num_supplies;
u32 mclk_rate;
u32 dmic_sample_rate;
u32 mad_dmic_sample_rate;
u32 dmic_clk_drv;
- enum codec_variant cdc_variant;
u16 use_pinctrl;
};
diff --git a/include/linux/mfd/wcd9xxx/wcd-gpio-ctrl.h b/include/linux/mfd/wcd9xxx/wcd-gpio-ctrl.h
deleted file mode 100644
index 1260c33d1003..000000000000
--- a/include/linux/mfd/wcd9xxx/wcd-gpio-ctrl.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Copyright (c) 2016, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only 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.
- */
-
-#ifndef __MFD_CDC_GPIO_CTRL_H_
-#define __MFD_CDC_GPIO_CTRL_H_
-
-#include <linux/types.h>
-#include <linux/of.h>
-
-#ifdef CONFIG_WCD9335_CODEC
-extern int wcd_gpio_ctrl_select_sleep_state(struct device_node *);
-extern int wcd_gpio_ctrl_select_active_state(struct device_node *);
-
-#else
-int wcd_gpio_ctrl_select_sleep_state(struct device_node *np)
-{
- return 0;
-}
-int wcd_gpio_ctrl_select_active_state(struct device_node *np)
-{
- return 0;
-}
-#endif
-
-#endif
diff --git a/include/linux/mfd/wcd9xxx/wcd9xxx-irq.h b/include/linux/mfd/wcd9xxx/wcd9xxx-irq.h
new file mode 100644
index 000000000000..f1b7a4320ad1
--- /dev/null
+++ b/include/linux/mfd/wcd9xxx/wcd9xxx-irq.h
@@ -0,0 +1,32 @@
+/* Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+#include <linux/types.h>
+#include <linux/mfd/wcd9xxx/core.h>
+
+#ifndef __MFD_WCD9XXX_IRQ_H
+#define __MFD_WCD9XXX_IRQ_H
+bool wcd9xxx_lock_sleep(struct wcd9xxx_core_resource *);
+void wcd9xxx_unlock_sleep(struct wcd9xxx_core_resource *);
+void wcd9xxx_nested_irq_lock(struct wcd9xxx_core_resource *);
+void wcd9xxx_nested_irq_unlock(struct wcd9xxx_core_resource *);
+int wcd9xxx_request_irq(struct wcd9xxx_core_resource *, int,
+ irq_handler_t, const char *, void *);
+
+void wcd9xxx_free_irq(struct wcd9xxx_core_resource *, int, void*);
+void wcd9xxx_enable_irq(struct wcd9xxx_core_resource *, int);
+void wcd9xxx_disable_irq(struct wcd9xxx_core_resource *, int);
+void wcd9xxx_disable_irq_sync(struct wcd9xxx_core_resource *, int);
+
+int wcd9xxx_irq_init(struct wcd9xxx_core_resource *);
+void wcd9xxx_irq_exit(struct wcd9xxx_core_resource *);
+#endif
diff --git a/include/linux/mfd/wcd9xxx/wcd9xxx-utils.h b/include/linux/mfd/wcd9xxx/wcd9xxx-utils.h
new file mode 100644
index 000000000000..441d70b97f4e
--- /dev/null
+++ b/include/linux/mfd/wcd9xxx/wcd9xxx-utils.h
@@ -0,0 +1,119 @@
+/* Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+#ifndef __WCD9XXX_UTILS_H__
+#define __WCD9XXX_UTILS_H__
+
+#include <linux/kernel.h>
+#include <linux/device.h>
+#include <linux/regmap.h>
+#include <linux/mfd/wcd9xxx/pdata.h>
+#include <linux/mfd/wcd9xxx/core.h>
+
+struct wcd9xxx_pdata *wcd9xxx_populate_dt_data(struct device *dev);
+int wcd9xxx_bringup(struct device *dev);
+int wcd9xxx_bringdown(struct device *dev);
+struct regmap *wcd9xxx_regmap_init(struct device *,
+ const struct regmap_config *);
+int wcd9xxx_reset(struct device *dev);
+int wcd9xxx_reset_low(struct device *dev);
+int wcd9xxx_get_codec_info(struct device *dev);
+
+typedef int (*codec_bringup_fn)(struct wcd9xxx *);
+typedef int (*codec_bringdown_fn)(struct wcd9xxx *);
+typedef int (*codec_type_fn)(struct wcd9xxx *,
+ struct wcd9xxx_codec_type *);
+
+#ifdef CONFIG_WCD9335_CODEC
+extern int wcd9335_bringup(struct wcd9xxx *wcd9xxx);
+extern int wcd9335_bringdown(struct wcd9xxx *wcd9xxx);
+extern int wcd9335_get_codec_info(struct wcd9xxx *,
+ struct wcd9xxx_codec_type *);
+#endif
+
+#ifdef CONFIG_WCD9330_CODEC
+extern int wcd9330_bringup(struct wcd9xxx *wcd9xxx);
+extern int wcd9330_bringdown(struct wcd9xxx *wcd9xxx);
+extern int wcd9330_get_codec_info(struct wcd9xxx *,
+ struct wcd9xxx_codec_type *);
+#endif
+
+static inline codec_bringdown_fn wcd9xxx_bringdown_fn(int type)
+{
+ codec_bringdown_fn cdc_bdown_fn;
+
+ switch (type) {
+#ifdef CONFIG_WCD9335_CODEC
+ case WCD9335:
+ cdc_bdown_fn = wcd9335_bringdown;
+ break;
+#endif
+#ifdef CONFIG_WCD9330_CODEC
+ case WCD9330:
+ cdc_bdown_fn = wcd9330_bringdown;
+ break;
+#endif
+ default:
+ cdc_bdown_fn = NULL;
+ break;
+ }
+
+ return cdc_bdown_fn;
+}
+
+static inline codec_bringup_fn wcd9xxx_bringup_fn(int type)
+{
+ codec_bringup_fn cdc_bup_fn;
+
+ switch (type) {
+#ifdef CONFIG_WCD9335_CODEC
+ case WCD9335:
+ cdc_bup_fn = wcd9335_bringup;
+ break;
+#endif
+#ifdef CONFIG_WCD9330_CODEC
+ case WCD9330:
+ cdc_bup_fn = wcd9330_bringup;
+ break;
+#endif
+ default:
+ cdc_bup_fn = NULL;
+ break;
+ }
+
+ return cdc_bup_fn;
+}
+
+static inline codec_type_fn wcd9xxx_get_codec_info_fn(int type)
+{
+ codec_type_fn cdc_type_fn;
+
+ switch (type) {
+#ifdef CONFIG_WCD9335_CODEC
+ case WCD9335:
+ cdc_type_fn = wcd9335_get_codec_info;
+ break;
+#endif
+#ifdef CONFIG_WCD9330_CODEC
+ case WCD9330:
+ cdc_type_fn = wcd9330_get_codec_info;
+ break;
+#endif
+ default:
+ cdc_type_fn = NULL;
+ break;
+ }
+
+ return cdc_type_fn;
+}
+#endif
+