分类: LINUX
2008-09-01 10:44:12
#ifdef CONFIG_PXA27x /* set i2c command & data GPIO */ pxa_gpio_mode(GPIO117_I2CSCL_MD); pxa_gpio_mode(GPIO118_I2CSDA_MD); #endif |
static irqreturn_t i2c_pxa_handler(int this_irq, void *dev_id, struct pt_regs *regs) { int status, wakeup = 0; status = (ISR); if (status & ISR_BED){ (ISR) |= ISR_BED; bus_error=ISR_BED; wakeup = 1; } if (status & ISR_ITE){ (ISR) |= ISR_ITE; tx_finished=ISR_ITE; wakeup = 1; } if (status & ISR_IRF){ (ISR) |= ISR_IRF; rx_finished=ISR_IRF; wakeup = 1; } if (wakeup) { i2c_pending = 1; wake_up_interruptible(&i2c_wait); } return IRQ_HANDLED; } |
struct i2c_algorithm i2c_pxa_algorithm = { .name = "PXA I2C Algorithm", .id = I2C_ALGO_PXA, .master_xfer = i2c_pxa_xfer, .functionality = i2c_pxa_functionality, }; static struct i2c_adapter i2c_pxa_ops = { .owner = THIS_MODULE, .id = I2C_ALGO_PXA, .name = "PXA i2c adapter", .algo_data = &i2c_pxa_data, .retries = 2, }; |
struct i2c_algo_pxa_data { void (*write_byte) (u8 value); u8 (*read_byte) (void); void (*start) (void); void (*repeat_start) (void); void (*stop) (void); void (*abort) (void); int (*wait_bus_not_busy) (void); int (*wait_for_interrupt) (int wait_type); void (*transfer) (int lastbyte, int receive, int midbyte); void (*reset) (void); int udelay; int timeout; }; |
static struct i2c_algo_pxa_data i2c_pxa_data = { write_byte: i2c_pxa_write_byte, read_byte: i2c_pxa_read_byte, start: i2c_pxa_start, repeat_start: i2c_pxa_repeat_start, stop: i2c_pxa_stop, abort: i2c_pxa_abort, wait_bus_not_busy: i2c_pxa_wait_bus_not_busy, wait_for_interrupt: i2c_pxa_wait_for_int, transfer: i2c_pxa_transfer, reset: i2c_pxa_reset, udelay: 10, timeout: DEF_TIMEOUT, }; |
/* place a byte in the transmit register */ static void i2c_pxa_write_byte(u8 value) { IDBR = value; } |
chinaunix网友2009-04-27 10:41:17
版主,请教下,我现在用的也是LINUX2.6.9 CPU 用PXA270 怎么在linux中加载SPI(DMA) 2.6.9 DRIVER中没有SPI 文件夹。要自己建个字符型设备么?能给模板么?我的邮箱是nnnn_777@163.com