|
@@ -0,0 +1,104 @@
|
|
|
+/*
|
|
|
+ * OMAP Voltage Controller (VC) interface
|
|
|
+ *
|
|
|
+ * Copyright (C) 2011 Texas Instruments, Inc.
|
|
|
+ *
|
|
|
+ * This file is licensed under the terms of the GNU General Public
|
|
|
+ * License version 2. This program is licensed "as is" without any
|
|
|
+ * warranty of any kind, whether express or implied.
|
|
|
+ */
|
|
|
+#include <linux/kernel.h>
|
|
|
+#include <linux/delay.h>
|
|
|
+#include <linux/init.h>
|
|
|
+#include <linux/bug.h>
|
|
|
+#include <linux/io.h>
|
|
|
+
|
|
|
+#include <asm/div64.h>
|
|
|
+
|
|
|
+#include "iomap.h"
|
|
|
+#include "soc.h"
|
|
|
+#include "voltage.h"
|
|
|
+#include "vc.h"
|
|
|
+#include "prm-regbits-34xx.h"
|
|
|
+#include "prm-regbits-44xx.h"
|
|
|
+#include "prm44xx.h"
|
|
|
+#include "pm.h"
|
|
|
+#include "scrm44xx.h"
|
|
|
+#include "control.h"
|
|
|
+
|
|
|
+/**
|
|
|
+ * struct omap_vc_channel_cfg - describe the cfg_channel bitfield
|
|
|
+ * @sa: bit for slave address
|
|
|
+ * @rav: bit for voltage configuration register
|
|
|
+ * @rac: bit for command configuration register
|
|
|
+ * @racen: enable bit for RAC
|
|
|
+ * @cmd: bit for command value set selection
|
|
|
+ *
|
|
|
+ * Channel configuration bits, common for OMAP3+
|
|
|
+ * OMAP3 register: PRM_VC_CH_CONF
|
|
|
+ * OMAP4 register: PRM_VC_CFG_CHANNEL
|
|
|
+ * OMAP5 register: PRM_VC_SMPS_<voltdm>_CONFIG
|
|
|
+ */
|
|
|
+struct omap_vc_channel_cfg {
|
|
|
+ u8 sa;
|
|
|
+ u8 rav;
|
|
|
+ u8 rac;
|
|
|
+ u8 racen;
|
|
|
+ u8 cmd;
|
|
|
+};
|
|
|
+
|
|
|
+static struct omap_vc_channel_cfg vc_default_channel_cfg = {
|
|
|
+ .sa = BIT(0),
|
|
|
+ .rav = BIT(1),
|
|
|
+ .rac = BIT(2),
|
|
|
+ .racen = BIT(3),
|
|
|
+ .cmd = BIT(4),
|
|
|
+};
|
|
|
+
|
|
|
+/*
|
|
|
+ * On OMAP3+, all VC channels have the above default bitfield
|
|
|
+ * configuration, except the OMAP4 MPU channel. This appears
|
|
|
+ * to be a freak accident as every other VC channel has the
|
|
|
+ * default configuration, thus creating a mutant channel config.
|
|
|
+ */
|
|
|
+static struct omap_vc_channel_cfg vc_mutant_channel_cfg = {
|
|
|
+ .sa = BIT(0),
|
|
|
+ .rav = BIT(2),
|
|
|
+ .rac = BIT(3),
|
|
|
+ .racen = BIT(4),
|
|
|
+ .cmd = BIT(1),
|
|
|
+};
|
|
|
+
|
|
|
+static struct omap_vc_channel_cfg *vc_cfg_bits;
|
|
|
+
|
|
|
+/* Default I2C trace length on pcb, 6.3cm. Used for capacitance calculations. */
|
|
|
+static u32 sr_i2c_pcb_length = 63;
|
|
|
+#define CFG_CHANNEL_MASK 0x1f
|
|
|
+
|
|
|
+/**
|
|
|
+ * omap_vc_config_channel - configure VC channel to PMIC mappings
|
|
|
+ * @voltdm: pointer to voltagdomain defining the desired VC channel
|
|
|
+ *
|
|
|
+ * Configures the VC channel to PMIC mappings for the following
|
|
|
+ * PMIC settings
|
|
|
+ * - i2c slave address (SA)
|
|
|
+ * - voltage configuration address (RAV)
|
|
|
+ * - command configuration address (RAC) and enable bit (RACEN)
|
|
|
+ * - command values for ON, ONLP, RET and OFF (CMD)
|
|
|
+ *
|
|
|
+ * This function currently only allows flexible configuration of the
|
|
|
+ * non-default channel. Starting with OMAP4, there are more than 2
|
|
|
+ * channels, with one defined as the default (on OMAP4, it's MPU.)
|
|
|
+ * Only the non-default channel can be configured.
|
|
|
+ */
|
|
|
+static int omap_vc_config_channel(struct voltagedomain *voltdm)
|
|
|
+{
|
|
|
+ struct omap_vc_channel *vc = voltdm->vc;
|
|
|
+
|
|
|
+ /*
|
|
|
+ * For default channel, the only configurable bit is RACEN.
|
|
|
+ * All others must stay at zero (see function comment above.)
|
|
|
+ */
|
|
|
+ if (vc->flags & OMAP_VC_CHANNEL_DEFAULT)
|
|
|
+ vc->cfg_channel &= vc_cfg_bits->racen;
|
|
|
+
|