GPCLK2 is used for Wifi, stop using it. Should fix the Wifi hangout

This commit is contained in:
F5OEO 2018-11-23 12:01:47 +00:00
parent 2ca0ed14a5
commit 6148190afa
3 changed files with 20 additions and 22 deletions

View file

@ -96,9 +96,7 @@ void dma::GetRpiInfo()
dma::~dma()
{
stop();
/*
unmapmem(mbox.virt_addr, NumPages * PAGE_SIZE);
*/
mem_unlock(mbox.handle, mbox.mem_ref);
mem_free(mbox.handle, mbox.mem_ref);

View file

@ -90,8 +90,8 @@ int clkgpio::SetPllNumber(int PllNo, int MashType)
Mash = 0;
gpioreg[GPCLK_CNTL] = 0x5A000000 | (Mash << 9) | pllnumber /*|(1 << 5)*/; //5 is Reset CLK
usleep(100);
gpioreg[GPCLK_CNTL_2] = 0x5A000000 | (Mash << 9) | pllnumber /*|(1 << 5)*/; //5 is Reset CLK
usleep(100);
//gpioreg[GPCLK_CNTL_2] = 0x5A000000 | (Mash << 9) | pllnumber /*|(1 << 5)*/; //5 is Reset CLK
//usleep(100);
Pllfrequency = GetPllFrequency(pllnumber);
return 0;
}
@ -128,8 +128,8 @@ int clkgpio::SetClkDivFrac(uint32_t Div, uint32_t Frac)
gpioreg[GPCLK_DIV] = 0x5A000000 | ((Div) << 12) | Frac;
usleep(100);
gpioreg[GPCLK_DIV_2] = 0x5A000000 | ((Div) << 12) | Frac;
usleep(100);
//gpioreg[GPCLK_DIV_2] = 0x5A000000 | ((Div) << 12) | Frac;
//usleep(100);
fprintf(stderr, "Clk Number %d div %d frac %d\n", pllnumber, Div, Frac);
//gpioreg[GPCLK_CNTL]= 0x5A000000 | (Mash << 9) | pllnumber |(1<<4) ; //4 is START CLK
// usleep(10);
@ -314,18 +314,18 @@ int clkgpio::SetCenterFrequency(uint64_t Frequency, int Bandwidth)
usleep(100);
gpioreg[GPCLK_CNTL] = 0x5A000000 | (Mash << 9) | pllnumber | (1 << 4); //4 is START CLK
usleep(100);
gpioreg[GPCLK_CNTL_2] = 0x5A000000 | (Mash << 9) | pllnumber | (1 << 4); //4 is START CLK
usleep(100);
//gpioreg[GPCLK_CNTL_2] = 0x5A000000 | (Mash << 9) | pllnumber | (1 << 4); //4 is START CLK
//usleep(100);
gpioreg[GPCLK_CNTL] = 0x5A000000 | (Mash << 9) | pllnumber | (1 << 4); //4 is START CLK
usleep(100);
gpioreg[GPCLK_CNTL_2] = 0x5A000000 | (Mash << 9) | pllnumber | (1 << 4); //4 is START CLK
usleep(100);
//gpioreg[GPCLK_CNTL_2] = 0x5A000000 | (Mash << 9) | pllnumber | (1 << 4); //4 is START CLK
//usleep(100);
}
else
{
GetPllFrequency(pllnumber); // Be sure to get the master PLL frequency
gpioreg[GPCLK_CNTL] = 0x5A000000 | (Mash << 9) | pllnumber | (1 << 4); //4 is START CLK
gpioreg[GPCLK_CNTL_2] = 0x5A000000 | (Mash << 9) | pllnumber | (1 << 4); //4 is START CLK
//gpioreg[GPCLK_CNTL_2] = 0x5A000000 | (Mash << 9) | pllnumber | (1 << 4); //4 is START CLK
}
return 0;
}
@ -334,9 +334,9 @@ void clkgpio::SetPhase(bool inversed)
{
uint32_t StateBefore = clkgpio::gpioreg[GPCLK_CNTL];
clkgpio::gpioreg[GPCLK_CNTL] = (0x5A << 24) | StateBefore | ((inversed ? 1 : 0) << 8) | 1 << 5;
clkgpio::gpioreg[GPCLK_CNTL_2] = (0x5A << 24) | StateBefore | ((inversed ? 1 : 0) << 8) | 1 << 5;
//clkgpio::gpioreg[GPCLK_CNTL_2] = (0x5A << 24) | StateBefore | ((inversed ? 1 : 0) << 8) | 1 << 5;
clkgpio::gpioreg[GPCLK_CNTL] = (0x5A << 24) | StateBefore | ((inversed ? 1 : 0) << 8) | 0 << 5;
clkgpio::gpioreg[GPCLK_CNTL_2] = (0x5A << 24) | StateBefore | ((inversed ? 1 : 0) << 8) | 0 << 5;
//clkgpio::gpioreg[GPCLK_CNTL_2] = (0x5A << 24) | StateBefore | ((inversed ? 1 : 0) << 8) | 0 << 5;
}
//Should inspect https://github.com/raspberrypi/linux/blob/ffd7bf4085b09447e5db96edd74e524f118ca3fe/drivers/clk/bcm/clk-bcm2835.c#L695
void clkgpio::SetAdvancedPllMode(bool Advanced)

