2 * linux/arch/sh/boards/hp6xx/setup.c
4 * Copyright (C) 2002 Andriy Skulysh
5 * Copyright (C) 2007 Kristoffer Ericson <Kristoffer_e1@hotmail.com>
7 * May be copied or modified under the terms of the GNU General Public
8 * License. See linux/COPYING for more information.
10 * Setup code for HP620/HP660/HP680/HP690 (internal peripherials only)
12 #include <linux/types.h>
13 #include <linux/init.h>
14 #include <linux/platform_device.h>
15 #include <linux/irq.h>
16 #include <sound/sh_dac_audio.h>
17 #include <asm/hd64461.h>
19 #include <mach/hp6xx.h>
22 #define SCPCR 0xa4000116
23 #define SCPDR 0xa4000136
26 static struct resource cf_ide_resources
[] = {
28 .start
= 0x15000000 + 0x1f0,
29 .end
= 0x15000000 + 0x1f0 + 0x08 - 0x01,
30 .flags
= IORESOURCE_MEM
,
33 .start
= 0x15000000 + 0x1fe,
34 .end
= 0x15000000 + 0x1fe + 0x01,
35 .flags
= IORESOURCE_MEM
,
39 .flags
= IORESOURCE_IRQ
,
43 static struct platform_device cf_ide_device
= {
44 .name
= "pata_platform",
46 .num_resources
= ARRAY_SIZE(cf_ide_resources
),
47 .resource
= cf_ide_resources
,
50 static struct platform_device jornadakbd_device
= {
51 .name
= "jornada680_kbd",
55 static void dac_audio_start(struct dac_audio_pdata
*pdata
)
60 /* HP Jornada 680/690 speaker on */
61 v
= inw(HD64461_GPADR
);
62 v
&= ~HD64461_GPADR_SPEAKER
;
63 outw(v
, HD64461_GPADR
);
65 /* HP Palmtop 620lx/660lx speaker on */
70 sh_dac_enable(pdata
->channel
);
73 static void dac_audio_stop(struct dac_audio_pdata
*pdata
)
78 /* HP Jornada 680/690 speaker off */
79 v
= inw(HD64461_GPADR
);
80 v
|= HD64461_GPADR_SPEAKER
;
81 outw(v
, HD64461_GPADR
);
83 /* HP Palmtop 620lx/660lx speaker off */
88 sh_dac_output(0, pdata
->channel
);
89 sh_dac_disable(pdata
->channel
);
92 static struct dac_audio_pdata dac_audio_platform_data
= {
95 .start
= dac_audio_start
,
96 .stop
= dac_audio_stop
,
99 static struct platform_device dac_audio_device
= {
103 .platform_data
= &dac_audio_platform_data
,
108 static struct platform_device
*hp6xx_devices
[] __initdata
= {
114 static void __init
hp6xx_init_irq(void)
116 /* Gets touchscreen and powerbutton IRQ working */
117 plat_irq_setup_pins(IRQ_MODE_IRQ
);
120 static int __init
hp6xx_devices_setup(void)
122 return platform_add_devices(hp6xx_devices
, ARRAY_SIZE(hp6xx_devices
));
125 static void __init
hp6xx_setup(char **cmdline_p
)
130 v
= inw(HD64461_STBCR
);
131 v
|= HD64461_STBCR_SURTST
| HD64461_STBCR_SIRST
|
132 HD64461_STBCR_STM1ST
| HD64461_STBCR_STM0ST
|
133 HD64461_STBCR_SAFEST
| HD64461_STBCR_SPC0ST
|
134 HD64461_STBCR_SMIAST
| HD64461_STBCR_SAFECKE_OST
|
135 HD64461_STBCR_SAFECKE_IST
;
136 #ifndef CONFIG_HD64461_ENABLER
137 v
|= HD64461_STBCR_SPC1ST
;
139 outw(v
, HD64461_STBCR
);
140 v
= inw(HD64461_GPADR
);
141 v
|= HD64461_GPADR_SPEAKER
| HD64461_GPADR_PCMCIA0
;
142 outw(v
, HD64461_GPADR
);
144 outw(HD64461_PCCGCR_VCC0
| HD64461_PCCSCR_VCC1
, HD64461_PCC0GCR
);
146 #ifndef CONFIG_HD64461_ENABLER
147 outw(HD64461_PCCGCR_VCC0
| HD64461_PCCSCR_VCC1
, HD64461_PCC1GCR
);
150 sh_dac_output(0, DAC_SPEAKER_VOLUME
);
151 sh_dac_disable(DAC_SPEAKER_VOLUME
);
152 v8
= __raw_readb(DACR
);
154 __raw_writeb(v8
,DACR
);
156 v8
= __raw_readb(SCPDR
);
157 v8
|= SCPDR_TS_SCAN_X
| SCPDR_TS_SCAN_Y
;
158 v8
&= ~SCPDR_TS_SCAN_ENABLE
;
159 __raw_writeb(v8
, SCPDR
);
161 v
= __raw_readw(SCPCR
);
163 v
|= SCPCR_TS_ENABLE
;
164 __raw_writew(v
, SCPCR
);
166 device_initcall(hp6xx_devices_setup
);
168 static struct sh_machine_vector mv_hp6xx __initmv
= {
170 .mv_setup
= hp6xx_setup
,
171 /* IRQ's : CPU(64) + CCHIP(16) + FREE_TO_USE(6) */
172 .mv_nr_irqs
= HD64461_IRQBASE
+ HD64461_IRQ_NUM
+ 6,
173 /* Enable IRQ0 -> IRQ3 in IRQ_MODE */
174 .mv_init_irq
= hp6xx_init_irq
,