root/i2c/trunk/kernel/i2c-rpx.c @ 3759

Revision 3759, 2.4 KB (checked in by kmalkki, 12 years ago)

(Kyösti)

More C99 initializers. More initcalls.

Replace <linux/i2c*.h> with "i2c*.h" in CVS files.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
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
21#include <asm/mpc8xx.h>
22#include <asm/commproc.h>
23
24#include "i2c.h"
25#include "i2c-algo-8xx.h"
26
27static void
28rpx_iic_init(struct i2c_algo_8xx_data *data)
29{
30        volatile cpm8xx_t *cp;
31        volatile immap_t *immap;
32
33        cp = cpmp;      /* Get pointer to Communication Processor */
34        immap = (immap_t *)IMAP_ADDR;   /* and to internal registers */
35
36        data->iip = (iic_t *)&cp->cp_dparam[PROFF_IIC];
37
38        /* Check for and use a microcode relocation patch.
39        */
40        if ((data->reloc = data->iip->iic_rpbase))
41                data->iip = (iic_t *)&cp->cp_dpmem[data->iip->iic_rpbase];
42               
43        data->i2c = (i2c8xx_t *)&(immap->im_i2c);
44        data->cp = cp;
45
46        /* Initialize Port B IIC pins.
47        */
48        cp->cp_pbpar |= 0x00000030;
49        cp->cp_pbdir |= 0x00000030;
50        cp->cp_pbodr |= 0x00000030;
51
52        /* Allocate space for two transmit and two receive buffer
53         * descriptors in the DP ram.
54         */
55        data->dp_addr = m8xx_cpm_dpalloc(sizeof(cbd_t) * 4);
56
57        /* ptr to i2c area */
58        data->i2c = (i2c8xx_t *)&(((immap_t *)IMAP_ADDR)->im_i2c);
59}
60
61static int rpx_install_isr(int irq, void (*func)(void *, void *), void *data)
62{
63        /* install interrupt handler */
64        cpm_install_handler(irq, (void (*)(void *, struct pt_regs *)) func, data);
65
66        return 0;
67}
68
69static struct i2c_algo_8xx_data rpx_data = {
70        .setisr = rpx_install_isr
71};
72
73static struct i2c_adapter rpx_ops = {
74        .owner          = THIS_MODULE,
75        .name           = "m8xx",
76        .id             = I2C_HW_MPC8XX_EPON,
77        .algo_data      = &rpx_data,
78};
79
80int __init i2c_rpx_init(void)
81{
82        printk("i2c-rpx.o: i2c MPC8xx module version %s (%s)\n", I2C_VERSION, I2C_DATE);
83
84        /* reset hardware to sane state */
85        rpx_iic_init(&rpx_data);
86
87        if (i2c_8xx_add_bus(&rpx_ops) < 0) {
88                printk("i2c-rpx: Unable to register with I2C\n");
89                return -ENODEV;
90        }
91
92        return 0;
93}
94
95void __exit i2c_rpx_exit(void)
96{
97        i2c_8xx_del_bus(&rpx_ops);
98}
99
100MODULE_AUTHOR("Dan Malek <dmalek@jlc.net>");
101MODULE_DESCRIPTION("I2C-Bus adapter routines for MPC8xx boards");
102
103module_init(i2c_rpx_init);
104module_exit(i2c_rpx_exit);
Note: See TracBrowser for help on using the browser.