Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
gpmc.c File Reference
#include <linux/irq.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/err.h>
#include <linux/clk.h>
#include <linux/ioport.h>
#include <linux/spinlock.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/interrupt.h>
#include <linux/platform_device.h>
#include <asm/mach-types.h>
#include <plat/gpmc.h>
#include <plat/cpu.h>
#include <plat/sdrc.h>
#include <plat/omap_device.h>
#include "soc.h"
#include "common.h"

Go to the source code of this file.

Data Structures

struct  gpmc_client_irq
 
struct  gpmc_cs_config
 
struct  omap3_gpmc_regs
 

Macros

#define DEVICE_NAME   "omap-gpmc"
 
#define GPMC_REVISION   0x00
 
#define GPMC_SYSCONFIG   0x10
 
#define GPMC_SYSSTATUS   0x14
 
#define GPMC_IRQSTATUS   0x18
 
#define GPMC_IRQENABLE   0x1c
 
#define GPMC_TIMEOUT_CONTROL   0x40
 
#define GPMC_ERR_ADDRESS   0x44
 
#define GPMC_ERR_TYPE   0x48
 
#define GPMC_CONFIG   0x50
 
#define GPMC_STATUS   0x54
 
#define GPMC_PREFETCH_CONFIG1   0x1e0
 
#define GPMC_PREFETCH_CONFIG2   0x1e4
 
#define GPMC_PREFETCH_CONTROL   0x1ec
 
#define GPMC_PREFETCH_STATUS   0x1f0
 
#define GPMC_ECC_CONFIG   0x1f4
 
#define GPMC_ECC_CONTROL   0x1f8
 
#define GPMC_ECC_SIZE_CONFIG   0x1fc
 
#define GPMC_ECC1_RESULT   0x200
 
#define GPMC_ECC_BCH_RESULT_0   0x240 /* not available on OMAP2 */
 
#define GPMC_ECC_CTRL_ECCCLEAR   0x100
 
#define GPMC_ECC_CTRL_ECCDISABLE   0x000
 
#define GPMC_ECC_CTRL_ECCREG1   0x001
 
#define GPMC_ECC_CTRL_ECCREG2   0x002
 
#define GPMC_ECC_CTRL_ECCREG3   0x003
 
#define GPMC_ECC_CTRL_ECCREG4   0x004
 
#define GPMC_ECC_CTRL_ECCREG5   0x005
 
#define GPMC_ECC_CTRL_ECCREG6   0x006
 
#define GPMC_ECC_CTRL_ECCREG7   0x007
 
#define GPMC_ECC_CTRL_ECCREG8   0x008
 
#define GPMC_ECC_CTRL_ECCREG9   0x009
 
#define GPMC_CS0_OFFSET   0x60
 
#define GPMC_CS_SIZE   0x30
 
#define GPMC_MEM_START   0x00000000
 
#define GPMC_MEM_END   0x3FFFFFFF
 
#define BOOT_ROM_SPACE   0x100000 /* 1MB */
 
#define GPMC_CHUNK_SHIFT   24 /* 16 MB */
 
#define GPMC_SECTION_SHIFT   28 /* 128 MB */
 
#define CS_NUM_SHIFT   24
 
#define ENABLE_PREFETCH   (0x1 << 7)
 
#define DMA_MPU_MODE   2
 
#define GPMC_REVISION_MAJOR(l)   ((l >> 4) & 0xf)
 
#define GPMC_REVISION_MINOR(l)   (l & 0xf)
 
#define GPMC_HAS_WR_ACCESS   0x1
 
#define GPMC_HAS_WR_DATA_MUX_BUS   0x2
 
#define GPMC_NR_IRQ   2
 
#define GPMC_SET_ONE(reg, st, end, field)
 

Functions

void gpmc_cs_write_reg (int cs, int idx, u32 val)
 
u32 gpmc_cs_read_reg (int cs, int idx)
 
unsigned long gpmc_get_fclk_period (void)
 
unsigned int gpmc_ns_to_ticks (unsigned int time_ns)
 
unsigned int gpmc_ps_to_ticks (unsigned int time_ps)
 
