18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * June 2006 Steve Glendinning <steve.glendinning@shawell.net>
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Polaris-specific resource declaration
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include <linux/init.h>
108c2ecf20Sopenharmony_ci#include <linux/interrupt.h>
118c2ecf20Sopenharmony_ci#include <linux/irq.h>
128c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
138c2ecf20Sopenharmony_ci#include <linux/regulator/fixed.h>
148c2ecf20Sopenharmony_ci#include <linux/regulator/machine.h>
158c2ecf20Sopenharmony_ci#include <linux/smsc911x.h>
168c2ecf20Sopenharmony_ci#include <linux/io.h>
178c2ecf20Sopenharmony_ci#include <asm/irq.h>
188c2ecf20Sopenharmony_ci#include <asm/machvec.h>
198c2ecf20Sopenharmony_ci#include <asm/heartbeat.h>
208c2ecf20Sopenharmony_ci#include <cpu/gpio.h>
218c2ecf20Sopenharmony_ci#include <mach-se/mach/se.h>
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#define BCR2		(0xFFFFFF62)
248c2ecf20Sopenharmony_ci#define WCR2		(0xFFFFFF66)
258c2ecf20Sopenharmony_ci#define AREA5_WAIT_CTRL	(0x1C00)
268c2ecf20Sopenharmony_ci#define WAIT_STATES_10	(0x7)
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci/* Dummy supplies, where voltage doesn't matter */
298c2ecf20Sopenharmony_cistatic struct regulator_consumer_supply dummy_supplies[] = {
308c2ecf20Sopenharmony_ci	REGULATOR_SUPPLY("vddvario", "smsc911x.0"),
318c2ecf20Sopenharmony_ci	REGULATOR_SUPPLY("vdd33a", "smsc911x.0"),
328c2ecf20Sopenharmony_ci};
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_cistatic struct resource smsc911x_resources[] = {
358c2ecf20Sopenharmony_ci	[0] = {
368c2ecf20Sopenharmony_ci		.name		= "smsc911x-memory",
378c2ecf20Sopenharmony_ci		.start		= PA_EXT5,
388c2ecf20Sopenharmony_ci		.end		= PA_EXT5 + 0x1fff,
398c2ecf20Sopenharmony_ci		.flags		= IORESOURCE_MEM,
408c2ecf20Sopenharmony_ci	},
418c2ecf20Sopenharmony_ci	[1] = {
428c2ecf20Sopenharmony_ci		.name		= "smsc911x-irq",
438c2ecf20Sopenharmony_ci		.start		= IRQ0_IRQ,
448c2ecf20Sopenharmony_ci		.end		= IRQ0_IRQ,
458c2ecf20Sopenharmony_ci		.flags		= IORESOURCE_IRQ,
468c2ecf20Sopenharmony_ci	},
478c2ecf20Sopenharmony_ci};
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_cistatic struct smsc911x_platform_config smsc911x_config = {
508c2ecf20Sopenharmony_ci	.irq_polarity	= SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
518c2ecf20Sopenharmony_ci	.irq_type	= SMSC911X_IRQ_TYPE_OPEN_DRAIN,
528c2ecf20Sopenharmony_ci	.flags		= SMSC911X_USE_32BIT,
538c2ecf20Sopenharmony_ci	.phy_interface	= PHY_INTERFACE_MODE_MII,
548c2ecf20Sopenharmony_ci};
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_cistatic struct platform_device smsc911x_device = {
578c2ecf20Sopenharmony_ci	.name		= "smsc911x",
588c2ecf20Sopenharmony_ci	.id		= 0,
598c2ecf20Sopenharmony_ci	.num_resources	= ARRAY_SIZE(smsc911x_resources),
608c2ecf20Sopenharmony_ci	.resource	= smsc911x_resources,
618c2ecf20Sopenharmony_ci	.dev = {
628c2ecf20Sopenharmony_ci		.platform_data = &smsc911x_config,
638c2ecf20Sopenharmony_ci	},
648c2ecf20Sopenharmony_ci};
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_cistatic unsigned char heartbeat_bit_pos[] = { 0, 1, 2, 3 };
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_cistatic struct heartbeat_data heartbeat_data = {
698c2ecf20Sopenharmony_ci	.bit_pos	= heartbeat_bit_pos,
708c2ecf20Sopenharmony_ci	.nr_bits	= ARRAY_SIZE(heartbeat_bit_pos),
718c2ecf20Sopenharmony_ci};
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_cistatic struct resource heartbeat_resource = {
748c2ecf20Sopenharmony_ci	.start	= PORT_PCDR,
758c2ecf20Sopenharmony_ci	.end	= PORT_PCDR,
768c2ecf20Sopenharmony_ci	.flags	= IORESOURCE_MEM | IORESOURCE_MEM_8BIT,
778c2ecf20Sopenharmony_ci};
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_cistatic struct platform_device heartbeat_device = {
808c2ecf20Sopenharmony_ci	.name		= "heartbeat",
818c2ecf20Sopenharmony_ci	.id		= -1,
828c2ecf20Sopenharmony_ci	.dev	= {
838c2ecf20Sopenharmony_ci		.platform_data	= &heartbeat_data,
848c2ecf20Sopenharmony_ci	},
858c2ecf20Sopenharmony_ci	.num_resources	= 1,
868c2ecf20Sopenharmony_ci	.resource	= &heartbeat_resource,
878c2ecf20Sopenharmony_ci};
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_cistatic struct platform_device *polaris_devices[] __initdata = {
908c2ecf20Sopenharmony_ci	&smsc911x_device,
918c2ecf20Sopenharmony_ci	&heartbeat_device,
928c2ecf20Sopenharmony_ci};
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_cistatic int __init polaris_initialise(void)
958c2ecf20Sopenharmony_ci{
968c2ecf20Sopenharmony_ci	u16 wcr, bcr_mask;
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci	printk(KERN_INFO "Configuring Polaris external bus\n");
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ci	regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci	/* Configure area 5 with 2 wait states */
1038c2ecf20Sopenharmony_ci	wcr = __raw_readw(WCR2);
1048c2ecf20Sopenharmony_ci	wcr &= (~AREA5_WAIT_CTRL);
1058c2ecf20Sopenharmony_ci	wcr |= (WAIT_STATES_10 << 10);
1068c2ecf20Sopenharmony_ci	__raw_writew(wcr, WCR2);
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci	/* Configure area 5 for 32-bit access */
1098c2ecf20Sopenharmony_ci	bcr_mask = __raw_readw(BCR2);
1108c2ecf20Sopenharmony_ci	bcr_mask |= 1 << 10;
1118c2ecf20Sopenharmony_ci	__raw_writew(bcr_mask, BCR2);
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_ci	return platform_add_devices(polaris_devices,
1148c2ecf20Sopenharmony_ci				    ARRAY_SIZE(polaris_devices));
1158c2ecf20Sopenharmony_ci}
1168c2ecf20Sopenharmony_ciarch_initcall(polaris_initialise);
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_cistatic struct ipr_data ipr_irq_table[] = {
1198c2ecf20Sopenharmony_ci	/* External IRQs */
1208c2ecf20Sopenharmony_ci	{ IRQ0_IRQ, 0,  0,  1, },	/* IRQ0 */
1218c2ecf20Sopenharmony_ci	{ IRQ1_IRQ, 0,  4,  1, },	/* IRQ1 */
1228c2ecf20Sopenharmony_ci};
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_cistatic unsigned long ipr_offsets[] = {
1258c2ecf20Sopenharmony_ci	INTC_IPRC
1268c2ecf20Sopenharmony_ci};
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_cistatic struct ipr_desc ipr_irq_desc = {
1298c2ecf20Sopenharmony_ci	.ipr_offsets	= ipr_offsets,
1308c2ecf20Sopenharmony_ci	.nr_offsets	= ARRAY_SIZE(ipr_offsets),
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci	.ipr_data	= ipr_irq_table,
1338c2ecf20Sopenharmony_ci	.nr_irqs	= ARRAY_SIZE(ipr_irq_table),
1348c2ecf20Sopenharmony_ci	.chip = {
1358c2ecf20Sopenharmony_ci		.name	= "sh7709-ext",
1368c2ecf20Sopenharmony_ci	},
1378c2ecf20Sopenharmony_ci};
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_cistatic void __init init_polaris_irq(void)
1408c2ecf20Sopenharmony_ci{
1418c2ecf20Sopenharmony_ci	/* Disable all interrupts */
1428c2ecf20Sopenharmony_ci	__raw_writew(0, BCR_ILCRA);
1438c2ecf20Sopenharmony_ci	__raw_writew(0, BCR_ILCRB);
1448c2ecf20Sopenharmony_ci	__raw_writew(0, BCR_ILCRC);
1458c2ecf20Sopenharmony_ci	__raw_writew(0, BCR_ILCRD);
1468c2ecf20Sopenharmony_ci	__raw_writew(0, BCR_ILCRE);
1478c2ecf20Sopenharmony_ci	__raw_writew(0, BCR_ILCRF);
1488c2ecf20Sopenharmony_ci	__raw_writew(0, BCR_ILCRG);
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ci	register_ipr_controller(&ipr_irq_desc);
1518c2ecf20Sopenharmony_ci}
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_cistatic struct sh_machine_vector mv_polaris __initmv = {
1548c2ecf20Sopenharmony_ci	.mv_name		= "Polaris",
1558c2ecf20Sopenharmony_ci	.mv_init_irq		= init_polaris_irq,
1568c2ecf20Sopenharmony_ci};
157