Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * arch/arm/mach-orion5x/rd88f5181l-ge-setup.c
0004  *
0005  * Marvell Orion-VoIP GE Reference Design Setup
0006  */
0007 #include <linux/gpio.h>
0008 #include <linux/kernel.h>
0009 #include <linux/init.h>
0010 #include <linux/platform_device.h>
0011 #include <linux/pci.h>
0012 #include <linux/irq.h>
0013 #include <linux/mtd/physmap.h>
0014 #include <linux/mv643xx_eth.h>
0015 #include <linux/ethtool.h>
0016 #include <linux/i2c.h>
0017 #include <linux/platform_data/dsa.h>
0018 #include <asm/mach-types.h>
0019 #include <asm/mach/arch.h>
0020 #include <asm/mach/pci.h>
0021 #include "common.h"
0022 #include "mpp.h"
0023 #include "orion5x.h"
0024 
0025 /*****************************************************************************
0026  * RD-88F5181L GE Info
0027  ****************************************************************************/
0028 /*
0029  * 16M NOR flash Device bus boot chip select
0030  */
0031 #define RD88F5181L_GE_NOR_BOOT_BASE     0xff000000
0032 #define RD88F5181L_GE_NOR_BOOT_SIZE     SZ_16M
0033 
0034 
0035 /*****************************************************************************
0036  * 16M NOR Flash on Device bus Boot chip select
0037  ****************************************************************************/
0038 static struct physmap_flash_data rd88f5181l_ge_nor_boot_flash_data = {
0039     .width      = 1,
0040 };
0041 
0042 static struct resource rd88f5181l_ge_nor_boot_flash_resource = {
0043     .flags      = IORESOURCE_MEM,
0044     .start      = RD88F5181L_GE_NOR_BOOT_BASE,
0045     .end        = RD88F5181L_GE_NOR_BOOT_BASE +
0046               RD88F5181L_GE_NOR_BOOT_SIZE - 1,
0047 };
0048 
0049 static struct platform_device rd88f5181l_ge_nor_boot_flash = {
0050     .name           = "physmap-flash",
0051     .id         = 0,
0052     .dev        = {
0053         .platform_data  = &rd88f5181l_ge_nor_boot_flash_data,
0054     },
0055     .num_resources      = 1,
0056     .resource       = &rd88f5181l_ge_nor_boot_flash_resource,
0057 };
0058 
0059 
0060 /*****************************************************************************
0061  * General Setup
0062  ****************************************************************************/
0063 static unsigned int rd88f5181l_ge_mpp_modes[] __initdata = {
0064     MPP0_GPIO,      /* LED1 */
0065     MPP1_GPIO,      /* LED5 */
0066     MPP2_GPIO,      /* LED4 */
0067     MPP3_GPIO,      /* LED3 */
0068     MPP4_GPIO,      /* PCI_intA */
0069     MPP5_GPIO,      /* RTC interrupt */
0070     MPP6_PCI_CLK,       /* CPU PCI refclk */
0071     MPP7_PCI_CLK,       /* PCI/PCIe refclk */
0072     MPP8_GPIO,      /* 88e6131 interrupt */
0073     MPP9_GPIO,      /* GE_RXERR */
0074     MPP10_GPIO,     /* PCI_intB */
0075     MPP11_GPIO,     /* LED2 */
0076     MPP12_GIGE,     /* GE_TXD[4] */
0077     MPP13_GIGE,     /* GE_TXD[5] */
0078     MPP14_GIGE,     /* GE_TXD[6] */
0079     MPP15_GIGE,     /* GE_TXD[7] */
0080     MPP16_GIGE,     /* GE_RXD[4] */
0081     MPP17_GIGE,     /* GE_RXD[5] */
0082     MPP18_GIGE,     /* GE_RXD[6] */
0083     MPP19_GIGE,     /* GE_RXD[7] */
0084     0,
0085 };
0086 
0087 static struct mv643xx_eth_platform_data rd88f5181l_ge_eth_data = {
0088     .phy_addr   = MV643XX_ETH_PHY_NONE,
0089     .speed      = SPEED_1000,
0090     .duplex     = DUPLEX_FULL,
0091 };
0092 
0093 static struct dsa_chip_data rd88f5181l_ge_switch_chip_data = {
0094     .port_names[0]  = "lan2",
0095     .port_names[1]  = "lan1",
0096     .port_names[2]  = "wan",
0097     .port_names[3]  = "cpu",
0098     .port_names[5]  = "lan4",
0099     .port_names[7]  = "lan3",
0100 };
0101 
0102 static struct i2c_board_info __initdata rd88f5181l_ge_i2c_rtc = {
0103     I2C_BOARD_INFO("ds1338", 0x68),
0104 };
0105 
0106 static void __init rd88f5181l_ge_init(void)
0107 {
0108     /*
0109      * Setup basic Orion functions. Need to be called early.
0110      */
0111     orion5x_init();
0112 
0113     orion5x_mpp_conf(rd88f5181l_ge_mpp_modes);
0114 
0115     /*
0116      * Configure peripherals.
0117      */
0118     orion5x_ehci0_init();
0119     orion5x_eth_init(&rd88f5181l_ge_eth_data);
0120     orion5x_eth_switch_init(&rd88f5181l_ge_switch_chip_data);
0121     orion5x_i2c_init();
0122     orion5x_uart0_init();
0123 
0124     mvebu_mbus_add_window_by_id(ORION_MBUS_DEVBUS_BOOT_TARGET,
0125                     ORION_MBUS_DEVBUS_BOOT_ATTR,
0126                     RD88F5181L_GE_NOR_BOOT_BASE,
0127                     RD88F5181L_GE_NOR_BOOT_SIZE);
0128     platform_device_register(&rd88f5181l_ge_nor_boot_flash);
0129 
0130     i2c_register_board_info(0, &rd88f5181l_ge_i2c_rtc, 1);
0131 }
0132 
0133 static int __init
0134 rd88f5181l_ge_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
0135 {
0136     int irq;
0137 
0138     /*
0139      * Check for devices with hard-wired IRQs.
0140      */
0141     irq = orion5x_pci_map_irq(dev, slot, pin);
0142     if (irq != -1)
0143         return irq;
0144 
0145     /*
0146      * Cardbus slot.
0147      */
0148     if (pin == 1)
0149         return gpio_to_irq(4);
0150     else
0151         return gpio_to_irq(10);
0152 }
0153 
0154 static struct hw_pci rd88f5181l_ge_pci __initdata = {
0155     .nr_controllers = 2,
0156     .setup      = orion5x_pci_sys_setup,
0157     .scan       = orion5x_pci_sys_scan_bus,
0158     .map_irq    = rd88f5181l_ge_pci_map_irq,
0159 };
0160 
0161 static int __init rd88f5181l_ge_pci_init(void)
0162 {
0163     if (machine_is_rd88f5181l_ge()) {
0164         orion5x_pci_set_cardbus_mode();
0165         pci_common_init(&rd88f5181l_ge_pci);
0166     }
0167 
0168     return 0;
0169 }
0170 subsys_initcall(rd88f5181l_ge_pci_init);
0171 
0172 MACHINE_START(RD88F5181L_GE, "Marvell Orion-VoIP GE Reference Design")
0173     /* Maintainer: Lennert Buytenhek <buytenh@marvell.com> */
0174     .atag_offset    = 0x100,
0175     .nr_irqs    = ORION5X_NR_IRQS,
0176     .init_machine   = rd88f5181l_ge_init,
0177     .map_io     = orion5x_map_io,
0178     .init_early = orion5x_init_early,
0179     .init_irq   = orion5x_init_irq,
0180     .init_time  = orion5x_timer_init,
0181     .fixup      = tag_fixup_mem32,
0182     .restart    = orion5x_restart,
0183 MACHINE_END