Path: blob/master/arch/arm/mach-orion5x/rd88f5182-setup.c
10817 views
/*1* arch/arm/mach-orion5x/rd88f5182-setup.c2*3* Marvell Orion-NAS Reference Design Setup4*5* Maintainer: Ronen Shitrit <[email protected]>6*7* This file is licensed under the terms of the GNU General Public8* License version 2. This program is licensed "as is" without any9* warranty of any kind, whether express or implied.10*/1112#include <linux/kernel.h>13#include <linux/init.h>14#include <linux/platform_device.h>15#include <linux/pci.h>16#include <linux/irq.h>17#include <linux/mtd/physmap.h>18#include <linux/mv643xx_eth.h>19#include <linux/ata_platform.h>20#include <linux/i2c.h>21#include <asm/mach-types.h>22#include <asm/gpio.h>23#include <asm/leds.h>24#include <asm/mach/arch.h>25#include <asm/mach/pci.h>26#include <mach/orion5x.h>27#include "common.h"28#include "mpp.h"2930/*****************************************************************************31* RD-88F5182 Info32****************************************************************************/3334/*35* 512K NOR flash Device bus boot chip select36*/3738#define RD88F5182_NOR_BOOT_BASE 0xf400000039#define RD88F5182_NOR_BOOT_SIZE SZ_512K4041/*42* 16M NOR flash on Device bus chip select 143*/4445#define RD88F5182_NOR_BASE 0xfc00000046#define RD88F5182_NOR_SIZE SZ_16M4748/*49* PCI50*/5152#define RD88F5182_PCI_SLOT0_OFFS 753#define RD88F5182_PCI_SLOT0_IRQ_A_PIN 754#define RD88F5182_PCI_SLOT0_IRQ_B_PIN 65556/*57* GPIO Debug LED58*/5960#define RD88F5182_GPIO_DBG_LED 06162/*****************************************************************************63* 16M NOR Flash on Device bus CS164****************************************************************************/6566static struct physmap_flash_data rd88f5182_nor_flash_data = {67.width = 1,68};6970static struct resource rd88f5182_nor_flash_resource = {71.flags = IORESOURCE_MEM,72.start = RD88F5182_NOR_BASE,73.end = RD88F5182_NOR_BASE + RD88F5182_NOR_SIZE - 1,74};7576static struct platform_device rd88f5182_nor_flash = {77.name = "physmap-flash",78.id = 0,79.dev = {80.platform_data = &rd88f5182_nor_flash_data,81},82.num_resources = 1,83.resource = &rd88f5182_nor_flash_resource,84};8586#ifdef CONFIG_LEDS8788/*****************************************************************************89* Use GPIO debug led as CPU active indication90****************************************************************************/9192static void rd88f5182_dbgled_event(led_event_t evt)93{94int val;9596if (evt == led_idle_end)97val = 1;98else if (evt == led_idle_start)99val = 0;100else101return;102103gpio_set_value(RD88F5182_GPIO_DBG_LED, val);104}105106static int __init rd88f5182_dbgled_init(void)107{108int pin;109110if (machine_is_rd88f5182()) {111pin = RD88F5182_GPIO_DBG_LED;112113if (gpio_request(pin, "DBGLED") == 0) {114if (gpio_direction_output(pin, 0) != 0) {115printk(KERN_ERR "rd88f5182_dbgled_init failed "116"to set output pin %d\n", pin);117gpio_free(pin);118return 0;119}120} else {121printk(KERN_ERR "rd88f5182_dbgled_init failed "122"to request gpio %d\n", pin);123return 0;124}125126leds_event = rd88f5182_dbgled_event;127}128129return 0;130}131132__initcall(rd88f5182_dbgled_init);133134#endif135136/*****************************************************************************137* PCI138****************************************************************************/139140void __init rd88f5182_pci_preinit(void)141{142int pin;143144/*145* Configure PCI GPIO IRQ pins146*/147pin = RD88F5182_PCI_SLOT0_IRQ_A_PIN;148if (gpio_request(pin, "PCI IntA") == 0) {149if (gpio_direction_input(pin) == 0) {150irq_set_irq_type(gpio_to_irq(pin), IRQ_TYPE_LEVEL_LOW);151} else {152printk(KERN_ERR "rd88f5182_pci_preinit faield to "153"set_irq_type pin %d\n", pin);154gpio_free(pin);155}156} else {157printk(KERN_ERR "rd88f5182_pci_preinit failed to request gpio %d\n", pin);158}159160pin = RD88F5182_PCI_SLOT0_IRQ_B_PIN;161if (gpio_request(pin, "PCI IntB") == 0) {162if (gpio_direction_input(pin) == 0) {163irq_set_irq_type(gpio_to_irq(pin), IRQ_TYPE_LEVEL_LOW);164} else {165printk(KERN_ERR "rd88f5182_pci_preinit faield to "166"set_irq_type pin %d\n", pin);167gpio_free(pin);168}169} else {170printk(KERN_ERR "rd88f5182_pci_preinit failed to gpio_request %d\n", pin);171}172}173174static int __init rd88f5182_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)175{176int irq;177178/*179* Check for devices with hard-wired IRQs.180*/181irq = orion5x_pci_map_irq(dev, slot, pin);182if (irq != -1)183return irq;184185/*186* PCI IRQs are connected via GPIOs187*/188switch (slot - RD88F5182_PCI_SLOT0_OFFS) {189case 0:190if (pin == 1)191return gpio_to_irq(RD88F5182_PCI_SLOT0_IRQ_A_PIN);192else193return gpio_to_irq(RD88F5182_PCI_SLOT0_IRQ_B_PIN);194default:195return -1;196}197}198199static struct hw_pci rd88f5182_pci __initdata = {200.nr_controllers = 2,201.preinit = rd88f5182_pci_preinit,202.swizzle = pci_std_swizzle,203.setup = orion5x_pci_sys_setup,204.scan = orion5x_pci_sys_scan_bus,205.map_irq = rd88f5182_pci_map_irq,206};207208static int __init rd88f5182_pci_init(void)209{210if (machine_is_rd88f5182())211pci_common_init(&rd88f5182_pci);212213return 0;214}215216subsys_initcall(rd88f5182_pci_init);217218/*****************************************************************************219* Ethernet220****************************************************************************/221222static struct mv643xx_eth_platform_data rd88f5182_eth_data = {223.phy_addr = MV643XX_ETH_PHY_ADDR(8),224};225226/*****************************************************************************227* RTC DS1338 on I2C bus228****************************************************************************/229static struct i2c_board_info __initdata rd88f5182_i2c_rtc = {230I2C_BOARD_INFO("ds1338", 0x68),231};232233/*****************************************************************************234* Sata235****************************************************************************/236static struct mv_sata_platform_data rd88f5182_sata_data = {237.n_ports = 2,238};239240/*****************************************************************************241* General Setup242****************************************************************************/243static unsigned int rd88f5182_mpp_modes[] __initdata = {244MPP0_GPIO, /* Debug Led */245MPP1_GPIO, /* Reset Switch */246MPP2_UNUSED,247MPP3_GPIO, /* RTC Int */248MPP4_GPIO,249MPP5_GPIO,250MPP6_GPIO, /* PCI_intA */251MPP7_GPIO, /* PCI_intB */252MPP8_UNUSED,253MPP9_UNUSED,254MPP10_UNUSED,255MPP11_UNUSED,256MPP12_SATA_LED, /* SATA 0 presence */257MPP13_SATA_LED, /* SATA 1 presence */258MPP14_SATA_LED, /* SATA 0 active */259MPP15_SATA_LED, /* SATA 1 active */260MPP16_UNUSED,261MPP17_UNUSED,262MPP18_UNUSED,263MPP19_UNUSED,2640,265};266267static void __init rd88f5182_init(void)268{269/*270* Setup basic Orion functions. Need to be called early.271*/272orion5x_init();273274orion5x_mpp_conf(rd88f5182_mpp_modes);275276/*277* MPP[20] PCI Clock to MV88F5182278* MPP[21] PCI Clock to mini PCI CON11279* MPP[22] USB 0 over current indication280* MPP[23] USB 1 over current indication281* MPP[24] USB 1 over current enable282* MPP[25] USB 0 over current enable283*/284285/*286* Configure peripherals.287*/288orion5x_ehci0_init();289orion5x_ehci1_init();290orion5x_eth_init(&rd88f5182_eth_data);291orion5x_i2c_init();292orion5x_sata_init(&rd88f5182_sata_data);293orion5x_uart0_init();294orion5x_xor_init();295296orion5x_setup_dev_boot_win(RD88F5182_NOR_BOOT_BASE,297RD88F5182_NOR_BOOT_SIZE);298299orion5x_setup_dev1_win(RD88F5182_NOR_BASE, RD88F5182_NOR_SIZE);300platform_device_register(&rd88f5182_nor_flash);301302i2c_register_board_info(0, &rd88f5182_i2c_rtc, 1);303}304305MACHINE_START(RD88F5182, "Marvell Orion-NAS Reference Design")306/* Maintainer: Ronen Shitrit <[email protected]> */307.boot_params = 0x00000100,308.init_machine = rd88f5182_init,309.map_io = orion5x_map_io,310.init_early = orion5x_init_early,311.init_irq = orion5x_init_irq,312.timer = &orion5x_timer,313MACHINE_END314315316