18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * linux/arch/sh/boards/se/7780/setup.c
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 2006,2007  Nobuhiro Iwamatsu
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Hitachi UL SolutionEngine 7780 Support.
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci#include <linux/init.h>
108c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
118c2ecf20Sopenharmony_ci#include <asm/machvec.h>
128c2ecf20Sopenharmony_ci#include <mach-se/mach/se7780.h>
138c2ecf20Sopenharmony_ci#include <asm/io.h>
148c2ecf20Sopenharmony_ci#include <asm/heartbeat.h>
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci/* Heartbeat */
178c2ecf20Sopenharmony_cistatic struct resource heartbeat_resource = {
188c2ecf20Sopenharmony_ci	.start  = PA_LED,
198c2ecf20Sopenharmony_ci	.end    = PA_LED,
208c2ecf20Sopenharmony_ci	.flags  = IORESOURCE_MEM | IORESOURCE_MEM_16BIT,
218c2ecf20Sopenharmony_ci};
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_cistatic struct platform_device heartbeat_device = {
248c2ecf20Sopenharmony_ci	.name           = "heartbeat",
258c2ecf20Sopenharmony_ci	.id             = -1,
268c2ecf20Sopenharmony_ci	.num_resources  = 1,
278c2ecf20Sopenharmony_ci	.resource       = &heartbeat_resource,
288c2ecf20Sopenharmony_ci};
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci/* SMC91x */
318c2ecf20Sopenharmony_cistatic struct resource smc91x_eth_resources[] = {
328c2ecf20Sopenharmony_ci	[0] = {
338c2ecf20Sopenharmony_ci		.name   = "smc91x-regs" ,
348c2ecf20Sopenharmony_ci		.start  = PA_LAN + 0x300,
358c2ecf20Sopenharmony_ci		.end    = PA_LAN + 0x300 + 0x10 ,
368c2ecf20Sopenharmony_ci		.flags  = IORESOURCE_MEM,
378c2ecf20Sopenharmony_ci	},
388c2ecf20Sopenharmony_ci	[1] = {
398c2ecf20Sopenharmony_ci		.start  = SMC_IRQ,
408c2ecf20Sopenharmony_ci		.end    = SMC_IRQ,
418c2ecf20Sopenharmony_ci		.flags  = IORESOURCE_IRQ,
428c2ecf20Sopenharmony_ci	},
438c2ecf20Sopenharmony_ci};
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_cistatic struct platform_device smc91x_eth_device = {
468c2ecf20Sopenharmony_ci	.name           = "smc91x",
478c2ecf20Sopenharmony_ci	.id             = 0,
488c2ecf20Sopenharmony_ci	.dev = {
498c2ecf20Sopenharmony_ci		.dma_mask               = NULL,         /* don't use dma */
508c2ecf20Sopenharmony_ci		.coherent_dma_mask      = 0xffffffff,
518c2ecf20Sopenharmony_ci	},
528c2ecf20Sopenharmony_ci	.num_resources  = ARRAY_SIZE(smc91x_eth_resources),
538c2ecf20Sopenharmony_ci	.resource       = smc91x_eth_resources,
548c2ecf20Sopenharmony_ci};
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_cistatic struct platform_device *se7780_devices[] __initdata = {
578c2ecf20Sopenharmony_ci	&heartbeat_device,
588c2ecf20Sopenharmony_ci	&smc91x_eth_device,
598c2ecf20Sopenharmony_ci};
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_cistatic int __init se7780_devices_setup(void)
628c2ecf20Sopenharmony_ci{
638c2ecf20Sopenharmony_ci	return platform_add_devices(se7780_devices,
648c2ecf20Sopenharmony_ci		ARRAY_SIZE(se7780_devices));
658c2ecf20Sopenharmony_ci}
668c2ecf20Sopenharmony_cidevice_initcall(se7780_devices_setup);
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci#define GPIO_PHCR        0xFFEA000E
698c2ecf20Sopenharmony_ci#define GPIO_PMSELR      0xFFEA0080
708c2ecf20Sopenharmony_ci#define GPIO_PECR        0xFFEA0008
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_cistatic void __init se7780_setup(char **cmdline_p)
738c2ecf20Sopenharmony_ci{
748c2ecf20Sopenharmony_ci	/* "SH-Linux" on LED Display */
758c2ecf20Sopenharmony_ci	__raw_writew( 'S' , PA_LED_DISP + (DISP_SEL0_ADDR << 1) );
768c2ecf20Sopenharmony_ci	__raw_writew( 'H' , PA_LED_DISP + (DISP_SEL1_ADDR << 1) );
778c2ecf20Sopenharmony_ci	__raw_writew( '-' , PA_LED_DISP + (DISP_SEL2_ADDR << 1) );
788c2ecf20Sopenharmony_ci	__raw_writew( 'L' , PA_LED_DISP + (DISP_SEL3_ADDR << 1) );
798c2ecf20Sopenharmony_ci	__raw_writew( 'i' , PA_LED_DISP + (DISP_SEL4_ADDR << 1) );
808c2ecf20Sopenharmony_ci	__raw_writew( 'n' , PA_LED_DISP + (DISP_SEL5_ADDR << 1) );
818c2ecf20Sopenharmony_ci	__raw_writew( 'u' , PA_LED_DISP + (DISP_SEL6_ADDR << 1) );
828c2ecf20Sopenharmony_ci	__raw_writew( 'x' , PA_LED_DISP + (DISP_SEL7_ADDR << 1) );
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci	printk(KERN_INFO "Hitachi UL Solutions Engine 7780SE03 support.\n");
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci	/*
878c2ecf20Sopenharmony_ci	 * PCI REQ/GNT setting
888c2ecf20Sopenharmony_ci	 *   REQ0/GNT0 -> USB
898c2ecf20Sopenharmony_ci	 *   REQ1/GNT1 -> PC Card
908c2ecf20Sopenharmony_ci	 *   REQ2/GNT2 -> Serial ATA
918c2ecf20Sopenharmony_ci	 *   REQ3/GNT3 -> PCI slot
928c2ecf20Sopenharmony_ci	 */
938c2ecf20Sopenharmony_ci	__raw_writew(0x0213, FPGA_REQSEL);
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci	/* GPIO setting */
968c2ecf20Sopenharmony_ci	__raw_writew(0x0000, GPIO_PECR);
978c2ecf20Sopenharmony_ci	__raw_writew(__raw_readw(GPIO_PHCR)&0xfff3, GPIO_PHCR);
988c2ecf20Sopenharmony_ci	__raw_writew(0x0c00, GPIO_PMSELR);
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ci	/* iVDR Power ON */
1018c2ecf20Sopenharmony_ci	__raw_writew(0x0001, FPGA_IVDRPW);
1028c2ecf20Sopenharmony_ci}
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci/*
1058c2ecf20Sopenharmony_ci * The Machine Vector
1068c2ecf20Sopenharmony_ci */
1078c2ecf20Sopenharmony_cistatic struct sh_machine_vector mv_se7780 __initmv = {
1088c2ecf20Sopenharmony_ci	.mv_name                = "Solution Engine 7780" ,
1098c2ecf20Sopenharmony_ci	.mv_setup               = se7780_setup ,
1108c2ecf20Sopenharmony_ci	.mv_init_irq		= init_se7780_IRQ,
1118c2ecf20Sopenharmony_ci};
112