[aa2218]: arch / powerpc / platforms / embedded6xx / starlet-stm.c Maximize Restore History

Download this file

starlet-stm.c    107 lines (85 with data), 2.4 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
/*
* arch/powerpc/platforms/embedded6xx/starlet-stm.c
*
* Nintendo Wii starlet STM routines
* Copyright (C) 2008-2009 The GameCube Linux Team
* Copyright (C) 2008,2009 Albert Herranz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
*/
#define DBG(fmt, arg...) drv_printk(KERN_INFO, fmt, ##arg)
#include <linux/kernel.h>
#include <linux/dma-mapping.h>
#include <asm/starlet.h>
/*
* /dev/stm/immediate
*
*/
#define STARLET_STM_HOTRESET 0x2001
#define STARLET_STM_SHUTDOWN 0x2003
#define STARLET_STM_TIMEOUT 1000000 /* usecs */
#define STARLET_DEV_STM_IMMEDIATE "/dev/stm/immediate"
#define drv_printk(level, format, arg...) \
printk(level "starlet-stm: " format , ## arg)
static const char dev_stm_immediate[] = STARLET_DEV_STM_IMMEDIATE;
/* private aligned buffer for restart/power_off operations */
static u32 starlet_stm_buf[(STARLET_IPC_DMA_ALIGN+1)/sizeof(u32)]
__attribute__ ((aligned(STARLET_IPC_DMA_ALIGN+1)));
/*
*
*/
static void starlet_stm_common_restart(int request, u32 value)
{
static int already_in_restart;
u32 *buf = starlet_stm_buf;
size_t len = sizeof(starlet_stm_buf);
int fd;
int error;
if (already_in_restart) {
drv_printk(KERN_ERR, "previous restart attempt failed,"
" halting\n");
goto halt;
}
drv_printk(KERN_INFO, "trying IPC restart...\n");
already_in_restart = 1;
fd = starlet_open_polled(dev_stm_immediate, 0, STARLET_STM_TIMEOUT);
if (fd < 0) {
drv_printk(KERN_ERR, "failed to open %s\n", dev_stm_immediate);
error = fd;
goto done;
}
*buf = value;
error = starlet_ioctl_polled(fd, request, buf, len, buf, len,
STARLET_STM_TIMEOUT);
if (error < 0) {
drv_printk(KERN_ERR, "ioctl %d failed\n", request);
starlet_close_polled(fd, STARLET_STM_TIMEOUT);
} else {
halt:
for(;;)
cpu_relax();
}
done:
if (error < 0)
DBG("%s: error=%d (%x)\n", __func__, error, error);
}
/*
*
*/
void starlet_stm_restart(void)
{
starlet_stm_common_restart(STARLET_STM_HOTRESET, 0);
}
/*EXPORT_SYMBOL_GPL(starlet_stm_restart);*/
/*
*
*/
void starlet_stm_power_off(void)
{
starlet_stm_common_restart(STARLET_STM_SHUTDOWN, 0);
}
/*EXPORT_SYMBOL_GPL(starlet_stm_power_off);*/