View file

@ -49,7 +49,7 @@ void *mapmem(unsigned base, unsigned size)
base = base - offset;
/* open /dev/mem */
if ((mem_fd = open("/dev/mem", O_RDWR|O_SYNC) ) < 0) {
printf("can't open /dev/mem\nThis program should be run as root. Try prefixing command with: sudo\n");
fprintf(stderr,"can't open /dev/mem\nThis program should be run as root. Try prefixing command with: sudo\n");
exit (-1);
}
void *mem = mmap(
@ -60,10 +60,10 @@ void *mapmem(unsigned base, unsigned size)
mem_fd,
base);
#ifdef DEBUG
printf("base=0x%x, mem=%p\n", base, mem);
fprintf(stderr,"base=0x%x, mem=%p\n", base, mem);
#endif
if (mem == MAP_FAILED) {
printf("mmap error %p\n", mem);
fprintf(stderr,"mmap error %p\n", mem);
exit (-1);
}
close(mem_fd);
@ -90,13 +90,13 @@ static int mbox_property(int file_desc, void *buf)
int ret_val = ioctl(file_desc, IOCTL_MBOX_PROPERTY, buf);
if (ret_val < 0) {
printf("ioctl_set_msg failed:%d\n", ret_val);
fprintf(stderr,"ioctl_set_msg failed:%d\n", ret_val);
}
#ifdef DEBUG
unsigned *p = buf; int i; unsigned size = *(unsigned *)buf;
for (i=0; i<size/4; i++)
printf("%04x: 0x%08x\n", i*sizeof *p, p[i]);
fprintf(stderrn,"%04x: 0x%08x\n", i*sizeof *p, p[i]);
#endif
return ret_val;
}
@ -274,7 +274,7 @@ int mbox_open() {
// Open a char device file used for communicating with kernel mbox driver.
file_desc = open(VCIO_DEVICE_FILE_NAME, 0);
if(file_desc >= 0) {
printf("Using mbox device " VCIO_DEVICE_FILE_NAME ".\n");
fprintf(stderr,"Using mbox device " VCIO_DEVICE_FILE_NAME ".\n");
return file_desc;
}
@ -282,14 +282,14 @@ int mbox_open() {
unlink(LOCAL_DEVICE_FILE_NAME);
if(mknod(LOCAL_DEVICE_FILE_NAME, S_IFCHR|0600, makedev(MAJOR_NUM_A, 0)) >= 0 &&
(file_desc = open(LOCAL_DEVICE_FILE_NAME, 0)) >= 0) {
printf("Using local mbox device file with major %d.\n", MAJOR_NUM_A);
fprintf(stderr,"Using local mbox device file with major %d.\n", MAJOR_NUM_A);
return file_desc;
}
unlink(LOCAL_DEVICE_FILE_NAME);
if(mknod(LOCAL_DEVICE_FILE_NAME, S_IFCHR|0600, makedev(MAJOR_NUM_B, 0)) >= 0 &&
(file_desc = open(LOCAL_DEVICE_FILE_NAME, 0)) >= 0) {
printf("Using local mbox device file with major %d.\n", MAJOR_NUM_B);
fprintf(stderr,"Using local mbox device file with major %d.\n", MAJOR_NUM_B);
return file_desc;
}