Ok, here is my DRA function for i82830 raminit.c. Feedback,  
suggestions welcome. If there is any easier way to write this please  
let me know. I am still a newbie at C, but learning quickly. If the  
format looks funky, blaime Horde IMAP.

Thanks - Joe

----------------------------------------------

static void set_dram_row_attributes(const struct mem_controller *ctrl)
{
        int i, dra, col, width, page_size;


        for (i = 0; i < DIMM_SOCKETS; i++) {
                /* First check if a DIMM is actually present. */
                if (smbus_read_byte(ctrl->channel0[i], 2) == 4) {
                        print_debug("Found DIMM in slot ");
                        print_debug_hex8(i);
                        print_debug(", Setting DRA...\r\n");

                        dra = 0x00;

                        /* columns */
                        col = smbus_read_byte(ctrl->channel0[i], 4);

                        /* data width */
                        width = smbus_read_byte(ctrl->channel0[i], 6);

                        /* calculate page size in bits */
                        page_size = ((1 << col) * width);

                        /* convert to Kilobytes */
                        dra = ((page_size / 8) >> 10);

                        /* 2KB */
                        if (dra == 0x2) {
                                dra = 0xF0;
                        /* 4KB */
                        } else if (dra == 0x4) {
                                dra = 0xF1;
                        /* 8KB */
                        } else if (dra == 0x8) {
                                dra = 0xF2;
                        /* 16KB */
                        } else if (dra == 0x10) {
                                dra = 0xF3;
                        } else {
                                print_debug("Page Size not supported\r\n");
                                die("HALT!\r\n");
                        }
                } else {
                        print_debug("No DIMM found in slot ");
                        print_debug_hex8(i);
                        print_debug(", Setting DRA to 0xFF\r\n");

                        /* If there's no DIMM in the slot, set dra value to 
0xFF. */
                        dra = 0xFF;
                }

                /* Set the value for DRAM Row Attribute Registers */
                 pci_write_config8(ctrl->d0, DRA + i, dra);
                print_debug("DRA ");
                print_debug_hex8(DRA + i);
                print_debug(" has been set to ");
                print_debug_hex8(dra);
                print_debug("\r\n");
        }
}


-- 
linuxbios mailing list
[email protected]
http://www.linuxbios.org/mailman/listinfo/linuxbios

Reply via email to