18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * linux/arch/sh/boards/se/7721/setup.c
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 2008 Renesas Solutions Corp.
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Hitachi UL SolutionEngine 7721 Support.
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci#include <linux/init.h>
108c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
118c2ecf20Sopenharmony_ci#include <mach-se/mach/se7721.h>
128c2ecf20Sopenharmony_ci#include <mach-se/mach/mrshpc.h>
138c2ecf20Sopenharmony_ci#include <asm/machvec.h>
148c2ecf20Sopenharmony_ci#include <asm/io.h>
158c2ecf20Sopenharmony_ci#include <asm/heartbeat.h>
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_cistatic unsigned char heartbeat_bit_pos[] = { 8, 9, 10, 11, 12, 13, 14, 15 };
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_cistatic struct heartbeat_data heartbeat_data = {
208c2ecf20Sopenharmony_ci	.bit_pos	= heartbeat_bit_pos,
218c2ecf20Sopenharmony_ci	.nr_bits	= ARRAY_SIZE(heartbeat_bit_pos),
228c2ecf20Sopenharmony_ci};
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_cistatic struct resource heartbeat_resource = {
258c2ecf20Sopenharmony_ci	.start	= PA_LED,
268c2ecf20Sopenharmony_ci	.end	= PA_LED,
278c2ecf20Sopenharmony_ci	.flags	= IORESOURCE_MEM | IORESOURCE_MEM_16BIT,
288c2ecf20Sopenharmony_ci};
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_cistatic struct platform_device heartbeat_device = {
318c2ecf20Sopenharmony_ci	.name		= "heartbeat",
328c2ecf20Sopenharmony_ci	.id		= -1,
338c2ecf20Sopenharmony_ci	.dev	= {
348c2ecf20Sopenharmony_ci		.platform_data	= &heartbeat_data,
358c2ecf20Sopenharmony_ci	},
368c2ecf20Sopenharmony_ci	.num_resources	= 1,
378c2ecf20Sopenharmony_ci	.resource	= &heartbeat_resource,
388c2ecf20Sopenharmony_ci};
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_cistatic struct resource cf_ide_resources[] = {
418c2ecf20Sopenharmony_ci	[0] = {
428c2ecf20Sopenharmony_ci		.start	= PA_MRSHPC_IO + 0x1f0,
438c2ecf20Sopenharmony_ci		.end	= PA_MRSHPC_IO + 0x1f0 + 8 ,
448c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IO,
458c2ecf20Sopenharmony_ci	},
468c2ecf20Sopenharmony_ci	[1] = {
478c2ecf20Sopenharmony_ci		.start	= PA_MRSHPC_IO + 0x1f0 + 0x206,
488c2ecf20Sopenharmony_ci		.end	= PA_MRSHPC_IO + 0x1f0 + 8 + 0x206 + 8,
498c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IO,
508c2ecf20Sopenharmony_ci	},
518c2ecf20Sopenharmony_ci	[2] = {
528c2ecf20Sopenharmony_ci		.start  = MRSHPC_IRQ0,
538c2ecf20Sopenharmony_ci		.flags  = IORESOURCE_IRQ,
548c2ecf20Sopenharmony_ci	},
558c2ecf20Sopenharmony_ci};
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_cistatic struct platform_device cf_ide_device = {
588c2ecf20Sopenharmony_ci	.name		= "pata_platform",
598c2ecf20Sopenharmony_ci	.id		= -1,
608c2ecf20Sopenharmony_ci	.num_resources	= ARRAY_SIZE(cf_ide_resources),
618c2ecf20Sopenharmony_ci	.resource	= cf_ide_resources,
628c2ecf20Sopenharmony_ci};
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_cistatic struct platform_device *se7721_devices[] __initdata = {
658c2ecf20Sopenharmony_ci	&cf_ide_device,
668c2ecf20Sopenharmony_ci	&heartbeat_device
678c2ecf20Sopenharmony_ci};
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_cistatic int __init se7721_devices_setup(void)
708c2ecf20Sopenharmony_ci{
718c2ecf20Sopenharmony_ci	mrshpc_setup_windows();
728c2ecf20Sopenharmony_ci	return platform_add_devices(se7721_devices, ARRAY_SIZE(se7721_devices));
738c2ecf20Sopenharmony_ci}
748c2ecf20Sopenharmony_cidevice_initcall(se7721_devices_setup);
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_cistatic void __init se7721_setup(char **cmdline_p)
778c2ecf20Sopenharmony_ci{
788c2ecf20Sopenharmony_ci	/* for USB */
798c2ecf20Sopenharmony_ci	__raw_writew(0x0000, 0xA405010C);	/* PGCR */
808c2ecf20Sopenharmony_ci	__raw_writew(0x0000, 0xA405010E);	/* PHCR */
818c2ecf20Sopenharmony_ci	__raw_writew(0x00AA, 0xA4050118);	/* PPCR */
828c2ecf20Sopenharmony_ci	__raw_writew(0x0000, 0xA4050124);	/* PSELA */
838c2ecf20Sopenharmony_ci}
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci/*
868c2ecf20Sopenharmony_ci * The Machine Vector
878c2ecf20Sopenharmony_ci */
888c2ecf20Sopenharmony_cistruct sh_machine_vector mv_se7721 __initmv = {
898c2ecf20Sopenharmony_ci	.mv_name		= "Solution Engine 7721",
908c2ecf20Sopenharmony_ci	.mv_setup		= se7721_setup,
918c2ecf20Sopenharmony_ci	.mv_init_irq		= init_se7721_IRQ,
928c2ecf20Sopenharmony_ci};
93