unsigned int gpmc_ticks_to_ns (unsigned int ticks)
 
unsigned int gpmc_round_ns_to_ticks (unsigned int time_ns)
 
int gpmc_cs_calc_divider (int cs, unsigned int sync_clk)
 
int gpmc_cs_set_timings (int cs, const struct gpmc_timings *t)
 
int gpmc_cs_set_reserved (int cs, int reserved)
 
int gpmc_cs_reserved (int cs)
 
int gpmc_cs_request (int cs, unsigned long size, unsigned long *base)
 
 EXPORT_SYMBOL (gpmc_cs_request)
 
void gpmc_cs_free (int cs)
 
 EXPORT_SYMBOL (gpmc_cs_free)
 
int gpmc_read_status (int cmd)
 
 EXPORT_SYMBOL (gpmc_read_status)
 
int gpmc_cs_configure (int cs, int cmd, int wval)
 
 EXPORT_SYMBOL (gpmc_cs_configure)
 
int gpmc_nand_read (int cs, int cmd)
 
 EXPORT_SYMBOL (gpmc_nand_read)
 
int gpmc_nand_write (int cs, int cmd, int wval)
 
 EXPORT_SYMBOL (gpmc_nand_write)
 
int gpmc_prefetch_enable (int cs, int fifo_th, int dma_mode, unsigned int u32_count, int is_write)
 
 EXPORT_SYMBOL (gpmc_prefetch_enable)
 
int gpmc_prefetch_reset (int cs)
 
 EXPORT_SYMBOL (gpmc_prefetch_reset)
 
void gpmc_update_nand_reg (struct gpmc_nand_regs *reg, int cs)
 
int gpmc_get_client_irq (unsigned irq_config)
 
 postcore_initcall (gpmc_init)
 
 module_exit (gpmc_exit)
 
 postcore_initcall (omap_gpmc_init)
 
int gpmc_enable_hwecc (int cs, int mode, int dev_width, int ecc_size)
 
 EXPORT_SYMBOL_GPL (gpmc_enable_hwecc)
 
int gpmc_calculate_ecc (int cs, const u_char *dat, u_char *ecc_code)
 
 EXPORT_SYMBOL_GPL (gpmc_calculate_ecc)
 

Macro Definition Documentation

#define BOOT_ROM_SPACE   0x100000 /* 1MB */

Definition at line 81 of file gpmc.c.

#define CS_NUM_SHIFT   24

Definition at line 86 of file gpmc.c.

#define DEVICE_NAME   "omap-gpmc"

Definition at line 40 of file gpmc.c.

#define DMA_MPU_MODE   2

Definition at line 88 of file gpmc.c.

#define ENABLE_PREFETCH   (0x1 << 7)

Definition at line 87 of file gpmc.c.

#define GPMC_CHUNK_SHIFT   24 /* 16 MB */

Definition at line 83 of file gpmc.c.

#define GPMC_CONFIG   0x50

Definition at line 51 of file gpmc.c.

#define GPMC_CS0_OFFSET   0x60

Definition at line 76 of file gpmc.c.

#define GPMC_CS_SIZE   0x30

Definition at line 77 of file gpmc.c.

#define GPMC_ECC1_RESULT   0x200

Definition at line 60 of file gpmc.c.

#define GPMC_ECC_BCH_RESULT_0   0x240 /* not available on OMAP2 */

Definition at line 61 of file gpmc.c.

#define GPMC_ECC_CONFIG   0x1f4

Definition at line 57 of file gpmc.c.

#define GPMC_ECC_CONTROL   0x1f8

Definition at line 58 of file gpmc.c.

#define GPMC_ECC_CTRL_ECCCLEAR   0x100

Definition at line 64 of file gpmc.c.

#define GPMC_ECC_CTRL_ECCDISABLE   0x000

Definition at line 65 of file gpmc.c.

#define GPMC_ECC_CTRL_ECCREG1   0x001

Definition at line 66 of file gpmc.c.

#define GPMC_ECC_CTRL_ECCREG2   0x002

Definition at line 67 of file gpmc.c.

#define GPMC_ECC_CTRL_ECCREG3   0x003

