|
|
@ -6,83 +6,6 @@ |
|
|
|
#include "gpio.h" |
|
|
|
#include "a3k.h" |
|
|
|
|
|
|
|
#define AIC14K_ADDR 0x80 |
|
|
|
|
|
|
|
void init_i2c1(void); |
|
|
|
int i2c_write(uint8_t addr, uint8_t *data, int len); |
|
|
|
int i2c_read(uint8_t addr, uint8_t *data, int len); |
|
|
|
|
|
|
|
int console_read(void *ptr, int len) |
|
|
|
{ |
|
|
|
return serial_recv_buffered(&serial0, ptr, len); |
|
|
|
} |
|
|
|
|
|
|
|
int console_write(const void *ptr, int len) |
|
|
|
{ |
|
|
|
return serial_send_buffered(&serial0, ptr, len); |
|
|
|
} |
|
|
|
|
|
|
|
static int do_codec_r(struct cmd_tbl_s *cmd, int argc, char *argv[]) |
|
|
|
{ |
|
|
|
uint8_t reg, val = 0; |
|
|
|
|
|
|
|
if (argc < 2) { |
|
|
|
return -1; |
|
|
|
} |
|
|
|
|
|
|
|
reg = strtoul(argv[1], NULL, 0); |
|
|
|
i2c_write(AIC14K_ADDR, ®, 1); |
|
|
|
i2c_read(AIC14K_ADDR, &val, 1); |
|
|
|
printf("read: reg %02x, val %02x\n", reg, val); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
CON_CMD(ar, 1, "read codec reg", do_codec_r); |
|
|
|
|
|
|
|
static int do_codec_w(struct cmd_tbl_s *cmd, int argc, char *argv[]) |
|
|
|
{ |
|
|
|
uint8_t dt[2]; |
|
|
|
|
|
|
|
if (argc < 3) { |
|
|
|
return -1; |
|
|
|
} |
|
|
|
|
|
|
|
dt[0] = strtoul(argv[1], NULL, 0); |
|
|
|
dt[1] = strtoul(argv[2], NULL, 0); |
|
|
|
i2c_write(AIC14K_ADDR, dt, 2); |
|
|
|
printf("write: reg %02x, val %02x\n", dt[0], dt[1]); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
CON_CMD(aw, 1, "write codec reg", do_codec_w); |
|
|
|
|
|
|
|
void init_codec() |
|
|
|
{ |
|
|
|
#define N_REG (7) |
|
|
|
int i; |
|
|
|
uint8_t regs[N_REG][2] = { |
|
|
|
{0x1, 0x41}, |
|
|
|
{0x2, 0xA0}, |
|
|
|
{0x4, 0x83}, |
|
|
|
{0x4, 0x8A}, |
|
|
|
{0x4, 0x01}, |
|
|
|
{0x5c, 0xB8}, |
|
|
|
{0x6, 0x02} |
|
|
|
}; |
|
|
|
uint8_t dt; |
|
|
|
|
|
|
|
for (i = 0; i < N_REG; ++i) { |
|
|
|
i2c_write(0x80, regs[i], 2); |
|
|
|
} |
|
|
|
|
|
|
|
for (i = 0; i < N_REG; ++i) { |
|
|
|
dt = 0xff; |
|
|
|
i2c_write(0x80, regs[i], 1); |
|
|
|
i2c_read(0x80, &dt, 1); |
|
|
|
printf("reg: %02x, val: %02x\r\n", regs[i][0], dt); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
static void loopback() |
|
|
|
{ |
|
|
|
static uint8_t buffer[512] = {0}; |
|
|
|