Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f3a4ce95 authored by Dmitri Vorobiev's avatar Dmitri Vorobiev Committed by Ralf Baechle
Browse files

[MIPS] Malta: check the PCI clock frequency in a separate function



This patch adds a separate short and sweet function to check the
PCI clock frequency. This is to improve readability of the Malta
setup code.

Along the way, a couple of coding style violations are fixed.

No functional changes introduced.

Signed-off-by: default avatarDmitri Vorobiev <dmitri.vorobiev@gmail.com>
Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent 8216d348
Loading
Loading
Loading
Loading
+25 −18
Original line number Diff line number Diff line
@@ -108,6 +108,30 @@ void __init fd_activate(void)
}
#endif

#ifdef CONFIG_BLK_DEV_IDE
static void __init pci_clock_check(void)
{
	unsigned int __iomem *jmpr_p =
		(unsigned int *) ioremap(MALTA_JMPRS_REG, sizeof(unsigned int));
	int jmpr = (__raw_readl(jmpr_p) >> 2) & 0x07;
	static const int pciclocks[] __initdata = {
		33, 20, 25, 30, 12, 16, 37, 10
	};
	int pciclock = pciclocks[jmpr];
	char *argptr = prom_getcmdline();

	if (pciclock != 33 && !strstr(argptr, "idebus=")) {
		printk(KERN_WARNING "WARNING: PCI clock is %dMHz, "
				"setting idebus\n", pciclock);
		argptr += strlen(argptr);
		sprintf(argptr, " idebus=%d", pciclock);
		if (pciclock < 20 || pciclock > 66)
			printk(KERN_WARNING "WARNING: IDE timing "
					"calculations will be incorrect\n");
	}
}
#endif

void __init plat_mem_setup(void)
{
	unsigned int i;
@@ -171,24 +195,7 @@ void __init plat_mem_setup(void)
#endif

#ifdef CONFIG_BLK_DEV_IDE
	/* Check PCI clock */
	{
		unsigned int __iomem *jmpr_p = (unsigned int *) ioremap(MALTA_JMPRS_REG, sizeof(unsigned int));
		int jmpr = (__raw_readl(jmpr_p) >> 2) & 0x07;
		static const int pciclocks[] __initdata = {
			33, 20, 25, 30, 12, 16, 37, 10
		};
		int pciclock = pciclocks[jmpr];
		char *argptr = prom_getcmdline();

		if (pciclock != 33 && !strstr (argptr, "idebus=")) {
			printk("WARNING: PCI clock is %dMHz, setting idebus\n", pciclock);
			argptr += strlen(argptr);
			sprintf(argptr, " idebus=%d", pciclock);
			if (pciclock < 20 || pciclock > 66)
				printk("WARNING: IDE timing calculations will be incorrect\n");
		}
	}
	pci_clock_check();
#endif
#ifdef CONFIG_BLK_DEV_FD
	fd_activate();