| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
| Uwe Zeisberger | f30c226 | 2006-10-03 23:01:26 +0200 | [diff] [blame] | 2 |  * linux/arch/sh/boards/hp6xx/setup.c | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 |  * | 
 | 4 |  * Copyright (C) 2002 Andriy Skulysh | 
| Kristoffer Ericson | 34a780a | 2007-04-10 07:45:08 +0900 | [diff] [blame] | 5 |  * Copyright (C) 2007 Kristoffer Ericson <Kristoffer_e1@hotmail.com> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 |  * | 
 | 7 |  * May be copied or modified under the terms of the GNU General Public | 
 | 8 |  * License.  See linux/COPYING for more information. | 
 | 9 |  * | 
| Kristoffer Ericson | aedb598 | 2007-09-12 11:35:55 +0900 | [diff] [blame] | 10 |  * Setup code for HP620/HP660/HP680/HP690 (internal peripherials only) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 |  */ | 
| Paul Mundt | e5723e0 | 2006-09-27 17:38:11 +0900 | [diff] [blame] | 12 | #include <linux/types.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <linux/init.h> | 
| Kristoffer Ericson | 34a780a | 2007-04-10 07:45:08 +0900 | [diff] [blame] | 14 | #include <linux/platform_device.h> | 
| Paul Mundt | 604437f | 2009-01-09 15:11:58 +0900 | [diff] [blame] | 15 | #include <linux/irq.h> | 
| Rafael Ignacio Zurita | 9dcaa7b | 2009-11-03 17:16:27 -0300 | [diff] [blame] | 16 | #include <sound/sh_dac_audio.h> | 
| Paul Mundt | 0025835 | 2006-01-16 22:14:08 -0800 | [diff] [blame] | 17 | #include <asm/hd64461.h> | 
| Paul Mundt | e5723e0 | 2006-09-27 17:38:11 +0900 | [diff] [blame] | 18 | #include <asm/io.h> | 
| Paul Mundt | 7639a45 | 2008-10-20 13:02:48 +0900 | [diff] [blame] | 19 | #include <mach/hp6xx.h> | 
| Paul Mundt | f15cbe6 | 2008-07-29 08:09:44 +0900 | [diff] [blame] | 20 | #include <cpu/dac.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 |  | 
| Andriy Skulysh | 3aa770e | 2006-09-27 16:20:22 +0900 | [diff] [blame] | 22 | #define	SCPCR	0xa4000116 | 
| Kristoffer Ericson | aedb598 | 2007-09-12 11:35:55 +0900 | [diff] [blame] | 23 | #define	SCPDR	0xa4000136 | 
| Andriy Skulysh | 3aa770e | 2006-09-27 16:20:22 +0900 | [diff] [blame] | 24 |  | 
| Kristoffer Ericson | 34a780a | 2007-04-10 07:45:08 +0900 | [diff] [blame] | 25 | /* CF Slot */ | 
 | 26 | static struct resource cf_ide_resources[] = { | 
 | 27 | 	[0] = { | 
 | 28 | 		.start = 0x15000000 + 0x1f0, | 
 | 29 | 		.end   = 0x15000000 + 0x1f0 + 0x08 - 0x01, | 
 | 30 | 		.flags = IORESOURCE_MEM, | 
 | 31 | 	}, | 
 | 32 | 	[1] = { | 
 | 33 | 		.start = 0x15000000 + 0x1fe, | 
 | 34 | 		.end   = 0x15000000 + 0x1fe + 0x01, | 
 | 35 | 		.flags = IORESOURCE_MEM, | 
 | 36 | 	}, | 
 | 37 | 	[2] = { | 
| Kristoffer Ericson | c9eaaa9 | 2007-09-11 12:51:02 +0900 | [diff] [blame] | 38 | 		.start = 77, | 
| Kristoffer Ericson | 34a780a | 2007-04-10 07:45:08 +0900 | [diff] [blame] | 39 | 		.flags = IORESOURCE_IRQ, | 
 | 40 | 	}, | 
 | 41 | }; | 
 | 42 |  | 
 | 43 | static struct platform_device cf_ide_device = { | 
 | 44 | 	.name		=  "pata_platform", | 
 | 45 | 	.id		=  -1, | 
 | 46 | 	.num_resources	= ARRAY_SIZE(cf_ide_resources), | 
 | 47 | 	.resource	= cf_ide_resources, | 
 | 48 | }; | 
 | 49 |  | 
