blob: f1147caebacf020e6933b1069b962f1bc2a0cfca [file] [log] [blame]
kogiidena94c0fa52006-09-27 14:53:35 +09001/*
2 * arch/sh/boards/landisk/setup.c
3 *
kogiidena94c0fa52006-09-27 14:53:35 +09004 * I-O DATA Device, Inc. LANDISK Support.
5 *
kogiidena00e8c492007-03-19 16:24:12 +09006 * Copyright (C) 2000 Kazumoto Kojima
7 * Copyright (C) 2002 Paul Mundt
8 * Copylight (C) 2002 Atom Create Engineering Co., Ltd.
9 * Copyright (C) 2005-2007 kogiidena
Paul Mundtd7cdc9e2006-09-27 15:16:42 +090010 *
11 * This file is subject to the terms and conditions of the GNU General Public
12 * License. See the file "COPYING" in the main directory of this archive
13 * for more details.
kogiidena94c0fa52006-09-27 14:53:35 +090014 */
kogiidena94c0fa52006-09-27 14:53:35 +090015#include <linux/init.h>
kogiidena00e8c492007-03-19 16:24:12 +090016#include <linux/platform_device.h>
Jeff Garzik0a87e3e2008-02-01 18:02:30 -050017#include <linux/ata_platform.h>
kogiidena94c0fa52006-09-27 14:53:35 +090018#include <linux/pm.h>
Paul Mundtd7cdc9e2006-09-27 15:16:42 +090019#include <linux/mm.h>
kogiidena94c0fa52006-09-27 14:53:35 +090020#include <asm/machvec.h>
Paul Mundt0764bff2008-07-29 22:10:01 +090021#include <mach-landisk/mach/iodata_landisk.h>
Paul Mundtd7cdc9e2006-09-27 15:16:42 +090022#include <asm/io.h>
kogiidena94c0fa52006-09-27 14:53:35 +090023
kogiidena94c0fa52006-09-27 14:53:35 +090024static void landisk_power_off(void)
25{
Nobuhiro Iwamatsueee76312011-03-28 00:50:01 +000026 __raw_writeb(0x01, PA_SHUTDOWN);
kogiidena94c0fa52006-09-27 14:53:35 +090027}
28
kogiidena00e8c492007-03-19 16:24:12 +090029static struct resource cf_ide_resources[3];
Paul Mundtd7cdc9e2006-09-27 15:16:42 +090030
kogiidena00e8c492007-03-19 16:24:12 +090031static struct pata_platform_info pata_info = {
32 .ioport_shift = 1,
33};
Paul Mundtd7cdc9e2006-09-27 15:16:42 +090034
kogiidena00e8c492007-03-19 16:24:12 +090035static struct platform_device cf_ide_device = {
36 .name = "pata_platform",
37 .id = -1,
38 .num_resources = ARRAY_SIZE(cf_ide_resources),
39 .resource = cf_ide_resources,
40 .dev = {
41 .platform_data = &pata_info,
42 },
43};
kogiidena94c0fa52006-09-27 14:53:35 +090044
kogiidenaad47c122007-05-12 20:24:15 +090045static struct platform_device rtc_device = {
46 .name = "rs5c313",
47 .id = -1,
48};
49
kogiidena00e8c492007-03-19 16:24:12 +090050static struct platform_device *landisk_devices[] __initdata = {
51 &cf_ide_device,
kogiidenaad47c122007-05-12 20:24:15 +090052 &rtc_device,
kogiidena00e8c492007-03-19 16:24:12 +090053};
kogiidena94c0fa52006-09-27 14:53:35 +090054
kogiidena00e8c492007-03-19 16:24:12 +090055static int __init landisk_devices_setup(void)
kogiidena94c0fa52006-09-27 14:53:35 +090056{
57 pgprot_t prot;
kogiidena00e8c492007-03-19 16:24:12 +090058 unsigned long paddrbase;
59 void *cf_ide_base;
kogiidena94c0fa52006-09-27 14:53:35 +090060
61 /* open I/O area window */
62 paddrbase = virt_to_phys((void *)PA_AREA5_IO);
kogiidena94c0fa52006-09-27 14:53:35 +090063 prot = PAGE_KERNEL_PCC(1, _PAGE_PCC_IO16);
Paul Mundtf33609342010-01-19 13:55:41 +090064 cf_ide_base = ioremap_prot(paddrbase, PAGE_SIZE, pgprot_val(prot));
kogiidena00e8c492007-03-19 16:24:12 +090065 if (!cf_ide_base) {
kogiidena94c0fa52006-09-27 14:53:35 +090066 printk("allocate_cf_area : can't open CF I/O window!\n");
67 return -ENOMEM;
68 }
69
kogiidena00e8c492007-03-19 16:24:12 +090070 /* IDE cmd address : 0x1f0-0x1f7 and 0x3f6 */
71 cf_ide_resources[0].start = (unsigned long)cf_ide_base + 0x40;
72 cf_ide_resources[0].end = (unsigned long)cf_ide_base + 0x40 + 0x0f;
73 cf_ide_resources[0].flags = IORESOURCE_IO;
74 cf_ide_resources[1].start = (unsigned long)cf_ide_base + 0x2c;
75 cf_ide_resources[1].end = (unsigned long)cf_ide_base + 0x2c + 0x03;
76 cf_ide_resources[1].flags = IORESOURCE_IO;
77 cf_ide_resources[2].start = IRQ_FATA;
78 cf_ide_resources[2].flags = IORESOURCE_IRQ;
kogiidena94c0fa52006-09-27 14:53:35 +090079
kogiidena00e8c492007-03-19 16:24:12 +090080 return platform_add_devices(landisk_devices,
81 ARRAY_SIZE(landisk_devices));
kogiidena94c0fa52006-09-27 14:53:35 +090082}
83
Nobuhiro Iwamatsu95d210c2011-01-07 03:02:15 +000084device_initcall(landisk_devices_setup);
kogiidena00e8c492007-03-19 16:24:12 +090085
Paul Mundt2c7834a2006-09-27 18:17:31 +090086static void __init landisk_setup(char **cmdline_p)
87{
Nobuhiro Iwamatsueee76312011-03-28 00:50:01 +000088 /* LED ON */
Paul Mundt9d56dd32010-01-26 12:58:40 +090089 __raw_writeb(__raw_readb(PA_LED) | 0x03, PA_LED);
Paul Mundt2c7834a2006-09-27 18:17:31 +090090
91 printk(KERN_INFO "I-O DATA DEVICE, INC. \"LANDISK Series\" support.\n");
Paul Mundt2c7834a2006-09-27 18:17:31 +090092 pm_power_off = landisk_power_off;
93}
94
95/*
96 * The Machine Vector
97 */
Paul Mundt82f81f42007-05-15 15:19:34 +090098static struct sh_machine_vector mv_landisk __initmv = {
Paul Mundt2c7834a2006-09-27 18:17:31 +090099 .mv_name = "LANDISK",
100 .mv_setup = landisk_setup,
Paul Mundt2c7834a2006-09-27 18:17:31 +0900101 .mv_init_irq = init_landisk_IRQ,
Paul Mundt2c7834a2006-09-27 18:17:31 +0900102};