setup.c 4.0 KB
Newer Older
K
kogiidena 已提交
1 2 3
/*
 * arch/sh/boards/landisk/setup.c
 *
P
Paul Mundt 已提交
4
 * Copyright (C) 2000 Kazumoto Kojima
K
kogiidena 已提交
5 6 7 8 9 10
 * Copyright (C) 2002 Paul Mundt
 *
 * I-O DATA Device, Inc. LANDISK Support.
 *
 * Modified for LANDISK by
 * Atom Create Engineering Co., Ltd. 2002.
P
Paul Mundt 已提交
11
 *
K
kogiidena 已提交
12 13
 * modifed by kogiidena
 * 2005.09.16
P
Paul Mundt 已提交
14 15 16 17
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file "COPYING" in the main directory of this archive
 * for more details.
K
kogiidena 已提交
18 19 20 21
 */
#include <linux/config.h>
#include <linux/init.h>
#include <linux/pm.h>
P
Paul Mundt 已提交
22
#include <linux/mm.h>
K
kogiidena 已提交
23 24 25
#include <asm/machvec.h>
#include <asm/rtc.h>
#include <asm/landisk/iodata_landisk.h>
P
Paul Mundt 已提交
26
#include <asm/io.h>
K
kogiidena 已提交
27 28

void landisk_time_init(void);
P
Paul Mundt 已提交
29
void init_landisk_IRQ(void);
K
kogiidena 已提交
30 31 32 33 34

int landisk_ledparam;
int landisk_buzzerparam;
int landisk_arch;

P
Paul Mundt 已提交
35 36
/* cycle the led's in the clasic knightrider/sun pattern */
static void heartbeat_landisk(void)
K
kogiidena 已提交
37 38
{
	static unsigned int cnt = 0, blink = 0x00, period = 25;
P
Paul Mundt 已提交
39
        volatile u8 *p = (volatile u8 *)PA_LED;
K
kogiidena 已提交
40 41
	char data;

P
Paul Mundt 已提交
42
        if ((landisk_ledparam & 0x080) == 0)
K
kogiidena 已提交
43
		return;
P
Paul Mundt 已提交
44

K
kogiidena 已提交
45
	cnt += 1;
P
Paul Mundt 已提交
46 47

        if (cnt < period)
K
kogiidena 已提交
48
		return;
P
Paul Mundt 已提交
49

K
kogiidena 已提交
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
	cnt = 0;
	blink++;

	data = (blink & 0x01) ? (landisk_ledparam >> 16) : 0;
	data |= (blink & 0x02) ? (landisk_ledparam >> 8) : 0;
	data |= landisk_ledparam;

	/* buzzer */
	if (landisk_buzzerparam & 0x1) {
		data |= 0x80;
	} else {
		data &= 0x7f;
	}
	*p = data;

P
Paul Mundt 已提交
65 66
        if (((landisk_ledparam & 0x007f7f00) == 0) &&
             (landisk_buzzerparam == 0))
K
kogiidena 已提交
67
		landisk_ledparam &= (~0x0080);
P
Paul Mundt 已提交
68

K
kogiidena 已提交
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
	landisk_buzzerparam >>= 1;
}

/*
 * The Machine Vector
 */
struct sh_machine_vector mv_landisk __initmv = {
	.mv_nr_irqs = 72,
	.mv_inb = landisk_inb,
	.mv_inw = landisk_inw,
	.mv_inl = landisk_inl,
	.mv_outb = landisk_outb,
	.mv_outw = landisk_outw,
	.mv_outl = landisk_outl,
	.mv_inb_p = landisk_inb_p,
	.mv_inw_p = landisk_inw,
	.mv_inl_p = landisk_inl,
	.mv_outb_p = landisk_outb_p,
	.mv_outw_p = landisk_outw,
	.mv_outl_p = landisk_outl,
	.mv_insb = landisk_insb,
	.mv_insw = landisk_insw,
	.mv_insl = landisk_insl,
	.mv_outsb = landisk_outsb,
	.mv_outsw = landisk_outsw,
	.mv_outsl = landisk_outsl,
P
Paul Mundt 已提交
95
        .mv_ioport_map = landisk_ioport_map,
K
kogiidena 已提交
96 97 98 99 100 101
	.mv_init_irq = init_landisk_IRQ,
#ifdef CONFIG_HEARTBEAT
	.mv_heartbeat = heartbeat_landisk,
#endif
};
ALIAS_MV(landisk)
P
Paul Mundt 已提交
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179

const char *get_system_type(void)
{
        return "LANDISK";
}

static void landisk_power_off(void)
{
        ctrl_outb(0x01, PA_SHUTDOWN);
}

static void check_usl5p(void)
{
        volatile u8 *p = (volatile u8 *)PA_LED;
        u8 tmp1, tmp2;

        tmp1 = *p;
        *p = 0x40;
        tmp2 = *p;
        *p = tmp1;

        landisk_arch = (tmp2 == 0x40);
        if (landisk_arch == 1) {
                /* arch == usl-5p */
                landisk_ledparam = 0x00000380;
                landisk_ledparam |= (tmp1 & 0x07c);
        } else {
                /* arch == landisk */
                landisk_ledparam = 0x02000180;
                landisk_ledparam |= 0x04;
        }
}

void __init platform_setup(void)
{
        landisk_buzzerparam = 0;
        check_usl5p();

        printk(KERN_INFO "I-O DATA DEVICE, INC. \"LANDISK Series\" support.\n");
        board_time_init = landisk_time_init;
        pm_power_off = landisk_power_off;
}

void *area5_io_base;
void *area6_io_base;

static int __init landisk_cf_init(void)
{
	pgprot_t prot;
	unsigned long paddrbase, psize;

	/* open I/O area window */
	paddrbase = virt_to_phys((void *)PA_AREA5_IO);
	psize = PAGE_SIZE;
	prot = PAGE_KERNEL_PCC(1, _PAGE_PCC_IO16);
	area5_io_base = p3_ioremap(paddrbase, psize, prot.pgprot);
	if (!area5_io_base) {
		printk("allocate_cf_area : can't open CF I/O window!\n");
		return -ENOMEM;
	}

	paddrbase = virt_to_phys((void *)PA_AREA6_IO);
	psize = PAGE_SIZE;
	prot = PAGE_KERNEL_PCC(0, _PAGE_PCC_IO16);
	area6_io_base = p3_ioremap(paddrbase, psize, prot.pgprot);
	if (!area6_io_base) {
		printk("allocate_cf_area : can't open HDD I/O window!\n");
		return -ENOMEM;
	}

	printk(KERN_INFO "Allocate Area5/6 success.\n");

	/* XXX : do we need attribute and common-memory area also? */

	return 0;
}

__initcall(landisk_cf_init);