| Kristoffer Ericson | aedb598 | 2007-09-12 11:35:55 +0900 | [diff] [blame] | 50 | static struct platform_device jornadakbd_device = { | 
 | 51 | 	.name		= "jornada680_kbd", | 
 | 52 | 	.id		= -1, | 
| Kristoffer Ericson | 34a780a | 2007-04-10 07:45:08 +0900 | [diff] [blame] | 53 | }; | 
 | 54 |  | 
| Rafael Ignacio Zurita | 9dcaa7b | 2009-11-03 17:16:27 -0300 | [diff] [blame] | 55 | static void dac_audio_start(struct dac_audio_pdata *pdata) | 
 | 56 | { | 
 | 57 | 	u16 v; | 
 | 58 | 	u8 v8; | 
 | 59 |  | 
 | 60 | 	/* HP Jornada 680/690 speaker on */ | 
 | 61 | 	v = inw(HD64461_GPADR); | 
 | 62 | 	v &= ~HD64461_GPADR_SPEAKER; | 
 | 63 | 	outw(v, HD64461_GPADR); | 
 | 64 |  | 
 | 65 | 	/* HP Palmtop 620lx/660lx speaker on */ | 
 | 66 | 	v8 = inb(PKDR); | 
 | 67 | 	v8 &= ~PKDR_SPEAKER; | 
 | 68 | 	outb(v8, PKDR); | 
 | 69 |  | 
 | 70 | 	sh_dac_enable(pdata->channel); | 
 | 71 | } | 
 | 72 |  | 
 | 73 | static void dac_audio_stop(struct dac_audio_pdata *pdata) | 
 | 74 | { | 
 | 75 | 	u16 v; | 
 | 76 | 	u8 v8; | 
 | 77 |  | 
 | 78 | 	/* HP Jornada 680/690 speaker off */ | 
 | 79 | 	v = inw(HD64461_GPADR); | 
 | 80 | 	v |= HD64461_GPADR_SPEAKER; | 
 | 81 | 	outw(v, HD64461_GPADR); | 
 | 82 |  | 
 | 83 | 	/* HP Palmtop 620lx/660lx speaker off */ | 
 | 84 | 	v8 = inb(PKDR); | 
 | 85 | 	v8 |= PKDR_SPEAKER; | 
 | 86 | 	outb(v8, PKDR); | 
 | 87 |  | 
 | 88 | 	sh_dac_output(0, pdata->channel); | 
 | 89 | 	sh_dac_disable(pdata->channel); | 
 | 90 | } | 
 | 91 |  | 
 | 92 | static struct dac_audio_pdata dac_audio_platform_data = { | 
 | 93 | 	.buffer_size		= 64000, | 
 | 94 | 	.channel		= 1, | 
 | 95 | 	.start			= dac_audio_start, | 
 | 96 | 	.stop			= dac_audio_stop, | 
 | 97 | }; | 
 | 98 |  | 
 | 99 | static struct platform_device dac_audio_device = { | 
 | 100 | 	.name		= "dac_audio", | 
 | 101 | 	.id		= -1, | 
 | 102 | 	.dev		= { | 
 | 103 | 		.platform_data	= &dac_audio_platform_data, | 
 | 104 | 	} | 
 | 105 |  | 
 | 106 | }; | 
 | 107 |  | 
| Kristoffer Ericson | aedb598 | 2007-09-12 11:35:55 +0900 | [diff] [blame] | 108 | static struct platform_device *hp6xx_devices[] __initdata = { | 
 | 109 | 	&cf_ide_device, | 
 | 110 | 	&jornadakbd_device, | 
| Rafael Ignacio Zurita | 9dcaa7b | 2009-11-03 17:16:27 -0300 | [diff] [blame] | 111 | 	&dac_audio_device, | 
| Kristoffer Ericson | aedb598 | 2007-09-12 11:35:55 +0900 | [diff] [blame] | 112 | }; | 
 | 113 |  | 
 | 114 | static void __init hp6xx_init_irq(void) | 
 | 115 | { | 
 | 116 | 	/* Gets touchscreen and powerbutton IRQ working */ | 
| Paul Mundt | 2f0ae55 | 2007-09-13 16:36:52 +0900 | [diff] [blame] | 117 | 	plat_irq_setup_pins(IRQ_MODE_IRQ); | 
| Kristoffer Ericson | aedb598 | 2007-09-12 11:35:55 +0900 | [diff] [blame] | 118 | } | 
 | 119 |  | 
