s2c24xxx cleanup and modernization of devices using it (nw)

This commit is contained in:
Miodrag Milanovic 2013-04-18 14:52:27 +00:00
parent 03ce85e696
commit 96f1b3375f
12 changed files with 361 additions and 304 deletions

View File

@ -59,39 +59,33 @@ extern const device_type S3C2400;
TYPE DEFINITIONS
*******************************************************************************/
typedef UINT32 (*s3c24xx_gpio_port_r_func)( device_t *device, int port, UINT32 mask);
typedef void (*s3c24xx_gpio_port_w_func)( device_t *device, int port, UINT32 mask, UINT32 data);
typedef int (*s3c24xx_core_pin_r_func)( device_t *device, int pin);
typedef void (*s3c24xx_core_pin_w_func)( device_t *device, int pin, int data);
struct s3c2400_interface_core
{
s3c24xx_core_pin_r_func pin_r;
s3c24xx_core_pin_w_func pin_w;
devcb_read32 pin_r;
devcb_write32 pin_w;
};
struct s3c2400_interface_gpio
{
s3c24xx_gpio_port_r_func port_r;
s3c24xx_gpio_port_w_func port_w;
devcb_read32 port_r;
devcb_write32 port_w;
};
struct s3c2400_interface_i2c
{
write_line_device_func scl_w;
read_line_device_func sda_r;
write_line_device_func sda_w;
devcb_write_line scl_w;
devcb_read_line sda_r;
devcb_write_line sda_w;
};
struct s3c2400_interface_adc
{
read32_device_func data_r;
devcb_read32 data_r;
};
struct s3c2400_interface_i2s
{
write16_device_func data_w;
devcb_write16 data_w;
};
struct s3c2400_interface_lcd
@ -746,6 +740,20 @@ struct s3c24xx_t
s3c24xx_spi_t spi[S3C24XX_SPI_COUNT];
s3c24xx_mmc_t mmc;
device_t *m_cpu;
devcb_resolved_read32 pin_r;
devcb_resolved_write32 pin_w;
devcb_resolved_read32 port_r;
devcb_resolved_write32 port_w;
devcb_resolved_write_line scl_w;
devcb_resolved_read_line sda_r;
devcb_resolved_write_line sda_w;
devcb_resolved_read32 adc_data_r;
devcb_resolved_write16 i2s_data_w;
devcb_resolved_write8 command_w;
devcb_resolved_write8 address_w;
devcb_resolved_read8 nand_data_r;
devcb_resolved_write8 nand_data_w;
};
#endif

View File

@ -69,47 +69,41 @@ DECLARE_READ32_DEVICE_HANDLER( s3c2410_lcd_r );
TYPE DEFINITIONS
*******************************************************************************/
typedef UINT32 (*s3c24xx_gpio_port_r_func)( device_t *device, int port, UINT32 mask);
typedef void (*s3c24xx_gpio_port_w_func)( device_t *device, int port, UINT32 mask, UINT32 data);
typedef int (*s3c24xx_core_pin_r_func)( device_t *device, int pin);
typedef void (*s3c24xx_core_pin_w_func)( device_t *device, int pin, int data);
struct s3c2410_interface_core
{
s3c24xx_core_pin_r_func pin_r;
s3c24xx_core_pin_w_func pin_w;
devcb_read32 pin_r;
devcb_write32 pin_w;
};
struct s3c2410_interface_gpio
{
s3c24xx_gpio_port_r_func port_r;
s3c24xx_gpio_port_w_func port_w;
devcb_read32 port_r;
devcb_write32 port_w;
};
struct s3c2410_interface_i2c
{
write_line_device_func scl_w;
read_line_device_func sda_r;
write_line_device_func sda_w;
devcb_write_line scl_w;
devcb_read_line sda_r;
devcb_write_line sda_w;
};
struct s3c2410_interface_adc
{
read32_device_func data_r;
devcb_read32 data_r;
};
struct s3c2410_interface_i2s
{
write16_device_func data_w;
devcb_write16 data_w;
};
struct s3c2410_interface_nand
{
write8_device_func command_w;
write8_device_func address_w;
read8_device_func data_r;
write8_device_func data_w;
devcb_write8 command_w;
devcb_write8 address_w;
devcb_read8 data_r;
devcb_write8 data_w;
};
struct s3c2410_interface_lcd
@ -893,6 +887,20 @@ struct s3c24xx_t
s3c24xx_spi_t spi[S3C24XX_SPI_COUNT];
s3c24xx_sdi_t sdi;
device_t *m_cpu;
devcb_resolved_read32 pin_r;
devcb_resolved_write32 pin_w;
devcb_resolved_read32 port_r;
devcb_resolved_write32 port_w;
devcb_resolved_write_line scl_w;
devcb_resolved_read_line sda_r;
devcb_resolved_write_line sda_w;
devcb_resolved_read32 adc_data_r;
devcb_resolved_write16 i2s_data_w;
devcb_resolved_write8 command_w;
devcb_resolved_write8 address_w;
devcb_resolved_read8 nand_data_r;
devcb_resolved_write8 nand_data_w;
};
#endif

View File

@ -67,47 +67,41 @@ extern const device_type S3C2440;
TYPE DEFINITIONS
*******************************************************************************/
typedef UINT32 (*s3c24xx_gpio_port_r_func)( device_t *device, int port, UINT32 mask);
typedef void (*s3c24xx_gpio_port_w_func)( device_t *device, int port, UINT32 mask, UINT32 data);
typedef int (*s3c24xx_core_pin_r_func)( device_t *device, int pin);
typedef void (*s3c24xx_core_pin_w_func)( device_t *device, int pin, int data);
struct s3c2440_interface_core
{
s3c24xx_core_pin_r_func pin_r;
s3c24xx_core_pin_w_func pin_w;
devcb_read32 pin_r;
devcb_write32 pin_w;
};
struct s3c2440_interface_gpio
{
s3c24xx_gpio_port_r_func port_r;
s3c24xx_gpio_port_w_func port_w;
devcb_read32 port_r;
devcb_write32 port_w;
};
struct s3c2440_interface_i2c
{
write_line_device_func scl_w;
read_line_device_func sda_r;
write_line_device_func sda_w;
devcb_write_line scl_w;
devcb_read_line sda_r;
devcb_write_line sda_w;
};
struct s3c2440_interface_adc
{
read32_device_func data_r;
devcb_read32 data_r;
};
struct s3c2440_interface_i2s
{
write16_device_func data_w;
devcb_write16 data_w;
};
struct s3c2440_interface_nand
{
write8_device_func command_w;
write8_device_func address_w;
read8_device_func data_r;
write8_device_func data_w;
devcb_write8 command_w;
devcb_write8 address_w;
devcb_read8 data_r;
devcb_write8 data_w;
};
struct s3c2440_interface_lcd
@ -964,6 +958,19 @@ struct s3c24xx_t
s3c24xx_sdi_t sdi;
s3c24xx_ac97_t ac97;
device_t *m_cpu;
devcb_resolved_read32 pin_r;
devcb_resolved_write32 pin_w;
devcb_resolved_read32 port_r;
devcb_resolved_write32 port_w;
devcb_resolved_write_line scl_w;
devcb_resolved_read_line sda_r;
devcb_resolved_write_line sda_w;
devcb_resolved_read32 adc_data_r;
devcb_resolved_write16 i2s_data_w;
devcb_resolved_write8 command_w;
devcb_resolved_write8 address_w;
devcb_resolved_read8 nand_data_r;
devcb_resolved_write8 nand_data_w;
};
#endif

View File