Definition at line 68 of file gpmc.c.

#define GPMC_ECC_CTRL_ECCREG4   0x004

Definition at line 69 of file gpmc.c.

#define GPMC_ECC_CTRL_ECCREG5   0x005

Definition at line 70 of file gpmc.c.

#define GPMC_ECC_CTRL_ECCREG6   0x006

Definition at line 71 of file gpmc.c.

#define GPMC_ECC_CTRL_ECCREG7   0x007

Definition at line 72 of file gpmc.c.

#define GPMC_ECC_CTRL_ECCREG8   0x008

Definition at line 73 of file gpmc.c.

#define GPMC_ECC_CTRL_ECCREG9   0x009

Definition at line 74 of file gpmc.c.

#define GPMC_ECC_SIZE_CONFIG   0x1fc

Definition at line 59 of file gpmc.c.

#define GPMC_ERR_ADDRESS   0x44

Definition at line 49 of file gpmc.c.

#define GPMC_ERR_TYPE   0x48

Definition at line 50 of file gpmc.c.

#define GPMC_HAS_WR_ACCESS   0x1

Definition at line 93 of file gpmc.c.

#define GPMC_HAS_WR_DATA_MUX_BUS   0x2

Definition at line 94 of file gpmc.c.

#define GPMC_IRQENABLE   0x1c

Definition at line 47 of file gpmc.c.

#define GPMC_IRQSTATUS   0x18

Definition at line 46 of file gpmc.c.

#define GPMC_MEM_END   0x3FFFFFFF

Definition at line 80 of file gpmc.c.

#define GPMC_MEM_START   0x00000000

Definition at line 79 of file gpmc.c.

#define GPMC_NR_IRQ   2

Definition at line 98 of file gpmc.c.

#define GPMC_PREFETCH_CONFIG1   0x1e0

Definition at line 53 of file gpmc.c.

#define GPMC_PREFETCH_CONFIG2   0x1e4

Definition at line 54 of file gpmc.c.

#define GPMC_PREFETCH_CONTROL   0x1ec

Definition at line 55 of file gpmc.c.

#define GPMC_PREFETCH_STATUS   0x1f0

Definition at line 56 of file gpmc.c.

#define GPMC_REVISION   0x00

Definition at line 43 of file gpmc.c.

#define GPMC_REVISION_MAJOR (   l)    ((l >> 4) & 0xf)

Definition at line 90 of file gpmc.c.

#define GPMC_REVISION_MINOR (   l)    (l & 0xf)

Definition at line 91 of file gpmc.c.

#define GPMC_SECTION_SHIFT   28 /* 128 MB */

Definition at line 84 of file gpmc.c.

#define GPMC_SET_ONE (   reg,
  st,
  end,
  field 
)
Value:
if (set_gpmc_timing_reg(cs, (reg), (st), (end), t->field) < 0) \
return -1

Definition at line 286 of file gpmc.c.

#define GPMC_STATUS   0x54

Definition at line 52 of file gpmc.c.

#define GPMC_SYSCONFIG   0x10

Definition at line 44 of file gpmc.c.

#define GPMC_SYSSTATUS   0x14

Definition at line 45 of file gpmc.c.

#define GPMC_TIMEOUT_CONTROL   0x40

Definition at line 48 of file gpmc.c.

Function Documentation

EXPORT_SYMBOL ( gpmc_cs_request  )
EXPORT_SYMBOL ( gpmc_cs_free  )
EXPORT_SYMBOL ( gpmc_read_status  )
EXPORT_SYMBOL ( gpmc_cs_configure  )
EXPORT_SYMBOL ( gpmc_nand_read  )
EXPORT_SYMBOL ( gpmc_nand_write  )
EXPORT_SYMBOL ( gpmc_prefetch_enable  )
EXPORT_SYMBOL ( gpmc_prefetch_reset  )
EXPORT_SYMBOL_GPL ( gpmc_enable_hwecc  )
EXPORT_SYMBOL_GPL ( gpmc_calculate_ecc  )
int gpmc_calculate_ecc ( int  cs,
const u_char dat,
u_char ecc_code 
)

