a344f481debb9f7081d5754a65098973584e9b80
[openembedded.git] /
1 From a1a4ba7a5fce36522a994cb06d6d76931964578c Mon Sep 17 00:00:00 2001
2 From: Steve Sakoman <steve@sakoman.com>
3 Date: Wed, 10 Feb 2010 15:23:19 -0800
4 Subject: [PATCH 04/50] OMAP3: Set VAUX2 to 1.8V for EHCI PHY on Beagle Rev C4 boards
5
6 ---
7  board/ti/beagle/beagle.c |    5 +++++
8  drivers/power/twl4030.c  |   45 +++++++++++++++++++++++++--------------------
9  include/twl4030.h        |   15 +++++++++++++++
10  3 files changed, 45 insertions(+), 20 deletions(-)
11
12 diff --git a/board/ti/beagle/beagle.c b/board/ti/beagle/beagle.c
13 index ba16dd7..b4ea7e6 100644
14 --- a/board/ti/beagle/beagle.c
15 +++ b/board/ti/beagle/beagle.c
16 @@ -120,6 +120,11 @@ int misc_init_r(void)
17         case REVISION_C4:
18                 printf("C4\n");
19                 MUX_BEAGLE_C();
20 +               /* Set VAUX2 to 1.8V for EHCI PHY */
21 +               twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
22 +                                       TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
23 +                                       TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
24 +                                       TWL4030_PM_RECEIVER_DEV_GRP_P1);
25                 break;
26         case REVISION_D:
27                 printf("D\n");
28 diff --git a/drivers/power/twl4030.c b/drivers/power/twl4030.c
29 index eb066cb..f354834 100644
30 --- a/drivers/power/twl4030.c
31 +++ b/drivers/power/twl4030.c
32 @@ -59,57 +59,62 @@ void twl4030_power_reset_init(void)
33         }
34  }
35  
36 -
37 -/*
38 - * Power Init
39 - */
40 -#define DEV_GRP_P1             0x20
41 -#define VAUX3_VSEL_28          0x03
42 -#define DEV_GRP_ALL            0xE0
43 -#define VPLL2_VSEL_18          0x05
44 -#define VDAC_VSEL_18           0x03
45 -
46  void twl4030_power_init(void)
47  {
48         unsigned char byte;
49  
50         /* set VAUX3 to 2.8V */
51 -       byte = DEV_GRP_P1;
52 +       byte = TWL4030_PM_RECEIVER_DEV_GRP_P1;
53         twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, byte,
54                              TWL4030_PM_RECEIVER_VAUX3_DEV_GRP);
55 -       byte = VAUX3_VSEL_28;
56 +       byte = TWL4030_PM_RECEIVER_VAUX3_VSEL_28;
57         twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, byte,
58                              TWL4030_PM_RECEIVER_VAUX3_DEDICATED);
59  
60         /* set VPLL2 to 1.8V */
61 -       byte = DEV_GRP_ALL;
62 +       byte = TWL4030_PM_RECEIVER_DEV_GRP_ALL;
63         twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, byte,
64                              TWL4030_PM_RECEIVER_VPLL2_DEV_GRP);
65 -       byte = VPLL2_VSEL_18;
66 +       byte = TWL4030_PM_RECEIVER_VPLL2_VSEL_18;
67         twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, byte,
68                              TWL4030_PM_RECEIVER_VPLL2_DEDICATED);
69  
70         /* set VDAC to 1.8V */
71 -       byte = DEV_GRP_P1;
72 +       byte = TWL4030_PM_RECEIVER_DEV_GRP_P1;
73         twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, byte,
74                              TWL4030_PM_RECEIVER_VDAC_DEV_GRP);
75 -       byte = VDAC_VSEL_18;
76 +       byte = TWL4030_PM_RECEIVER_VDAC_VSEL_18;
77         twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, byte,
78                              TWL4030_PM_RECEIVER_VDAC_DEDICATED);
79  }
80  
81 -#define VMMC1_VSEL_30          0x02
82 -
83  void twl4030_power_mmc_init(void)
84  {
85         unsigned char byte;
86  
87 -       byte = DEV_GRP_P1;
88 +       byte = TWL4030_PM_RECEIVER_DEV_GRP_P1;
89         twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, byte,
90                              TWL4030_PM_RECEIVER_VMMC1_DEV_GRP);
91  
92         /* 3 Volts */
93 -       byte = VMMC1_VSEL_30;
94 +       byte = TWL4030_PM_RECEIVER_VMMC1_VSEL_30;
95         twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, byte,
96                              TWL4030_PM_RECEIVER_VMMC1_DEDICATED);
97  }
98 +
99 +/*
100 + * Generic function to select Device Group and Voltage
101 + */
102 +void twl4030_pmrecv_vsel_cfg(u8 vsel_reg, u8 vsel_val,
103 +                               u8 dev_grp, u8 dev_grp_sel)
104 +{
105 +       /* Select the Device Group */
106 +       twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, dev_grp_sel,
107 +                               dev_grp);
108 +
109 +       /* Select the Voltage */
110 +       twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, vsel_val,
111 +                               vsel_reg);
112 +}
113 +
114 +
115 diff --git a/include/twl4030.h b/include/twl4030.h
116 index 2b2f5ae..cc99403 100644
117 --- a/include/twl4030.h
118 +++ b/include/twl4030.h
119 @@ -471,6 +471,21 @@
120  #define TWL4030_USB_PHY_CLK_CTRL_STS                   0xFF
121  
122  /*
123 + * Voltage Selection in PM Receiver Module
124 + */
125 +#define TWL4030_PM_RECEIVER_VAUX2_VSEL_18              0x05
126 +#define TWL4030_PM_RECEIVER_VAUX3_VSEL_28              0x03
127 +#define TWL4030_PM_RECEIVER_VPLL2_VSEL_18              0x05
128 +#define TWL4030_PM_RECEIVER_VDAC_VSEL_18               0x03
129 +#define TWL4030_PM_RECEIVER_VMMC1_VSEL_30              0x02
130 +
131 +/*
132 + * Device Selection in PM Receiver Module
133 + */
134 +#define TWL4030_PM_RECEIVER_DEV_GRP_P1                 0x20
135 +#define TWL4030_PM_RECEIVER_DEV_GRP_ALL                        0xE0
136 +
137 +/*
138   * Convience functions to read and write from TWL4030
139   *
140   * chip_no is the i2c address, it must be one of the chip addresses
141 -- 
142 1.6.6.1
143