@ -136,9 +136,9 @@ static void s3c24xx_reset( device_t *device)
INLINE int iface_core_pin_r( device_t *device, int pin)
{
s3c24xx_t *s3c24xx = get_token( device);
if (s3c24xx->iface->core.pin_r)
if (!s3c24xx->pin_r.isnull())
{
return (s3c24xx->iface->core.pin_r)( device, pin);
return (s3c24xx->pin_r)(pin);
}
else
{
@ -1872,9 +1872,9 @@ static void s3c24xx_gpio_reset( device_t *device)
INLINE UINT32 iface_gpio_port_r( device_t *device, int port, UINT32 mask)
{
s3c24xx_t *s3c24xx = get_token( device);
if (s3c24xx->iface->gpio.port_r)
if (!s3c24xx->port_r.isnull())
{
return (s3c24xx->iface->gpio.port_r)( device, port, mask);
return (s3c24xx->port_r)( port, mask);
}
else
{
@ -1885,9 +1885,9 @@ INLINE UINT32 iface_gpio_port_r( device_t *device, int port, UINT32 mask)
INLINE void iface_gpio_port_w( device_t *device, int port, UINT32 mask, UINT32 data)
{
s3c24xx_t *s3c24xx = get_token( device);
if (s3c24xx->iface->gpio.port_w)
if (!s3c24xx->port_w.isnull())
{
(s3c24xx->iface->gpio.port_w)( device, port, mask, data);
(s3c24xx->port_w)( port, data, mask );
}
}
@ -2437,27 +2437,27 @@ static void s3c24xx_iic_reset( device_t *device)
INLINE void iface_i2c_scl_w( device_t *device, int state)
{
s3c24xx_t *s3c24xx = get_token( device);
if (s3c24xx->iface->i2c.scl_w)
if (!s3c24xx->scl_w.isnull())
{
(s3c24xx->iface->i2c.scl_w)( device, state);
(s3c24xx->scl_w)( state);
}
}
INLINE void iface_i2c_sda_w( device_t *device, int state)
{
s3c24xx_t *s3c24xx = get_token( device);
if (s3c24xx->iface->i2c.sda_w)
if (!s3c24xx->sda_w.isnull())
{
(s3c24xx->iface->i2c.sda_w)( device, state);
(s3c24xx->sda_w)(state);
}
}
INLINE int iface_i2c_sda_r( device_t *device)
{
s3c24xx_t *s3c24xx = get_token( device);
if (s3c24xx->iface->i2c.sda_r)
if (!s3c24xx->sda_r.isnull())
{
return (s3c24xx->iface->i2c.sda_r)( device);
return (s3c24xx->sda_r)();
}
else
{
@ -2684,9 +2684,9 @@ static void s3c24xx_iis_reset( device_t *device)
INLINE void iface_i2s_data_w( device_t *device, int ch, UINT16 data)
{
s3c24xx_t *s3c24xx = get_token( device);
if (s3c24xx->iface->i2s.data_w)
if (!s3c24xx->i2s_data_w.isnull())
{
(s3c24xx->iface->i2s.data_w)( device, device->machine().driver_data()->generic_space(), ch, data, 0);
(s3c24xx->i2s_data_w)( ch, data, 0);
}
}
@ -2940,7 +2940,7 @@ static void s3c24xx_adc_reset( device_t *device)
static UINT32 iface_adc_data_r( device_t *device, int ch)
{
s3c24xx_t *s3c24xx = get_token( device);
if (s3c24xx->iface->adc.data_r)
if (!s3c24xx->adc_data_r.isnull())
{
int offs = ch;
#if defined(DEVICE_S3C2410) || defined(DEVICE_S3C2440)
@ -2949,7 +2949,7 @@ static UINT32 iface_adc_data_r( device_t *device, int ch)
offs += 2;
}
#endif
return (s3c24xx->iface->adc.data_r)( device, device->machine().driver_data()->generic_space(), offs, 0);
return (s3c24xx->adc_data_r)(offs, 0);
}
else
{
@ -3179,27 +3179,27 @@ static void s3c24xx_nand_reset( device_t *device)
INLINE void iface_nand_command_w( device_t *device, UINT8 data)
{
s3c24xx_t *s3c24xx = get_token( device);
if (s3c24xx->iface->nand.command_w)
if (!s3c24xx->command_w.isnull())
{
(s3c24xx->iface->nand.command_w)( device, device->machine().driver_data()->generic_space(), 0, data, 0xff);
(s3c24xx->command_w)( 0, data, 0xff);
}
}
INLINE void iface_nand_address_w( device_t *device, UINT8 data)
{
s3c24xx_t *s3c24xx = get_token( device);
if (s3c24xx->iface->nand.address_w)
if (!s3c24xx->address_w.isnull())
{
(s3c24xx->iface->nand.address_w)( device, device->machine().driver_data()->generic_space(), 0, data, 0xff);
(s3c24xx->address_w)( 0, data, 0xff);
}
}
INLINE UINT8 iface_nand_data_r( device_t *device)
{
s3c24xx_t *s3c24xx = get_token( device);
if (s3c24xx->iface->nand.data_r)
if (!s3c24xx->nand_data_r.isnull())
{
return (s3c24xx->iface->nand.data_r)( device, device->machine().driver_data()->generic_space(), 0, 0xff);
return (s3c24xx->nand_data_r)( 0, 0xff);
}
else
{
@ -3210,9 +3210,9 @@ INLINE UINT8 iface_nand_data_r( device_t *device)
INLINE void iface_nand_data_w( device_t *device, UINT8 data)
{
s3c24xx_t *s3c24xx = get_token( device);
if (s3c24xx->iface->nand.data_w)
if (!s3c24xx->nand_data_w.isnull())
{
(s3c24xx->iface->nand.data_w)( device, device->machine().driver_data()->generic_space(), 0, data, 0xff);
(s3c24xx->nand_data_w)(0, data, 0xff);
}
}
@ -3684,6 +3684,21 @@ static DEVICE_START( s3c24xx )
verboselog( device->machine(), 1, "s3c24xx device start\n");
s3c24xx->iface = (const s3c24xx_interface *)device->static_config();
s3c24xx->pin_r.resolve(s3c24xx->iface->core.pin_r, *device);
s3c24xx->pin_w.resolve(s3c24xx->iface->core.pin_w, *device);
s3c24xx->port_r.resolve(s3c24xx->iface->gpio.port_r, *device);
s3c24xx->port_w.resolve(s3c24xx->iface->gpio.port_w, *device);
s3c24xx->scl_w.resolve(s3c24xx->iface->i2c.scl_w, *device);
s3c24xx->sda_r.resolve(s3c24xx->iface->i2c.sda_r, *device);
s3c24xx->sda_w.resolve(s3c24xx->iface->i2c.sda_w, *device);
s3c24xx->adc_data_r.resolve(s3c24xx->iface->adc.data_r, *device);
s3c24xx->i2s_data_w.resolve(s3c24xx->iface->i2s.data_w, *device);
#if !defined(DEVICE_S3C2400)
s3c24xx->command_w.resolve(s3c24xx->iface->nand.command_w, *device);
s3c24xx->address_w.resolve(s3c24xx->iface->nand.address_w, *device);
s3c24xx->nand_data_r.resolve(s3c24xx->iface->nand.data_r, *device);
s3c24xx->nand_data_w.resolve(s3c24xx->iface->nand.data_w, *device);
#endif
for (int i = 0; i < 5; i++)
{
s3c24xx->pwm.timer[i] = device->machine().scheduler().timer_alloc( FUNC(s3c24xx_pwm_timer_exp), (void*)device);

View File

@ -85,7 +85,8 @@ public:
: driver_device(mconfig, type, tag),
m_system_memory(*this, "systememory"),
m_i2cmem(*this, "i2cmem"),
m_maincpu(*this, "maincpu") { }
m_s3c2410(*this, "s3c2410"),
m_maincpu(*this, "maincpu") { }
required_shared_ptr<UINT32> m_system_memory;
required_device<i2cmem_device> m_i2cmem;
@ -99,12 +100,22 @@ public:
int m_rom_pagesize;
UINT8* m_flash;
device_t* m_s3c2410;
required_device<s3c2410_device> m_s3c2410;
DECLARE_DRIVER_INIT(touryuu);
DECLARE_DRIVER_INIT(bballoon);
virtual void machine_start();
virtual void machine_reset();
required_device<cpu_device> m_maincpu;
DECLARE_READ32_MEMBER(s3c2410_gpio_port_r);
DECLARE_WRITE32_MEMBER(s3c2410_gpio_port_w);
DECLARE_READ32_MEMBER(s3c2410_core_pin_r);
DECLARE_WRITE8_MEMBER(s3c2410_nand_command_w );
DECLARE_WRITE8_MEMBER(s3c2410_nand_address_w );
DECLARE_READ8_MEMBER(s3c2410_nand_data_r );
DECLARE_WRITE8_MEMBER(s3c2410_nand_data_w );
DECLARE_WRITE_LINE_MEMBER(s3c2410_i2c_scl_w );
DECLARE_READ_LINE_MEMBER(s3c2410_i2c_sda_r );
DECLARE_WRITE_LINE_MEMBER(s3c2410_i2c_sda_w );
};
@ -136,40 +147,38 @@ NAND Flash Controller (4KB internal buffer)
static const UINT8 security_data[] = { 0x01, 0xC4, 0xFF, 0x22, 0xFF, 0xFF, 0xFF, 0xFF };
static UINT32 s3c2410_gpio_port_r( device_t *device, int port, UINT32 mask)
READ32_MEMBER(ghosteo_state::s3c2410_gpio_port_r)
{
ghosteo_state *state = device->machine().driver_data<ghosteo_state>();
UINT32 data = state->m_bballoon_port[port];
switch (port)
UINT32 data = m_bballoon_port[offset];
switch (offset)
{
case S3C2410_GPIO_PORT_F :
{
data = (data & ~0xFF) | security_data[state->m_security_count]; // bballoon security @ 0x3001BD68
data = (data & ~0xFF) | security_data[m_security_count]; // bballoon security @ 0x3001BD68
}
break;
case S3C2410_GPIO_PORT_G :
{
data = data ^ 0x20;
state->m_bballoon_port[port] = data;
m_bballoon_port[offset] = data;
}
break;
}
return data;
}
static void s3c2410_gpio_port_w( device_t *device, int port, UINT32 mask, UINT32 data)
WRITE32_MEMBER(ghosteo_state::s3c2410_gpio_port_w)
{
ghosteo_state *state = device->machine().driver_data<ghosteo_state>();
UINT32 old_value = state->m_bballoon_port[port];
state->m_bballoon_port[port] = data;
switch (port)
UINT32 old_value = m_bballoon_port[offset];
m_bballoon_port[offset] = data;
switch (offset)
{
case S3C2410_GPIO_PORT_F :
{
switch (data)
{
case 0x04 : state->m_security_count = 0; break;
case 0x44 : state->m_security_count = 2; break;
case 0x04 : m_security_count = 0; break;
case 0x44 : m_security_count = 2; break;
}
}
break;
@ -179,10 +188,10 @@ static void s3c2410_gpio_port_w( device_t *device, int port, UINT32 mask, UINT32
if (((data & 0x10) != 0) && ((old_value & 0x10) == 0))
{
#if NAND_LOG
logerror( "security_count %d -> %d\n", state->m_security_count, state->m_security_count + 1);
logerror( "security_count %d -> %d\n", m_security_count, m_security_count + 1);
#endif
state->m_security_count++;
if (state->m_security_count > 7) state->m_security_count = 0;
m_security_count++;
if (m_security_count > 7) m_security_count = 0;
}
}
break;
@ -203,10 +212,10 @@ NCON : NAND flash memory address step selection
*/
static int s3c2410_core_pin_r( device_t *device, int pin)
READ32_MEMBER(ghosteo_state::s3c2410_core_pin_r)
{
int data = 0;
switch (pin)
switch (offset)
{
case S3C2410_CORE_PIN_NCON : data = 1; break;
case S3C2410_CORE_PIN_OM0 : data = 0; break;
@ -217,10 +226,9 @@ static int s3c2410_core_pin_r( device_t *device, int pin)
// NAND
static WRITE8_DEVICE_HANDLER( s3c2410_nand_command_w )
WRITE8_MEMBER(ghosteo_state::s3c2410_nand_command_w )
{
ghosteo_state *state = space.machine().driver_data<ghosteo_state>();
struct nand_t &nand = state->m_nand;
struct nand_t &nand = m_nand;
// device_t *nand = space.machine().device( "nand");
#if NAND_LOG
logerror( "s3c2410_nand_command_w %02X\n", data);
@ -230,7 +238,7 @@ static WRITE8_DEVICE_HANDLER( s3c2410_nand_command_w )
case 0xFF :
{
nand.mode = NAND_M_INIT;
s3c2410_pin_frnb_w( device, 1);
s3c2410_pin_frnb_w( m_s3c2410, 1);
}
break;
case 0x00 :
@ -243,10 +251,9 @@ static WRITE8_DEVICE_HANDLER( s3c2410_nand_command_w )
}
}
static WRITE8_DEVICE_HANDLER( s3c2410_nand_address_w )
WRITE8_MEMBER(ghosteo_state::s3c2410_nand_address_w )
{
ghosteo_state *state = space.machine().driver_data<ghosteo_state>();
struct nand_t &nand = state->m_nand;
struct nand_t &nand = m_nand;
// device_t *nand = space.machine().device( "nand");
#if NAND_LOG
logerror( "s3c2410_nand_address_w %02X\n", data);
@ -271,18 +278,17 @@ static WRITE8_DEVICE_HANDLER( s3c2410_nand_address_w )
nand.addr_load_ptr++;
if ((nand.mode == NAND_M_READ) && (nand.addr_load_ptr == 4))
{
s3c2410_pin_frnb_w( device, 0);
s3c2410_pin_frnb_w( device, 1);
s3c2410_pin_frnb_w( m_s3c2410, 0);
s3c2410_pin_frnb_w( m_s3c2410, 1);
}
}
break;
}
}
static READ8_DEVICE_HANDLER( s3c2410_nand_data_r )
READ8_MEMBER(ghosteo_state::s3c2410_nand_data_r )
{
ghosteo_state *state = space.machine().driver_data<ghosteo_state>();
struct nand_t &nand = state->m_nand;
struct nand_t &nand = m_nand;
// device_t *nand = space.machine().device( "nand");
UINT8 data = 0;
switch (nand.mode)
@ -294,16 +300,16 @@ static READ8_DEVICE_HANDLER( s3c2410_nand_data_r )
break;
case NAND_M_READ :
{
if (nand.byte_addr < state->m_rom_pagesize)
if (nand.byte_addr < m_rom_pagesize)
{
data = *(state->m_flash + nand.page_addr * state->m_rom_pagesize + nand.byte_addr);
data = *(m_flash + nand.page_addr * m_rom_pagesize + nand.byte_addr);
}
else
{
if ((nand.byte_addr >= 0x200) && (nand.byte_addr < 0x204))
{
UINT8 mecc[4];
s3c2410_nand_calculate_mecc( state->m_flash + nand.page_addr * 0x200, 0x200, mecc);
s3c2410_nand_calculate_mecc( m_flash + nand.page_addr * 0x200, 0x200, mecc);
data = mecc[nand.byte_addr-0x200];
}
else
@ -327,7 +333,7 @@ static READ8_DEVICE_HANDLER( s3c2410_nand_data_r )
return data;
}
static WRITE8_DEVICE_HANDLER( s3c2410_nand_data_w )
WRITE8_MEMBER(ghosteo_state::s3c2410_nand_data_w )
{
// device_t *nand = space.machine().device( "nand");
#if NAND_LOG
@ -337,27 +343,24 @@ static WRITE8_DEVICE_HANDLER( s3c2410_nand_data_w )
// I2C
static WRITE_LINE_DEVICE_HANDLER( s3c2410_i2c_scl_w )
WRITE_LINE_MEMBER(ghosteo_state::s3c2410_i2c_scl_w )
{
ghosteo_state *sta = device->machine().driver_data<ghosteo_state>();
// logerror( "s3c2410_i2c_scl_w %d\n", state ? 1 : 0);
i2cmem_scl_write( sta->m_i2cmem, state);
i2cmem_scl_write( m_i2cmem, state);
}
static READ_LINE_DEVICE_HANDLER( s3c2410_i2c_sda_r )
READ_LINE_MEMBER(ghosteo_state::s3c2410_i2c_sda_r )
{
ghosteo_state *sta = device->machine().driver_data<ghosteo_state>();
int state;
state = i2cmem_sda_read( sta->m_i2cmem );
state = i2cmem_sda_read( m_i2cmem );
// logerror( "s3c2410_i2c_sda_r %d\n", state ? 1 : 0);
return state;
}
static WRITE_LINE_DEVICE_HANDLER( s3c2410_i2c_sda_w )
WRITE_LINE_MEMBER(ghosteo_state::s3c2410_i2c_sda_w )
{
ghosteo_state *sta = device->machine().driver_data<ghosteo_state>();
// logerror( "s3c2410_i2c_sda_w %d\n", state ? 1 : 0);
i2cmem_sda_write( sta->m_i2cmem, state);
i2cmem_sda_write( m_i2cmem, state);
}
WRITE32_MEMBER(ghosteo_state::sound_w)
@ -540,17 +543,17 @@ INPUT_PORTS_END
static const s3c2410_interface bballoon_s3c2410_intf =
{
// CORE (pin read / pin write)
{ s3c2410_core_pin_r, NULL },
{ DEVCB_DRIVER_MEMBER32(ghosteo_state,s3c2410_core_pin_r), DEVCB_NULL },
// GPIO (port read / port write)
{ s3c2410_gpio_port_r, s3c2410_gpio_port_w },
{ DEVCB_DRIVER_MEMBER32(ghosteo_state,s3c2410_gpio_port_r), DEVCB_DRIVER_MEMBER32(ghosteo_state,s3c2410_gpio_port_w) },
// I2C (scl write / sda read / sda write)
{ s3c2410_i2c_scl_w, s3c2410_i2c_sda_r, s3c2410_i2c_sda_w },
{ DEVCB_DRIVER_LINE_MEMBER(ghosteo_state,s3c2410_i2c_scl_w), DEVCB_DRIVER_LINE_MEMBER(ghosteo_state,s3c2410_i2c_sda_r), DEVCB_DRIVER_LINE_MEMBER(ghosteo_state,s3c2410_i2c_sda_w) },
// ADC (data read)
{ NULL },
{ DEVCB_NULL },
// I2S (data write)
{ NULL },
{ DEVCB_NULL },
// NAND (command write / address write / data read / data write)
{ s3c2410_nand_command_w, s3c2410_nand_address_w, s3c2410_nand_data_r, s3c2410_nand_data_w }
{ DEVCB_DRIVER_MEMBER(ghosteo_state,s3c2410_nand_command_w), DEVCB_DRIVER_MEMBER(ghosteo_state,s3c2410_nand_address_w), DEVCB_DRIVER_MEMBER(ghosteo_state,s3c2410_nand_data_r), DEVCB_DRIVER_MEMBER(ghosteo_state,s3c2410_nand_data_w) }
};
static const i2cmem_interface bballoon_i2cmem_interface =
@ -596,8 +599,7 @@ void ghosteo_state::machine_start()
void ghosteo_state::machine_reset()
{
m_maincpu->space(AS_PROGRAM).install_read_handler(0x4d000010, 0x4d000013,read32_delegate(FUNC(ghosteo_state::bballoon_speedup_r), this));
m_s3c2410 = machine().device("s3c2410");
m_maincpu->space(AS_PROGRAM).install_read_handler(0x4d000010, 0x4d000013,read32_delegate(FUNC(ghosteo_state::bballoon_speedup_r), this));
}
static MACHINE_CONFIG_START( ghosteo, ghosteo_state )

View File

@ -55,6 +55,8 @@ public:
DECLARE_INPUT_CHANGED_MEMBER(port_changed);
inline void ATTR_PRINTF(3,4) verboselog( int n_level, const char *s_fmt, ...);
required_device<cpu_device> m_maincpu;
DECLARE_READ32_MEMBER(s3c2440_gpio_port_r);
DECLARE_WRITE32_MEMBER(s3c2440_gpio_port_w);
};
@ -76,11 +78,10 @@ inline void ATTR_PRINTF(3,4) gizmondo_state::verboselog( int n_level, const char
// I/O PORT
static UINT32 s3c2440_gpio_port_r( device_t *device, int port, UINT32 mask)
READ32_MEMBER(gizmondo_state::s3c2440_gpio_port_r)
{
gizmondo_state *gizmondo = device->machine().driver_data<gizmondo_state>();
UINT32 data = gizmondo->m_port[port];
switch (port)
UINT32 data = m_port[offset];
switch (offset)
{
case S3C2440_GPIO_PORT_D :
{
@ -90,16 +91,16 @@ static UINT32 s3c2440_gpio_port_r( device_t *device, int port, UINT32 mask)
break;
case S3C2440_GPIO_PORT_F :
{
UINT32 port_c = gizmondo->m_port[S3C2440_GPIO_PORT_C];
UINT32 port_c = m_port[S3C2440_GPIO_PORT_C];
data = data & ~0x000000F2;
// keys
data |= 0x00F2;
if ((port_c & 0x01) == 0) data &= ~gizmondo->ioport( "PORTF-01")->read();
if ((port_c & 0x02) == 0) data &= ~gizmondo->ioport( "PORTF-02")->read();
if ((port_c & 0x04) == 0) data &= ~gizmondo->ioport( "PORTF-04")->read();
if ((port_c & 0x08) == 0) data &= ~gizmondo->ioport( "PORTF-08")->read();
if ((port_c & 0x10) == 0) data &= ~gizmondo->ioport( "PORTF-10")->read();
data &= ~gizmondo->ioport( "PORTF")->read();
if ((port_c & 0x01) == 0) data &= ~ioport( "PORTF-01")->read();
if ((port_c & 0x02) == 0) data &= ~ioport( "PORTF-02")->read();
if ((port_c & 0x04) == 0) data &= ~ioport( "PORTF-04")->read();
if ((port_c & 0x08) == 0) data &= ~ioport( "PORTF-08")->read();
if ((port_c & 0x10) == 0) data &= ~ioport( "PORTF-10")->read();
data &= ~ioport( "PORTF")->read();
}
break;
case S3C2440_GPIO_PORT_G :
@ -107,7 +108,7 @@ static UINT32 s3c2440_gpio_port_r( device_t *device, int port, UINT32 mask)
data = data & ~0x00008001;
// keys
data = data | 0x8000;
data &= ~gizmondo->ioport( "PORTG")->read();
data &= ~ioport( "PORTG")->read();
// no sd card inserted
data = data | 0x0001;
}
@ -116,10 +117,9 @@ static UINT32 s3c2440_gpio_port_r( device_t *device, int port, UINT32 mask)
return data;
}
static void s3c2440_gpio_port_w( device_t *device, int port, UINT32 mask, UINT32 data)
WRITE32_MEMBER(gizmondo_state::s3c2440_gpio_port_w)
{
gizmondo_state *gizmondo = device->machine().driver_data<gizmondo_state>();
gizmondo->m_port[port] = data;
m_port[offset] = data;
}
INPUT_CHANGED_MEMBER(gizmondo_state::port_changed)
@ -178,17 +178,17 @@ DRIVER_INIT_MEMBER(gizmondo_state,gizmondo)
static S3C2440_INTERFACE( gizmondo_s3c2440_intf )
{
// CORE (pin read / pin write)
{ NULL, NULL },
{ DEVCB_NULL, DEVCB_NULL },
// GPIO (port read / port write)
{ s3c2440_gpio_port_r, s3c2440_gpio_port_w },
{ DEVCB_DRIVER_MEMBER32(gizmondo_state,s3c2440_gpio_port_r), DEVCB_DRIVER_MEMBER32(gizmondo_state,s3c2440_gpio_port_w) },
// I2C (scl write / sda read / sda write)
{ NULL, NULL, NULL },
{ DEVCB_NULL, DEVCB_NULL, DEVCB_NULL },
// ADC (data read)
{ NULL },
{ DEVCB_NULL },
// I2S (data write)
{ NULL },
{ DEVCB_NULL },
// NAND (command write / address write / data read / data write)
{ NULL, NULL, NULL, NULL },
{ DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL },
// LCD (flags)
{ 0 }
};

View File

@ -35,6 +35,8 @@ public:
virtual void machine_start();
virtual void machine_reset();
DECLARE_INPUT_CHANGED_MEMBER(port_changed);
DECLARE_READ32_MEMBER(s3c2410_gpio_port_r);
DECLARE_WRITE32_MEMBER(s3c2410_gpio_port_w);
inline void ATTR_PRINTF(3,4) verboselog( int n_level, const char *s_fmt, ...);
void lcd_spi_reset( );
void lcd_spi_init( );
@ -167,11 +169,10 @@ int hp49gp_state::lcd_spi_line_r( int line)
// I/O PORT
static UINT32 s3c2410_gpio_port_r( device_t *device, int port, UINT32 mask)
READ32_MEMBER(hp49gp_state::s3c2410_gpio_port_r)
{
hp49gp_state *hp49gp = device->machine().driver_data<hp49gp_state>();
UINT32 data = hp49gp->m_port[port];
switch (port)
UINT32 data = m_port[offset];
switch (offset)
{
case S3C2410_GPIO_PORT_C :
{
@ -182,9 +183,9 @@ static UINT32 s3c2410_gpio_port_r( device_t *device, int port, UINT32 mask)
{
data = data | 0x0008;
data = data & ~0x3200;
data |= (hp49gp->lcd_spi_line_r( LCD_SPI_LINE_1) ? 1 : 0) << 9;
data |= (hp49gp->lcd_spi_line_r( LCD_SPI_LINE_DATA) ? 1 : 0) << 12;
data |= (hp49gp->lcd_spi_line_r( LCD_SPI_LINE_3) ? 1 : 0) << 13;
data |= (lcd_spi_line_r( LCD_SPI_LINE_1) ? 1 : 0) << 9;
data |= (lcd_spi_line_r( LCD_SPI_LINE_DATA) ? 1 : 0) << 12;
data |= (lcd_spi_line_r( LCD_SPI_LINE_3) ? 1 : 0) << 13;
}
break;
case S3C2410_GPIO_PORT_E :
@ -200,13 +201,13 @@ static UINT32 s3c2410_gpio_port_r( device_t *device, int port, UINT32 mask)
case S3C2410_GPIO_PORT_G :
{
data = data & ~0xFF00;
if ((data & 0x02) == 0) data |= (hp49gp->ioport( "ROW1")->read() << 8);
if ((data & 0x04) == 0) data |= (hp49gp->ioport( "ROW2")->read() << 8);
if ((data & 0x08) == 0) data |= (hp49gp->ioport( "ROW3")->read() << 8);
if ((data & 0x10) == 0) data |= (hp49gp->ioport( "ROW4")->read() << 8);
if ((data & 0x20) == 0) data |= (hp49gp->ioport( "ROW5")->read() << 8);
if ((data & 0x40) == 0) data |= (hp49gp->ioport( "ROW6")->read() << 8);
if ((data & 0x80) == 0) data |= (hp49gp->ioport( "ROW7")->read() << 8);
if ((data & 0x02) == 0) data |= (ioport( "ROW1")->read() << 8);
if ((data & 0x04) == 0) data |= (ioport( "ROW2")->read() << 8);
if ((data & 0x08) == 0) data |= (ioport( "ROW3")->read() << 8);
if ((data & 0x10) == 0) data |= (ioport( "ROW4")->read() << 8);
if ((data & 0x20) == 0) data |= (ioport( "ROW5")->read() << 8);
if ((data & 0x40) == 0) data |= (ioport( "ROW6")->read() << 8);
if ((data & 0x80) == 0) data |= (ioport( "ROW7")->read() << 8);
}
break;
case S3C2410_GPIO_PORT_H :
@ -218,17 +219,16 @@ static UINT32 s3c2410_gpio_port_r( device_t *device, int port, UINT32 mask)
return data;
}
static void s3c2410_gpio_port_w( device_t *device, int port, UINT32 mask, UINT32 data)
WRITE32_MEMBER(hp49gp_state::s3c2410_gpio_port_w)
{
hp49gp_state *hp49gp = device->machine().driver_data<hp49gp_state>();
hp49gp->m_port[port] = data;
switch (port)
m_port[offset] = data;
switch (offset)
{
case S3C2410_GPIO_PORT_D :
{
hp49gp->lcd_spi_line_w( LCD_SPI_LINE_1, BIT( data, 9) ? 1 : 0);
hp49gp->lcd_spi_line_w( LCD_SPI_LINE_DATA, BIT( data, 12) ? 1 : 0);
hp49gp->lcd_spi_line_w( LCD_SPI_LINE_3, BIT( data, 13) ? 1 : 0);
lcd_spi_line_w( LCD_SPI_LINE_1, BIT( data, 9) ? 1 : 0);
lcd_spi_line_w( LCD_SPI_LINE_DATA, BIT( data, 12) ? 1 : 0);
lcd_spi_line_w( LCD_SPI_LINE_3, BIT( data, 13) ? 1 : 0);
}
break;
}
@ -279,17 +279,17 @@ DRIVER_INIT_MEMBER(hp49gp_state,hp49gp)
static S3C2410_INTERFACE( hp49gp_s3c2410_intf )
{
// CORE (pin read / pin write)
{ NULL, NULL },
{ DEVCB_NULL, DEVCB_NULL },
// GPIO (port read / port write)
{ s3c2410_gpio_port_r, s3c2410_gpio_port_w },
{ DEVCB_DRIVER_MEMBER32(hp49gp_state,s3c2410_gpio_port_r), DEVCB_DRIVER_MEMBER32(hp49gp_state,s3c2410_gpio_port_w) },
// I2C (scl write / sda read / sda write)
{ NULL, NULL, NULL },
{ DEVCB_NULL, DEVCB_NULL, DEVCB_NULL },
// ADC (data read)
{ NULL },
{DEVCB_NULL },
// I2S (data write)
{ NULL },
{ DEVCB_NULL },
// NAND (command write / address write / data read / data write)
{ NULL, NULL, NULL, NULL },
{ DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL },
// LCD (flags)
{ S3C24XX_INTERFACE_LCD_REVERSE }
};

View File

@ -52,6 +52,9 @@ public:
void smc_init( );
UINT8 smc_read( );
void smc_write( UINT8 data);
DECLARE_READ32_MEMBER(s3c44b0_gpio_port_r);
DECLARE_WRITE32_MEMBER(s3c44b0_gpio_port_w);
DECLARE_WRITE16_MEMBER(s3c44b0_i2s_data_w);
};
inline void ATTR_PRINTF(3,4) juicebox_state::verboselog( int n_level, const char *s_fmt, ...)
@ -128,11 +131,10 @@ void juicebox_state::smc_write( UINT8 data)
}
}
static UINT32 s3c44b0_gpio_port_r( device_t *device, int port)
READ32_MEMBER(juicebox_state::s3c44b0_gpio_port_r)
{
juicebox_state *juicebox = device->machine().driver_data<juicebox_state>();
UINT32 data = juicebox->port[port];
switch (port)
UINT32 data = port[offset];
switch (offset)
{
case S3C44B0_GPIO_PORT_A :
{
@ -168,22 +170,22 @@ static UINT32 s3c44b0_gpio_port_r( device_t *device, int port)
data = data | (0 << 7);
data = 0x0000009F;
data &= ~0xE0;
if (juicebox->smc.cmd_latch) data = data | 0x00000020;
if (juicebox->smc.add_latch) data = data | 0x00000040;
if (!juicebox->smc.busy) data = data | 0x00000080;
if (smc.cmd_latch) data = data | 0x00000020;
if (smc.add_latch) data = data | 0x00000040;
if (!smc.busy) data = data | 0x00000080;
}
break;
case S3C44B0_GPIO_PORT_G :
{
data = 0x0000009F;
data = (data & ~0x1F) | (juicebox->ioport( "PORTG")->read() & 0x1F);
data = (data & ~0x1F) | (ioport( "PORTG")->read() & 0x1F);
#if defined(JUICEBOX_ENTER_DEBUG_MENU)
if (juicebox->port_g_read_count++ < 1)
if (port_g_read_count++ < 1)
{
data = 0x00000095; // PLAY + REVERSE
}
#elif defined(JUICEBOX_DISPLAY_ROM_ID)
if (juicebox->port_g_read_count++ < 3)
if (port_g_read_count++ < 3)
{
data = 0x0000008A; // RETURN + FORWARD + STAR
}
@ -195,17 +197,16 @@ static UINT32 s3c44b0_gpio_port_r( device_t *device, int port)
return data;
}
static void s3c44b0_gpio_port_w( device_t *device, int port, UINT32 data)
WRITE32_MEMBER(juicebox_state::s3c44b0_gpio_port_w)
{
juicebox_state *juicebox = device->machine().driver_data<juicebox_state>();
juicebox->port[port] = data;
switch (port)
port[offset] = data;
switch (offset)
{
case S3C44B0_GPIO_PORT_F :
{
juicebox->smc.cmd_latch = ((data & 0x00000020) != 0);
juicebox->smc.add_latch = ((data & 0x00000040) != 0);
juicebox->verboselog( 5, "s3c44b0_gpio_port_w - nand cle %d ale %d\n", (data & 0x20) ? 1 : 0, (data & 0x40) ? 1 : 0);
smc.cmd_latch = ((data & 0x00000020) != 0);
smc.add_latch = ((data & 0x00000040) != 0);
verboselog( 5, "s3c44b0_gpio_port_w - nand cle %d ale %d\n", (data & 0x20) ? 1 : 0, (data & 0x40) ? 1 : 0);
}
break;
}
@ -235,10 +236,9 @@ WRITE32_MEMBER(juicebox_state::juicebox_nand_w)
// I2S
static WRITE16_DEVICE_HANDLER( s3c44b0_i2s_data_w )
WRITE16_MEMBER(juicebox_state::s3c44b0_i2s_data_w )
{
juicebox_state *juicebox = space.machine().driver_data<juicebox_state>();
juicebox->dac->write_signed16(data ^ 0x8000);
dac->write_signed16(data ^ 0x8000);
}
// ...
@ -285,13 +285,13 @@ DRIVER_INIT_MEMBER(juicebox_state,juicebox)
static S3C44B0_INTERFACE( juicebox_s3c44b0_intf )
{
// GPIO (port read / port write)
{ s3c44b0_gpio_port_r, s3c44b0_gpio_port_w },
{ DEVCB_DRIVER_MEMBER32(juicebox_state,s3c44b0_gpio_port_r), DEVCB_DRIVER_MEMBER32(juicebox_state,s3c44b0_gpio_port_w) },
// I2C (scl write / sda read / sda write)
{ NULL, NULL, NULL },
{ DEVCB_NULL, DEVCB_NULL, DEVCB_NULL },
// ADC (data read)
{ NULL },
{ DEVCB_NULL },
// I2S (data write)
{ s3c44b0_i2s_data_w }
{ DEVCB_DRIVER_MEMBER16(juicebox_state,s3c44b0_i2s_data_w) }
};
static MACHINE_CONFIG_START( juicebox, juicebox_state )

View File

@ -40,6 +40,16 @@ public:
virtual void machine_reset();
DECLARE_INPUT_CHANGED_MEMBER(mini2440_input_changed);
inline void ATTR_PRINTF(3,4) verboselog( int n_level, const char *s_fmt, ...);
DECLARE_READ32_MEMBER(s3c2440_gpio_port_r);
DECLARE_WRITE32_MEMBER(s3c2440_gpio_port_w);
DECLARE_READ32_MEMBER(s3c2440_core_pin_r);
DECLARE_WRITE8_MEMBER(s3c2440_nand_command_w );
DECLARE_WRITE8_MEMBER(s3c2440_nand_address_w );
DECLARE_READ8_MEMBER(s3c2440_nand_data_r );
DECLARE_WRITE8_MEMBER(s3c2440_nand_data_w );
DECLARE_WRITE16_MEMBER(s3c2440_i2s_data_w );
DECLARE_READ32_MEMBER(s3c2440_adc_data_r );
};
inline void ATTR_PRINTF(3,4) mini2440_state::verboselog( int n_level, const char *s_fmt, ...)
@ -61,11 +71,10 @@ inline void ATTR_PRINTF(3,4) mini2440_state::verboselog( int n_level, const char
// GPIO
static UINT32 s3c2440_gpio_port_r( device_t *device, int port, UINT32 mask)
READ32_MEMBER(mini2440_state::s3c2440_gpio_port_r)
{
mini2440_state *state = device->machine().driver_data<mini2440_state>();
UINT32 data = state->m_port[port];
switch (port)
UINT32 data = m_port[offset];
switch (offset)
{
case S3C2440_GPIO_PORT_G :
{
@ -79,15 +88,14 @@ static UINT32 s3c2440_gpio_port_r( device_t *device, int port, UINT32 mask)
return data;
}
static void s3c2440_gpio_port_w( device_t *device, int port, UINT32 mask, UINT32 data)
WRITE32_MEMBER(mini2440_state::s3c2440_gpio_port_w)
{
mini2440_state *state = device->machine().driver_data<mini2440_state>();
state->m_port[port] = data;
switch (port)
m_port[offset] = data;
switch (offset)
{
case S3C2440_GPIO_PORT_B :
{
state->verboselog(5, "LED %d %d %d %d\n", BIT( data, 5), BIT( data, 6), BIT( data, 7), BIT( data, 8));
verboselog(5, "LED %d %d %d %d\n", BIT( data, 5), BIT( data, 6), BIT( data, 7), BIT( data, 8));
}
break;
}
@ -105,10 +113,10 @@ NCON: NAND flash memory selection (Normal / Advance)
*/
static int s3c2440_core_pin_r( device_t *device, int pin)
READ32_MEMBER(mini2440_state::s3c2440_core_pin_r)
{
int data = 0;
switch (pin)
switch (offset)
{
case S3C2440_CORE_PIN_NCON : data = 1; break;
case S3C2440_CORE_PIN_OM0 : data = 0; break;
@ -119,54 +127,47 @@ static int s3c2440_core_pin_r( device_t *device, int pin)
// NAND
static WRITE8_DEVICE_HANDLER( s3c2440_nand_command_w )
WRITE8_MEMBER(mini2440_state::s3c2440_nand_command_w )
{
mini2440_state *state = space.machine().driver_data<mini2440_state>();
state->m_nand->command_w(data);
m_nand->command_w(data);
}
static WRITE8_DEVICE_HANDLER( s3c2440_nand_address_w )
WRITE8_MEMBER(mini2440_state::s3c2440_nand_address_w )
{
mini2440_state *state = space.machine().driver_data<mini2440_state>();
state->m_nand->address_w(data);
m_nand->address_w(data);
}
static READ8_DEVICE_HANDLER( s3c2440_nand_data_r )
READ8_MEMBER(mini2440_state::s3c2440_nand_data_r )
{
mini2440_state *state = space.machine().driver_data<mini2440_state>();
return state->m_nand->data_r();
return m_nand->data_r();
}
static WRITE8_DEVICE_HANDLER( s3c2440_nand_data_w )
WRITE8_MEMBER(mini2440_state::s3c2440_nand_data_w )
{
mini2440_state *state = space.machine().driver_data<mini2440_state>();
state->m_nand->data_w(data);
m_nand->data_w(data);
}
// I2S
static WRITE16_DEVICE_HANDLER( s3c2440_i2s_data_w )
WRITE16_MEMBER(mini2440_state::s3c2440_i2s_data_w )
{
mini2440_state *state = space.machine().driver_data<mini2440_state>();
if ( offset )
state->m_dac1->write_signed16(data + 0x8000);
m_dac1->write_signed16(data + 0x8000);
else
state->m_dac2->write_signed16(data + 0x8000);
m_dac2->write_signed16(data + 0x8000);
}
// ADC
static READ32_DEVICE_HANDLER( s3c2440_adc_data_r )
READ32_MEMBER(mini2440_state::s3c2440_adc_data_r )
{
mini2440_state *state = space.machine().driver_data<mini2440_state>();
UINT32 data = 0;
switch (offset)
{
case 2 + 0 : data = state->m_penx->read(); break;
case 2 + 1 : data = 915 - state->m_peny->read() + 90; break;
case 2 + 0 : data = m_penx->read(); break;
case 2 + 1 : data = 915 - m_peny->read() + 90; break;
}
state->verboselog(5, "s3c2440_adc_data_r %08X\n", data);
verboselog(5, "s3c2440_adc_data_r %08X\n", data);
return data;
}
@ -211,17 +212,17 @@ DRIVER_INIT_MEMBER(mini2440_state,mini2440)
static S3C2440_INTERFACE( mini2440_s3c2440_intf )
{
// CORE (pin read / pin write)
{ s3c2440_core_pin_r, NULL },
{ DEVCB_DRIVER_MEMBER32(mini2440_state,s3c2440_core_pin_r), DEVCB_NULL },
// GPIO (port read / port write)
{ s3c2440_gpio_port_r, s3c2440_gpio_port_w },
{ DEVCB_DRIVER_MEMBER32(mini2440_state,s3c2440_gpio_port_r), DEVCB_DRIVER_MEMBER32(mini2440_state,s3c2440_gpio_port_w) },
// I2C (scl write / sda read / sda write)
{ NULL, NULL, NULL },
{ DEVCB_NULL, DEVCB_NULL, DEVCB_NULL },
// ADC (data read)
{ s3c2440_adc_data_r },
{ DEVCB_DRIVER_MEMBER32(mini2440_state,s3c2440_adc_data_r) },
// I2S (data write)
{ s3c2440_i2s_data_w },
{ DEVCB_DRIVER_MEMBER16(mini2440_state,s3c2440_i2s_data_w) },
// NAND (command write / address write / data read / data write)
{ s3c2440_nand_command_w, s3c2440_nand_address_w, s3c2440_nand_data_r, s3c2440_nand_data_w }
{ DEVCB_DRIVER_MEMBER(mini2440_state,s3c2440_nand_command_w), DEVCB_DRIVER_MEMBER(mini2440_state,s3c2440_nand_address_w), DEVCB_DRIVER_MEMBER(mini2440_state,s3c2440_nand_data_r), DEVCB_DRIVER_MEMBER(mini2440_state,s3c2440_nand_data_w) }
};
static NAND_INTERFACE( mini2440_nand_intf )

View File

@ -90,6 +90,15 @@ public:
virtual void machine_reset();
DECLARE_INPUT_CHANGED_MEMBER(palmz22_input_changed);
inline void ATTR_PRINTF(3,4) verboselog( int n_level, const char *s_fmt, ...);
DECLARE_WRITE8_MEMBER( s3c2410_nand_command_w );
DECLARE_WRITE8_MEMBER( s3c2410_nand_address_w );
DECLARE_READ8_MEMBER( s3c2410_nand_data_r );
DECLARE_WRITE8_MEMBER( s3c2410_nand_data_w );
DECLARE_READ32_MEMBER(s3c2410_gpio_port_r);
DECLARE_WRITE32_MEMBER(s3c2410_gpio_port_w);
DECLARE_READ32_MEMBER(s3c2410_core_pin_r);
DECLARE_READ32_MEMBER(s3c2410_adc_data_r );
};
@ -112,50 +121,46 @@ inline void ATTR_PRINTF(3,4) palmz22_state::verboselog( int n_level, const char
// NAND
static WRITE8_DEVICE_HANDLER( s3c2410_nand_command_w )
WRITE8_MEMBER( palmz22_state::s3c2410_nand_command_w )
{
palmz22_state *state = space.machine().driver_data<palmz22_state>();
state->verboselog(9, "s3c2410_nand_command_w %02X\n", data);
state->m_nand->command_w(data);
verboselog(9, "s3c2410_nand_command_w %02X\n", data);
m_nand->command_w(data);
}
static WRITE8_DEVICE_HANDLER( s3c2410_nand_address_w )
WRITE8_MEMBER( palmz22_state::s3c2410_nand_address_w )
{
palmz22_state *state = space.machine().driver_data<palmz22_state>();
state->verboselog(9, "s3c2410_nand_address_w %02X\n", data);
state->m_nand->address_w(data);
verboselog(9, "s3c2410_nand_address_w %02X\n", data);
m_nand->address_w(data);
}
static READ8_DEVICE_HANDLER( s3c2410_nand_data_r )
READ8_MEMBER( palmz22_state::s3c2410_nand_data_r )
{
palmz22_state *state = space.machine().driver_data<palmz22_state>();
UINT8 data = state->m_nand->data_r();
state->verboselog(9, "s3c2410_nand_data_r %02X\n", data);
UINT8 data = m_nand->data_r();
verboselog(9, "s3c2410_nand_data_r %02X\n", data);
return data;
}
static WRITE8_DEVICE_HANDLER( s3c2410_nand_data_w )
WRITE8_MEMBER( palmz22_state::s3c2410_nand_data_w )
{
palmz22_state *state = space.machine().driver_data<palmz22_state>();
state->verboselog(9, "s3c2410_nand_data_w %02X\n", data);
state->m_nand->data_w(data);
verboselog(9, "s3c2410_nand_data_w %02X\n", data);
m_nand->data_w(data);
}
ATTR_UNUSED static READ8_DEVICE_HANDLER( s3c2410_nand_busy_r )
/*
READ8_MEMBER( palmz22_state::s3c2410_nand_busy_r )
{
palmz22_state *state = device->machine().driver_data<palmz22_state>();
UINT8 data = state->m_nand->is_busy();
state->verboselog(9, "s3c2410_nand_busy_r %02X\n", data);
UINT8 data = m_nand->is_busy();
verboselog(9, "s3c2410_nand_busy_r %02X\n", data);
return data;
}
*/
// GPIO
static UINT32 s3c2410_gpio_port_r( device_t *device, int port, UINT32 mask)
READ32_MEMBER(palmz22_state::s3c2410_gpio_port_r)
{
palmz22_state *state = device->machine().driver_data<palmz22_state>();
UINT32 data = state->m_port[port];
switch (port)
UINT32 data = m_port[offset];
switch (offset)
{
case S3C2410_GPIO_PORT_E :
{
@ -165,7 +170,7 @@ static UINT32 s3c2410_gpio_port_r( device_t *device, int port, UINT32 mask)
break;
case S3C2410_GPIO_PORT_F :
{
data = (data & ~0xFF) | (state->ioport( "PORT-F")->read() & 0xFF);
data = (data & ~0xFF) | (ioport( "PORT-F")->read() & 0xFF);
}
break;
case S3C2410_GPIO_PORT_G :
@ -178,10 +183,9 @@ static UINT32 s3c2410_gpio_port_r( device_t *device, int port, UINT32 mask)
return data;
}
static void s3c2410_gpio_port_w( device_t *device, int port, UINT32 mask, UINT32 data)
WRITE32_MEMBER(palmz22_state::s3c2410_gpio_port_w)
{
palmz22_state *state = device->machine().driver_data<palmz22_state>();
state->m_port[port] = data;
m_port[offset] = data;
}
// CORE
@ -198,10 +202,10 @@ NCON : NAND flash memory address step selection
*/
static int s3c2410_core_pin_r( device_t *device, int pin)
READ32_MEMBER(palmz22_state::s3c2410_core_pin_r)
{
int data = 0;
switch (pin)
switch (offset)
{
case S3C2410_CORE_PIN_NCON : data = 0; break;
case S3C2410_CORE_PIN_OM0 : data = 0; break;
@ -212,18 +216,17 @@ static int s3c2410_core_pin_r( device_t *device, int pin)
// ADC
static READ32_DEVICE_HANDLER( s3c2410_adc_data_r )
READ32_MEMBER(palmz22_state::s3c2410_adc_data_r )
{
palmz22_state *state = device->machine().driver_data<palmz22_state>();
UINT32 data = 0;
switch (offset)
{
case 0 + 0 : data = 0x2EE + (PALM_Z22_BATTERY_LEVEL * 0xFF / 100); break;
case 0 + 1 : data = 0; break;
case 2 + 0 : data = state->ioport( "PENX")->read(); break;
case 2 + 1 : data = 0x3FF - state->ioport( "PENY")->read(); break;
case 2 + 0 : data = ioport( "PENX")->read(); break;
case 2 + 1 : data = 0x3FF - ioport( "PENY")->read(); break;
}
state->verboselog(5, "s3c2410_adc_data_r %08X\n", data);
verboselog(5, "s3c2410_adc_data_r %08X\n", data);
return data;
}
@ -275,17 +278,17 @@ DRIVER_INIT_MEMBER(palmz22_state,palmz22)
static S3C2410_INTERFACE( palmz22_s3c2410_intf )
{
// CORE (pin read / pin write)
{ s3c2410_core_pin_r, NULL },
{ DEVCB_DRIVER_MEMBER32(palmz22_state,s3c2410_core_pin_r), DEVCB_NULL },
// GPIO (port read / port write)
{ s3c2410_gpio_port_r, s3c2410_gpio_port_w },
{ DEVCB_DRIVER_MEMBER32(palmz22_state,s3c2410_gpio_port_r), DEVCB_DRIVER_MEMBER32(palmz22_state,s3c2410_gpio_port_w)},
// I2C (scl write / sda read / sda write)
{ NULL, NULL, NULL },
{ DEVCB_NULL, DEVCB_NULL, DEVCB_NULL },
// ADC (data read)
{ s3c2410_adc_data_r },
{ DEVCB_DRIVER_MEMBER32(palmz22_state,s3c2410_adc_data_r) },
// I2S (data write)
{ NULL },
{ DEVCB_NULL },
// NAND (command write / address write / data read / data write)
{ s3c2410_nand_command_w, s3c2410_nand_address_w, s3c2410_nand_data_r, s3c2410_nand_data_w },
{ DEVCB_DRIVER_MEMBER(palmz22_state,s3c2410_nand_command_w), DEVCB_DRIVER_MEMBER(palmz22_state,s3c2410_nand_address_w), DEVCB_DRIVER_MEMBER(palmz22_state,s3c2410_nand_data_r), DEVCB_DRIVER_MEMBER(palmz22_state,s3c2410_nand_data_w) },
// LCD (flags)
{ 0 }
};

View File

@ -875,27 +875,27 @@ static TIMER_CALLBACK( s3c44b0_pwm_timer_exp )
INLINE void iface_i2c_scl_w( device_t *device, int state)
{
s3c44b0_t *s3c44b0 = get_token( device);
if (s3c44b0->iface->i2c.scl_w)
if (!s3c44b0->scl_w.isnull())
{
(s3c44b0->iface->i2c.scl_w)( device, state);
(s3c44b0->scl_w)( state);
}
}
INLINE void iface_i2c_sda_w( device_t *device, int state)
{
s3c44b0_t *s3c44b0 = get_token( device);
if (s3c44b0->iface->i2c.sda_w)
if (!s3c44b0->sda_w.isnull())
{
(s3c44b0->iface->i2c.sda_w)( device, state);
(s3c44b0->sda_w)( state);
}
}
INLINE int iface_i2c_sda_r( device_t *device)
{
s3c44b0_t *s3c44b0 = get_token( device);
if (s3c44b0->iface->i2c.sda_r)
if (!s3c44b0->sda_r.isnull())
{
return (s3c44b0->iface->i2c.sda_r)( device);
return (s3c44b0->sda_r)();
}
else
{
@ -1115,9 +1115,9 @@ static TIMER_CALLBACK( s3c44b0_iic_timer_exp )
INLINE UINT32 iface_gpio_port_r( device_t *device, int port)
{
s3c44b0_t *s3c44b0 = get_token( device);
if (s3c44b0->iface->gpio.port_r)
if (!s3c44b0->port_r.isnull())
{
return (s3c44b0->iface->gpio.port_r)( device, port);
return (s3c44b0->port_r)(port);
}
else
{
@ -1128,9 +1128,9 @@ INLINE UINT32 iface_gpio_port_r( device_t *device, int port)
INLINE void iface_gpio_port_w( device_t *device, int port, UINT32 data)
{
s3c44b0_t *s3c44b0 = get_token( device);
if (s3c44b0->iface->gpio.port_w)
if (!s3c44b0->port_w.isnull())
{
(s3c44b0->iface->gpio.port_w)( device, port, data);
(s3c44b0->port_w)( port, data);
}
}
@ -1604,9 +1604,9 @@ static TIMER_CALLBACK( s3c44b0_sio_timer_exp )
INLINE void iface_i2s_data_w( device_t *device, address_space &space, int ch, UINT16 data)
{
s3c44b0_t *s3c44b0 = get_token( device);
if (s3c44b0->iface->i2s.data_w)
if (!s3c44b0->i2s_data_w.isnull())
{
(s3c44b0->iface->i2s.data_w)( device, space, ch, data, 0);
(s3c44b0->i2s_data_w)( ch, data, 0);
}
}
@ -2004,6 +2004,15 @@ DEVICE_START( s3c44b0 )
address_space &space = machine.device( "maincpu")->memory().space( AS_PROGRAM);
s3c44b0_t *s3c44b0 = get_token( device);
s3c44b0->iface = (const s3c44b0_interface *)device->static_config();
s3c44b0->port_r.resolve(s3c44b0->iface->gpio.port_r, *device);
s3c44b0->port_w.resolve(s3c44b0->iface->gpio.port_w, *device);
s3c44b0->scl_w.resolve(s3c44b0->iface->i2c.scl_w, *device);
s3c44b0->sda_r.resolve(s3c44b0->iface->i2c.sda_r, *device);
s3c44b0->sda_w.resolve(s3c44b0->iface->i2c.sda_w, *device);
s3c44b0->adc_data_r.resolve(s3c44b0->iface->adc.data_r, *device);
s3c44b0->i2s_data_w.resolve(s3c44b0->iface->i2s.data_w, *device);
s3c44b0->space = &space;
s3c44b0->cpu = downcast<cpu_device *>(device->machine().device( "maincpu"));
for (int i = 0; i < 6; i++) s3c44b0->pwm.timer[i] = machine.scheduler().timer_alloc(FUNC(s3c44b0_pwm_timer_exp), (void*)device);

View File

@ -60,30 +60,27 @@ extern const device_type S3C44B0;
TYPE DEFINITIONS
*******************************************************************************/
typedef UINT32 (*s3c44b0_gpio_port_r_func)( device_t *device, int port);
typedef void (*s3c44b0_gpio_port_w_func)( device_t *device, int port, UINT32 data);
struct s3c44b0_interface_gpio
{
s3c44b0_gpio_port_r_func port_r;
s3c44b0_gpio_port_w_func port_w;
devcb_read32 port_r;
devcb_write32 port_w;
};
struct s3c44b0_interface_i2c
{
write_line_device_func scl_w;
read_line_device_func sda_r;
write_line_device_func sda_w;
devcb_write_line scl_w;
devcb_read_line sda_r;
devcb_write_line sda_w;
};
struct s3c44b0_interface_adc
{
read32_device_func data_r;
devcb_read32 data_r;
};
struct s3c44b0_interface_i2s
{
write16_device_func data_w;
devcb_write16 data_w;
};
struct s3c44b0_interface
@ -695,6 +692,13 @@ struct s3c44b0_t
s3c44b0_rtc_t rtc;
s3c44b0_adc_t adc;
s3c44b0_cpuwrap_t cpuwrap;
devcb_resolved_read32 port_r;
devcb_resolved_write32 port_w;
devcb_resolved_write_line scl_w;
devcb_resolved_read_line sda_r;
devcb_resolved_write_line sda_w;
devcb_resolved_read32 adc_data_r;
devcb_resolved_write16 i2s_data_w;
};
#endif