summaryrefslogtreecommitdiffstats
path: root/arch/cris/arch-v32/kernel
diff options
context:
space:
mode:
authorJesper Nilsson <jespern@stork.se.axis.com>2007-11-29 17:11:23 +0100
committerJesper Nilsson <jesper.nilsson@axis.com>2008-02-08 11:06:23 +0100
commit035e111f9a9b29843bc899f03d56f19d94bebb53 (patch)
treecb46b3c0eb6d9f2cc915522153454d3acaa7fcda /arch/cris/arch-v32/kernel
parent6107c61fd3e6b47106b078db1726ad814564efef (diff)
CRIS v32: Add new machine dependent files for Etrax-FS and Artpec-3.
The two chips are somewhat different, and needs different handling. Adds handing of the dma, dram initialization, hardware settings, io, memory arbiter and pinmux Also moves the dma, dram initialization and io from CRIS v32 common files.
Diffstat (limited to 'arch/cris/arch-v32/kernel')
-rw-r--r--arch/cris/arch-v32/kernel/dma.c224
-rw-r--r--arch/cris/arch-v32/kernel/io.c153
2 files changed, 0 insertions, 377 deletions
diff --git a/arch/cris/arch-v32/kernel/dma.c b/arch/cris/arch-v32/kernel/dma.c
deleted file mode 100644
index 570e19128ff..00000000000
--- a/arch/cris/arch-v32/kernel/dma.c
+++ /dev/null
@@ -1,224 +0,0 @@
-/* Wrapper for DMA channel allocator that starts clocks etc */
-
-#include <linux/kernel.h>
-#include <linux/spinlock.h>
-#include <asm/dma.h>
-#include <asm/arch/hwregs/reg_map.h>
-#include <asm/arch/hwregs/reg_rdwr.h>
-#include <asm/arch/hwregs/marb_defs.h>
-#include <asm/arch/hwregs/config_defs.h>
-#include <asm/arch/hwregs/strmux_defs.h>
-#include <linux/errno.h>
-#include <asm/system.h>
-#include <asm/arch/arbiter.h>
-
-static char used_dma_channels[MAX_DMA_CHANNELS];
-static const char * used_dma_channels_users[MAX_DMA_CHANNELS];
-
-static DEFINE_SPINLOCK(dma_lock);
-
-int crisv32_request_dma(unsigned int dmanr, const char * device_id,
- unsigned options, unsigned int bandwidth,
- enum dma_owner owner)
-{
- unsigned long flags;
- reg_config_rw_clk_ctrl clk_ctrl;
- reg_strmux_rw_cfg strmux_cfg;
-
- if (crisv32_arbiter_allocate_bandwidth(dmanr,
- options & DMA_INT_MEM ? INT_REGION : EXT_REGION,
- bandwidth))
- return -ENOMEM;
-
- spin_lock_irqsave(&dma_lock, flags);
-
- if (used_dma_channels[dmanr]) {
- spin_unlock_irqrestore(&dma_lock, flags);
- if (options & DMA_VERBOSE_ON_ERROR) {
- printk("Failed to request DMA %i for %s, already allocated by %s\n", dmanr, device_id, used_dma_channels_users[dmanr]);
- }
- if (options & DMA_PANIC_ON_ERROR)
- panic("request_dma error!");
- return -EBUSY;
- }
- clk_ctrl = REG_RD(config, regi_config, rw_clk_ctrl);
- strmux_cfg = REG_RD(strmux, regi_strmux, rw_cfg);
-
- switch(dmanr)
- {
- case 0:
- case 1:
- clk_ctrl.dma01_eth0 = 1;
- break;
- case 2:
- case 3:
- clk_ctrl.dma23 = 1;
- break;
- case 4:
- case 5:
- clk_ctrl.dma45 = 1;
- break;
- case 6:
- case 7:
- clk_ctrl.dma67 = 1;
- break;
- case 8:
- case 9:
- clk_ctrl.dma89_strcop = 1;
- break;
-#if MAX_DMA_CHANNELS-1 != 9
-#error Check dma.c
-#endif
- default:
- spin_unlock_irqrestore(&dma_lock, flags);
- if (options & DMA_VERBOSE_ON_ERROR) {
- printk("Failed to request DMA %i for %s, only 0-%i valid)\n", dmanr, device_id, MAX_DMA_CHANNELS-1);
- }
-
- if (options & DMA_PANIC_ON_ERROR)
- panic("request_dma error!");
- return -EINVAL;
- }
-
- switch(owner)
- {
- case dma_eth0:
- if (dmanr == 0)
- strmux_cfg.dma0 = regk_strmux_eth0;
- else if (dmanr == 1)
- strmux_cfg.dma1 = regk_strmux_eth0;
- else
- panic("Invalid DMA channel for eth0\n");
- break;
- case dma_eth1:
- if (dmanr == 6)
- strmux_cfg.dma6 = regk_strmux_eth1;
- else if (dmanr == 7)
- strmux_cfg.dma7 = regk_strmux_eth1;
- else
- panic("Invalid DMA channel for eth1\n");
- break;
- case dma_iop0:
- if (dmanr == 2)
- strmux_cfg.dma2 = regk_strmux_iop0;
- else if (dmanr == 3)
- strmux_cfg.dma3 = regk_strmux_iop0;
- else
- panic("Invalid DMA channel for iop0\n");
- break;
- case dma_iop1:
- if (dmanr == 4)
- strmux_cfg.dma4 = regk_strmux_iop1;
- else if (dmanr == 5)
- strmux_cfg.dma5 = regk_strmux_iop1;
- else
- panic("Invalid DMA channel for iop1\n");
- break;
- case dma_ser0:
- if (dmanr == 6)
- strmux_cfg.dma6 = regk_strmux_ser0;
- else if (dmanr == 7)
- strmux_cfg.dma7 = regk_strmux_ser0;
- else
- panic("Invalid DMA channel for ser0\n");
- break;
- case dma_ser1:
- if (dmanr == 4)
- strmux_cfg.dma4 = regk_strmux_ser1;
- else if (dmanr == 5)
- strmux_cfg.dma5 = regk_strmux_ser1;
- else
- panic("Invalid DMA channel for ser1\n");
- break;
- case dma_ser2:
- if (dmanr == 2)
- strmux_cfg.dma2 = regk_strmux_ser2;
- else if (dmanr == 3)
- strmux_cfg.dma3 = regk_strmux_ser2;
- else
- panic("Invalid DMA channel for ser2\n");
- break;
- case dma_ser3:
- if (dmanr == 8)
- strmux_cfg.dma8 = regk_strmux_ser3;
- else if (dmanr == 9)
- strmux_cfg.dma9 = regk_strmux_ser3;
- else
- panic("Invalid DMA channel for ser3\n");
- break;
- case dma_sser0:
- if (dmanr == 4)
- strmux_cfg.dma4 = regk_strmux_sser0;
- else if (dmanr == 5)
- strmux_cfg.dma5 = regk_strmux_sser0;
- else
- panic("Invalid DMA channel for sser0\n");
- break;
- case dma_sser1:
- if (dmanr == 6)
- strmux_cfg.dma6 = regk_strmux_sser1;
- else if (dmanr == 7)
- strmux_cfg.dma7 = regk_strmux_sser1;
- else
- panic("Invalid DMA channel for sser1\n");
- break;
- case dma_ata:
- if (dmanr == 2)
- strmux_cfg.dma2 = regk_strmux_ata;
- else if (dmanr == 3)
- strmux_cfg.dma3 = regk_strmux_ata;
- else
- panic("Invalid DMA channel for ata\n");
- break;
- case dma_strp:
- if (dmanr == 8)
- strmux_cfg.dma8 = regk_strmux_strcop;
- else if (dmanr == 9)
- strmux_cfg.dma9 = regk_strmux_strcop;
- else
- panic("Invalid DMA channel for strp\n");
- break;
- case dma_ext0:
- if (dmanr == 6)
- strmux_cfg.dma6 = regk_strmux_ext0;
- else
- panic("Invalid DMA channel for ext0\n");
- break;
- case dma_ext1:
- if (dmanr == 7)
- strmux_cfg.dma7 = regk_strmux_ext1;
- else
- panic("Invalid DMA channel for ext1\n");
- break;
- case dma_ext2:
- if (dmanr == 2)
- strmux_cfg.dma2 = regk_strmux_ext2;
- else if (dmanr == 8)
- strmux_cfg.dma8 = regk_strmux_ext2;
- else
- panic("Invalid DMA channel for ext2\n");
- break;
- case dma_ext3:
- if (dmanr == 3)
- strmux_cfg.dma3 = regk_strmux_ext3;
- else if (dmanr == 9)
- strmux_cfg.dma9 = regk_strmux_ext2;
- else
- panic("Invalid DMA channel for ext2\n");
- break;
- }
-
- used_dma_channels[dmanr] = 1;
- used_dma_channels_users[dmanr] = device_id;
- REG_WR(config, regi_config, rw_clk_ctrl, clk_ctrl);
- REG_WR(strmux, regi_strmux, rw_cfg, strmux_cfg);
- spin_unlock_irqrestore(&dma_lock,flags);
- return 0;
-}
-
-void crisv32_free_dma(unsigned int dmanr)
-{
- spin_lock(&dma_lock);
- used_dma_channels[dmanr] = 0;
- spin_unlock(&dma_lock);
-}
diff --git a/arch/cris/arch-v32/kernel/io.c b/arch/cris/arch-v32/kernel/io.c
deleted file mode 100644
index a22a9e02e09..00000000000
--- a/arch/cris/arch-v32/kernel/io.c
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Helper functions for I/O pins.
- *
- * Copyright (c) 2004 Axis Communications AB.
- */
-
-#include <linux/types.h>
-#include <linux/errno.h>
-#include <linux/init.h>
-#include <linux/string.h>
-#include <linux/ctype.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <asm/io.h>
-#include <asm/arch/pinmux.h>
-#include <asm/arch/hwregs/gio_defs.h>
-
-struct crisv32_ioport crisv32_ioports[] =
-{
- {
- (unsigned long*)REG_ADDR(gio, regi_gio, rw_pa_oe),
- (unsigned long*)REG_ADDR(gio, regi_gio, rw_pa_dout),
- (unsigned long*)REG_ADDR(gio, regi_gio, r_pa_din),
- 8
- },
- {
- (unsigned long*)REG_ADDR(gio, regi_gio, rw_pb_oe),
- (unsigned long*)REG_ADDR(gio, regi_gio, rw_pb_dout),
- (unsigned long*)REG_ADDR(gio, regi_gio, r_pb_din),
- 18
- },
- {
- (unsigned long*)REG_ADDR(gio, regi_gio, rw_pc_oe),
- (unsigned long*)REG_ADDR(gio, regi_gio, rw_pc_dout),
- (unsigned long*)REG_ADDR(gio, regi_gio, r_pc_din),
- 18
- },
- {
- (unsigned long*)REG_ADDR(gio, regi_gio, rw_pd_oe),
- (unsigned long*)REG_ADDR(gio, regi_gio, rw_pd_dout),
- (unsigned long*)REG_ADDR(gio, regi_gio, r_pd_din),
- 18
- },
- {
- (unsigned long*)REG_ADDR(gio, regi_gio, rw_pe_oe),
- (unsigned long*)REG_ADDR(gio, regi_gio, rw_pe_dout),
- (unsigned long*)REG_ADDR(gio, regi_gio, r_pe_din),
- 18
- }
-};
-
-#define NBR_OF_PORTS ARRAY_SIZE(crisv32_ioports)
-
-struct crisv32_iopin crisv32_led1_green;
-struct crisv32_iopin crisv32_led1_red;
-struct crisv32_iopin crisv32_led2_green;
-struct crisv32_iopin crisv32_led2_red;
-struct crisv32_iopin crisv32_led3_green;
-struct crisv32_iopin crisv32_led3_red;
-
-/* Dummy port used when green LED and red LED is on the same bit */
-static unsigned long io_dummy;
-static struct crisv32_ioport dummy_port =
-{
- &io_dummy,
- &io_dummy,
- &io_dummy,
- 18
-};
-static struct crisv32_iopin dummy_led =
-{
- &dummy_port,
- 0
-};
-
-static int __init crisv32_io_init(void)
-{
- int ret = 0;
- /* Initialize LEDs */
- ret += crisv32_io_get_name(&crisv32_led1_green, CONFIG_ETRAX_LED1G);
- ret += crisv32_io_get_name(&crisv32_led1_red, CONFIG_ETRAX_LED1R);
- ret += crisv32_io_get_name(&crisv32_led2_green, CONFIG_ETRAX_LED2G);
- ret += crisv32_io_get_name(&crisv32_led2_red, CONFIG_ETRAX_LED2R);
- ret += crisv32_io_get_name(&crisv32_led3_green, CONFIG_ETRAX_LED3G);
- ret += crisv32_io_get_name(&crisv32_led3_red, CONFIG_ETRAX_LED3R);
- crisv32_io_set_dir(&crisv32_led1_green, crisv32_io_dir_out);
- crisv32_io_set_dir(&crisv32_led1_red, crisv32_io_dir_out);
- crisv32_io_set_dir(&crisv32_led2_green, crisv32_io_dir_out);
- crisv32_io_set_dir(&crisv32_led2_red, crisv32_io_dir_out);
- crisv32_io_set_dir(&crisv32_led3_green, crisv32_io_dir_out);
- crisv32_io_set_dir(&crisv32_led3_red, crisv32_io_dir_out);
-
- if (!strcmp(CONFIG_ETRAX_LED1G, CONFIG_ETRAX_LED1R))
- crisv32_led1_red = dummy_led;
- if (!strcmp(CONFIG_ETRAX_LED2G, CONFIG_ETRAX_LED2R))
- crisv32_led2_red = dummy_led;
-
- return ret;
-}
-
-__initcall(crisv32_io_init);
-
-int crisv32_io_get(struct crisv32_iopin* iopin,
- unsigned int port, unsigned int pin)
-{
- if (port > NBR_OF_PORTS)
- return -EINVAL;
- if (port > crisv32_ioports[port].pin_count)
- return -EINVAL;
-
- iopin->bit = 1 << pin;
- iopin->port = &crisv32_ioports[port];
-
- if (crisv32_pinmux_alloc(port, pin, pin, pinmux_gpio))
- return -EIO;
-
- return 0;
-}
-
-int crisv32_io_get_name(struct crisv32_iopin* iopin,
- char* name)
-{
- int port;
- int pin;
-
- if (toupper(*name) == 'P')
- name++;
-
- if (toupper(*name) < 'A' || toupper(*name) > 'E')
- return -EINVAL;
-
- port = toupper(*name) - 'A';
- name++;
- pin = simple_strtoul(name, NULL, 10);
-
- if (pin < 0 || pin > crisv32_ioports[port].pin_count)
- return -EINVAL;
-
- iopin->bit = 1 << pin;
- iopin->port = &crisv32_ioports[port];
-
- if (crisv32_pinmux_alloc(port, pin, pin, pinmux_gpio))
- return -EIO;
-
- return 0;
-}
-
-#ifdef CONFIG_PCI
-/* PCI I/O access stuff */
-struct cris_io_operations* cris_iops = NULL;
-EXPORT_SYMBOL(cris_iops);
-#endif
-