cf3d81b16888606076dc9d7b5b3278be6d21fdcc
[linux-2.6-microblaze.git] / arch / arm / mach-omap2 / twl-common.c
1 /*
2  * twl-common.c
3  *
4  * Copyright (C) 2011 Texas Instruments, Inc..
5  * Author: Peter Ujfalusi <peter.ujfalusi@ti.com>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * version 2 as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19  * 02110-1301 USA
20  *
21  */
22
23 #include <linux/i2c.h>
24 #include <linux/i2c/twl.h>
25 #include <linux/gpio.h>
26 #include <linux/string.h>
27 #include <linux/phy/phy.h>
28 #include <linux/regulator/machine.h>
29 #include <linux/regulator/fixed.h>
30
31 #include "soc.h"
32 #include "twl-common.h"
33 #include "pm.h"
34 #include "voltage.h"
35 #include "mux.h"
36
37 static struct i2c_board_info __initdata pmic_i2c_board_info = {
38         .addr           = 0x48,
39         .flags          = I2C_CLIENT_WAKE,
40 };
41
42 void __init omap_pmic_init(int bus, u32 clkrate,
43                            const char *pmic_type, int pmic_irq,
44                            struct twl4030_platform_data *pmic_data)
45 {
46         omap_mux_init_signal("sys_nirq", OMAP_PIN_INPUT_PULLUP | OMAP_PIN_OFF_WAKEUPENABLE);
47         strlcpy(pmic_i2c_board_info.type, pmic_type,
48                 sizeof(pmic_i2c_board_info.type));
49         pmic_i2c_board_info.irq = pmic_irq;
50         pmic_i2c_board_info.platform_data = pmic_data;
51
52         omap_register_i2c_bus(bus, clkrate, &pmic_i2c_board_info, 1);
53 }
54
55 void __init omap_pmic_late_init(void)
56 {
57         /* Init the OMAP TWL parameters (if PMIC has been registerd) */
58         if (!pmic_i2c_board_info.irq)
59                 return;
60
61         omap3_twl_init();
62         omap4_twl_init();
63 }
64
65 #if IS_ENABLED(CONFIG_SND_OMAP_SOC_OMAP_TWL4030)
66 #include <linux/platform_data/omap-twl4030.h>
67
68 /* Commonly used configuration */
69 static struct omap_tw4030_pdata omap_twl4030_audio_data;
70
71 static struct platform_device audio_device = {
72         .name           = "omap-twl4030",
73         .id             = -1,
74 };
75
76 void omap_twl4030_audio_init(char *card_name,
77                                     struct omap_tw4030_pdata *pdata)
78 {
79         if (!pdata)
80                 pdata = &omap_twl4030_audio_data;
81
82         pdata->card_name = card_name;
83
84         audio_device.dev.platform_data = pdata;
85         platform_device_register(&audio_device);
86 }
87
88 #else /* SOC_OMAP_TWL4030 */
89 void omap_twl4030_audio_init(char *card_name,
90                                     struct omap_tw4030_pdata *pdata)
91 {
92         return;
93 }
94 #endif /* SOC_OMAP_TWL4030 */