?? hal_x86.c
字號:
* __u16 dir ---> Direction ( Inc or Dec)
*
* Output int Length ----> Number of bytes read
*
* Called by: system function
*
*
*--------------------------------------------------------------*/
/* Memory read function IO */
int
isp1761_mem_write(struct isp1761_dev *dev,
__u32 start_add, __u32 end_add,
__u32 * buffer, __u32 length,
__u16 dir)
{
u8 *temp_base_mem = 0;
int a = length;
u8 *temp = (u8*)buffer;
u8 one =(u8 )(*buffer);
u16 two =(u16 )(*buffer);
temp_base_mem = (dev->baseaddress + start_add);
if(a == 1){
writeb(one,temp_base_mem);
return 0;
}
if(a == 2){
writew(two,temp_base_mem);
return 0;
}
while(a>0){
writel(*buffer, temp_base_mem);
temp_base_mem = temp_base_mem+4;
start_add +=4;
a -=4;
if(a <= 0)
break;
buffer += 1;
}
return ((a < 0) || (a == 0))?0:(-1);
}
/*--------------------------------------------------------------*
*
* Module dtatils: isp1761_check_mem_region
*
* Check the memory region for Memory Mapping
* Check with the system about the availability of the region,
* and returns success, if available.
*
* Input: struct isp1761_driver *drv --> Driver structure.
*
* Output result
*
*
* Called by: system function
*
*
*--------------------------------------------------------------*/
int isp1761_check_mem_region(struct isp1761_dev *dev)
{
int ret;
ret=check_mem_region(dev->start, dev->length);
return ret;
}/* End of isp1761_check_mem_region */
/*--------------------------------------------------------------*
*
* Module dtatils: isp1761_request_mem_region
isp1761_release_mem_region
isp1761_get_mem_params
*
* If the check returns Success, we can request the region for
* Memory mapping of our chip memory
*
* Input: struct isp1761_driver *drv --> Driver structure.
*
* Output result
*
*
* Called by: system function
*
*
*--------------------------------------------------------------*/
struct resource* isp1761_request_mem_region(struct isp1761_dev *dev)
{
dev->mem_res = request_mem_region(dev->start, dev->length, "Isp1761_device");
return dev->mem_res;
}/* End of isp1761_request_mem_region */
/* Release an already acquired memory region.
It should be done at the rmmod of the module */
void isp1761_release_mem_region(struct isp1761_dev* dev)
{
release_mem_region (dev->start, dev->length);
}
/* Get the start address and length of Mapped Memory */
void isp1761_get_mem_params(struct isp1761_dev *dev,struct isp1761_driver *drv)
{
dev->start =isp1761_loc_dev[drv->index].start;
dev->length =isp1761_loc_dev[drv->index].length;
}/* End of isp1761_get_mem_params*/
/*--------------------------------------------------------------*
*
* Module dtatils: isp1761_request_irq
*
* This function registers the ISR of driver with this driver.
* Since there is only one interrupt line, when the first driver
* is registerd, will call the system function request_irq. The PLX
* bridge needs enabling of interrupt in the interrupt control register to
* pass the local interrupts to the PCI (cpu).
* For later registrations will just update the variables. On ISR, this driver
* will look for registered handlers and calls the corresponding driver's
* ISR "handler" function with "isr_data" as parameter.
*
* Input: struct
* (void (*handler)(struct isp1761_dev *, void *)-->handler.
* isp1761_driver *drv --> Driver structure.
* Output result
* 0= complete
* 1= error.
*
* Called by: system function module_init
*
*
*--------------------------------------------------------------*/
int isp1761_request_irq(void (*handler)(struct isp1761_dev *, void *),
struct isp1761_dev *dev, void *isr_data)
{
int result = 0;
u32 intcsr = 0;
hal_entry("%s: Entered\n",__FUNCTION__);
hal_int("isp1761_request_irq: dev->index %x\n",dev->index);
if(dev->index == ISP1761_DC){
result = request_irq(dev->irq, isp1761_pci_dc_isr,
SA_SHIRQ,
dev->name,
isr_data);
}else {
result= request_irq(dev->irq,isp1761_pci_isr,
SA_SHIRQ,
dev->name,
isr_data);
}
/*CONFIGURE PCI/PLX interrupt*/
intcsr = readl(iobase+0x68);
intcsr |= 0x900;
writel(intcsr,iobase+0x68);
/*Interrupt handler routine*/
dev->handler = handler;
dev->isr_data = isr_data;
hal_int("isp1761_request_irq: dev->handler %s\n",dev->handler);
hal_int("isp1761_request_irq: dev->isr_data %x\n",dev->isr_data);
hal_entry("%s: Exit\n",__FUNCTION__);
return result;
} /* End of isp1761_request_irq */
/*--------------------------------------------------------------*
*
* Module dtatils: isp1761_free_irq
*
* This function de-registers the ISR of driver with this driver.
* Since there is only one interrupt line, when the last driver
* is de-registerd, will call the system function free_irq. The PLX
* bridge needs disabling of interrupt in the interrupt control register to
* block the local interrupts to the PCI (cpu).
*
* Input: struct
* (void (*handler)(struct isp1761_dev *, void *)-->handler.
* isp1761_driver *drv --> Driver structure.
* Output result
* 0= complete
* 1= error.
*
* Called by: system function module_init
*
*
*--------------------------------------------------------------*/
void isp1761_free_irq(struct isp1761_dev *dev, void *isr_data)
{
__u32 intcsr;
hal_int(("isp1761_free_irq(dev=%p,isr_data=%p)\n",dev,isr_data));
free_irq(dev->irq,isr_data);
/*disable the plx/pci interrupt*/
intcsr = readl(iobase+0x68);
intcsr &= ~0x900;
writel(intcsr,iobase+0x68);
} /* isp1761_free_irq */
/* Allocate Fragmented kernel Memory */
void* isp_1761_kmalloc(size_t size,int flags)
{
void* ret;
ret =kmalloc(size,flags);
return ret;
}
/* Free the memory allocated by kmalloc */
void isp_1761_kfree(const void* objp)
{
kfree(objp);
}
/* Allocate Contiguous kernel Memory */
void* isp_1761_vmalloc(__u32 size, __u16 flags, pgprot_t prot)
{
void* ret;
ret =__vmalloc(size, flags, prot);
return ret;
}
/* Free the memory allocated by vmalloc */
void isp_1761_vfree(const void* objp)
{
kfree(objp);
}
/*--------------------------------------------------------------*
*
* Module dtatils: isp1761_register_driver
*
* This function is used by top driver (OTG, HCD, DCD) to register
* their communication functions (probe, remove, suspend, resume) using
* the drv data structure.
* This function will call the probe function of the driver if the ISP1761
* corresponding to the driver is enabled
*
* Input: struct isp1761_driver *drv --> Driver structure.
* Output result
* 0= complete
* 1= error.
*
* Called by: system function module_init
*
*
*--------------------------------------------------------------*/
int isp1761_register_driver(struct isp1761_driver *drv)
{
struct isp1761_dev *dev;
int result;
isp1761_id *id;
hal_entry("%s: Entered\n",__FUNCTION__);
info("isp1761_register_driver(drv=%p) \n",drv);
if(!drv) return -EINVAL;
dev = &isp1761_loc_dev[drv->index];
if(drv->index == ISP1761_DC){/*FIX for device*/
result = drv->probe(dev,drv->id);
}else{
id = drv->id;
if(dev->active) result = drv->probe(dev,id);
else result = -ENODEV;
}
if(result >= 0 ) {
printk(KERN_INFO __FILE__ ": Registered Driver %s\n",
drv->name);
dev->driver = drv;
}
hal_entry("%s: Exit\n",__FUNCTION__);
return result;
} /* End of isp1761_register_driver */
/*--------------------------------------------------------------*
*
* Module dtatils: isp1761_unregister_driver
*
* This function is used by top driver (OTG, HCD, DCD) to de-register
* their communication functions (probe, remove, suspend, resume) using
* the drv data structure.
* This function will check whether the driver is registered or not and
* call the remove function of the driver if registered
*
* Input: struct isp1761_driver *drv --> Driver structure.
* Output result
* 0= complete
* 1= error.
*
* Called by: system function module_init
*
*
*--------------------------------------------------------------*/
void isp1761_unregister_driver(struct isp1761_driver *drv)
{
struct isp1761_dev *dev;
hal_entry("%s: Entered\n",__FUNCTION__);
info("isp1761_unregister_driver(drv=%p)\n",drv);
dev = &isp1761_loc_dev[drv->index];
if(dev->driver == drv) {
/* driver registered is same as the requestig driver */
drv->remove(dev);
dev->driver = NULL;
info(": De-registered Driver %s\n",
drv->name);
return;
}
hal_entry("%s: Exit\n",__FUNCTION__);
} /* End of isp1761_unregister_driver */
/*--------------------------------------------------------------*
* ISP1761 PCI driver interface routine.
*--------------------------------------------------------------*/
/*--------------------------------------------------------------*
*
* Module dtatils: isp1761_pci_module_init
*
* This is the module initialization function. It registers to
* PCI driver for a PLX PCI bridge device. And also resets the
* internal data structures before registering to PCI driver.
*
* Input: void
* Output result
* 0= complete
* 1= error.
*
* Called by: system function module_init
*
*
*
-------------------------------------------------------------------*/
static int __init isp1761_pci_module_init (void)
{
int result = 0;
hal_entry("%s: Entered\n",__FUNCTION__);
memset(isp1761_loc_dev,0,sizeof(isp1761_loc_dev));
if((result = pci_module_init(&isp1761_pci_driver)) < 0) {
printk("PCI Iinitialization Fail(error = %d)\n",result);
return result;
}
else
info(": %s PCI Initialization Success \n",isp1761_driver_name);
hal_entry("%s: Exit\n",__FUNCTION__);
return result;
}
/*--------------------------------------------------------------*
*
* Module dtatils: isp1761_pci_module_cleanup
*
* This is the module cleanup function. It de-registers from
* PCI driver and resets the internal data structures.
*
* Input: void
* Output void
*
* Called by: system function module_cleanup
*
*
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -