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