/*-
* Copyright (c) 2006 Itronix Inc.
* All rights reserved.
*
* Written by Garrett D'Amore for Itronix Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of Itronix Inc. may not be used to endorse
* or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* ATI Technologies Inc. ("ATI") has not assisted in the creation of, and
* does not endorse, this software. ATI will not be responsible or liable
* for any actual or alleged damage or loss caused by or in connection with
* the use of or reliance on this software.
*/
/*
* Block initialization routines. These take action based on data in
* the tables.
*/
int
rb_load_init_block(struct radeonfb_softc *sc, struct rb_table *tp)
{
uint16_t offset;
uint16_t value;
case TABLE_FLAG_DELAY:
/* in the worst case, this would be 16msec */
count = GETBIOS16(sc, offset);
DPRINTF(("DELAY: %d\n", count));
delay(count);
offset += 2;
break;
case TABLE_FLAG_SCOMMAND:
DPRINTF(("SCOMMAND %x\n", command));
switch (command) {
case TABLE_SCOMMAND_WAIT_MC_BUSY_MASK:
count = GETBIOS16(sc, offset);
rb_wait_mc_busy_mask(sc, count);
break;
case TABLE_SCOMMAND_WAIT_MEM_PWRUP_COMPLETE:
count = GETBIOS16(sc, offset);
rb_wait_mem_pwrup_complete(sc, count);
break;
switch (index & PLL_FLAG_MASK) {
case PLL_FLAG_WAIT:
switch (index & PLL_INDEX_MASK) {
case PLL_WAIT_150MKS:
delay(150);
break;
case PLL_WAIT_5MS:
/* perhaps this should be tsleep? */
delay(5000);
break;
case PLL_WAIT_MC_BUSY_MASK:
rb_wait_mc_busy_mask(sc, 1000);
break;
case PLL_WAIT_DLL_READY_MASK:
rb_wait_dll_ready_mask(sc, 1000);
break;
case PLL_WAIT_CHK_SET_CLK_PWRMGT_CNTL24:
rb_wait_chk_set_clk_pwrmgt_cntl24(sc);
break;
}
break;
case PLL_FLAG_MASK_BYTE:
shift = GETBIOS8(sc, offset) * 8;
offset++;
/*
* Master entry point to parse and act on table data.
*/
int
radeonfb_bios_init(struct radeonfb_softc *sc)
{
uint16_t revision;
uint16_t scratch;
int i;
struct rb_table *tp;
if (rb_rage_regs1_table.offset)
rb_load_init_block(sc, &rb_rage_regs1_table);
if (revision < SINGLE_TABLE_REVISION) {
if (rb_pll_init_table.offset)
rb_load_pll_block(sc, &rb_pll_init_table);
if (rb_rage_regs2_table.offset)
rb_load_init_block(sc, &rb_rage_regs2_table);
if (rb_rage_regs4_table.offset)
rb_load_init_block(sc, &rb_rage_regs4_table);
if (rb_mem_reset_table.offset)
rb_reset_sdram(sc, &rb_mem_reset_table);
if (rb_rage_regs3_table.offset)
rb_load_init_block(sc, &rb_rage_regs3_table);
if (rb_dyn_clock_table.offset)
rb_load_pll_block(sc, &rb_dyn_clock_table);
}