| Kristoffer Ericson | 34a780a | 2007-04-10 07:45:08 +0900 | [diff] [blame] | 120 | static int __init hp6xx_devices_setup(void) | 
 | 121 | { | 
 | 122 | 	return platform_add_devices(hp6xx_devices, ARRAY_SIZE(hp6xx_devices)); | 
 | 123 | } | 
 | 124 |  | 
| Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 125 | static void __init hp6xx_setup(char **cmdline_p) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | { | 
| Paul Mundt | 0025835 | 2006-01-16 22:14:08 -0800 | [diff] [blame] | 127 | 	u8 v8; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | 	u16 v; | 
| Andriy Skulysh | 3aa770e | 2006-09-27 16:20:22 +0900 | [diff] [blame] | 129 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | 	v = inw(HD64461_STBCR); | 
| Kristoffer Ericson | aedb598 | 2007-09-12 11:35:55 +0900 | [diff] [blame] | 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; | 
| Paul Mundt | 0025835 | 2006-01-16 22:14:08 -0800 | [diff] [blame] | 136 | #ifndef CONFIG_HD64461_ENABLER | 
 | 137 | 	v |= HD64461_STBCR_SPC1ST; | 
 | 138 | #endif | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | 	outw(v, HD64461_STBCR); | 
 | 140 | 	v = inw(HD64461_GPADR); | 
 | 141 | 	v |= HD64461_GPADR_SPEAKER | HD64461_GPADR_PCMCIA0; | 
 | 142 | 	outw(v, HD64461_GPADR); | 
 | 143 |  | 
| Paul Mundt | 0025835 | 2006-01-16 22:14:08 -0800 | [diff] [blame] | 144 | 	outw(HD64461_PCCGCR_VCC0 | HD64461_PCCSCR_VCC1, HD64461_PCC0GCR); | 
 | 145 |  | 
 | 146 | #ifndef CONFIG_HD64461_ENABLER | 
 | 147 | 	outw(HD64461_PCCGCR_VCC0 | HD64461_PCCSCR_VCC1, HD64461_PCC1GCR); | 
 | 148 | #endif | 
 | 149 |  | 
 | 150 | 	sh_dac_output(0, DAC_SPEAKER_VOLUME); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | 	sh_dac_disable(DAC_SPEAKER_VOLUME); | 
| Paul Mundt | 0025835 | 2006-01-16 22:14:08 -0800 | [diff] [blame] | 152 | 	v8 = ctrl_inb(DACR); | 
 | 153 | 	v8 &= ~DACR_DAE; | 
 | 154 | 	ctrl_outb(v8,DACR); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 |  | 
| Andriy Skulysh | 3aa770e | 2006-09-27 16:20:22 +0900 | [diff] [blame] | 156 | 	v8 = ctrl_inb(SCPDR); | 
 | 157 | 	v8 |= SCPDR_TS_SCAN_X | SCPDR_TS_SCAN_Y; | 
 | 158 | 	v8 &= ~SCPDR_TS_SCAN_ENABLE; | 
 | 159 | 	ctrl_outb(v8, SCPDR); | 
 | 160 |  | 
 | 161 | 	v = ctrl_inw(SCPCR); | 
 | 162 | 	v &= ~SCPCR_TS_MASK; | 
 | 163 | 	v |= SCPCR_TS_ENABLE; | 
 | 164 | 	ctrl_outw(v, SCPCR); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | } | 
| Kristoffer Ericson | 34a780a | 2007-04-10 07:45:08 +0900 | [diff] [blame] | 166 | device_initcall(hp6xx_devices_setup); | 
| Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 167 |  | 
| Paul Mundt | 82f81f4 | 2007-05-15 15:19:34 +0900 | [diff] [blame] | 168 | static struct sh_machine_vector mv_hp6xx __initmv = { | 
| Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 169 | 	.mv_name = "hp6xx", | 
 | 170 | 	.mv_setup = hp6xx_setup, | 
| Kristoffer Ericson | aedb598 | 2007-09-12 11:35:55 +0900 | [diff] [blame] | 171 | 	/* IRQ's : CPU(64) + CCHIP(16) + FREE_TO_USE(6) */ | 
 | 172 | 	.mv_nr_irqs = HD64461_IRQBASE + HD64461_IRQ_NUM + 6, | 
| Kristoffer Ericson | aedb598 | 2007-09-12 11:35:55 +0900 | [diff] [blame] | 173 | 	/* Enable IRQ0 -> IRQ3 in IRQ_MODE */ | 
 | 174 | 	.mv_init_irq = hp6xx_init_irq, | 
| Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 175 | }; |