gpmc_calculate_ecc - generate non-inverted ecc bytes : chip select number : data pointer over which ecc is computed : ecc code buffer

Using non-inverted ECC is considered ugly since writing a blank page (padding) will clear the ECC bytes. This is not a problem as long no one is trying to write data on the seemingly unused page. Reading an erased page will produce an ECC mismatch between generated and read ECC bytes that has to be dealt with separately.

Definition at line 1159 of file gpmc.c.

int gpmc_cs_calc_divider ( int  cs,
unsigned int  sync_clk 
)

Definition at line 291 of file gpmc.c.

int gpmc_cs_configure ( int  cs,
int  cmd,
int  wval 
)

gpmc_cs_configure - write request to configure gpmc : chip select number : command type : value to write

Returns
status of the operation

Definition at line 556 of file gpmc.c.

void gpmc_cs_free ( int  cs)

Definition at line 495 of file gpmc.c.

u32 gpmc_cs_read_reg ( int  cs,
int  idx 
)

Definition at line 185 of file gpmc.c.

int gpmc_cs_request ( int  cs,
unsigned long  size,
unsigned long base 
)

Definition at line 461 of file gpmc.c.

int gpmc_cs_reserved ( int  cs)

Definition at line 410 of file gpmc.c.

int gpmc_cs_set_reserved ( int  cs,
int  reserved 
)

Definition at line 399 of file gpmc.c.

int gpmc_cs_set_timings ( int  cs,
const struct gpmc_timings t 
)

Definition at line 306 of file gpmc.c.

void gpmc_cs_write_reg ( int  cs,
int  idx,
u32  val 
)

Definition at line 177 of file gpmc.c.

int gpmc_enable_hwecc ( int  cs,
int  mode,
int  dev_width,
int  ecc_size 
)

gpmc_enable_hwecc - enable hardware ecc functionality : chip select number : read/write mode : device bus width(1 for x16, 0 for x8) : bytes for which ECC will be generated

Definition at line 1104 of file gpmc.c.

int gpmc_get_client_irq ( unsigned  irq_config)

Definition at line 750 of file gpmc.c.

unsigned long gpmc_get_fclk_period ( void  )

Definition at line 194 of file gpmc.c.

int gpmc_nand_read ( int  cs,
int  cmd 
)

gpmc_nand_read - nand specific read access request : chip select number : command type

Definition at line 622 of file gpmc.c.

int gpmc_nand_write ( int  cs,
int  cmd,
int  wval 
)

gpmc_nand_write - nand specific write request : chip select number : command type : value to write

Definition at line 644 of file gpmc.c.

unsigned int gpmc_ns_to_ticks ( unsigned int  time_ns)

Definition at line 209 of file gpmc.c.

int gpmc_prefetch_enable ( int  cs,
int  fifo_th,
int  dma_mode,
unsigned int  u32_count,
int  is_write 
)

gpmc_prefetch_enable - configures and starts prefetch transfer : cs (chip select) number : fifo threshold to be used for read/ write : dma mode enable (1) or disable (0) : number of bytes to be transferred : prefetch read(0) or write post(1) mode

Definition at line 678 of file gpmc.c.

int gpmc_prefetch_reset ( int  cs)

gpmc_prefetch_reset - disables and stops the prefetch engine

Definition at line 711 of file gpmc.c.

unsigned int gpmc_ps_to_ticks ( unsigned int  time_ps)

Definition at line 219 of file gpmc.c.

int gpmc_read_status ( int  cmd)

gpmc_read_status - read access request to get the different gpmc status : command type

Returns
status

Definition at line 516 of file gpmc.c.

unsigned int gpmc_round_ns_to_ticks ( unsigned int  time_ns)

Definition at line 234 of file gpmc.c.

unsigned int gpmc_ticks_to_ns ( unsigned int  ticks)

Definition at line 229 of file gpmc.c.

void gpmc_update_nand_reg ( struct gpmc_nand_regs reg,
int  cs 
)

Definition at line 730 of file gpmc.c.

module_exit ( gpmc_exit  )
postcore_initcall ( gpmc_init  )
postcore_initcall ( omap_gpmc_init  )