/* * a.lp_mp3 - VS1011B driver for Fonera * Copyright (c) 2007 phrozen.org - John Crispin * * 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., 59 Temple Place, Suite 330, Boston, MA02111-1307USA * * Feedback, Bugs.... mail john@phrozen.org * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "ar531xlnx.h" #define AR5315_DSLBASE 0xB1000000 #define AR5315_GPIO_DI (AR5315_DSLBASE + 0x0088) #define AR5315_GPIO_DO (AR5315_DSLBASE + 0x0090) #define AR5315_GPIO_CR (AR5315_DSLBASE + 0x0098) #define AR5315_GPIO_INT (AR5315_DSLBASE + 0x00a0) #define GPIO_0 1<<0 #define GPIO_1 1<<1 #define GPIO_2 1<<2 #define GPIO_3 1<<3 #define GPIO_4 1<<4 #define GPIO_6 1<<6 #define GPIO_7 1<<7 #define DREQ ((unsigned int)GPIO_7) #define SCK ((unsigned int)GPIO_1) #define SI ((unsigned int)GPIO_4) #define BSYNC ((unsigned int)GPIO_3) #define CS ((unsigned int)GPIO_0) #define SO ((unsigned int)GPIO_6) #define RES ((unsigned int)GPIO_2) #define REG_MODE 0x0 #define REG_STATUS 0x1 #define REG_BASS 0x2 #define REG_CLOCKF 0x3 #define REG_DECODETIME 0x4 #define REG_AUDATA 0x5 #define REG_WRAM 0x6 #define REG_WRAMADDR 0x7 #define REG_HDAT0 0x8 #define REG_HDAT1 0x9 #define REG_A1ADDR 0xa #define REG_VOL 0xb #define REG_A1CTRL0 0xc #define REG_A1CTRL1 0xd #define REG_A1CTRL2 0xe #define VS1011_NEEDS_DATA spi_get_bit(DREQ) #define VS1011_NEEDS_NO_DATA (spi_get_bit(DREQ)== 0x00) #define VS1011_WHILE_NEEDS_NO_DATA while(spi_get_bit(DREQ)== 0x00){} #define VS_CS_LO spi_clear_bit(CS) #define VS_CS_HI spi_set_bit(CS) #define VS_BSYNC_LO spi_clear_bit(BSYNC) #define VS_BSYNC_HI spi_set_bit(BSYNC) #define VS_RESET_LO spi_clear_bit(RES) #define VS_RESET_HI spi_set_bit(RES) #define VS1011_READ SPI_io_vs1011b(0x03) #define VS1011_WRITE SPI_io_vs1011b(0x02) void msDelay(int ms) { int i,a; int delayvar=10; for (a=0;a=0; i--){ if(byte & (1<>8)&0xff); SPI_io_vs1011b(data&0xff); VS_CS_HI; } unsigned int VS1011_read_SCI(unsigned char reg){ unsigned int data; VS_CS_LO; VS1011_READ; SPI_io_vs1011b(reg); data = 0; data = SPI_io_vs1011b(0x00); data <<= 8; data += SPI_io_vs1011b(0x00); VS_CS_HI; return data; } void VS1011_send_SDI(unsigned char byte){ int i; VS_BSYNC_LO; for(i = 7; i>=0; i--){ if(byte & (1<sample_rate = sample_rate_values[(audata&0x1E00)>>9]; audio->bitrate = audata&0x1FF; audio->is_stereo = (audata&0x8000)>>15; } void VS1011_print_registers(void){ unsigned char i; for(i = 0; i< 14; i++){ unsigned int regval = VS1011_read_SCI(i); printk("mp3_drv.ko : %d \n", regval); } } void VS1011_volume(unsigned char left, unsigned char right){ unsigned int regval = left; regval <<=8; regval += right; VS1011_send_SCI(REG_VOL, regval); } void VS1011_set_bass(unsigned int regval){ VS1011_send_SCI(REG_BASS, regval); } void VS1011_set_reg(unsigned int reg, unsigned int regval){ VS1011_send_SCI(reg, regval); } /* int vs_test(void) { SPI_init_vs1011(); printk("%u\n", *R_GEN_CONFIG); VS1001_init(_crystal_freq); VS1001_print_registers(); VS1001_volume(0x30, 0x30); msDelay(1000); VS1001_sine(1, 0x30); msDelay(1000); VS1001_sine(0, 0); VS1001_send_zeros(0x20); msDelay(1000); VS1001_sine(1, 0x30); msDelay(1000); VS1001_sine(0, 0); VS1001_send_zeros(0x20); msDelay(1000); VS1001_sine(1, 0x30); msDelay(1000); VS1001_sine(0, 0); AUDIO_DATA a; VS1001_get_audio_data(&a); printk("mp3_drv.ko : rate : %d, bit : %d, stereo : %d \n", a.sample_rate, a.bitrate, a.is_stereo); VS1001_SW_reset(_crystal_freq); return 0; }*/