mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-11 06:02:37 -05:00
Initial commit of work-in-progress iPod port
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7781 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
3cd5c646d0
commit
77372d1218
24 changed files with 2178 additions and 21 deletions
|
|
@ -254,4 +254,18 @@ void adc_init(void)
|
|||
sleep(2); /* Ensure valid readings when adc_init returns */
|
||||
}
|
||||
|
||||
#elif CONFIG_CPU == PP5020
|
||||
|
||||
#warning Implement adc.c
|
||||
|
||||
unsigned short adc_read(int channel)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void adc_init(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -71,6 +71,43 @@
|
|||
#define SET_REG(reg,val) reg = ((val) << 8)
|
||||
#define SET_16BITREG(reg,val) reg = (val)
|
||||
|
||||
#elif CONFIG_CPU == PP5020
|
||||
|
||||
/* don't use sh7034 assembler routines */
|
||||
#define PREFER_C_READING
|
||||
#define PREFER_C_WRITING
|
||||
|
||||
#define ATA_IOBASE 0xc30001e0
|
||||
#define ATA_DATA (*((volatile unsigned short*)(ATA_IOBASE)))
|
||||
#define ATA_ERROR (*((volatile unsigned char*)(ATA_IOBASE + 0x04)))
|
||||
#define ATA_NSECTOR (*((volatile unsigned char*)(ATA_IOBASE + 0x08)))
|
||||
#define ATA_SECTOR (*((volatile unsigned char*)(ATA_IOBASE + 0x0c)))
|
||||
#define ATA_LCYL (*((volatile unsigned char*)(ATA_IOBASE + 0x10)))
|
||||
#define ATA_HCYL (*((volatile unsigned char*)(ATA_IOBASE + 0x14)))
|
||||
#define ATA_SELECT (*((volatile unsigned char*)(ATA_IOBASE + 0x18)))
|
||||
#define ATA_COMMAND (*((volatile unsigned char*)(ATA_IOBASE + 0x1c)))
|
||||
#define ATA_CONTROL (*((volatile unsigned char*)(0xc30003f8)))
|
||||
|
||||
#define STATUS_BSY 0x80
|
||||
#define STATUS_RDY 0x40
|
||||
#define STATUS_DF 0x20
|
||||
#define STATUS_DRQ 0x08
|
||||
#define STATUS_ERR 0x01
|
||||
#define ERROR_ABRT 0x04
|
||||
|
||||
#define WRITE_PATTERN1 0xa5
|
||||
#define WRITE_PATTERN2 0x5a
|
||||
#define WRITE_PATTERN3 0xaa
|
||||
#define WRITE_PATTERN4 0x55
|
||||
|
||||
#define READ_PATTERN1 0xa5
|
||||
#define READ_PATTERN2 0x5a
|
||||
#define READ_PATTERN3 0xaa
|
||||
#define READ_PATTERN4 0x55
|
||||
|
||||
#define SET_REG(reg,val) reg = (val)
|
||||
#define SET_16BITREG(reg,val) reg = (val)
|
||||
|
||||
#elif CONFIG_CPU == SH7034
|
||||
|
||||
#define SWAP_WORDS
|
||||
|
|
@ -362,7 +399,7 @@ static void copy_read_sectors(unsigned char* buf, int wordcount)
|
|||
{ /* loop compiles to 7 assembler instructions */
|
||||
/* takes 12 clock cycles (2 pipeline stalls, 1 wait) */
|
||||
#ifdef SWAP_WORDS
|
||||
*wbuf = letoh16(ATA_DATA);
|
||||
*wbuf = swap16(ATA_DATA);
|
||||
#else
|
||||
*wbuf = ATA_DATA;
|
||||
#endif
|
||||
|
|
@ -677,7 +714,7 @@ static void copy_write_sectors(const unsigned char* buf, int wordcount)
|
|||
#ifdef SWAP_WORDS
|
||||
/* loop compiles to 6 assembler instructions */
|
||||
/* takes 10 clock cycles (2 pipeline stalls) */
|
||||
SET_16BITREG(ATA_DATA, htole16(*wbuf));
|
||||
SET_16BITREG(ATA_DATA, swap16(*wbuf));
|
||||
#else
|
||||
SET_16BITREG(ATA_DATA, *wbuf);
|
||||
#endif
|
||||
|
|
@ -1242,6 +1279,8 @@ void ata_enable(bool on)
|
|||
or_l(0x00040000, &GPIO_FUNCTION);
|
||||
#elif CONFIG_CPU == TCC730
|
||||
|
||||
#elif CONFIG_CPU == PP5020
|
||||
#warning Implement ata_enable()
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -1255,7 +1294,6 @@ static int identify(void)
|
|||
DEBUGF("identify() - not RDY\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
SET_REG(ATA_COMMAND, CMD_IDENTIFY);
|
||||
|
||||
if (!wait_for_start_of_transfer())
|
||||
|
|
@ -1267,10 +1305,11 @@ static int identify(void)
|
|||
for (i=0; i<SECTOR_SIZE/2; i++) {
|
||||
/* the IDENTIFY words are already swapped, so we need to treat
|
||||
this info differently that normal sector data */
|
||||
#ifdef SWAP_WORDS
|
||||
identify_info[i] = ATA_DATA;
|
||||
#if defined(ROCKBOX_IS_BIGENDIAN) && !defined(SWAP_WORDS)
|
||||
#warning Swapping ATA identify data
|
||||
identify_info[i] = swap16(ATA_DATA);
|
||||
#else
|
||||
identify_info[i] = letoh16(ATA_DATA);
|
||||
identify_info[i] = ATA_DATA;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -1393,6 +1432,9 @@ int ata_init(void)
|
|||
bool coldstart = (P1 & 0x80) == 0;
|
||||
#elif CONFIG_CPU == MCF5249
|
||||
bool coldstart = (GPIO_FUNCTION & 0x00080000) == 0;
|
||||
#elif CONFIG_CPU == PP5020
|
||||
bool coldstart = false;
|
||||
#warning Implement coldstart variable
|
||||
#else
|
||||
bool coldstart = (PACR2 & 0x4000) != 0;
|
||||
#endif
|
||||
|
|
@ -1418,6 +1460,13 @@ int ata_init(void)
|
|||
or_l(0x00080000, &GPIO_FUNCTION);
|
||||
|
||||
/* FYI: The IDECONFIGx registers are set by set_cpu_frequency() */
|
||||
#elif CONFIG_CPU == PP5020
|
||||
/* From ipod-ide.c:ipod_ide_register() */
|
||||
outl(inl(0xc3000028) | (1 << 5), 0xc3000028);
|
||||
outl(inl(0xc3000028) & ~0x10000000, 0xc3000028);
|
||||
|
||||
outl(0x10, 0xc3000000);
|
||||
outl(0x80002150, 0xc3000004);
|
||||
#endif
|
||||
|
||||
sleeping = false;
|
||||
|
|
|
|||
189
firmware/drivers/i2c-pp5020.c
Normal file
189
firmware/drivers/i2c-pp5020.c
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2005 by Dave Chapman
|
||||
*
|
||||
* All files in this archive are subject to the GNU General Public License.
|
||||
* See the file COPYING in the source tree root for full license agreement.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "cpu.h"
|
||||
#include "kernel.h"
|
||||
#include "logf.h"
|
||||
#include "system.h"
|
||||
#include "i2c-pp5020.h"
|
||||
|
||||
#define I2C_DEVICE_1 ((volatile unsigned char *)0)
|
||||
#define I2C_DEVICE_2 ((volatile unsigned char *)0)
|
||||
|
||||
/* Local functions definitions */
|
||||
|
||||
static int i2c_write_byte(int device, unsigned char data);
|
||||
static int i2c_gen_start(int device);
|
||||
static void i2c_gen_stop(int device);
|
||||
static volatile unsigned char *i2c_get_addr(int device);
|
||||
|
||||
#define IPOD_I2C_BASE 0x7000c000
|
||||
#define IPOD_I2C_CTRL (IPOD_I2C_BASE+0x00)
|
||||
#define IPOD_I2C_ADDR (IPOD_I2C_BASE+0x04)
|
||||
#define IPOD_I2C_DATA0 (IPOD_I2C_BASE+0x0c)
|
||||
#define IPOD_I2C_DATA1 (IPOD_I2C_BASE+0x10)
|
||||
#define IPOD_I2C_DATA2 (IPOD_I2C_BASE+0x14)
|
||||
#define IPOD_I2C_DATA3 (IPOD_I2C_BASE+0x18)
|
||||
#define IPOD_I2C_STATUS (IPOD_I2C_BASE+0x1c)
|
||||
|
||||
/* IPOD_I2C_CTRL bit definitions */
|
||||
#define IPOD_I2C_SEND 0x80
|
||||
|
||||
/* IPOD_I2C_STATUS bit definitions */
|
||||
#define IPOD_I2C_BUSY (1<<6)
|
||||
|
||||
#define POLL_TIMEOUT (HZ)
|
||||
|
||||
static int
|
||||
ipod_i2c_wait_not_busy(void)
|
||||
{
|
||||
unsigned long timeout;
|
||||
#if 0
|
||||
timeout = jiffies + POLL_TIMEOUT;
|
||||
while (time_before(jiffies, timeout)) {
|
||||
if (!(inb(IPOD_I2C_STATUS) & IPOD_I2C_BUSY)) {
|
||||
return 0;
|
||||
}
|
||||
yield();
|
||||
}
|
||||
|
||||
return -ETIMEDOUT;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* Public functions */
|
||||
|
||||
void i2c_init(void)
|
||||
{
|
||||
/* From ipodlinux */
|
||||
|
||||
outl(inl(0x6000600c) | 0x1000, 0x6000600c); /* enable 12 */
|
||||
outl(inl(0x60006004) | 0x1000, 0x60006004); /* start reset 12 */
|
||||
outl(inl(0x60006004) & ~0x1000, 0x60006004); /* end reset 12 */
|
||||
|
||||
outl(0x0, 0x600060a4);
|
||||
outl(0x80 | (0 << 8), 0x600060a4);
|
||||
|
||||
i2c_readbyte(0x8, 0);
|
||||
|
||||
}
|
||||
|
||||
void i2c_close(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes bytes to the selected device.
|
||||
*
|
||||
* Returns number of bytes successfully send or -1 if START failed
|
||||
*/
|
||||
int i2c_write(int device, unsigned char *buf, int count)
|
||||
{
|
||||
/* From ipodlinux */
|
||||
int data_addr;
|
||||
int i;
|
||||
|
||||
if (count < 1 || count > 4) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
if (ipod_i2c_wait_not_busy() < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// clear top 15 bits, left shift 1
|
||||
outb((device << 17) >> 16, IPOD_I2C_ADDR);
|
||||
|
||||
outb(inb(IPOD_I2C_CTRL) & ~0x20, IPOD_I2C_CTRL);
|
||||
|
||||
data_addr = IPOD_I2C_DATA0;
|
||||
for ( i = 0; i < count; i++ ) {
|
||||
outb(*buf++, data_addr);
|
||||
|
||||
data_addr += 4;
|
||||
}
|
||||
|
||||
outb((inb(IPOD_I2C_CTRL) & ~0x26) | ((count-1) << 1), IPOD_I2C_CTRL);
|
||||
|
||||
outb(inb(IPOD_I2C_CTRL) | IPOD_I2C_SEND, IPOD_I2C_CTRL);
|
||||
|
||||
return 0x0;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/* Write a byte to the interface, returns 0 on success, -1 otherwise. */
|
||||
int i2c_write_byte(int device, unsigned char data)
|
||||
{
|
||||
if (ipod_i2c_wait_not_busy() < 0) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
// clear top 15 bits, left shift 1
|
||||
outb((device << 17) >> 16, IPOD_I2C_ADDR);
|
||||
|
||||
outb(inb(IPOD_I2C_CTRL) & ~0x20, IPOD_I2C_CTRL);
|
||||
|
||||
outb(data, IPOD_I2C_DATA0);
|
||||
|
||||
outb((inb(IPOD_I2C_CTRL) & ~0x26), IPOD_I2C_CTRL);
|
||||
|
||||
outb(inb(IPOD_I2C_CTRL) | IPOD_I2C_SEND, IPOD_I2C_CTRL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Returns 0 on success, -1 on failure */
|
||||
int i2c_gen_start(int device)
|
||||
{
|
||||
volatile unsigned char *regs = i2c_get_addr(device);
|
||||
long count = 0;
|
||||
|
||||
/* Wait for bus to become free */
|
||||
while ((regs[O_MBSR] & IBB) && (count < MAX_LOOP))
|
||||
{
|
||||
yield();
|
||||
count++;
|
||||
}
|
||||
|
||||
if (count >= MAX_LOOP)
|
||||
return -1;
|
||||
|
||||
regs[O_MBCR] |= MSTA | MTX; /* Generate START */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void i2c_gen_stop(int device)
|
||||
{
|
||||
volatile unsigned char *regs = i2c_get_addr(device);
|
||||
regs[O_MBCR] &= ~MSTA; /* Clear MSTA to generate STOP */
|
||||
}
|
||||
|
||||
|
||||
volatile unsigned char *i2c_get_addr(int device)
|
||||
{
|
||||
if (device == 1)
|
||||
return I2C_DEVICE_1;
|
||||
|
||||
return I2C_DEVICE_2;
|
||||
}
|
||||
1266
firmware/drivers/lcd-16bit.c
Normal file
1266
firmware/drivers/lcd-16bit.c
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -73,6 +73,8 @@ void power_init(void)
|
|||
#ifdef HAVE_SPDIF_POWER
|
||||
spdif_power_enable(false);
|
||||
#endif
|
||||
#elif CONFIG_CPU == PP5020
|
||||
#warning Implement power_init()
|
||||
#else
|
||||
#ifdef HAVE_POWEROFF_ON_PB5
|
||||
PBCR2 &= ~0x0c00; /* GPIO for PB5 */
|
||||
|
|
@ -163,6 +165,8 @@ void ide_power_enable(bool on)
|
|||
and_l(~0x80000000, &GPIO_OUT);
|
||||
else
|
||||
or_l(0x80000000, &GPIO_OUT);
|
||||
#elif CONFIG_CPU == PP5020
|
||||
#warning Implement ide_power_enable()
|
||||
#elif defined(GMINI_ARCH)
|
||||
if(on)
|
||||
P1 |= 0x08;
|
||||
|
|
@ -213,6 +217,9 @@ bool ide_powered(void)
|
|||
{
|
||||
#if CONFIG_CPU == MCF5249
|
||||
return (GPIO_OUT & 0x80000000)?false:true;
|
||||
#elif CONFIG_CPU == PP5020
|
||||
#warning Implement ide_powered()
|
||||
return true;
|
||||
#elif defined(GMINI_ARCH)
|
||||
return (P1 & 0x08?true:false);
|
||||
#else /* SH1 based archos */
|
||||
|
|
@ -244,6 +251,8 @@ void power_off(void)
|
|||
set_irq_level(HIGHEST_IRQ_LEVEL);
|
||||
#if CONFIG_CPU == MCF5249
|
||||
and_l(~0x00080000, &GPIO1_OUT);
|
||||
#elif CONFIG_CPU == PP5020
|
||||
#warning Implement power_off()
|
||||
#elif defined(GMINI_ARCH)
|
||||
P1 &= ~1;
|
||||
P1CON &= ~1;
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@
|
|||
#include "lcd.h"
|
||||
#include "serial.h"
|
||||
|
||||
#if (CONFIG_CPU != MCF5249) && (CONFIG_CPU != TCC730)
|
||||
/* FIX: this doesn't work on iRiver or Gmini yet */
|
||||
#if (CONFIG_CPU != MCF5249) && (CONFIG_CPU != TCC730) && (CONFIG_CPU != PP5020)
|
||||
/* FIX: this doesn't work on iRiver or Gmini or iPod yet */
|
||||
|
||||
#ifndef HAVE_MMC /* MMC takes serial port 1, so don't mess with it */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue