⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pxa.c

📁 linux和2410结合开发 用他可以生成2410所需的zImage文件
💻 C
📖 第 1 页 / 共 3 页
字号:
/* * linux/drivers/pcmcia/pxa/pxa.c * * Author:	George Davis * Created:	Jan 10, 2002 * Copyright:	MontaVista Software Inc. *  * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * Originally based upon linux/drivers/pcmcia/sa1100_generic.c * *//*======================================================================    Device driver for the PCMCIA control functionality of Intel    PXA250/210 microprocessors.    The contents of this file are subject to the Mozilla Public    License Version 1.1 (the "License"); you may not use this file    except in compliance with the License. You may obtain a copy of    the License at http://www.mozilla.org/MPL/    Software distributed under the License is distributed on an "AS    IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or    implied. See the License for the specific language governing    rights and limitations under the License.    The initial developer of the original code is John G. Dorsey    <john+@cs.cmu.edu>.  Portions created by John G. Dorsey are    Copyright (C) 1999 John G. Dorsey.  All Rights Reserved.    Alternatively, the contents of this file may be used under the    terms of the GNU Public License version 2 (the "GPL"), in which    case the provisions of the GPL are applicable instead of the    above.  If you wish to allow the use of your version of this file    only under the terms of the GPL and not to allow others to use    your version of this file under the MPL, indicate your decision    by deleting the provisions above and replace them with the notice    and other provisions required by the GPL.  If you do not delete    the provisions above, a recipient may use your version of this    file under either the MPL or the GPL.    ======================================================================*/#include <linux/module.h>#include <linux/init.h>#include <linux/config.h>#include <linux/cpufreq.h>#include <linux/delay.h>#include <linux/ioport.h>#include <linux/kernel.h>#include <linux/tqueue.h>#include <linux/timer.h>#include <linux/mm.h>#include <linux/notifier.h>#include <linux/proc_fs.h>#include <linux/version.h>#include <linux/cpufreq.h>#include <pcmcia/version.h>#include <pcmcia/cs_types.h>#include <pcmcia/cs.h>#include <pcmcia/ss.h>#include <pcmcia/bus_ops.h>#include <asm/hardware.h>#include <asm/io.h>#include <asm/irq.h>#include <asm/system.h>#include <asm/arch/lubbock.h>#include "pxa.h"#ifdef PCMCIA_DEBUGstatic int pc_debug;#endifMODULE_AUTHOR("George Davis <davis_g@mvista.com>");MODULE_DESCRIPTION("Linux PCMCIA Card Services: PXA250/210 Socket Controller");/* This structure maintains housekeeping state for each socket, such * as the last known values of the card detect pins, or the Card Services * callback value associated with the socket: */static struct pxa_pcmcia_socket pxa_pcmcia_socket[PXA_PCMCIA_MAX_SOCK];static int pxa_pcmcia_socket_count;/* Returned by the low-level PCMCIA interface: */static struct pcmcia_low_level *pcmcia_low_level;/* Event poll timer structure */static struct timer_list poll_timer;/* Prototypes for routines which are used internally: */static int  pxa_pcmcia_driver_init(void);static void pxa_pcmcia_driver_shutdown(void);static void pxa_pcmcia_task_handler(void *data);static void pxa_pcmcia_poll_event(unsigned long data);static void pxa_pcmcia_interrupt(int irq, void *dev,				    struct pt_regs *regs);static struct tq_struct pxa_pcmcia_task;#ifdef CONFIG_PROC_FSstatic int  pxa_pcmcia_proc_status(char *buf, char **start, off_t pos,				      int count, int *eof, void *data);#endif/* Prototypes for operations which are exported to the * new-and-impr^H^H^H^H^H^H^H^H^H^H in-kernel PCMCIA core: */static int pxa_pcmcia_init(unsigned int sock);static int pxa_pcmcia_suspend(unsigned int sock);static int pxa_pcmcia_register_callback(unsigned int sock,					   void (*handler)(void *, 							   unsigned int),					   void *info);static int pxa_pcmcia_inquire_socket(unsigned int sock, 					socket_cap_t *cap);static int pxa_pcmcia_get_status(unsigned int sock, u_int *value);static int pxa_pcmcia_get_socket(unsigned int sock, 				    socket_state_t *state);static int pxa_pcmcia_set_socket(unsigned int sock,				    socket_state_t *state);static int pxa_pcmcia_get_io_map(unsigned int sock,				    struct pccard_io_map *io);static int pxa_pcmcia_set_io_map(unsigned int sock,				    struct pccard_io_map *io);static int pxa_pcmcia_get_mem_map(unsigned int sock,				     struct pccard_mem_map *mem);static int pxa_pcmcia_set_mem_map(unsigned int sock,				     struct pccard_mem_map *mem);#ifdef CONFIG_PROC_FSstatic void pxa_pcmcia_proc_setup(unsigned int sock,				     struct proc_dir_entry *base);#endifstatic struct pccard_operations pxa_pcmcia_operations = {  pxa_pcmcia_init,  pxa_pcmcia_suspend,  pxa_pcmcia_register_callback,  pxa_pcmcia_inquire_socket,  pxa_pcmcia_get_status,  pxa_pcmcia_get_socket,  pxa_pcmcia_set_socket,  pxa_pcmcia_get_io_map,  pxa_pcmcia_set_io_map,  pxa_pcmcia_get_mem_map,  pxa_pcmcia_set_mem_map,#ifdef CONFIG_PROC_FS  pxa_pcmcia_proc_setup#endif};#ifdef CONFIG_CPU_FREQ/* forward declaration */static struct notifier_block pxa_pcmcia_notifier_block;#endif/* pxa_pcmcia_driver_init() * ^^^^^^^^^^^^^^^^^^^^^^^^^^^ * * This routine performs a basic sanity check to ensure that this * kernel has been built with the appropriate board-specific low-level * PCMCIA support, performs low-level PCMCIA initialization, registers * this socket driver with Card Services, and then spawns the daemon * thread which is the real workhorse of the socket driver. * * Please see linux/Documentation/arm/SA1100/PCMCIA for more information * on the low-level kernel interface. * * Returns: 0 on success, -1 on error */static int __init pxa_pcmcia_driver_init(void){  servinfo_t info;  struct pcmcia_init pcmcia_init;  struct pcmcia_state state[PXA_PCMCIA_MAX_SOCK];  struct pcmcia_state_array state_array;  unsigned int i, clock;  unsigned long mecr;  printk(KERN_INFO "Intel PXA250/210 PCMCIA (CS release %s)\n", CS_RELEASE);  CardServices(GetCardServicesInfo, &info);  if(info.Revision!=CS_RELEASE_CODE){    printk(KERN_ERR "Card Services release codes do not match\n");    return -1;  }  /* Setup GPIOs for PCMCIA/CF alternate function mode.   *   * It would be nice if set_GPIO_mode included support   * for driving GPIO outputs to default high/low state   * before programming GPIOs as outputs. Setting GPIO   * outputs to default high/low state via GPSR/GPCR   * before defining them as outputs should reduce   * the possibility of glitching outputs during GPIO   * setup. This of course assumes external terminators   * are present to hold GPIOs in a defined state.   *   * In the meantime, setup default state of GPIO   * outputs before we enable them as outputs.   */  GPSR(GPIO48_nPOE) = GPIO_bit(GPIO48_nPOE) |                      GPIO_bit(GPIO49_nPWE) |                      GPIO_bit(GPIO50_nPIOR) |                      GPIO_bit(GPIO51_nPIOW) |                      GPIO_bit(GPIO52_nPCE_1) |                      GPIO_bit(GPIO53_nPCE_2);  set_GPIO_mode(GPIO48_nPOE_MD);  set_GPIO_mode(GPIO49_nPWE_MD);  set_GPIO_mode(GPIO50_nPIOR_MD);  set_GPIO_mode(GPIO51_nPIOW_MD);  set_GPIO_mode(GPIO52_nPCE_1_MD);  set_GPIO_mode(GPIO53_nPCE_2_MD);  set_GPIO_mode(GPIO54_pSKTSEL_MD); /* REVISIT: s/b dependent on num sockets */  set_GPIO_mode(GPIO55_nPREG_MD);  set_GPIO_mode(GPIO56_nPWAIT_MD);  set_GPIO_mode(GPIO57_nIOIS16_MD);  if(machine_is_lubbock()){#ifdef CONFIG_ARCH_LUBBOCK    pcmcia_low_level=&lubbock_pcmcia_ops;#endif  } else if (machine_is_pxa_idp()) {    pcmcia_low_level=&pxa_idp_pcmcia_ops;  } else if( machine_is_pxa_cerf()){    pcmcia_low_level=&cerf_pcmcia_ops;  }  if (!pcmcia_low_level) {    printk(KERN_ERR "This hardware is not supported by the PXA250/210 Card Service driver\n");    return -ENODEV;  }  pcmcia_init.handler=pxa_pcmcia_interrupt;  if((pxa_pcmcia_socket_count=pcmcia_low_level->init(&pcmcia_init))<0){    printk(KERN_ERR "Unable to initialize kernel PCMCIA service.\n");    return -EIO;  }  state_array.size=pxa_pcmcia_socket_count;  state_array.state=state;  /* Configure MECR based on the number of sockets present. */  if (pxa_pcmcia_socket_count == 2) {    MECR |= GPIO_bit(0);  } else {    MECR &= ~GPIO_bit(0);  }  if(pcmcia_low_level->socket_state(&state_array)<0){    printk(KERN_ERR "Unable to get PCMCIA status from kernel.\n");    return -EIO;  }  /* Well, it looks good to go. So we can now enable the PCMCIA   * controller.   */  MECR |= GPIO_bit(1);  /* We need to initialize the MCXX registers to default values   * here because we're not guaranteed to see a SetIOMap operation   * at runtime.   */  clock = get_lclk_frequency_10khz();  for(i=0; i<pxa_pcmcia_socket_count; ++i){    pxa_pcmcia_socket[i].k_state=state[i];    /* This is an interim fix. Apparently, SetSocket is no longer     * called to initialize each socket (prior to the first detect     * event). For now, we'll just manually set up the mask.     */    pxa_pcmcia_socket[i].cs_state.csc_mask=SS_DETECT;    pxa_pcmcia_socket[i].virt_io=(i==0)?PCMCIA_IO_0_BASE:PCMCIA_IO_1_BASE;    pxa_pcmcia_socket[i].phys_attr=_PCMCIAAttr(i);    pxa_pcmcia_socket[i].phys_mem=_PCMCIAMem(i);    /* REVISIT: cleanup these macros */    //MCIO_SET(i, PXA_PCMCIA_IO_ACCESS, clock);    //MCATTR_SET(i, PXA_PCMCIA_5V_MEM_ACCESS, clock);    //MCMEM_SET(i, PXA_PCMCIA_5V_MEM_ACCESS, clock);    pxa_pcmcia_socket[i].speed_io=PXA_PCMCIA_IO_ACCESS;    pxa_pcmcia_socket[i].speed_attr=PXA_PCMCIA_5V_MEM_ACCESS;    pxa_pcmcia_socket[i].speed_mem=PXA_PCMCIA_5V_MEM_ACCESS;  }/* REVISIT: cleanup these macros */MCMEM0 = ((pxa_mcxx_setup(PXA_PCMCIA_5V_MEM_ACCESS, clock)		& MCXX_SETUP_MASK) << MCXX_SETUP_SHIFT)       | ((pxa_mcxx_asst(PXA_PCMCIA_5V_MEM_ACCESS, clock)		& MCXX_ASST_MASK) << MCXX_ASST_SHIFT)       | ((pxa_mcxx_hold(PXA_PCMCIA_5V_MEM_ACCESS, clock)		& MCXX_HOLD_MASK) << MCXX_HOLD_SHIFT);MCMEM1 = ((pxa_mcxx_setup(PXA_PCMCIA_5V_MEM_ACCESS, clock)		& MCXX_SETUP_MASK) << MCXX_SETUP_SHIFT)       | ((pxa_mcxx_asst(PXA_PCMCIA_5V_MEM_ACCESS, clock)		& MCXX_ASST_MASK) << MCXX_ASST_SHIFT)       | ((pxa_mcxx_hold(PXA_PCMCIA_5V_MEM_ACCESS, clock)		& MCXX_HOLD_MASK) << MCXX_HOLD_SHIFT);MCATT0 = ((pxa_mcxx_setup(PXA_PCMCIA_5V_MEM_ACCESS, clock)		& MCXX_SETUP_MASK) << MCXX_SETUP_SHIFT)       | ((pxa_mcxx_asst(PXA_PCMCIA_5V_MEM_ACCESS, clock)		& MCXX_ASST_MASK) << MCXX_ASST_SHIFT)       | ((pxa_mcxx_hold(PXA_PCMCIA_5V_MEM_ACCESS, clock)		& MCXX_HOLD_MASK) << MCXX_HOLD_SHIFT);MCATT1 = ((pxa_mcxx_setup(PXA_PCMCIA_5V_MEM_ACCESS, clock)		& MCXX_SETUP_MASK) << MCXX_SETUP_SHIFT)       | ((pxa_mcxx_asst(PXA_PCMCIA_5V_MEM_ACCESS, clock)		& MCXX_ASST_MASK) << MCXX_ASST_SHIFT)       | ((pxa_mcxx_hold(PXA_PCMCIA_5V_MEM_ACCESS, clock)		& MCXX_HOLD_MASK) << MCXX_HOLD_SHIFT);MCIO0 = ((pxa_mcxx_setup(PXA_PCMCIA_IO_ACCESS, clock)		& MCXX_SETUP_MASK) << MCXX_SETUP_SHIFT)       | ((pxa_mcxx_asst(PXA_PCMCIA_IO_ACCESS, clock)		& MCXX_ASST_MASK) << MCXX_ASST_SHIFT)       | ((pxa_mcxx_hold(PXA_PCMCIA_IO_ACCESS, clock)		& MCXX_HOLD_MASK) << MCXX_HOLD_SHIFT);MCIO1 = ((pxa_mcxx_setup(PXA_PCMCIA_IO_ACCESS, clock)		& MCXX_SETUP_MASK) << MCXX_SETUP_SHIFT)       | ((pxa_mcxx_asst(PXA_PCMCIA_IO_ACCESS, clock)		& MCXX_ASST_MASK) << MCXX_ASST_SHIFT)       | ((pxa_mcxx_hold(PXA_PCMCIA_IO_ACCESS, clock)		& MCXX_HOLD_MASK) << MCXX_HOLD_SHIFT);#ifdef CONFIG_CPU_FREQ  if(cpufreq_register_notifier(&pxa_pcmcia_notifier_block) < 0){    printk(KERN_ERR "Unable to register CPU frequency change notifier\n");    return -ENXIO;  }#endif  /* Only advertise as many sockets as we can detect: */  if(register_ss_entry(pxa_pcmcia_socket_count, 		       &pxa_pcmcia_operations)<0){    printk(KERN_ERR "Unable to register socket service routine\n");    return -ENXIO;  }  /* Start the event poll timer.  It will reschedule by itself afterwards. */  pxa_pcmcia_poll_event(0);  DEBUG(1, "pxa_cs: initialization complete\n");  return 0;}  /* pxa_pcmcia_driver_init() */module_init(pxa_pcmcia_driver_init);/* pxa_pcmcia_driver_shutdown() * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * Invokes the low-level kernel service to free IRQs associated with this * socket controller and reset GPIO edge detection. */static void __exit pxa_pcmcia_driver_shutdown(void){  del_timer_sync(&poll_timer);  unregister_ss_entry(&pxa_pcmcia_operations);#ifdef CONFIG_CPU_FREQ  cpufreq_unregister_notifier(&pxa_pcmcia_notifier_block);#endif  pcmcia_low_level->shutdown();  flush_scheduled_tasks();  DEBUG(1, "pxa_cs: shutdown complete\n");}module_exit(pxa_pcmcia_driver_shutdown);/* pxa_pcmcia_init() * ^^^^^^^^^^^^^^^^^^^^ * We perform all of the interesting initialization tasks in  * pxa_pcmcia_driver_init(). * * Returns: 0 */static int pxa_pcmcia_init(unsigned int sock){    DEBUG(2, "%s(): initializing socket %u\n", __FUNCTION__, sock);  return 0;}/* pxa_pcmcia_suspend() * ^^^^^^^^^^^^^^^^^^^^^^^ * We don't currently perform any actions on a suspend. * * Returns: 0 */static int pxa_pcmcia_suspend(unsigned int sock){  struct pcmcia_configure conf;  int ret;  DEBUG(2, "%s(): suspending socket %u\n", __FUNCTION__, sock);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -