add more Radeon functionality
This commit is contained in:
474
radeon/i2c-algo-bit.c
Normal file
474
radeon/i2c-algo-bit.c
Normal file
@@ -0,0 +1,474 @@
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* i2c-algo-bit.c i2c driver algorithms for bit-shift adapters */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Copyright (C) 1995-2000 Simon G. Vogl
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* With some changes from Frodo Looijaard <frodol@dds.nl>, Ky<4B>sti M<>lkki
|
||||
<kmalkki@cc.hut.fi> and Jean Delvare <khali@linux-fr.org> */
|
||||
|
||||
#include "wait.h"
|
||||
#include "i2c.h"
|
||||
#include "i2c-algo-bit.h"
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL ((void *)0)
|
||||
#endif
|
||||
|
||||
// #define DEBUG
|
||||
#include "debug.h"
|
||||
|
||||
extern void start_timeout(void);
|
||||
extern int end_timeout(long msec);
|
||||
extern void udelay(long usec);
|
||||
|
||||
/* --- setting states on the bus with the right timing: --------------- */
|
||||
|
||||
#define setsda(adap,val) adap->setsda(adap->data, val)
|
||||
#define setscl(adap,val) adap->setscl(adap->data, val)
|
||||
#define getsda(adap) adap->getsda(adap->data)
|
||||
#define getscl(adap) adap->getscl(adap->data)
|
||||
|
||||
static inline void sdalo(struct i2c_algo_bit_data *adap)
|
||||
{
|
||||
setsda(adap,0);
|
||||
wait_us(adap->udelay);
|
||||
}
|
||||
|
||||
static inline void sdahi(struct i2c_algo_bit_data *adap)
|
||||
{
|
||||
setsda(adap,1);
|
||||
wait_us(adap->udelay);
|
||||
}
|
||||
|
||||
static inline void scllo(struct i2c_algo_bit_data *adap)
|
||||
{
|
||||
setscl(adap,0);
|
||||
wait_us(adap->udelay);
|
||||
}
|
||||
|
||||
/*
|
||||
* Raise scl line, and do checking for delays. This is necessary for slower
|
||||
* devices.
|
||||
*/
|
||||
static inline int sclhi(struct i2c_algo_bit_data *adap)
|
||||
{
|
||||
setscl(adap,1);
|
||||
/* Not all adapters have scl sense line... */
|
||||
if(adap->getscl == NULL )
|
||||
{
|
||||
wait_us(adap->udelay);
|
||||
return 0;
|
||||
}
|
||||
start_timeout();
|
||||
while(! getscl(adap))
|
||||
{
|
||||
/* the hw knows how to read the clock line,
|
||||
* so we wait until it actually gets high.
|
||||
* This is safer as some chips may hold it low
|
||||
* while they are processing data internally.
|
||||
*/
|
||||
if(end_timeout((long)adap->timeout))
|
||||
return -110;
|
||||
}
|
||||
wait_us(adap->udelay);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* --- other auxiliary functions -------------------------------------- */
|
||||
void i2c_start(struct i2c_algo_bit_data *adap)
|
||||
{
|
||||
/* assert: scl, sda are high */
|
||||
sdalo(adap);
|
||||
scllo(adap);
|
||||
}
|
||||
|
||||
static void i2c_repstart(struct i2c_algo_bit_data *adap)
|
||||
{
|
||||
/* scl, sda may not be high */
|
||||
setsda(adap,1);
|
||||
sclhi(adap);
|
||||
wait_ms(adap->udelay);
|
||||
sdalo(adap);
|
||||
scllo(adap);
|
||||
}
|
||||
|
||||
static void i2c_stop(struct i2c_algo_bit_data *adap)
|
||||
{
|
||||
/* assert: scl is low */
|
||||
sdalo(adap);
|
||||
sclhi(adap);
|
||||
sdahi(adap);
|
||||
}
|
||||
|
||||
/* send a byte without start cond., look for arbitration,
|
||||
check ackn. from slave */
|
||||
/* returns:
|
||||
* 1 if the device acknowledged
|
||||
* 0 if the device did not ack
|
||||
* -ETIMEDOUT if an error occurred (while raising the scl line)
|
||||
*/
|
||||
static int i2c_outb(struct i2c_adapter *i2c_adap, char c)
|
||||
{
|
||||
int i;
|
||||
int sb;
|
||||
int ack;
|
||||
struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
|
||||
/* assert: scl is low */
|
||||
|
||||
for (i = 7; i >= 0; i--)
|
||||
{
|
||||
sb = c & ( 1 << i );
|
||||
setsda(adap,sb);
|
||||
wait_ms(adap->udelay);
|
||||
if(sclhi(adap)<0)
|
||||
{ /* timed out */
|
||||
sdahi(adap); /* we don't want to block the net */
|
||||
#ifdef DEBUG
|
||||
dbg("ETIMEDOUT\r\n");
|
||||
#endif
|
||||
return -110;
|
||||
};
|
||||
/* do arbitration here:
|
||||
* if ( sb && ! getsda(adap) ) -> ouch! Get out of here.
|
||||
*/
|
||||
setscl(adap, 0 );
|
||||
wait_us(adap->udelay);
|
||||
}
|
||||
sdahi(adap);
|
||||
if(sclhi(adap)<0)
|
||||
{
|
||||
/* timeout */
|
||||
#ifdef DEBUG
|
||||
dbg("ETIMEDOUT\r\n");
|
||||
#endif
|
||||
return -110;
|
||||
}
|
||||
/* read ack: SDA should be pulled down by slave */
|
||||
ack = getsda(adap); /* ack: sda is pulled low ->success. */
|
||||
scllo(adap);
|
||||
#ifdef DEBUG
|
||||
dbg("0x%02x, ack=0x%02x\r\n", (unsigned long)(c & 0xff), ack);
|
||||
#endif
|
||||
return 0==ack; /* return 1 if device acked */
|
||||
/* assert: scl is low (sda undef) */
|
||||
}
|
||||
|
||||
static int i2c_inb(struct i2c_adapter *i2c_adap)
|
||||
{
|
||||
/* read byte via i2c port, without start/stop sequence */
|
||||
/* acknowledge is sent in i2c_read. */
|
||||
int i;
|
||||
unsigned char indata=0;
|
||||
struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
|
||||
/* assert: scl is low */
|
||||
sdahi(adap);
|
||||
for(i=0;i<8;i++)
|
||||
{
|
||||
if(sclhi(adap)<0)
|
||||
{
|
||||
/* timeout */
|
||||
#ifdef DEBUG
|
||||
dbg("i2c_inb TIMEDOUT\r\n");
|
||||
#endif
|
||||
return -110;
|
||||
}
|
||||
indata *= 2;
|
||||
if(getsda(adap))
|
||||
indata |= 0x01;
|
||||
scllo(adap);
|
||||
}
|
||||
/* assert: scl is low */
|
||||
#ifdef DEBUG
|
||||
dbg("0x%02x\r\n", (unsigned long)(indata & 0xff));
|
||||
#endif
|
||||
return (int) (indata & 0xff);
|
||||
}
|
||||
|
||||
/*
|
||||
* Sanity check for the adapter hardware - check the reaction of
|
||||
* the bus lines only if it seems to be idle.
|
||||
*/
|
||||
static int test_bus(struct i2c_algo_bit_data *adap)
|
||||
{
|
||||
int scl,sda;
|
||||
sda=getsda(adap);
|
||||
scl=(adap->getscl==NULL?1:getscl(adap));
|
||||
if(!scl || !sda )
|
||||
goto bailout;
|
||||
sdalo(adap);
|
||||
sda=getsda(adap);
|
||||
scl=(adap->getscl==NULL?1:getscl(adap));
|
||||
if(sda !=0 || scl == 0)
|
||||
goto bailout;
|
||||
sdahi(adap);
|
||||
sda=getsda(adap);
|
||||
scl=(adap->getscl==NULL?1:getscl(adap));
|
||||
if (sda == 0 || scl ==0)
|
||||
goto bailout;
|
||||
scllo(adap);
|
||||
sda=getsda(adap);
|
||||
scl=(adap->getscl==NULL?0:getscl(adap));
|
||||
if(scl !=0 || sda == 0)
|
||||
goto bailout;
|
||||
sclhi(adap);
|
||||
sda=getsda(adap);
|
||||
scl=(adap->getscl==NULL?1:getscl(adap));
|
||||
if(scl == 0 || sda ==0)
|
||||
goto bailout;
|
||||
return 0;
|
||||
bailout:
|
||||
sdahi(adap);
|
||||
sclhi(adap);
|
||||
return -110;
|
||||
}
|
||||
|
||||
/* ----- Utility functions
|
||||
*/
|
||||
|
||||
/* try_address tries to contact a chip for a number of
|
||||
* times before it gives up.
|
||||
* return values:
|
||||
* 1 chip answered
|
||||
* 0 chip did not answer
|
||||
* -x transmission error
|
||||
*/
|
||||
static inline int try_address(struct i2c_adapter *i2c_adap,
|
||||
unsigned char addr, int retries)
|
||||
{
|
||||
struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
|
||||
int i,ret = -1;
|
||||
for(i=0;i<=retries;i++)
|
||||
{
|
||||
ret = i2c_outb(i2c_adap,addr);
|
||||
if(ret==1)
|
||||
break; /* success! */
|
||||
i2c_stop(adap);
|
||||
wait_us(5);
|
||||
if(i==retries) /* no success */
|
||||
break;
|
||||
i2c_start(adap);
|
||||
wait_us(adap->udelay);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int sendbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
|
||||
{
|
||||
struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
|
||||
char c;
|
||||
const char *temp = (const char *)msg->buf;
|
||||
int count = msg->len;
|
||||
unsigned short nak_ok = msg->flags & I2C_M_IGNORE_NAK;
|
||||
int retval;
|
||||
int wrcount=0;
|
||||
while(count > 0)
|
||||
{
|
||||
c = *temp;
|
||||
retval = i2c_outb(i2c_adap,c);
|
||||
if((retval>0) || (nak_ok && (retval==0)))
|
||||
{ /* ok or ignored NAK */
|
||||
count--;
|
||||
temp++;
|
||||
wrcount++;
|
||||
}
|
||||
else
|
||||
{ /* arbitration or no acknowledge */
|
||||
i2c_stop(adap);
|
||||
return (retval<0)? retval : -110;
|
||||
/* got a better one ?? */
|
||||
}
|
||||
}
|
||||
return wrcount;
|
||||
}
|
||||
|
||||
static inline int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
|
||||
{
|
||||
int inval;
|
||||
int rdcount=0; /* counts bytes read */
|
||||
struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
|
||||
char *temp = (char *)msg->buf;
|
||||
int count = msg->len;
|
||||
while(count > 0)
|
||||
{
|
||||
inval = i2c_inb(i2c_adap);
|
||||
if(inval>=0)
|
||||
{
|
||||
*temp = inval;
|
||||
rdcount++;
|
||||
}
|
||||
else
|
||||
/* read timed out */
|
||||
break;
|
||||
temp++;
|
||||
count--;
|
||||
if(msg->flags & I2C_M_NO_RD_ACK)
|
||||
continue;
|
||||
if( count > 0 )
|
||||
/* send ack */
|
||||
sdalo(adap);
|
||||
else
|
||||
sdahi(adap); /* neg. ack on last byte */
|
||||
if(sclhi(adap)<0)
|
||||
{ /* timeout */
|
||||
sdahi(adap);
|
||||
return -1;
|
||||
};
|
||||
scllo(adap);
|
||||
sdahi(adap);
|
||||
}
|
||||
return rdcount;
|
||||
}
|
||||
|
||||
/* doAddress initiates the transfer by generating the start condition (in
|
||||
* try_address) and transmits the address in the necessary format to handle
|
||||
* reads, writes as well as 10bit-addresses.
|
||||
* returns:
|
||||
* 0 everything went okay, the chip ack'ed, or IGNORE_NAK flag was set
|
||||
* -x an error occurred (like: -EREMOTEIO if the device did not answer, or
|
||||
* -ETIMEDOUT, for example if the lines are stuck...)
|
||||
*/
|
||||
static inline int bit_doAddress(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
|
||||
{
|
||||
unsigned short flags = msg->flags;
|
||||
unsigned short nak_ok = msg->flags & I2C_M_IGNORE_NAK;
|
||||
struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
|
||||
unsigned char addr;
|
||||
int ret, retries;
|
||||
retries = nak_ok ? 0 : i2c_adap->retries;
|
||||
if(flags & I2C_M_TEN)
|
||||
{
|
||||
/* a ten bit address */
|
||||
addr = 0xf0 | (( msg->addr >> 7) & 0x03);
|
||||
/* try extended address code...*/
|
||||
ret = try_address(i2c_adap, addr, retries);
|
||||
if((ret != 1) && !nak_ok)
|
||||
return -1;
|
||||
/* the remaining 8 bit address */
|
||||
ret = i2c_outb(i2c_adap,msg->addr & 0x7f);
|
||||
if((ret != 1) && !nak_ok)
|
||||
/* the chip did not ack / xmission error occurred */
|
||||
return -1;
|
||||
if(flags & I2C_M_RD)
|
||||
{
|
||||
i2c_repstart(adap);
|
||||
/* okay, now switch into reading mode */
|
||||
addr |= 0x01;
|
||||
ret = try_address(i2c_adap, addr, retries);
|
||||
if ((ret!=1) && !nak_ok)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ /* normal 7bit address */
|
||||
addr = ( msg->addr << 1 );
|
||||
if(flags & I2C_M_RD )
|
||||
addr |= 1;
|
||||
if(flags & I2C_M_REV_DIR_ADDR )
|
||||
addr ^= 1;
|
||||
ret = try_address(i2c_adap, addr, retries);
|
||||
if((ret!=1) && !nak_ok)
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bit_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs[], int num)
|
||||
{
|
||||
struct i2c_msg *pmsg;
|
||||
struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
|
||||
int i,ret;
|
||||
unsigned short nak_ok;
|
||||
i2c_start(adap);
|
||||
for(i=0;i<num;i++)
|
||||
{
|
||||
pmsg = &msgs[i];
|
||||
nak_ok = pmsg->flags & I2C_M_IGNORE_NAK;
|
||||
if(!(pmsg->flags & I2C_M_NOSTART))
|
||||
{
|
||||
if(i)
|
||||
i2c_repstart(adap);
|
||||
ret = bit_doAddress(i2c_adap, pmsg);
|
||||
if((ret != 0) && !nak_ok)
|
||||
return (ret<0) ? ret : -1;
|
||||
}
|
||||
if(pmsg->flags & I2C_M_RD )
|
||||
{
|
||||
/* read bytes into buffer*/
|
||||
ret = readbytes(i2c_adap, pmsg);
|
||||
if(ret < pmsg->len)
|
||||
return (ret<0)? ret : -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* write bytes from buffer */
|
||||
ret = sendbytes(i2c_adap, pmsg);
|
||||
if(ret < pmsg->len )
|
||||
return (ret<0) ? ret : -1;
|
||||
}
|
||||
}
|
||||
i2c_stop(adap);
|
||||
return num;
|
||||
}
|
||||
|
||||
/* -----exported algorithm data: ------------------------------------- */
|
||||
|
||||
static struct i2c_algorithm i2c_bit_algo = {
|
||||
.master_xfer = bit_xfer,
|
||||
};
|
||||
|
||||
/*
|
||||
* registering functions to load algorithms at runtime
|
||||
*/
|
||||
int i2c_bit_add_bus(struct i2c_adapter *adap)
|
||||
{
|
||||
struct i2c_algo_bit_data *bit_adap = adap->algo_data;
|
||||
if(1)
|
||||
{
|
||||
int ret = test_bus(bit_adap);
|
||||
if(ret<0)
|
||||
return -1;
|
||||
}
|
||||
/* register new adapter to i2c module... */
|
||||
adap->algo = &i2c_bit_algo;
|
||||
adap->timeout = 100; /* default values, should */
|
||||
adap->retries = 3; /* be replaced by defines */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int i2c_bit_del_bus(struct i2c_adapter *adap)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------
|
||||
* the functional interface to the i2c busses.
|
||||
* ----------------------------------------------------
|
||||
*/
|
||||
|
||||
int i2c_transfer(struct i2c_adapter * adap, struct i2c_msg *msgs, int num)
|
||||
{
|
||||
int ret;
|
||||
if(adap->algo->master_xfer)
|
||||
{
|
||||
ret = adap->algo->master_xfer(adap,msgs,num);
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
@@ -311,6 +311,7 @@ uint32_t __INPLL(struct radeonfb_info *rinfo, uint32_t addr)
|
||||
radeon_pll_errata_after_index(rinfo);
|
||||
data = INREG(CLOCK_CNTL_DATA);
|
||||
radeon_pll_errata_after_data(rinfo);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -339,7 +340,7 @@ static __inline int round_div(int num, int den)
|
||||
|
||||
static __inline uint32_t read_vline_crnt(struct radeonfb_info *rinfo)
|
||||
{
|
||||
return((INREG(CRTC_VLINE_CRNT_VLINE) >> 16) & 0x3FF);
|
||||
return (INREG(CRTC_VLINE_CRNT_VLINE) >> 16) & 0x3FF;
|
||||
}
|
||||
|
||||
static int radeon_map_ROM(struct radeonfb_info *rinfo)
|
||||
@@ -481,6 +482,7 @@ static int radeon_probe_pll_params(struct radeonfb_info *rinfo)
|
||||
uint32_t stop_tv;
|
||||
int timeout = 0;
|
||||
int ipl;
|
||||
uint32_t vline;
|
||||
|
||||
/*
|
||||
* Ugh, we cut interrupts, bad bad bad, but we want some precision
|
||||
@@ -488,15 +490,15 @@ static int radeon_probe_pll_params(struct radeonfb_info *rinfo)
|
||||
*/
|
||||
ipl = set_ipl(0);
|
||||
|
||||
dbg("radeon_probe_pll_params\r\n");
|
||||
dbg("\r\n");
|
||||
|
||||
/* Flush PCI buffers ? */
|
||||
tmp = INREG16(DEVICE_ID);
|
||||
|
||||
start_tv = get_timer();
|
||||
while (read_vline_crnt(rinfo) != 0)
|
||||
while ((vline = read_vline_crnt(rinfo)) != 0)
|
||||
{
|
||||
if ((get_timer() - start_tv) > US_TO_TIMER(10000000UL)) /* 10 sec */
|
||||
if ((start_tv - get_timer()) > US_TO_TIMER(10000000UL)) /* 10 sec */
|
||||
{
|
||||
timeout = 1;
|
||||
dbg("timeout\r\n");
|
||||
@@ -509,7 +511,7 @@ static int radeon_probe_pll_params(struct radeonfb_info *rinfo)
|
||||
start_tv = get_timer();
|
||||
while (read_vline_crnt(rinfo) == 0)
|
||||
{
|
||||
if ((get_timer() - start_tv) > US_TO_TIMER(1000000UL)) /* 1 sec */
|
||||
if ((start_tv - get_timer()) > US_TO_TIMER(1000000UL)) /* 1 sec */
|
||||
{
|
||||
timeout = 1;
|
||||
dbg("timeout2\r\n");
|
||||
@@ -521,7 +523,7 @@ static int radeon_probe_pll_params(struct radeonfb_info *rinfo)
|
||||
{
|
||||
while (read_vline_crnt(rinfo) != 0)
|
||||
{
|
||||
if ((get_timer() - start_tv) > US_TO_TIMER(10000000UL)) /* 10 sec */
|
||||
if ((start_tv - get_timer()) > US_TO_TIMER(10000000UL)) /* 10 sec */
|
||||
{
|
||||
timeout = 1;
|
||||
dbg("timeout3\r\n");
|
||||
@@ -534,8 +536,11 @@ static int radeon_probe_pll_params(struct radeonfb_info *rinfo)
|
||||
|
||||
set_ipl(ipl);
|
||||
|
||||
hz = US_TO_TIMER(1000000.0) / (double)(stop_tv - start_tv);
|
||||
hz = US_TO_TIMER(1000000.0) / (double)(start_tv - stop_tv);
|
||||
dbg("hz %d\r\n", (int32_t) hz);
|
||||
OUTREG(CRTC_H_TOTAL_DISP, 640 / 8 - 1);
|
||||
OUTREG(CRTC_V_TOTAL_DISP, 480 - 1);
|
||||
dbg("h_total=%d vtotal=%d\r\n", INREG(CRTC_H_TOTAL_DISP), INREG(CRTC_V_TOTAL_DISP));
|
||||
|
||||
hTotal = ((INREG(CRTC_H_TOTAL_DISP) & 0x1ff) + 1) * 8;
|
||||
vTotal = ((INREG(CRTC_V_TOTAL_DISP) & 0x3ff) + 1);
|
||||
@@ -1260,7 +1265,7 @@ static void radeon_write_pll_regs(struct radeonfb_info *rinfo, struct radeon_reg
|
||||
{
|
||||
int i;
|
||||
|
||||
dbg("radeonfb: radeon_write_pll_regs\r\n");
|
||||
dbg("\r\n");
|
||||
radeon_wait_for_fifo(rinfo, 20);
|
||||
|
||||
#if 0
|
||||
@@ -1367,16 +1372,15 @@ static void radeon_timer_func(void)
|
||||
int chg;
|
||||
int disp;
|
||||
|
||||
#ifdef FIXME_LATER
|
||||
static int32_t start_timer;
|
||||
|
||||
/* delayed LVDS panel power up/down */
|
||||
if (rinfo->lvds_timer)
|
||||
{
|
||||
if (!start_timer)
|
||||
start_timer = *_hz_200;
|
||||
start_timer = get_timer();
|
||||
|
||||
if (((*_hz_200 - start_timer) * 5) >= (int32_t)rinfo->lvds_timer)
|
||||
if (((start_timer - get_timer())) >= (int32_t)rinfo->lvds_timer)
|
||||
{
|
||||
rinfo->lvds_timer = 0;
|
||||
radeon_engine_idle();
|
||||
@@ -1385,7 +1389,6 @@ static void radeon_timer_func(void)
|
||||
}
|
||||
else
|
||||
start_timer = 0;
|
||||
#endif /* FIXME_LATER */
|
||||
|
||||
if (rinfo->RenderCallback != NULL)
|
||||
rinfo->RenderCallback(rinfo);
|
||||
@@ -2367,7 +2370,7 @@ int32_t radeonfb_pci_register(int32_t handle, const struct pci_device_id *ent)
|
||||
offscreen_init(info);
|
||||
|
||||
/* Probe screen types */
|
||||
dbg("probe screen types, monitor_layout: 0x%x\r\n", monitor_layout);
|
||||
dbg("probe screen types, monitor_layout: %s\r\n", monitor_layout);
|
||||
radeon_probe_screens(rinfo, monitor_layout, (int) ignore_edid);
|
||||
|
||||
/* Build mode list, check out panel native model */
|
||||
@@ -2393,6 +2396,8 @@ int32_t radeonfb_pci_register(int32_t handle, const struct pci_device_id *ent)
|
||||
#else
|
||||
install_vbl_timer(radeon_timer_func, 0);
|
||||
#endif
|
||||
radeon_timer_func();
|
||||
|
||||
//rinfo->RageTheatreCrystal = rinfo->RageTheatreTunerPort=rinfo->RageTheatreCompositePort = rinfo->RageTheatreSVideoPort = -1;
|
||||
//rinfo->tunerType = -1;
|
||||
return 0;
|
||||
|
||||
@@ -1,25 +1,30 @@
|
||||
#include "video.h"
|
||||
#include "radeonfb.h"
|
||||
// #include "relocate.h"
|
||||
#include "edid.h"
|
||||
#include "i2c.h"
|
||||
#include "driver_mem.h"
|
||||
|
||||
#define DEBUG
|
||||
#include "debug.h"
|
||||
|
||||
|
||||
#define CONFIG_FB_RADEON_I2C
|
||||
#ifdef CONFIG_FB_RADEON_I2C
|
||||
|
||||
#define RADEON_DDC 0x50
|
||||
|
||||
extern void mdelay(long msec);
|
||||
extern void udelay(long usec);
|
||||
|
||||
static void radeon_gpio_setscl(void* data, int state)
|
||||
{
|
||||
struct radeon_i2c_chan *chan = data;
|
||||
struct radeonfb_info *rinfo = chan->rinfo;
|
||||
unsigned long val;
|
||||
|
||||
val = INREG(chan->ddc_reg) & ~(VGA_DDC_CLK_OUT_EN);
|
||||
if(!state)
|
||||
|
||||
if (!state)
|
||||
val |= VGA_DDC_CLK_OUT_EN;
|
||||
OUTREG(chan->ddc_reg, val);
|
||||
(void)INREG(chan->ddc_reg);
|
||||
(void) INREG(chan->ddc_reg);
|
||||
}
|
||||
|
||||
static void radeon_gpio_setsda(void* data, int state)
|
||||
@@ -27,11 +32,12 @@ static void radeon_gpio_setsda(void* data, int state)
|
||||
struct radeon_i2c_chan *chan = data;
|
||||
struct radeonfb_info *rinfo = chan->rinfo;
|
||||
unsigned long val;
|
||||
|
||||
val = INREG(chan->ddc_reg) & ~(VGA_DDC_DATA_OUT_EN);
|
||||
if(!state)
|
||||
if (!state)
|
||||
val |= VGA_DDC_DATA_OUT_EN;
|
||||
OUTREG(chan->ddc_reg, val);
|
||||
(void)INREG(chan->ddc_reg);
|
||||
(void) INREG(chan->ddc_reg);
|
||||
}
|
||||
|
||||
static int radeon_gpio_getscl(void* data)
|
||||
@@ -39,8 +45,9 @@ static int radeon_gpio_getscl(void* data)
|
||||
struct radeon_i2c_chan *chan = data;
|
||||
struct radeonfb_info *rinfo = chan->rinfo;
|
||||
unsigned long val;
|
||||
|
||||
val = INREG(chan->ddc_reg);
|
||||
return(val & VGA_DDC_CLK_INPUT) ? 1 : 0;
|
||||
return (val & VGA_DDC_CLK_INPUT) ? 1 : 0;
|
||||
}
|
||||
|
||||
static int radeon_gpio_getsda(void* data)
|
||||
@@ -129,8 +136,10 @@ static unsigned char *radeon_do_probe_i2c_edid(struct radeon_i2c_chan *chan)
|
||||
return NULL;
|
||||
|
||||
msgs[1].buf = buf;
|
||||
if(i2c_transfer(&chan->adapter, msgs, 2) == 2)
|
||||
if (i2c_transfer(&chan->adapter, msgs, 2) == 2)
|
||||
return buf;
|
||||
else
|
||||
err("i2c_transfer() failed\r\n");
|
||||
|
||||
driver_mem_free(buf);
|
||||
return NULL;
|
||||
@@ -138,14 +147,14 @@ static unsigned char *radeon_do_probe_i2c_edid(struct radeon_i2c_chan *chan)
|
||||
|
||||
int32_t radeon_probe_i2c_connector(struct radeonfb_info *rinfo, int32_t conn, uint8_t **out_edid)
|
||||
{
|
||||
unsigned long reg = rinfo->i2c[conn-1].ddc_reg;
|
||||
unsigned long reg = rinfo->i2c[conn - 1].ddc_reg;
|
||||
unsigned char *edid = NULL;
|
||||
int i, j;
|
||||
// DPRINTVAL("radeonfb: radeon_probe_i2c_connector ", conn);
|
||||
// DPRINT("\r\n");
|
||||
|
||||
OUTREG(reg, INREG(reg) & ~(VGA_DDC_DATA_OUTPUT | VGA_DDC_CLK_OUTPUT));
|
||||
OUTREG(reg, INREG(reg) & ~(VGA_DDC_CLK_OUT_EN));
|
||||
(void)INREG(reg);
|
||||
(void) INREG(reg);
|
||||
|
||||
for(i = 0; i < 3; i++)
|
||||
{
|
||||
/* For some old monitors we need the
|
||||
@@ -153,56 +162,68 @@ int32_t radeon_probe_i2c_connector(struct radeonfb_info *rinfo, int32_t conn, ui
|
||||
*/
|
||||
OUTREG(reg, INREG(reg) & ~(VGA_DDC_DATA_OUT_EN));
|
||||
(void)INREG(reg);
|
||||
mdelay(13);
|
||||
wait_ms(13);
|
||||
|
||||
OUTREG(reg, INREG(reg) & ~(VGA_DDC_CLK_OUT_EN));
|
||||
(void)INREG(reg);
|
||||
|
||||
for(j = 0; j < 5; j++)
|
||||
{
|
||||
mdelay(10);
|
||||
if(INREG(reg) & VGA_DDC_CLK_INPUT)
|
||||
wait_ms(10);
|
||||
if (INREG(reg) & VGA_DDC_CLK_INPUT)
|
||||
break;
|
||||
}
|
||||
if(j == 5)
|
||||
|
||||
if (j == 5)
|
||||
continue;
|
||||
|
||||
OUTREG(reg, INREG(reg) | VGA_DDC_DATA_OUT_EN);
|
||||
(void)INREG(reg);
|
||||
mdelay(15);
|
||||
(void) INREG(reg);
|
||||
wait_ms(15);
|
||||
|
||||
OUTREG(reg, INREG(reg) | VGA_DDC_CLK_OUT_EN);
|
||||
(void)INREG(reg);
|
||||
mdelay(15);
|
||||
(void) INREG(reg);
|
||||
wait_ms(15);
|
||||
|
||||
OUTREG(reg, INREG(reg) & ~(VGA_DDC_DATA_OUT_EN));
|
||||
(void)INREG(reg);
|
||||
mdelay(15);
|
||||
(void) INREG(reg);
|
||||
wait_ms(15);
|
||||
|
||||
/* Do the real work */
|
||||
edid = radeon_do_probe_i2c_edid(&rinfo->i2c[conn-1]);
|
||||
edid = radeon_do_probe_i2c_edid(&rinfo->i2c[conn - 1]);
|
||||
OUTREG(reg, INREG(reg) | (VGA_DDC_DATA_OUT_EN | VGA_DDC_CLK_OUT_EN));
|
||||
(void)INREG(reg);
|
||||
mdelay(15);
|
||||
(void) INREG(reg);
|
||||
wait_ms(15);
|
||||
OUTREG(reg, INREG(reg) & ~(VGA_DDC_CLK_OUT_EN));
|
||||
(void)INREG(reg);
|
||||
(void) INREG(reg);
|
||||
for(j = 0; j < 10; j++)
|
||||
{
|
||||
mdelay(10);
|
||||
if(INREG(reg) & VGA_DDC_CLK_INPUT)
|
||||
wait_ms(10);
|
||||
if (INREG(reg) & VGA_DDC_CLK_INPUT)
|
||||
break;
|
||||
}
|
||||
OUTREG(reg, INREG(reg) & ~(VGA_DDC_DATA_OUT_EN));
|
||||
(void)INREG(reg);
|
||||
mdelay(15);
|
||||
(void) INREG(reg);
|
||||
wait_ms(15);
|
||||
|
||||
OUTREG(reg, INREG(reg) | (VGA_DDC_DATA_OUT_EN | VGA_DDC_CLK_OUT_EN));
|
||||
(void)INREG(reg);
|
||||
if(edid)
|
||||
(void) INREG(reg);
|
||||
|
||||
if (edid)
|
||||
break;
|
||||
}
|
||||
/* Release the DDC lines when done or the Apple Cinema HD display
|
||||
* will switch off */
|
||||
OUTREG(reg, INREG(reg) & ~(VGA_DDC_CLK_OUT_EN | VGA_DDC_DATA_OUT_EN));
|
||||
(void)INREG(reg);
|
||||
if(out_edid)
|
||||
(void) INREG(reg);
|
||||
|
||||
if (out_edid)
|
||||
*out_edid = edid;
|
||||
if(!edid)
|
||||
|
||||
if (!edid)
|
||||
return MT_NONE;
|
||||
if(edid[0x14] & 0x80)
|
||||
|
||||
if (edid[0x14] & 0x80)
|
||||
{
|
||||
/* Fix detection using BIOS tables */
|
||||
if(rinfo->is_mobility /*&& conn == ddc_dvi*/ && (INREG(LVDS_GEN_CNTL) & LVDS_ON))
|
||||
|
||||
@@ -4,8 +4,9 @@
|
||||
#include "driver_mem.h"
|
||||
#include "bas_printf.h"
|
||||
#include "bas_string.h"
|
||||
#include "video.h"
|
||||
|
||||
// #define DEBUG
|
||||
#define DEBUG
|
||||
#include "debug.h"
|
||||
|
||||
#ifndef INT_MAX
|
||||
@@ -171,33 +172,35 @@ static int radeon_parse_monitor_layout(struct radeonfb_info *rinfo, const char *
|
||||
s2[0] = '\0';
|
||||
}
|
||||
|
||||
if (strcmp(s1, "CRT"))
|
||||
dbg("s1=%s, s2=%s \r\n", s1, s2);
|
||||
|
||||
if (!strcmp(s1, "CRT"))
|
||||
{
|
||||
rinfo->mon1_type = MT_CRT;
|
||||
dbg("monitor 1 set to CRT\r\n");
|
||||
}
|
||||
else if (strcmp(s1, "TMDS"))
|
||||
else if (!strcmp(s1, "TMDS"))
|
||||
{
|
||||
rinfo->mon1_type = MT_DFP;
|
||||
dbg("monitor 1 set to TMDS\r\n");
|
||||
}
|
||||
else if (strcmp(s1, "LVDS"))
|
||||
else if (!strcmp(s1, "LVDS"))
|
||||
{
|
||||
rinfo->mon1_type = MT_LCD;
|
||||
dbg("monitor 1 set to LVDS\r\n");
|
||||
}
|
||||
|
||||
if (strcmp(s2, "CRT"))
|
||||
if (!strcmp(s2, "CRT"))
|
||||
{
|
||||
rinfo->mon2_type = MT_CRT;
|
||||
dbg("monitor 2 set to CRT\r\n");
|
||||
}
|
||||
else if (strcmp(s2, "TMDS"))
|
||||
else if (!strcmp(s2, "TMDS"))
|
||||
{
|
||||
rinfo->mon2_type = MT_DFP;
|
||||
dbg("monitor 2 set to TMDS\r\n");
|
||||
}
|
||||
else if (strcmp(s2, "LVDS"))
|
||||
else if (!strcmp(s2, "LVDS"))
|
||||
{
|
||||
rinfo->mon2_type = MT_LCD;
|
||||
dbg("monitor 2 set to LVDS\r\n");
|
||||
@@ -211,9 +214,12 @@ static int radeon_parse_monitor_layout(struct radeonfb_info *rinfo, const char *
|
||||
*/
|
||||
void radeon_probe_screens(struct radeonfb_info *rinfo, const char *monitor_layout, int ignore_edid)
|
||||
{
|
||||
|
||||
#ifdef CONFIG_FB_RADEON_I2C
|
||||
int ddc_crt2_used = 0;
|
||||
#endif
|
||||
|
||||
dbg("monitor_layout=%s\r\n", monitor_layout);
|
||||
if (radeon_parse_monitor_layout(rinfo, monitor_layout))
|
||||
{
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user