Read about our upcoming Code of Conduct on this issue

Commit 2f4ef8f6 authored by alex@thinkpad's avatar alex@thinkpad
Browse files

QEMU: refactored serial flash CS handling to reduce duplicate code

(moved CS register and tested value to model_list.c)

--HG--
branch : qemu
parent 545a63e89193
......@@ -2454,6 +2454,20 @@ static int eos_handle_rtc_cs( unsigned int parm, EOSState *s, unsigned int addre
return ret;
}
static int eos_handle_serial_flash_cs( unsigned int parm, EOSState *s, unsigned int address, unsigned char type, unsigned int value )
{
const char * msg = "Serial flash CS";
unsigned int ret = 0;
if (type & MODE_WRITE)
{
serial_flash_set_CS(s->sf, (value & s->model->serial_flash_cs_bitmask) ? 1 : 0);
}
io_log("GPIO", s, address, type, value, ret, msg, 0, 0);
return ret;
}
unsigned int eos_handle_gpio ( unsigned int parm, EOSState *s, unsigned int address, unsigned char type, unsigned int value )
{
unsigned int ret = 1;
......@@ -2480,6 +2494,12 @@ unsigned int eos_handle_gpio ( unsigned int parm, EOSState *s, unsigned int addr
return eos_handle_rtc_cs(parm, s, address, type, value);
}
/* 0xC022002C, 0xC022C0D4 */
if (s->sf && address == s->model->serial_flash_cs_register)
{
return eos_handle_serial_flash_cs(parm, s, address, type, value);
}
switch (address & 0xFFFF)
{
case 0xCB6C: /* 5D3/6D expect this one to be 0x10 in bootloader (6D:FFFF0544) */
......@@ -2632,36 +2652,6 @@ unsigned int eos_handle_gpio ( unsigned int parm, EOSState *s, unsigned int addr
ret = 0;
break;
case 0xC0D4:
/* Serial flash on 100D */
msg = "SPI";
if (s->sf)
{
serial_flash_set_CS(s->sf, (value & 0x100000) ? 1 : 0);
}
if (!qemu_loglevel_mask(EOS_LOG_SFLASH))
{
if (value == 0x83DC00 || value == 0x93D800)
return 0; // Quiet
}
ret = 0;
break;
case 0x002C:
/* Serial flash on 70D */
msg = "SPI";
if (s->sf)
{
serial_flash_set_CS(s->sf, (value & 0x2) ? 1 : 0);
}
if (!qemu_loglevel_mask(EOS_LOG_SFLASH))
{
if (value == 0x46 || value == 0x44)
return 0; // Quiet
}
ret = 0;
break;
case 0x0098:
{
static int last_value = 1;
......@@ -5040,18 +5030,25 @@ unsigned int eos_handle_digic6 ( unsigned int parm, EOSState *s, unsigned int ad
return eos_handle_card_led(parm, s, address, type, value);
}
/* 0xD20B0884/084 so far */
/* 0xD20B0884/084, 0xD20B02A4/22A4 */
if (address == s->model->mpu_request_register ||
address == s->model->mpu_status_register)
{
return eos_handle_mpu(parm, s, address, type, value);
}
/* 0xD4013008, 0xD4013048 */
if (address == s->model->mpu_control_register)
{
return eos_handle_mreq(parm, s, address, type, value);
}
/* 0xD20B0D8C */
if (s->sf && address == s->model->serial_flash_cs_register)
{
return eos_handle_serial_flash_cs(parm, s, address, type, value);
}
switch (address)
{
case 0xD203046C:
......@@ -5182,21 +5179,6 @@ unsigned int eos_handle_digic6 ( unsigned int parm, EOSState *s, unsigned int ad
ret = 0x10000;
break;
case 0xD20B0D8C:
/* Serial flash on 80D */
msg = "SPI";
if (s->sf)
{
serial_flash_set_CS(s->sf, (value & 1) ? 0 : 1);
}
if (!qemu_loglevel_mask(EOS_LOG_SFLASH))
{
if (value == 0xD0002 || value == 0xC0003)
return 0; // Quiet
}
ret = 0;
break;
case 0xD6040000: /* M3: appears to expect 0x3008000 or 0x3108000 */
ret = 0x3008000;
break;
......
......@@ -99,9 +99,11 @@ struct eos_model_desc eos_model_list[] = {
.uart_rx_interrupt = 0x2E,
.uart_tx_interrupt = 0x3A,
.rtc_cs_register = 0xC02201F8,
.serial_flash_sio_ch = 4,
.serial_flash_sfio_ch = 4,
.serial_flash_sio_ch = 4, /* SF params are only valid on models */
.serial_flash_sfio_ch = 4, /* where .serial_flash_size is set */
.serial_flash_interrupt = 0x17B,
.serial_flash_cs_register = 0xC022C0D4,
.serial_flash_cs_bitmask = 0x00100000, /* 0x83DC00 / 0x93D800 */
},
{
/* defaults for DIGIC 6 cameras */
......@@ -132,6 +134,8 @@ struct eos_model_desc eos_model_list[] = {
.serial_flash_sio_ch = 2,
.serial_flash_sfio_ch = 7,
.serial_flash_interrupt = 0xFE,
.serial_flash_cs_register = 0xD20B0D8C,
.serial_flash_cs_bitmask = 0x00010000, /* 0xC0003 / 0xD0002 */
.mpu_request_register = 0xD20B0884, /* written in mpu_send (run with -d io) */
.mpu_request_bitmask = 0x00010000, /* 0xC0003 request, 0xD0002 idle, 0x4D00B2 init */
.mpu_status_register = 0xD20B0084, /* read in SIO3_ISR and MREQ_ISR (tst 0x10000) */
......@@ -227,9 +231,9 @@ struct eos_model_desc eos_model_list[] = {
{
.name = "100D",
.digic_version = 5,
.current_task_addr = 0x652AC,
.serial_flash_size = 0x1000000,
.serial_flash_sio_ch = 7,
.current_task_addr = 0x652AC,
.rtc_cs_register = 0xC022C020,
.rtc_time_correct = 0x98,
},
......@@ -253,6 +257,8 @@ struct eos_model_desc eos_model_list[] = {
.mpu_request_register = 0xC02200BC, /* written in mpu_send (run with -d io) */
.mpu_status_register = 0xC02200BC, /* read in SIO3_ISR and MREQ_ISR (tst 0x2) */
.serial_flash_size = 0x800000,
.serial_flash_cs_register = 0xC022002C,
.serial_flash_cs_bitmask = 0x00000002, /* 0x44 / 0x46 */
.current_task_addr = 0x74C28,
.rtc_cs_register = 0xC02201D4,
.rtc_time_correct = 0x9F,
......@@ -265,6 +271,8 @@ struct eos_model_desc eos_model_list[] = {
.mpu_status_register = 0xC02200BC, /* read in SIO3_ISR and MREQ_ISR (tst 0x2) */
.card_led_address = 0xC022C06C,
.serial_flash_size = 0x800000,
.serial_flash_cs_register = 0xC022002C,
.serial_flash_cs_bitmask = 0x00000002, /* 0x44 / 0x46 */
.rtc_cs_register = 0xC02201D4,
.rtc_time_correct = 0xA0,
},
......@@ -316,7 +324,7 @@ struct eos_model_desc eos_model_list[] = {
.card_led_address = 0xC022C188,
.serial_flash_size = 0x800000,
.rtc_cs_register = 0xC022C0C4,
//.rtc_time_correct = 0x98, /* the date/time dialog prevents the camera from going into LiveView */
//.rtc_time_correct = 0x98, /* the date/time dialog prevents the camera from going into LiveView */
},
{
.name = "EOSM2",
......@@ -326,7 +334,7 @@ struct eos_model_desc eos_model_list[] = {
.serial_flash_sio_ch = 7,
.rtc_cs_register = 0xC022C0C4,
.rtc_time_correct = 0x9A,
.rtc_control_reg_2 = 0x10, /* the date/time dialog prevents the camera from going into LiveView */
.rtc_control_reg_2 = 0x10, /* the date/time dialog prevents the camera from going into LiveView */
},
{
.name = "EOSM3",
......
......@@ -45,6 +45,8 @@ struct eos_model_desc {
uint32_t mpu_mreq_interrupt;
uint32_t mpu_sio3_interrupt;
uint32_t serial_flash_size;
uint32_t serial_flash_cs_register;
uint32_t serial_flash_cs_bitmask;
uint32_t serial_flash_sio_ch;
uint32_t serial_flash_sfio_ch;
uint32_t serial_flash_interrupt;
......@@ -63,7 +65,7 @@ struct eos_model_desc {
/* this must match the number of items in the above struct */
/* note: you get a compile-time error if params[] is smaller than the struct */
uint32_t params[44];
uint32_t params[46];
};
} __attribute__((packed));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment