blob: 8f305b36358ba4912ea6c9bf2deb2fd017969421 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Uwe Zeisbergerf30c2262006-10-03 23:01:26 +02002 * linux/arch/sh/boards/hp6xx/setup.c
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
4 * Copyright (C) 2002 Andriy Skulysh
Kristoffer Ericson34a780a2007-04-10 07:45:08 +09005 * Copyright (C) 2007 Kristoffer Ericson <Kristoffer_e1@hotmail.com>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 *
7 * May be copied or modified under the terms of the GNU General Public
8 * License. See linux/COPYING for more information.
9 *
Kristoffer Ericsonaedb5982007-09-12 11:35:55 +090010 * Setup code for HP620/HP660/HP680/HP690 (internal peripherials only)
Linus Torvalds1da177e2005-04-16 15:20:36 -070011 */
Paul Mundte5723e02006-09-27 17:38:11 +090012#include <linux/types.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <linux/init.h>
Kristoffer Ericson34a780a2007-04-10 07:45:08 +090014#include <linux/platform_device.h>
Paul Mundt604437f2009-01-09 15:11:58 +090015#include <linux/irq.h>
Paul Mundt00258352006-01-16 22:14:08 -080016#include <asm/hd64461.h>
Paul Mundte5723e02006-09-27 17:38:11 +090017#include <asm/io.h>
Paul Mundt7639a452008-10-20 13:02:48 +090018#include <mach/hp6xx.h>
Paul Mundtf15cbe62008-07-29 08:09:44 +090019#include <cpu/dac.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
Andriy Skulysh3aa770e2006-09-27 16:20:22 +090021#define SCPCR 0xa4000116
Kristoffer Ericsonaedb5982007-09-12 11:35:55 +090022#define SCPDR 0xa4000136
Andriy Skulysh3aa770e2006-09-27 16:20:22 +090023
Kristoffer Ericson34a780a2007-04-10 07:45:08 +090024/* CF Slot */
25static struct resource cf_ide_resources[] = {
26 [0] = {
27 .start = 0x15000000 + 0x1f0,
28 .end = 0x15000000 + 0x1f0 + 0x08 - 0x01,
29 .flags = IORESOURCE_MEM,
30 },
31 [1] = {
32 .start = 0x15000000 + 0x1fe,
33 .end = 0x15000000 + 0x1fe + 0x01,
34 .flags = IORESOURCE_MEM,
35 },
36 [2] = {
Kristoffer Ericsonc9eaaa92007-09-11 12:51:02 +090037 .start = 77,
Kristoffer Ericson34a780a2007-04-10 07:45:08 +090038 .flags = IORESOURCE_IRQ,
39 },
40};
41
42static struct platform_device cf_ide_device = {
43 .name = "pata_platform",
44 .id = -1,
45 .num_resources = ARRAY_SIZE(cf_ide_resources),
46 .resource = cf_ide_resources,
47};
48
Kristoffer Ericsonaedb5982007-09-12 11:35:55 +090049static struct platform_device jornadakbd_device = {
50 .name = "jornada680_kbd",
51 .id = -1,
Kristoffer Ericson34a780a2007-04-10 07:45:08 +090052};
53
Kristoffer Ericsonaedb5982007-09-12 11:35:55 +090054static struct platform_device *hp6xx_devices[] __initdata = {
55 &cf_ide_device,
56 &jornadakbd_device,
57};
58
59static void __init hp6xx_init_irq(void)
60{
61 /* Gets touchscreen and powerbutton IRQ working */
Paul Mundt2f0ae552007-09-13 16:36:52 +090062 plat_irq_setup_pins(IRQ_MODE_IRQ);
Kristoffer Ericsonaedb5982007-09-12 11:35:55 +090063}
64
Kristoffer Ericson34a780a2007-04-10 07:45:08 +090065static int __init hp6xx_devices_setup(void)
66{
67 return platform_add_devices(hp6xx_devices, ARRAY_SIZE(hp6xx_devices));
68}
69
Paul Mundt2c7834a2006-09-27 18:17:31 +090070static void __init hp6xx_setup(char **cmdline_p)
Linus Torvalds1da177e2005-04-16 15:20:36 -070071{
Paul Mundt00258352006-01-16 22:14:08 -080072 u8 v8;
Linus Torvalds1da177e2005-04-16 15:20:36 -070073 u16 v;
Andriy Skulysh3aa770e2006-09-27 16:20:22 +090074
Linus Torvalds1da177e2005-04-16 15:20:36 -070075 v = inw(HD64461_STBCR);
Kristoffer Ericsonaedb5982007-09-12 11:35:55 +090076 v |= HD64461_STBCR_SURTST | HD64461_STBCR_SIRST |
77 HD64461_STBCR_STM1ST | HD64461_STBCR_STM0ST |
78 HD64461_STBCR_SAFEST | HD64461_STBCR_SPC0ST |
79 HD64461_STBCR_SMIAST | HD64461_STBCR_SAFECKE_OST|
80 HD64461_STBCR_SAFECKE_IST;
Paul Mundt00258352006-01-16 22:14:08 -080081#ifndef CONFIG_HD64461_ENABLER
82 v |= HD64461_STBCR_SPC1ST;
83#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070084 outw(v, HD64461_STBCR);
85 v = inw(HD64461_GPADR);
86 v |= HD64461_GPADR_SPEAKER | HD64461_GPADR_PCMCIA0;
87 outw(v, HD64461_GPADR);
88
Paul Mundt00258352006-01-16 22:14:08 -080089 outw(HD64461_PCCGCR_VCC0 | HD64461_PCCSCR_VCC1, HD64461_PCC0GCR);
90
91#ifndef CONFIG_HD64461_ENABLER
92 outw(HD64461_PCCGCR_VCC0 | HD64461_PCCSCR_VCC1, HD64461_PCC1GCR);
93#endif
94
95 sh_dac_output(0, DAC_SPEAKER_VOLUME);
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 sh_dac_disable(DAC_SPEAKER_VOLUME);
Paul Mundt00258352006-01-16 22:14:08 -080097 v8 = ctrl_inb(DACR);
98 v8 &= ~DACR_DAE;
99 ctrl_outb(v8,DACR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100
Andriy Skulysh3aa770e2006-09-27 16:20:22 +0900101 v8 = ctrl_inb(SCPDR);
102 v8 |= SCPDR_TS_SCAN_X | SCPDR_TS_SCAN_Y;
103 v8 &= ~SCPDR_TS_SCAN_ENABLE;
104 ctrl_outb(v8, SCPDR);
105
106 v = ctrl_inw(SCPCR);
107 v &= ~SCPCR_TS_MASK;
108 v |= SCPCR_TS_ENABLE;
109 ctrl_outw(v, SCPCR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110}
Kristoffer Ericson34a780a2007-04-10 07:45:08 +0900111device_initcall(hp6xx_devices_setup);
Paul Mundt2c7834a2006-09-27 18:17:31 +0900112
Paul Mundt82f81f42007-05-15 15:19:34 +0900113static struct sh_machine_vector mv_hp6xx __initmv = {
Paul Mundt2c7834a2006-09-27 18:17:31 +0900114 .mv_name = "hp6xx",
115 .mv_setup = hp6xx_setup,
Kristoffer Ericsonaedb5982007-09-12 11:35:55 +0900116 /* IRQ's : CPU(64) + CCHIP(16) + FREE_TO_USE(6) */
117 .mv_nr_irqs = HD64461_IRQBASE + HD64461_IRQ_NUM + 6,
Kristoffer Ericsonaedb5982007-09-12 11:35:55 +0900118 /* Enable IRQ0 -> IRQ3 in IRQ_MODE */
119 .mv_init_irq = hp6xx_init_irq,
Paul Mundt2c7834a2006-09-27 18:17:31 +0900120};