Code:
#define MX35 4
#define MEM_BASE_ADDR 0x80000000
#define MEM_BOTTOM_ADDR 0x87FFFFFF
/* watch dog registers */
#define WDOG_BASE_ADDR 0x53FDC000
#define WDOG_WCR (WDOG_BASE_ADDR)
#define WDOG_WSR (WDOG_BASE_ADDR + 0x2)
and even with those pretty defines, the magic addresses are hard coded (again):
Code:
#define WD_TIMEOUT 0x20
static void inline watchdog_service(void)
{
if (*(volatile u16 *)0x53FDC000 & 0x04) {
*(volatile u16 *)0x53FDC002 = 0x5555;
*(volatile u16 *)0x53FDC002 = 0xAAAA;
}
}
and then we have a little programmed delay loop (on a variable clock speed device):
Code:
/*!
* delay
*/
static void delay(void)
{
int i;
for (i=0;i<300;i++) {
}
}
And this thing could be made a lot more reliable:
Code:
/*!
* Function to send data to host through channel
*
* @buf buf to send
* @count send data size
*
* @return 0
*/
u32 atk_channel_send(const u8 *buf, u32 count)
{
u32 size;
u32 i;
u32 to = WD_TIMEOUT;
usb_buffer_descriptor_t buf_desc;
usb_status_t status = USB_FAILURE;
if (channel == CHAN_USB) {
watchdog_service();
while (count) {
size = count > BULK_BUFFER_SIZE ? BULK_BUFFER_SIZE : count;
/* FIXME: if the buffer is messed by the USB, use static buffer arrary */
buf_desc.buffer = (u8 *)buf;
buf_desc.size = size;
buf_desc.bytes_transfered = 0;
status = (usb_status_t )tl_send_data(&buf_desc);
count -= size;
buf += size; /* update buffer addr */
if (--to <= 0) {
watchdog_service();
to = WD_TIMEOUT;
}
}
} else {
watchdog_service();
for (i = 0; i < count; i++) {
delay();
/* put data to UART transmit fifo */
uart_putchar(buf[i]);
/* wait for TF empty */
while (!(*(volatile u32 *)UART1_USR2_1 & 0x4000)) {
if (--to <= 0) {
watchdog_service();
to = WD_TIMEOUT;
}
}
if (--to <= 0) {
watchdog_service();
to = WD_TIMEOUT;
}
}
}
return 0;
}
Somewhere in the reading, Freescale wrote that this ATK code wasn't for "production use".
It does begin to look like we will have to build our own.
At least the license allows us to make derivatives and distribute them in object code form for use on "licensed i.MX devices".
On the "up side" - all of the defines and most of the code to use the OTG port looks like it is in the ATK source code.