Skip to contentSkip to conversation

am33xx: pmic: Add support for tps65217

PATCH New Joel A Fernandes 2 participants 2 messages Oct 31, 2012 – Nov 1, 2012 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 am33xx: pmic: Add support for tps65217

This is mostly copied from "support for TPS65217 PMIC" patches from the old am33xx U-boot tree by Greg Guyyote with additions by Tom Rini, me and others.

Also drop DDR3 voltage level from 1.5V to 1.35V for beaglebone. DDR3 operation is verified at this lower voltage level.

---
 arch/arm/cpu/armv7/am33xx/board.c    |  134 ++++++++++++++++++++++++++++++++++
 arch/arm/cpu/armv7/am33xx/pmic.h     |   76 +++++++++++++++++++
 arch/arm/cpu/armv7/am33xx/tps65217.h |   90 +++++++++++++++++++++++
 3 files changed, 300 insertions(+)
 create mode 100644 arch/arm/cpu/armv7/am33xx/pmic.h
 create mode 100644 arch/arm/cpu/armv7/am33xx/tps65217.h
arch/arm/cpu/armv7/am33xx/board.c +134 -0
index 6de03fd..075295c 100644
@@ -33,6 +33,8 @@
 #include <i2c.h>
 #include <miiphy.h>
 #include <cpsw.h>
+#include "pmic.h"
+#include "tps65217.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -135,6 +137,132 @@ static short inline board_memory_type(void)
 	return EMIF_REG_SDRAM_TYPE_DDR2;
 }
 
+/**
+ * tps65217_reg_read() - Generic function that can read a TPS65217 register
+ * @src_reg:          Source register address
+ * @src_val:          Address of destination variable
+ */
+
+unsigned char tps65217_reg_read(uchar src_reg, uchar *src_val)
+{
+        if (i2c_read(TPS65217_CHIP_PM, src_reg, 1, src_val, 1))
+                return 1;
+        return 0;
+}
+
+/**
+ *  tps65217_reg_write() - Generic function that can write a TPS65217 PMIC
+ *                         register or bit field regardless of protection
+ *                         level.
+ *
+ *  @prot_level:        Register password protection.
+ *                      use PROT_LEVEL_NONE, PROT_LEVEL_1, or PROT_LEVEL_2
+ *  @dest_reg:          Register address to write.
+ *  @dest_val:          Value to write.
+ *  @mask:              Bit mask (8 bits) to be applied.  Function will only
+ *                      change bits that are set in the bit mask.
+ *
+ *  @return:            0 for success, 1 for failure.
+ */
+int tps65217_reg_write(uchar prot_level, uchar dest_reg,
+        uchar dest_val, uchar mask)
+{
+        uchar read_val;
+        uchar xor_reg;
+
+        /* if we are affecting only a bit field, read dest_reg and apply the mask */
+        if (mask != MASK_ALL_BITS) {
+                if (i2c_read(TPS65217_CHIP_PM, dest_reg, 1, &read_val, 1))
+                        return 1;
+                read_val &= (~mask);
+                read_val |= (dest_val & mask);
+                dest_val = read_val;
+        }
+
+        if (prot_level > 0) {
+                xor_reg = dest_reg ^ PASSWORD_UNLOCK;
+                if (i2c_write(TPS65217_CHIP_PM, PASSWORD, 1, &xor_reg, 1))
+                        return 1;
+        }
+
+        if (i2c_write(TPS65217_CHIP_PM, dest_reg, 1, &dest_val, 1))
+                return 1;
+
+        if (prot_level == PROT_LEVEL_2) {
+                if (i2c_write(TPS65217_CHIP_PM, PASSWORD, 1, &xor_reg, 1))
+                        return 1;
+
+                if (i2c_write(TPS65217_CHIP_PM, dest_reg, 1, &dest_val, 1))
+                        return 1;
+        }
+
+        return 0;
+}
+
+int tps65217_voltage_update(unsigned char dc_cntrl_reg, unsigned char volt_sel)
+{
+        if ((dc_cntrl_reg != DEFDCDC1) && (dc_cntrl_reg != DEFDCDC2)
+                && (dc_cntrl_reg != DEFDCDC3))
+                return 1;
+
+        /* set voltage level */
+        if (tps65217_reg_write(PROT_LEVEL_2, dc_cntrl_reg, volt_sel, MASK_ALL_BITS))
+                return 1;
+
+        /* set GO bit to initiate voltage transition */
+        if (tps65217_reg_write(PROT_LEVEL_2, DEFSLEW, DCDC_GO, DCDC_GO))
+                return 1;
+
+        return 0;
+}
+
+/*
+ * voltage switching for MPU frequency switching.
+ * @module = mpu - 0, core - 1
+ * @vddx_op_vol_sel = vdd voltage to set
+ */
+
+#define MPU     0
+#define CORE    1
+
+int voltage_update(unsigned int module, unsigned char vddx_op_vol_sel)
+{
+        uchar buf[4];
+        unsigned int reg_offset;
+
+        if(module == MPU)
+                reg_offset = PMIC_VDD1_OP_REG;
+        else
+                reg_offset = PMIC_VDD2_OP_REG;
+
+        /* Select VDDx OP   */
+        if (i2c_read(PMIC_CTRL_I2C_ADDR, reg_offset, 1, buf, 1))
+                return 1;
+
+        buf[0] &= ~PMIC_OP_REG_CMD_MASK;
+
+        if (i2c_write(PMIC_CTRL_I2C_ADDR, reg_offset, 1, buf, 1))
+                return 1;
+
+        /* Configure VDDx OP  Voltage */
+        if (i2c_read(PMIC_CTRL_I2C_ADDR, reg_offset, 1, buf, 1))
+                return 1;
+
+        buf[0] &= ~PMIC_OP_REG_SEL_MASK;
+        buf[0] |= vddx_op_vol_sel;
+
+        if (i2c_write(PMIC_CTRL_I2C_ADDR, reg_offset, 1, buf, 1))
+                return 1;
+
+        if (i2c_read(PMIC_CTRL_I2C_ADDR, reg_offset, 1, buf, 1))
+                return 1;
+
+        if ((buf[0] & PMIC_OP_REG_SEL_MASK ) != vddx_op_vol_sel)
+                return 1;
+
+        return 0;
+}
+
 /*
  * early system init of muxing and clocks.
  */
@@ -190,6 +318,12 @@ void s_init(void)
 		gpio_request(GPIO_DDR_VTT_EN, "ddr_vtt_en");
 		gpio_direction_output(GPIO_DDR_VTT_EN, 1);
 	}
+	/* Set DCDC2 (MPU) voltage to 1.275V */
+	if (tps65217_voltage_update(DEFDCDC1,
+				DCDC_VOLT_SEL_135MV)) {
+		printf("tps65217_voltage_update failure\n");
+		return;
+	}
 
 	config_ddr(board_memory_type());
 #endif
arch/arm/cpu/armv7/am33xx/pmic.h new file +76 -0

76 lines not on this page · raw message

arch/arm/cpu/armv7/am33xx/tps65217.h new file +90 -0

90 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/1 am33xx: pmic: Add support for tps65217

Quoted 11 lines · Joel A Fernandes

This is mostly copied from "support for TPS65217 PMIC" patches from the old am33xx U-boot tree by Greg Guyyote with additions by Tom Rini, me and others.

Also drop DDR3 voltage level from 1.5V to 1.35V for beaglebone. DDR3 operation is verified at this lower voltage level.

---
 arch/arm/cpu/armv7/am33xx/board.c    |  134 ++++++++++++++++++++++++++++++++++
 arch/arm/cpu/armv7/am33xx/pmic.h     |   76 +++++++++++++++++++
 arch/arm/cpu/armv7/am33xx/tps65217.h |   90 +++++++++++++++++++++++

We need to split this up into a pmic file. Assuming it's all generic to the tps65217, you should grab Lukasz Majewski's pmic series and build on top of that, putting this code into drivers/power/pmic/. And please checkpatch.pl the code as I'm sure there were a few violations that slipped in to the non-mainline tree. Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20121031/bbe6a1d6/attachment-0001.pgp>