| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 | /* * arch/arm/mach-orion5x/common.c * * Core functions for Marvell Orion 5x SoCs * * Maintainer: Tzachi Perelstein <tzachi@marvell.com> * * This file is licensed under the terms of the GNU General Public * License version 2.  This program is licensed "as is" without any * warranty of any kind, whether express or implied. */#include <linux/kernel.h>#include <linux/init.h>#include <linux/platform_device.h>#include <linux/dma-mapping.h>#include <linux/serial_8250.h>#include <linux/mv643xx_i2c.h>#include <linux/ata_platform.h>#include <linux/delay.h>#include <linux/clk-provider.h>#include <net/dsa.h>#include <asm/page.h>#include <asm/setup.h>#include <asm/system_misc.h>#include <asm/timex.h>#include <asm/mach/arch.h>#include <asm/mach/map.h>#include <asm/mach/time.h>#include <mach/bridge-regs.h>#include <mach/hardware.h>#include <mach/orion5x.h>#include <linux/platform_data/mtd-orion_nand.h>#include <linux/platform_data/usb-ehci-orion.h>#include <plat/time.h>#include <plat/common.h>#include <plat/addr-map.h>#include "common.h"/***************************************************************************** * I/O Address Mapping ****************************************************************************/static struct map_desc orion5x_io_desc[] __initdata = {	{		.virtual	= (unsigned long) ORION5X_REGS_VIRT_BASE,		.pfn		= __phys_to_pfn(ORION5X_REGS_PHYS_BASE),		.length		= ORION5X_REGS_SIZE,		.type		= MT_DEVICE,	}, {		.virtual	= (unsigned long) ORION5X_PCIE_WA_VIRT_BASE,		.pfn		= __phys_to_pfn(ORION5X_PCIE_WA_PHYS_BASE),		.length		= ORION5X_PCIE_WA_SIZE,		.type		= MT_DEVICE,	},};void __init orion5x_map_io(void){	iotable_init(orion5x_io_desc, ARRAY_SIZE(orion5x_io_desc));}/***************************************************************************** * CLK tree ****************************************************************************/static struct clk *tclk;void __init clk_init(void){	tclk = clk_register_fixed_rate(NULL, "tclk", NULL, CLK_IS_ROOT,				       orion5x_tclk);	orion_clkdev_init(tclk);}/***************************************************************************** * EHCI0 ****************************************************************************/void __init orion5x_ehci0_init(void){	orion_ehci_init(ORION5X_USB0_PHYS_BASE, IRQ_ORION5X_USB0_CTRL,			EHCI_PHY_ORION);}/***************************************************************************** * EHCI1 ****************************************************************************/void __init orion5x_ehci1_init(void){	orion_ehci_1_init(ORION5X_USB1_PHYS_BASE, IRQ_ORION5X_USB1_CTRL);}/***************************************************************************** * GE00 ****************************************************************************/void __init orion5x_eth_init(struct mv643xx_eth_platform_data *eth_data){	orion_ge00_init(eth_data,			ORION5X_ETH_PHYS_BASE, IRQ_ORION5X_ETH_SUM,			IRQ_ORION5X_ETH_ERR,			MV643XX_TX_CSUM_DEFAULT_LIMIT);}/***************************************************************************** * Ethernet switch ****************************************************************************/void __init orion5x_eth_switch_init(struct dsa_platform_data *d, int irq){	orion_ge00_switch_init(d, irq);}/***************************************************************************** * I2C ****************************************************************************/void __init orion5x_i2c_init(void){	orion_i2c_init(I2C_PHYS_BASE, IRQ_ORION5X_I2C, 8);}/***************************************************************************** * SATA ****************************************************************************/void __init orion5x_sata_init(struct mv_sata_platform_data *sata_data){	orion_sata_init(sata_data, ORION5X_SATA_PHYS_BASE, IRQ_ORION5X_SATA);}/***************************************************************************** * SPI ****************************************************************************/void __init orion5x_spi_init(){	orion_spi_init(SPI_PHYS_BASE);}/***************************************************************************** * UART0 ****************************************************************************/void __init orion5x_uart0_init(void){	orion_uart0_init(UART0_VIRT_BASE, UART0_PHYS_BASE,			 IRQ_ORION5X_UART0, tclk);}/***************************************************************************** * UART1 ****************************************************************************/void __init orion5x_uart1_init(void){	orion_uart1_init(UART1_VIRT_BASE, UART1_PHYS_BASE,			 IRQ_ORION5X_UART1, tclk);}/***************************************************************************** * XOR engine ****************************************************************************/void __init orion5x_xor_init(void){	orion_xor0_init(ORION5X_XOR_PHYS_BASE,			ORION5X_XOR_PHYS_BASE + 0x200,			IRQ_ORION5X_XOR0, IRQ_ORION5X_XOR1);}/***************************************************************************** * Cryptographic Engines and Security Accelerator (CESA) ****************************************************************************/static void __init orion5x_crypto_init(void){	orion5x_setup_sram_win();	orion_crypto_init(ORION5X_CRYPTO_PHYS_BASE, ORION5X_SRAM_PHYS_BASE,			  SZ_8K, IRQ_ORION5X_CESA);}/***************************************************************************** * Watchdog ****************************************************************************/void __init orion5x_wdt_init(void){	orion_wdt_init();}/***************************************************************************** * Time handling ****************************************************************************/void __init orion5x_init_early(void){	orion_time_set_base(TIMER_VIRT_BASE);	/*	 * Some Orion5x devices allocate their coherent buffers from atomic	 * context. Increase size of atomic coherent pool to make sure such	 * the allocations won't fail.	 */	init_dma_coherent_pool_size(SZ_1M);}int orion5x_tclk;int __init orion5x_find_tclk(void){	u32 dev, rev;	orion5x_pcie_id(&dev, &rev);	if (dev == MV88F6183_DEV_ID &&	    (readl(MPP_RESET_SAMPLE) & 0x00000200) == 0)		return 133333333;	return 166666667;}static void __init orion5x_timer_init(void){	orion5x_tclk = orion5x_find_tclk();	orion_time_init(ORION5X_BRIDGE_VIRT_BASE, BRIDGE_INT_TIMER1_CLR,			IRQ_ORION5X_BRIDGE, orion5x_tclk);}struct sys_timer orion5x_timer = {	.init = orion5x_timer_init,};/***************************************************************************** * General ****************************************************************************//* * Identify device ID and rev from PCIe configuration header space '0'. */void __init orion5x_id(u32 *dev, u32 *rev, char **dev_name){	orion5x_pcie_id(dev, rev);
 |