|
@@ -0,0 +1,104 @@
|
|
|
+/*
|
|
|
+ * twl-common.c
|
|
|
+ *
|
|
|
+ * Copyright (C) 2011 Texas Instruments, Inc..
|
|
|
+ * Author: Peter Ujfalusi <peter.ujfalusi@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/i2c.h>
|
|
|
+#include <linux/i2c/twl.h>
|
|
|
+#include <linux/gpio.h>
|
|
|
+#include <linux/regulator/machine.h>
|
|
|
+#include <linux/regulator/fixed.h>
|
|
|
+
|
|
|
+#include "soc.h"
|
|
|
+#include "twl-common.h"
|
|
|
+#include "pm.h"
|
|
|
+#include "voltage.h"
|
|
|
+#include "mux.h"
|
|
|
+
|
|
|
+static struct i2c_board_info __initdata pmic_i2c_board_info = {
|
|
|
+ .addr = 0x48,
|
|
|
+ .flags = I2C_CLIENT_WAKE,
|
|
|
+};
|
|
|
+
|
|
|
+#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
|
|
|
+static int twl_set_voltage(void *data, int target_uV)
|
|
|
+{
|
|
|
+ struct voltagedomain *voltdm = (struct voltagedomain *)data;
|
|
|
+ return voltdm_scale(voltdm, target_uV);
|
|
|
+}
|
|
|
+
|
|
|
+static int twl_get_voltage(void *data)
|
|
|
+{
|
|
|
+ struct voltagedomain *voltdm = (struct voltagedomain *)data;
|
|
|
+ return voltdm_get_voltage(voltdm);
|
|
|
+}
|
|
|
+#endif
|
|
|
+
|
|
|
+void __init omap_pmic_init(int bus, u32 clkrate,
|
|
|
+ const char *pmic_type, int pmic_irq,
|
|
|
+ struct twl4030_platform_data *pmic_data)
|
|
|
+{
|
|
|
+ omap_mux_init_signal("sys_nirq", OMAP_PIN_INPUT_PULLUP | OMAP_PIN_OFF_WAKEUPENABLE);
|
|
|
+ strncpy(pmic_i2c_board_info.type, pmic_type,
|
|
|
+ sizeof(pmic_i2c_board_info.type));
|
|
|
+ pmic_i2c_board_info.irq = pmic_irq;
|
|
|
+ pmic_i2c_board_info.platform_data = pmic_data;
|
|
|
+
|
|
|
+ omap_register_i2c_bus(bus, clkrate, &pmic_i2c_board_info, 1);
|
|
|
+}
|
|
|
+
|
|
|
+void __init omap4_pmic_init(const char *pmic_type,
|
|
|
+ struct twl4030_platform_data *pmic_data,
|
|
|
+ struct i2c_board_info *devices, int nr_devices)
|
|
|
+{
|
|
|
+ /* PMIC part*/
|
|
|
+ omap_mux_init_signal("sys_nirq1", OMAP_PIN_INPUT_PULLUP | OMAP_PIN_OFF_WAKEUPENABLE);
|
|
|
+ omap_mux_init_signal("fref_clk0_out.sys_drm_msecure", OMAP_PIN_OUTPUT);
|
|
|
+ omap_pmic_init(1, 400, pmic_type, 7 + OMAP44XX_IRQ_GIC_START, pmic_data);
|
|
|
+
|
|
|
+ /* Register additional devices on i2c1 bus if needed */
|
|
|
+ if (devices)
|
|
|
+ i2c_register_board_info(1, devices, nr_devices);
|
|
|
+}
|
|
|
+
|
|
|
+void __init omap_pmic_late_init(void)
|
|
|
+{
|
|
|
+ /* Init the OMAP TWL parameters (if PMIC has been registerd) */
|
|
|
+ if (!pmic_i2c_board_info.irq)
|
|
|
+ return;
|
|
|
+
|
|
|
+ omap3_twl_init();
|
|
|
+ omap4_twl_init();
|
|
|
+}
|
|
|
+
|
|
|
+#if defined(CONFIG_ARCH_OMAP3)
|
|
|
+static struct twl4030_usb_data omap3_usb_pdata = {
|
|
|
+ .usb_mode = T2_USB_MODE_ULPI,
|
|
|
+};
|
|
|
+
|
|
|
+static int omap3_batt_table[] = {
|
|
|
+/* 0 C */
|
|
|
+30800, 29500, 28300, 27100,
|
|
|
+26000, 24900, 23900, 22900, 22000, 21100, 20300, 19400, 18700, 17900,
|
|
|
+17200, 16500, 15900, 15300, 14700, 14100, 13600, 13100, 12600, 12100,
|
|
|
+11600, 11200, 10800, 10400, 10000, 9630, 9280, 8950, 8620, 8310,
|
|
|
+8020, 7730, 7460, 7200, 6950, 6710, 6470, 6250, 6040, 5830,
|
|
|
+5640, 5450, 5260, 5090, 4920, 4760, 4600, 4450, 4310, 4170,
|
|
|
+4040, 3910, 3790, 3670, 3550
|