setup.c 2.9 KB
Newer Older
L
Linus Torvalds 已提交
1
/*
2
 * linux/arch/sh/boards/hp6xx/setup.c
L
Linus Torvalds 已提交
3 4
 *
 * Copyright (C) 2002 Andriy Skulysh
5
 * Copyright (C) 2007 Kristoffer Ericson <Kristoffer_e1@hotmail.com>
L
Linus Torvalds 已提交
6 7 8 9
 *
 * May be copied or modified under the terms of the GNU General Public
 * License.  See linux/COPYING for more information.
 *
10
 * Setup code for HP620/HP660/HP680/HP690 (internal peripherials only)
L
Linus Torvalds 已提交
11
 */
12
#include <linux/types.h>
L
Linus Torvalds 已提交
13
#include <linux/init.h>
14
#include <linux/platform_device.h>
15
#include <asm/hd64461.h>
16 17
#include <asm/io.h>
#include <asm/irq.h>
18
#include <mach/hp6xx.h>
P
Paul Mundt 已提交
19
#include <cpu/dac.h>
L
Linus Torvalds 已提交
20

A
Andriy Skulysh 已提交
21
#define	SCPCR	0xa4000116
22
#define	SCPDR	0xa4000136
A
Andriy Skulysh 已提交
23

24 25 26 27 28 29 30 31 32 33 34 35 36
/* CF Slot */
static struct resource cf_ide_resources[] = {
	[0] = {
		.start = 0x15000000 + 0x1f0,
		.end   = 0x15000000 + 0x1f0 + 0x08 - 0x01,
		.flags = IORESOURCE_MEM,
	},
	[1] = {
		.start = 0x15000000 + 0x1fe,
		.end   = 0x15000000 + 0x1fe + 0x01,
		.flags = IORESOURCE_MEM,
	},
	[2] = {
37
		.start = 77,
38 39 40 41 42 43 44 45 46 47 48
		.flags = IORESOURCE_IRQ,
	},
};

static struct platform_device cf_ide_device = {
	.name		=  "pata_platform",
	.id		=  -1,
	.num_resources	= ARRAY_SIZE(cf_ide_resources),
	.resource	= cf_ide_resources,
};

49 50 51 52 53
static struct platform_device jornadakbd_device = {
	.name		= "jornada680_kbd",
	.id		= -1,
};

54
static struct platform_device *hp6xx_devices[] __initdata = {
55 56
	&cf_ide_device,
	&jornadakbd_device,
57 58
};

59 60 61
static void __init hp6xx_init_irq(void)
{
	/* Gets touchscreen and powerbutton IRQ working */
62
	plat_irq_setup_pins(IRQ_MODE_IRQ);
63 64
}

65 66 67 68 69
static int __init hp6xx_devices_setup(void)
{
	return platform_add_devices(hp6xx_devices, ARRAY_SIZE(hp6xx_devices));
}

P
Paul Mundt 已提交
70
static void __init hp6xx_setup(char **cmdline_p)
L
Linus Torvalds 已提交
71
{
72
	u8 v8;
L
Linus Torvalds 已提交
73
	u16 v;
A
Andriy Skulysh 已提交
74

L
Linus Torvalds 已提交
75
	v = inw(HD64461_STBCR);
76 77 78 79 80
	v |=	HD64461_STBCR_SURTST | HD64461_STBCR_SIRST	|
		HD64461_STBCR_STM1ST | HD64461_STBCR_STM0ST	|
		HD64461_STBCR_SAFEST | HD64461_STBCR_SPC0ST	|
		HD64461_STBCR_SMIAST | HD64461_STBCR_SAFECKE_OST|
		HD64461_STBCR_SAFECKE_IST;
81 82 83
#ifndef CONFIG_HD64461_ENABLER
	v |= HD64461_STBCR_SPC1ST;
#endif
L
Linus Torvalds 已提交
84 85 86 87 88
	outw(v, HD64461_STBCR);
	v = inw(HD64461_GPADR);
	v |= HD64461_GPADR_SPEAKER | HD64461_GPADR_PCMCIA0;
	outw(v, HD64461_GPADR);

89 90 91 92 93 94 95
	outw(HD64461_PCCGCR_VCC0 | HD64461_PCCSCR_VCC1, HD64461_PCC0GCR);

#ifndef CONFIG_HD64461_ENABLER
	outw(HD64461_PCCGCR_VCC0 | HD64461_PCCSCR_VCC1, HD64461_PCC1GCR);
#endif

	sh_dac_output(0, DAC_SPEAKER_VOLUME);
L
Linus Torvalds 已提交
96
	sh_dac_disable(DAC_SPEAKER_VOLUME);
97 98 99
	v8 = ctrl_inb(DACR);
	v8 &= ~DACR_DAE;
	ctrl_outb(v8,DACR);
L
Linus Torvalds 已提交
100

A
Andriy Skulysh 已提交
101 102 103 104 105 106 107 108 109
	v8 = ctrl_inb(SCPDR);
	v8 |= SCPDR_TS_SCAN_X | SCPDR_TS_SCAN_Y;
	v8 &= ~SCPDR_TS_SCAN_ENABLE;
	ctrl_outb(v8, SCPDR);

	v = ctrl_inw(SCPCR);
	v &= ~SCPCR_TS_MASK;
	v |= SCPCR_TS_ENABLE;
	ctrl_outw(v, SCPCR);
L
Linus Torvalds 已提交
110
}
111
device_initcall(hp6xx_devices_setup);
P
Paul Mundt 已提交
112

P
Paul Mundt 已提交
113
static struct sh_machine_vector mv_hp6xx __initmv = {
P
Paul Mundt 已提交
114 115
	.mv_name = "hp6xx",
	.mv_setup = hp6xx_setup,
116 117
	/* IRQ's : CPU(64) + CCHIP(16) + FREE_TO_USE(6) */
	.mv_nr_irqs = HD64461_IRQBASE + HD64461_IRQ_NUM + 6,
P
Paul Mundt 已提交
118
	.mv_irq_demux = hd64461_irq_demux,
119 120
	/* Enable IRQ0 -> IRQ3 in IRQ_MODE */
	.mv_init_irq = hp6xx_init_irq,
P
Paul Mundt 已提交
121
};