Rev 420 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
420 | giacomo | 1 | /* |
2 | * Embedded Planet RPX Lite MPC8xx CPM I2C interface. |
||
3 | * Copyright (c) 1999 Dan Malek (dmalek@jlc.net). |
||
4 | * |
||
5 | * moved into proper i2c interface; |
||
6 | * Brad Parker (brad@heeltoe.com) |
||
7 | * |
||
8 | * RPX lite specific parts of the i2c interface |
||
9 | * Update: There actually isn't anything RPXLite-specific about this module. |
||
10 | * This should work for most any 8xx board. The console messages have been |
||
11 | * changed to eliminate RPXLite references. |
||
12 | */ |
||
13 | |||
14 | #include <linux/kernel.h> |
||
15 | #include <linux/ioport.h> |
||
16 | #include <linux/module.h> |
||
17 | #include <linux/init.h> |
||
18 | #include <linux/stddef.h> |
||
19 | #include <linux/parport.h> |
||
20 | #include <linux/i2c.h> |
||
21 | #include <linux/i2c-algo-8xx.h> |
||
22 | #include <asm/mpc8xx.h> |
||
23 | #include <asm/commproc.h> |
||
24 | |||
25 | |||
26 | static void |
||
27 | rpx_iic_init(struct i2c_algo_8xx_data *data) |
||
28 | { |
||
29 | volatile cpm8xx_t *cp; |
||
30 | volatile immap_t *immap; |
||
31 | |||
32 | cp = cpmp; /* Get pointer to Communication Processor */ |
||
33 | immap = (immap_t *)IMAP_ADDR; /* and to internal registers */ |
||
34 | |||
35 | data->iip = (iic_t *)&cp->cp_dparam[PROFF_IIC]; |
||
36 | |||
37 | /* Check for and use a microcode relocation patch. |
||
38 | */ |
||
39 | if ((data->reloc = data->iip->iic_rpbase)) |
||
40 | data->iip = (iic_t *)&cp->cp_dpmem[data->iip->iic_rpbase]; |
||
41 | |||
42 | data->i2c = (i2c8xx_t *)&(immap->im_i2c); |
||
43 | data->cp = cp; |
||
44 | |||
45 | /* Initialize Port B IIC pins. |
||
46 | */ |
||
47 | cp->cp_pbpar |= 0x00000030; |
||
48 | cp->cp_pbdir |= 0x00000030; |
||
49 | cp->cp_pbodr |= 0x00000030; |
||
50 | |||
51 | /* Allocate space for two transmit and two receive buffer |
||
52 | * descriptors in the DP ram. |
||
53 | */ |
||
54 | data->dp_addr = m8xx_cpm_dpalloc(sizeof(cbd_t) * 4); |
||
55 | |||
56 | /* ptr to i2c area */ |
||
57 | data->i2c = (i2c8xx_t *)&(((immap_t *)IMAP_ADDR)->im_i2c); |
||
58 | } |
||
59 | |||
60 | static int rpx_install_isr(int irq, void (*func)(void *, void *), void *data) |
||
61 | { |
||
62 | /* install interrupt handler */ |
||
63 | cpm_install_handler(irq, (void (*)(void *, struct pt_regs *)) func, data); |
||
64 | |||
65 | return 0; |
||
66 | } |
||
67 | |||
68 | static struct i2c_algo_8xx_data rpx_data = { |
||
69 | .setisr = rpx_install_isr |
||
70 | }; |
||
71 | |||
72 | static struct i2c_adapter rpx_ops = { |
||
73 | .owner = THIS_MODULE, |
||
74 | .name = "m8xx", |
||
75 | .id = I2C_HW_MPC8XX_EPON, |
||
76 | .algo_data = &rpx_data, |
||
77 | }; |
||
78 | |||
79 | int __init i2c_rpx_init(void) |
||
80 | { |
||
81 | printk(KERN_INFO "i2c-rpx: i2c MPC8xx driver\n"); |
||
82 | |||
83 | /* reset hardware to sane state */ |
||
84 | rpx_iic_init(&rpx_data); |
||
85 | |||
86 | if (i2c_8xx_add_bus(&rpx_ops) < 0) { |
||
87 | printk("i2c-rpx: Unable to register with I2C\n"); |
||
88 | return -ENODEV; |
||
89 | } |
||
90 | |||
91 | return 0; |
||
92 | } |
||
93 | |||
94 | void __exit i2c_rpx_exit(void) |
||
95 | { |
||
96 | i2c_8xx_del_bus(&rpx_ops); |
||
97 | } |
||
98 | |||
99 | MODULE_AUTHOR("Dan Malek <dmalek@jlc.net>"); |
||
100 | MODULE_DESCRIPTION("I2C-Bus adapter routines for MPC8xx boards"); |
||
101 | |||
102 | module_init(i2c_rpx_init); |
||
103 | module_exit(i2c_rpx_exit); |