static inline void __init apollon_init_smc91x(void) { unsigned long base; /* Make sure CS1 timings are correct */ GPMC_CONFIG1_1 = 0x00011203; GPMC_CONFIG2_1 = 0x001f1f01; GPMC_CONFIG3_1 = 0x00080803; GPMC_CONFIG4_1 = 0x1c091c09; GPMC_CONFIG5_1 = 0x041f1f1f; GPMC_CONFIG6_1 = 0x000004c4; if (gpmc_cs_request(APOLLON_ETH_CS, SZ_16M, &base) < 0) { printk(KERN_ERR "Failed to request GPMC CS for smc91x\n"); return; } apollon_smc91x_resources[0].start = base + 0x300; apollon_smc91x_resources[0].end = base + 0x30f; udelay(100); omap_cfg_reg(W4__24XX_GPIO74); if (omap_request_gpio(APOLLON_ETHR_GPIO_IRQ) < 0) { printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n", APOLLON_ETHR_GPIO_IRQ); gpmc_cs_free(APOLLON_ETH_CS); return; } omap_set_gpio_direction(APOLLON_ETHR_GPIO_IRQ, 1); }
static int __devexit omap2_onenand_remove(struct platform_device *pdev) { struct omap2_onenand *c = dev_get_drvdata(&pdev->dev); BUG_ON(c == NULL); #ifdef CONFIG_MTD_PARTITIONS if (c->parts) del_mtd_partitions(&c->mtd); else del_mtd_device(&c->mtd); #else del_mtd_device(&c->mtd); #endif onenand_release(&c->mtd); if (c->dma_channel != -1) omap_free_dma(c->dma_channel); omap2_onenand_shutdown(pdev); platform_set_drvdata(pdev, NULL); if (c->gpio_irq) { free_irq(gpio_to_irq(c->gpio_irq), c); gpio_free(c->gpio_irq); } iounmap(c->onenand.base); release_mem_region(c->phys_base, ONENAND_IO_SIZE); gpmc_cs_free(c->gpmc_cs); kfree(c); return 0; }
static void __exit fpga_perh_exit(void) { gpio_recover(); // free CS3 gpmc_cs_free(GPMC_FPGA_CS); dma_free_coherent (NULL, MAX_DMA_TRANSFER_IN_BYTES, fpga_buf, dmaphysdest); printk("fpga_perh exit!\n"); }
static inline void __init sdp2430_init_smc91x(void) { int eth_cs; unsigned long cs_mem_base; unsigned int rate; struct clk *l3ck; eth_cs = SDP2430_SMC91X_CS; l3ck = clk_get(NULL, "core_l3_ck"); if (IS_ERR(l3ck)) rate = 100000000; else rate = clk_get_rate(l3ck); /* Make sure CS1 timings are correct, for 2430 always muxed */ gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1, 0x00011200); if (rate >= 160000000) { gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4); } else if (rate >= 130000000) { gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4); } else { /* rate = 100000000 */ gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2); } if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) { printk(KERN_ERR "Failed to request GPMC mem for smc91x\n"); return; } sdp2430_smc91x_resources[0].start = cs_mem_base + 0x300; sdp2430_smc91x_resources[0].end = cs_mem_base + 0x30f; udelay(100); if (omap_request_gpio(OMAP24XX_ETHR_GPIO_IRQ) < 0) { printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n", OMAP24XX_ETHR_GPIO_IRQ); gpmc_cs_free(eth_cs); return; } omap_set_gpio_direction(OMAP24XX_ETHR_GPIO_IRQ, 1); }
/* * Initialize smsc911x device connected to the GPMC. Note that we * assume that pin multiplexing is done in the board-*.c file, * or in the bootloader. */ void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *gpmc_cfg) { struct platform_device *pdev; unsigned long cs_mem_base; int ret; if (gpmc_cs_request(gpmc_cfg->cs, SZ_16M, &cs_mem_base) < 0) { pr_err("Failed to request GPMC mem region\n"); return; } gpmc_smsc911x_resources[0].start = cs_mem_base + 0x0; gpmc_smsc911x_resources[0].end = cs_mem_base + 0xff; if (gpio_request_one(gpmc_cfg->gpio_irq, GPIOF_IN, "smsc911x irq")) { pr_err("Failed to request IRQ GPIO%d\n", gpmc_cfg->gpio_irq); goto free1; } gpmc_smsc911x_resources[1].start = gpio_to_irq(gpmc_cfg->gpio_irq); if (gpio_is_valid(gpmc_cfg->gpio_reset)) { ret = gpio_request_one(gpmc_cfg->gpio_reset, GPIOF_OUT_INIT_HIGH, "smsc911x reset"); if (ret) { pr_err("Failed to request reset GPIO%d\n", gpmc_cfg->gpio_reset); goto free2; } gpio_set_value(gpmc_cfg->gpio_reset, 0); msleep(100); gpio_set_value(gpmc_cfg->gpio_reset, 1); } gpmc_smsc911x_config.flags = gpmc_cfg->flags ? : SMSC911X_USE_16BIT; pdev = platform_device_register_resndata(NULL, "smsc911x", gpmc_cfg->id, gpmc_smsc911x_resources, ARRAY_SIZE(gpmc_smsc911x_resources), &gpmc_smsc911x_config, sizeof(gpmc_smsc911x_config)); if (!pdev) { pr_err("Unable to register platform device\n"); gpio_free(gpmc_cfg->gpio_reset); goto free2; } return; free2: gpio_free(gpmc_cfg->gpio_irq); free1: gpmc_cs_free(gpmc_cfg->cs); pr_err("Could not initialize smsc911x device\n"); }
int __init gpmc_nand_init(struct omap_nand_platform_data *gpmc_nand_data) { int err = 0; struct device *dev = &gpmc_nand_device.dev; gpmc_nand_device.dev.platform_data = gpmc_nand_data; err = gpmc_cs_request(gpmc_nand_data->cs, NAND_IO_SIZE, (unsigned long *)&gpmc_nand_resource[0].start); if (err < 0) { dev_err(dev, "Cannot request GPMC CS\n"); return err; } gpmc_nand_resource[0].end = gpmc_nand_resource[0].start + NAND_IO_SIZE - 1; gpmc_nand_resource[1].start = gpmc_get_client_irq(GPMC_IRQ_FIFOEVENTENABLE); gpmc_nand_resource[2].start = gpmc_get_client_irq(GPMC_IRQ_COUNT_EVENT); /* Set timings in GPMC */ err = omap2_nand_gpmc_retime(gpmc_nand_data); if (err < 0) { dev_err(dev, "Unable to set gpmc timings: %d\n", err); return err; } /* Enable RD PIN Monitoring Reg */ if (gpmc_nand_data->dev_ready) { gpmc_cs_configure(gpmc_nand_data->cs, GPMC_CONFIG_RDY_BSY, 1); } gpmc_update_nand_reg(&gpmc_nand_data->reg, gpmc_nand_data->cs); err = platform_device_register(&gpmc_nand_device); if (err < 0) { dev_err(dev, "Unable to register NAND device\n"); goto out_free_cs; } return 0; out_free_cs: gpmc_cs_free(gpmc_nand_data->cs); return err; }
int __init gpmc_nand_init(struct omap_nand_platform_data *_nand_data) { unsigned int val; int err = 0; struct device *dev = &gpmc_nand_device.dev; gpmc_nand_data = _nand_data; gpmc_nand_data->nand_setup = gpmc_nand_setup; gpmc_nand_device.dev.platform_data = gpmc_nand_data; err = gpmc_cs_request(gpmc_nand_data->cs, NAND_IO_SIZE, &gpmc_nand_data->phys_base); if (err < 0) { dev_err(dev, "Cannot request GPMC CS\n"); return err; } err = gpmc_nand_setup(); if (err < 0) { dev_err(dev, "NAND platform setup failed: %d\n", err); return err; } /* Enable RD PIN Monitoring Reg */ if (gpmc_nand_data->dev_ready) { val = gpmc_cs_read_reg(gpmc_nand_data->cs, GPMC_CS_CONFIG1); val |= WR_RD_PIN_MONITORING; gpmc_cs_write_reg(gpmc_nand_data->cs, GPMC_CS_CONFIG1, val); } err = platform_device_register(&gpmc_nand_device); if (err < 0) { dev_err(dev, "Unable to register NAND device\n"); goto out_free_cs; } return 0; out_free_cs: gpmc_cs_free(gpmc_nand_data->cs); return err; }
void cy_as_hal_omap_hardware_deinit(cy_as_omap_dev_kernel *dev_p) { /* * free omap hw resources */ if (dev_p->m_vma_addr_base != 0) iounmap((void *)dev_p->m_vma_addr_base); if (dev_p->m_phy_addr_base != 0) release_mem_region((void *)dev_p->m_phy_addr_base, SZ_16K); gpmc_cs_free(AST_GPMC_CS); if (have_irq) free_irq(OMAP_GPIO_IRQ(AST_INT), dev_p); cy_as_hal_release_user_pads(user_pad_cfg); }
static int __devexit omap2_onenand_remove(struct platform_device *pdev) { struct omap2_onenand *c = dev_get_drvdata(&pdev->dev); onenand_release(&c->mtd); regulator_put(c->regulator); if (c->dma_channel != -1) omap_free_dma(c->dma_channel); omap2_onenand_shutdown(pdev); platform_set_drvdata(pdev, NULL); if (c->gpio_irq) { free_irq(gpio_to_irq(c->gpio_irq), c); gpio_free(c->gpio_irq); } iounmap(c->onenand.base); release_mem_region(c->phys_base, c->mem_size); gpmc_cs_free(c->gpmc_cs); kfree(c); return 0; }
int gpmc_onenand_init(struct omap_onenand_platform_data *_onenand_data) { int err; struct device *dev = &gpmc_onenand_device.dev; gpmc_onenand_data = _onenand_data; gpmc_onenand_data->onenand_setup = gpmc_onenand_setup; gpmc_onenand_device.dev.platform_data = gpmc_onenand_data; if (cpu_is_omap24xx() && (gpmc_onenand_data->flags & ONENAND_SYNC_READWRITE)) { dev_warn(dev, "OneNAND using only SYNC_READ on 24xx\n"); gpmc_onenand_data->flags &= ~ONENAND_SYNC_READWRITE; gpmc_onenand_data->flags |= ONENAND_SYNC_READ; } if (cpu_is_omap34xx()) gpmc_onenand_data->flags |= ONENAND_IN_OMAP34XX; else gpmc_onenand_data->flags &= ~ONENAND_IN_OMAP34XX; err = gpmc_cs_request(gpmc_onenand_data->cs, ONENAND_IO_SIZE, (unsigned long *)&gpmc_onenand_resource.start); if (err < 0) { dev_err(dev, "Cannot request GPMC CS %d, error %d\n", gpmc_onenand_data->cs, err); return err; } gpmc_onenand_resource.end = gpmc_onenand_resource.start + ONENAND_IO_SIZE - 1; err = platform_device_register(&gpmc_onenand_device); if (err) { dev_err(dev, "Unable to register OneNAND device\n"); gpmc_cs_free(gpmc_onenand_data->cs); } return err; }
int __init gpmc_nand_init(struct omap_nand_platform_data *gpmc_nand_data) { int err = 0; struct device *dev = &gpmc_nand_device.dev; gpmc_nand_device.dev.platform_data = gpmc_nand_data; err = gpmc_cs_request(gpmc_nand_data->cs, NAND_IO_SIZE, &gpmc_nand_data->phys_base); if (err < 0) { dev_err(dev, "Cannot request GPMC CS\n"); return err; } /* Set timings in GPMC */ err = omap2_nand_gpmc_retime(gpmc_nand_data); if (err < 0) { dev_err(dev, "Unable to set gpmc timings: %d\n", err); return err; } /* Enable RD PIN Monitoring Reg */ if (gpmc_nand_data->dev_ready) { gpmc_cs_configure(gpmc_nand_data->cs, GPMC_CONFIG_RDY_BSY, 1); } err = platform_device_register(&gpmc_nand_device); if (err < 0) { dev_err(dev, "Unable to register NAND device\n"); goto out_free_cs; } return 0; out_free_cs: gpmc_cs_free(gpmc_nand_data->cs); return err; }
static inline void __init igep2_init_smsc911x(void) { unsigned long cs_mem_base; if (gpmc_cs_request(IGEP2_SMSC911X_CS, SZ_16M, &cs_mem_base) < 0) { pr_err("IGEP v2: Failed request for GPMC mem for smsc911x\n"); gpmc_cs_free(IGEP2_SMSC911X_CS); return; } igep2_smsc911x_resources[0].start = cs_mem_base + 0x0; igep2_smsc911x_resources[0].end = cs_mem_base + 0xff; if ((gpio_request(IGEP2_SMSC911X_GPIO, "SMSC911X IRQ") == 0) && (gpio_direction_input(IGEP2_SMSC911X_GPIO) == 0)) { gpio_export(IGEP2_SMSC911X_GPIO, 0); } else { pr_err("IGEP v2: Could not obtain gpio for for SMSC911X IRQ\n"); return; } platform_device_register(&igep2_smsc911x_device); }
uint32_t cy_as_hal_gpmc_init(cy_as_omap_dev_kernel *dev_p) { u32 tmp32; int err; struct gpmc_timings timings; unsigned int cs_mem_base; unsigned int cs_vma_base; /* * get GPMC i/o registers base(already been i/o mapped * in kernel, no need for separate i/o remap) */ cy_as_hal_print_message(KERN_INFO "%s: mapping phys_to_virt\n", __func__); gpmc_base = (u32)ioremap_nocache(OMAP34XX_GPMC_BASE, SZ_16K); cy_as_hal_print_message(KERN_INFO "kernel has gpmc_base=%x , val@ the base=%x", gpmc_base, __raw_readl(gpmc_base) ); cy_as_hal_print_message(KERN_INFO "%s: calling gpmc_cs_request\n", __func__); /* * request GPMC CS for ASTORIA request */ if (gpmc_cs_request(AST_GPMC_CS, SZ_16M, (void *)&cs_mem_base) < 0) { cy_as_hal_print_message(KERN_ERR "error failed to request" "ncs4 for ASTORIA\n"); return -1; } else { cy_as_hal_print_message(KERN_INFO "got phy_addr:%x for " "GPMC CS%d GPMC_CFGREG7[CS4]\n", cs_mem_base, AST_GPMC_CS); } cy_as_hal_print_message(KERN_INFO "%s: calling request_mem_region\n", __func__); /* * request VM region for 4K addr space for chip select 4 phy address * technically we don't need it for NAND devices, but do it anyway * so that data read/write bus cycle can be triggered by reading * or writing this mem region */ if (!request_mem_region(cs_mem_base, SZ_16K, "AST_OMAP_HAL")) { err = -EBUSY; cy_as_hal_print_message(KERN_ERR "error MEM region " "request for phy_addr:%x failed\n", cs_mem_base); goto out_free_cs; } cy_as_hal_print_message(KERN_INFO "%s: calling ioremap_nocache\n", __func__); /* REMAP mem region associated with our CS */ cs_vma_base = (u32)ioremap_nocache(cs_mem_base, SZ_16K); if (!cs_vma_base) { err = -ENOMEM; cy_as_hal_print_message(KERN_ERR "error- ioremap()" "for phy_addr:%x failed", cs_mem_base); goto out_release_mem_region; } cy_as_hal_print_message(KERN_INFO "ioremap(%x) returned vma=%x\n", cs_mem_base, cs_vma_base); dev_p->m_phy_addr_base = (void *) cs_mem_base; dev_p->m_vma_addr_base = (void *) cs_vma_base; memset(&timings, 0, sizeof(timings)); /* cs timing */ timings.cs_on = WB_GPMC_CS_t_on; timings.cs_wr_off = WB_GPMC_BUSCYC_t; timings.cs_rd_off = WB_GPMC_BUSCYC_t; /* adv timing */ timings.adv_on = WB_GPMC_ADV_t_on; timings.adv_rd_off = WB_GPMC_ADV_t_off; timings.adv_wr_off = WB_GPMC_ADV_t_off; /* oe timing */ timings.oe_on = WB_GPMC_OE_t_on; timings.oe_off = WB_GPMC_OE_t_off; timings.access = WB_GPMC_RD_t_a_c_c; timings.rd_cycle = WB_GPMC_BUSCYC_t; /* we timing */ timings.we_on = WB_GPMC_WE_t_on; timings.we_off = WB_GPMC_WE_t_off; timings.wr_access = WB_GPMC_WR_t_a_c_c; timings.wr_cycle = WB_GPMC_BUSCYC_t; timings.page_burst_access = WB_GPMC_BUSCYC_t; timings.wr_data_mux_bus = WB_GPMC_BUSCYC_t; gpmc_cs_set_timings(AST_GPMC_CS, &timings); /* * by default configure GPMC into 8 bit mode * (to match astoria default mode) */ gpmc_cs_write_reg(AST_GPMC_CS, GPMC_CS_CONFIG1, (GPMC_CONFIG1_DEVICETYPE(0) | GPMC_CONFIG1_DEVICESIZE_16 | 0x10 //twhs )); /* * No method currently exists to write this register through GPMC APIs * need to change WAIT2 polarity */ tmp32 = IORD32(GPMC_VMA(GPMC_CONFIG_REG)); tmp32 = tmp32 | NAND_FORCE_POSTED_WRITE_B | 0x40; IOWR32(GPMC_VMA(GPMC_CONFIG_REG), tmp32); tmp32 = IORD32(GPMC_VMA(GPMC_CONFIG_REG)); cy_as_hal_print_message("GPMC_CONFIG_REG=0x%x\n", tmp32); cy_as_hal_print_omap_regs("GPMC_CONFIG", 1, GPMC_VMA(GPMC_CFG_REG(1, AST_GPMC_CS)), 7); return 0; out_release_mem_region: release_mem_region(cs_mem_base, SZ_16K); out_free_cs: gpmc_cs_free(AST_GPMC_CS); return err; }
static inline void __init h4_init_debug(void) { int eth_cs; unsigned long cs_mem_base; unsigned int muxed, rate; struct clk *gpmc_fck; eth_cs = H4_SMC91X_CS; gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */ if (IS_ERR(gpmc_fck)) { WARN_ON(1); return; } clk_enable(gpmc_fck); rate = clk_get_rate(gpmc_fck); clk_disable(gpmc_fck); clk_put(gpmc_fck); if (is_gpmc_muxed()) muxed = 0x200; else muxed = 0; /* Make sure CS1 timings are correct */ gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1, 0x00011000 | muxed); if (rate >= 160000000) { gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4); } else if (rate >= 130000000) { gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4); } else {/* rate = 100000000 */ gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2); } if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) { printk(KERN_ERR "Failed to request GPMC mem for smc91x\n"); goto out; } udelay(100); omap_mux_init_gpio(92, 0); if (debug_card_init(cs_mem_base, H4_ETHR_GPIO_IRQ) < 0) gpmc_cs_free(eth_cs); out: clk_disable(gpmc_fck); clk_put(gpmc_fck); }
static inline void __init sdp2430_init_smc91x(void) { int eth_cs; unsigned long cs_mem_base; unsigned int rate; struct clk *gpmc_fck; eth_cs = SDP2430_SMC91X_CS; gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */ if (IS_ERR(gpmc_fck)) { WARN_ON(1); return; } clk_enable(gpmc_fck); rate = clk_get_rate(gpmc_fck); /* Make sure CS1 timings are correct, for 2430 always muxed */ gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1, 0x00011200); if (rate >= 160000000) { gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4); } else if (rate >= 130000000) { gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4); } else { /* rate = 100000000 */ gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2); } if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) { printk(KERN_ERR "Failed to request GPMC mem for smc91x\n"); goto out; } sdp2430_smc91x_resources[0].start = cs_mem_base + 0x300; sdp2430_smc91x_resources[0].end = cs_mem_base + 0x30f; udelay(100); if (gpio_request(OMAP24XX_ETHR_GPIO_IRQ, "SMC91x irq") < 0) { printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n", OMAP24XX_ETHR_GPIO_IRQ); gpmc_cs_free(eth_cs); goto out; } gpio_direction_input(OMAP24XX_ETHR_GPIO_IRQ); out: clk_disable(gpmc_fck); clk_put(gpmc_fck); }
static int __devinit omap2_onenand_probe(struct platform_device *pdev) { struct omap_onenand_platform_data *pdata; struct omap2_onenand *c; int r; pdata = pdev->dev.platform_data; if (pdata == NULL) { dev_err(&pdev->dev, "platform data missing\n"); return -ENODEV; } c = kzalloc(sizeof(struct omap2_onenand), GFP_KERNEL); if (!c) return -ENOMEM; init_completion(&c->irq_done); init_completion(&c->dma_done); c->gpmc_cs = pdata->cs; c->gpio_irq = pdata->gpio_irq; c->dma_channel = pdata->dma_channel; if (c->dma_channel < 0) { c->gpio_irq = 0; } r = gpmc_cs_request(c->gpmc_cs, ONENAND_IO_SIZE, &c->phys_base); if (r < 0) { dev_err(&pdev->dev, "Cannot request GPMC CS\n"); goto err_kfree; } if (request_mem_region(c->phys_base, ONENAND_IO_SIZE, pdev->dev.driver->name) == NULL) { dev_err(&pdev->dev, "Cannot reserve memory region at 0x%08lx, " "size: 0x%x\n", c->phys_base, ONENAND_IO_SIZE); r = -EBUSY; goto err_free_cs; } c->onenand.base = ioremap(c->phys_base, ONENAND_IO_SIZE); if (c->onenand.base == NULL) { r = -ENOMEM; goto err_release_mem_region; } if (pdata->onenand_setup != NULL) { r = pdata->onenand_setup(c->onenand.base, c->freq); if (r < 0) { dev_err(&pdev->dev, "Onenand platform setup failed: " "%d\n", r); goto err_iounmap; } c->setup = pdata->onenand_setup; } if (c->gpio_irq) { if ((r = gpio_request(c->gpio_irq, "OneNAND irq")) < 0) { dev_err(&pdev->dev, "Failed to request GPIO%d for " "OneNAND\n", c->gpio_irq); goto err_iounmap; } gpio_direction_input(c->gpio_irq); if ((r = request_irq(gpio_to_irq(c->gpio_irq), omap2_onenand_interrupt, IRQF_TRIGGER_RISING, pdev->dev.driver->name, c)) < 0) goto err_release_gpio; } if (c->dma_channel >= 0) { r = omap_request_dma(0, pdev->dev.driver->name, omap2_onenand_dma_cb, (void *) c, &c->dma_channel); if (r == 0) { omap_set_dma_write_mode(c->dma_channel, OMAP_DMA_WRITE_NON_POSTED); omap_set_dma_src_data_pack(c->dma_channel, 1); omap_set_dma_src_burst_mode(c->dma_channel, OMAP_DMA_DATA_BURST_8); omap_set_dma_dest_data_pack(c->dma_channel, 1); omap_set_dma_dest_burst_mode(c->dma_channel, OMAP_DMA_DATA_BURST_8); } else { dev_info(&pdev->dev, "failed to allocate DMA for OneNAND, " "using PIO instead\n"); c->dma_channel = -1; } } dev_info(&pdev->dev, "initializing on CS%d, phys base 0x%08lx, virtual " "base %p\n", c->gpmc_cs, c->phys_base, c->onenand.base); c->pdev = pdev; c->mtd.name = dev_name(&pdev->dev); c->mtd.priv = &c->onenand; c->mtd.owner = THIS_MODULE; c->mtd.dev.parent = &pdev->dev; if (c->dma_channel >= 0) { struct onenand_chip *this = &c->onenand; this->wait = omap2_onenand_wait; if (cpu_is_omap34xx()) { this->read_bufferram = omap3_onenand_read_bufferram; this->write_bufferram = omap3_onenand_write_bufferram; } else { this->read_bufferram = omap2_onenand_read_bufferram; this->write_bufferram = omap2_onenand_write_bufferram; } } if ((r = onenand_scan(&c->mtd, 1)) < 0) goto err_release_dma; switch ((c->onenand.version_id >> 4) & 0xf) { case 0: c->freq = 40; break; case 1: c->freq = 54; break; case 2: c->freq = 66; break; case 3: c->freq = 83; break; } #ifdef CONFIG_MTD_PARTITIONS if (pdata->parts != NULL) r = add_mtd_partitions(&c->mtd, pdata->parts, pdata->nr_parts); else #endif r = add_mtd_device(&c->mtd); if (r < 0) goto err_release_onenand; platform_set_drvdata(pdev, c); return 0; err_release_onenand: onenand_release(&c->mtd); err_release_dma: if (c->dma_channel != -1) omap_free_dma(c->dma_channel); if (c->gpio_irq) free_irq(gpio_to_irq(c->gpio_irq), c); err_release_gpio: if (c->gpio_irq) gpio_free(c->gpio_irq); err_iounmap: iounmap(c->onenand.base); err_release_mem_region: release_mem_region(c->phys_base, ONENAND_IO_SIZE); err_free_cs: gpmc_cs_free(c->gpmc_cs); err_kfree: kfree(c); return r; }
static inline void __init apollon_init_smc91x(void) { unsigned long base; unsigned int rate; struct clk *gpmc_fck; int eth_cs; int err; gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */ if (IS_ERR(gpmc_fck)) { WARN_ON(1); return; } clk_enable(gpmc_fck); rate = clk_get_rate(gpmc_fck); eth_cs = APOLLON_ETH_CS; /* Make sure CS1 timings are correct */ gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1, 0x00011200); if (rate >= 160000000) { gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4); } else if (rate >= 130000000) { gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4); } else {/* rate = 100000000 */ gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F); gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2); } if (gpmc_cs_request(APOLLON_ETH_CS, SZ_16M, &base) < 0) { printk(KERN_ERR "Failed to request GPMC CS for smc91x\n"); goto out; } apollon_smc91x_resources[0].start = base + 0x300; apollon_smc91x_resources[0].end = base + 0x30f; udelay(100); omap_mux_init_gpio(APOLLON_ETHR_GPIO_IRQ, 0); err = gpio_request_one(APOLLON_ETHR_GPIO_IRQ, GPIOF_IN, "SMC91x irq"); if (err) { printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n", APOLLON_ETHR_GPIO_IRQ); gpmc_cs_free(APOLLON_ETH_CS); } out: clk_disable(gpmc_fck); clk_put(gpmc_fck); }
/* * Initialize smc91x device connected to the GPMC. Note that we * assume that pin multiplexing is done in the board-*.c file, * or in the bootloader. */ void __init gpmc_smc91x_init(struct omap_smc91x_platform_data *board_data) { unsigned long cs_mem_base; int ret; gpmc_cfg = board_data; if (gpmc_cfg->flags & GPMC_TIMINGS_SMC91C96) gpmc_cfg->retime = smc91c96_gpmc_retime; if (gpmc_cs_request(gpmc_cfg->cs, SZ_16M, &cs_mem_base) < 0) { printk(KERN_ERR "Failed to request GPMC mem for smc91x\n"); return; } gpmc_smc91x_resources[0].start = cs_mem_base + 0x300; gpmc_smc91x_resources[0].end = cs_mem_base + 0x30f; gpmc_smc91x_resources[1].flags |= (gpmc_cfg->flags & IRQF_TRIGGER_MASK); if (gpmc_cfg->flags & GPMC_MUX_ADD_DATA) smc91x_settings.mux_add_data = GPMC_MUX_AD; if (gpmc_cfg->flags & GPMC_READ_MON) smc91x_settings.wait_on_read = true; if (gpmc_cfg->flags & GPMC_WRITE_MON) smc91x_settings.wait_on_write = true; if (gpmc_cfg->wait_pin) smc91x_settings.wait_pin = gpmc_cfg->wait_pin; ret = gpmc_cs_program_settings(gpmc_cfg->cs, &smc91x_settings); if (ret < 0) goto free1; if (gpmc_cfg->retime) { ret = gpmc_cfg->retime(); if (ret != 0) goto free1; } if (gpio_request_one(gpmc_cfg->gpio_irq, GPIOF_IN, "SMC91X irq") < 0) goto free1; gpmc_smc91x_resources[1].start = gpio_to_irq(gpmc_cfg->gpio_irq); if (gpmc_cfg->gpio_pwrdwn) { ret = gpio_request_one(gpmc_cfg->gpio_pwrdwn, GPIOF_OUT_INIT_LOW, "SMC91X powerdown"); if (ret) goto free2; } if (gpmc_cfg->gpio_reset) { ret = gpio_request_one(gpmc_cfg->gpio_reset, GPIOF_OUT_INIT_LOW, "SMC91X reset"); if (ret) goto free3; gpio_set_value(gpmc_cfg->gpio_reset, 1); msleep(100); gpio_set_value(gpmc_cfg->gpio_reset, 0); } if (platform_device_register(&gpmc_smc91x_device) < 0) { printk(KERN_ERR "Unable to register smc91x device\n"); gpio_free(gpmc_cfg->gpio_reset); goto free3; } return; free3: if (gpmc_cfg->gpio_pwrdwn) gpio_free(gpmc_cfg->gpio_pwrdwn); free2: gpio_free(gpmc_cfg->gpio_irq); free1: gpmc_cs_free(gpmc_cfg->cs); printk(KERN_ERR "Could not initialize smc91x\n"); }
int __devinit gpmc_nand_init(struct omap_nand_platform_data *gpmc_nand_data) { int err = 0; u8 cs = 0; struct device *dev = &gpmc_nand_device.dev; /* if cs not provided, find out the chip-select on which NAND exist */ if (gpmc_nand_data->cs > GPMC_CS_NUM) while (cs < GPMC_CS_NUM) { u32 ret = 0; ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1); if ((ret & 0xC00) == 0x800) { printk(KERN_INFO "Found NAND on CS%d\n", cs); gpmc_nand_data->cs = cs; break; } cs++; } if (gpmc_nand_data->cs > GPMC_CS_NUM) { printk(KERN_INFO "NAND: Unable to find configuration " "in GPMC\n "); return -ENODEV; } gpmc_nand_device.dev.platform_data = gpmc_nand_data; gpmc_nand_data->ctrlr_suspend = gpmc_suspend; gpmc_nand_data->ctrlr_resume = gpmc_resume; printk(KERN_INFO "Registering NAND on CS%d\n", gpmc_nand_data->cs); err = gpmc_cs_request(gpmc_nand_data->cs, NAND_IO_SIZE, &gpmc_nand_data->phys_base); if (err < 0) { dev_err(dev, "Cannot request GPMC CS\n"); return err; } /* Set timings in GPMC */ err = omap2_nand_gpmc_retime(gpmc_nand_data); if (err < 0) { dev_err(dev, "Unable to set gpmc timings: %d\n", err); return err; } /* Enable RD PIN Monitoring Reg */ if (gpmc_nand_data->dev_ready) { gpmc_cs_configure(gpmc_nand_data->cs, GPMC_CONFIG_RDY_BSY, 1); } err = platform_device_register(&gpmc_nand_device); if (err < 0) { dev_err(dev, "Unable to register NAND device\n"); goto out_free_cs; } return 0; out_free_cs: gpmc_cs_free(gpmc_nand_data->cs); return err; }
static int __devinit omap2_onenand_probe(struct platform_device *pdev) { struct omap_onenand_platform_data *pdata; struct omap2_onenand *c; struct onenand_chip *this; int r; pdata = pdev->dev.platform_data; if (pdata == NULL) { dev_err(&pdev->dev, "platform data missing\n"); return -ENODEV; } c = kzalloc(sizeof(struct omap2_onenand), GFP_KERNEL); if (!c) return -ENOMEM; init_completion(&c->irq_done); init_completion(&c->dma_done); c->gpmc_cs = pdata->cs; c->gpio_irq = pdata->gpio_irq; c->dma_channel = pdata->dma_channel; if (c->dma_channel < 0) { /* if -1, don't use DMA */ c->gpio_irq = 0; } r = gpmc_cs_request(c->gpmc_cs, ONENAND_IO_SIZE, &c->phys_base); if (r < 0) { dev_err(&pdev->dev, "Cannot request GPMC CS\n"); goto err_kfree; } if (request_mem_region(c->phys_base, ONENAND_IO_SIZE, pdev->dev.driver->name) == NULL) { dev_err(&pdev->dev, "Cannot reserve memory region at 0x%08lx, " "size: 0x%x\n", c->phys_base, ONENAND_IO_SIZE); r = -EBUSY; goto err_free_cs; } c->onenand.base = ioremap(c->phys_base, ONENAND_IO_SIZE); if (c->onenand.base == NULL) { r = -ENOMEM; goto err_release_mem_region; } if (pdata->onenand_setup != NULL) { r = pdata->onenand_setup(c->onenand.base, &c->freq); if (r < 0) { dev_err(&pdev->dev, "Onenand platform setup failed: " "%d\n", r); goto err_iounmap; } c->setup = pdata->onenand_setup; } if (c->gpio_irq) { if ((r = gpio_request(c->gpio_irq, "OneNAND irq")) < 0) { dev_err(&pdev->dev, "Failed to request GPIO%d for " "OneNAND\n", c->gpio_irq); goto err_iounmap; } gpio_direction_input(c->gpio_irq); if ((r = request_irq(gpio_to_irq(c->gpio_irq), omap2_onenand_interrupt, IRQF_TRIGGER_RISING, pdev->dev.driver->name, c)) < 0) goto err_release_gpio; } if (c->dma_channel >= 0) { r = omap_request_dma(0, pdev->dev.driver->name, omap2_onenand_dma_cb, (void *) c, &c->dma_channel); if (r == 0) { omap_set_dma_write_mode(c->dma_channel, OMAP_DMA_WRITE_NON_POSTED); omap_set_dma_src_data_pack(c->dma_channel, 1); omap_set_dma_src_burst_mode(c->dma_channel, OMAP_DMA_DATA_BURST_8); omap_set_dma_dest_data_pack(c->dma_channel, 1); omap_set_dma_dest_burst_mode(c->dma_channel, OMAP_DMA_DATA_BURST_8); } else { dev_info(&pdev->dev, "failed to allocate DMA for OneNAND, " "using PIO instead\n"); c->dma_channel = -1; } } dev_info(&pdev->dev, "initializing on CS%d, phys base 0x%08lx, virtual " "base %p, freq %d MHz\n", c->gpmc_cs, c->phys_base, c->onenand.base, c->freq); c->pdev = pdev; c->mtd.name = dev_name(&pdev->dev); c->mtd.priv = &c->onenand; c->mtd.owner = THIS_MODULE; c->mtd.dev.parent = &pdev->dev; this = &c->onenand; if (c->dma_channel >= 0) { this->wait = omap2_onenand_wait; if (cpu_is_omap34xx()) { this->read_bufferram = omap3_onenand_read_bufferram; this->write_bufferram = omap3_onenand_write_bufferram; } else { this->read_bufferram = omap2_onenand_read_bufferram; this->write_bufferram = omap2_onenand_write_bufferram; } } if (pdata->regulator_can_sleep) { c->regulator = regulator_get(&pdev->dev, "vonenand"); if (IS_ERR(c->regulator)) { dev_err(&pdev->dev, "Failed to get regulator\n"); goto err_release_dma; } c->onenand.enable = omap2_onenand_enable; c->onenand.disable = omap2_onenand_disable; } if (pdata->skip_initial_unlocking) this->options |= ONENAND_SKIP_INITIAL_UNLOCKING; if ((r = onenand_scan(&c->mtd, 1)) < 0) goto err_release_regulator; r = parse_mtd_partitions(&c->mtd, part_probes, &c->parts, 0); if (r > 0) r = mtd_device_register(&c->mtd, c->parts, r); else if (pdata->parts != NULL) r = mtd_device_register(&c->mtd, pdata->parts, pdata->nr_parts); else r = mtd_device_register(&c->mtd, NULL, 0); if (r) goto err_release_onenand; platform_set_drvdata(pdev, c); return 0; err_release_onenand: onenand_release(&c->mtd); err_release_regulator: regulator_put(c->regulator); err_release_dma: if (c->dma_channel != -1) omap_free_dma(c->dma_channel); if (c->gpio_irq) free_irq(gpio_to_irq(c->gpio_irq), c); err_release_gpio: if (c->gpio_irq) gpio_free(c->gpio_irq); err_iounmap: iounmap(c->onenand.base); err_release_mem_region: release_mem_region(c->phys_base, ONENAND_IO_SIZE); err_free_cs: gpmc_cs_free(c->gpmc_cs); err_kfree: kfree(c->parts); kfree(c); return r; }
static void __init apollon_cs_init(void) { unsigned long base; unsigned int rate; struct clk *l3ck; u32 value; int cs, sync = 0; l3ck = clk_get(NULL, "core_l3_ck"); if (IS_ERR(l3ck)) rate = 100000000; else rate = clk_get_rate(l3ck); /* CS2: OneNAND */ cs = 2; value = gpmc_cs_read_reg(0, GPMC_CS_CONFIG1); gpmc_cs_write_reg(cs, GPMC_CS_CONFIG1, value); value = gpmc_cs_read_reg(0, GPMC_CS_CONFIG2); gpmc_cs_write_reg(cs, GPMC_CS_CONFIG2, value); value = gpmc_cs_read_reg(0, GPMC_CS_CONFIG3); gpmc_cs_write_reg(cs, GPMC_CS_CONFIG3, value); value = gpmc_cs_read_reg(0, GPMC_CS_CONFIG4); gpmc_cs_write_reg(cs, GPMC_CS_CONFIG4, value); value = gpmc_cs_read_reg(0, GPMC_CS_CONFIG5); gpmc_cs_write_reg(cs, GPMC_CS_CONFIG5, value); value = gpmc_cs_read_reg(0, GPMC_CS_CONFIG6); gpmc_cs_write_reg(cs, GPMC_CS_CONFIG6, value); gpmc_cs_write_reg(cs, GPMC_CS_CONFIG7, APOLLON_ONENAND_CS2_ADDRESS); /* CS3: External NOR */ cs = APOLLON_NOR_CS; if (rate >= 160000000) { sync = 1; gpmc_cs_write_reg(cs, GPMC_CS_CONFIG1, 0xe5011211); gpmc_cs_write_reg(cs, GPMC_CS_CONFIG2, 0x00090b01); gpmc_cs_write_reg(cs, GPMC_CS_CONFIG3, 0x00020201); gpmc_cs_write_reg(cs, GPMC_CS_CONFIG4, 0x09030b03); gpmc_cs_write_reg(cs, GPMC_CS_CONFIG5, 0x010a0a0c); gpmc_cs_write_reg(cs, GPMC_CS_CONFIG6, 0x00000000); } else if (rate >= 130000000) { /* Not yet know ... Use the async values */ gpmc_cs_write_reg(cs, GPMC_CS_CONFIG1, 0x00021201); gpmc_cs_write_reg(cs, GPMC_CS_CONFIG2, 0x00121601); gpmc_cs_write_reg(cs, GPMC_CS_CONFIG3, 0x00040401); gpmc_cs_write_reg(cs, GPMC_CS_CONFIG4, 0x12061605); gpmc_cs_write_reg(cs, GPMC_CS_CONFIG5, 0x01151317); gpmc_cs_write_reg(cs, GPMC_CS_CONFIG6, 0x00000000); } else {/* rate = 100000000 */ sync = 1; gpmc_cs_write_reg(cs, GPMC_CS_CONFIG1, 0xe1001202); gpmc_cs_write_reg(cs, GPMC_CS_CONFIG2, 0x00151501); gpmc_cs_write_reg(cs, GPMC_CS_CONFIG3, 0x00050501); gpmc_cs_write_reg(cs, GPMC_CS_CONFIG4, 0x0e070e07); gpmc_cs_write_reg(cs, GPMC_CS_CONFIG5, 0x01131F1F); gpmc_cs_write_reg(cs, GPMC_CS_CONFIG6, 0x00000000); } gpmc_cs_write_reg(cs, GPMC_CS_CONFIG7, APOLLON_EXT_CS3_ADDRESS); if (gpmc_cs_request(cs, SZ_32M, &base) < 0) { printk(KERN_ERR "Failed to request GPMC CS for external\n"); return; } /* Synchronous mode */ if (sync) { void __iomem *addr = ioremap(base, SZ_32M); writew(0xaa, addr + 0xaaa); writew(0x55, addr + 0x554); writew(0xc0, addr + 0x24aaa); iounmap(addr); } gpmc_cs_free(cs); }