Previous 15994 Revisions Next

r6680 Wednesday 16th December, 2009 at 18:08:38 UTC by Tim Schuerewegen
[GP32] Added PWM timer DMA request mode.
[src/mess/drivers]gp32.c

src/mess/drivers/gp32.c
r6679r6680
4040
4141#define CLOCK_MULTIPLIER 1
4242
43#define MPLLCON  1
44#define UPLLCON  2
45
4346#define BIT(x,n) (((x)>>(n))&1)
4447#define BITS(x,m,n) (((x)>>(n))&((1<<((m)-(n)+1))-1))
4548
46#define MPLLCON  1
47#define UPLLCON  2
48
4949static UINT32 *s3c240x_ram;
5050static UINT8 *eeprom_data;
5151
52static UINT32 s3c240x_get_fclk( int reg);
5253static UINT32 s3c240x_get_hclk( int reg);
54static UINT32 s3c240x_get_pclk( int reg);
5355
56static void s3c240x_dma_request_iis( running_machine *machine);
57static void s3c240x_dma_request_pwm( running_machine *machine);
58
5459// LCD CONTROLLER
5560
5661static UINT32 s3c240x_lcd_regs[0x400/4];
r6679r6680
7580#define BPPMODE_TFT_08   0x0B
7681#define BPPMODE_TFT_16   0x0C
7782
78//             76543210 76543210 76543210 76543210
79// 5551 16-bit 00000000 00000000 RRRRRGGG GGBBBBB0
80// 5551 32-bit 00000000 RRRRRI00 GGGGGI00 BBBBBI00
81// 565  16-bit 00000000 00000000 RRRRRGGG GGBBBBB0
82// 565  32-bit 00000000 RRRRR000 GGGGG000 BBBBB000
83
8483static void s3c240x_lcd_dma_reload( running_machine *machine)
8584{
8685   s3c240x_lcd.vramaddr_cur = s3c240x_lcd_regs[5] << 1;
r6679r6680
498497static void s3c240x_request_irq( running_machine *machine, UINT32 int_type)
499498{
500499   verboselog( machine, 5, "request irq %d\n", int_type);
501   verboselog( machine, 5, "(1) %08X %08X %08X %08X %08X %08X\n", s3c240x_irq_regs[0], s3c240x_irq_regs[1], s3c240x_irq_regs[2], s3c240x_irq_regs[3], s3c240x_irq_regs[4], s3c240x_irq_regs[5]);
502500   if (s3c240x_irq_regs[0] == 0)
503501   {
504502      s3c240x_irq_regs[0] |= (1 << int_type); // SRCPND
r6679r6680
534532      case 0x00 / 4 :
535533      {
536534         s3c240x_irq_regs[0] = (old_value & ~data); // clear only the bit positions of SRCPND corresponding to those set to one in the data
537         verboselog( machine, 5, "(2) %08X %08X %08X %08X %08X %08X\n", s3c240x_irq_regs[0], s3c240x_irq_regs[1], s3c240x_irq_regs[2], s3c240x_irq_regs[3], s3c240x_irq_regs[4], s3c240x_irq_regs[5]);
538535         s3c240x_check_pending_irq( machine);
539536      }
540537      break;
r6679r6680
542539      case 0x10 / 4 :
543540      {
544541         s3c240x_irq_regs[4] = (old_value & ~data); // clear only the bit positions of INTPND corresponding to those set to one in the data
545         verboselog( machine, 5, "(3) %08X %08X %08X %08X %08X %08X\n", s3c240x_irq_regs[0], s3c240x_irq_regs[1], s3c240x_irq_regs[2], s3c240x_irq_regs[3], s3c240x_irq_regs[4], s3c240x_irq_regs[5]);
546542      }
547543      break;
548544   }
r6679r6680
680676   int ch = param;
681677   const int ch_int[] = { INT_TIMER0, INT_TIMER1, INT_TIMER2, INT_TIMER3, INT_TIMER4 };
682678   verboselog( machine, 2, "PWM %d timer callback\n", ch);
683   s3c240x_request_irq( machine, ch_int[ch]);
679   if (BITS( s3c240x_pwm_regs[1], 23, 20) == (ch + 1))
680   {
681      s3c240x_dma_request_pwm( machine);
682   }
683   else
684   {
685      s3c240x_request_irq( machine, ch_int[ch]);
686   }
684687}
685688
686689// DMA
r6679r6680
700703{
701704   UINT32 *regs = &s3c240x_dma_regs[dma<<3];
702705   UINT32 curr_tc, curr_src, curr_dst;
703  const address_space *space = cputag_get_address_space( machine, "maincpu", ADDRESS_SPACE_PROGRAM);
706   const address_space *space = cputag_get_address_space( machine, "maincpu", ADDRESS_SPACE_PROGRAM);
704707   int dsz, inc_src, inc_dst, servmode;
705708   const UINT32 ch_int[] = { INT_DMA0, INT_DMA1, INT_DMA2, INT_DMA3};
706709   verboselog( machine, 5, "DMA %d trigger\n", dma);
r6679r6680
752755   }
753756}
754757
758static void s3c240x_dma_request_iis( running_machine *machine)
759{
760   UINT32 *regs = &s3c240x_dma_regs[2<<3];
761   verboselog( machine, 5, "s3c240x_dma_request_iis\n");
762   if ((BIT( regs[6], 1) != 0) && (BIT( regs[2], 23) != 0) && (BITS( regs[2], 25, 24) == 0))
763   {
764      s3c240x_dma_trigger( machine, 2);
765   }
766}
767
768static void s3c240x_dma_request_pwm( running_machine *machine)
769{
770   int i;
771   verboselog( machine, 5, "s3c240x_dma_request_pwm\n");
772   for (i = 0; i < 4; i++)
773   {
774      if (i != 1)
775      {
776         UINT32 *regs = &s3c240x_dma_regs[i<<3];
777         if ((BIT( regs[6], 1) != 0) && (BIT( regs[2], 23) != 0) && (BITS( regs[2], 25, 24) == 3))
778         {
779            s3c240x_dma_trigger( machine, i);
780         }
781      }
782   }
783}
784
755785static void s3c240x_dma_start( running_machine *machine, int dma)
756786{
757787   UINT32 addr_src, addr_dst, tc;
r6679r6680
10891119static WRITE32_HANDLER( s3c240x_gpio_w )
10901120{
10911121   running_machine *machine = space->machine;
1092//  UINT32 old_value = s3c240x_gpio_regs[offset];
10931122   COMBINE_DATA(&s3c240x_gpio[offset]);
10941123   verboselog( machine, 9, "(GPIO) %08X <- %08X (PC %08X)\n", 0x15600000 + (offset << 2), data, cpu_get_pc( space->cpu));
10951124   switch (offset)
r6679r6680
11251154         // smartmedia
11261155         smc.cmd_latch = ((data & 0x00000020) != 0);
11271156         smc.add_latch = ((data & 0x00000010) != 0);
1128         smc.do_write = ((data & 0x00000008) == 0);
1157         smc.do_write = ((data & 0x00000008) == 0);
11291158         smc_update( machine);
11301159         // sound
11311160         i2s_write( machine, I2S_L3D, (data & 0x00000800) ? 1 : 0);
r6679r6680
11331162         i2s_write( machine, I2S_L3C, (data & 0x00000200) ? 1 : 0);
11341163      }
11351164      break;
1136/*
1137        // PGDAT
1138        case 0x48 / 4 :
1139        {
1140            int i2ssdo;
1141            i2ssdo = BIT( data, 3);
1142        }
1143        break;
1144*/
1165#if 0
1166      // PGDAT
1167      case 0x48 / 4 :
1168      {
1169         int i2ssdo;
1170         i2ssdo = BIT( data, 3);
1171      }
1172      break;
1173#endif
11451174   }
11461175}
11471176
r6679r6680
13051334static emu_timer *s3c240x_iic_timer;
13061335static UINT32 s3c240x_iic_regs[0x10/4];
13071336
1308/*
1337#if 0
13091338static UINT8 i2cmem_read_byte( running_machine *machine, int last)
13101339{
1311    UINT8 data = 0;
1312    int i;
1313    i2cmem_write( machine, 0, I2CMEM_SDA, 1);
1314    for (i = 0; i < 8; i++)
1315    {
1316        i2cmem_write( machine, 0, I2CMEM_SCL, 1);
1317    data = (data << 1) + (i2cmem_read( machine, 0, I2CMEM_SDA) ? 1 : 0);
1318        i2cmem_write( machine, 0, I2CMEM_SCL, 0);
1319    }
1320    i2cmem_write( machine, 0, I2CMEM_SDA, last);
1321    i2cmem_write( machine, 0, I2CMEM_SCL, 1);
1322    i2cmem_write( machine, 0, I2CMEM_SCL, 0);
1323    return data;
1340   UINT8 data = 0;
1341   int i;
1342   i2cmem_write( machine, 0, I2CMEM_SDA, 1);
1343   for (i = 0; i < 8; i++)
1344   {
1345      i2cmem_write( machine, 0, I2CMEM_SCL, 1);
1346      data = (data << 1) + (i2cmem_read( machine, 0, I2CMEM_SDA) ? 1 : 0);
1347      i2cmem_write( machine, 0, I2CMEM_SCL, 0);
1348   }
1349   i2cmem_write( machine, 0, I2CMEM_SDA, last);
1350   i2cmem_write( machine, 0, I2CMEM_SCL, 1);
1351   i2cmem_write( machine, 0, I2CMEM_SCL, 0);
1352   return data;
13241353}
1325*/
1354#endif
13261355
1327/*
1356#if 0
13281357static void i2cmem_write_byte( running_machine *machine, UINT8 data)
13291358{
1330    int i;
1331    for (i = 0; i < 8; i++)
1332    {
1333        i2cmem_write( machine, 0, I2CMEM_SDA, (data & 0x80) ? 1 : 0);
1334        data = data << 1;
1335        i2cmem_write( machine, 0, I2CMEM_SCL, 1);
1336        i2cmem_write( machine, 0, I2CMEM_SCL, 0);
1337    }
1338    i2cmem_write( machine, 0, I2CMEM_SDA, 1); // ack bit
1339    i2cmem_write( machine, 0, I2CMEM_SCL, 1);
1340    i2cmem_write( machine, 0, I2CMEM_SCL, 0);
1359   int i;
1360   for (i = 0; i < 8; i++)
1361   {
1362      i2cmem_write( machine, 0, I2CMEM_SDA, (data & 0x80) ? 1 : 0);
1363      data = data << 1;
1364      i2cmem_write( machine, 0, I2CMEM_SCL, 1);
1365      i2cmem_write( machine, 0, I2CMEM_SCL, 0);
1366   }
1367   i2cmem_write( machine, 0, I2CMEM_SDA, 1); // ack bit
1368   i2cmem_write( machine, 0, I2CMEM_SCL, 1);
1369   i2cmem_write( machine, 0, I2CMEM_SCL, 0);
13411370}
1342*/
1371#endif
13431372
1344/*
1373#if 0
13451374static void i2cmem_start( running_machine *machine)
13461375{
1347    i2cmem_write( machine, 0, I2CMEM_SDA, 1);
1348    i2cmem_write( machine, 0, I2CMEM_SCL, 1);
1349    i2cmem_write( machine, 0, I2CMEM_SDA, 0);
1350    i2cmem_write( machine, 0, I2CMEM_SCL, 0);
1376   i2cmem_write( machine, 0, I2CMEM_SDA, 1);
1377   i2cmem_write( machine, 0, I2CMEM_SCL, 1);
1378   i2cmem_write( machine, 0, I2CMEM_SDA, 0);
1379   i2cmem_write( machine, 0, I2CMEM_SCL, 0);
13511380}
1352*/
1381#endif
13531382
1354/*
1383#if 0
13551384static void i2cmem_stop( running_machine *machine)
13561385{
1357    i2cmem_write( machine, 0, I2CMEM_SDA, 0);
1358    i2cmem_write( machine, 0, I2CMEM_SCL, 1);
1359    i2cmem_write( machine, 0, I2CMEM_SDA, 1);
1360    i2cmem_write( machine, 0, I2CMEM_SCL, 0);
1386   i2cmem_write( machine, 0, I2CMEM_SDA, 0);
1387   i2cmem_write( machine, 0, I2CMEM_SCL, 1);
1388   i2cmem_write( machine, 0, I2CMEM_SDA, 1);
1389   i2cmem_write( machine, 0, I2CMEM_SCL, 0);
13611390}
1362*/
1391#endif
13631392
13641393static void iic_start( running_machine *machine)
13651394{
r6679r6680
14081437      case 0x00 / 4 :
14091438      {
14101439         int interrupt_pending_flag;
1411//          const int div_table[] = { 16, 512};
1412//          int enable_interrupt, transmit_clock_value, tx_clock_source_selection
1413//          double clock;
1414//          transmit_clock_value = (data >> 0) & 0xF;
1415//          tx_clock_source_selection = (data >> 6) & 1;
1416//          enable_interrupt = (data >> 5) & 1;
1417//          clock = (double)(s3c240x_get_pclk( MPLLCON) / div_table[tx_clock_source_selection] / (transmit_clock_value + 1));
1440#if 0
1441         const int div_table[] = { 16, 512};
1442         int enable_interrupt, transmit_clock_value, tx_clock_source_selection
1443         double clock;
1444         transmit_clock_value = (data >> 0) & 0xF;
1445         tx_clock_source_selection = (data >> 6) & 1;
1446         enable_interrupt = (data >> 5) & 1;
1447         clock = (double)(s3c240x_get_pclk( MPLLCON) / div_table[tx_clock_source_selection] / (transmit_clock_value + 1));
1448#endif
14181449         interrupt_pending_flag = BIT( data, 4);
14191450         if (interrupt_pending_flag == 0)
14201451         {
r6679r6680
15411572{
15421573   running_machine *machine = space->machine;
15431574   UINT32 data = s3c240x_iis_regs[offset];
1544/*
1545    switch (offset)
1546    {
1547        // IISCON
1548        case 0x00 / 4 :
1549        {
1550            //data = data & ~1; // for mp3 player
1551        }
1552        break;
1553    }
1554*/
1575#if 0
1576   switch (offset)
1577   {
1578      // IISCON
1579      case 0x00 / 4 :
1580      {
1581         data = data & ~1; // for mp3 player
1582      }
1583      break;
1584   }
1585#endif
15551586   verboselog( machine, 9, "(IIS) %08X -> %08X (PC %08X)\n", 0x15508000 + (offset << 2), data, cpu_get_pc( space->cpu));
15561587   return data;
15571588}
r6679r6680
15871618            dac[0] = devtag_get_device( machine, "dac1");
15881619            dac[1] = devtag_get_device( machine, "dac2");
15891620            s3c240x_iis.fifo_index = 0;
1590          dac_signed_data_16_w( dac[0], s3c240x_iis.fifo[0] + 0x8000);
1591          dac_signed_data_16_w( dac[1], s3c240x_iis.fifo[1] + 0x8000);
1621            dac_signed_data_16_w( dac[0], s3c240x_iis.fifo[0] + 0x8000);
1622            dac_signed_data_16_w( dac[1], s3c240x_iis.fifo[1] + 0x8000);
15921623         }
15931624      }
15941625      break;
r6679r6680
15971628
15981629static TIMER_CALLBACK( s3c240x_iis_timer_exp )
15991630{
1600   UINT32 dcon;
1601   int hwsrcsel, swhwsel;
16021631   verboselog( machine, 2, "IIS timer callback\n");
1603   dcon = s3c240x_dma_regs[0x48/4];
1604   hwsrcsel = BITS( dcon, 25, 24);
1605   swhwsel = BIT( dcon, 23);
1606   if ((swhwsel == 1) && (hwsrcsel == 0))
1607   {
1608      UINT32 dmasktrig;
1609      int on_off;
1610      dmasktrig = s3c240x_dma_regs[0x58/4];
1611      on_off = BIT( dmasktrig, 1);
1612      if (on_off)
1613      {
1614         s3c240x_dma_trigger( machine, 2);
1615      }
1616   }
1632   s3c240x_dma_request_iis( machine);
16171633}
16181634
16191635// RTC
r6679r6680
18361852   ROMX_LOAD( "gp32166m.bin", 0x000000, 0x080000, CRC(4548a840) SHA1(1ad0cab0af28fb45c182e5e8c87ead2aaa4fffe1), ROM_BIOS(4) )
18371853   ROM_SYSTEM_BIOS( 4, "mfv2", "Mr. Spiv Multi Firmware V2" )
18381854   ROMX_LOAD( "gp32mfv2.bin", 0x000000, 0x080000, CRC(7ddaaaeb) SHA1(5a85278f721beb3b00125db5c912d1dc552c5897), ROM_BIOS(5) )
1839//  ROM_SYSTEM_BIOS( 5, "test", "test" )
1840//  ROMX_LOAD( "test.bin", 0x000000, 0x080000, CRC(00000000) SHA1(0000000000000000000000000000000000000000), ROM_BIOS(6) )
1855#if 0
1856   ROM_SYSTEM_BIOS( 5, "test", "test" )
1857   ROMX_LOAD( "test.bin", 0x000000, 0x080000, CRC(00000000) SHA1(0000000000000000000000000000000000000000), ROM_BIOS(6) )
1858#endif
18411859ROM_END
18421860
18431861CONS(2001, gp32, 0, 0, gp32, gp32, 0, 0, "Game Park", "GP32", ROT270|GAME_NOT_WORKING|GAME_NO_SOUND)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team