Skip to content

Commit 98d4f93

Browse files
frederichgregkh
authored andcommitted
Staging: olpc_dcon: replace some magic numbers
This patch replace some magic numbers. I believe it makes the driver more readable. The magic number 0x26 is the XO system embedded controller (EC) command 'DCON power enable/disable'. Number 0x41, and 0x42 are special memory controller settings register. The 0x41 initialize bit sequence 0x101 means: enable memory power down function and special SDRAM clock delay for synchronize SDRAM output and clock signal. The 0x42 initialize squence 0x101 is wrong. According to the specification Bit 8 is reserved, thus not in use. I removed it. Signed-off-by: Jens Frederich <jfrederich@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 01f865b commit 98d4f93

3 files changed

Lines changed: 26 additions & 15 deletions

File tree

‎drivers/staging/olpc_dcon/olpc_dcon.c‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,10 @@ static int dcon_hw_init(struct dcon_priv *dcon, int is_init)
9090

9191
/* SDRAM setup/hold time */
9292
dcon_write(dcon, 0x3a, 0xc040);
93-
dcon_write(dcon, 0x41, 0x0000);
94-
dcon_write(dcon, 0x41, 0x0101);
95-
dcon_write(dcon, 0x42, 0x0101);
93+
dcon_write(dcon, DCON_REG_MEM_OPT_A, 0x0000); /* clear option bits */
94+
dcon_write(dcon, DCON_REG_MEM_OPT_A,
95+
MEM_DLL_CLOCK_DELAY | MEM_POWER_DOWN);
96+
dcon_write(dcon, DCON_REG_MEM_OPT_B, MEM_SOFT_RESET);
9697

9798
/* Colour swizzle, AA, no passthrough, backlight */
9899
if (is_init) {
@@ -126,7 +127,7 @@ static int dcon_bus_stabilize(struct dcon_priv *dcon, int is_powered_down)
126127
power_up:
127128
if (is_powered_down) {
128129
x = 1;
129-
x = olpc_ec_cmd(0x26, (unsigned char *)&x, 1, NULL, 0);
130+
x = olpc_ec_cmd(EC_DCON_POWER_MODE, (u8 *)&x, 1, NULL, 0);
130131
if (x) {
131132
pr_warn("unable to force dcon to power up: %d!\n", x);
132133
return x;
@@ -144,7 +145,7 @@ static int dcon_bus_stabilize(struct dcon_priv *dcon, int is_powered_down)
144145
pr_err("unable to stabilize dcon's smbus, reasserting power and praying.\n");
145146
BUG_ON(olpc_board_at_least(olpc_board(0xc2)));
146147
x = 0;
147-
olpc_ec_cmd(0x26, (unsigned char *)&x, 1, NULL, 0);
148+
olpc_ec_cmd(EC_DCON_POWER_MODE, (u8 *)&x, 1, NULL, 0);
148149
msleep(100);
149150
is_powered_down = 1;
150151
goto power_up; /* argh, stupid hardware.. */
@@ -208,7 +209,7 @@ static void dcon_sleep(struct dcon_priv *dcon, bool sleep)
208209

209210
if (sleep) {
210211
x = 0;
211-
x = olpc_ec_cmd(0x26, (unsigned char *)&x, 1, NULL, 0);
212+
x = olpc_ec_cmd(EC_DCON_POWER_MODE, (u8 *)&x, 1, NULL, 0);
212213
if (x)
213214
pr_warn("unable to force dcon to power down: %d!\n", x);
214215
else

‎drivers/staging/olpc_dcon/olpc_dcon.h‎

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,24 @@
2222
#define MODE_DEBUG (1<<14)
2323
#define MODE_SELFTEST (1<<15)
2424

25-
#define DCON_REG_HRES 2
26-
#define DCON_REG_HTOTAL 3
27-
#define DCON_REG_HSYNC_WIDTH 4
28-
#define DCON_REG_VRES 5
29-
#define DCON_REG_VTOTAL 6
30-
#define DCON_REG_VSYNC_WIDTH 7
31-
#define DCON_REG_TIMEOUT 8
32-
#define DCON_REG_SCAN_INT 9
33-
#define DCON_REG_BRIGHT 10
25+
#define DCON_REG_HRES 0x2
26+
#define DCON_REG_HTOTAL 0x3
27+
#define DCON_REG_HSYNC_WIDTH 0x4
28+
#define DCON_REG_VRES 0x5
29+
#define DCON_REG_VTOTAL 0x6
30+
#define DCON_REG_VSYNC_WIDTH 0x7
31+
#define DCON_REG_TIMEOUT 0x8
32+
#define DCON_REG_SCAN_INT 0x9
33+
#define DCON_REG_BRIGHT 0x10
34+
#define DCON_REG_MEM_OPT_A 0x41
35+
#define DCON_REG_MEM_OPT_B 0x42
36+
37+
/* Load Delay Locked Loop (DLL) settings for clock delay */
38+
#define MEM_DLL_CLOCK_DELAY (1<<0)
39+
/* Memory controller power down function */
40+
#define MEM_POWER_DOWN (1<<8)
41+
/* Memory controller software reset */
42+
#define MEM_SOFT_RESET (1<<0)
3443

3544
/* Status values */
3645

‎include/linux/olpc-ec.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#define EC_WRITE_SCI_MASK 0x1b
77
#define EC_WAKE_UP_WLAN 0x24
88
#define EC_WLAN_LEAVE_RESET 0x25
9+
#define EC_DCON_POWER_MODE 0x26
910
#define EC_READ_EB_MODE 0x2a
1011
#define EC_SET_SCI_INHIBIT 0x32
1112
#define EC_SET_SCI_INHIBIT_RELEASE 0x34

0 commit comments

Comments
 (0)