13 void sm_write_mode(void)
15 out_byte(0xA539, 0x00);
16 out_byte(0xA53A, 0x03);
19 void sm_read_mode(void)
21 out_byte(0xA53A, 0x02);
22 out_byte(0xA539, 0x02);
25 void sm_write_byte(uint8 writeme)
30 out_byte(0xA539, 0x00);
36 if ((writeme & 0x80) == (level<<7))
38 /* Bit did not change, rewrite strobe */
39 out_byte(0xA539, level | 0x02);
40 out_byte(0xA539, level);
44 /* Bit changed, set bit, then strobe */
45 level = (writeme & 0x80) >> 7;
46 out_byte(0xA539, level);
47 out_byte(0xA539, level | 0x02);
48 out_byte(0xA539, level);
52 out_byte(0xA539, 0x00);
55 uint8 sm_read_byte(void)
64 out_byte(0xA539, 0x00);
65 out_byte(0xA539, 0x02);
66 r = in_byte(0xA538) & 0x01;
77 if ((r&0x01) == 0) return TRUE;
81 void sm_write_ack(void)
83 out_byte(0xA539, 0x00);
84 out_byte(0xA539, 0x02);
85 out_byte(0xA539, 0x00);
88 void sm_write_nack(void)
90 out_byte(0xA539, 0x01);
91 out_byte(0xA539, 0x03);
92 out_byte(0xA539, 0x01);
95 void sm_send_start(void)
97 out_byte(0xA539, 0x03);
98 out_byte(0xA539, 0x02);
101 void sm_send_stop(void)
103 out_byte(0xA539, 0x02);
104 out_byte(0xA539, 0x03);
107 int sm_read_byte_from_device(uint8 addr, uint8 reg, uint8 *storage)
112 sm_write_byte((addr<<1));
116 if (sm_get_ack() == FALSE) return FALSE;
124 if (sm_get_ack() == FALSE) return FALSE;
129 sm_write_byte((addr<<1)|1);
133 if (sm_get_ack() == FALSE) return FALSE;
136 *storage = sm_read_byte();
148 /* Switch to PMC mode */
149 pci_write_cfg_byte(0, 0, REG_GROUP, (uint8)(REG_GROUP_SPECIAL|REG_GROUP_POWER));
152 pci_write_cfg_long(0, 0, 0x40, 0xa500);
155 pci_write_cfg_byte(0, 0, 0x44, 0x11);
157 /* Set both GPIO 0 and 1 as output */
158 out_byte(0xA53A, 0x03);
164 /* Switch to normal mode */
165 pci_write_cfg_byte(0, 0, REG_GROUP, 0);
169 int sm_get_data(uint8 *DataArray, int dimm_socket)
174 /* Switch to PMC mode */
175 pci_write_cfg_byte(0, 0, REG_GROUP, (uint8)(REG_GROUP_SPECIAL|REG_GROUP_POWER));
178 pci_write_cfg_long(0, 0, 0x40, 0xa500);
181 pci_write_cfg_byte(0, 0, 0x44, 0x11);
183 /* Set both GPIO 0 and 1 as output */
184 out_byte(0xA53A, 0x03);
188 /* Start reading the rom */
194 if (sm_read_byte_from_device(dimm_socket, (uint8)j, DataArray) == FALSE)